diff --git a/src/4cade.a b/src/4cade.a index bc41118a2..88881d244 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -83,10 +83,6 @@ RestoreStackNextTime !source "src/glue.font.a" ; add new files above here so ui.common stays last !source "src/ui.common.a" -MachineStatus - !byte 0 -GameCount - !byte 0 gAttractModeStore gFXStore gDFXStore diff --git a/src/4cade.init.a b/src/4cade.init.a index dec54effc..0f46e8979 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -241,6 +241,7 @@ OneTimeSetup cpy #$03 bcc @outer + +READ_RAM2_WRITE_RAM2 ldx #5 - lda Prelaunch,x ; copy reentry wrapper to bottom of stack sta $100,x ; (used as reset vector because ][+ always diff --git a/src/glue.launch.a b/src/glue.launch.a index d5e7556ad..4c93c8884 100644 --- a/src/glue.launch.a +++ b/src/glue.launch.a @@ -194,65 +194,4 @@ Launch dex bpl - jmp $106 ; jump to pre-launch code - -;------------------------------------------------------------------------------ -; 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.impl.a b/src/prodos.impl.a index 00864b4d8..33eebc3e0 100644 --- a/src/prodos.impl.a +++ b/src/prodos.impl.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2019 by qkumba +;(c) 2019 by 4am & qkumba ; ; Pseudo-ProDOS environment ; @@ -647,3 +647,63 @@ 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/ui.attract.mode.a b/src/ui.attract.mode.a index f56c220e1..9cc2aecb6 100644 --- a/src/ui.attract.mode.a +++ b/src/ui.attract.mode.a @@ -219,32 +219,42 @@ RunAttractModule pla ; restore module type - and #$0F ; convert ASCII digit to int - asl tax - lda @slideshows-2,x + lda @slideshowslo-1,x sta @jmp+1 - lda @slideshows-1,x + lda @slideshowshi-1,x sta @jmp+2 +LDAY @key ; pass in module name @jmp jmp $FDFD ; SMC @dispatchSingle - clc - adc #$06 + adc #(@singleslo-@slideshowslo)-1 bne - ; always branches -@slideshows - !word HGRTitleSlideshow - !word HGRActionSlideshow - !word DHGRTitleSlideshow - !word DHGRActionSlideshow - !word SHRSlideshow - !word GRActionSlideshow -@singles - !word HGRSingle - !word DHGRSingle - !word SHRSingle - !word GRSingle +@slideshowslo + !byte HGRTitleSlideshow + !byte >HGRActionSlideshow + !byte >DHGRTitleSlideshow + !byte >DHGRActionSlideshow + !byte >SHRSlideshow + !byte >GRActionSlideshow +@singleshi + !byte >HGRSingle + !byte >DHGRSingle + !byte >SHRSingle + !byte >GRSingle LoadAndParseAttractModeConf ; TODO refactor launch code then make this private diff --git a/src/ui.browse.mode.a b/src/ui.browse.mode.a index 84b4b1690..f06a1f533 100644 --- a/src/ui.browse.mode.a +++ b/src/ui.browse.mode.a @@ -66,7 +66,8 @@ BrowseMode ldx BrowseSelectedIndex cpx #$FF bne @notTooSmall - ldx GameCount +GameCount = *+1 + ldx #$D1 ; SMC dex bne @done ; always branches @notTooSmall diff --git a/src/ui.common.a b/src/ui.common.a index 9afa697ee..ec5383963 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -259,7 +259,8 @@ SoftBell ; out: $0106..$011F clobbered ;------------------------------------------------------------------------------ Home - lda MachineStatus +MachineStatus = *+1 + lda #$D1 ; SMC and #SUPPORTS_SHR beq @noSHR lda NEWVIDEO