2018-02-09 01:38:26 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
2018-04-15 16:29:24 +00:00
|
|
|
; Parser for global preferences file
|
2018-02-09 01:38:26 +00:00
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - LoadGlobalPreferences
|
2018-03-24 23:03:00 +00:00
|
|
|
; - SaveGlobalPreferences
|
2018-03-16 18:17:45 +00:00
|
|
|
;
|
|
|
|
; Public variables
|
2018-04-18 19:28:55 +00:00
|
|
|
; - gGlobalPrefsStore word address of prefs okvs (set in LoadGameList)
|
|
|
|
; - gGlobalPrefsDirty byte 0=false, nonzero=true
|
2018-03-27 21:17:47 +00:00
|
|
|
; set to 1 if prefs have changed. SaveGlobalPreferences won't write to disk if this is 0.
|
2018-03-24 23:03:00 +00:00
|
|
|
;
|
2018-03-27 21:17:47 +00:00
|
|
|
; Public constants (all length-prefixed strings)
|
2018-04-18 20:39:59 +00:00
|
|
|
; - kGlobalPrefsFilename
|
2018-03-24 23:03:00 +00:00
|
|
|
; - kForce40
|
|
|
|
; - kForceUpper
|
2018-03-26 18:57:06 +00:00
|
|
|
; - kScriptToFile
|
|
|
|
; - kAutoScript
|
2018-03-24 23:03:00 +00:00
|
|
|
; - kLastPlayed
|
2018-03-26 18:57:06 +00:00
|
|
|
;
|
2018-02-09 01:38:26 +00:00
|
|
|
|
|
|
|
!zone {
|
2018-03-28 15:48:47 +00:00
|
|
|
gGlobalPrefsStore
|
|
|
|
!word 0
|
|
|
|
|
2018-04-01 22:26:54 +00:00
|
|
|
gGlobalPrefsDirty
|
2018-03-27 20:31:01 +00:00
|
|
|
!byte 0
|
|
|
|
|
2018-04-18 20:39:59 +00:00
|
|
|
kGlobalPrefsFilename
|
|
|
|
!byte 15
|
|
|
|
!raw "PITCH.DARK.CONF"
|
|
|
|
|
2018-03-24 23:03:00 +00:00
|
|
|
kForce40
|
|
|
|
!byte 14
|
|
|
|
!raw "FORCE40COLUMNS"
|
|
|
|
kForceUpper
|
|
|
|
!byte 14
|
|
|
|
!raw "FORCEUPPERCASE"
|
2018-03-26 17:17:35 +00:00
|
|
|
kScriptToFile
|
|
|
|
!byte 12
|
|
|
|
!raw "SCRIPTTOFILE"
|
|
|
|
kAutoScript
|
|
|
|
!byte 10
|
|
|
|
!raw "AUTOSCRIPT"
|
2018-03-24 23:03:00 +00:00
|
|
|
kLastPlayed
|
|
|
|
!byte 10
|
|
|
|
!raw "LASTPLAYED"
|
2018-02-09 01:38:26 +00:00
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
.exit rts
|
2018-03-27 19:19:48 +00:00
|
|
|
|
2018-03-27 21:17:47 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; SaveGlobalPreferences
|
2018-04-10 17:32:49 +00:00
|
|
|
; save global options and state to file
|
|
|
|
; note: this function is inefficient because I want the preferences file to
|
|
|
|
; look a certain way at all times
|
2018-03-27 21:17:47 +00:00
|
|
|
;
|
|
|
|
; in: current ProDOS prefix is the same as the PITCH.DARK.CONF file
|
|
|
|
; out: all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
2018-03-27 19:19:48 +00:00
|
|
|
SaveGlobalPreferences
|
2018-04-01 22:26:54 +00:00
|
|
|
lda gGlobalPrefsDirty
|
2018-03-29 02:49:51 +00:00
|
|
|
beq .exit
|
2018-03-30 17:43:48 +00:00
|
|
|
+LDADDR kGlobalPrefsBuffer
|
|
|
|
+STAY $FE
|
2018-03-27 19:19:48 +00:00
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .fluff1
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
|
|
|
|
|
|
|
jsr addBooleanFromStore
|
2018-03-24 23:03:00 +00:00
|
|
|
!word kForce40
|
2018-03-24 16:04:09 +00:00
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addBooleanFromStore
|
2018-03-24 23:03:00 +00:00
|
|
|
!word kForceUpper
|
2018-03-24 16:04:09 +00:00
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addBooleanFromStore
|
2018-03-26 17:17:35 +00:00
|
|
|
!word kScriptToFile
|
2018-03-24 16:04:09 +00:00
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addBooleanFromStore
|
2018-03-26 17:17:35 +00:00
|
|
|
!word kAutoScript
|
2018-03-24 19:28:55 +00:00
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .fluff2
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
|
|
|
|
|
|
|
jsr addStringFromStore
|
|
|
|
!word kLastPlayed
|
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .fluff3
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
|
|
|
|
2018-04-13 19:17:18 +00:00
|
|
|
jsr okvs_iter
|
2018-03-28 18:09:39 +00:00
|
|
|
!word gGamesListStore
|
2018-04-13 19:17:18 +00:00
|
|
|
!word addGameToPrefs
|
2018-03-27 19:19:48 +00:00
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .eof
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
|
|
|
|
|
|
|
lda $FE
|
2018-03-29 02:49:51 +00:00
|
|
|
sta .filelen
|
2018-03-27 19:19:48 +00:00
|
|
|
lda $FF
|
|
|
|
sec
|
2018-03-30 17:43:48 +00:00
|
|
|
sbc #>kGlobalPrefsBuffer
|
2018-03-29 02:49:51 +00:00
|
|
|
sta .filelen+1
|
2018-03-27 20:31:01 +00:00
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr SaveFile
|
2018-04-18 20:39:59 +00:00
|
|
|
!word kGlobalPrefsFilename
|
2018-03-27 19:19:48 +00:00
|
|
|
!byte 4 ; filetype=TXT
|
|
|
|
!word 0 ; auxtype=0000
|
2018-03-30 17:43:48 +00:00
|
|
|
!word kGlobalPrefsBuffer
|
2018-03-29 02:49:51 +00:00
|
|
|
.filelen !word $FDFD ; SMC
|
2018-02-09 01:38:26 +00:00
|
|
|
!word kProDOSFileBuffer
|
2018-03-27 20:31:01 +00:00
|
|
|
|
2018-04-01 22:26:54 +00:00
|
|
|
stz gGlobalPrefsDirty
|
2018-03-16 18:17:45 +00:00
|
|
|
rts
|
|
|
|
|
2018-04-13 19:17:18 +00:00
|
|
|
addGameToPrefs
|
|
|
|
+STAY +
|
|
|
|
jsr addStringFromStore
|
|
|
|
+ !word $FDFD ; SMC
|
|
|
|
rts
|
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
addBooleanFromStore
|
|
|
|
lda #$24 ; BIT opcode
|
2018-04-18 02:28:22 +00:00
|
|
|
+HIDE_NEXT_2_BYTES
|
2018-03-27 19:19:48 +00:00
|
|
|
addStringFromStore
|
|
|
|
lda #$80 ; BRA opcode
|
|
|
|
sta .skipOverBooleanLogic
|
|
|
|
+PARAMS_ON_STACK 2
|
2018-04-02 18:38:05 +00:00
|
|
|
+LDPARAM 1
|
|
|
|
+STAY .key
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .equals
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addString
|
|
|
|
jsr okvs_get
|
2018-03-28 02:40:09 +00:00
|
|
|
!word gGlobalPrefsStore
|
2018-03-29 02:49:51 +00:00
|
|
|
.key !word $FDFD ; SMC
|
2018-03-27 19:19:48 +00:00
|
|
|
.skipOverBooleanLogic
|
2018-03-28 15:48:47 +00:00
|
|
|
bra + ; SMC (opcode may become BIT)
|
2018-03-29 02:49:51 +00:00
|
|
|
+STAY PTR
|
2018-03-27 19:19:48 +00:00
|
|
|
ldy #1
|
|
|
|
lda (PTR),y
|
|
|
|
ora #$30
|
|
|
|
sta (PTR),y
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDAY PTR
|
2018-03-27 19:19:48 +00:00
|
|
|
+ jsr addString
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDADDR .lf
|
2018-03-27 19:19:48 +00:00
|
|
|
jmp addString
|
|
|
|
|
|
|
|
addString
|
2018-03-29 02:49:51 +00:00
|
|
|
+STAY $00
|
2018-03-27 19:19:48 +00:00
|
|
|
lda ($00)
|
|
|
|
inc
|
|
|
|
sta .len
|
|
|
|
ldy #1
|
|
|
|
- lda ($00),y
|
|
|
|
sta ($FE)
|
|
|
|
+ iny
|
|
|
|
inc $FE
|
|
|
|
bne +
|
|
|
|
inc $FF
|
|
|
|
.len=*+1
|
2018-03-28 15:48:47 +00:00
|
|
|
+ cpy #$FD ; SMC
|
2018-03-27 19:19:48 +00:00
|
|
|
bne -
|
2018-02-09 01:38:26 +00:00
|
|
|
rts
|
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
.equals !byte 1
|
|
|
|
!raw "="
|
|
|
|
.lf !byte 1
|
|
|
|
!byte $0D
|
|
|
|
.fluff1 !byte 101
|
|
|
|
!raw "# Pitch Dark preferences file",$0D
|
|
|
|
!raw "# Do not edit by hand.",$0D
|
|
|
|
!raw "# Or do. I'm a comment, not a cop.",$0D,$0D
|
|
|
|
!raw "# value=0|1",$0D
|
|
|
|
.fluff2 !byte 24
|
|
|
|
!byte $0D
|
|
|
|
!raw "# value=game directory",$0D
|
|
|
|
.fluff3 !byte 58
|
|
|
|
!byte $0D
|
|
|
|
!raw "# key=game directory, value=filename of selected version",$0D
|
2018-03-28 14:42:37 +00:00
|
|
|
.eof !byte 7
|
2018-03-27 19:19:48 +00:00
|
|
|
!byte $0D
|
2018-03-28 14:42:37 +00:00
|
|
|
!raw "[eof]",$0D
|
2018-02-09 01:38:26 +00:00
|
|
|
}
|