Putting a VIC program into a QR code

You need an actual VIC.

Moderator: Moderators

User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Putting a VIC program into a QR code

Post by Jeff-20 »

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.
High Scores, Links, and Jeff's Basic Games page.
User avatar
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

Post by Mike »

Jeff-20 wrote:I figure I can get about 3k into one.
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.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Putting a VIC program into a QR code

Post by Jeff-20 »

Mike wrote: Sun Aug 09, 2020 1:22 pm
Jeff-20 wrote:I figure I can get about 3k into one.
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.
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.
High Scores, Links, and Jeff's Basic Games page.
User avatar
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

Post by Mike »

Jeff-20 wrote:I was thinking of a whole program in the actual code.
It should be entirely possible to encode a *.prg file this way, yes.
Certainly smart phones have no problem with 177x177.
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. :wink:

BTW, we had something like this already more than 25 years ago: mc Paper Disk.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Putting a VIC program into a QR code

Post by Jeff-20 »

Mike wrote: Mon Aug 10, 2020 1:34 am
Certainly smart phones have no problem with 177x177.
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. :wink:

BTW, we had something like this already more than 25 years ago: mc Paper Disk.
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. :lol:
High Scores, Links, and Jeff's Basic Games page.
User avatar
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

Post by joshuadenmark »

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
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Putting a VIC program into a QR code

Post by Noizer »

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.
Very interesting! I knew about something similar for digital audio recording upon, called R-DAT. Maybe the same system?
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
JavaJack
Vic 20 Drifter
Posts: 39
Joined: Fri May 30, 2014 10:19 am

Re: Putting a VIC program into a QR code

Post by JavaJack »

Can you fit a whole game into a QR code?
https://www.youtube.com/watch?v=ExwqNreocpg
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Putting a VIC program into a QR code

Post by nippur72 »

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.
User avatar
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

Post by chysn »

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.
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.

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
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Putting a VIC program into a QR code

Post by nippur72 »

@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:
qr-code.png
qr-code.png (9.69 KiB) Viewed 847 times
User avatar
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

Post by Kweepa »

Wowzers, nice!
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: Putting a VIC program into a QR code

Post by Jeff-20 »

nippur72 wrote: Sun Sep 13, 2020 3:47 am ...
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.
High Scores, Links, and Jeff's Basic Games page.
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Putting a VIC program into a QR code

Post by nippur72 »

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.
User avatar
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

Post by chysn »

nippur72 wrote: Sat Sep 26, 2020 4:23 am 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.
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
Post Reply