2018-12-30 06:23:00 +00:00
|
|
|
; Lo-res fire animation, size-optimized
|
|
|
|
|
|
|
|
; by deater (Vince Weaver) <vince@deater.net>
|
|
|
|
|
|
|
|
; based on code described here http://fabiensanglard.net/doom_fire_psx/
|
|
|
|
|
|
|
|
; 611 bytes at first
|
2018-12-30 07:26:08 +00:00
|
|
|
; 601 bytes -- strip out some unused code
|
2018-12-30 06:23:00 +00:00
|
|
|
; 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
|
2018-12-30 07:26:08 +00:00
|
|
|
; 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
|
2018-12-30 07:37:08 +00:00
|
|
|
; 149 bytes -- load into zero page
|
|
|
|
; 140 bytes -- start using zero-page addressing
|
2018-12-30 21:57:19 +00:00
|
|
|
; 139 bytes -- rotate instead of mask for low bit
|
|
|
|
; 138 bytes -- bcs instead of jmp
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
; Zero Page
|
|
|
|
SEEDL = $4E
|
2018-12-30 07:26:08 +00:00
|
|
|
TEMP = $00
|
|
|
|
TEMPY = $01
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 07:26:08 +00:00
|
|
|
; 100 = $64
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
; Soft Switches
|
|
|
|
SET_GR = $C050 ; Enable graphics
|
|
|
|
FULLGR = $C052 ; Full screen, no text
|
|
|
|
LORES = $C056 ; Enable LORES graphics
|
|
|
|
|
2018-12-30 07:26:08 +00:00
|
|
|
; monitor routines
|
|
|
|
GR = $F390
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
fire_demo:
|
|
|
|
|
|
|
|
; GR part
|
2018-12-30 07:26:08 +00:00
|
|
|
jsr GR ; 3
|
|
|
|
bit FULLGR ; 3
|
|
|
|
;==========
|
|
|
|
; 6
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Setup white line on bottom
|
|
|
|
|
2018-12-30 07:26:08 +00:00
|
|
|
lda #$ff ; 2
|
2018-12-30 07:37:08 +00:00
|
|
|
ldy #39 ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
white_loop:
|
2018-12-30 07:37:08 +00:00
|
|
|
sta $7d0,Y ; hline 24 (46+47) ; 3
|
|
|
|
dey ; 1
|
2018-12-30 07:26:08 +00:00
|
|
|
bpl white_loop ; 2
|
|
|
|
;============
|
|
|
|
; 10
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
fire_loop:
|
|
|
|
|
2018-12-30 21:57:19 +00:00
|
|
|
ldx #44 ; 22 * 2 ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
yloop:
|
2018-12-30 21:57:19 +00:00
|
|
|
lda <gr_offsets,X ; 2
|
|
|
|
sta <smc2+1 ; 2
|
|
|
|
lda <gr_offsets+1,X ; 2
|
|
|
|
sta <smc2+2 ; 2
|
|
|
|
lda <gr_offsets+2,X ; 2
|
|
|
|
sta <smc1+1 ; 2
|
|
|
|
lda <gr_offsets+3,X ; 2
|
|
|
|
sta <smc1+2 ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 21:57:19 +00:00
|
|
|
stx TEMPY ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 21:57:19 +00:00
|
|
|
ldy #39 ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
xloop:
|
|
|
|
smc1:
|
2018-12-30 21:57:19 +00:00
|
|
|
lda $7d0,Y ; 3
|
|
|
|
sta TEMP ; 2
|
|
|
|
and #$7 ; mask off ; 2
|
|
|
|
tax ; 1
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 07:26:08 +00:00
|
|
|
;=============================
|
|
|
|
; random8
|
|
|
|
;=============================
|
|
|
|
; 8-bit 6502 Random Number Generator
|
|
|
|
; Linear feedback shift register PRNG by White Flame
|
|
|
|
; http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng
|
|
|
|
|
|
|
|
random8:
|
2018-12-30 06:23:00 +00:00
|
|
|
lda SEEDL
|
2018-12-30 07:26:08 +00:00
|
|
|
beq doEor
|
|
|
|
asl
|
|
|
|
beq noEor ; if the input was $80, skip the EOR
|
|
|
|
bcc noEor
|
|
|
|
doEor: eor #$1d
|
|
|
|
noEor: sta SEEDL
|
|
|
|
|
|
|
|
; end inlined RNG
|
|
|
|
|
2018-12-30 21:57:19 +00:00
|
|
|
ror ; shift into carry ; 1
|
|
|
|
bcc no_change ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
decrement:
|
2018-12-30 21:57:19 +00:00
|
|
|
lda <color_progression,X ; 2
|
|
|
|
bcs done_change ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
no_change:
|
2018-12-30 21:57:19 +00:00
|
|
|
lda TEMP ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
done_change:
|
|
|
|
|
|
|
|
smc2:
|
2018-12-30 21:57:19 +00:00
|
|
|
sta $750,Y ; 3
|
|
|
|
dey ; 1
|
|
|
|
bpl xloop ; 2
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 07:37:08 +00:00
|
|
|
ldx TEMPY
|
2018-12-30 06:23:00 +00:00
|
|
|
|
2018-12-30 07:37:08 +00:00
|
|
|
dex
|
|
|
|
dex
|
2018-12-30 06:23:00 +00:00
|
|
|
bpl yloop
|
|
|
|
|
2018-12-30 07:26:08 +00:00
|
|
|
bmi fire_loop
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
color_progression:
|
2018-12-30 07:26:08 +00:00
|
|
|
.byte $00 ; 8->0 ; 1000 0101
|
|
|
|
.byte $bb ; 9->11 ; 1001 0001
|
|
|
|
.byte 0 ; 10->0 ; 1010 0000
|
|
|
|
.byte $aa ; 11->10 ; 1011 0000
|
|
|
|
.byte 0 ; 12->0 ; 1100 0000
|
|
|
|
.byte $99 ; 13->9 ; 1101 1001
|
|
|
|
.byte $00 ; 14->0 ; 1110 0000
|
|
|
|
.byte $dd ; 15->13 ; 1111 1101
|
2018-12-30 06:23:00 +00:00
|
|
|
|
|
|
|
gr_offsets:
|
|
|
|
.word $400,$480,$500,$580,$600,$680,$700,$780
|
|
|
|
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
|
|
|
|
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0
|
|
|
|
|