Behind the scenes of a C64 demo Ninja / The Dreams 28C3 Ninja / - - PowerPoint PPT Presentation

behind the scenes of a c64 demo
SMART_READER_LITE
LIVE PREVIEW

Behind the scenes of a C64 demo Ninja / The Dreams 28C3 Ninja / - - PowerPoint PPT Presentation

Behind the scenes of a C64 demo Ninja / The Dreams 28C3 Ninja / The Dreams Behind the scenes of a C64 demo About me Linux kernel hacker embedded systems low level computing prefers limited machines and thats mainly because. . . Ninja /


slide-1
SLIDE 1

Behind the scenes of a C64 demo

Ninja / The Dreams 28C3

Ninja / The Dreams Behind the scenes of a C64 demo

slide-2
SLIDE 2

About me

Linux kernel hacker embedded systems low level computing prefers limited machines and that’s mainly because. . .

Ninja / The Dreams Behind the scenes of a C64 demo

slide-3
SLIDE 3

About me

coding on the C64 since 1988 mainly demo-scene related Zen(?)-like passion

(searching enlightment via excessive practice :))

Ninja / The Dreams Behind the scenes of a C64 demo

slide-4
SLIDE 4

Some more notes

This is a group effort Thanks, Oswald Thanks, Edhellon Thanks, Bubis Thanks, Leon Thanks, AMN Thanks, Dalezy Thanks, Doc Bacardi This is a case study! Yeah, we rock, but others do, too Yeah, C64 rocks, but other platforms do, too

Ninja / The Dreams Behind the scenes of a C64 demo

slide-5
SLIDE 5

C64 facts

CPU: 6502-based, 985248 Hz, three 8-bit registers, 56+

  • pcodes, 13 addressing modes, no multiplication and such

Memory: 64KB RAM, forget the ROM Graphics: 160x200x16 (4 colors per 4x8 cell), Sprites Sound: 3 voices (Triangle. Pulse. . . ), Modulation, Filters Disk: 170KB per disk side, serial interface, handshake Other: 4 cycle-based timers, chainable

Ninja / The Dreams Behind the scenes of a C64 demo

slide-6
SLIDE 6

Design choices

flow dictated by music high pace, effect after effect no obvious filling material avoid empty screens as much as possible no story ”right in your face”

Ninja / The Dreams Behind the scenes of a C64 demo

slide-7
SLIDE 7

Let’s get serious

Showtime!

Warning: Current working state

Ninja / The Dreams Behind the scenes of a C64 demo

slide-8
SLIDE 8

Some terminology

Speedcode unrolled loops usually generated at runtime

LDA sine,x ADC sine,y STA pixel LDA sine+1,x ADC sine+1,y STA pixel+1

Ninja / The Dreams Behind the scenes of a C64 demo

slide-9
SLIDE 9

Some terminology

Speedcode unrolled loops usually generated at runtime

LDA sine,x ADC sine,y STA pixel LDA sine+1,x ADC sine+1,y STA pixel+1

Illegal opcodes undocumented opcodes

  • nly few useful, but those should be used

Ninja / The Dreams Behind the scenes of a C64 demo

slide-10
SLIDE 10

Some terminology

Speedcode unrolled loops usually generated at runtime

LDA sine,x ADC sine,y STA pixel LDA sine+1,x ADC sine+1,y STA pixel+1

Illegal opcodes undocumented opcodes

  • nly few useful, but those should be used

Raster time cycles

Ninja / The Dreams Behind the scenes of a C64 demo

slide-11
SLIDE 11

Things we do

Self modifying code can’t do without code is data, data is code

Ninja / The Dreams Behind the scenes of a C64 demo

slide-12
SLIDE 12

Things we do

Self modifying code can’t do without code is data, data is code Abuse the stack LDA table,x; INX costs 6 cycles PLA costs 4 cycles (and leaves X free!) needs sliding window for interrupts

Ninja / The Dreams Behind the scenes of a C64 demo

slide-13
SLIDE 13

Things we do

Self modifying code can’t do without code is data, data is code Abuse the stack LDA table,x; INX costs 6 cycles PLA costs 4 cycles (and leaves X free!) needs sliding window for interrupts Anarchy! Assume $DC06 LDA #$4C LDA #$04 is our STA $DC04 STA $FFFE jitter counter LDA #$00 LDA #$DC STA $DC05 STA $FFFF . . . . . .

Ninja / The Dreams Behind the scenes of a C64 demo

slide-14
SLIDE 14

