mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-02-11 22:30:37 +00:00
Merge pull request #8 from chris-torrence/master
Add support for game Catalog, fixes #3
This commit is contained in:
commit
3bd842387b
BIN
bin/V2Make.scpt
BIN
bin/V2Make.scpt
Binary file not shown.
@ -37,6 +37,7 @@
|
||||
!source "src/ui.main.a"
|
||||
!source "src/ui.main.keys.a"
|
||||
!source "src/ui.options.a"
|
||||
!source "src/ui.catalog.a"
|
||||
!source "src/ui.resume.a"
|
||||
!source "src/ui.versions.a"
|
||||
!source "src/ui.artwork.a"
|
||||
|
283
src/ui.catalog.a
Normal file
283
src/ui.catalog.a
Normal file
@ -0,0 +1,283 @@
|
||||
;license:MIT
|
||||
;(c) 2018 by 4am
|
||||
;
|
||||
; User interface - views and paint routines for catalog screen
|
||||
;
|
||||
; Public functions
|
||||
; - CatalogDialog
|
||||
;
|
||||
|
||||
; View IDs (application-specific, acceptable range 0..15, no duplicates)
|
||||
ID_CATALOG_FRAME = 1
|
||||
ID_CATALOG_MAIN = 2
|
||||
ID_CATALOG_PREVIOUS = 3
|
||||
ID_CATALOG_NEXT = 4
|
||||
|
||||
; action keys for catalog screen
|
||||
kCatalogKeys
|
||||
!byte $8D,ID_CATALOG_MAIN ; <Return>
|
||||
!byte $9B,ID_CATALOG_MAIN ; <Esc>
|
||||
!byte $88,ID_CATALOG_PREVIOUS ; left arrow
|
||||
!byte $8B,ID_CATALOG_PREVIOUS ; up arrow
|
||||
!byte $95,ID_CATALOG_NEXT ; right arrow
|
||||
!byte $8A,ID_CATALOG_NEXT ; down arrow
|
||||
!byte $A0,ID_CATALOG_NEXT ; <Space>
|
||||
_endCatalogKeys
|
||||
|
||||
MAXGAMES = 18 ; max number of displayed games
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; CatalogDialog
|
||||
; call WeeGUI to create and paint option screen, and run to completion
|
||||
;
|
||||
; in: WeeGUI initialized
|
||||
; out: exits via MainScreen
|
||||
; all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
CatalogDialog
|
||||
ldx #$FF
|
||||
txs
|
||||
jsr HardResetWeeGUI
|
||||
|
||||
ldx #WGClearScreen ; paint background
|
||||
jsr WeeGUI
|
||||
|
||||
jsr CreateDialog ; create decorated frame
|
||||
!word kViewCatalogFrame
|
||||
!word kStringCatalogFrame
|
||||
|
||||
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)
|
||||
jsr WeeGUI
|
||||
|
||||
lda gameCount
|
||||
bne @alreadyCounted
|
||||
jsr okvs_iter ; count the total number of games
|
||||
!word gGamesListStore
|
||||
!word countGames
|
||||
@alreadyCounted
|
||||
|
||||
lda #0
|
||||
sta startIndex
|
||||
jsr RefreshCatalog
|
||||
|
||||
; WeeGUI cursor/key loop
|
||||
jsr ClearPendingInput
|
||||
- ldx #WGPendingClick ; since our game list isn't WeeGUI buttons
|
||||
jsr WeeGUI ; we need to manually check for mouse click
|
||||
cpx #$FF
|
||||
beq @1 ; no click
|
||||
jsr HandleCatalogClick ; yes, mouse click
|
||||
@1 ldx #WGPendingViewAction
|
||||
jsr WeeGUI ; handle mouse movement and clicks
|
||||
lda $C000
|
||||
bpl -
|
||||
jsr ClearPendingInput
|
||||
jsr HandleCatalogKey ; handle keypresses
|
||||
bra -
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; internal functions
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
RefreshCatalog
|
||||
lda #ID_CATALOG_FRAME
|
||||
ldx #WGSelectView ; select frame (required for print routines)
|
||||
jsr WeeGUI
|
||||
ldx #WGEraseViewContents
|
||||
jsr WeeGUI
|
||||
lda #1 ; start at second line within text frame
|
||||
sta catLineNum
|
||||
lda #$C1 ; letter 'A', first game in game list
|
||||
sta kCatLetter + 1
|
||||
jsr okvs_iter
|
||||
!word gGamesListStore
|
||||
!word printCatalog
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; !byte $01,$02,$03,$04,$05
|
||||
gameCount
|
||||
!byte $00 ; SMC
|
||||
startIndex
|
||||
!byte $FD ; SMC
|
||||
|
||||
; Count up the total number of games
|
||||
countGames
|
||||
inc gameCount
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Print out a single game name/letter, A/Y contains key, X contains index
|
||||
printCatalog
|
||||
cpx startIndex ; skip until we reach our current start index
|
||||
bcc @skip
|
||||
ldx catLineNum
|
||||
dex
|
||||
cpx #MAXGAMES ; are we on the last line?
|
||||
bcc +
|
||||
@skip rts
|
||||
+ +STAY @key
|
||||
jsr okvs_get ; retrieve the game name
|
||||
!word gGamesListStore
|
||||
@key !word $FDFD ; SMC
|
||||
ldx #55 ; maximum string length
|
||||
jsr CreateNullTerminatedString ; copies string to kNullTerminatedBuffer
|
||||
jsr PrintAt
|
||||
!byte 8
|
||||
catLineNum
|
||||
!byte $FD ; SMC
|
||||
!word kNullTerminatedBuffer
|
||||
lda catLineNum
|
||||
sta @ln2
|
||||
jsr PrintAt ; print a letter key next to each game
|
||||
!byte 4
|
||||
@ln2 !byte $FD ; SMC
|
||||
!word kCatLetter
|
||||
|
||||
inc catLineNum
|
||||
inc kCatLetter + 1
|
||||
rts
|
||||
|
||||
kCatLetter
|
||||
!text "[A]",0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; User clicked on the screen, X, Y contain absolute mouse position
|
||||
HandleCatalogClick
|
||||
cpx #8
|
||||
bcc @outOfBounds
|
||||
cpx #68
|
||||
bcs @outOfBounds
|
||||
cpy #2
|
||||
bcc @outOfBounds
|
||||
tya
|
||||
clc
|
||||
adc #$BF ; convert Y pos into 'A'-'Z' key
|
||||
bra isUppercaseKey ; use our keyboard handler to verify
|
||||
@outOfBounds
|
||||
jmp SoftBell
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; HandleCatalogKey
|
||||
;
|
||||
; in: A = key pressed
|
||||
; out: all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
HandleCatalogKey
|
||||
cmp #$E0
|
||||
bcc isUppercaseKey
|
||||
and #%11011111 ; convert lower to uppercase
|
||||
isUppercaseKey
|
||||
cmp #$C1 ; 'A'
|
||||
bcc @notLetter
|
||||
cmp kCatLetter + 1 ; highest key (+1) on the game list
|
||||
bcs @notLetter
|
||||
; convert uppercase letter to game index (+1)
|
||||
and #%00011111
|
||||
clc
|
||||
adc startIndex
|
||||
tax
|
||||
dex
|
||||
jsr loadNewGameInfoAndRepaint
|
||||
@main jmp MainScreen
|
||||
@notLetter ; handle other (non-game) keys
|
||||
ldx #(_endCatalogKeys-kCatalogKeys)-2
|
||||
- cmp kCatalogKeys,x
|
||||
beq @activateView
|
||||
dex
|
||||
dex
|
||||
bpl -
|
||||
@error jmp SoftBell
|
||||
|
||||
@activateView
|
||||
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
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; 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
|
||||
!byte ID_CATALOG_FRAME ; view ID
|
||||
!byte 0 ; style (decorated frame)
|
||||
!byte 4 ; left
|
||||
!byte 1 ; top
|
||||
!byte 72 ; visible width
|
||||
!byte 20 ; visible height
|
||||
!byte 72 ; width
|
||||
!byte 20 ; height
|
||||
|
||||
kStringCatalogFrame
|
||||
!text "Catalog",0
|
||||
|
||||
kStringCatPrevious
|
||||
!text "<--",0
|
||||
|
||||
kStringCatNext
|
||||
!text "-->",0
|
||||
|
||||
kStringCatMain
|
||||
!text "<ESC> Main",0
|
@ -21,6 +21,7 @@ ID_VERSIONS = 7
|
||||
ID_INFO = 8
|
||||
ID_DESCRIPTION = 9
|
||||
ID_ABOUT = 10
|
||||
ID_CATALOG = 11
|
||||
|
||||
gMainScreenPaintDirty
|
||||
!byte 0
|
||||
@ -75,6 +76,9 @@ RepaintMainIfDirty
|
||||
jsr CreateButton ; create 'previous' button
|
||||
!word kViewPrevious
|
||||
|
||||
jsr CreateButton ; create 'catalog' button
|
||||
!word kViewCatalog
|
||||
|
||||
jsr CreateButton ; create 'settings' button
|
||||
!word kViewOptions
|
||||
|
||||
@ -312,9 +316,17 @@ kViewNext
|
||||
!word callback_next ; callback
|
||||
!word kStringNext ; caption
|
||||
|
||||
kViewCatalog
|
||||
!byte ID_CATALOG ; view ID
|
||||
!byte 27 ; left
|
||||
!byte 2 ; top
|
||||
!byte 11 ; width
|
||||
!word CatalogDialog ; callback
|
||||
!word kStringCatalog
|
||||
|
||||
kViewOptions
|
||||
!byte ID_OPTIONS ; view ID
|
||||
!byte 34 ; left
|
||||
!byte 41 ; left
|
||||
!byte 2 ; top
|
||||
!byte 12 ; width
|
||||
!word OptionsDialog ; callback
|
||||
@ -395,7 +407,9 @@ kStringPrevious
|
||||
kStringNext
|
||||
!byte $0E ; 'N' inverse
|
||||
!text "ext game >",0
|
||||
|
||||
kStringCatalog
|
||||
!byte $03 ; 'C' inverse
|
||||
!text "atalog",0
|
||||
kStringOptions
|
||||
!byte $13 ; 'S' inverse
|
||||
!text "ettings",0
|
||||
|
@ -28,6 +28,8 @@ kMainKeys
|
||||
!byte $E1,ID_BOXART ; a
|
||||
!byte $D6,ID_VERSIONS ; V
|
||||
!byte $F6,ID_VERSIONS ; v
|
||||
!byte $C3,ID_CATALOG ; C
|
||||
!byte $E3,ID_CATALOG ; c
|
||||
!byte $D3,ID_OPTIONS ; S
|
||||
!byte $F3,ID_OPTIONS ; s
|
||||
!byte $D0,ID_PREVIOUS ; P
|
||||
|
Loading…
x
Reference in New Issue
Block a user