pitch-dark/src/pitchdark.init.a

150 lines
5.2 KiB
Plaintext

;------------------------------------------------------------------------------
; check machine requirements (128K with 65C02) and quit to ProDOS if not met
;------------------------------------------------------------------------------
lda MACHID
and #$30
cmp #$30 ; 128K?
beq + ; yes, continue
- jmp QuitToProDOS
+ inc ; 65C02-only INC instruction will clear Z flag
beq - ; if Z flag is still set, this is not a 65C02
;------------------------------------------------------------------------------
; 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 @maybeRAMdisk
lda RAM32+1
cmp NODEV+1
beq @noRAMdisk
@maybeRAMdisk
ldy DEVCNT
- lda DEVLST, y
and #$F3
cmp #$B3
beq @foundRAMdisk
dey
bpl -
bmi @noRAMdisk
@foundRAMdisk
- lda DEVLST+1, y ; move other devices up in list
sta DEVLST, y
beq + ; device list is zero-terminated
iny
bne - ; always branches
+ 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
;------------------------------------------------------------------------------
; detect VidHD by searching for magic bytes across all slots
;------------------------------------------------------------------------------
ldx #$c7
@findVidHD
stx @matchVidHD+2
ldy #2
@matchVidHD
lda $c700, y ; SMC
cmp @kVidHDID, y
bne @nextslot
dey
bpl @matchVidHD
lda #$90
sta PatchVidHD
bne @setSHR ; always
@kVidHDID
!byte $24, $EA, $4C
@nextslot
dex
cpx #$c0
bne @findVidHD
;------------------------------------------------------------------------------
; detect IIGS
;------------------------------------------------------------------------------
lda $FBB3
cmp #$06
bne +
sec
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
bcs +
@setSHR inc WeCanHazSHR+1
+
;------------------------------------------------------------------------------
; clear options script and make checksum invalid
;------------------------------------------------------------------------------
ldy #(kOnBeyondChecksum-kOnBeyondOptionsStruct)
lda #0
- sta kOnBeyondOptionsStruct,y
dey
bpl -
;------------------------------------------------------------------------------
; load file with master game list
;------------------------------------------------------------------------------
jsr LoadFile ; load prefs file at $2000
!word @kGamesListFilename
- !word $2000
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into games list store
!word gGamesListStore
!word -
!byte 0
+LDAY SRC
+STAY gGlobalPrefsStore ; save pointer to free space for next store
bra +
@kGamesListFilename
!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
- !word kGlobalPrefsBuffer
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into global prefs store
!word gGlobalPrefsStore
!word -
!byte 16
+LDAY SRC
+STAY gVersionsStore ; save pointer to free space for next store
;------------------------------------------------------------------------------
; set any pending save slot information for the current game
;------------------------------------------------------------------------------
jsr FlushSaveInfo
;------------------------------------------------------------------------------
; get current game description and game-specific options
;------------------------------------------------------------------------------
jsr LoadGameInfo
;------------------------------------------------------------------------------
; initialize WeeGUI and enable mouse support
;------------------------------------------------------------------------------
jsr WGInit
ldx #WGEnableMouse
jsr WeeGUI