News for hackers. Stuff that matters.
Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by vidarh on Sunday November 08, 2015 @01:18PM (#10529268)
A bit disappointingly (not meant as a complaint against the authors, it's fun to see them squeeze it into the small space nevertheless) the mechanism used to make the "polyglot" part work is very simple:

The C64 doesn't care at all what it loads. It just treats the first two bytes as an address to load the data into (not used unless you explicitly request it with an extra flag when loading). So it loads the whole file, excluding the first two bytes but including the html/js, straight into memory.

The browser, on the other hand, accepts pretty much any junk prior to the body tag and ignores it.

So this is just one of those cases where two formats can pretty much just be concatenated.

It'd be fun to use the same mechanism to have the two programs e.g. share data tables.

Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by svenfaw on Sunday November 08, 2015 @02:08PM (#10529430)
Making the polyglot was the easy part, definitely. I just thought it would be interesting to see if it would actually load and run on a C64.

By the way, a simple way to test it if you don't have a real C64 at hand is using the CCS64 emulator: Just drag and drop the .PRG file onto it.

Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by vidarh on Monday November 09, 2015 @03:27PM (#10535576)
Oh, it's cool. And clever. Part of my "disappointment" was that I hadn't thought through how simple it would be, and so was half expecting some crazy trickery.
Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by PhasmaFelis on Sunday November 08, 2015 @03:31PM (#10529757)
This doesn't disappoint me at all, honestly. I knew it had to be some kind of trick, and it is, but it's quite a clever trick.
Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by vidarh on Monday November 09, 2015 @01:59PM (#10535001)
My "disappointment" was that they didn't do something really tricky.. It's clever, but also very simple.
Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by oneJob on Sunday November 08, 2015 @12:40PM (#10529136)
Conway's Game of Life appears to be a very fit species based on the length of the period for which it has successfully reproduced as well as the varied environments in which it has successfully reproduced.
Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by ruk_booze on Sunday November 08, 2015 @03:59PM (#10529878)
W00t! That's my old 256b C64 version of Conway's Game of Life :)

http://csdb.dk/release/?id=104384

Re:Conway's Polyglot: 1K file runs Game of Life both in the ... by dtech on Sunday November 08, 2015 @01:22PM (#10529279)
Looking at the source it seems like it is a concatenation of a binary file (presumably the C64 binary) and some HTML, which hides the binary content through CSS. The HTML is probably in the data part of the C64 binary.

Interesting, but nowhere near as amazing as if you e.g. made a file that somehow both was a valid C64 binary and valid browser-interpretable (HTML/JS/whatever) file.