Thomas Jentzsch Posted April 7, 2021 Share Posted April 7, 2021 (edited) 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: https://www.embeddedrelated.com/showarticle/1182.php (Solomon-Reed error correction in C) https://www.thonky.com/qr-code-tutorial/ (extensive tutorial about QR code generation) https://github.com/nayuki/QR-Code-generator (QR code generator library with source code for various programming languages) https://www.nayuki.io/page/creating-a-qr-code-step-by-step (QR code generation explained step by step) http://qrlogo.kaarposoft.dk/qrdecode.html (QR code check, with debug info) Edited April 12, 2021 by Thomas Jentzsch 9 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 (edited) 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 April 7, 2021 by Thomas Jentzsch 1 Quote Link to comment Share on other sites More sharing options...
Octavio Pinho Bokel Posted April 7, 2021 Share Posted April 7, 2021 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. 2 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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: 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. 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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. Quote Link to comment Share on other sites More sharing options...
Octavio Pinho Bokel Posted April 7, 2021 Share Posted April 7, 2021 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... Quote Link to comment Share on other sites More sharing options...
Octavio Pinho Bokel Posted April 7, 2021 Share Posted April 7, 2021 8 minutes ago, Thomas Jentzsch said: BTW: Does a browser understand binary symbols? I suppose the QR-Reader converts them, right? Binary is just the default QR way to encode ISO-8859-1... Almost all QR codes use it. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 (edited) 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 April 7, 2021 by Thomas Jentzsch 2 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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 2 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 (edited) 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 April 7, 2021 by Thomas Jentzsch Quote Link to comment Share on other sites More sharing options...
+Karl G Posted April 7, 2021 Share Posted April 7, 2021 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? Quote Link to comment Share on other sites More sharing options...
RevEng Posted April 7, 2021 Share Posted April 7, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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). Quote Link to comment Share on other sites More sharing options...
RevEng Posted April 7, 2021 Share Posted April 7, 2021 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. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
vitoco Posted April 7, 2021 Share Posted April 7, 2021 Be careful!!! Margins are important... There should be enough blank area surrounding the QR. 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 Yes, in total I am calculating with one extra empty pixel row at top and bottom minimum. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted April 7, 2021 Share Posted April 7, 2021 (edited) would https://github.com/pfusik/datamatrix6502 be of any use? used in High Score collection - https://xxl.atari.pl/hsc/ Edited April 7, 2021 by Wrathchild added 'use' 3 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted April 7, 2021 Share Posted April 7, 2021 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: URL to a logon page encoded score/time/etc info after logging in the Audacity website accesses your camera to scan the second QR Code. 2 1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 24 minutes ago, SpiceWare said: They did it by using two 21x21 QR Codes, not one: Cheaters! 1 Quote Link to comment Share on other sites More sharing options...
Octavio Pinho Bokel Posted April 7, 2021 Share Posted April 7, 2021 (edited) 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 April 7, 2021 by Octavio Pinho Bokel Quote Link to comment Share on other sites More sharing options...
trapperkeeper Posted April 7, 2021 Share Posted April 7, 2021 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? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 7, 2021 Author Share Posted April 7, 2021 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.