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

204 lines
5.7 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
;
!zone {
;------------------------------------------------------------------------------
; 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
ldx SelectedIndex
stx BrowseSelectedIndex
.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
cmp .BrowseKeys,y
bne -
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
jmp .BrowseModeInputLoop ; and start over
+
2019-07-03 22:31:50 +00:00
ldx #kBrowseSearch
; execution falls through here
@BrowseDispatch
2019-09-06 19:21:38 +00:00
ldy .BrowseDispatchTableLo,x
sty @j+1
ldy .BrowseDispatchTableHi,x
sty @j+2
2019-07-03 22:31:50 +00:00
@j jsr $FDFD ; SMC
jmp .BrowseModeInputLoop
2019-07-03 22:31:50 +00:00
.OnSearch
sta InputBuffer
lda #$01
sta InputLength
jmp SearchMode
.OnPrevious
dec BrowseSelectedIndex
jmp +
.OnNext
inc BrowseSelectedIndex
+
ldx BrowseSelectedIndex
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
@done stx BrowseSelectedIndex
jmp .OnBrowseChanged
.OnLaunch
ldx BrowseSelectedIndex
jsr PlayGameFromBrowse
jsr BlankHGR
jmp .ForceBrowseChanged
.OnCheat
jsr ToggleCheat
beq .ForceBrowseChanged ; always branches because Z=1 on exit from ToggleCheat
2019-07-03 22:31:50 +00:00
.OnTab
ldx BrowseSelectedIndex
jsr MiniAttractMode
cmp #$8D
beq .OnLaunch
.ForceBrowseChanged
bit CLEARKBD
2019-07-03 22:31:50 +00:00
ldx BrowseSelectedIndex
; execution falls through here
2019-07-03 22:31:50 +00:00
.OnBrowseChanged
stx @index
jsr okvs_nth ; get the name of the new game
!word gGamesListStore
@index !byte $FD
+STAY @key
2019-09-10 02:38:17 +00:00
+STAY @key2
2019-07-03 22:31:50 +00:00
jsr GetOffscreenAddress ; load new title screenshot offscreen
sta + ; new title screenshot (offscreen)
2019-09-10 02:38:17 +00:00
jsr LoadFile
!word kHGRTitleDirectory
@key !word $FDFD ; SMC
2019-07-03 22:31:50 +00:00
!byte $00
+ !byte $FD ; SMC
jsr okvs_get
!word gGamesListStore
2019-09-10 02:38:17 +00:00
@key2 !word $FDFD
2019-07-03 22:31:50 +00:00
+STAY SRC ; A/Y points to game title (in OKVS)
ldy #0 ; copy game title into search bar buffer
lda (SRC),y
sta SAVE ; game title length
inc SAVE
- iny
cpy SAVE
bcc @printTitleChar
lda #" "
+HIDE_NEXT_2_BYTES
@printTitleChar
lda (SRC),y ; copy game title to UI line 2
sta UILine2,y
cpy #MaxInputLength+1
bcc -
ldx #8
- lda ReturnToPlay,x ; replace games count with 'to play' label
sta UI_ToPlay,x
dex
bpl -
ldx @index
jsr BuildUILine1WithNoDots ; build UI line 1 with bars and other shapes
ldx @index
jsr DrawSearchBarOffscreen ; actually draw the UI (offscreen)
2019-07-03 22:31:50 +00:00
jmp ShowOtherPage ; now show everything at once
;------------------------------------------------------------------------------
; 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-06 19:21:38 +00:00
.BrowseDispatchTableLo
!byte <.OnSearch
!byte <.OnPrevious
!byte <.OnNext
!byte <SearchMode
!byte <.OnTab
!byte <.OnLaunch
!byte <Credits
!byte <.OnCheat
2019-09-06 19:21:38 +00:00
.BrowseDispatchTableHi
!byte >.OnSearch
!byte >.OnPrevious
!byte >.OnNext
!byte >SearchMode
!byte >.OnTab
!byte >.OnLaunch
!byte >Credits
!byte >.OnCheat
2019-09-06 19:21:38 +00:00
kNumBrowseKeys = 11 ; number of entries in next 2 tables (each)
2019-09-06 19:21: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
.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
2019-07-03 22:31:50 +00:00
BrowseSelectedIndex
!byte $FF
}