From db9e66cc86a54dd7febfe86101b3669d743018d6 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 24 Jan 2013 23:18:08 -0500 Subject: [PATCH] snes: add wait_until_keypressed routine --- tb1_snes/checksum.inc | 4 ++-- tb1_snes/opening.s | 22 +--------------------- tb1_snes/svmwgraph.s | 35 +++++++++++++++++++++++++++++++++++ tb1_snes/title_screen.s | 20 ++++---------------- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/tb1_snes/checksum.inc b/tb1_snes/checksum.inc index 743713a..d50fa07 100644 --- a/tb1_snes/checksum.inc +++ b/tb1_snes/checksum.inc @@ -1,2 +1,2 @@ - .word $3d2c ; Complement of checksum - .word $c2d3 ; Unsigned 16-bit sum of ROM + .word $3851 ; Complement of checksum + .word $c7ae ; Unsigned 16-bit sum of ROM diff --git a/tb1_snes/opening.s b/tb1_snes/opening.s index bdd9fbd..d12bd3d 100644 --- a/tb1_snes/opening.s +++ b/tb1_snes/opening.s @@ -168,35 +168,15 @@ opening_setup_video: sta $2105 ; set Mode 3 lda #$81 ; Enable NMI (VBlank Interrupt) and joypads -; lda #$01 ; enable joypad sta $4200 ; jsr svmw_fade_in - - -;forever: -; bra forever - - -opening_joypad_read: - lda $4212 ; get joypad status - and #%00000001 ; if joy is not ready - bne opening_joypad_read ; wait - - lda $4219 ; read joypad (BYSTudlr) - - and #%11110000 ; see if a button pressed - - beq opening_joypad_read - ; if so, skip and don't move ball + jsr svmw_repeat_until_keypressed jsr svmw_fade_out -; lda #$80 -; sta $2100 ; Turn off screen - rts diff --git a/tb1_snes/svmwgraph.s b/tb1_snes/svmwgraph.s index 0bebb4a..4bb2911 100644 --- a/tb1_snes/svmwgraph.s +++ b/tb1_snes/svmwgraph.s @@ -235,3 +235,38 @@ done_fade_out: plp ; restore status rts ; return + + +;======================== +;======================== +; repeat until keypressed +;======================== +;======================== +; this assumes auto-joypad read enabled + +svmw_repeat_until_keypressed: + php ; save status register + + sep #$20 ; set accumulator to 8 bit +.a8 + +wait_for_keypress: + wai ; wait until next interrupt + +wait_for_joypad_ready: + lda $4212 ; get joypad status + and #$01 ; loop if joypad is not ready + bne wait_for_joypad_ready + + lda $4219 ; read joypad (BYSTudlr) + bne found_keypress + + lda $4218 ; read joypad (axlriiii) + bne found_keypress + + bra wait_for_keypress + +found_keypress: + + plp ; restore status + rts diff --git a/tb1_snes/title_screen.s b/tb1_snes/title_screen.s index 2a0276c..9a49931 100644 --- a/tb1_snes/title_screen.s +++ b/tb1_snes/title_screen.s @@ -109,27 +109,15 @@ title_setup_video: sta $2100 ; Turn on screen, full Brightness -; lda #$81 ; Enable NMI (VBlank Interrupt) and joypads - lda #$01 ; Enable joypad -; lda #$00 + lda #$81 ; Enable NMI (VBlank Interrupt) and joypads sta $4200 ; -;big: -; bra big + jsr svmw_fade_in -title_joypad_read: - lda $4212 ; get joypad status - and #%00000001 ; if joy is not ready - bne title_joypad_read ; wait + jsr svmw_repeat_until_keypressed - lda $4219 ; read joypad (BYSTudlr) + jsr svmw_fade_out - and #%11110000 ; see if a button pressed - - beq title_joypad_read - - lda #$80 - sta $2100 ; Turn off screen rts