ds: update to use common code

This commit is contained in:
Vince Weaver 2019-11-02 11:22:21 -04:00
parent 65e0d56062
commit 335f5c0bd2
3 changed files with 33 additions and 84 deletions

View File

@ -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

View File

@ -4,20 +4,8 @@
; by deater (Vince Weaver) <vince@deater.net>
; 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 GBASL
lda pictures+1,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 GBASL
lda pictures+3,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"

View File

@ -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"