program depacker;
uses crt, fastgraph;

var qrCode: string = 'PPPPPPPAcfhOibHKgApLNEkCeMKfEkkgKKfElOoKkfHKJeeLNAcFkFibPPmIOpPDdKnknbDffCpGnEkJJJODFNCEOHJNaEbfphEopIGanGcGaMMDDeFJNijGIJedGPGNmoFpnHADFJODCfNFBMpMkkNccPCFfCLGNNCpdBOLOOCJKPpBldNdaDPOmjPoLAdoFBkhHKOEAojEkemDaNElkCppJElFbJplHKifJApAcBldLNPPPPPPP';
    i0, i1, x, y, dicLA, dicCA, qrBlock : byte;

begin
  InitGraph(5);
  SetColor(1);

  // the 5-bit dictionary has 16 capital letters 'A'..'P' and 16 lowercasers 'a'..'p'
  dicLA := ord('a');
  dicCA := ord('A') - 16; // 16 - second half of dictionary

  // point coordinates
  x := 0;
  y := 0;

  for i0 := 1 to 245 do begin
    case qrCode[i0] of
      'a'..'p': qrBlock := ord(qrCode[i0]) - dicLA;
      'A'..'P': qrBlock := ord(qrCode[i0]) - dicCA;
    end;
    for i1 := 1 to 5 do begin
      if (qrBlock and %10000 > 0) then PutPixel(x,y);
      qrBlock := qrBlock shl 1;
      x := x + 1;
      if (x = 35) then begin
        x := 0;
        y := y + 1;
      end;
    end;
  end;
  ReadKey;
end.
