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
|
2019-07-04 02:27:46 +00:00
|
|
|
jsr WaitForKeyFor30Seconds
|
2019-07-03 22:31:50 +00:00
|
|
|
bit CLEARKBD
|
|
|
|
jsr ResetInputTimeout
|
|
|
|
|
|
|
|
cmp #$88 ; left arrow = previous
|
|
|
|
bne +
|
|
|
|
- ldx #kBrowsePrevious
|
|
|
|
bne @BrowseDispatch ; always branches
|
|
|
|
+ cmp #$8B ; up arrow is same as left arrow
|
|
|
|
beq -
|
|
|
|
|
|
|
|
cmp #$95 ; right arrow = next
|
|
|
|
bne +
|
|
|
|
- ldx #kBrowseNext
|
|
|
|
bne @BrowseDispatch ; always branches
|
|
|
|
+ cmp #$8A ; down arrow is same as right arrow
|
|
|
|
beq -
|
|
|
|
|
|
|
|
cmp #$9B ; Esc switches to search mode
|
|
|
|
bne +
|
2019-07-04 02:27:46 +00:00
|
|
|
ldx #kBrowseExitToSearch
|
2019-07-03 22:31:50 +00:00
|
|
|
bne @BrowseDispatch ; always branches
|
|
|
|
+
|
|
|
|
cmp #$8D ; ENTER launches the current game
|
|
|
|
bne +
|
|
|
|
ldx #kBrowseLaunch
|
|
|
|
bne @BrowseDispatch ; always branches
|
|
|
|
+
|
|
|
|
cmp #$89 ; TAB switches to mini attract mode
|
|
|
|
bne + ; temporarily
|
|
|
|
ldx #kBrowseTab
|
|
|
|
bne @BrowseDispatch ; always branches
|
|
|
|
+
|
|
|
|
and #$7F ; strip high bit for search characters
|
2019-07-04 02:27:46 +00:00
|
|
|
jsr IsSearchKey
|
|
|
|
beq +
|
2019-07-03 22:31:50 +00:00
|
|
|
jsr SoftBell ; beep on invalid input
|
|
|
|
jmp .BrowseModeInputLoop ; and start over
|
2019-07-04 02:27:46 +00:00
|
|
|
+
|
2019-07-03 22:31:50 +00:00
|
|
|
ldx #kBrowseSearch
|
|
|
|
; execution falls through here
|
|
|
|
@BrowseDispatch
|
|
|
|
pha ; save key pressed
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
lda .BrowseDispatchTable,x
|
|
|
|
sta @j+1
|
|
|
|
lda .BrowseDispatchTable+1,x
|
|
|
|
sta @j+2
|
|
|
|
pla ; restore key pressed
|
|
|
|
@j jsr $FDFD ; SMC
|
2019-07-04 02:27:46 +00:00
|
|
|
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
|
|
|
|
ldx GameCount
|
|
|
|
dex
|
|
|
|
bne @done ; always branches
|
|
|
|
@notTooSmall
|
|
|
|
cpx GameCount
|
|
|
|
bcc @done
|
|
|
|
ldx #0
|
|
|
|
@done stx BrowseSelectedIndex
|
|
|
|
jmp .OnBrowseChanged
|
|
|
|
|
2019-07-04 02:27:46 +00:00
|
|
|
.OnLaunch
|
|
|
|
ldx BrowseSelectedIndex
|
|
|
|
jsr PlayGameFromBrowse
|
|
|
|
jsr BlankHGR
|
|
|
|
jmp +
|
|
|
|
|
2019-07-03 22:31:50 +00:00
|
|
|
.OnTab
|
|
|
|
ldx BrowseSelectedIndex
|
|
|
|
jsr MiniAttractMode
|
|
|
|
cmp #$8D
|
|
|
|
beq .OnLaunch
|
2019-07-04 02:27:46 +00:00
|
|
|
+ bit CLEARKBD
|
2019-07-03 22:31:50 +00:00
|
|
|
ldx BrowseSelectedIndex
|
2019-07-04 02:27:46 +00:00
|
|
|
; 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
|
|
|
|
jsr GetOffscreenAddress ; load new title screenshot offscreen
|
|
|
|
sta + ; new title screenshot (offscreen)
|
|
|
|
+LDADDR kHGRTitleDirectory
|
|
|
|
jsr SetPath
|
|
|
|
+LDAY @key
|
|
|
|
jsr AddToPath
|
|
|
|
jsr LoadFileAt
|
|
|
|
!byte $00
|
|
|
|
+ !byte $FD ; SMC
|
|
|
|
|
|
|
|
jsr okvs_get
|
|
|
|
!word gGamesListStore
|
|
|
|
@key !word $FDFD
|
|
|
|
+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 -
|
2019-07-08 18:10:11 +00:00
|
|
|
ldx #8
|
|
|
|
- lda ReturnToPlay,x ; replace games count with 'to play' label
|
|
|
|
sta UI_ToPlay,x
|
|
|
|
dex
|
|
|
|
bpl -
|
2019-07-03 22:31:50 +00:00
|
|
|
ldx #40
|
|
|
|
lda #0
|
|
|
|
- sta UILine1-1,x ; reset UI line 1
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
jsr DrawSearchBarOffscreen ; actually draw the search UI (offscreen)
|
|
|
|
jmp ShowOtherPage ; now show everything at once
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
; indices into BrowseDispatchTable
|
|
|
|
kBrowseSearch = 0
|
|
|
|
kBrowsePrevious = 1
|
|
|
|
kBrowseNext = 2
|
2019-07-04 02:27:46 +00:00
|
|
|
kBrowseExitToSearch = 3
|
2019-07-03 22:31:50 +00:00
|
|
|
kBrowseTab = 4
|
|
|
|
kBrowseLaunch = 5
|
|
|
|
|
|
|
|
.BrowseDispatchTable
|
|
|
|
!word .OnSearch
|
|
|
|
!word .OnPrevious
|
|
|
|
!word .OnNext
|
|
|
|
!word SearchMode
|
|
|
|
!word .OnTab
|
|
|
|
!word .OnLaunch
|
|
|
|
|
|
|
|
BrowseSelectedIndex
|
|
|
|
!byte $FF
|
|
|
|
|
|
|
|
}
|