wooky / nes-qr-demo Goto Github PK
View Code? Open in Web Editor NEWQR code generator demo for the NES
License: MIT License
QR code generator demo for the NES
License: MIT License
Need to find a web-based NES emulator that supports the Family BASIC Keyboard.
qrcodegen stores modules (pixels) in memory in the order 76543210. However, the PPU requires them to be in the order 01234567, so bit reversal is required before copying the pixels to the PPU. If qrcodegen can work with bits reversed, some efficiencies can be gotten.
Only background tiles are used to render the QR code. 256 tiles, arranged in a 16x16 grid, produce an image that can have a maximum size of 128x128 pixels, allowing a Version 27 QR code to be displayed.
(Side note, it's somewhat buggy, because tile $00 is reserved as the white tile, so the bottom row(s?) of the generated QR code can spill over into the $1xxx PPU RAM space. That's fine, though, since QR codes are resilient enough against this bug.)
We can also use sprite tiles to increase the number of pixels that can be rendered. We can use 64 tiles of size 8x16. With an effective size of 384 tiles, an image of 19x19 tiles, or 152x152 pixels, can be created. This bumps the maximum version to 33, allowing up to 2,068 characters to be rendered.
Memory usage will increase significantly. To support Version 33, two buffers of 4769 bytes, for a total of 9538 bytes, will be required. This is larger than the maximum PRG RAM window of 8192 bytes. Therefore, #2 will need to be resolved first.
QR code rendering will need to be modified, including rearranging the tile pattern. One way is to have the first 16 rows to be 11 background and 8 sprite tiles wide, and the next 3 rows be 19 background tiles wide. This will use a total of 256 background tiles, 128 sprite tiles, and the maximum allowable 64 OAM objects with 8 sprites per scanline.
This is an extension to #3 and is meant to supersede it.
Version 40, the maximum QR version, has a size of 177x177 pixels, or 23x23 tiles, and supports up to 2953 characters. At a width of 23 tiles, only 11 rows can be displayed due to CHR RAM limitations. By swapping the CHR RAM banks at precise scanlines, the maximum QR code version can be achieved.
After every 11 rows, the CHR RAM bank can be swapped, and the nametable can be reused. As is, three 4KB CHR RAM banks are required, and two bank swaps will be needed mid-frame: one after 11 rows, and one after 22 rows. IF the MMC1 mapper is used, which has no scanline counting, this will be difficult.
Alternatively, if even the rightmost 2 columns are replaced with sprites, 12 rows can be displayed using a single nametable, so only a single bank swap will be needed. This bank swap can be done with a sprite 0 hit, eliminating a lot of complexity. This solution also uses only three 4KB CHR RAM banks: two for background tiles, and one for sprite tiles.
qrcodegen uses two large memory buffers: input text + scratch memory, and generated QR code. During code generation, the input text gets overwritten, and does not appear to be recoverable. For version 27, each buffer is 4001 bytes, for a total of 8002 bytes. PRG RAM supports $2000 bytes, or 8192 bytes, at any time, so there's no way to store a copy of the original text without modifications.
Some ideas as to how to overcome this:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.