fireworks: split out some files

This commit is contained in:
Vince Weaver 2018-09-11 13:58:29 -04:00
parent a0654a0f3c
commit 3fbd3675a9
5 changed files with 187 additions and 172 deletions

View File

@ -17,6 +17,7 @@ FIREWORKS: fireworks.o
ld65 -o FIREWORKS fireworks.o -C ../linker_scripts/apple2_1000.inc
fireworks.o: fireworks.s gr_copy.s random16.s fw.s hgr.s \
vapor_lock.s gr_hline.s \
background_final.inc
ca65 -o fireworks.o fireworks.s -l fireworks.lst

View File

@ -125,62 +125,15 @@ setup_background:
; setup graphics for vapor lock
;==============================
; Clear Page0
lda #$0
sta DRAW_PAGE
lda #$44
jsr clear_gr
; Make screen half green
lda #$11
ldy #24
jsr clear_page_loop
;=====================================================
; attempt vapor lock
; by reading the "floating bus" we can see most recently
; written value of the display
; we look for $55 (which is the grey line)
;=====================================================
; See:
; Have an Apple Split by Bob Bishop
; Softalk, October 1982
; Challenges: each scan line scans 40 bytes.
; The blanking happens at the *beginning*
; So 65 bytes are scanned, starting at adress of the line - 25
; the scan takes 8 cycles, look for 4 repeats of the value
; to avoid false positive found if the horiz blanking is mirroring
; the line (max 3 repeats in that case)
vapor_lock_loop: ; first make sure we have all zeroes
LDA #$11
zxloop:
LDX #$04
wiloop:
CMP $C051
BNE zxloop
DEX
BNE wiloop
LDA #$44 ; now look for our border color (4 times)
zloop:
LDX #$04
qloop:
CMP $C051
BNE zloop
DEX
BNE qloop
jsr vapor_lock ; 6 for rts?
; found first line of black after green, at up to line 26 on screen
; so we want roughly 22 lines * 4 = 88*65 = 5720 + 4550 = 10270
; - 65 (for the scanline we missed) = 10205 - 12 = 10193
jsr gr_copy_to_current ; 6+ 9292
; 10193 - 9298 = 895
; Fudge factor (unknown) -30 = 865
; 10193 - 9298 - 6 = 889
; Fudge factor (unknown) -24 = 865
; GR part
bit LORES ; 4
@ -244,37 +197,8 @@ sloop2:
bit LORES ; 4
;top_loop:
;
;
; ldy #76 ; 2
;
;outer_loop:
;
; bit PAGE0 ; 4
; ldx #12 ; 65 cycles with PAGE0 ; 2
;page0_loop: ; delay 61+bit
; dex ; 2
; bne page0_loop ; 2/3
; bit(4) -1(fallthrough) + loop*5 -1(fallthrouh)+4 extra = 61
; 5L = 55
;
; bit PAGE1 ; 4
; ldx #11 ; 65 cycles with PAGE1 ; 2
; ;
;page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
; dex ; 2
; bne page1_loop ; 2/3
;
; dey ; 2
; bne outer_loop ; 2/3
;
;
;
;bottom_loop:
ldy #20 ; 2
@ -380,54 +304,14 @@ bloop2:
rts ; 6
;==================================
; HLINE
;==================================
; Color in A
; Y has which line
hline:
pha ; 3
ldx gr_offsets,y ; 4+
stx hline_loop+1 ; 4
lda gr_offsets+1,y ; 4+
clc ; 2
adc DRAW_PAGE ; 3
sta hline_loop+2 ; 4
pla ; 4
ldx #39 ; 2
hline_loop:
sta $5d0,X ; 38 ; 5
dex ; 2
bpl hline_loop ; 2nt/3
rts ; 6
;==========================
; Clear gr screen
;==========================
; Color in A
clear_gr:
ldy #46
clear_page_loop:
jsr hline
dey
dey
bpl clear_page_loop
rts
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
.include "gr_hline.s"
.include "../asm_routines/gr_unrle.s"
.include "../asm_routines/keypress.s"
.include "gr_copy.s"
.include "random16.s"
.include "fw.s"
.include "hgr.s"
.include "vapor_lock.s"
background:

View File

