Jump to content
Thomas Jentzsch

QR Code generation

Recommended Posts

Audacity Games has proved that it is possible to generate a QR-code on-the-fly using a stock 6507 with 128 bytes of RAM. Since it is currently unlikely that they will share their code (someone should still ask them), we will try do the same. This topic is here to discuss, collect info and hopefully develop a working code which everybody can embed into their own projects.

 

The source code of my QR code generator can be found here.

 

Here are some useful links:

Edited by Thomas Jentzsch
  • Like 8

Share this post


Link to post
Share on other sites

Given the number of info we want to submit, I suppose we need a 25x25 code. This allows for to 47 alphanumeric symbols using minimal error correction. We have to find out how robust a QR code displayed on a CRT is to define the required error correction. Audacity Games uses a 21x21 code, we should check the error correction level they use.

 

Using the playfield to display 25 QR-pixel horizontally, we need 100 pixel. The aspect ratio is about 1:1.6, so that results into 160 vertical pixel. Which still should fit easily on each display. Else we would have to check how square the pixels have to be. 

Edited by Thomas Jentzsch
  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Thomas Jentzsch said:

with 128 bytes of RAM

Probably considerably less, since you cannot throw way the game state... (If is just dynamic in end game screen, they can probably use more memory...) 

 

3 minutes ago, Thomas Jentzsch said:

Audacity Games uses a 21x21 code, e should check the error correction level they use.

https://www.qrcode.com/en/about/version.html

You cannot use alphanumeric since only supports uppercase, you have to use binary for URLs.
For the manual admg.us/gg01 they can only use up to 15% error correction.

Maybe it is a good idea to try the same before changing to 25 by 25, I can reduce my url (git.io) and drop the https:// part (they did that, not recommended, but all QR codes readers work fine). My current error correction is 7% ... Maybe 15% will solve my issues. They probably tested this several times...

 

12 minutes ago, Thomas Jentzsch said:

we would have to check how square the pixels have to be. 

As square as possible according to specs. But my tests shows that QR readers are very tolerant... 25 by 25 is the limit for square pixels in the recommended drawing area of the TV.

I let you know my findings.
 

  • Like 2

Share this post


Link to post
Share on other sites
3 minutes ago, Octavio Pinho Bokel said:

You cannot use alphanumeric since only supports uppercase, you have to use binary for URLs.

Ouch, you are right. So 21x21 with level M error correction (15%) would only allow for up to 14 data symbols. That seems pretty limited. Can they even encode enough information into so few symbols? Let's see:

 

image.png

 

