2018-02-07 14:05:24 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
2018-03-27 21:00:02 +00:00
|
|
|
; Parser for per-game configuration files
|
2018-02-07 14:05:24 +00:00
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - LoadGameInfo
|
|
|
|
;
|
|
|
|
|
|
|
|
!zone {
|
2018-02-08 17:00:20 +00:00
|
|
|
kTextRootDirectory
|
2018-02-03 17:01:34 +00:00
|
|
|
!byte 5
|
2018-02-08 17:00:20 +00:00
|
|
|
!raw "TEXT/"
|
2018-02-03 17:01:34 +00:00
|
|
|
|
2018-03-28 02:40:09 +00:00
|
|
|
gVersionsStore
|
|
|
|
!word $FDFD ; set at runtime in LoadGlobalPreferences
|
|
|
|
|
2018-03-03 22:45:39 +00:00
|
|
|
sectionPointers ; array of pointers to start of each section
|
2018-03-03 23:07:13 +00:00
|
|
|
addrEOF
|
|
|
|
!word 0
|
|
|
|
addrOptions
|
|
|
|
!word 0
|
2018-03-03 22:45:39 +00:00
|
|
|
addrVersions
|
2018-02-07 14:05:24 +00:00
|
|
|
!word 0
|
|
|
|
addrDescription
|
|
|
|
!word 0
|
2018-03-03 22:45:39 +00:00
|
|
|
addrInfo
|
2018-02-07 14:05:24 +00:00
|
|
|
!word 0
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; LoadGameInfo
|
|
|
|
; load file with information about the current game
|
|
|
|
;
|
|
|
|
; in: gCurrentGame between 0 and (kNumberOfGames-1)
|
2018-03-03 23:07:13 +00:00
|
|
|
; out: addrInfo, addrDescription, addrVersions, addrOptions populated
|
2018-03-03 22:45:39 +00:00
|
|
|
; all registers and flags clobbered
|
2018-02-07 14:05:24 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2018-02-03 17:01:34 +00:00
|
|
|
LoadGameInfo
|
2018-02-07 21:02:14 +00:00
|
|
|
jsr ResetPath
|
2018-02-08 17:00:20 +00:00
|
|
|
lda #<kTextRootDirectory
|
|
|
|
ldy #>kTextRootDirectory
|
2018-02-07 21:02:14 +00:00
|
|
|
jsr AddToPath
|
2018-02-05 15:04:35 +00:00
|
|
|
lda gCurrentGame
|
2018-02-03 17:01:34 +00:00
|
|
|
asl
|
|
|
|
tax
|
2018-02-07 21:02:14 +00:00
|
|
|
lda GAMES,x
|
|
|
|
ldy GAMES+1,x
|
|
|
|
jsr AddToPath
|
2018-02-05 15:04:35 +00:00
|
|
|
|
|
|
|
jsr LoadFile
|
2018-02-07 21:02:14 +00:00
|
|
|
!word gPathname
|
2018-02-03 17:01:34 +00:00
|
|
|
!word $0800
|
|
|
|
!word $1400
|
2018-02-09 01:38:26 +00:00
|
|
|
!word kProDOSFileBuffer
|
2018-02-05 17:17:06 +00:00
|
|
|
|
|
|
|
lda #$FF
|
2018-03-27 19:19:48 +00:00
|
|
|
sta $FE
|
2018-03-03 22:45:39 +00:00
|
|
|
lda #$07
|
2018-03-27 19:19:48 +00:00
|
|
|
sta $FF ; ($FE) points to start of data buffer
|
|
|
|
ldy #$00 ; index into ($FF) pointing to current character
|
2018-03-03 23:07:13 +00:00
|
|
|
ldx #$08 ; index into sectionPointers array, stores pointer to start of each section
|
2018-03-03 22:45:39 +00:00
|
|
|
|
|
|
|
.convertSectionLoop
|
|
|
|
jsr IncAndGetChar
|
|
|
|
.convertSectionNoInc
|
2018-03-03 22:53:50 +00:00
|
|
|
cmp #$5B ; '[' is the start of a new section
|
2018-03-03 22:45:39 +00:00
|
|
|
beq .skipSectionName
|
2018-03-27 19:19:48 +00:00
|
|
|
cmp #$0D ; CR -> 0x00 (WeeGUI wants null-terminated strings)
|
2018-03-03 22:45:39 +00:00
|
|
|
beq .null
|
2018-02-08 21:28:49 +00:00
|
|
|
cmp #$5E ; '^' -> closed-apple mousetext
|
2018-03-03 22:45:39 +00:00
|
|
|
beq .ca
|
|
|
|
cmp #$26 ; '&' -> open-apple mousetext
|
|
|
|
beq .oa
|
2018-03-03 22:53:50 +00:00
|
|
|
ora #$80 ; all other characters -> set high bit
|
2018-03-03 22:45:39 +00:00
|
|
|
!byte $2C
|
|
|
|
.null lda #$00
|
|
|
|
!byte $2C
|
|
|
|
.ca lda #$40
|
|
|
|
!byte $2C
|
|
|
|
.oa lda #$41
|
2018-03-27 19:19:48 +00:00
|
|
|
sta ($FE),y
|
2018-03-03 22:45:39 +00:00
|
|
|
bra .convertSectionLoop
|
|
|
|
|
|
|
|
; We found the start of a new section, so skip to the first character on the next line
|
|
|
|
.skipSectionName
|
|
|
|
jsr IncAndGetChar
|
2018-03-27 19:19:48 +00:00
|
|
|
cmp #$0D ; CR
|
2018-03-03 22:45:39 +00:00
|
|
|
bne .skipSectionName
|
|
|
|
jsr IncAndGetChar
|
|
|
|
|
|
|
|
; We are at the start of a section, so save this address in the sectionPointers array
|
|
|
|
pha
|
2018-03-03 16:41:09 +00:00
|
|
|
tya
|
|
|
|
clc
|
2018-03-27 19:19:48 +00:00
|
|
|
adc $FE
|
2018-03-03 22:45:39 +00:00
|
|
|
sta sectionPointers,x
|
2018-03-27 19:19:48 +00:00
|
|
|
lda $FF
|
2018-03-03 16:41:09 +00:00
|
|
|
bcc +
|
|
|
|
inc
|
2018-03-03 22:45:39 +00:00
|
|
|
+ sta sectionPointers+1,x
|
2018-02-05 17:17:06 +00:00
|
|
|
pla
|
2018-03-03 22:45:39 +00:00
|
|
|
dex
|
|
|
|
dex
|
|
|
|
bpl .convertSectionNoInc
|
|
|
|
|
2018-03-28 02:40:09 +00:00
|
|
|
jmp LoadVersions
|
|
|
|
;jmp LoadGamePreferences
|
|
|
|
}
|
|
|
|
|
|
|
|
!zone {
|
|
|
|
LoadVersions
|
|
|
|
jsr okvs_init
|
|
|
|
!word gVersionsStore
|
|
|
|
|
|
|
|
lda addrVersions+1
|
|
|
|
sta $FF
|
|
|
|
lda addrVersions
|
|
|
|
sec
|
|
|
|
sbc #$01
|
|
|
|
sta $FE
|
|
|
|
bcs +
|
|
|
|
dec $FF
|
|
|
|
+ ldy #$00 ; index into ($FE) pointing to current character
|
|
|
|
.newKey ldx #$00 ; X = index into current key
|
|
|
|
.gatherKey
|
|
|
|
stx gKeyLen
|
|
|
|
jsr IncAndGetChar
|
|
|
|
and #$7F
|
|
|
|
cmp #$3D ; '=' ends the key
|
|
|
|
beq .endKey
|
|
|
|
cmp #$5B ; '[' ends the parsing
|
|
|
|
beq .doneParsing
|
|
|
|
sta gKey,x
|
|
|
|
inx
|
|
|
|
bra .gatherKey
|
|
|
|
.endKey stx gKeyLen
|
|
|
|
ldx #$00 ; X = index into the current value
|
|
|
|
.gatherValue
|
|
|
|
stx gValLen
|
|
|
|
jsr IncAndGetChar
|
|
|
|
cmp #$00 ; null ends the value
|
|
|
|
beq .endValue
|
|
|
|
and #$7F
|
|
|
|
sta gVal,x
|
|
|
|
inx
|
|
|
|
bra .gatherValue
|
|
|
|
.endValue
|
|
|
|
stx gValLen
|
|
|
|
phy ; okvs functions clobber everything but we need Y
|
|
|
|
jsr okvs_append
|
|
|
|
!word gVersionsStore
|
|
|
|
!word gKeyLen
|
|
|
|
!word gValLen
|
|
|
|
!byte 0
|
|
|
|
ply
|
|
|
|
bra .newKey
|
|
|
|
.doneParsing
|
2018-02-03 17:01:34 +00:00
|
|
|
rts
|
2018-02-05 17:17:06 +00:00
|
|
|
}
|