From bcd68fd7ed1dfcc6a5c1b9ad164dc8873d86e0eb Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 20 Jan 2024 23:10:30 -0500 Subject: [PATCH] trogdor: vertical scroll --- demos/trogdor/Makefile | 3 +- demos/trogdor/hgr_copy_magnify.s | 2 +- demos/trogdor/horiz_scroll_double.s | 119 +++++++++++++++++++++++++ demos/trogdor/horiz_scroll_simple.s | 43 ++++++--- demos/trogdor/horiz_scroll_skip.s | 133 ++++++++++++++++++++++++++++ demos/trogdor/start.s | 2 +- demos/trogdor/trogdor.s | 59 +++++++++++- demos/trogdor/vertical_scroll.s | 79 +++++++++++++++++ 8 files changed, 423 insertions(+), 17 deletions(-) create mode 100644 demos/trogdor/horiz_scroll_double.s create mode 100644 demos/trogdor/horiz_scroll_skip.s create mode 100644 demos/trogdor/vertical_scroll.s diff --git a/demos/trogdor/Makefile b/demos/trogdor/Makefile index 138a4a27..a82ea412 100644 --- a/demos/trogdor/Makefile +++ b/demos/trogdor/Makefile @@ -165,7 +165,8 @@ trogdor.o: trogdor.s \ flames.inc \ zp.inc hardware.inc qload.inc \ graphics/trog00_trogdor.hgr.zx02 \ - hgr_sprite_big_mask.s horiz_scroll_simple.s hgr_copy_magnify.s + hgr_sprite_big_mask.s horiz_scroll_simple.s hgr_copy_magnify.s \ + horiz_scroll_skip.s vertical_scroll.s ca65 -o trogdor.o trogdor.s -l trogdor.lst diff --git a/demos/trogdor/hgr_copy_magnify.s b/demos/trogdor/hgr_copy_magnify.s index cb8dee98..85569a55 100644 --- a/demos/trogdor/hgr_copy_magnify.s +++ b/demos/trogdor/hgr_copy_magnify.s @@ -49,7 +49,7 @@ magnify_outer_loop: sta GBASH - ldy #0 + ldy #0 ; 2 magnify_inner_loop: lda (INL),Y ; 5 and #$f ; 2 diff --git a/demos/trogdor/horiz_scroll_double.s b/demos/trogdor/horiz_scroll_double.s new file mode 100644 index 00000000..81f78790 --- /dev/null +++ b/demos/trogdor/horiz_scroll_double.s @@ -0,0 +1,119 @@ + ;====================================== + ; do very simple horizontal scroll + ;====================================== + ; skips by 4 because we need fairly high FPS + + ; originally ~12 seconds to scroll 80 (twice) + + ; also assumes every-other line the same + + + ; screens to pan in $2000/$4000 to left + + +horiz_pan_skip: + +pan_loop: + + ; how many times to scroll + + lda #0 + sta COUNT + +pan_outer_outer_loop: + + + ldx #191 +pan_outer_loop: + + txa + pha + + ; self-modify the PAGE1 high input addresses + + lda hposn_high,X + sta pil_in_smc1+2 ; input source + + sta pil_out_smc1+2 ; output odd + sta pil_out_smc4+2 + + ;self modify the PAGE2 high input addresses + eor #$60 + sta pil_in_page2_smc1+2 + + + ; self modify the PAGE1 LOW addresses + lda hposn_low,X + sta pil_out_smc1+1 ; output odd + sta pil_out_smc4+1 ; output odd + + + ; self modify the PAGE1 LOW input addresses + sta pil_in_smc1+1 ; input is regular+1 + inc pil_in_smc1+1 + + ; offset in PAGE2 to get input from + + clc + adc COUNT + sta pil_in_page2_smc1+1 + + + inx + lda hposn_high,X + sta pil_out_smc2+2 ; output even high + sta pil_out_smc5+2 + + lda hposn_low,X ; output even low + sta pil_out_smc2+1 + sta pil_out_smc5+1 + + + + ;========================= + ; inner loop, from 0-39 + + ldy #0 +pan_inner_loop: + + ; load in+1, store to in + + ; if completely unrolled, would save 1 cycle for store and + ; 5 for the branch/loop + ; 192*6=not a lot + +pil_in_smc1: + lda $2000+1,Y ; 4 +pil_out_smc1: + sta $2000,Y ; 5 +pil_out_smc2: + sta $2000,Y ; 5 + + iny ; 2 + cpy #39 ; 2 + bne pan_inner_loop ; 2/3 + + ; for right edge, scroll in from PAGE2 + +pil_in_page2_smc1: + lda $4000 +pil_out_smc4: + sta $2000,Y +pil_out_smc5: + sta $2000,Y + + pla + tax + + dex + dex + cpx #$ff + bne pan_outer_loop + + inc COUNT + lda COUNT + cmp #39 + + bne pan_outer_outer_loop + + rts diff --git a/demos/trogdor/horiz_scroll_simple.s b/demos/trogdor/horiz_scroll_simple.s index b0060458..c2f0d41b 100644 --- a/demos/trogdor/horiz_scroll_simple.s +++ b/demos/trogdor/horiz_scroll_simple.s @@ -1,6 +1,6 @@ - ;================================== + ;====================================== ; do very simple horizontal scroll - ;================================== + ;====================================== ; screens to pan in $2000/$4000 to left @@ -8,43 +8,66 @@ horiz_pan: pan_loop: + ; how many times to scroll + lda #0 sta COUNT pan_outer_outer_loop: + ; do all 191 lines + ldx #191 pan_outer_loop: + ; self-modify the PAGE1 high addresses + lda hposn_high,X sta pil_smc1+2 sta pil_smc2+2 sta pil_smc4+2 + + ;self modify the PAGE2 high addresses eor #$60 sta pil_smc3+2 + ; self modify the PAGE1 LOW addresses lda hposn_low,X sta pil_smc2+1 sta pil_smc4+1 + ; self mofidy the PAGE1 LOW input addresses sta pil_smc1+1 inc pil_smc1+1 + + clc adc COUNT sta pil_smc3+1 + ;========================= + ; inner loop, from 0-39 + ldy #0 pan_inner_loop: -pil_smc1: - lda $2000+1,Y -pil_smc2: - sta $2000,Y + ; load in+1, store to in - iny - cpy #39 - bne pan_inner_loop + ; if completely unrolled, would save 1 cycle for store and + ; 5 for the branch/loop + ; 192*6=not a lot + +pil_smc1: + lda $2000+1,Y ; 4 +pil_smc2: + sta $2000,Y ; 5 + + iny ; 2 + cpy #39 ; 2 + bne pan_inner_loop ; 2/3 + + ; for right edge, scroll in from PAGE2 pil_smc3: lda $4000 @@ -55,8 +78,6 @@ pil_smc4: cpx #$ff bne pan_outer_loop -; jsr wait_until_keypress - inc COUNT lda COUNT cmp #39 diff --git a/demos/trogdor/horiz_scroll_skip.s b/demos/trogdor/horiz_scroll_skip.s new file mode 100644 index 00000000..1866b24b --- /dev/null +++ b/demos/trogdor/horiz_scroll_skip.s @@ -0,0 +1,133 @@ + ;====================================== + ; do very simple horizontal scroll + ;====================================== + ; skips by 4 because we need fairly high FPS + + ; originally ~12 seconds to scroll 80 (twice) + ; made double high, ~8s + + ; screens to pan in $2000/$4000 to left + + +horiz_pan_skip: + +pan_loop: + + ; how many times to scroll + + lda #0 + sta COUNT + +pan_outer_outer_loop: + + + ldx #191 +pan_outer_loop: + + txa + pha + + ; self-modify the PAGE1 high input addresses + + lda hposn_high,X + sta pil_in_smc1+2 ; input source + + sta pil_out_smc1+2 ; output odd + sta pil_out_smc4+2 + + ;self modify the PAGE2 high input addresses + eor #$60 + sta pil_in_page2_smc1+2 + + + ; self modify the PAGE1 LOW addresses + lda hposn_low,X + sta pil_out_smc1+1 ; output odd + sta pil_out_smc4+1 ; output odd + + + ; self modify the PAGE1 LOW input addresses + sta pil_in_smc1+1 ; input is regular+1 + inc pil_in_smc1+1 + inc pil_in_smc1+1 + inc pil_in_smc1+1 + inc pil_in_smc1+1 + + ; offset in PAGE2 to get input from + + clc + adc COUNT + sta pil_in_page2_smc1+1 + + + inx + lda hposn_high,X + sta pil_out_smc2+2 ; output even high + sta pil_out_smc5+2 + + lda hposn_low,X ; output even low + sta pil_out_smc2+1 + sta pil_out_smc5+1 + + + + ;========================= + ; inner loop, from 0-36 + + ldy #0 +pan_inner_loop: + + ; load in+1, store to in + + ; if completely unrolled, would save 1 cycle for store and + ; 5 for the branch/loop + ; 192*6=not a lot + +pil_in_smc1: + lda $2000+1,Y ; 4 +pil_out_smc1: + sta $2000,Y ; 5 +pil_out_smc2: + sta $2000,Y ; 5 + + iny ; 2 + cpy #36 ; 2 + bne pan_inner_loop ; 2/3 + + ; for right edge, scroll in from PAGE2 + + ldx #0 +tail_loop: + +pil_in_page2_smc1: + lda $4000,X +pil_out_smc4: + sta $2000,Y +pil_out_smc5: + sta $2000,Y + + iny + inx + cpy #40 + bne tail_loop + + + pla + tax + + dex + dex + cpx #$ff + bne pan_outer_loop + + inc COUNT + inc COUNT + inc COUNT + inc COUNT + + lda COUNT + cmp #36 + + bne pan_outer_outer_loop + + rts diff --git a/demos/trogdor/start.s b/demos/trogdor/start.s index 7529b7a3..25859074 100644 --- a/demos/trogdor/start.s +++ b/demos/trogdor/start.s @@ -209,7 +209,7 @@ load_trogdor: ;======================= ;======================= - cli ; start music +; cli ; start music jsr $8000 diff --git a/demos/trogdor/trogdor.s b/demos/trogdor/trogdor.s index 22e58018..75446a5c 100644 --- a/demos/trogdor/trogdor.s +++ b/demos/trogdor/trogdor.s @@ -32,6 +32,15 @@ trogdor_main: lda #$20 sta DRAW_PAGE + + lda SOUND_STATUS + and #SOUND_MOCKINGBOARD + beq trog_no_music + + cli ; start music +trog_no_music: + + ;====================================== ; draw SCENE 1 ;====================================== @@ -53,13 +62,13 @@ trogdor_main: lda #$60 jsr hgr_copy_magnify - jsr horiz_pan + jsr horiz_pan_skip ; clear to white ldy #$7f jsr hgr_clear_screen - jsr horiz_pan + jsr horiz_pan_skip jsr hgr_page_flip @@ -244,6 +253,49 @@ left_flame_animate2: jsr hgr_clear_screen jsr hgr_page_flip + + + ;====================================== + ; draw SCENE 2 + ;====================================== + ; scroll trogdor intro place + + ; takes rougly 90 frames (3s) to scroll in + ; remains there 10 frames (almost .5s) + + ; orignal: 28s, want 9 times faster??? + ; can easily do 8 times... + + ; now should be on PAGE1?? + + ldy #$7f + jsr hgr_clear_screen + jsr hgr_page_flip + +; lda #24 ; 192/8 +; sta ANIMATE_COUNT + + lda #0 + sta COUNT + +scroll_in_loop: + + jsr hgr_vertical_scroll + + lda COUNT + clc + adc #8 + + cmp #192 + bne scroll_in_loop + + lda #10 + jsr wait_ticks + + + + ;======================================= + jsr wait_until_keypress ; second @@ -295,8 +347,9 @@ hposn_low = $1e00 hposn_high = $1f00 .include "hgr_sprite_big_mask.s" -.include "horiz_scroll_simple.s" +.include "horiz_scroll_skip.s" .include "hgr_copy_magnify.s" +.include "vertical_scroll.s" ;=============================== ; draw_flame_small diff --git a/demos/trogdor/vertical_scroll.s b/demos/trogdor/vertical_scroll.s new file mode 100644 index 00000000..f662e56f --- /dev/null +++ b/demos/trogdor/vertical_scroll.s @@ -0,0 +1,79 @@ + + ;======================================= + ; scrolls to PAGE1 + ; relies on going off the edge... + ;======================================= + +hgr_vertical_scroll: + ldx #0 + +outer_vscroll_loop: + lda hposn_low,X + sta OUTL + lda hposn_high,X + sta OUTH + + txa + clc + adc #8 + tay + lda hposn_low,y + sta INL + lda hposn_high,Y + sta INH + + ldy #29 +inner_vscroll_loop: + lda (INL),Y + sta (OUTL),Y + dey + cpy #9 + bpl inner_vscroll_loop + + inx + cpx #184 + bne outer_vscroll_loop + + + ;================================ + ; copy in off screen + + ; for now from 0..19 + +hgr_vertical_scroll2: + ldx #184 + +outer_vscroll_loop2: + lda hposn_low,X + clc + adc #10 + sta OUTL + + lda hposn_high,X + sta OUTH + + ldy COUNT + lda hposn_low,Y + sta INL + lda hposn_high,Y + clc + adc #$40 ; load from $6000 + sta INH + + ldy #19 +inner_vscroll_loop2: + lda (INL),Y + sta (OUTL),Y + dey + bpl inner_vscroll_loop2 + + inc COUNT + + inx + cpx #192 + bne outer_vscroll_loop2 + + + + rts +