From 335f5c0bd2c6150954727b5375ccd55b6bfece30 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 2 Nov 2019 11:22:21 -0400 Subject: [PATCH] ds: update to use common code --- demosplash/Makefile | 1 + demosplash/book.s | 106 +++++++++++------------------------------ demosplash/musictest.s | 10 ++-- 3 files changed, 33 insertions(+), 84 deletions(-) diff --git a/demosplash/Makefile b/demosplash/Makefile index 9cad1ef5..1fddc948 100644 --- a/demosplash/Makefile +++ b/demosplash/Makefile @@ -55,6 +55,7 @@ musictest.o: musictest.s \ interrupt_handler.s \ missing.s k_40_48d.inc missing_screen_update.s \ create_update_type1.s \ + book.s \ dya_space_demo2.pt3 ca65 -o musictest.o musictest.s -l musictest.lst diff --git a/demosplash/book.s b/demosplash/book.s index c9102b82..077c7f8f 100644 --- a/demosplash/book.s +++ b/demosplash/book.s @@ -4,20 +4,8 @@ ; by deater (Vince Weaver) -; Zero Page -;FRAME = $60 -;BLARGH = $69 -;DRAW_PAGE = $EE -;LASTKEY = $F1 -;PADDLE_STATUS = $F2 -;TEMP = $FA -WHICH = $E3 - - -book: - lda #0 - sta WHICH +end_book: ;=================== ; init screen @@ -31,17 +19,17 @@ book: lda #0 sta DRAW_PAGE + ;=================== + ; setup grahics + + jsr create_update_type1 + ;============================= ; Load graphic page0 - lda WHICH - asl - asl ; which*4 - tay - - lda pictures,Y + lda #book_low sta GBASH lda #$c ; load image to $c00 @@ -67,14 +55,9 @@ book: ;============================= ; Load graphic page1 - lda WHICH - asl - asl ; which*4 - tay - - lda pictures+2,Y + lda #book_high sta GBASH lda #$c ; load image to $c00 jsr load_rle_gr @@ -128,72 +111,34 @@ loopR: dex ; 2 ;================================================ ; Display Loop ;================================================ - ; each scan line 65 cycles - ; 1 cycle each byte (40cycles) + 25 for horizontal - ; Total of 12480 cycles to draw screen - ; Vertical blank = 4550 cycles (70 scan lines) - ; Total of 17030 cycles to get back to where was - ; We want to alternate between page1 and page2 every 65 cycles ; vblank = 4550 cycles to do scrolling - - ; 2 + 48*( (4+2+25*(2+3)) + (4+2+23*(2+3)+4+5)) + 9) - ; 48*[(6+125)-1] + [(6+115+10)-1] - book_loop: - ldy #96 ; 2 - -book_outer_loop: - - bit PAGE0 ; 4 - ldx #12 ; 65 cycles with PAGE0 ; 2 -book_page0_loop: ; delay 61+bit - dex ; 2 - bne book_page0_loop ; 2/3 - - - ; bit(4) -1(fallthrough) + loop*5 -1(fallthrouh)+4 extra = 61 - ; 5L = 55 - - bit PAGE1 ; 4 - ldx #11 ; 65 cycles with PAGE1 ; 2 - ; -book_page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra) - dex ; 2 - bne book_page1_loop ; 2/3 - - dey ; 2 - bne book_outer_loop ; 2/3 - - + jsr $9000 ; cycle-counted page0/page1 flip code ;====================================================== ; We have 4550 cycles in the vblank, use them wisely ;====================================================== - ; do_nothing should be 4550+1 -2-9 -7= 4533 - - jsr book_do_nothing ; 6 - - lda KEYPRESS ; 4 - bpl book_no_keypress ; 3 - rts -book_no_keypress: - - jmp book_loop ; 3 - + ; do_nothing should be + ; 4550 + ; -12 -- enter/leave flip code + ; -10 -- keypress code + ; ======= + ; 4528 cycles ;================================= ; do nothing ;================================= - ; and take 4533-6 = 4527 cycles to do it + ; and take 4528 + book_do_nothing: - ; Try X=4 Y=174 cycles=4525 R2 + ; Try X=4 Y=174 cycles=4525 R3 - nop ; 2 + lda TEMP ; 3 ldy #174 ; 2 bloop1: @@ -206,11 +151,14 @@ bloop2: bne bloop1 ; 2nt/3 - rts ; 6 + lda KEYPRESS ; 4 + bpl book_no_keypress ; 3 + rts ; 6 +book_no_keypress: + + jmp book_loop ; 3 -pictures: - .word book_low,book_high .include "book_40_48d.inc" diff --git a/demosplash/musictest.s b/demosplash/musictest.s index a3345422..d576e090 100644 --- a/demosplash/musictest.s +++ b/demosplash/musictest.s @@ -113,21 +113,21 @@ frame_decode_loop: ; start irq music ;======================== - cli ; enable interrupts +; cli ; enable interrupts ;=========================== ; book scene ;============================ - +; jsr open_book ;=========================== ; starbase scene ;=========================== - jsr starbase +; jsr starbase ;=========================== ; escape scene @@ -139,7 +139,7 @@ frame_decode_loop: ; book scene ;=========================== -; jsr book + jsr end_book ; wait wait wait @@ -190,7 +190,7 @@ wait_until_keypressed: ;.include "escape.s" ; book -;.include "book.s" +.include "book.s" ; Music player .include "pt3_lib_core.s"