2018-02-09 01:38:26 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
2018-03-27 20:55:31 +00:00
|
|
|
; Global preferences
|
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-03-27 20:31:01 +00:00
|
|
|
; - gNeedToSavePrefs byte 0=false, 1=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-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-03-27 20:31:01 +00:00
|
|
|
gNeedToSavePrefs
|
|
|
|
!byte 0
|
|
|
|
|
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
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; LoadGlobalPreferences
|
|
|
|
;
|
2018-03-27 19:19:48 +00:00
|
|
|
; in: current ProDOS prefix is the same as the PITCH.DARK.CONF file
|
2018-02-09 01:38:26 +00:00
|
|
|
; out: all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
LoadGlobalPreferences
|
2018-03-27 20:31:01 +00:00
|
|
|
stz gNeedToSavePrefs
|
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr LoadFile ; load prefs file at $2000
|
|
|
|
!word .globalPrefsFilename
|
2018-03-29 02:49:51 +00:00
|
|
|
.handle !word $2000
|
2018-03-27 19:19:48 +00:00
|
|
|
!word kProDOSFileBuffer
|
|
|
|
|
2018-03-28 14:42:37 +00:00
|
|
|
jsr ParseKeyValueText ; parse contents into global prefs store
|
2018-03-28 02:40:09 +00:00
|
|
|
!word gGlobalPrefsStore
|
2018-03-29 02:49:51 +00:00
|
|
|
!word .handle
|
2018-03-28 14:42:37 +00:00
|
|
|
!byte 16
|
2018-03-27 19:19:48 +00:00
|
|
|
|
2018-03-29 02:49:51 +00:00
|
|
|
+LDAY SRC
|
|
|
|
+STAY gVersionsStore ; save pointer to free space for next store
|
|
|
|
.exit rts
|
2018-03-27 19:19:48 +00:00
|
|
|
|
2018-03-27 21:17:47 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; SaveGlobalPreferences
|
|
|
|
;
|
|
|
|
; 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-03-27 20:31:01 +00:00
|
|
|
lda gNeedToSavePrefs
|
2018-03-29 02:49:51 +00:00
|
|
|
beq .exit
|
2018-03-27 20:31:01 +00:00
|
|
|
stz $FE
|
2018-03-27 19:19:48 +00:00
|
|
|
lda #$20
|
|
|
|
sta $FF
|
|
|
|
|
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-03-28 18:09:39 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gGamesListStore
|
|
|
|
sta .numberOfGames
|
2018-03-27 19:19:48 +00:00
|
|
|
ldx #0
|
|
|
|
.gameLoop
|
|
|
|
phx
|
2018-03-29 02:49:51 +00:00
|
|
|
stx +
|
2018-03-28 18:09:39 +00:00
|
|
|
jsr okvs_nth
|
|
|
|
!word gGamesListStore
|
2018-03-29 02:49:51 +00:00
|
|
|
+ !byte $FD ; SMC
|
|
|
|
+STAY +
|
2018-03-27 19:19:48 +00:00
|
|
|
jsr addStringFromStore
|
2018-03-29 02:49:51 +00:00
|
|
|
+ !word $FDFD ; SMC
|
2018-03-27 19:19:48 +00:00
|
|
|
plx
|
|
|
|
inx
|
2018-03-28 18:09:39 +00:00
|
|
|
.numberOfGames=*+1
|
|
|
|
cpx #$FD ; SMC
|
2018-03-27 19:19:48 +00:00
|
|
|
bne .gameLoop
|
|
|
|
|
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
|
|
|
|
sbc #$20
|
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-02-09 01:38:26 +00:00
|
|
|
!word .globalPrefsFilename
|
2018-03-27 19:19:48 +00:00
|
|
|
!byte 4 ; filetype=TXT
|
|
|
|
!word 0 ; auxtype=0000
|
2018-03-16 18:17:45 +00:00
|
|
|
!word $2000
|
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-03-29 02:49:51 +00:00
|
|
|
stz gNeedToSavePrefs
|
2018-03-16 18:17:45 +00:00
|
|
|
rts
|
|
|
|
|
2018-03-27 19:19:48 +00:00
|
|
|
addBooleanFromStore
|
|
|
|
lda #$24 ; BIT opcode
|
|
|
|
!byte $2C
|
|
|
|
addStringFromStore
|
|
|
|
lda #$80 ; BRA opcode
|
|
|
|
sta .skipOverBooleanLogic
|
|
|
|
+PARAMS_ON_STACK 2
|
|
|
|
ldy #1
|
|
|
|
lda (PARAM),y
|
2018-03-29 02:49:51 +00:00
|
|
|
sta .key
|
2018-03-27 19:19:48 +00:00
|
|
|
pha
|
|
|
|
iny
|
|
|
|
lda (PARAM),y
|
2018-03-29 02:49:51 +00:00
|
|
|
sta .key+1
|
2018-03-27 19:19:48 +00:00
|
|
|
tay
|
|
|
|
pla
|
|
|
|
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
|
|
|
|
|
|
|
|
.globalPrefsFilename
|
|
|
|
!byte 15
|
|
|
|
!raw "PITCH.DARK.CONF"
|
2018-03-16 18:17:45 +00:00
|
|
|
|
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
|
|
|
}
|