mirror of
https://github.com/a2-4am/4cade.git
synced 2025-01-13 05:30:32 +00:00
refactor UILine1 and UILine2
This commit is contained in:
parent
00deb0f54b
commit
ee045b8723
@ -79,7 +79,10 @@ zpCharMask = $F1 ; only uesd during init, then clobbered
|
|||||||
gPathname = $1F00 ; used by SetPath/AddToPath
|
gPathname = $1F00 ; used by SetPath/AddToPath
|
||||||
gKeyLen = $1F00 ; used by ParseGamesList
|
gKeyLen = $1F00 ; used by ParseGamesList
|
||||||
gKey = $1F01
|
gKey = $1F01
|
||||||
UILine1 = $1F80
|
UILine1 = $1FB0
|
||||||
|
UILine2 = $1FD8
|
||||||
|
UI_ToPlay = $1FF7
|
||||||
|
|
||||||
gValLen = $1F80
|
gValLen = $1F80
|
||||||
gVal = $1F81
|
gVal = $1F81
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ GameCount = *+1
|
|||||||
; execution falls through here
|
; execution falls through here
|
||||||
.OnBrowseChanged
|
.OnBrowseChanged
|
||||||
+LDADDR gGamesListStore
|
+LDADDR gGamesListStore
|
||||||
jsr okvs_nth ; get the name of the new game
|
jsr okvs_nth ; get the filename of the new game
|
||||||
+STAY @key
|
+STAY @key
|
||||||
+STAY @key2
|
|
||||||
jsr GetOffscreenAddress ; load new title screenshot offscreen
|
jsr GetOffscreenAddress ; load new title screenshot offscreen
|
||||||
sta + ; new title screenshot (offscreen)
|
sta + ; new title screenshot (offscreen)
|
||||||
jsr LoadFile
|
jsr LoadFile
|
||||||
@ -106,34 +106,9 @@ GameCount = *+1
|
|||||||
!byte $00
|
!byte $00
|
||||||
+ !byte $FD ; SMC
|
+ !byte $FD ; SMC
|
||||||
|
|
||||||
jsr okvs_get
|
clc
|
||||||
!word gGamesListStore
|
jsr DrawSearchBarOffscreen
|
||||||
@key2 !word $FDFD
|
jmp ShowOtherPage
|
||||||
+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 gGameToLaunch
|
|
||||||
jsr BuildUILine1WithNoDots; build UI line 1 with bars and other shapes
|
|
||||||
ldx gGameToLaunch
|
|
||||||
jsr DrawSearchBarOffscreen; actually draw the UI (offscreen)
|
|
||||||
jmp ShowOtherPage ; now show everything at once
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -29,10 +29,65 @@ ToggleCheat
|
|||||||
@pref !byte 1
|
@pref !byte 1
|
||||||
@val !byte $FD
|
@val !byte $FD
|
||||||
|
|
||||||
BuildUILine1WithNoDots
|
BuildUILine1And2
|
||||||
; in: X = game index, or #$FF if no game selected
|
; in: gGameToLaunch = game index, or #$FF if no game selected
|
||||||
; out: all registers clobbered
|
; C set = print block cursor after game title and print dots to
|
||||||
; UILine1 contains 40-character buffer (not length-prefixed) to print
|
; highlight matching characters
|
||||||
|
; C clear = don't print either of those things
|
||||||
|
; UILine1 and UILine2 each contain a 40-character buffer (not length-prefixed) to print
|
||||||
|
php
|
||||||
|
bcc + ; set up cursor printing if caller wanted that
|
||||||
|
lda #$7F
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
+
|
||||||
|
lda #" "
|
||||||
|
sta @printCursor+1
|
||||||
|
|
||||||
|
ldy #39 ; copy instructions to line 2
|
||||||
|
- lda Instructions,y
|
||||||
|
sta UILine2,y
|
||||||
|
dey
|
||||||
|
bpl -
|
||||||
|
|
||||||
|
ldx gGameToLaunch
|
||||||
|
cpx #$FF ; if no game, we're done with the bottom line
|
||||||
|
beq @doneWithLine2
|
||||||
|
|
||||||
|
+LDADDR gGamesListStore
|
||||||
|
jsr okvs_nth
|
||||||
|
+STAY +
|
||||||
|
|
||||||
|
jsr okvs_get
|
||||||
|
!word gGamesListStore
|
||||||
|
+ !word $FDFD
|
||||||
|
+STAY SRC ; (SRC) -> 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
|
||||||
|
beq @printCursor
|
||||||
|
lda #" "
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
@printCursor
|
||||||
|
lda #$FD ; SMC
|
||||||
|
+HIDE_NEXT_2_BYTES
|
||||||
|
@printTitleChar
|
||||||
|
lda (SRC),y ; copy game title to search UI
|
||||||
|
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 -
|
||||||
|
|
||||||
|
@doneWithLine2
|
||||||
|
ldx gGameToLaunch
|
||||||
ldy gCheatsAvailable,x
|
ldy gCheatsAvailable,x
|
||||||
cpx #$FF
|
cpx #$FF
|
||||||
bne +
|
bne +
|
||||||
@ -45,7 +100,7 @@ BuildUILine1WithNoDots
|
|||||||
bne -
|
bne -
|
||||||
|
|
||||||
bit gCheatsEnabled
|
bit gCheatsEnabled
|
||||||
bpl @done ; if cheats are not enabled, we're done
|
bpl @maybeDrawDots ; if no cheats, we don't need any curves on this line
|
||||||
|
|
||||||
lda .kCheatDescriptionLo,y
|
lda .kCheatDescriptionLo,y
|
||||||
sta PTR
|
sta PTR
|
||||||
@ -75,13 +130,35 @@ BuildUILine1WithNoDots
|
|||||||
lda #$08 ; rounded bottom-left character
|
lda #$08 ; rounded bottom-left character
|
||||||
sta UILine1,x
|
sta UILine1,x
|
||||||
|
|
||||||
@done rts
|
@maybeDrawDots
|
||||||
|
plp
|
||||||
|
bcc @doneHighlight
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
ldy #0
|
||||||
|
@dotloop
|
||||||
|
iny
|
||||||
|
lda (SRC),y ; (SRC) still points to game title
|
||||||
|
+LOW_ASCII_TO_LOWER
|
||||||
|
cmp InputBuffer,x
|
||||||
|
bne +
|
||||||
|
lda #$11 ; dot character
|
||||||
|
sta UILine1,y
|
||||||
|
inx
|
||||||
|
cpx InputLength ; if input buffer is exhausted, we're done
|
||||||
|
beq @doneHighlight
|
||||||
|
+ inc HTAB
|
||||||
|
cpy SAVE ; if game name is exhausted, we're done
|
||||||
|
bne @dotloop
|
||||||
|
@doneHighlight
|
||||||
|
rts
|
||||||
|
|
||||||
BuildCheatLine1
|
BuildCheatLine1
|
||||||
; in: X = game index, or #$FF if no game is selected
|
; in: gGameToLaunch = game index, or #$FF if no game is selected
|
||||||
; out: gPathname contains length-prefixed string to print centered
|
; out: gPathname contains length-prefixed string to print centered
|
||||||
; all registers clobbered
|
; all registers clobbered
|
||||||
; PTR clobbered
|
; PTR clobbered
|
||||||
|
ldx gGameToLaunch
|
||||||
ldy gCheatsAvailable,x
|
ldy gCheatsAvailable,x
|
||||||
cpx #$FF
|
cpx #$FF
|
||||||
bne +
|
bne +
|
||||||
@ -112,11 +189,12 @@ BuildCheatLine1
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
BuildCheatLine2
|
BuildCheatLine2
|
||||||
; in: X = game index, or #$FF if no game is selected
|
; in: gGameToLaunch = game index, or #$FF if no game is selected
|
||||||
; out: gPathname contains length-prefixed string to print centered
|
; out: gPathname contains length-prefixed string to print centered
|
||||||
; all registers clobbered
|
; all registers clobbered
|
||||||
; PTR clobbered
|
; PTR clobbered
|
||||||
; SAVE clobbered
|
; SAVE clobbered
|
||||||
|
ldx gGameToLaunch
|
||||||
ldy gCheatsAvailable,x
|
ldy gCheatsAvailable,x
|
||||||
cpx #$FF
|
cpx #$FF
|
||||||
bne +
|
bne +
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
; Public variables
|
; Public variables
|
||||||
; - OffscreenPage
|
; - OffscreenPage
|
||||||
; - UILine2
|
|
||||||
; - VisibleGameCount (set during init)
|
; - VisibleGameCount (set during init)
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -34,14 +33,6 @@ OffscreenPage
|
|||||||
; 1 = currently showing HGR page 1
|
; 1 = currently showing HGR page 1
|
||||||
; (so offscreen is page 2 @ $4000)
|
; (so offscreen is page 2 @ $4000)
|
||||||
|
|
||||||
UILine2
|
|
||||||
!byte 0,0,0,0,0,0,0,0,0,0
|
|
||||||
!byte 0,0,0,0,0,0,0,0,0,0
|
|
||||||
!byte 0,0,0,0,0,0,0,0,0,0
|
|
||||||
!byte 0
|
|
||||||
UI_ToPlay
|
|
||||||
!byte 0,0,0,0,0,0,0,0,0
|
|
||||||
|
|
||||||
Instructions
|
Instructions
|
||||||
!text "[Type to search, "
|
!text "[Type to search, "
|
||||||
!byte $0B
|
!byte $0B
|
||||||
@ -134,14 +125,18 @@ CoverFade
|
|||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; DrawSearchBarOffscreen
|
; DrawSearchBarOffscreen
|
||||||
; draw 2-line search UI on the HGR page that is not currently showing
|
; draw 2- or 4-line search/browse UI on the HGR page that is not currently
|
||||||
|
; showing
|
||||||
;
|
;
|
||||||
; in: X = game index, or #$FF if no game is selected
|
; in: gGameToLaunch = game index, or #$FF if no game is selected
|
||||||
|
; C set = print block cursor after game title and print dots to
|
||||||
|
; highlight matching characters
|
||||||
|
; C clear = don't print either of those things
|
||||||
; out: all flags and registers clobbered
|
; out: all flags and registers clobbered
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
DrawSearchBarOffscreen
|
DrawSearchBarOffscreen
|
||||||
txa
|
jsr BuildUILine1And2
|
||||||
pha
|
|
||||||
lda #22 ; draw visible search bar
|
lda #22 ; draw visible search bar
|
||||||
sta VTAB
|
sta VTAB
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
@ -153,12 +148,9 @@ DrawSearchBarOffscreen
|
|||||||
+LDADDR UILine2
|
+LDADDR UILine2
|
||||||
jsr Draw40Chars
|
jsr Draw40Chars
|
||||||
|
|
||||||
pla
|
|
||||||
bit gCheatsEnabled
|
bit gCheatsEnabled
|
||||||
bpl OffscreenDone ; if cheats are not enabled, we're done
|
bpl OffscreenDone ; if cheats are not enabled, we're done
|
||||||
|
|
||||||
pha
|
|
||||||
tax
|
|
||||||
lda #20
|
lda #20
|
||||||
sta VTAB
|
sta VTAB
|
||||||
jsr BuildCheatLine1
|
jsr BuildCheatLine1
|
||||||
@ -168,8 +160,6 @@ DrawSearchBarOffscreen
|
|||||||
jsr DrawCenteredString
|
jsr DrawCenteredString
|
||||||
|
|
||||||
inc VTAB
|
inc VTAB
|
||||||
pla
|
|
||||||
tax
|
|
||||||
jsr BuildCheatLine2
|
jsr BuildCheatLine2
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
ror
|
ror
|
||||||
|
@ -123,19 +123,12 @@ SearchMode
|
|||||||
lda InputLength
|
lda InputLength
|
||||||
bne @findMatchingTitle
|
bne @findMatchingTitle
|
||||||
; no input, reset params and UI
|
; no input, reset params and UI
|
||||||
lda #$FF
|
ldx #$FF
|
||||||
sta gGameToLaunch ; no game selected
|
stx gGameToLaunch ; no game selected
|
||||||
ldx #39 ; copy instructions to line 2
|
|
||||||
- lda Instructions,x
|
|
||||||
sta UILine2,x
|
|
||||||
dex
|
|
||||||
bpl -
|
|
||||||
jsr LoadTitleOffscreen
|
jsr LoadTitleOffscreen
|
||||||
ldx #$FF ; no game selected
|
clc
|
||||||
jsr BuildUILine1WithNoDots; build UI line 1 with bars and other shapes
|
jsr DrawSearchBarOffscreen
|
||||||
ldx #$FF ; no game selected
|
jsr ShowOtherPage
|
||||||
jsr DrawSearchBarOffscreen; draw everything at once (offscreen)
|
|
||||||
jsr ShowOtherPage ; show it all at once
|
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -157,9 +150,8 @@ SearchMode
|
|||||||
php ; (we'll use this later to skip reloading)
|
php ; (we'll use this later to skip reloading)
|
||||||
stx gGameToLaunch
|
stx gGameToLaunch
|
||||||
+LDADDR gGamesListStore
|
+LDADDR gGamesListStore
|
||||||
jsr okvs_nth ; get the name of the new best match
|
jsr okvs_nth ; get the filename of the new best match
|
||||||
+STAY @key
|
+STAY @key
|
||||||
+STAY @key2
|
|
||||||
plp
|
plp
|
||||||
bne +
|
bne +
|
||||||
jsr ToggleOffscreenPage ; Since we're not loading a new screenshot
|
jsr ToggleOffscreenPage ; Since we're not loading a new screenshot
|
||||||
@ -176,58 +168,9 @@ SearchMode
|
|||||||
+ !byte $FD ; SMC
|
+ !byte $FD ; SMC
|
||||||
|
|
||||||
@skipload
|
@skipload
|
||||||
jsr okvs_get
|
sec
|
||||||
!word gGamesListStore
|
jsr DrawSearchBarOffscreen
|
||||||
@key2 !word $FDFD
|
jmp ShowOtherPage
|
||||||
+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
|
|
||||||
beq @printCursor
|
|
||||||
lda #" "
|
|
||||||
+HIDE_NEXT_2_BYTES
|
|
||||||
@printCursor
|
|
||||||
lda #$7F
|
|
||||||
+HIDE_NEXT_2_BYTES
|
|
||||||
@printTitleChar
|
|
||||||
lda (SRC),y ; copy game title to search UI
|
|
||||||
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 gGameToLaunch
|
|
||||||
jsr BuildUILine1WithNoDots; build UI line 1 with bars and other shapes
|
|
||||||
|
|
||||||
; now add dots to UI line 1 to highlight matched characters
|
|
||||||
ldx #0
|
|
||||||
ldy #0
|
|
||||||
@dotloop
|
|
||||||
iny
|
|
||||||
lda (SRC),y
|
|
||||||
+LOW_ASCII_TO_LOWER
|
|
||||||
cmp InputBuffer,x
|
|
||||||
bne +
|
|
||||||
lda #$11 ; dot character
|
|
||||||
sta UILine1,y
|
|
||||||
inx
|
|
||||||
cpx InputLength ; if input buffer is exhausted, we're done
|
|
||||||
beq @doneHighlight
|
|
||||||
+ inc HTAB
|
|
||||||
cpy SAVE ; if game name is exhausted, we're done
|
|
||||||
bne @dotloop
|
|
||||||
@doneHighlight
|
|
||||||
ldx gGameToLaunch
|
|
||||||
jsr DrawSearchBarOffscreen; actually draw the search UI (offscreen)
|
|
||||||
jmp ShowOtherPage ; now show everything at once
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user