mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-01-16 20:32:59 +00:00
Add letters to select games from catalog, add buttons
This commit is contained in:
parent
ffa073569b
commit
addc11e219
298
src/ui.catalog.a
298
src/ui.catalog.a
@ -9,22 +9,22 @@
|
|||||||
|
|
||||||
; View IDs (application-specific, acceptable range 0..15, no duplicates)
|
; View IDs (application-specific, acceptable range 0..15, no duplicates)
|
||||||
ID_CATALOG_FRAME = 1
|
ID_CATALOG_FRAME = 1
|
||||||
ID_CATALOG_OK = 2
|
ID_CATALOG_MAIN = 2
|
||||||
ID_CATALOG_CANCEL = 3
|
ID_CATALOG_PREVIOUS = 3
|
||||||
ID_CATALOG_PREVIOUS = 4
|
ID_CATALOG_NEXT = 4
|
||||||
ID_CATALOG_NEXT = 5
|
|
||||||
|
|
||||||
; action keys for catalog screen
|
; action keys for catalog screen
|
||||||
kCatalogKeys
|
kCatalogKeys
|
||||||
!byte $8D,ID_CATALOG_OK ; Return
|
!byte $8D,ID_CATALOG_MAIN ; <Return>
|
||||||
!byte $9B,ID_CATALOG_CANCEL ; Esc
|
!byte $9B,ID_CATALOG_MAIN ; <Esc>
|
||||||
!byte $88,ID_CATALOG_PREVIOUS ; left arrow
|
!byte $88,ID_CATALOG_PREVIOUS ; left arrow
|
||||||
!byte $8B,ID_CATALOG_PREVIOUS ; up arrow
|
!byte $8B,ID_CATALOG_PREVIOUS ; up arrow
|
||||||
!byte $95,ID_CATALOG_NEXT ; right arrow
|
!byte $95,ID_CATALOG_NEXT ; right arrow
|
||||||
!byte $8A,ID_CATALOG_NEXT ; down arrow
|
!byte $8A,ID_CATALOG_NEXT ; down arrow
|
||||||
|
!byte $A0,ID_CATALOG_NEXT ; <Space>
|
||||||
_endCatalogKeys
|
_endCatalogKeys
|
||||||
|
|
||||||
MAXGAMES = 20 ; max number of displayed games
|
MAXGAMES = 18 ; max number of displayed games
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; CatalogDialog
|
; CatalogDialog
|
||||||
@ -39,15 +39,24 @@ CatalogDialog
|
|||||||
txs
|
txs
|
||||||
jsr HardResetWeeGUI
|
jsr HardResetWeeGUI
|
||||||
|
|
||||||
|
ldx #WGClearScreen ; paint background
|
||||||
|
jsr WeeGUI
|
||||||
|
|
||||||
jsr CreateDialog ; create decorated frame
|
jsr CreateDialog ; create decorated frame
|
||||||
!word kViewCatalogFrame
|
!word kViewCatalogFrame
|
||||||
!word kStringCatalogFrame
|
!word kStringCatalogFrame
|
||||||
|
|
||||||
ldx #WGDesktop ; paint background
|
|
||||||
jsr WeeGUI
|
|
||||||
|
|
||||||
jsr PaintTitleBar ; paint top title bar
|
jsr PaintTitleBar ; paint top title bar
|
||||||
|
|
||||||
|
jsr CreateButton ; create 'previous' button
|
||||||
|
!word kViewCatalogPrevious
|
||||||
|
|
||||||
|
jsr CreateButton ; create 'next' button
|
||||||
|
!word kViewCatalogNext
|
||||||
|
|
||||||
|
jsr CreateButton ; create 'main' button
|
||||||
|
!word kViewCatalogMain
|
||||||
|
|
||||||
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
|
ldx #WGViewPaintAll ; paint UI controls (window frame, buttons, checkboxes, radio buttons)
|
||||||
jsr WeeGUI
|
jsr WeeGUI
|
||||||
|
|
||||||
@ -55,167 +64,217 @@ CatalogDialog
|
|||||||
lda #ID_CATALOG_FRAME
|
lda #ID_CATALOG_FRAME
|
||||||
jsr WeeGUI
|
jsr WeeGUI
|
||||||
|
|
||||||
lda @gameCount
|
lda gameCount
|
||||||
bne @alreadyCounted
|
bne @alreadyCounted
|
||||||
jsr okvs_iter ; count the total number of games
|
jsr okvs_iter ; count the total number of games
|
||||||
!word gGamesListStore
|
!word gGamesListStore
|
||||||
!word @countGames
|
!word countGames
|
||||||
@alreadyCounted
|
@alreadyCounted
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta startIndex
|
||||||
lda #$FD ; reset previous start index just in case
|
lda #$FD ; reset previous start index just in case
|
||||||
sta @prevStartIndex
|
sta prevStartIndex
|
||||||
jsr @RefreshCatalog
|
jsr RefreshCatalog
|
||||||
|
|
||||||
; WeeGUI cursor/key loop
|
; WeeGUI cursor/key loop
|
||||||
jsr ClearPendingInput
|
jsr ClearPendingInput
|
||||||
- ldx #WGPendingViewAction
|
- ldx #WGPendingClick
|
||||||
|
jsr WeeGUI ; check for mouse click
|
||||||
|
cpx #$FF
|
||||||
|
beq @1
|
||||||
|
jsr HandleCatalogClick
|
||||||
|
@1 ldx #WGPendingViewAction
|
||||||
jsr WeeGUI ; handle mouse movement and clicks
|
jsr WeeGUI ; handle mouse movement and clicks
|
||||||
lda $C000
|
lda $C000
|
||||||
bpl -
|
bpl -
|
||||||
jsr ClearPendingInput
|
jsr ClearPendingInput
|
||||||
jsr @HandleCatalogKey ; handle keypresses
|
jsr HandleCatalogKey ; handle keypresses
|
||||||
bra -
|
bra -
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; internal functions
|
; internal functions
|
||||||
; !byte $01,$02,$03,$04,$05
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@RefreshCatalog
|
RefreshCatalog
|
||||||
jsr GetCurrentGameIndex
|
lda startIndex
|
||||||
stx @currGameIndex
|
cmp prevStartIndex ; avoid redrawing the list if possible
|
||||||
; Determine where to start in the game list
|
|
||||||
lda #0
|
|
||||||
sta @startIndex
|
|
||||||
sta @lineNum
|
|
||||||
lda @currGameIndex
|
|
||||||
cmp #MAXGAMES/2 ; within MAXGAMES/2 of start?
|
|
||||||
bcc @cont ; yes, start at top
|
|
||||||
clc
|
|
||||||
adc #MAXGAMES/2
|
|
||||||
cmp @gameCount ; within MAXGAMES/2 of the end?
|
|
||||||
bcc @1 ; no
|
|
||||||
lda @gameCount ; yes, start at end
|
|
||||||
@1 sec ; subtract off MAXGAMES
|
|
||||||
sbc #MAXGAMES
|
|
||||||
sta @startIndex
|
|
||||||
|
|
||||||
@cont ; Print out the list of games
|
|
||||||
lda @startIndex
|
|
||||||
cmp @prevStartIndex ; avoid redrawing the list if possible
|
|
||||||
beq @noRefreshNeeded
|
beq @noRefreshNeeded
|
||||||
sta @prevStartIndex
|
sta prevStartIndex
|
||||||
|
lda #1
|
||||||
|
sta lineNum
|
||||||
|
lda #$C1 ; letter 'A'
|
||||||
|
sta kIndex + 1
|
||||||
|
ldx #WGSelectView
|
||||||
|
jsr WeeGUI
|
||||||
|
ldx #WGEraseViewContents
|
||||||
|
jsr WeeGUI
|
||||||
jsr okvs_iter
|
jsr okvs_iter
|
||||||
!word gGamesListStore
|
!word gGamesListStore
|
||||||
!word @printCatalog
|
!word printCatalog
|
||||||
@noRefreshNeeded
|
@noRefreshNeeded
|
||||||
jsr @eraseOldCursor
|
rts
|
||||||
jmp @printCursor
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; !byte $01,$02,$03,$04,$05
|
; !byte $01,$02,$03,$04,$05
|
||||||
@currGameIndex
|
gameCount
|
||||||
!byte $FD ; SMC
|
|
||||||
@gameCount
|
|
||||||
!byte $00 ; SMC
|
!byte $00 ; SMC
|
||||||
@startIndex
|
startIndex
|
||||||
!byte $FD ; SMC
|
!byte $FD ; SMC
|
||||||
@prevStartIndex
|
prevStartIndex
|
||||||
!byte $FD ; SMC
|
!byte $FD ; SMC
|
||||||
|
|
||||||
; Count up the total number of games
|
; Count up the total number of games
|
||||||
@countGames
|
countGames
|
||||||
inc @gameCount
|
inc gameCount
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Add an arrow cursor next to current game
|
HandleCatalogClick
|
||||||
@printCursor
|
cpx #8
|
||||||
lda @currGameIndex
|
bcc @outOfBounds
|
||||||
sec
|
cpx #68
|
||||||
sbc @startIndex
|
bcs @outOfBounds
|
||||||
sta @line1
|
cpy #2
|
||||||
jsr PrintAt
|
bcc @outOfBounds
|
||||||
!byte 1
|
tya
|
||||||
@line1 !byte $00 ; SMC
|
clc
|
||||||
!word @kStringCursor
|
adc #$BF ; convert Y pos into 'A'-'Z' key
|
||||||
rts
|
bra isUpper
|
||||||
@kStringCursor
|
@outOfBounds
|
||||||
!text "---->",0
|
jmp SoftBell
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Erase previous arrow cursor
|
; HandleCatalogKey
|
||||||
@eraseOldCursor
|
|
||||||
lda @line1
|
|
||||||
sta @line2
|
|
||||||
jsr PrintAt
|
|
||||||
!byte 1
|
|
||||||
@line2 !byte $FD ; SMC
|
|
||||||
!word @kStringErase
|
|
||||||
@done
|
|
||||||
rts
|
|
||||||
@kStringErase
|
|
||||||
!text " ",0
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
; Print out a single game name, A/Y contains key, X contains index
|
|
||||||
@printCatalog
|
|
||||||
cpx @startIndex
|
|
||||||
bcc @skip
|
|
||||||
+STAY @key
|
|
||||||
jsr okvs_get
|
|
||||||
!word gGamesListStore
|
|
||||||
@key !word $FDFD ; SMC
|
|
||||||
ldx #55
|
|
||||||
jsr CreateNullTerminatedString ; copies string to kNullTerminatedBuffer
|
|
||||||
jsr PrintAt
|
|
||||||
!byte 6
|
|
||||||
@lineNum !byte $FD ; SMC
|
|
||||||
!word kNullTerminatedBuffer
|
|
||||||
inc @lineNum
|
|
||||||
@skip rts
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
; HandleCatalog
|
|
||||||
;
|
;
|
||||||
; in: A = key pressed
|
; in: A = key pressed
|
||||||
; out: all registers and flags clobbered
|
; out: all registers and flags clobbered
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@HandleCatalogKey
|
HandleCatalogKey
|
||||||
|
cmp #$E0
|
||||||
|
bcc isUpper
|
||||||
|
and #%11011111 ; convert lower to uppercase
|
||||||
|
isUpper
|
||||||
|
cmp #$C1 ; 'A'
|
||||||
|
bcc @notLetter
|
||||||
|
cmp kIndex + 1
|
||||||
|
bcs @notLetter
|
||||||
|
; we have an uppercase letter, convert to game index
|
||||||
|
and #%00011111
|
||||||
|
clc
|
||||||
|
adc startIndex
|
||||||
|
tax
|
||||||
|
dex
|
||||||
|
jsr loadNewGameInfoAndRepaint
|
||||||
|
@main jmp MainScreen
|
||||||
|
@notLetter
|
||||||
ldx #(_endCatalogKeys-kCatalogKeys)-2
|
ldx #(_endCatalogKeys-kCatalogKeys)-2
|
||||||
- cmp kCatalogKeys,x
|
- cmp kCatalogKeys,x
|
||||||
beq @found
|
beq @activateView
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
bpl -
|
bpl -
|
||||||
jmp SoftBell
|
@error jmp SoftBell
|
||||||
@found lda kCatalogKeys+1,x
|
|
||||||
cmp #ID_CATALOG_OK
|
|
||||||
beq @callback_catalog_ok
|
|
||||||
cmp #ID_CATALOG_CANCEL
|
|
||||||
beq @callback_catalog_cancel
|
|
||||||
cmp #ID_CATALOG_PREVIOUS
|
|
||||||
bne @next
|
|
||||||
jsr callback_previous
|
|
||||||
jmp @RefreshCatalog
|
|
||||||
@next jsr callback_next
|
|
||||||
jmp @RefreshCatalog
|
|
||||||
|
|
||||||
@callback_catalog_ok
|
@activateView
|
||||||
jsr SoftBell
|
lda kCatalogKeys+1,x
|
||||||
|
tax
|
||||||
|
ldy gViewInUse,x
|
||||||
|
beq @error
|
||||||
|
ldx #WGSelectView
|
||||||
|
jsr WeeGUI
|
||||||
|
@click jmp SimulateClick
|
||||||
|
|
||||||
|
catalog_next
|
||||||
|
lda startIndex
|
||||||
|
clc
|
||||||
|
adc #MAXGAMES ; page forward and refresh
|
||||||
|
cmp gameCount
|
||||||
|
beq @good
|
||||||
|
bcc @good
|
||||||
|
jmp SoftBell ; at end of list
|
||||||
|
@good sta startIndex
|
||||||
|
jmp RefreshCatalog
|
||||||
|
|
||||||
|
catalog_previous
|
||||||
|
lda startIndex
|
||||||
|
bne @1
|
||||||
|
jmp SoftBell ; at beginning of list
|
||||||
|
@1
|
||||||
|
sec
|
||||||
|
sbc #MAXGAMES ; page back and refresh
|
||||||
|
sta startIndex
|
||||||
|
jmp RefreshCatalog
|
||||||
|
|
||||||
|
catalog_main
|
||||||
jmp MainScreen
|
jmp MainScreen
|
||||||
|
|
||||||
@callback_catalog_cancel
|
;------------------------------------------------------------------------------
|
||||||
jmp MainScreen
|
; Print out a single game name, A/Y contains key, X contains index
|
||||||
|
printCatalog
|
||||||
|
cpx startIndex
|
||||||
|
bcc @skip
|
||||||
|
ldx lineNum
|
||||||
|
dex
|
||||||
|
cpx #MAXGAMES
|
||||||
|
bcc +
|
||||||
|
@skip rts
|
||||||
|
+ +STAY @key
|
||||||
|
jsr okvs_get
|
||||||
|
!word gGamesListStore
|
||||||
|
@key !word $FDFD ; SMC
|
||||||
|
ldx #55 ; maximum string length
|
||||||
|
jsr CreateNullTerminatedString ; copies string to kNullTerminatedBuffer
|
||||||
|
jsr PrintAt
|
||||||
|
!byte 8
|
||||||
|
lineNum !byte $FD ; SMC
|
||||||
|
!word kNullTerminatedBuffer
|
||||||
|
lda lineNum
|
||||||
|
sta @ln2
|
||||||
|
jsr PrintAt
|
||||||
|
!byte 4
|
||||||
|
@ln2 !byte $FD ; SMC
|
||||||
|
!word kIndex
|
||||||
|
inc lineNum
|
||||||
|
inc kIndex + 1
|
||||||
|
rts
|
||||||
|
|
||||||
|
kIndex
|
||||||
|
!text "[A]",0
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; WeeGUI view configuration records
|
; WeeGUI view configuration records
|
||||||
|
|
||||||
|
kViewCatalogPrevious
|
||||||
|
!byte ID_CATALOG_PREVIOUS ; view ID
|
||||||
|
!byte 1 ; left
|
||||||
|
!byte 22 ; top
|
||||||
|
!byte 13 ; width
|
||||||
|
!word catalog_previous ; callback
|
||||||
|
!word kStringCatPrevious ; caption
|
||||||
|
|
||||||
|
kViewCatalogNext
|
||||||
|
!byte ID_CATALOG_NEXT ; view ID
|
||||||
|
!byte 66 ; left
|
||||||
|
!byte 22 ; top
|
||||||
|
!byte 13 ; width
|
||||||
|
!word catalog_next ; callback
|
||||||
|
!word kStringCatNext ; caption
|
||||||
|
|
||||||
|
kViewCatalogMain
|
||||||
|
!byte ID_CATALOG_MAIN ; view ID
|
||||||
|
!byte 34 ; left
|
||||||
|
!byte 22 ; top
|
||||||
|
!byte 14 ; width
|
||||||
|
!word catalog_main ; callback
|
||||||
|
!word kStringCatMain ; caption
|
||||||
|
|
||||||
kViewCatalogFrame
|
kViewCatalogFrame
|
||||||
!byte ID_CATALOG_FRAME ; view ID
|
!byte ID_CATALOG_FRAME ; view ID
|
||||||
!byte 0 ; style (decorated frame)
|
!byte 0 ; style (decorated frame)
|
||||||
!byte 4 ; left
|
!byte 4 ; left
|
||||||
!byte 2 ; top
|
!byte 1 ; top
|
||||||
!byte 72 ; visible width
|
!byte 72 ; visible width
|
||||||
!byte 20 ; visible height
|
!byte 20 ; visible height
|
||||||
!byte 72 ; width
|
!byte 72 ; width
|
||||||
@ -223,3 +282,12 @@ kViewCatalogFrame
|
|||||||
|
|
||||||
kStringCatalogFrame
|
kStringCatalogFrame
|
||||||
!text "Catalog",0
|
!text "Catalog",0
|
||||||
|
|
||||||
|
kStringCatPrevious
|
||||||
|
!text "<--",0
|
||||||
|
|
||||||
|
kStringCatNext
|
||||||
|
!text "-->",0
|
||||||
|
|
||||||
|
kStringCatMain
|
||||||
|
!text "<ESC> Main",0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user