From f0a2779fe878c0474fa6c7162cf717c338cf44eb Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 17 Dec 2017 23:06:49 -0500 Subject: [PATCH] mode7_demo: add scrolling --- mode7_demo/Makefile | 3 +- mode7_demo/deater_scroll.inc | 10 ++ mode7_demo/mode7_demo.s | 217 ++++++++++++++++++++++++++++++++++- 3 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 mode7_demo/deater_scroll.inc diff --git a/mode7_demo/Makefile b/mode7_demo/Makefile index f8113936..9cf70051 100644 --- a/mode7_demo/Makefile +++ b/mode7_demo/Makefile @@ -23,7 +23,8 @@ mode7_demo.o: mode7_demo.s mode7_demo_backgrounds.inc \ ../asm_routines/gr_unrle.s \ ../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_setpage.s \ - ../asm_routines/gr_fade.s + ../asm_routines/gr_fade.s \ + ../asm_routines/gr_copy.s ca65 -o mode7_demo.o mode7_demo.s -l mode7_demo.lst diff --git a/mode7_demo/deater_scroll.inc b/mode7_demo/deater_scroll.inc new file mode 100644 index 00000000..c234891b --- /dev/null +++ b/mode7_demo/deater_scroll.inc @@ -0,0 +1,10 @@ +; Original size = 668 bytes +deater_scroll: +; scroll_length: +.byte 167 + .byte $A0,$28,$00,$20,$20,$A3,$00,$A4,$20,$00,$00,$20,$20,$00,$00,$A3,$20,$00,$A4,$20,$00,$A3,$20,$A7,$00,$40,$A3,$00,$40,$00,$00,$40,$40,$A3,$00,$A3,$40,$A6,$00,$10,$00,$00,$10,$00,$A4,$10,$00,$A3,$10,$00,$00,$A4,$10,$00,$A3,$10,$00,$A3,$10,$00,$A3,$10,$A0,$82,$00 + .byte $A0,$28,$00,$E6,$00,$06,$E0,$00,$E6,$A4,$00,$E6,$00,$00,$E6,$00,$00,$E6,$00,$00,$E6,$A4,$00,$E6,$00,$00,$E6,$A6,$00,$DC,$A3,$00,$DC,$00,$DC,$00,$00,$DC,$00,$DC,$A9,$00,$B3,$00,$00,$B3,$00,$B3,$A4,$00,$B3,$00,$00,$B3,$00,$B3,$A4,$00,$03,$B3,$03,$00,$03,$B3,$03,$00,$03,$B3,$03,$A0,$82,$00 + .byte $A0,$28,$00,$EF,$00,$00,$EF,$00,$EF,$0F,$0F,$00,$00,$EF,$0F,$0F,$EF,$00,$00,$EF,$00,$00,$EF,$0F,$0F,$00,$00,$EF,$0F,$0F,$E0,$A6,$00,$DF,$00,$D0,$00,$DF,$00,$DF,$0F,$0F,$DF,$00,$00,$0F,$0F,$D0,$A6,$00,$BF,$0F,$0F,$BF,$00,$BF,$0F,$0F,$00,$00,$BF,$0F,$0F,$B0,$00,$BF,$0F,$0F,$A3,$00,$0F,$A3,$00,$0F,$A3,$00,$0F,$A0,$83,$00 + .byte $A0,$28,$00,$26,$20,$06,$00,$00,$26,$A3,$20,$00,$26,$00,$00,$26,$00,$00,$26,$00,$00,$26,$A3,$20,$00,$26,$00,$00,$26,$A6,$00,$4C,$0C,$00,$0C,$4C,$00,$4C,$00,$00,$4C,$00,$A3,$40,$0C,$A6,$00,$13,$00,$00,$13,$00,$13,$A3,$10,$00,$13,$00,$00,$13,$00,$13,$A3,$10,$00,$00,$13,$A3,$00,$13,$A3,$00,$13,$A0,$83,$00 + .byte $A1 +; Compressed size = 294 bytes diff --git a/mode7_demo/mode7_demo.s b/mode7_demo/mode7_demo.s index efaa0ea8..bde9fca9 100644 --- a/mode7_demo/mode7_demo.s +++ b/mode7_demo/mode7_demo.s @@ -25,11 +25,30 @@ demo_loop: + ;========== + ; Fade in + ;========== + jsr fade_in - lda #255 - jsr WAIT + ;========================================== + ; Make sure page0 and page1 show same image + ;========================================== + jsr gr_copy_to_current + + ;=================== + ; Scroll the message + ;=================== + +; lda #255 +; jsr WAIT + + jsr scroll + + ;============= + ; Fade out + ;============= jsr fade_out @@ -45,5 +64,199 @@ demo_loop: .include "../asm_routines/gr_setpage.s" .include "../asm_routines/pageflip.s" .include "../asm_routines/gr_fade.s" +.include "../asm_routines/gr_copy.s" .include "mode7_demo_backgrounds.inc" + + +scroll_row1 EQU $8A00 +scroll_row2 EQU $8B00 +scroll_row3 EQU $8C00 +scroll_row4 EQU $8D00 + +SCROLL_LENGTH EQU $E6 + + + +scroll: + lda #0 + sta ANGLE + + ;======================= + ; decompress scroll text + ;======================= + lda #>deater_scroll + sta INH + lda #scroll_row1 + sta OUTH + +decompress_scroll_loop: + jsr scroll_load_and_increment ; load compressed value + + cmp #$A1 ; EOF marker + beq done_decompress_scroll ; if EOF, exit + + pha ; save + + and #$f0 ; mask + cmp #$a0 ; see if special AX + beq decompress_scroll_special + + pla ; note, PLA sets flags! + + ldx #$1 ; only want to print 1 + bne decompress_scroll_run + +decompress_scroll_special: + pla + + and #$0f ; check if was A0 + + bne decompress_scroll_color ; if A0 need to read run, color + +decompress_scroll_large: + jsr scroll_load_and_increment ; get run length + +decompress_scroll_color: + tax ; put runlen into X + jsr scroll_load_and_increment ; get color + +decompress_scroll_run: + sta (OUTL),Y + pha + + clc ; increment 16-bit pointer + lda OUTL + adc #$1 + sta OUTL + lda OUTH + adc #$0 + sta OUTH + + pla + + dex ; repeat for X times + bne decompress_scroll_run + + beq decompress_scroll_loop ; get next run + +done_decompress_scroll: + rts + + +scroll_load_and_increment: + lda (INL),Y ; load and increment 16-bit pointer + pha + clc + lda INL + adc #$1 + sta INL + lda INH + adc #$0 + sta INH + pla + rts + + +;=============================================== +; Variables +;=============================================== + +.include "deater_scroll.inc" + +