;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 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 ; $00/$01/$FE/$FF clobbered ;------------------------------------------------------------------------------ SaveGlobalPreferences +LDADDR kGlobalPrefsBuffer +STAY $FE +LDADDR @kFluff1 jsr @addString +LDADDR kLastPlayed jsr @addStringFromStore +LDADDR @kFluff2 jsr @addString +LDADDR kNextAttract jsr @addStringFromStore +LDADDR @kFluff3 jsr @addString +LDADDR kNextFX jsr @addStringFromStore +LDADDR @kFluff4 jsr @addString +LDADDR kNextDFX jsr @addStringFromStore +LDADDR @kEOF jsr @addString jsr SaveSmallFile !word kGlobalPrefsFilename !word kGlobalPrefsBuffer rts @addStringFromStore +STAY @key jsr @addString +LDADDR @kEquals jsr @addString jsr okvs_get !word gGlobalPrefsStore @key !word $FDFD ; SMC jsr @addString +LDADDR @kLF jmp @addString @addString +STAY $00 ldx #0 ldy #0 lda ($00),y beq ++ clc adc #$01 sta @len iny - lda ($00),y sta ($FE,x) + iny inc $FE bne + inc $FF @len=*+1 + cpy #$FD ; SMC bne - ++ rts @kEquals !byte 1 !raw "=" @kLF !byte 1,$0D @kFluff1 !byte @kFluff2-*-1 !raw "# 4cade preferences file",$0D !raw "# Do not edit by hand.",$0D !raw "# Or do. I'm a comment, not a cop.",$0D !byte $0D !raw "# value=game directory listed in GAMES.CONF, or empty",$0D @kFluff2 !byte @kFluff3-*-1 !byte $0D !raw "# value=attract mode module listed in ATTRACT.CONF, or empty",$0D @kFluff3 !byte @kFluff4-*-1 !byte $0D !raw "# value=transition effect listed in FX.CONF, or empty",$0D @kFluff4 !byte @kEOF-*-1 !byte $0D !raw "# value=transition effect listed in DFX.CONF, or empty",$0D @kEOF !byte @_-*-1 !byte $0D !raw "[eof]",$0D @_