Making Makeshift
"This is like when those tribal people venture out in the desert to endure great pains to finally become a man! Some kind of ancestor tribute" - loaderror
Commodore 64 crash course
commodore 64
- CPU: MOS 6510
- Slightly-modified 6502
- 0.985mhz in PAL regions
- Memory: 64 kilobytes
- Shared (mostly) memory architecture, no separate VRAM (except 4-bit color RAM, but that's CPU-accessible directly)
- Graphics resolution: 320x200 pixels
- LOTS of caveats here, but that's mostly what's used in this demo
- Release date: August 1982
commodore 64 (cot'd)
- Audio: SID (6581/8580)
- Three channels, multiple waveforms, analog filter(!)
- OS: KERNAL + Commodore BASIC
- Yes, KERNAL is spelled correctly
- Mostly we bank these out, except for using BASIC for jumpstart and table gen
The demo
project goals
project goals
- Finally release a c64 prod
- At Solskogen! :)
- Play with compression
- Specifically a different technique than for 64k
- Show off a new effect I hadn't seen before on the platform :)
- Experiment with a "full demo in 4k"-ish style
- There are a lot of c64 4k's, but most don't give me this feeling at least
- Little need for pixel art :)
tools
tools
- kickassembler
- make
- admiral p4kbar
- custom packer, as we'll see later
- vice
- very very very good and accurate emulator!
- aseprite
- rust
- various text editors
- 1k play
PACKING
admiral p4kbar
- Custom packer
- LZ(SS)-based
- Lightning-fast decompression
- Small unpacker
- Slow packer (depending on impl and params)
- Literals/backreferences
- Encoding is where the magic is!
- Competitive with existing c64 packers
- ~100 bytes worse than the best
- But I did it myself :)
- Full control of mem layout, unpacker, etc.
unpacking stages
unpacking stages
- Stage 1: Autostart
- The first bytes of the intro are a small BASIC program, that jumps to a subroutine located directly after
Load address (2 bytes, little-endian)
BASIC program
"10 sys 2061"
Machine code program (2061)
unpacking stages
- Stage 2: Relocation
- We want to extend the BASIC program with some table generation stuff when decompressing, but that would clobber our compressed data, so let's move it (and the next unpacker stage) out of the way first!
- Super simple 8kb copy
- 8kb, not 4kb, for some wiggle room during testing
- Jump at the end to the relocated code/data
Unpacking stages
- Stage 3: decompression
- Unpack the newly-relocated data
Making Makeshift
By yupferris
Making Makeshift
"This is like when those tribal people venture out in the desert to endure great pains to finally become a man! Some kind of ancestor tribute" - loaderror
- 621