From d31311d4e7eb5cc380a703d64767ef0d5dbcb842 Mon Sep 17 00:00:00 2001 From: 4am Date: Sat, 14 Sep 2019 22:57:52 -0400 Subject: [PATCH] add prelaunch subsystem --- Makefile | 67 ++++-------------------- res/credits.txt | 2 +- src/4cade.init.a | 15 +++--- src/glue.launch.a | 19 ++++--- src/{cheat => prelaunch}/bolo.a | 6 ++- src/{cheat => prelaunch}/bruce.lee.a | 6 ++- src/{cheat => prelaunch}/bubble.bobble.a | 6 ++- src/{cheat => prelaunch}/burgertime.a | 6 ++- src/prelaunch/common.a | 30 +++++++++++ src/{cheat => prelaunch}/conan.a | 6 ++- src/{cheat => prelaunch}/dig.dug.a | 6 ++- src/{cheat => prelaunch}/donkey.kong.a | 7 +-- src/{cheat => prelaunch}/drol.a | 6 ++- src/{cheat => prelaunch}/joust.a | 6 ++- src/{cheat => prelaunch}/mario.bros.a | 6 ++- src/{cheat => prelaunch}/montezuma.a | 6 ++- src/{cheat => prelaunch}/moon.patrol.a | 6 ++- src/{cheat => prelaunch}/mr.do.a | 9 ++-- src/{cheat => prelaunch}/ms.pacman.a | 6 ++- src/{cheat => prelaunch}/sneakers.a | 6 ++- src/prelaunch/standard.a | 36 +++++++++++++ src/{cheat => prelaunch}/tapper.a | 8 +-- src/{cheat => prelaunch}/wavy.navy.a | 6 ++- src/prodos.impl.a | 60 --------------------- src/prodos.path.a | 8 +++ src/ui.attract.mode.a | 5 ++ src/ui.common.a | 2 +- 27 files changed, 181 insertions(+), 171 deletions(-) rename src/{cheat => prelaunch}/bolo.a (64%) rename src/{cheat => prelaunch}/bruce.lee.a (66%) rename src/{cheat => prelaunch}/bubble.bobble.a (61%) rename src/{cheat => prelaunch}/burgertime.a (66%) create mode 100644 src/prelaunch/common.a rename src/{cheat => prelaunch}/conan.a (79%) rename src/{cheat => prelaunch}/dig.dug.a (63%) rename src/{cheat => prelaunch}/donkey.kong.a (62%) rename src/{cheat => prelaunch}/drol.a (76%) rename src/{cheat => prelaunch}/joust.a (63%) rename src/{cheat => prelaunch}/mario.bros.a (60%) rename src/{cheat => prelaunch}/montezuma.a (60%) rename src/{cheat => prelaunch}/moon.patrol.a (67%) rename src/{cheat => prelaunch}/mr.do.a (84%) rename src/{cheat => prelaunch}/ms.pacman.a (73%) rename src/{cheat => prelaunch}/sneakers.a (63%) create mode 100644 src/prelaunch/standard.a rename src/{cheat => prelaunch}/tapper.a (67%) rename src/{cheat => prelaunch}/wavy.navy.a (57%) diff --git a/Makefile b/Makefile index 0ee4b6d2b..80a71b4e8 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/res/credits.txt b/res/credits.txt index 927bccd3c..c113ac9c6 100644 --- a/res/credits.txt +++ b/res/credits.txt @@ -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] \ No newline at end of file + 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] \ No newline at end of file diff --git a/src/4cade.init.a b/src/4cade.init.a index 6f34cafb3..253011744 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -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 diff --git a/src/glue.launch.a b/src/glue.launch.a index 4c93c8884..c7c248848 100644 --- a/src/glue.launch.a +++ b/src/glue.launch.a @@ -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 diff --git a/src/cheat/bolo.a b/src/prelaunch/bolo.a similarity index 64% rename from src/cheat/bolo.a rename to src/prelaunch/bolo.a index 5e6c53174..c7f4cc5b3 100644 --- a/src/cheat/bolo.a +++ b/src/prelaunch/bolo.a @@ -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 diff --git a/src/cheat/bruce.lee.a b/src/prelaunch/bruce.lee.a similarity index 66% rename from src/cheat/bruce.lee.a rename to src/prelaunch/bruce.lee.a index 95bfd8b38..4a1127c66 100644 --- a/src/cheat/bruce.lee.a +++ b/src/prelaunch/bruce.lee.a @@ -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 + lda #>cheat sta $249 jmp $200 diff --git a/src/cheat/wavy.navy.a b/src/prelaunch/wavy.navy.a similarity index 57% rename from src/cheat/wavy.navy.a rename to src/prelaunch/wavy.navy.a index b9f370cd2..8f0ad7b6d 100644 --- a/src/cheat/wavy.navy.a +++ b/src/prelaunch/wavy.navy.a @@ -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 diff --git a/src/prodos.impl.a b/src/prodos.impl.a index 33eebc3e0..69970c5cd 100644 --- a/src/prodos.impl.a +++ b/src/prodos.impl.a @@ -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 diff --git a/src/prodos.path.a b/src/prodos.path.a index 721f140d3..eb9ee568b 100644 --- a/src/prodos.path.a +++ b/src/prodos.path.a @@ -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 diff --git a/src/ui.attract.mode.a b/src/ui.attract.mode.a index 9cc2aecb6..44e7993fe 100644 --- a/src/ui.attract.mode.a +++ b/src/ui.attract.mode.a @@ -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 diff --git a/src/ui.common.a b/src/ui.common.a index ec5383963..333615718 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -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