They need:

  • adgm.us/ (that's already 8 symbols)
  • Game Time (5 digits, encoded into 3 binary symbols)
  • Stars (1 binary symbol)
  • Cart-Id (might be the serial number, 2 binary symbols)

That's exactly 14 symbols. And then there is the platform, but there are free bits in the other elements.

 

BTW: Does a browser understand binary symbols? I suppose the QR-Reader converts them, right?

 

15 minutes ago, Octavio Pinho Bokel said:

Maybe it is a good idea to try the same before changing to 25 by 25. 

I think we should go for 25x25. Anything below is not versatile enough.

  • Like 1

Share this post


Link to post
Share on other sites
18 minutes ago, Octavio Pinho Bokel said:

Probably considerably less, since you cannot throw way the game state... (If is just dynamic in end game screen, they can probably use more memory...) 

IIRC there are QR codes for help pages, which can be opened during the game. But maybe these are hard coded.

Share this post


Link to post
Share on other sites
3 minutes ago, Thomas Jentzsch said:

IIRC there are QR codes for help pages, which can be opened during the game. But maybe these are hard coded.

I think that is the case for the manual! I did not see their score submission screen, I think it is very unlikely they are using 21 x 21.

Does someone have access to the game and can confirm that (the size)? You don't have to post, we I understand that the QR codes are ultra secret...

Share this post


Link to post
Share on other sites

For a start, here some DASM macro magic to define the Log and Antilog tables as required by the C code mentioned above:

_POLY = %100011101 ; for 0x11d = x^8 + x^4 + x^3 + x^2 + 1
    ECHO "Poly:", _POLY

; macro for calculate antilog and log tables
  MAC ANTI_LOG ; all {0} or for given {_C}
    LIST OFF
_C SET 1
_K SET 0
  REPEAT 255
   IF {1}
    IF {1} == _C
      LIST ON
      .byte   _K
      LIST OFF
      ECHO "log[", _C, "] =", _K
      ;MEXIT ; would abort the outer REPEAT loop, so we have to continue looping
    ENDIF
   ELSE
      LIST ON
      .byte   _C
      LIST OFF
      ECHO "antilog[", _K, "] =", _C
   ENDIF
_C SET _C << 1
    IF _C & $100
_C SET _C ^ _POLY
    ENDIF
_K SET _K + 1
  REPEND
   IF {1} = 0
; antilog[255] = 0 (not 1)
    LIST ON
    .byte   0
    LIST OFF
    ECHO "antilog[", _K, "] =", 0
   ENDIF
  ENDM

AntiLogTbl
    ANTI_LOG 0 ; calculate all

    LIST ON
LogTbl
    .byte   0
    LIST OFF
    ECHO "log[", 0, "] =", 0
_LC SET 1
  REPEAT 255
    ANTI_LOG _LC
_LC SET _LC + 1
  REPEND
    LIST ON

Note: Switching LIST ON and OFF massively reduced the created .lst file and also massively reduced the assemble time. The problem is that the LogTbl has to loop the macro 255*255 times.

Edited by Thomas Jentzsch
  • Like 2

Share this post


Link to post
Share on other sites

OK, Reed Solomon encoding is not a difficult as I thought (or I am wrong). I got it working for (255, 239) as in the C code example from above. I am not 100% sure how this relates to the error correction levels though. This one can correct 8 errors in 255 bytes, which is ~3%. So I suppose for 7% or 15% one would need different codes (e.g. 255, 223).

 

Also I have to look into "padding" yet. 

QRCode_002.asm

  • Like 2

Share this post


Link to post
Share on other sites
2 hours ago, Octavio Pinho Bokel said:

Binary is just the default QR way to encode ISO-8859-1... Almost all QR codes use it.

I found that alphanumeric encoding might do it for out task too. It allows upper case letters, numbers and a few special chars (Space, $, %, *, +, −, /, ., :). Two chars are encoded into 11 bits. 

 

But probably the encoding overhead is not worth it.

Edited by Thomas Jentzsch

Share this post


Link to post
Share on other sites
4 hours ago, Octavio Pinho Bokel said:

Does someone have access to the game and can confirm that (the size)? You don't have to post, we I understand that the QR codes are ultra secret...

Where does it say that the codes are supposed to be secret? Was this a request from the folks at Audacity?

Share this post


Link to post
Share on other sites

Been looking at this from the 7800 side.

 

I reached the earlier conclusion here about alphanumeric not supporting proper URL encoding. I think it's questionable that all QR readers would turn these into proper links (since URLs are case-sensitive, i anticipate many not bothering)

 

v3 29x29 doesn't seem out of question. With the aspect ratio of the 2600 and 7800, you'd need 6.89 lines vertical for perfectly square pixels based around 2600 PF pixels or 7800 characters. If you drop that to 6, you get a 32x32 display, with 15% distortion. IMO that's good enough. People use monospace fonts to embed QR codes in reddit posts, and those are nowhere near square.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
21 minutes ago, Karl G said:

Where does it say that the codes are supposed to be secret? Was this a request from the folks at Audacity?

No, but you could maybe(!) use other peoples codes for faking their scores.

  • Like 1

Share this post


Link to post
Share on other sites
9 minutes ago, RevEng said:

I reached the earlier conclusion here about alphanumeric not supporting proper URL encoding. I think it's questionable that all QR readers would turn these into proper links (since URLs are case-sensitive, i anticipate many not bothering)

Depends on the webserver, AFAIK (e.g. IIS is not case-sensitive). So maybe we can ignore case. But that's academic for now. First we have to solve more major problems. :) 

12 minutes ago, RevEng said:

v3 29x29 doesn't seem out of question. With the aspect ratio of the 2600 and 7800, you'd need 6.89 lines vertical for perfectly square pixels based around 2600 PF pixels or 7800 characters. If you drop that to 6, you get a 32x32 display, with 15% distortion. IMO that's good enough. People use monospace fonts to embed QR codes in reddit posts, and those are nowhere near square.

Why do you get a 32x32 display from 29x29? Also I think 29 * 7 = 203 should work on any display (unless 7800 is preventing that, no clue).

Share this post


Link to post
Share on other sites

32x32 was just what I figured was the maximum with PF and character resolution and being nearly square, and dialing back a bit on the squareness; a back-of-the-envelope calculation of what was possible. Of course 29x29 is the goal.

 

203 would be fine on either platform, but the further we go past 192, the more rounding distortion we get on CRTs, which I anticipate is going to be more problematic than non-square pixels.

Share this post


Link to post
Share on other sites
2 minutes ago, RevEng said:

203 would be fine on either platform, but the further we go past 192, the more rounding distortion we get on CRTs, which I think is anticipate is going to be more problematic than non-square pixels.

Agreed, that's worth considering. At least the QR-code will be displayed (almost) centered, so it won't extend to the corners. Which are even worse on old CRTs.

  • Like 1

Share this post


Link to post
Share on other sites

Yes, in total I am calculating with one extra empty pixel row at top and bottom minimum.

Share this post


Link to post
Share on other sites
7 hours ago, Thomas Jentzsch said:

Can they even encode enough information into so few symbols?

 

They did it by using two 21x21 QR Codes, not one:

  1. URL to a logon page
  2. encoded score/time/etc info

 

after logging in the Audacity website accesses your camera to scan the second QR Code.

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
24 minutes ago, SpiceWare said:

They did it by using two 21x21 QR Codes, not one:

:thumbsup:

 

Cheaters! :D

  • Like 1

Share this post


Link to post
Share on other sites

25 by 25 seams like the perfect trade off, at least for static ones, I just updated my game to use it. 25 by 25 is also the limit that the QR code would be in the recommended 192 lines, have some bleeding space and be square. I think is the perfect trade off.

For dynamic ones, it might increase memory requirement beyond what Atari can offer... This might be the reason they use 21x21.

 

41 minutes ago, SpiceWare said:

 

They did it by using two 21x21 QR Codes, not one

I see, this explains everything!

Edited by Octavio Pinho Bokel

Share this post


Link to post
Share on other sites
8 hours ago, Thomas Jentzsch said:

Audacity Games has proved that it is possible to generate a QR-code on-the-fly using a stock 6507 with 128 bytes of RAM.

Didn't The Stacks generate a QR code?  Weren't you involved with that game?

Share this post


Link to post
Share on other sites
1 hour ago, Wrathchild said:

would https://github.com/pfusik/datamatrix6502 be of any use?

 

used in High Score collection - https://xxl.atari.pl/hsc/

That would probably be simpler, but people are much more used to QR codes. And many today's smartphone have QR-code readers ready out of the box.

Share this post


Link to post
Share on other sites
Just now, trapperkeeper said:

Didn't The Stacks generate a QR code?  Weren't you involved with that game?

Yes. But that's a static code. That won't work here.

 

I wasn't involved in the first version (with the QR code), only (still) working on extending the game into something with more replay value.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...