mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2024-06-04 20:29:29 +00:00
add global preferences to save and restore current game
This commit is contained in:
parent
882a19e5b9
commit
237c04b697
BIN
res/pitchdark.po
BIN
res/pitchdark.po
Binary file not shown.
25
src/action.a
25
src/action.a
|
@ -31,10 +31,8 @@ kGameRootDirectory ; length-prefixed pathname of where game su
|
|||
!byte $EE,ID_NEXT ; n
|
||||
!byte $95,ID_NEXT ; right arrow
|
||||
; IDs of actions that do not correspond to WeeGUI view IDs have high bit set
|
||||
ID_QUIT = $80
|
||||
ID_SCROLLUP = $81
|
||||
ID_SCROLLDOWN = $82
|
||||
!byte $9B,ID_QUIT ; Esc
|
||||
!byte $8B,ID_SCROLLUP ; up arrow
|
||||
!byte $8A,ID_SCROLLDOWN ; down arrow
|
||||
.endkeys
|
||||
|
@ -44,10 +42,7 @@ ID_SCROLLDOWN = $82
|
|||
; handle keypress to activate various UI elements
|
||||
;
|
||||
; in: A contains key pressed
|
||||
; out: C set if program should quit
|
||||
; C clear otherwise (no other indication of whether the specific key
|
||||
; was handled or not)
|
||||
; all registers and other flags clobbered
|
||||
; out: all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
HandleKey
|
||||
ldx #.endkeys-.keys
|
||||
|
@ -56,7 +51,7 @@ HandleKey
|
|||
dex
|
||||
dex
|
||||
bpl -
|
||||
bra .unhandled
|
||||
rts
|
||||
.foundKey
|
||||
lda .keys+1,x
|
||||
bpl .activateView
|
||||
|
@ -64,9 +59,7 @@ HandleKey
|
|||
beq .handleScrollUp
|
||||
cmp #ID_SCROLLDOWN
|
||||
beq .handleScrollDown
|
||||
cmp #ID_QUIT
|
||||
beq .tellCallerToQuit
|
||||
bra .unhandled
|
||||
rts
|
||||
.handleScrollUp
|
||||
lda #$01
|
||||
!byte $2C ; hide next LDA
|
||||
|
@ -90,13 +83,7 @@ HandleKey
|
|||
ldx #WGViewFocusAction
|
||||
jsr WeeGUI
|
||||
ldx #WGViewUnfocus
|
||||
jsr WeeGUI
|
||||
.unhandled
|
||||
clc
|
||||
rts
|
||||
.tellCallerToQuit
|
||||
sec
|
||||
rts
|
||||
jmp WeeGUI
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
|
@ -117,7 +104,6 @@ callback_next
|
|||
.loadNewGameInfoAndRepaint
|
||||
jsr LoadGameInfo
|
||||
jmp RepaintSomeViews
|
||||
jmp $ff59
|
||||
|
||||
callback_play
|
||||
jmp LaunchInterpreter
|
||||
|
@ -128,6 +114,7 @@ callback_options
|
|||
rts
|
||||
|
||||
LaunchInterpreter
|
||||
jsr SaveGlobalPreferences
|
||||
jsr ResetPath
|
||||
lda #<.interpreterFilename
|
||||
ldy #>.interpreterFilename
|
||||
|
@ -136,7 +123,7 @@ LaunchInterpreter
|
|||
!word gPathname
|
||||
!word $2000
|
||||
!word $2000
|
||||
!word $1C00
|
||||
!word kProDOSFileBuffer
|
||||
bcs .nope
|
||||
; change prefix to folder of file we want the interpreter to open
|
||||
jsr ResetPath
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
;
|
||||
; Public functions
|
||||
; - LoadGameInfo
|
||||
; - AddToPath
|
||||
;
|
||||
; Public variables
|
||||
; - gCurrentGame
|
||||
|
@ -172,7 +171,7 @@ LoadGameInfo
|
|||
!word gPathname
|
||||
!word $0800
|
||||
!word $1400
|
||||
!word $1C00
|
||||
!word kProDOSFileBuffer
|
||||
bcc .parseGameInfo
|
||||
rts
|
||||
|
||||
|
|
9
src/memory.a
Normal file
9
src/memory.a
Normal file
|
@ -0,0 +1,9 @@
|
|||
;license:MIT
|
||||
;(c) 2018 by 4am
|
||||
;
|
||||
; Memory addresses and constants
|
||||
;
|
||||
; Public constants
|
||||
; - kProDOSFileBuffer
|
||||
|
||||
kProDOSFileBuffer = $1C00
|
|
@ -96,6 +96,7 @@ CreateViews
|
|||
; CreateViews has been called
|
||||
; out: all registers clobbered
|
||||
; all flags clobbered
|
||||
; $00/$01 clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
PaintAllViews
|
||||
ldx #WGViewPaintAll ; repaint all views that can be painted automatically
|
||||
|
|
|
@ -29,6 +29,8 @@ ResetPath
|
|||
; in: A contains low byte of address of length-prefixed string to append
|
||||
; Y contains high byte of address of length-prefixed string to append
|
||||
; out: all registers and flags clobbered
|
||||
; $00/$01 clobbered
|
||||
; gPathname updated with concatenated length-prefixed string
|
||||
;------------------------------------------------------------------------------
|
||||
AddToPath
|
||||
sta $00
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
!raw "BIN/WEEGUI"
|
||||
|
||||
!source "WeeGUI_MLI.s"
|
||||
!source "memory.a"
|
||||
!source "prodos.a"
|
||||
!source "ramdisk.a"
|
||||
!source "path.a"
|
||||
!source "prefs.a"
|
||||
!source "config.a"
|
||||
!source "action.a"
|
||||
!source "paint.a"
|
||||
|
@ -38,11 +40,11 @@ Start
|
|||
!word .weeguiFilename
|
||||
!word $4000
|
||||
!word $2000
|
||||
!word $1C00
|
||||
!word kProDOSFileBuffer
|
||||
|
||||
jsr $4000 ; initialize WeeGUI
|
||||
|
||||
lda #22 ; TODO load this from a prefs file instead
|
||||
sta gCurrentGame
|
||||
jsr LoadGlobalPreferences ; get current game
|
||||
jsr LoadGameInfo ; load and parse game description text
|
||||
|
||||
jsr CreateViews ; create all WeeGUI views (UI elements)
|
||||
|
@ -58,10 +60,7 @@ Start
|
|||
bpl .runLoop
|
||||
bit $c010
|
||||
jsr HandleKey
|
||||
bcc .runLoop
|
||||
|
||||
jsr ExitWeeGUI
|
||||
jmp QuitToProDOS ; quit via ProDOS MLI
|
||||
bra .runLoop
|
||||
|
||||
ExitWeeGUI
|
||||
ldx #WGDisableMouse ; disable mouse support before quitting
|
||||
|
|
53
src/prefs.a
Normal file
53
src/prefs.a
Normal file
|
@ -0,0 +1,53 @@
|
|||
;license:MIT
|
||||
;(c) 2018 by 4am
|
||||
;
|
||||
; Global and per-game preferences
|
||||
;
|
||||
; Public functions
|
||||
; - LoadGlobalPreferences
|
||||
|
||||
!zone {
|
||||
kDefaultGame = 22 ; Zork I
|
||||
kPrefsRecord = $0800
|
||||
kPrefsLength = 1
|
||||
kPrefsCurrentGame = kPrefsRecord + 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadGlobalPreferences
|
||||
;
|
||||
; in: current ProDOS prefix is the same as the PITCH.DARK binary
|
||||
; out: all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
LoadGlobalPreferences
|
||||
jsr LoadFile ; load prefs file at $0800
|
||||
!word .globalPrefsFilename
|
||||
!word kPrefsRecord
|
||||
!word kPrefsLength
|
||||
!word kProDOSFileBuffer
|
||||
bcs .useDefaults
|
||||
lda kPrefsCurrentGame
|
||||
cmp #kNumberOfGames
|
||||
bcs .useDefaults
|
||||
sta gCurrentGame
|
||||
rts
|
||||
.useDefaults
|
||||
lda #kDefaultGame
|
||||
sta gCurrentGame
|
||||
rts
|
||||
|
||||
SaveGlobalPreferences
|
||||
lda gCurrentGame
|
||||
sta kPrefsCurrentGame
|
||||
jsr SaveFile
|
||||
!word .globalPrefsFilename
|
||||
!byte $06
|
||||
!word $0000
|
||||
!word kPrefsRecord
|
||||
!word kPrefsLength
|
||||
!word kProDOSFileBuffer
|
||||
rts
|
||||
|
||||
.globalPrefsFilename
|
||||
!byte 15
|
||||
!raw "PITCH.DARK.CONF"
|
||||
}
|
Loading…
Reference in New Issue
Block a user