From a2990d38c2730deaf662ac2c8877098bfe6eac36 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 9 May 2024 23:48:49 -0400 Subject: [PATCH] keen: story with up works --- games/keen/delay_a.s | 25 ++++ games/keen/story.s | 88 +++++++++---- games/keen/vapor_lock.s | 273 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 360 insertions(+), 26 deletions(-) create mode 100644 games/keen/delay_a.s create mode 100644 games/keen/vapor_lock.s diff --git a/games/keen/delay_a.s b/games/keen/delay_a.s new file mode 100644 index 00000000..2d0802da --- /dev/null +++ b/games/keen/delay_a.s @@ -0,0 +1,25 @@ +; From http://6502org.wikidot.com/software-delay + +; 25+A cycles (including JSR), 19 bytes (excluding JSR) +; +; The branches must not cross page boundaries! +; + + ; Cycles Accumulator Carry flag + ; 0 1 2 3 4 5 6 (hex) 0 1 2 3 4 5 6 + +; jsr delay_a ; 6 6 6 6 6 6 6 00 01 02 03 04 05 06 + +dly0: sbc #7 +delay_a:cmp #7 ; 2 2 2 2 2 2 2 00 01 02 03 04 05 06 0 0 0 0 0 0 0 + bcs dly0 ; 2 2 2 2 2 2 2 00 01 02 03 04 05 06 0 0 0 0 0 0 0 + lsr ; 2 2 2 2 2 2 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0 + bcs dly1 ; 2 3 2 3 2 3 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0 +dly1: beq dly2 ; 3 3 2 2 2 2 2 00 00 01 01 02 02 03 0 1 0 1 0 1 0 + lsr ; 2 2 2 2 2 00 00 01 01 01 1 1 0 0 1 + beq dly3 ; 3 3 2 2 2 00 00 01 01 01 1 1 0 0 1 + bcc dly3 ; 3 3 2 01 01 01 0 0 1 +dly2: bne dly3 ; 2 2 3 00 00 01 0 1 0 +dly3: rts ; 6 6 6 6 6 6 6 00 00 00 00 01 01 01 0 1 1 1 0 0 1 + ; + ; Total cycles: 25 26 27 28 29 30 31 diff --git a/games/keen/story.s b/games/keen/story.s index 66fbe3e6..c14b037b 100644 --- a/games/keen/story.s +++ b/games/keen/story.s @@ -18,11 +18,15 @@ keen_story_start: bit KEYRESET - bit SET_GR + bit SET_TEXT bit PAGE1 - bit HIRES bit FULLGR +; bit SET_GR +; bit PAGE1 +; bit HIRES +; bit FULLGR + ;=================== ; Load story data ;=================== @@ -53,17 +57,40 @@ load_background: jsr full_decomp - jsr wait_until_keypress - - - bit SET_TEXT - bit PAGE1 +; bit SET_TEXT +; bit PAGE1 lda #story_data sta START_LINE_H + jsr vapor_lock + + ; in theory at roughly 7410 cycles here (line 114) + ; we want to be at line 192 (12480) + + ; 12480 - 7410 = 5070 + + ; want to delay 5070 cycles + + ; experimentally want about 9 less? + + ; 5070 - 4 - 8 = 5058/9 = 562 -(9) = 561 + ; 561 / 256 = 2 r 49 + + nop + nop + nop + nop + + + lda #2 ; 2 + ldy #49 ; 2 + jsr delay_loop + + + ;=========================== ; main loop ;=========================== @@ -227,16 +254,18 @@ done_key7: nop done_key41: inc $00 ; nop5 - lda $00 ; nop3 -done_key_49: + nop + nop +done_key_50: inc $00 ; nop5 - lda $00 ; nop3 + nop done_key_57: inc $00 ; nop5 inc $00 ; nop5 + lda $00 ; nop3 +done_key_70: + nop nop -done_key_69: - inc $00 ; nop5 nop done_key_76: @@ -318,8 +347,8 @@ test4: do_up_w: ; 27 - nop - nop + nop ; 2 + nop ; 2 do_up_up: ; 31 lda START_LINE_H ; 3 @@ -328,40 +357,42 @@ do_up_up: ; 38 lda START_LINE_L ; 3 cmp #