diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2020-12-29 10:38:09 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2020-12-29 11:54:10 +0300 |
commit | 23da7522ba8d61420aaccec56a52e39b63910021 (patch) | |
tree | d9fb7339adf5de5729d41731f08806d182192b66 /buttons.asm | |
parent | bc71aa555d5fb0e3a2720ce546ffe50e84991f12 (diff) |
Menu wrapping
Diffstat (limited to 'buttons.asm')
-rw-r--r-- | buttons.asm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/buttons.asm b/buttons.asm index 2d0b471..3b83c05 100644 --- a/buttons.asm +++ b/buttons.asm @@ -3,6 +3,12 @@ BUTTONS_TMP .rs 1 ; temporary variable for buttons BUTTONS_HOLD_TIME .rs 1 ; up/down/left/right buttons hold time
KONAMI_CODE_STATE .rs 1 ; Konami Code state
+ .if GAMES_COUNT >= 11
+MAXIMUM_SCROLL .equ GAMES_COUNT - 11
+ .else
+MAXIMUM_SCROLL .equ 0
+ .endif
+
; controller reading, two times
read_controller:
pha
@@ -102,13 +108,14 @@ buttons_check: jsr .check_separator_up
jmp .button_end
.button_up_ovf:
- lda #GAMES_COUNT & $FF
- sec
- sbc #1
+ .if GAMES_COUNT < WRAP_GAMES
+ lda #(GAMES_COUNT - 1) & $FF
sta <SELECTED_GAME
- lda #(GAMES_COUNT >> 8) & $FF
- sbc #0
+ lda #((GAMES_COUNT - 1) >> 8) & $FF
sta <SELECTED_GAME+1
+ .else
+ jsr screen_wrap_up
+ .endif
jsr .check_separator_up
jmp .button_end
@@ -133,11 +140,15 @@ buttons_check: jsr .check_separator_down
jmp .button_end
.button_down_ovf:
+ .if GAMES_COUNT < WRAP_GAMES
lda #0
sta <SELECTED_GAME
sta <SELECTED_GAME+1
sta <SCROLL_LINES_TARGET
sta <SCROLL_LINES_TARGET+1
+ .else
+ jsr screen_wrap_down
+ .endif
jsr .check_separator_down
jmp .button_end
@@ -260,7 +271,7 @@ buttons_check: rts
.button_end:
- jsr set_cursor_targets ; updating cursor targets
+ jsr set_scroll_targets ; updating cursor targets
jsr wait_buttons_not_pressed
rts
|