; Lo-res fire animation, size-optimized ; by deater (Vince Weaver) ; based on code described here http://fabiensanglard.net/doom_fire_psx/ ; 611 bytes at first ; 601 bytes -- strip out some unused code ; 592 bytes -- don't init screen ; 443 bytes -- remove more dead code ; 206 bytes -- no need to clear screen ; 193 bytes -- un-cycle exact the random16 code ; 189 bytes -- more optimization of random16 code ; 161 bytes -- move to 8-bit RNG ; 152 bytes -- reduce lookup to top half colors (had to remove brown) ; also changed maroon to pink ; 149 bytes -- use monitor GR ; 149 bytes -- load into zero page ; 140 bytes -- start using zero-page addressing ; 139 bytes -- rotate instead of mask for low bit ; 138 bytes -- bcs instead of jmp ; 137 bytes -- BIT nop trick to get rid of jump ; 135 bytes -- push/pull instead of saving to zero page ; 134 bytes -- replace half of lookup table with math ; 119 bytes -- replace that half of lookup table with better math ; 134 bytes -- replace other half of lookup table with math ; 132 bytes -- replace stack with zp loads ; 129 bytes -- use Y instead of X ; 125 bytes -- optimize low byte generationw with branch ; 113 bytes -- make get_row a subroutine ; 112 bytes -- regrettable change to the low-byte code ; 109 bytes -- replace BIT/OR in low calc with an ADC ; Zero Page SEEDL = $4E TEMP = $00 TEMPY = $01 ; 100 = $64 ; Soft Switches SET_GR = $C050 ; Enable graphics FULLGR = $C052 ; Full screen, no text LORES = $C056 ; Enable LORES graphics ; monitor routines GR = $F390 fire_demo: ; GR part jsr GR ; 3 bit FULLGR ; 3 ;========== ; 6 ; Setup white line on bottom lda #$ff ; 2 ldy #39 ; 2 white_loop: sta $7d0,Y ; hline 24 (46+47) ; 3 dey ; 1 bpl white_loop ; 2 ;============ ; 10 fire_loop: ldx #22 ; 22 ; 2 yloop: stx TEMPY ; txa/pha not any better ; 2 ; Self-modify the inner loop so it loads/stores from proper ; low-res address. Generate the proper row memory address jsr get_row ; 3 sty 0 ; 1000 0101 .byte $bb ; 9->11 ; 1001 0001 .byte $00 ; 10->0 ; 1010 0000 .byte $aa ; 11->10 ; 1011 0000 .byte $00 ; 12->0 ; 1100 0000 .byte $99 ; 13->9 ; 1101 1001 .byte $00 ; 14->0 ; 1110 0000 .byte $dd ; 15->13 ; 1111 1101 ; Take row X and convert to address A:Y get_row: ; get low byte ; 000X X00O ; lsr ; 0000 XX00 O ; adc #1 ; 0000 XXOx ; lsr ; 0000 0XXO ; lsr ; 0000 00XX O ; ror txa ; 1 and #$19 ; 2 lsr ; 1 adc #1 ; 2 lsr ; 1 lsr ; 1 tay ; 1 lda