@ -196,10 +196,10 @@ done_hill:
; 11
;===============
;==========================================================================
; Move rocket
;===============
; cycles=24+11+20+18+14+53
;==========================================================================
; cycles=24+11+20+18+14+53 = 140
move_rocket:
@ -351,35 +351,41 @@ done_bounds_checking:
;==========================
; if not done, draw rocket
;==========================
;=======================================================================
; draw rocket
;=======================================================================
;
draw_rocket:
lda CURRENT_STEP
cmp MAX_STEPS
beq erase_rocket
lda CURRENT_STEP ; 3
cmp MAX_STEPS ; 3
beq erase_rocket ; ?
; set hcolor to proper white (3 or 7)
clc
lda COLOR_GROUP
adc #3
tax
lda colortbl,X ; get color from table
sta HGR_COLOR
clc ; 2
lda COLOR_GROUP ; 3
adc #3 ; 2
tax ; 2
lda colortbl,X ; get color from table ; 4+
sta HGR_COLOR ; 3
; HPLOT X,Y: X= (y,x), Y=a
ldx X_OLD
lda Y_OLD
ldy #0
jsr hplot0 ; hplot(x_old,y_old);
ldx X_OLD ; 3
lda Y_OLD ; 3
ldy #0 ; 2
jsr hplot0 ; hplot(x_old,y_old); ;6+244
; HPLOT TO X,Y X=(x,a), y=Y
lda XPOS_L
ldx #0
ldy YPOS_H
jsr hglin ; hplot_to(xpos_l,ypos_h);
ldx XPOS_L
ldy #0
lda YPOS_H
jsr hplot0
; lda XPOS_L ; 3
; ldx #0 ; 2
; ldy YPOS_H ; 3
; jsr hglin ; hplot_to(xpos_l,ypos_h); ;?????
erase_rocket:
@ -397,10 +403,16 @@ erase_rocket:
jsr hplot0 ; hplot(x_old,y_old);
; HPLOT TO X,Y X=(x,a), y=Y
lda X_OLD
ldx #0
ldy Y_OLD
jsr hglin ; hplot_to(x_old,y_old);
ldx X_OLD
ldy #0
lda Y_OLD
jsr hplot0
; lda X_OLD
; ldx #0
; ldy Y_OLD
; jsr hglin ; hplot_to(x_old,y_old);
done_with_loop:
@ -414,8 +426,8 @@ done_with_loop:
not_done_with_launch:
; lda #$c0
; jsr WAIT
lda #$c0
jsr WAIT
inc CURRENT_STEP
@ -423,15 +435,16 @@ not_done_with_launch:
;==================================
;======================================================================
; Start explosion near x_old, y_old
;==================================
;======================================================================
; cycles =
;
start_explosion:
lda #0
sta XPOS_H
lda #0 ; 2
sta XPOS_H ; 3
; Set X position
@ -441,7 +454,7 @@ start_explosion:
sec ; 2
sbc #8 ; -8..7 ; 2
clc
vmw:
bmi blahblah
adc X_OLD ; 3
@ -506,9 +519,14 @@ blahblah2:
rts ; 6
;===============================
;==========================================================================
; Continue Explosion
;===============================
;==========================================================================
;
; cycles cpy!=9 : 8+2230+2227+13+5 = 4483
; cpy==9 : 8+ +2227+13+62 = 2310
continue_explosion:
ldy TEMPY ; 3
@ -516,8 +534,12 @@ continue_explosion:
; Draw spreading dots in white
cpy #9 ; 2
beq explosion_erase ; ?
beq explosion_erase ; 3
;===========
; 8
; -1
; hcolor_equals(color_group+3);
lda COLOR_GROUP ; 3
clc ; 2
@ -529,7 +551,10 @@ continue_explosion:
ldx TEMPY ; 3
stx OFFSET ; 3
jsr explosion ; 6+
jsr explosion ; 6+2203
;============
; 2230
explosion_erase:
;======================
@ -545,8 +570,9 @@ explosion_erase:
dex ; 2
stx OFFSET ; 3
jsr explosion ; 6
jsr explosion ; 6+2203
;==============
; 2227
done_with_explosion:
lda #$c0 ;
@ -555,7 +581,11 @@ done_with_explosion:
inc TEMPY ; 5
lda TEMPY ; 3
cmp #10 ; 2
beq explosion_done ; ?
beq explosion_done ; 3
;=============
; 13
; -1
rts ; 6
explosion_done:
@ -571,7 +601,8 @@ explosion_done:
; if 2, then move to state 2 (new random explosion)
rts ; 6
;============
; 62
;===============================
@ -713,11 +744,12 @@ explosion:
;=============================
;=========================================================================
; Draw the stars
;=============================
;=========================================================================
; 7+ 280X + 5
; 16 stars = 4492
.align $100
draw_stars:
; HCOLOR = 3, white (though they are drawn purple)

40
fireworks/gr_hline.s Normal file
View File

@ -0,0 +1,40 @@
;==================================
; HLINE
;==================================
; Color in A
; Y has which line
hline:
pha ; 3
ldx gr_offsets,y ; 4+
stx hline_loop+1 ; 4
lda gr_offsets+1,y ; 4+
clc ; 2
adc DRAW_PAGE ; 3
sta hline_loop+2 ; 4
pla ; 4
ldx #39 ; 2
hline_loop:
sta $5d0,X ; 38 ; 5
dex ; 2
bpl hline_loop ; 2nt/3
rts ; 6
;==========================
; Clear gr screen
;==========================
; Color in A
clear_gr:
ldy #46
clear_page_loop:
jsr hline
dey
dey
bpl clear_page_loop
rts
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

58
fireworks/vapor_lock.s Normal file
View File

@ -0,0 +1,58 @@
;==============================
; setup graphics for vapor lock
;==============================
vapor_lock:
; Clear Page0
lda #$0
sta DRAW_PAGE
lda #$44
jsr clear_gr
; Make screen half green
lda #$11
ldy #24
jsr clear_page_loop
;=====================================================
; attempt vapor lock
; by reading the "floating bus" we can see most recently
; written value of the display
; we look for $55 (which is the grey line)
;=====================================================
; See:
; Have an Apple Split by Bob Bishop
; Softalk, October 1982
; Challenges: each scan line scans 40 bytes.
; The blanking happens at the *beginning*
; So 65 bytes are scanned, starting at adress of the line - 25
; the scan takes 8 cycles, look for 4 repeats of the value
; to avoid false positive found if the horiz blanking is mirroring
; the line (max 3 repeats in that case)
vapor_lock_loop: ; first make sure we have all zeroes
LDA #$11
zxloop:
LDX #$04
wiloop:
CMP $C051
BNE zxloop
DEX
BNE wiloop
LDA #$44 ; now look for our border color (4 times)
zloop:
LDX #$04
qloop:
CMP $C051
BNE zloop
DEX
BNE qloop
rts