Tabled based effects

lots of speedcode and tables ”magic” is in the tables and code generators runs in main loop code too slow, effect too slow chunky modes are common speed measured in fps (50 = good, 25 = well. . . ) ”newschool” effects

Ninja / The Dreams Behind the scenes of a C64 demo

slide-15
SLIDE 15

VIC (register) based effects

less speedcode and tables ”magic” is in the actual code runs in interrupt, must often be cycle exact code too slow, effect impossible usually full resolution (or even increased) speed measured in rasterlines ”oldschool” effects Our team can do both \o/

Example: Bump mapper

Ninja / The Dreams Behind the scenes of a C64 demo

slide-16
SLIDE 16

Tools/Equipment used

Mostly cross-development GFX: ProjectOne, Grafx2, AmicaPaint, Sprite-Char-Edit,

  • ther GFX tools

Music: GoatTracker Code: AS, DreamAss, CA65, TASS Custom Tools: mostly data converters or generators in C, Perl, VB, Java, CBM BASIC V2 Linking: make, exomizer Developer machines: C64, Linux, Win, Mac

EOL can still be annoying

Master machine: Pentium MMX233 running DOS

Ninja / The Dreams Behind the scenes of a C64 demo

slide-17
SLIDE 17

Memory layout

$FFFF ... $2000 free for parts $0F80 music $0700 temporary stuff $0200 loader, buffers, depacker (relocatable) $0100 stack $0000 zeropage

Ninja / The Dreams Behind the scenes of a C64 demo

slide-18
SLIDE 18

Memory layout (Rekmap)

$FFFF ... $2000 free for parts $0F80 music $0700 temporary stuff $0200 loader, buffers, depacker (relocatable) $0100 stack $0000 zeropage

speedcodes tables init code tables variables

Ninja / The Dreams Behind the scenes of a C64 demo

slide-19
SLIDE 19

Memory layout (Rekmap)

$FFFF ... $2000 free for parts $0F80 music $0700 temporary stuff $0200 loader, buffers, depacker (relocatable) $0100 stack $0000 zeropage

speedcodes tables init code tables variables

Ninja / The Dreams Behind the scenes of a C64 demo

slide-20
SLIDE 20

Loading

Custom load routines Serial(!), asynchronous(!!) protocol [rant, rant] demos usually use 2bit + ATN you need custom code in the drive

Some demos use the drive for calculations

was cool to have your own loader, but lots of them crashed a few survived and are commonly used these days Here, our DreamLoad is used

Special feature: Can also run from HD and MMC

You want good compression to minimize loading.

Ninja / The Dreams Behind the scenes of a C64 demo

slide-21
SLIDE 21

Packing

Pimped exomizer (cross, of course) best packer around

can take surprisingly long to pack 40KB

depacking too slow for fast paced demos custom depacker, faster but nearly twice as large (500 byte) tweak the packer: use literals if the gain is not at least ’n’ bit tweaked the parameters for every part

Ninja / The Dreams Behind the scenes of a C64 demo

slide-22
SLIDE 22

Packing

Pimped exomizer (cross, of course) best packer around

can take surprisingly long to pack 40KB

depacking too slow for fast paced demos custom depacker, faster but nearly twice as large (500 byte) tweak the packer: use literals if the gain is not at least ’n’ bit tweaked the parameters for every part A priori knowledge (manual) know your data find symmetries use delta-packing derive tables from other tables . . .

Ninja / The Dreams Behind the scenes of a C64 demo

slide-23
SLIDE 23

Linking

Putting it all together usually parts are developed independently Linking means

Proper init/clean exit rewrite code generators Sync to music Find/create spot to load/depack next part assign resources (memory!) don’t crash don’t create visual/audial glitches don’t be boring

everybody hates it no fame involved, although it is pretty hard

Ninja / The Dreams Behind the scenes of a C64 demo

slide-24
SLIDE 24

Syncing

Music is the reference Music player is called once per frame (usually) a simple counter is used for synchronization loading times are variable since drives are mechanic! don’t even think about the time-of-day clocks, too coarse music players use ”instruments” internally so you can do something on e.g. every drum

Ninja / The Dreams Behind the scenes of a C64 demo

slide-25
SLIDE 25

Once more

Showtime again

Now with pauses and comments

Ninja / The Dreams Behind the scenes of a C64 demo

slide-26
SLIDE 26

Thanks!

ninja@the-dreams.de

Ninja / The Dreams Behind the scenes of a C64 demo