fire: update to v1.2 with 64-byte fire_extreme

This commit is contained in:
Vince Weaver 2019-01-03 20:27:43 -05:00
parent e14ec89248
commit 7e44173ef4
4 changed files with 54 additions and 106 deletions

3
fire/fe_monitor Normal file
View File

@ -0,0 +1,3 @@
70: 2c 50 c0 20 70 fc a9 ff 99 cf 07 88 d0 fa a9 16 85 25 20 22 fc a0 27 a5 4e f0 05 0a f0 04 90 02 49 1d 85 4e 30 09 b1 28 29 07 aa b5 a8 91 28 88 10 e5 c6 25 10 dc 30 cb 00 bb 00 aa 00 99 00 dd
70G

Binary file not shown.

View File

@ -1,149 +1,84 @@
; Lo-res fire animation, size-optimized ; Apple ][ Lo-res fire animation, size-optimized to 64 bytes
; by deater (Vince Weaver) <vince@deater.net> ; by deater (Vince Weaver) <vince@deater.net>
; based on code described here http://fabiensanglard.net/doom_fire_psx/ ; originally based on code described here
; http://fabiensanglard.net/doom_fire_psx/
; but this is a slightly different algorithm (but still cool looking)
; Optimization history:
; 80 bytes -- the size of tire_tiny.s
; 64 bytes -- use the firmware SCROLL routine to handle the scrolling
; this adds some flicker but saves many bytes
; 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
; 107 bytes -- replace self-modifying load/store absolute with Y-indirect
; 106 bytes -- assume bit 8 is as random as bit 0
; 82 bytes -- use VTAB in firmware to setup addresses
; (Antoine Vignau on comp.sys.apple2 reminded me of this)
; 81 bytes -- qkumba points out that GR leaves BASL:BASH pointing at line 23
; so we can use Y-indirect of BASL to draw the bottom white line
; 83 bytes -- remove use of X as counter, use CV instead
; 83 bytes -- tried flipping x/y loops in case it allowed more optimization
; but the display runs way too slow in that case
; 81 bytes -- call LF to increment CV + VTAB all at once
; 80 bytes -- re-arrange how the random stuff happens. remove last BIT hack
; Zero Page ; Zero Page
SEEDL = $4E
TEMP = $00 WNDTOP = $22
TEMPY = $01 WNDBTM = $23
OUTL = $04
OUTH = $05
CV = $25 CV = $25
BASL = $28 BASL = $28
BASH = $29 BASH = $29
H2 = $2C SEEDL = $4E
COLOR = $30
; 100 = $64
; Soft Switches ; Soft Switches
SET_GR = $C050 ; Enable graphics SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text FULLGR = $C052 ; Full screen, no text
LORES = $C056 ; Enable LORES graphics LORES = $C056 ; Enable LORES graphics
; monitor routines ; Monitor ROM routines. Try to use well-known entry points as
ASOFT_GR = $F390 ; these did sometimes change with newer models
MON_SETGR = $FB40 SCROLL = $FC70
VTAB = $FC22 ; takes row in CV, Result is in BASL:BASH ($28/$29)
; VTAB notes VTABZ = $FC24 ; VTABZ variant vakes row in Accumulator
; if Applesoft ROM, we can jump to ASOFT_VTAB which takes value in X
; this won't work on the original Apple II with Integer ROM
; we can jum to MON.TABV instead but then have to copy the value
; to Accumulator first
; This ovewrites CV (25)
; Result is in BASL:BASH (28/29)
ASOFT_VTAB = $F25A
MON_TABV = $FB5B
VTAB = $FC22
VTABZ = $FC24
LF = $FC66
fire_demo: fire_demo:
; GR part ; Set lores graphics
bit SET_GR ; force lores mode ; 3 bit SET_GR ; force graphics mode ; 3
; bit FULLGR ; set by default at bootup? ; happily at bootup FULLGR and LORES
; seem to already be in the right positions
; so we get LORES 40x48 mode
; Setup white line on bottom ; Set window. This seems to be set properly at boot though
; lda #0
; sta WNDTOP
; lda #24
; sta WNDBTM
; note: calling HLINE in firmware would take at least 13 bytes
; below code is 9
; we depend on the call to MON_SETGR leaving BASL:BASH set for line 39
; (thanks to qkumba)
CLEOL2 = $FCA0 ; on original II, they got rid of it on IIe :(
; lda #$ff ; 2 bytes shorter on II/II+
; ldy #0
; jsr CLEOL2
SCROLL = $FC70
WNDTOP = $22
WNDBTM = $23
; lda #0
; sta WNDTOP
; lda #24
; sta WNDBTM
scroll_loop: scroll_loop:
KEYPRESS= $C000 jsr SCROLL ; scrolls screen up one row ; 3
KEYRESET= $C010
;repeat1: ;======================================
; lda KEYPRESS ; re-draw bottom line (row 23) as white
; bpl repeat1
; bit KEYRESET
jsr SCROLL lda #$ff ; top/bottom white ; 2
; ldy #39 ; Y is left at 40 after SCROLL
lda #$ff ; 2
; dey ; y is 40 after SCROLL
; ldy #39 ; 2
w_loop: w_loop:
sta $7cf,Y ; hline 23 (46+47) ; 2 sta $7cf,Y ; hline 23 (46+47) ; 2
dey ; 1 dey ; 1
bne w_loop ; 2 bne w_loop ; 2
;============ ;============
; 9 ; 8
fire_loop: fire_loop:
lda #22 ; start at line 22 ; 2 lda #22 ; start at line 22 ; 2
sta CV ; ; 2 sta CV ; store in Row location ; 2
yloop: yloop:
; puts address of row CV into BASL:BASH ; puts address of row CV into BASL:BASH
jsr VTAB ; 3 jsr VTAB ; 3
ldy #39
; loop for X values 39 ... 0
ldy #39 ; 2
xloop: xloop:
;============================= ;=============================
@ -164,8 +99,10 @@ noEor: sta SEEDL ; 2
; end inlined RNG ; end inlined RNG
; Randomly either use current value, or decay by one
bmi no_change ; assume bit 7 is as random as bit 0 ; 2 bmi no_change ; assume bit 7 is as random as bit 0 ; 2
; Lookup the new color in table
lda (BASL),Y ; load value ; 2 lda (BASL),Y ; load value ; 2
and #$7 ; mask off ; 2 and #$7 ; mask off ; 2
tax ; 1 tax ; 1

View File

@ -1,4 +1,12 @@
5 HOME 5 HOME
10 PRINT "FIRE DEMO V1.2" 10 PRINT "FIRE DEMO V1.2 BY DEATER"
40 PRINT:PRINT 40 PRINT:PRINT
105 PRINT CHR$ (4)"BRUN FIRE_EXTREME" 50 PRINT "WHICH DEMO DO YOU WISH TO RUN?"
60 PRINT "1. FIRE_TINY (105 BYTES)"
70 PRINT "2. FIRE_FIRMWARE (80 BYTES)"
80 PRINT "3. FIRE_EXTREME (64 BYTES)"
90 INPUT A
100 IF A=1 THEN PRINT CHR$ (4)"BRUN FIRE_TINY"
110 IF A=2 THEN PRINT CHR$ (4)"BRUN FIRE_FIRMWARE"
120 IF A=3 THEN PRINT CHR$ (4)"BRUN FIRE_EXTREME"
130 GOTO 5