4cade/src/ui.browse.mode.a

156 lines
4.2 KiB
Plaintext
Raw Normal View History

2019-07-03 22:31:50 +00:00
;license:MIT
;(c) 2018-9 by 4am
;
; Browse Mode - main UI
;
; Public functions
; - BrowseMode
;
;------------------------------------------------------------------------------
; BrowseMode
; main entry point for Browse Mode, which allows the user to browse the game
; catalog in alphabetical order and launch games
;
; in: none
; out: never returns to caller (may JMP to other major modes)
;------------------------------------------------------------------------------
BrowseMode
ldx #$FF
txs
2019-09-21 22:04:38 +00:00
@BrowseModeInputLoop
jsr WaitForKeyFor30Seconds
bit CLEARKBD
2019-07-03 22:31:50 +00:00
2019-09-06 19:21:38 +00:00
ldy #kNumBrowseKeys
- dey
bmi @noKeyMatch
2019-09-21 22:04:38 +00:00
cmp BrowseKeys,y
2019-09-06 19:21:38 +00:00
bne -
2019-09-21 22:04:38 +00:00
ldx BrowseKeyDispatch,y
2019-07-10 17:37:59 +00:00
bne @BrowseDispatch ; always branches
2019-09-06 19:21:38 +00:00
@noKeyMatch
jsr IsSearchKey
beq +
2019-07-03 22:31:50 +00:00
jsr SoftBell ; beep on invalid input
2019-09-21 22:04:38 +00:00
jmp @BrowseModeInputLoop ; and start over
+
2019-07-03 22:31:50 +00:00
ldx #kBrowseSearch
; execution falls through here
@BrowseDispatch
2019-09-21 22:04:38 +00:00
ldy BrowseDispatchTableLo,x
2019-09-06 19:21:38 +00:00
sty @j+1
2019-09-21 22:04:38 +00:00
ldy BrowseDispatchTableHi,x
2019-09-06 19:21:38 +00:00
sty @j+2
2019-07-03 22:31:50 +00:00
@j jsr $FDFD ; SMC
2019-09-21 22:04:38 +00:00
jmp @BrowseModeInputLoop
2019-07-03 22:31:50 +00:00
2019-09-21 22:04:38 +00:00
OnBrowseSearch
2019-07-03 22:31:50 +00:00
sta InputBuffer
lda #$01
sta InputLength
jmp SearchMode
2019-09-21 22:04:38 +00:00
OnBrowsePrevious
2019-09-21 03:26:32 +00:00
dec gGameToLaunch
2019-07-03 22:31:50 +00:00
jmp +
2019-09-21 22:04:38 +00:00
OnBrowseNext
2019-09-21 03:26:32 +00:00
inc gGameToLaunch
2019-07-03 22:31:50 +00:00
+
2019-09-21 03:26:32 +00:00
ldx gGameToLaunch
2019-07-03 22:31:50 +00:00
cpx #$FF
bne @notTooSmall
2019-09-11 04:26:00 +00:00
GameCount = *+1
ldx #$D1 ; SMC
2019-07-03 22:31:50 +00:00
dex
bne @done ; always branches
@notTooSmall
cpx GameCount
bcc @done
ldx #0
2019-09-21 03:26:32 +00:00
@done stx gGameToLaunch
2019-09-21 22:04:38 +00:00
jmp OnBrowseChanged
2019-07-03 22:31:50 +00:00
2019-09-21 22:04:38 +00:00
OnBrowseLaunch
2019-09-21 03:26:32 +00:00
jsr PlayGame
jsr BlankHGR
2019-09-21 22:04:38 +00:00
jmp ForceBrowseChanged
2019-09-21 22:04:38 +00:00
OnBrowseCheat
jsr ToggleCheat
2019-09-21 22:04:38 +00:00
beq ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat
2019-09-21 22:04:38 +00:00
OnBrowseTab
2019-09-21 03:26:32 +00:00
ldx gGameToLaunch
2019-07-03 22:31:50 +00:00
jsr MiniAttractMode
cmp #$8D
2019-09-21 22:04:38 +00:00
beq OnBrowseLaunch
; execution falls through here
ForceBrowseChanged
bit CLEARKBD
2019-09-21 03:26:32 +00:00
ldx gGameToLaunch
; execution falls through here
2019-09-21 22:04:38 +00:00
OnBrowseChanged
2019-09-21 21:35:49 +00:00
; in: X = game index
jsr LoadGameTitleOffscreen
jmp DrawUIWithoutDots
2019-07-03 22:31:50 +00:00
;------------------------------------------------------------------------------
; indices into BrowseDispatchTable
kBrowseSearch = 0
kBrowsePrevious = 1
kBrowseNext = 2
kBrowseExitToSearch = 3
2019-07-03 22:31:50 +00:00
kBrowseTab = 4
kBrowseLaunch = 5
2019-07-10 17:37:59 +00:00
kBrowseCredits = 6
kBrowseCheat = 7
2019-07-03 22:31:50 +00:00
2019-09-21 22:04:38 +00:00
BrowseDispatchTableLo
!byte <OnBrowseSearch
!byte <OnBrowsePrevious
!byte <OnBrowseNext
2019-09-06 19:21:38 +00:00
!byte <SearchMode
2019-09-21 22:04:38 +00:00
!byte <OnBrowseTab
!byte <OnBrowseLaunch
2019-09-06 19:21:38 +00:00
!byte <Credits
2019-09-21 22:04:38 +00:00
!byte <OnBrowseCheat
BrowseDispatchTableHi
!byte >OnBrowseSearch
!byte >OnBrowsePrevious
!byte >OnBrowseNext
2019-09-06 19:21:38 +00:00
!byte >SearchMode
2019-09-21 22:04:38 +00:00
!byte >OnBrowseTab
!byte >OnBrowseLaunch
2019-09-06 19:21:38 +00:00
!byte >Credits
2019-09-21 22:04:38 +00:00
!byte >OnBrowseCheat
2019-09-06 19:21:38 +00:00
kNumBrowseKeys = 11 ; number of entries in next 2 tables (each)
2019-09-21 22:04:38 +00:00
BrowseKeys
!byte $83 ; Ctrl-C = toggle cheat mode
2019-09-06 19:21:38 +00:00
!byte $AF ; '/' = credits
!byte $BF ; '?' = credits
!byte $A0 ; Space = mini attract mode
!byte $89 ; TAB = mini attract mode
!byte $8D ; ENTER = launch current game
!byte $9B ; Esc = switch to search mode
!byte $8A ; down arrow = next
!byte $95 ; right arrow = next
!byte $8B ; up arrow = previous
!byte $88 ; left arrow = previous
2019-09-21 22:04:38 +00:00
BrowseKeyDispatch
!byte kBrowseCheat
2019-09-06 19:21:38 +00:00
!byte kBrowseCredits
!byte kBrowseCredits
!byte kBrowseTab
!byte kBrowseTab
!byte kBrowseLaunch
!byte kBrowseExitToSearch
!byte kBrowseNext
!byte kBrowseNext
!byte kBrowsePrevious
!byte kBrowsePrevious