4cade/src/parse.prefs.a

134 lines
3.0 KiB
Plaintext
Raw Normal View History

2018-11-10 13:36:36 +00:00
;license:MIT
;(c) 2018 by 4am
;
; Parser for global preferences file
;
; Public functions
; - SaveGlobalPreferences
;
; Public variables
; - gGlobalPrefsStore word address of prefs okvs
;
; Public constants (all length-prefixed strings)
; - kGlobalPrefsFilename
; - kLastPlayed
; - kNextAttract
; - kNextFX
; - kNextDFX
;
kGlobalPrefsBuffer = $8000
2018-11-10 15:08:14 +00:00
2018-11-10 13:36:36 +00:00
kGlobalPrefsFilename
!byte 10
!raw "PREFS.CONF"
kLastPlayed
!byte 10
!raw "LASTPLAYED"
kNextAttract
!byte 11
!raw "NEXTATTRACT"
kNextFX
!byte 6
!raw "NEXTFX"
kNextDFX
!byte 7
!raw "NEXTDFX"
;------------------------------------------------------------------------------
; SaveGlobalPreferences
; save global options and state to file
;
; in: none
; out: all registers and flags clobbered
2018-11-10 15:08:14 +00:00
; $00/$01/$FE/$FF clobbered
2018-11-10 13:36:36 +00:00
;------------------------------------------------------------------------------
SaveGlobalPreferences
+LDADDR kGlobalPrefsBuffer
2018-11-10 15:08:14 +00:00
+STAY $FE
2018-11-10 13:36:36 +00:00
+LDADDR @kFluff1
2018-11-10 15:08:14 +00:00
jsr @addString
+LDADDR kLastPlayed
jsr @addStringFromStore
2018-11-10 13:36:36 +00:00
+LDADDR @kFluff2
2018-11-10 15:08:14 +00:00
jsr @addString
+LDADDR kNextAttract
jsr @addStringFromStore
2018-11-10 13:36:36 +00:00
+LDADDR @kFluff3
2018-11-10 15:08:14 +00:00
jsr @addString
+LDADDR kNextFX
jsr @addStringFromStore
2018-11-10 13:36:36 +00:00
2018-11-10 15:08:14 +00:00
+LDADDR @kFluff4
jsr @addString
+LDADDR kNextDFX
jsr @addStringFromStore
2018-11-10 13:36:36 +00:00
+LDADDR @kEOF
2018-11-10 15:08:14 +00:00
jsr @addString
2018-11-10 13:36:36 +00:00
2018-11-10 15:08:14 +00:00
jsr SaveSmallFile
2018-11-10 13:36:36 +00:00
!word kGlobalPrefsFilename
!word kGlobalPrefsBuffer
rts
@addStringFromStore
+STAY @key
jsr @addString
+LDADDR @kEquals
jsr @addString
jsr okvs_get
!word gGlobalPrefsStore
@key !word $FDFD ; SMC
2018-11-10 15:08:14 +00:00
jsr @addString
2018-11-10 13:36:36 +00:00
+LDADDR @kLF
jmp @addString
@addString
+STAY $00
2018-11-10 15:08:14 +00:00
ldx #0
ldy #0
lda ($00),y
2018-11-18 02:39:02 +00:00
beq ++
2018-11-10 15:08:14 +00:00
clc
adc #$01
2018-11-10 13:36:36 +00:00
sta @len
2018-11-10 15:08:14 +00:00
iny
2018-11-10 13:36:36 +00:00
- lda ($00),y
2018-11-10 15:08:14 +00:00
sta ($FE,x)
2018-11-10 13:36:36 +00:00
+ iny
inc $FE
bne +
inc $FF
@len=*+1
+ cpy #$FD ; SMC
bne -
2018-11-18 02:39:02 +00:00
++ rts
2018-11-10 13:36:36 +00:00
@kEquals !byte 1
!raw "="
2018-11-10 15:08:14 +00:00
@kLF !byte 1,$0D
@kFluff1 !byte @kFluff2-*-1
2018-11-10 13:36:36 +00:00
!raw "# 4cade preferences file",$0D
!raw "# Do not edit by hand.",$0D
2018-11-10 15:08:14 +00:00
!raw "# Or do. I'm a comment, not a cop.",$0D
!byte $0D
2018-11-10 13:36:36 +00:00
!raw "# value=game directory listed in GAMES.CONF, or empty",$0D
2018-11-10 15:08:14 +00:00
@kFluff2 !byte @kFluff3-*-1
!byte $0D
!raw "# value=attract mode module listed in ATTRACT.CONF, or empty",$0D
@kFluff3 !byte @kFluff4-*-1
2018-11-10 13:36:36 +00:00
!byte $0D
2018-11-10 15:08:14 +00:00
!raw "# value=transition effect listed in FX.CONF, or empty",$0D
@kFluff4 !byte @kEOF-*-1
2018-11-10 13:36:36 +00:00
!byte $0D
2018-11-10 15:08:14 +00:00
!raw "# value=transition effect listed in DFX.CONF, or empty",$0D
@kEOF !byte @_-*-1
2018-11-10 13:36:36 +00:00
!byte $0D
!raw "[eof]",$0D
2018-11-10 15:08:14 +00:00
@_