Putting a VIC program into a QR code
Moderator: Moderators
Putting a VIC program into a QR code
Anyone want to work with me on an idea? I want to create a QR code system for unexpanded VIC games. I figure I can get about 3k into one. It sounds pretty pointless, I know. Or maybe it's already been done.
- Mike
- Herr VC
- Posts: 4841
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Putting a VIC program into a QR code
Any successful interpretation of the QR code is at the discretion of the scanning device. IMO, the most straightforward application would not be including a complete *.prg file into the QR code, rather just providing a URL of (semi-)permanent file storage.Jeff-20 wrote:I figure I can get about 3k into one.
Re: Putting a VIC program into a QR code
But I just read a 177x177 qr grid (with error correction) could store up to 2953 bytes. A link wouldn't be interesting. I was thinking of a whole program in the actual code. Certainly smart phones have no problem with 177x177.Mike wrote: ↑Sun Aug 09, 2020 1:22 pmAny successful interpretation of the QR code is at the discretion of the scanning device. IMO, the most straightforward application would not be including a complete *.prg file into the QR code, rather just providing a URL of (semi-)permanent file storage.Jeff-20 wrote:I figure I can get about 3k into one.
- Mike
- Herr VC
- Posts: 4841
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Putting a VIC program into a QR code
It should be entirely possible to encode a *.prg file this way, yes.Jeff-20 wrote:I was thinking of a whole program in the actual code.
Sure. But then the file still has to find its way to the emulator on the phone, or from the phone to the PC running VICE. Or whatever. As I implied, both appliances should be capable of downloading the same file per URL.Certainly smart phones have no problem with 177x177.
BTW, we had something like this already more than 25 years ago: mc Paper Disk.
Re: Putting a VIC program into a QR code
I was inspired by the Nintendo E-reader cards. Of course there is no practical purpose. It's just a silly project. I imagined a phone app (with a built in emulator) that would receive programs by code. Too silly, now that I write it.Mike wrote: ↑Mon Aug 10, 2020 1:34 amSure. But then the file still has to find its way to the emulator on the phone, or from the phone to the PC running VICE. Or whatever. As I implied, both appliances should be capable of downloading the same file per URL.Certainly smart phones have no problem with 177x177.
BTW, we had something like this already more than 25 years ago: mc Paper Disk.
- joshuadenmark
- Big Mover
- Posts: 1218
- Joined: Sat Oct 23, 2010 11:32 am
- Location: Fr-Havn, Denmark
- Occupation: Service engineer
Re: Putting a VIC program into a QR code
I remember having a video backup system for my first PC, kind of like paperdisk, but stored the data as images on a VHS. Never recovered that backup, but the system was cool and cheap for it’s time.
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
____________________________________________________
In need of a wiki logon - PM me
Re: Putting a VIC program into a QR code
Very interesting! I knew about something similar for digital audio recording upon, called R-DAT. Maybe the same system?joshuadenmark wrote: ↑Mon Aug 10, 2020 5:32 am I remember having a video backup system for my first PC, kind of like paperdisk, but stored the data as images on a VHS. Never recovered that backup, but the system was cool and cheap for it’s time.
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-
Re: Putting a VIC program into a QR code
Can you fit a whole game into a QR code?
https://www.youtube.com/watch?v=ExwqNreocpg
https://www.youtube.com/watch?v=ExwqNreocpg
Re: Putting a VIC program into a QR code
producing the actual QR code should be quite easy, there a a lot of open source libraries for handling QR codes.
As for how to make a VIC20 environment to load it, one could use the web emulator and read the code with the browser webcam capabilities and then process it.
As for how to make a VIC20 environment to load it, one could use the web emulator and read the code with the browser webcam capabilities and then process it.
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Putting a VIC program into a QR code
If you updated your web-based emulator to accept a uri-encoded program as a query string, then the QR code would just need to contain a long URL.nippur72 wrote: ↑Wed Sep 09, 2020 1:26 am producing the actual QR code should be quite easy, there a a lot of open source libraries for handling QR codes.
As for how to make a VIC20 environment to load it, one could use the web emulator and read the code with the browser webcam capabilities and then process it.
Edit: I played around with your emulator in the Chrome console. I can't do this with an iframe because modern browsers prohibit cross-origin scripting. But if you've got this project on GitHub, I'd be willing to do the legwork on autoload via query string by submitting a pull request.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: Putting a VIC program into a QR code
@chsyn thanks but it was easy to add so I've just implemented it.
I used the builtin JavaScript functions "btoa()" and "atob()" that encode a binary file from/to ASCII using base64 encoding. The resulting string can passed in the URL as a ?b= ... query string parameter.
The limitations are:
- base64 encoding reduces the maximum file size by 33%
- (not sure) there is a limit on the length of the URL
How it works:
- first create a program on the emulator and save it with the JavaScript console command: save("test.prg") (any name is ok)
- from the same console type the command: makeBase64("test.prg") that will output the URL with the ?b= .... querystring
- optional: use the url to form a QR code
- open the URL in the browser
Example: CLICK ME!!!
or scan this:
I used the builtin JavaScript functions "btoa()" and "atob()" that encode a binary file from/to ASCII using base64 encoding. The resulting string can passed in the URL as a ?b= ... query string parameter.
The limitations are:
- base64 encoding reduces the maximum file size by 33%
- (not sure) there is a limit on the length of the URL
How it works:
- first create a program on the emulator and save it with the JavaScript console command: save("test.prg") (any name is ok)
- from the same console type the command: makeBase64("test.prg") that will output the URL with the ?b= .... querystring
- optional: use the url to form a QR code
- open the URL in the browser
Example: CLICK ME!!!
or scan this:
- Kweepa
- Vic 20 Scientist
- Posts: 1315
- Joined: Fri Jan 04, 2008 5:11 pm
- Location: Austin, Texas
- Occupation: Game maker
Re: Putting a VIC program into a QR code
Wowzers, nice!
Re: Putting a VIC program into a QR code
You, sir, are a genius! This is what I had in mind. I would love to implement a browser emulator to share my programs as well. I have no idea how you did this.
Re: Putting a VIC program into a QR code
unfortunately the browser complains for very long URLs resulting from programs larger than ~2K. That could be mitigated by using some form of compression, anyway I don't think we can embed a 16K or cartdrige with this method.
As for sharing programs, this is certainly a very good application for the emulator (I had this in mind back when Matt' Dawson firstly wrote his VIC20 emulator).
There are three possible routes:
The simplest and quickest one is to host the .prg files directly on my emulator's web site (Github) under the folder software/Jeff-20. Then you can call the game with a link, for example: It came from the grave. For this to work you have to periodically send me a .zip file with all your .prg files you want to share. The advantage is that the emulator is automatically updated; the downside is that you don't have control over your files, I have to manually publish them.
Second way is to host the emulator on your sleepingelephant.com domain along with the .prg files. The steps are:
- get the emulator here
- unzip it in your domain under a "vic20-emu" folder
- the software/Jeff-20 folder is already there, so you don't have to create it
- put any .prg file you wish to share under the software/Jeff-20 folder
- call the emulator with a link like: http://sleepingelephant.com/vic20-emu/i ... Fgrave.prg
The downside is that you have to manually update the emulator when a new release comes out, but you have full control over your files.
There is a third way which is rather difficult, it involves configuring the sleepingelephant HTTP server to allow the so called "CORS" requests from the emulator website. But I am not expert in that.
As for sharing programs, this is certainly a very good application for the emulator (I had this in mind back when Matt' Dawson firstly wrote his VIC20 emulator).
There are three possible routes:
The simplest and quickest one is to host the .prg files directly on my emulator's web site (Github) under the folder software/Jeff-20. Then you can call the game with a link, for example: It came from the grave. For this to work you have to periodically send me a .zip file with all your .prg files you want to share. The advantage is that the emulator is automatically updated; the downside is that you don't have control over your files, I have to manually publish them.
Second way is to host the emulator on your sleepingelephant.com domain along with the .prg files. The steps are:
- get the emulator here
- unzip it in your domain under a "vic20-emu" folder
- the software/Jeff-20 folder is already there, so you don't have to create it
- put any .prg file you wish to share under the software/Jeff-20 folder
- call the emulator with a link like: http://sleepingelephant.com/vic20-emu/i ... Fgrave.prg
The downside is that you have to manually update the emulator when a new release comes out, but you have full control over your files.
There is a third way which is rather difficult, it involves configuring the sleepingelephant HTTP server to allow the so called "CORS" requests from the emulator website. But I am not expert in that.
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Putting a VIC program into a QR code
That’s super-simple. You just need to send an access-control-allow-origin header. It can be configured in the host settings for the server.
Another option is to update the emulator so that it accepts a URL and a code, and pass that info via the QR code. The emulator then makes a POST request for a big program. The server would need to send the program and a response in the right format, looking up its own program based on the code, and would still need to send the cross-origin header. Basically, each developer would implement an interface that you specify.
But great work, even with the size limit!
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his