mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-08-14 10:26:14 +00:00
110 lines
2.8 KiB
Plaintext
110 lines
2.8 KiB
Plaintext
;license:MIT
|
|
;(c) 2018 by 4am
|
|
;
|
|
; Game descriptions and configuration
|
|
;
|
|
; Public functions
|
|
; - LoadGameInfo
|
|
;
|
|
|
|
!zone {
|
|
kTextRootDirectory
|
|
!byte 5
|
|
!raw "TEXT/"
|
|
|
|
sectionPointers ; array of pointers to start of each section
|
|
addrEOF
|
|
!word 0
|
|
addrOptions
|
|
!word 0
|
|
addrVersions
|
|
!word 0
|
|
addrDescription
|
|
!word 0
|
|
addrInfo
|
|
!word 0
|
|
|
|
;------------------------------------------------------------------------------
|
|
; LoadGameInfo
|
|
; load file with information about the current game
|
|
;
|
|
; in: gCurrentGame between 0 and (kNumberOfGames-1)
|
|
; out: addrInfo, addrDescription, addrVersions, addrOptions populated
|
|
; all registers and flags clobbered
|
|
;------------------------------------------------------------------------------
|
|
LoadGameInfo
|
|
jsr ResetPath
|
|
lda #<kTextRootDirectory
|
|
ldy #>kTextRootDirectory
|
|
jsr AddToPath
|
|
lda gCurrentGame
|
|
asl
|
|
tax
|
|
lda GAMES,x
|
|
ldy GAMES+1,x
|
|
jsr AddToPath
|
|
|
|
jsr LoadFile
|
|
!word gPathname
|
|
!word $0800
|
|
!word $1400
|
|
!word kProDOSFileBuffer
|
|
|
|
lda #$FF
|
|
sta $00
|
|
lda #$07
|
|
sta $01 ; ($00) points to start of data buffer
|
|
ldy #$00 ; index into ($00) pointing to current character
|
|
ldx #$08 ; index into sectionPointers array, stores pointer to start of each section
|
|
|
|
.convertSectionLoop
|
|
jsr IncAndGetChar
|
|
.convertSectionNoInc
|
|
cmp #$5B ; '[' is the start of a new section
|
|
beq .skipSectionName
|
|
cmp #$0A ; LF -> 0x00 (WeeGUI wants null-terminated strings)
|
|
beq .null
|
|
cmp #$5E ; '^' -> closed-apple mousetext
|
|
beq .ca
|
|
cmp #$26 ; '&' -> open-apple mousetext
|
|
beq .oa
|
|
ora #$80 ; all other characters -> set high bit
|
|
!byte $2C
|
|
.null lda #$00
|
|
!byte $2C
|
|
.ca lda #$40
|
|
!byte $2C
|
|
.oa lda #$41
|
|
sta ($00),y
|
|
bra .convertSectionLoop
|
|
|
|
; We found the start of a new section, so skip to the first character on the next line
|
|
.skipSectionName
|
|
jsr IncAndGetChar
|
|
cmp #$0A ; LF
|
|
bne .skipSectionName
|
|
jsr IncAndGetChar
|
|
|
|
; We are at the start of a section, so save this address in the sectionPointers array
|
|
pha
|
|
tya
|
|
clc
|
|
adc $00
|
|
sta sectionPointers,x
|
|
lda $01
|
|
bcc +
|
|
inc
|
|
+ sta sectionPointers+1,x
|
|
pla
|
|
dex
|
|
dex
|
|
bpl .convertSectionNoInc
|
|
|
|
IncAndGetChar
|
|
iny
|
|
bne +
|
|
inc $01
|
|
+ lda ($00),y
|
|
rts
|
|
}
|