Generating QR Codes

In order to generate our own QR codes natively on the Steckschwein, we drew a lot of inspiration from this article

It even points to an adapted version of the qrtiny library, that has been made to compile with cc65, including a demo for the Apple ][, using cc65’s own Tiny Graphics Interface (TGI). Which is very nice, because all the hard work has already been done.

We have not implemented TGI (yet?), but we do have our rudimentary BGI (Borland Graphics Interface), which is similar. So all that’s left to do is porting the code to BGI, which has proved to be fairly trivial:

  tgi_install (a2_lo_tgi);
  tgi_init ();
  tgi_clear ();
  tgi_bar(x0-2, y0-2, x0+21+2, y0+21+2);

  for (y=0; y<21; y++) {
    for (x=0; x<21; x++) {
      int module = QrTinyModuleGet(buffer, formatInfo, x, y);
      tgi_setcolor(module ? TGI_COLOR_BLACK : TGI_COLOR_WHITE);
      tgi_setpixel(x+x0, y+y0);

Original TGI version

  initgraph(NULL, 3, NULL);

  x0 = getmaxx() / 2 - QRTINY_DIMENSION + 11;
  y0 = getmaxy() / 2 - QRTINY_DIMENSION + 11;

  // graphics_bar(x0-2, y0-2, x0+QRTINY_DIMENSION+2, y0+QRTINY_DIMENSION+2);

  for (y=0; y<QRTINY_DIMENSION; y++) {
    for (x=0; x<QRTINY_DIMENSION; x++) {
      module = QrTinyModuleGet(buffer, formatInfo, x, y);

      putpixel(x+x0, y+y0, module ? BLACK : WHITE);

BGI version

And since it can only generate 21x21 sized QR codes, the VDP “MC” mode with 64x48 pixels is just right:

generated qrcode