pt3: visualize: we have fire

This commit is contained in:
Vince Weaver 2019-05-16 13:03:33 -04:00
parent 435fc84f7b
commit 096151d8ba
6 changed files with 101 additions and 7 deletions

View File

@ -44,7 +44,8 @@ PT3_PLAYER: pt3_player.o
ld65 -o PT3_PLAYER pt3_player.o -C ../linker_scripts/apple2_1000.inc
pt3_player.o: pt3_player.s \
gr_fast_clear.s pt3_lib.s interrupt_handler.s fire.s zp.inc
gr_fast_clear.s pt3_lib.s interrupt_handler.s random16.s fire.s \
zp.inc
ca65 -o pt3_player.o pt3_player.s -l pt3_player.lst
#

View File

@ -17,12 +17,11 @@ fire_init:
clear_fire_loop:
lda #0
ldy #40
ldy #39
clear_fire_line_loop:
beq done_fire_line_loop
sta (FIRE_FB_L),Y
dey
jmp clear_fire_line_loop
bpl clear_fire_line_loop
done_fire_line_loop:
clc
@ -96,12 +95,18 @@ fire_fb_update:
ldy #39
fire_fb_update_loop:
jsr random16
lda SEEDL
and #$1
sta FIRE_Q
; get next line color
lda (FIRE_FB2_L),Y
; adjust it
clc
adc #$ff
sec
sbc FIRE_Q
; saturate to 0
bpl fb_positive

24
pt3_player/pageflip.s Normal file
View File

@ -0,0 +1,24 @@
;==========
; page_flip
;==========
page_flip:
lda DISP_PAGE ; 3
beq page_flip_show_1 ; 2nt/3
page_flip_show_0:
bit PAGE0 ; 4
lda #4 ; 2
sta DRAW_PAGE ; DRAW_PAGE=1 ; 3
lda #0 ; 2
sta DISP_PAGE ; DISP_PAGE=0 ; 3
rts ; 6
page_flip_show_1:
bit PAGE1 ; 4
sta DRAW_PAGE ; DRAW_PAGE=0 ; 3
lda #1 ; 2
sta DISP_PAGE ; DISP_PAGE=1 ; 3
rts ; 6
;====================
; DISP_PAGE=0 26
; DISP_PAGE=1 24

View File

@ -588,7 +588,7 @@ song_list:
.include "interrupt_handler.s"
.include "pt3_lib.s"
.include "fire.s"
.include "random16.s"
;=========
; strings

60
pt3_player/random16.s Normal file
View File

@ -0,0 +1,60 @@
; 16-bit 6502 Random Number Generator
; Linear feedback shift register PRNG by White Flame
; http://codebase64.org/doku.php?id=base:small_fast_16-bit_prng
; The Apple II KEYIN routine increments this field
; while waiting for keypress
;SEEDL = $4E
;SEEDH = $4F
XOR_MAGIC = $7657 ; "vW"
;=============================
; random16
;=============================
; takes:
; not 0, cc = 5+ = 27
; not 0, cs = 5+12+19 = 36
; $0000 = 5+7+19 = 31
; $8000 = 5+6+14 = 25
; $XX00 = 5+6+7+19 = 37
random16:
lda SEEDL ; 3
beq lowZero ; $0000 and $8000 are special values ; 2
asl SEEDL ; Do a normal shift ; 5
lda SEEDH ; 3
rol ; 2
bcc noEor ; 2
doEor:
; high byte is in A
eor #>XOR_MAGIC ; 2
sta SEEDH ; 3
lda SEEDL ; 3
eor #<XOR_MAGIC ; 2
sta SEEDL ; 3
rts ; 6
lowZero:
; 1
lda SEEDH ; 3
beq doEor ; High byte is also zero ; 3
; so apply the EOR
; -1
; wasn't zero, check for $8000
asl ; 2
beq noEor ; if $00 is left after the shift ; 2
; then it was $80
bcs doEor ; else, do the EOR based on the carry ; 3
noEor:
; 1
sta SEEDH ; 3
rts ; 6

View File

@ -35,6 +35,9 @@ CSWH EQU $37
KSWL EQU $38 ; key in routine
KSWH EQU $39
SEEDL EQU $4E
SEEDH EQU $4F
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
@ -120,6 +123,7 @@ FIRE_FB_H EQU $A5
FIRE_FB2_L EQU $A6
FIRE_FB2_H EQU $A7
FIRE_FB_LINE EQU $A8
FIRE_Q EQU $A9
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related