mirror of
https://github.com/a2-4am/pitch-dark.git
synced 2025-02-06 05:29:56 +00:00
move more one-time initialization code before WeeGUI, centralize entry point address
This commit is contained in:
parent
4585344c0f
commit
567bdf7edd
1
Makefile
1
Makefile
@ -36,6 +36,7 @@ asm: md
|
||||
dsk: md asm
|
||||
cp res/"Pitch Dark.master games collection.do.not.edit.2mg" build/"$(DISK)"
|
||||
cp res/_FileInformation.txt build/
|
||||
bin/fixFileInformation.sh build/_FileInformation.txt
|
||||
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/GRUE.SYSTEM"
|
||||
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/ONBEYOND.SYSTEM"
|
||||
$(CADIUS) ADDFILE build/"$(DISK)" "/PITCH.DARK/" "build/ZINFO.SYSTEM"
|
||||
|
4
bin/fixFileInformation.sh
Executable file
4
bin/fixFileInformation.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
addr=`grep kPitchDarkBinaryAddress src/constants.a | cut -d"$" -f2`
|
||||
sed -i -e "s/kPitchDarkBinaryAddress/$addr/g" "$1"
|
@ -1,5 +1,5 @@
|
||||
GRUE.SYSTEM=Type(FF),AuxType(2000),Access(C3)
|
||||
PITCH.DARK=Type(06),AuxType(3FE3),Access(C3)
|
||||
PITCH.DARK=Type(06),AuxType(kPitchDarkBinaryAddress),Access(C3)
|
||||
PITCH.DARK.CONF=Type(04),AuxType(0000),Access(C3)
|
||||
GAMES.CONF=Type(04),AuxType(0000),Access(C3)
|
||||
ONBEYOND.SYSTEM=Type(FF),AuxType(2000),Access(C3)
|
||||
|
@ -17,6 +17,8 @@
|
||||
;~7400...... - program data (approximate)
|
||||
;
|
||||
|
||||
kPitchDarkBinaryAddress = $3F4D
|
||||
|
||||
kGameInfoBuffer = $0800 ; used by LoadGameInfo
|
||||
kProDOSFileBuffer = $1C00 ; 1K buffer for ProDOS MLI calls
|
||||
kSystemAddress = $2000 ; used by LaunchInterpreter
|
||||
@ -28,6 +30,10 @@ gKey = $3F01
|
||||
gValLen = $3F80
|
||||
gVal = $3F81
|
||||
WGInit = $4000 ; WeeGUI file load address and initialization function
|
||||
NODEV = $BF10 ; means 'no device connected'
|
||||
RAM32 = $BF26 ; S3,D2 /RAM device
|
||||
DEVCNT = $BF31 ; ProDOS device count
|
||||
DEVLST = $BF32 ; ProDOS device list
|
||||
MAGICRTS = $FF58 ; used to set overflow bit
|
||||
|
||||
; zero page
|
||||
|
@ -4,7 +4,6 @@
|
||||
; glue code to load, set up, and launch the On Beyond Z-Machine! interpreter
|
||||
;
|
||||
; Public functions
|
||||
; - ClearInterpreterOptions
|
||||
; - LaunchInterpreterWithNewGame
|
||||
; - LaunchInterpreterWithGame
|
||||
; - LaunchInterpreterWithHints
|
||||
@ -27,23 +26,6 @@ kOnBeyondAutoScript = $0304
|
||||
kOnBeyondWarnMissing = $0305
|
||||
kOnBeyondChecksum = $0306
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; ClearInterpreterOptions
|
||||
; clear options script and make checksum invalid
|
||||
;
|
||||
; in: none
|
||||
; out: A/Y clobbered
|
||||
; X preserved
|
||||
; all flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
ClearInterpreterOptions
|
||||
ldy #(kOnBeyondChecksum-kOnBeyondOptionsStruct)
|
||||
lda #0
|
||||
- sta kOnBeyondOptionsStruct,y
|
||||
dey
|
||||
bpl -
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LaunchInterpreterWithGame
|
||||
; load interpreter and launch it with a game based on global preferences store,
|
||||
|
@ -5,6 +5,8 @@
|
||||
*=$2000
|
||||
!to "build/GRUE.SYSTEM",plain
|
||||
|
||||
!source "src/constants.a"
|
||||
|
||||
lda $BF98 ; machine identification byte
|
||||
and #$30
|
||||
cmp #$30 ; 128K?
|
||||
@ -90,7 +92,7 @@ reloc cld
|
||||
jsr $bf00
|
||||
!byte $cc
|
||||
!word cc_parms
|
||||
jmp $3FE3
|
||||
jmp kPitchDarkBinaryAddress
|
||||
|
||||
c7_parms
|
||||
c6_parms
|
||||
@ -106,7 +108,7 @@ c8_parms
|
||||
ca_parms
|
||||
!byte 4
|
||||
!byte $d1
|
||||
!word $3FE3
|
||||
!word kPitchDarkBinaryAddress
|
||||
!word $ffff
|
||||
!word $34d1
|
||||
|
||||
|
@ -1,37 +0,0 @@
|
||||
;license:MIT
|
||||
;(c) 2018 by 4am
|
||||
;
|
||||
; Parser for game list file
|
||||
;
|
||||
; Public functions
|
||||
; - LoadGameList
|
||||
;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadGameList
|
||||
; load file with master game list
|
||||
;
|
||||
; in: current ProDOS prefix is the same as the GAMES.CONF file
|
||||
; out: gGamesListStore populated
|
||||
; all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
!zone {
|
||||
LoadGameList
|
||||
jsr LoadFile ; load prefs file at $2000
|
||||
!word .gamesListFilename
|
||||
.handle !word $2000
|
||||
!word kProDOSFileBuffer
|
||||
|
||||
jsr ParseKeyValueText ; parse contents into games list store
|
||||
!word gGamesListStore
|
||||
!word .handle
|
||||
!byte 0
|
||||
|
||||
+LDAY SRC
|
||||
+STAY gGlobalPrefsStore ; save pointer to free space for next store
|
||||
rts
|
||||
|
||||
.gamesListFilename
|
||||
!byte 10
|
||||
!raw "GAMES.CONF"
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
; set to 1 if prefs have changed. SaveGlobalPreferences won't write to disk if this is 0.
|
||||
;
|
||||
; Public constants (all length-prefixed strings)
|
||||
; - kGlobalPrefsFilename
|
||||
; - kForce40
|
||||
; - kForceUpper
|
||||
; - kScriptToFile
|
||||
@ -27,6 +28,10 @@ gGlobalPrefsStore
|
||||
gGlobalPrefsDirty
|
||||
!byte 0
|
||||
|
||||
kGlobalPrefsFilename
|
||||
!byte 15
|
||||
!raw "PITCH.DARK.CONF"
|
||||
|
||||
kForce40
|
||||
!byte 14
|
||||
!raw "FORCE40COLUMNS"
|
||||
@ -43,29 +48,6 @@ kLastPlayed
|
||||
!byte 10
|
||||
!raw "LASTPLAYED"
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadGlobalPreferences
|
||||
; load global options and state (including current game) from file and populate
|
||||
; global prefs store
|
||||
;
|
||||
; in: current ProDOS prefix is the same as the PITCH.DARK.CONF file
|
||||
; out: all registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
LoadGlobalPreferences
|
||||
stz gGlobalPrefsDirty
|
||||
|
||||
jsr LoadFile ; load prefs file at $2000
|
||||
!word .globalPrefsFilename
|
||||
.handle !word kGlobalPrefsBuffer
|
||||
!word kProDOSFileBuffer
|
||||
|
||||
jsr ParseKeyValueText ; parse contents into global prefs store
|
||||
!word gGlobalPrefsStore
|
||||
!word .handle
|
||||
!byte 16
|
||||
|
||||
+LDAY SRC
|
||||
+STAY gVersionsStore ; save pointer to free space for next store
|
||||
.exit rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@ -122,7 +104,7 @@ SaveGlobalPreferences
|
||||
sta .filelen+1
|
||||
|
||||
jsr SaveFile
|
||||
!word .globalPrefsFilename
|
||||
!word kGlobalPrefsFilename
|
||||
!byte 4 ; filetype=TXT
|
||||
!word 0 ; auxtype=0000
|
||||
!word kGlobalPrefsBuffer
|
||||
@ -182,10 +164,6 @@ addString
|
||||
bne -
|
||||
rts
|
||||
|
||||
.globalPrefsFilename
|
||||
!byte 15
|
||||
!raw "PITCH.DARK.CONF"
|
||||
|
||||
.equals !byte 1
|
||||
!raw "="
|
||||
.lf !byte 1
|
||||
|
@ -13,34 +13,30 @@
|
||||
!cpu 65c02
|
||||
!ct "src/lcase.ct"
|
||||
!to "build/PITCH.DARK",plain
|
||||
*=$3FE3
|
||||
|
||||
!source "src/constants.a"
|
||||
!source "src/macros.a"
|
||||
!source "src/WeeGUI_MLI.s"
|
||||
|
||||
*=kPitchDarkBinaryAddress
|
||||
|
||||
jsr QuitUnless128KAnd65C02; check minimum hardware requirements
|
||||
jsr DisconnectRAM32 ; disconnect /RAM in S3,D2
|
||||
jsr ClearInterpreterOptions ; clear options struct at $300
|
||||
jsr WGInit ; initialize WeeGUI
|
||||
jsr LoadGameList ; get master list of games
|
||||
jsr LoadGlobalPreferences ; get global options, including current game
|
||||
!source "src/pitchdark.init.a"
|
||||
jsr LoadGameInfo ; get current game description and game-specific options
|
||||
jsr WGInit ; initialize WeeGUI
|
||||
ldx #WGEnableMouse ; enable mouse support
|
||||
jsr WeeGUI
|
||||
jmp MainScreen
|
||||
|
||||
!if * != $4000 {
|
||||
!serious "WeeGUI library must start at $4000"
|
||||
!if *!=$4000 {
|
||||
!serious "WeeGUI library must start at $4000, set kPitchDarkBinaryAddress to ",kPitchDarkBinaryAddress+$4000-*
|
||||
}
|
||||
!bin "res/WEEGUI"
|
||||
|
||||
!source "src/macros.a"
|
||||
!source "src/constants.a"
|
||||
!source "src/WeeGUI_MLI.s"
|
||||
|
||||
!source "src/okvs.a"
|
||||
!source "src/prodos.mli.a"
|
||||
!source "src/prodos.ramdisk.a"
|
||||
!source "src/prodos.path.a"
|
||||
!source "src/parse.common.a"
|
||||
!source "src/parse.gamelist.a"
|
||||
!source "src/parse.gameinfo.a"
|
||||
!source "src/parse.prefs.a"
|
||||
!source "src/glue.common.a"
|
||||
|
97
src/pitchdark.init.a
Normal file
97
src/pitchdark.init.a
Normal file
@ -0,0 +1,97 @@
|
||||
;------------------------------------------------------------------------------
|
||||
; 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
|
@ -1,71 +0,0 @@
|
||||
;license:MIT
|
||||
;(c) 2018 by 4am
|
||||
;
|
||||
; /RAM routines
|
||||
; see ProDOS TechNote #26 Polite Use of Auxiliary Memory
|
||||
; and ProDOS 8 Technical Reference Manual 5.2.2.2 Disconnecting /RAM
|
||||
;
|
||||
; Public functions
|
||||
; - DisconnectRAM32
|
||||
;
|
||||
; does not reconnect /RAM on exit, which is rude
|
||||
;
|
||||
NODEV = $BF10 ; means 'no device connected'
|
||||
RAM32 = $BF26 ; S3,D2 /RAM device
|
||||
DEVCNT = $BF31 ; ProDOS device count
|
||||
DEVLST = $BF32 ; ProDOS device list
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; DisconnectRAM32
|
||||
; disconnect ProDOS /RAM disk in S3,D2
|
||||
; (does not affect other RAM disks like RAMWorks or RAMFactor)
|
||||
;
|
||||
; in: ProDOS in memory
|
||||
; out: C clear if /RAM was found and disconnected
|
||||
; C set if /RAM was not found or could not be disconnected
|
||||
; all other registers and flags clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
!zone {
|
||||
DisconnectRAM32
|
||||
lda RAM32 ; search for /RAM and disconnect if found
|
||||
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
|
||||
clc
|
||||
rts
|
||||
.noRAMdisk
|
||||
sec
|
||||
rts
|
||||
saveRAMDiskUnit
|
||||
!byte 0
|
||||
saveRAMDiskDriver
|
||||
!word 0
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user