pitch-dark/src/pitchdark.init.a

98 lines
3.2 KiB
Plaintext

;------------------------------------------------------------------------------
; disconnect ProDOS /RAM disk in S3,D2
; (does not affect other RAM disks like RAMWorks or RAMFactor)
; see ProDOS TechNote #26 Polite Use of Auxiliary Memory
; and ProDOS 8 Technical Reference Manual 5.2.2.2 Disconnecting /RAM
;------------------------------------------------------------------------------
lda RAM32
cmp NODEV
bne +
lda RAM32+1
cmp NODEV+1
beq .noRAMdisk
+ ldy DEVCNT
- lda DEVLST, y
and #$F3
cmp #$B3
beq .foundRAMdisk
dey
bpl -
bmi .noRAMdisk
.foundRAMdisk
lda DEVLST, y
sta saveRAMDiskUnit ; save RAM disk unit number
- lda DEVLST+1, y ; move other devices up in list
sta DEVLST, y
beq + ; device list is zero-terminated
iny
bne - ; always branches
+
lda RAM32
sta saveRAMDiskDriver ; save RAM disk device address
lda RAM32+1
sta saveRAMDiskDriver+1
lda NODEV ; tell ProDOS there's no RAM disk anymore
sta RAM32
lda NODEV+1
sta RAM32+1
dec DEVCNT ; reduce ProDOS device count
.noRAMdisk
bra +
saveRAMDiskUnit
!byte 0
saveRAMDiskDriver
!word 0
+
;------------------------------------------------------------------------------
; clear options script and make checksum invalid
;------------------------------------------------------------------------------
ClearInterpreterOptions
ldy #(kOnBeyondChecksum-kOnBeyondOptionsStruct)
lda #0
- sta kOnBeyondOptionsStruct,y
dey
bpl -
;------------------------------------------------------------------------------
; load file with master game list
;------------------------------------------------------------------------------
jsr LoadFile ; load prefs file at $2000
!word .gamesListFilename
.gamesListHandle
!word $2000
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into games list store
!word gGamesListStore
!word .gamesListHandle
!byte 0
+LDAY SRC
+STAY gGlobalPrefsStore ; save pointer to free space for next store
bra +
.gamesListFilename
!byte 10
!raw "GAMES.CONF"
+
;------------------------------------------------------------------------------
; load global options and state (including current game) from file and populate
; global prefs store
;------------------------------------------------------------------------------
stz gGlobalPrefsDirty
jsr LoadFile ; load prefs file at $2000
!word kGlobalPrefsFilename
.globalPrefsHandle
!word kGlobalPrefsBuffer
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into global prefs store
!word gGlobalPrefsStore
!word .globalPrefsHandle
!byte 16
+LDAY SRC
+STAY gVersionsStore ; save pointer to free space for next store