From 6e8bfa4181fce1e6b8e3066f5aee281a768e84b1 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 28 Oct 2023 20:13:34 -0400 Subject: [PATCH] second: have placeholder dot bounce --- demos/second/Makefile | 1 + demos/second/gr_plot.s | 47 +++++++++++++++ demos/second/part14_dotbounce/dots.s | 86 +++++++++++++++++++++++++++- demos/second/qload.s | 1 - demos/second/zp.inc | 3 +- 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 demos/second/gr_plot.s diff --git a/demos/second/Makefile b/demos/second/Makefile index bb08b05f..ba3fec9a 100644 --- a/demos/second/Makefile +++ b/demos/second/Makefile @@ -149,6 +149,7 @@ qload.inc: generate_common QLOAD ./generate_common -a 0x1200 -s clear_bottom qload.lst >> qload.inc ./generate_common -a 0x1200 -s clear_bottoms qload.lst >> qload.inc ./generate_common -a 0x1200 -s clear_screens qload.lst >> qload.inc + ./generate_common -a 0x1200 -s clear_top qload.lst >> qload.inc # ./generate_common -a 0x1200 -s mockingboard_patch qload.lst >> qload.inc # ./generate_common -a 0x1200 -s mockingboard_init qload.lst >> qload.inc diff --git a/demos/second/gr_plot.s b/demos/second/gr_plot.s new file mode 100644 index 00000000..c60c8a22 --- /dev/null +++ b/demos/second/gr_plot.s @@ -0,0 +1,47 @@ + ;================================ + ; plot routine + ;================================ + ; Xcoord in XPOS + ; Ycoord in YPOS + ; color in COLOR +plot: + lda YPOS ; 3 + + lsr ; shift bottom bit into carry ; 2 + + bcc plot_even ; 2nt/3 +plot_odd: + ldx #$f0 ; 2 + bcs plot_c_done ; 2nt/3 +plot_even: + ldx #$0f ; 2 +plot_c_done: + stx MASK ; 3 + + asl ; shift back (now even) ; 2 + tay ; 2 + + lda gr_offsets,Y ; lookup low-res memory address ; 4 + clc ; 2 + adc XPOS ; 3 + sta GBASL ; 3 + + lda gr_offsets+1,Y ; 4 + adc DRAW_PAGE ; add in draw page offset ; 3 + sta GBASH ; 3 + + ldy #0 ; 2 + +plot_write: + lda MASK ; 3 + eor #$ff ; 2 + + and (GBASL),Y ; 5+ + sta COLOR_MASK ; 3 + + lda COLOR ; 3 + and MASK ; 3 + ora COLOR_MASK ; 3 + sta (GBASL),Y ; 6 + + rts ; 6 diff --git a/demos/second/part14_dotbounce/dots.s b/demos/second/part14_dotbounce/dots.s index bdbcb5b6..e97ba11c 100644 --- a/demos/second/part14_dotbounce/dots.s +++ b/demos/second/part14_dotbounce/dots.s @@ -2,6 +2,13 @@ ; this one is a tough one +; TODO: +; 16 of them? Start by falling in, bouncing when hit bottom + +; wide, sine wave it up +; narrow, sine wave it up +; at end, just stop deleting them? draw random + ; ; by deater (Vince Weaver) @@ -17,18 +24,29 @@ spheres_start: ;=================== ; Load graphics ;=================== -load_loop: + + jsr clear_screens ; clear both pages of LORES bit SET_GR bit LORES bit FULLGR bit PAGE1 + lda #4 + sta DRAW_PAGE + +dots_loop: + jsr clear_top + jsr clear_bottom + + ldx #12 horizon_loop: lda gr_offsets_l,X sta OUTL lda gr_offsets_h,X + clc + adc DRAW_PAGE sta OUTH ldy #39 @@ -42,10 +60,61 @@ horizon_inner: cpx #24 bne horizon_loop + lda #15 + sta COUNT +dot_loop: + ; Xcoord in XPOS + ; Ycoord in YPOS + ; color in COLOR - jsr wait_until_keypress + ldx COUNT + lda wide_points_x,X + sta XPOS + lda wide_points_y,X + sta YPOS + lda #$66 ; light blue + sta COLOR + + jsr plot + + dec COUNT + bpl dot_loop + + jsr page_flip + + + ; move dots + + ldx #15 +move_dot_loop: + lda wide_points_y,X + clc + adc dot_direction,X + sta wide_points_y,X + cmp #40 + bcs dot_reverse ; bge + cmp #1 + bcc dot_reverse ; blt + bcs dot_good +dot_reverse: + lda dot_direction,X + eor #$FF + sta dot_direction,X + inc dot_direction,X + +dot_good: + dex + bpl move_dot_loop + + + + lda KEYPRESS + bmi dots_done + + jmp dots_loop dots_done: + bit KEYRESET rts @@ -55,6 +124,7 @@ dots_done: .include "../gr_copy.s" .include "../gr_offsets_split.s" .include "../gr_offsets.s" + .include "../gr_plot.s" .include "../wait_keypress.s" @@ -64,4 +134,16 @@ dots_done: ; .include "../hgr_copy_fast.s" +wide_points_x: + .byte 8,11,17,25,30,28,20,13 + .byte 9,14,21,28,30,24,17,11 +wide_points_y: +; .byte 19,16,12,11,14,18,20,21 +; .byte 18,13,11,12,16,19,20,20 + .byte 9, 6 ,2,1,4,8,10,11 + .byte 15,12, 8,7,10,14,16,17 + +dot_direction: + .byte 1, 1, 1, 1, 1, 1, 1, 1 + .byte 1, 1, 1, 1, 1, 1, 1, 1 diff --git a/demos/second/qload.s b/demos/second/qload.s index 06d2df71..9bf02757 100644 --- a/demos/second/qload.s +++ b/demos/second/qload.s @@ -174,7 +174,6 @@ start_address: .byte $D0,$60,$60,$60 ; MUSIC, INTRO, TUNNEL, OCEAN .byte $80,$80,$80 ; POLAR, SPHERES, DOTS - aux_dest: ; .byte $D0,$FF,$60,$60 ; MUSIC, INTRO, TUNNEL, OCEAN .byte $10,$20,$30 ; POLAR, SPHERES, DOTS diff --git a/demos/second/zp.inc b/demos/second/zp.inc index 8f7c02c4..b8da3a77 100644 --- a/demos/second/zp.inc +++ b/demos/second/zp.inc @@ -182,12 +182,13 @@ RR = $FA BACKUP_OUTL = $F2 BACKUP_OUTH = $F3 -; Nuts/ operner +; Nuts/ opener SPRITE_Y = $F2 SPRITE_X = $F3 CURRENT_ROW = $F4 +COLOR_MASK = $F2