pitch-dark/src/pitchdark.init.a

150 lines
5.2 KiB
Plaintext
Raw Permalink Normal View History

2018-04-18 20:48:20 +00:00
;------------------------------------------------------------------------------
; 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
2018-04-19 02:01:24 +00:00
+ 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
2019-01-11 01:28:01 +00:00
;------------------------------------------------------------------------------
; 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
2019-01-11 22:32:49 +00:00
sta PatchVidHD
bne @setSHR ; always
@kVidHDID
2019-01-12 18:50:41 +00:00
!byte $24, $EA, $4C
2019-01-11 01:28:01 +00:00
@nextslot
dex
cpx #$c0
bne @findVidHD
2019-01-11 22:32:49 +00:00
;------------------------------------------------------------------------------
2020-04-27 15:43:16 +00:00
; detect IIGS
2019-01-11 22:32:49 +00:00
;------------------------------------------------------------------------------
2020-04-27 15:43:16 +00:00
lda $FBB3
cmp #$06
bne +
sec
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
bcs +
@setSHR inc WeCanHazSHR+1
2019-01-11 01:28:01 +00:00
+
2019-01-11 22:32:49 +00:00
;------------------------------------------------------------------------------
; 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
2018-04-20 14:57:43 +00:00
!word @kGamesListFilename
2018-04-19 02:01:24 +00:00
- !word $2000
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into games list store
!word gGamesListStore
2018-04-19 02:01:24 +00:00
!word -
!byte 0
+LDAY SRC
+STAY gGlobalPrefsStore ; save pointer to free space for next store
bra +
2018-04-20 14:57:43 +00:00
@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
2018-04-19 02:01:24 +00:00
- !word kGlobalPrefsBuffer
!word kProDOSFileBuffer
jsr ParseKeyValueText ; parse contents into global prefs store
!word gGlobalPrefsStore
2018-04-19 02:01:24 +00:00
!word -
!byte 16
+LDAY SRC
+STAY gVersionsStore ; save pointer to free space for next store
2018-04-19 02:01:24 +00:00
2018-06-18 23:10:53 +00:00
;------------------------------------------------------------------------------
; set any pending save slot information for the current game
;------------------------------------------------------------------------------
jsr FlushSaveInfo
2018-04-19 02:01:24 +00:00
;------------------------------------------------------------------------------
; get current game description and game-specific options
;------------------------------------------------------------------------------
jsr LoadGameInfo
;------------------------------------------------------------------------------
; initialize WeeGUI and enable mouse support
;------------------------------------------------------------------------------
jsr WGInit
ldx #WGEnableMouse
jsr WeeGUI