diff --git a/pt3_player/Makefile b/pt3_player/Makefile index 85aa6e67..9dcb9817 100644 --- a/pt3_player/Makefile +++ b/pt3_player/Makefile @@ -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 # diff --git a/pt3_player/fire.s b/pt3_player/fire.s index 91bf416b..977ba3c5 100644 --- a/pt3_player/fire.s +++ b/pt3_player/fire.s @@ -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 diff --git a/pt3_player/pageflip.s b/pt3_player/pageflip.s new file mode 100644 index 00000000..f199f5be --- /dev/null +++ b/pt3_player/pageflip.s @@ -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 + diff --git a/pt3_player/pt3_player.s b/pt3_player/pt3_player.s index 3520406f..bb950e00 100644 --- a/pt3_player/pt3_player.s +++ b/pt3_player/pt3_player.s @@ -588,7 +588,7 @@ song_list: .include "interrupt_handler.s" .include "pt3_lib.s" .include "fire.s" - +.include "random16.s" ;========= ; strings diff --git a/pt3_player/random16.s b/pt3_player/random16.s new file mode 100644 index 00000000..ce4df66c --- /dev/null +++ b/pt3_player/random16.s @@ -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 #