add prelaunch subsystem

This commit is contained in:
4am 2019-09-14 22:57:52 -04:00
parent a37c82b6b3
commit d31311d4e7
27 changed files with 181 additions and 171 deletions

View File

@ -20,65 +20,15 @@ ACME=acme
# https://github.com/mach-kernel/cadius
CADIUS=cadius
asm: md
asm: md asmfx asmprelaunch
$(ACME) -r build/4cade.lst src/4cade.a 2>build/relbase.log
$(ACME) -r build/4cade.lst -DRELBASE=`cat build/relbase.log | grep "RELBASE =" | cut -d"=" -f2 | cut -d"(" -f2 | cut -d")" -f1` src/4cade.a
$(ACME) src/fx/fx.cover.fade.a
$(ACME) src/fx/fx.dhgr.fizzle.a
$(ACME) src/fx/fx.dhgr.fizzle.white.a
$(ACME) src/fx/fx.dhgr.ripple.a
$(ACME) src/fx/fx.dhgr.ripple.white.a
$(ACME) src/fx/fx.dhgr.iris.a
$(ACME) src/fx/fx.dhgr.iris.white.a
$(ACME) src/fx/fx.dhgr.radial.a
$(ACME) src/fx/fx.dhgr.radial.white.a
$(ACME) src/fx/fx.dhgr.radial2.a
$(ACME) src/fx/fx.dhgr.radial2.white.a
$(ACME) src/fx/fx.dhgr.radial3.a
$(ACME) src/fx/fx.dhgr.radial3.white.a
$(ACME) src/fx/fx.dhgr.radial4.a
$(ACME) src/fx/fx.dhgr.radial4.white.a
$(ACME) src/fx/fx.dhgr.radial5.a
$(ACME) src/fx/fx.dhgr.radial5.white.a
$(ACME) src/fx/fx.dhgr.star.a
$(ACME) src/fx/fx.dhgr.star.white.a
$(ACME) src/fx/fx.hgr.diagonal.a
$(ACME) src/fx/fx.hgr.interlock.ud.a
$(ACME) src/fx/fx.hgr.interlock.lr.a
$(ACME) src/fx/fx.hgr.spiral.a
$(ACME) src/fx/fx.hgr.fourspiral.a
$(ACME) src/fx/fx.hgr.fizzle.a
$(ACME) src/fx/fx.hgr.bar.dissolve.a
$(ACME) src/fx/fx.hgr.block.fizzle.a
$(ACME) src/fx/fx.hgr.block.fizzle.white.a
$(ACME) src/fx/fx.hgr.2pass.lr.a
$(ACME) src/fx/fx.hgr.crystal.a
$(ACME) src/fx/fx.hgr.foursquare.white.a
$(ACME) src/fx/fx.hgr.onesquare.white.a
$(ACME) src/fx/fx.hgr.diamond.a
$(ACME) src/fx/fx.hgr.checkerboard.white.a
$(ACME) src/fx/fx.hgr.halfblock.fizzle.a
$(ACME) src/fx/fx.hgr.halfblock.fizzle.white.a
$(ACME) src/fx/fx.hgr.stagger.ud.a
$(ACME) src/fx/fx.hgr.stagger.ud.white.a
$(ACME) src/fx/fx.hgr.stagger.lr.a
$(ACME) src/fx/fx.hgr.stagger.lr.white.a
$(ACME) src/fx/fx.hgr.corner.circle.a
$(ACME) src/fx/fx.hgr.sunrise.a
$(ACME) src/fx/fx.hgr.sunset.a
$(ACME) src/fx/fx.hgr.radial.a
$(ACME) src/fx/fx.hgr.radial2.a
$(ACME) src/fx/fx.hgr.radial3.a
$(ACME) src/fx/fx.hgr.radial4.a
$(ACME) src/fx/fx.hgr.radial5.a
$(ACME) src/fx/fx.hgr.split.ud.intro.a
$(ACME) src/fx/fx.hgr.iris.a
$(ACME) src/fx/fx.hgr.ripple.a
$(ACME) src/fx/fx.hgr.ripple2.a
$(ACME) src/fx/fx.hgr.star.a
$(ACME) src/fx/fx.hgr.star.white.a
$(ACME) src/fx/fx.shr.fizzle.a
$(ACME) src/fx/fx.gr.fizzle.a
asmfx:
@for f in $(shell ls src/fx/*.a); do grep "^\!to" $${f} >/dev/null && $(ACME) $${f} >> build/log; done
asmprelaunch:
@for f in $(shell ls src/prelaunch/*.a); do grep "^\!to" $${f} >/dev/null && $(ACME) $${f} >> build/log; done
dsk: md asm
#$(CADIUS) CREATEVOLUME build/"$(DISK)" "$(VOLUME)" 32767KB >>build/log
@ -142,6 +92,8 @@ dsk: md asm
rm -f build/X/**/PRODOS
rm -f build/X/**/LOADER.SYSTEM
$(CADIUS) ADDFOLDER build/"$(DISK)" "/$(VOLUME)/X" "build/X" >>build/log
bin/buildfileinfo.py build/PRELAUNCH "06" "0106" >>build/log
$(CADIUS) ADDFOLDER build/"$(DISK)" "/$(VOLUME)/PRELAUNCH" "build/PRELAUNCH" >>build/log
bin/changebootloader.py build/"$(DISK)" res/proboothd
chd: dsk
@ -163,6 +115,7 @@ md:
mkdir -p build/SS
mkdir -p build/DEMO
mkdir -p build/FX
mkdir -p build/PRELAUNCH
clean:
rm -rf build/ || rm -rf build

View File

@ -1 +1 @@
T O T A L R E P L A Y ~ revision 02 / serial number 190914 ~ design & interface * * * * * * * * * 4am ports & rwts * * * * * * * * * * *qkumba testing & moral support* * * * * crayone testing w/o moral support* * * * option8 ~ https://archive.org/TotalReplay [eof]
T O T A L R E P L A Y ~ revision 03 / serial number 190915 ~ design & interface * * * * * * * * * 4am ports & rwts * * * * * * * * * * *qkumba testing & moral support* * * * * crayone testing w/o moral support* * * * option8 ~ https://archive.org/TotalReplay [eof]

View File

@ -155,8 +155,8 @@ TOTAL
REPLAY
!text "R E P L A Y"
LoaderVersion
!byte 4
!text "v2.0"
!byte 10
!text "v3.0-alpha"
Loader64K
!byte 3
!text "64K"
@ -241,13 +241,11 @@ OneTimeSetup
cpy #$03
bcc @outer
+READ_RAM2_WRITE_RAM2
ldx #5
- lda Prelaunch,x ; copy reentry wrapper to bottom of stack
- lda @ResetVector,x ; copy reentry wrapper to bottom of stack
sta $100,x ; (used as reset vector because ][+ always
dex ; switches to ROM on Ctrl-Reset)
bpl -
inx
stx $3F2 ; page 3 reset vector to ($100)
inx
@ -256,8 +254,11 @@ OneTimeSetup
stx $3F4
bit CLEARKBD
jmp $100 ; will jump to |Reentry| in LC RAM bank
; execution falls through here
@ResetVector
; main entry point into launcher (also used by self-running demos, vectors)
+READ_RAM1_NO_WRITE
jmp Reenter
@kGameListConfFile
!byte 10

View File

@ -129,7 +129,15 @@ gCurrentlyVisibleSlideshowIndex
rts
.Go
+STAY PTR
+STAY SAVE
; TODO check if cheats are enabled and available for this game
jsr LoadFile ; load standard prelaunch code (|Launch| will call it)
!word kPrelaunchDirectory
!word kStandardPrelaunch
!word $0106
ldx #1 ; construct path to game's startup file
sec ; which is always /X/game/game
!byte $2c
@ -137,7 +145,7 @@ gCurrentlyVisibleSlideshowIndex
clc
php
ldy #0
lda (PTR), y
lda (SAVE), y
tay
iny
sty @runlength+1
@ -148,7 +156,7 @@ gCurrentlyVisibleSlideshowIndex
- inx
sta ProDOS_prefix, x
iny
lda (PTR), y
lda (SAVE), y
@runlength
cpy #$D1 ; SMC
bne -
@ -183,11 +191,6 @@ Launch
lda #$38 ; 'sec' opcode to tell |Reenter| to
sta RestoreStackNextTime ; restore the stack and stack pointer
ldx #(End_Prelaunch-Prelaunch-1)
- lda Prelaunch,x ; copy pre-launch code to main memory
sta $100,x
dex
bpl -
ldx #(end_promote-promote-1)
- lda promote,x ; copy ProDOS shim to main memory
sta $bf00,x

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/BOLO",plain
*=$14D
!to "build/PRELAUNCH/BOLO",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $8034

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/BRUCE.LEE",plain
*=$14D
!to "build/PRELAUNCH/BRUCE.LEE",plain
*=$106
!source "src/prelaunch/common.a"
lda #<cheat
sta $b3e

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/BUBBLE.BOBBLE",plain
*=$14D
!to "build/PRELAUNCH/BUBBLE.BOBBLE",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $94d

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/BURGERTIME",plain
*=$14d
!to "build/PRELAUNCH/BURGERTIME",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $3f03

30
src/prelaunch/common.a Normal file
View File

@ -0,0 +1,30 @@
; common code used by all prelaunchers
!source "src/constants.a" ; no code in these
!source "src/macros.a"
ldx #0 ; wipe zero page
txa
- sta $00,x
inx
bne -
lda #$65 ; Initialize 'random' seed. These are
sta RNDSEED ; arbitrary values. Some games like Pooyan
lda #$02 ; require these to be non-zero. Ask me
sta RNDSEED+1 ; how long that one took to debug.
+READ_ROM_NO_WRITE
jsr ROM_IN0 ; Initialize machine like a cold boot.
jsr ROM_PR0 ; Many games assume a 'clean slate' and
jsr ROM_NORMAL ; rely on zero page values set by these
sta STOREOFF ; ROM routines,
sta READMAINMEM ; e.g. Wavy Navy just prints out text via
sta WRITEMAINMEM ; $FDED and expects it to work. Having it
sta CLR80VID ; print all null characters is amusing, in
sta PRIMARYCHARSET ; a quiet way, but not really helpful.
jsr ROM_TEXT
jsr ROM_HOME
bit CLEARKBD

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/CONAN",plain
*=$14D
!to "build/PRELAUNCH/CONAN",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $81e

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/DIG.DUG",plain
*=$14D
!to "build/PRELAUNCH/DIG.DUG",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $826

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/DONKEY.KONG",plain
*=$14D
!to "build/PRELAUNCH/DONKEY.KONG",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $3eab
@ -12,4 +14,3 @@
sta $729b
sta $6fea
jmp $4000

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/DROL",plain
*=$14d
!to "build/PRELAUNCH/DROL",plain
*=$106
!source "src/prelaunch/common.a"
ldy #(cheat_e-cheat_b)-1
- lda cheat_b,y

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/JOUST",plain
*=$14D
!to "build/PRELAUNCH/JOUST",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $85e

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/MARIO.BROS",plain
*=$14D
!to "build/PRELAUNCH/MARIO.BROS",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $8214

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/MONTEZUMA",plain
*=$14d
!to "build/PRELAUNCH/MONTEZUMA",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $816

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/MOON.PATROL",plain
*=$14D
!to "build/PRELAUNCH/MOON.PATROL",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $49d5

View File

@ -2,10 +2,13 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/MR.DO",plain
*=$14D
!to "build/PRELAUNCH/MR.DO",plain
*=$106
bne cheat3
!source "src/prelaunch/common.a"
clc
bcc cheat3
cheat2
jsr $20d

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/MS.PACMAN",plain
*=$14D
!to "build/PRELAUNCH/MS.PACMAN",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $816

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/SNEAKERS",plain
*=$14D
!to "build/PRELAUNCH/SNEAKERS",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $84c6

36
src/prelaunch/standard.a Normal file
View File

@ -0,0 +1,36 @@
;license:MIT
;(c) 2019 by qkumba
!cpu 6502
!to "build/PRELAUNCH/STANDARD",plain
*=$106
;------------------------------------------------------------------------------
; Prelaunch
; code to set up and launch third-party code (either a self-running demo or
; an actual game)
; THIS IS NOT A FUNCTION. DO NOT CALL THIS DIRECTLY.
; must be run from main memory
;
; in: for first entry point, none
; for second entry point, the game must already be loaded in memory
; and ldrlo2/ldrhi2 must be the game entry point
; out: exits via JMP (ldrlo2), which is expected to exit via JMP |Prelaunch|
; (not here, but wherever it was copied to in main memory) or by
; manually enabling LC RAM then JMP |Reenter|
;------------------------------------------------------------------------------
lda $59 ; set up game entry point in stack page
ldy $5A ; (last ProRWTS load address - 1)
sec
sbc #$01
bcs +
dey
+ sta $1FE
sty $1FF
!source "src/PRELAUNCH/common.a"
ldx #$FD ; Jump to game entry point via stack pop.
txs
rts
End_Prelaunch

View File

@ -2,15 +2,17 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/TAPPER",plain
*=$14D
!to "build/PRELAUNCH/TAPPER",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $851
jsr $800
lda #<cheat
sta $248
lda #>cheat
lda #>cheat
sta $249
jmp $200

View File

@ -2,8 +2,10 @@
;(c) 2019 by qkumba
!cpu 6502
!to "build/cheat/WAVY.NAVY",plain
*=$14d
!to "build/PRELAUNCH/WAVY.NAVY",plain
*=$106
!source "src/prelaunch/common.a"
lda #$60
sta $505d

View File

@ -647,63 +647,3 @@ SaveSmallFileInternal
sta reqcmd
sta sizelo ; non-zero
jmp hddopendir ; exit via ProRWTS2 (must re-open the file after query)
;------------------------------------------------------------------------------
; Prelaunch
; code to set up and launch third-party code (either a self-running demo or
; an actual game)
; THIS IS NOT A FUNCTION. DO NOT CALL THIS DIRECTLY.
; must be run from main memory
; contains multiple entry points
;
; in: for first entry point, none
; for second entry point, the game must already be loaded in memory
; and ldrlo2/ldrhi2 must be the game entry point
; out: exits via JMP (ldrlo2), which is expected to exit via JMP |Prelaunch|
; (not here, but wherever it was copied to in main memory) or by
; manually enabling LC RAM then JMP |Reenter|
;------------------------------------------------------------------------------
Prelaunch
; copied to $0100 in main memory
; main entry point to return to launcher (used by self-running demos, vectors)
+READ_RAM1_NO_WRITE
jmp Reenter
!if * != Prelaunch+6 {
!error "Prelaunch entry points are messed up"
}
; copied to $0106 in main memory
; main entry point to launch game
+READ_ROM_NO_WRITE
lda ldrlo2 ; set up game entry point in stack page
ldy ldrhi2 ; (last load address - 1)
sec
sbc #$01
bcs +
dey
+
+STAY $1FE
ldx #0 ; wipe zero page
txa
- sta $00,x
inx
bne -
lda #$65 ; Initialize 'random' seed. These are
sta RNDSEED ; arbitrary values. Some games like Pooyan
lda #$02 ; require these to be non-zero. Ask me
sta RNDSEED+1 ; how long that one took to debug.
jsr ROM_IN0 ; Initialize machine like a cold boot.
jsr ROM_PR0 ; Many games assume a 'clean slate' and
jsr ROM_NORMAL ; rely on zero page values set by these
sta STOREOFF ; ROM routines,
sta READMAINMEM ; e.g. Wavy Navy just prints out text via
sta WRITEMAINMEM ; $FDED and expects it to work. Having it
sta CLR80VID ; print all null characters is amusing, in
sta PRIMARYCHARSET ; a quiet way, but not really helpful.
jsr ROM_TEXT
jsr ROM_HOME
bit CLEARKBD
ldx #$FD ; Jump to game entry point via stack pop.
txs
rts
End_Prelaunch

View File

@ -52,6 +52,14 @@ kFXDirectory
!byte 3
!raw "FX/"
kPrelaunchDirectory
!byte 10
!raw "PRELAUNCH/"
kStandardPrelaunch
!byte 8
!raw "STANDARD"
;------------------------------------------------------------------------------
; SetPath/AddToPath
; append a length-prefixed string to gPathname

View File

@ -187,6 +187,11 @@ RunAttractModule
+
jsr Home ; avoid seeing code load into the HGR page
jsr LoadFile ; load standard prelaunch code (|Launch| will call it)
!word kPrelaunchDirectory
!word kStandardPrelaunch
!word $0106
ldy kDemoDirectory
sty ProDOS_prefix ; temporarily set 'root' directory to
- lda kDemoDirectory, y ; /demos/ directory so demos can can load

View File

@ -146,7 +146,7 @@ CoverFade
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
DrawSearchBarOffscreen
LDA #22 ; draw visible search bar
lda #22 ; draw visible search bar
sta VTAB
lda OffscreenPage
ror ; draw on offscreen page