diff --git a/src/4cade.a b/src/4cade.a index d71f51306..f05f6099e 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -51,7 +51,11 @@ Main ; these routines will only be called after relocating to language card !source "src/ui.search.mode.a" !source "src/ui.attract.mode.a" + !source "src/ui.attract.hgr.a" + !source "src/ui.attract.dhgr.a" + !source "src/ui.attract.shr.a" !source "src/prodos.path.a" + !source "src/glue.launch.a" !source "src/glue.prorwts2.a" !source "src/okvs.a" !source "src/wait.a" diff --git a/src/constants.a b/src/constants.a index e376648b7..9060b496f 100644 --- a/src/constants.a +++ b/src/constants.a @@ -35,3 +35,6 @@ gKeyLen = $1F00 ; used by ParseGamesList gKey = $1F01 gValLen = $1F80 gVal = $1F81 + +; actual constants +SUPPORTS_SHR = %00110000 ; AND mask for MachineStatus diff --git a/src/glue.launch.a b/src/glue.launch.a new file mode 100644 index 000000000..fba1d8f29 --- /dev/null +++ b/src/glue.launch.a @@ -0,0 +1,166 @@ +;license:MIT +;(c) 2018 by 4am +; +; Functions to launch games and self-running demos +; +; Public functions +; - Launch +; +; Public variables +; - gCurrentAttractIndex ; [byte] numeric index in gAttractModeStore of current Mega-Attract Module +; - gCurrentlyVisibleSlideshowIndex ; [byte] numeric index in gSlideshowStore of currently visible slideshow picture + ; (only valid during slideshows, not updated once a key is pressed) + +Play + jsr LoadFile ; load attract-mode configuration file at $8000 + !word kAttractModeConfFile + jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000 + !word gAttractModeStore + !word ldrlo2 ; (ldrlo2) points to last load address, so $8000 + !byte 0 + + jsr okvs_nth ; get filename of current attract-mode module + !word gAttractModeStore +gCurrentAttractIndex + !byte $FD ; set in AttractMode + +STAY @key + jsr okvs_get + !word gAttractModeStore +@key !word $FDFD ; SMC + +STAY PTR + ldy #1 + lda (PTR),y + and #$0F + bne @playFromSlideshow + +; we reached here by pressing during a self-running demo, +; which means that @key points to the filename of the game we want to play + +LDAY @key + jmp Go + +@playFromSlideshow +; we reached here by pressing during a slideshow +; gSlideshowStore is still in memory, and gCurrentlyVisibleSlideshowIndex +; is the index into gSlideshowStore of the picture that is being displayed + jsr okvs_nth + !word gSlideshowStore +gCurrentlyVisibleSlideshowIndex + !byte $FD ; set in HGRTitleCallback, HGRActionCallback, DHGRTitleCallback + +STAY @sskey + +STAY @sskey2 + jsr okvs_get + !word gGamesListStore +@sskey !word $FDFD ; SMC + bcs + + +LDAY @sskey + jmp Go ++ +; if the key is not found, try getting the value of the current record +; from gSlideshowStore and using that instead +; (some games have multiple action screenshots, value points to the key in gGamesListStore) + jsr okvs_get + !word gSlideshowStore +@sskey2 !word $FDFD ; SMC + bcc Go + rts +Go + +STAY PTR + bit $C010 ; forget the key that was pressed + ldx #1 + sec + !byte $24 +-- clc + php + ldy #0 + lda (PTR), y + tay + iny + sty @runlength+1 + ldy #0 + lda #'X' + sta ProDOS_prefix+1 + lda #'/' +- inx + sta ProDOS_prefix, x + iny + lda (PTR), y +@runlength + cpy #$D1 ; SMC + bne - + plp + bcs -- + stx ProDOS_prefix + + jsr LoadFile + !word ProDOS_prefix + + ldy #0 + lda (namlo), y + tay + iny + iny + sty ProDOS_prefix + +copy_prelaunch + 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 + dex + bpl - + jmp $106 ; jump to pre-launch code + +;------------------------------------------------------------------------------ +; Prelaunch +; code to set up machine for running a self-running, self-terminating game demo +; DO NOT CALL DIRECTLY +; must be run from main memory +; contains multiple entry points +; +; in: none +; 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 bank 1 then JMP |Reenter| +;------------------------------------------------------------------------------ +Prelaunch ; this runs from main memory +; entry point used by some self-running demos + lda $C088 + jmp Reenter + +; 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 (some games like Pooyan + sta $4E ; require these to be non-zero) + lda #$02 + sta $4F + jsr $FE89 ; initialize machine like a cold boot (many + jsr $FE93 ; games assume a 'clean slate' and rely on + jsr $FE84 ; zero page values set by these ROM routines, + sta $C000 ; e.g. Wavy Navy just prints out text via $FDED + sta $C002 ; and expects it to work) + sta $C004 + sta $C00C + sta $C00E + jsr $FB2F + jsr $FC58 + ldx #$FD ; jump to game entry point via stack pop + txs + rts +End_Prelaunch diff --git a/src/ui.attract.dhgr.a b/src/ui.attract.dhgr.a new file mode 100644 index 000000000..e0d9ab953 --- /dev/null +++ b/src/ui.attract.dhgr.a @@ -0,0 +1,155 @@ +;license:MIT +;(c) 2018 by 4am +; +; Double hi-res slideshows +; +; Public functions +; - DHGRTitleSlideshow +; - BlankDHGR +; + +DHGRTitleSlideshow + bit MachineStatus ; only run DHGR slideshow if we have 128K + bvs + + rts ++ jsr LoadDHGRTransition ; load transition effect code at $6000 + jsr BlankDHGR ; switch to DHGR mode with initial blank screen + jsr okvs_iter ; cycle through all listed DHGR files + !word gSlideshowStore + !word DHGRTitleCallback ; address of callback (called on each file) + jmp BlankHGR ; switch back to HGR mode with initial blank screen on exit + +;------------------------------------------------------------------------------ +; LoadDHGRTransition +; looks up name of next DHGR transition effect in DFX.CONF and loads that file +; at $6000 + +; in: gDFXStore has been initialized +; gGlobalPrefsStore has been initialized +; out: all registers and flags clobbered +; $6000..$BFFF/main contains transition effect code +;------------------------------------------------------------------------------ +LoadDHGRTransition + jsr LoadFile ; load DHGR transition effects list into $8000 + !word kDFXConfFile + jsr ParseKeyValueList ; parse DHGR transition effects list into $6000 + !word gDFXStore + !word ldrlo2 ; (ldrlo2) points to last load address + !byte 0 + + jsr okvs_get ; get next DHGR transition effect from prefs + !word gGlobalPrefsStore + !word kNextDFX + bcs @nodfx + +STAY @dfx + jsr okvs_get + !word gDFXStore +@dfx !word $FDFD ; SMC + bcc + +@nodfx ldx #0 ++ stx gDFXIndex + + jsr okvs_nth ; get filename of DHGR transition effect code + !word gDFXStore +gDFXIndex + !byte 0 + +STAY @dfxkey + + inc gDFXIndex ; increment transition effect index for next time + jsr okvs_len + !word gDFXStore + cmp gDFXIndex + bne + + lda #0 + sta gDFXIndex ++ + lda gDFXIndex + sta @nexti + jsr okvs_nth ; get name of next DHGR transition + !word gDFXStore +@nexti !byte $FD ; SMC + +STAY @nextdfx + + jsr okvs_update ; save name of next DHGR transition in prefs store + !word gGlobalPrefsStore + !word kNextDFX +@nextdfx !word $FDFD ; SMC + + jsr SaveGlobalPreferences ; write prefs store to disk + + ; load transition effect code at $6000 + +LOAD_FILE kFXDirectory, @dfxkey + rts +@dfxkey !word $FDFD +kDFXConfFile + !byte @kDFXConfFile_e-*-1 + !text "DFX.CONF" +@kDFXConfFile_e + +;------------------------------------------------------------------------------ +; DHGRTitleCallback +; callback called by okvs_iter on gSlideshowStore +; to load and display a single DHGR title screenshot + +; in: A/Y contains address of filename (name only, path is always /DHGR/) +; X contains 0-based index of the current record in gSlideshowStore +; out: all registers and flags clobbered +; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) +; $2000..$BFFF clobbered by graphics data and transition code +; $2000..$5FFF/aux clobbered +;------------------------------------------------------------------------------ +DHGRTitleCallback + +STAY PTR + + lda $C000 + bpl + + rts ++ + stx gCurrentlyVisibleSlideshowIndex + + ; load DHGR screenshot at $4000/main and $4000/aux + jsr ResetPath + +LDADDR kDHGRTitleDirectory + jsr AddToPath + +LDADDR kPathSeparator + jsr AddToPath + +LDAY PTR + jsr AddToPath + jsr LoadDHRFile + !word gPathname + ; execution falls through here + +ExecuteTransition + jsr $6000 ; call transition effect code to display picture + ; execution falls through here + +WaitAfterTransition + ldx #$20 ; picture is already showing so just wait +- lda #0 + jsr WaitForKeyWithTimeout + bmi + + dex + bpl - ++ rts + +;------------------------------------------------------------------------------ +; BlankDHGR +; clear and show DHGR page 1 without flickering +; +; in: none +; out: text page clobbered (but screen holes preserved) +; $2000..$3FFF/main and /aux cleared +;------------------------------------------------------------------------------ +BlankDHGR + jsr Home + jsr ClearHGR1 ; clear hi-res screen 1 + sta $C005 + jsr ClearHGR1 ; clear hi-res screen 1 in auxmem + sta $C004 + sta $c00d + sta $c057 + sta $c054 + sta $c052 + sta $c050 + sta $c05e + rts diff --git a/src/ui.attract.hgr.a b/src/ui.attract.hgr.a new file mode 100644 index 000000000..37ea05154 --- /dev/null +++ b/src/ui.attract.hgr.a @@ -0,0 +1,244 @@ +;license:MIT +;(c) 2018 by 4am +; +; HGR title and action slideshows +; +; Public functions +; - HGRTitleSlideshow +; - HGRActionSlideshow +; - BlankHGR +; - ClearHGR1 +; + +HGRTitleSlideshow + jsr LoadHGRTransition ; load transition effect code at $6000 + jsr okvs_iter ; cycle through all listed HGR files + !word gSlideshowStore + !word HGRTitleCallback ; address of callback (called on each file) + rts ; exit with last picture still visible + +HGRActionSlideshow + jsr LoadHGRTransition ; load transition effect code at $6000 + jsr okvs_iter ; cycle through all listed HGR files + !word gSlideshowStore + !word HGRActionCallback ; address of callback (called on each file) + rts ; exit with last picture still visible + +;------------------------------------------------------------------------------ +; BlankHGR +; clear and show HGR page 1 without flickering +; +; in: none +; out: text page clobbered (but screen holes preserved) +; $2000..$3FFF cleared +;------------------------------------------------------------------------------ +BlankHGR + jsr Home + jsr ClearHGR1 ; clear hi-res screen 1 + lda $c057 ; show hi-res screen 1 (now blank) + lda $c054 + lda $c052 + lda $c050 + rts + +;------------------------------------------------------------------------------ +; ClearHGR1 +; clear $2000..$3FFF in current memory bank (main or auxmem) +; +; in: none +; out: $2000..$3FFF cleared +; A = 0 +; X = 0 +; Y = 0 +; Z = 1 +;------------------------------------------------------------------------------ +ClearHGR1 + ldx #$20 + stx @a+2 + lda #0 + tay +@a sta $2000,y + iny + bne @a + inc @a+2 + dex + bne @a + rts + +;------------------------------------------------------------------------------ +; HGRTitleCallback +; callback called by okvs_iter on gSlideshowStore +; to load and display a single HGR title screenshot + +; in: A/Y contains address of filename (name only, path is always /HGR/) +; X contains 0-based index of the current record in gSlideshowStore +; out: all registers and flags clobbered +; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) +; $2000..$BFFF clobbered by graphics data and transition code +;------------------------------------------------------------------------------ +HGRTitleCallback + +STAY PTR + + lda $C000 + bpl + + rts ++ + stx gCurrentlyVisibleSlideshowIndex + + ; load HGR screenshot at $4000 + +LOAD_FILE kHGRTitleDirectory, PTR + + jmp ExecuteTransition ; call transition effect code to display picture + +;------------------------------------------------------------------------------ +; HGRActionCallback +; callback called by okvs_iter on gSlideshowStore +; to load and display a single HGR action screenshot + +; in: A/Y contains address of filename (name only, path is always /ACTION/) +; X contains 0-based index of the current record in gSlideshowStore +; gGamesListStore must be initialized +; out: all registers and flags clobbered +; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) +; $2000..$BFFF clobbered by graphics data and transition code +;------------------------------------------------------------------------------ +HGRActionCallback + +STAY PTR + +STAY @key + +STAY @key2 + + lda $C000 + bpl + + rts ++ + stx gCurrentlyVisibleSlideshowIndex + + ; load HGR screenshot at $4000 + +LOAD_FILE kHGRActionDirectory, PTR + +; try to get the human-readable name of this game from gGamesListStore +; and display it in the bottom-left corner + jsr okvs_get + !word gGamesListStore +@key !word $FDFD ; SMC + bcc @foundname +; if the key is not found, try getting the value of the current record +; from gSlideshowStore and using that instead +; (some games have multiple action screenshots) + jsr okvs_get + !word gSlideshowStore +@key2 !word $FDFD ; SMC + bcs @noname ; should never happen + +STAY @key3 + jsr okvs_get + !word gGamesListStore +@key3 !word $FDFD ; SMC + bcs @noname ; should never happen +@foundname + +STAY PTR +@drawname + ldx #0 + stx HTAB + ldx #22 + stx VTAB + ldy #0 + lda (PTR),y + tax + +LDADDR @topline + sec + jsr DrawBuffer + ldx #3 + +LDADDR @toprightcorner + sec + jsr DrawBuffer + inc VTAB + ldx #0 + stx HTAB + inx + +LDADDR @rightline + sec + jsr DrawBuffer + +LDAY PTR + sec + jsr DrawString + ldx #2 + +LDADDR @rightline + sec + jsr DrawBuffer +@noname + jmp ExecuteTransition +@topline + !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +@toprightcorner + !byte 0,0,7 +@rightline + !text " " + !byte 3 + +;------------------------------------------------------------------------------ +; LoadHGRTransition +; looks up name of next HGR transition effect in FX.CONF and loads that file +; at $6000 + +; in: gFXStore has been initialized +; gGlobalPrefsStore has been initialized +; out: all registers and flags clobbered +; $6000..$BFFF contains transition effect code +;------------------------------------------------------------------------------ +LoadHGRTransition + jsr LoadFile ; load HGR transition effects list into $8000 + !word kFXConfFile + jsr ParseKeyValueList ; parse HGR transition effects list into $6000 + !word gFXStore + !word ldrlo2 ; (ldrlo2) points to last load address + !byte 0 + + jsr okvs_get ; get next HGR transition effect from prefs + !word gGlobalPrefsStore + !word kNextFX + bcs @nofx + +STAY @fx + jsr okvs_get + !word gFXStore +@fx !word $FDFD ; SMC + bcc + +@nofx ldx #0 ++ stx gFXIndex + + jsr okvs_nth ; get filename of transition effect code + !word gFXStore +gFXIndex + !byte 0 + +STAY @fxkey + + inc gFXIndex ; increment transition effect index + jsr okvs_len + !word gFXStore + cmp gFXIndex + bne + + lda #0 + sta gFXIndex ++ + lda gFXIndex + sta @nexti + jsr okvs_nth ; get name of next HGR transition + !word gFXStore +@nexti !byte $FD ; SMC + +STAY @nextfx + + jsr okvs_update ; save name of next HGR transition in prefs store + !word gGlobalPrefsStore + !word kNextFX +@nextfx !word $FDFD ; SMC + + jsr SaveGlobalPreferences ; write prefs store to disk + + ; load transition effect code at $6000 + +LOAD_FILE kFXDirectory, @fxkey + rts +@fxkey !word $FDFD +kFXConfFile + !byte @kFXConfFile_e-*-1 + !text "FX.CONF" +@kFXConfFile_e diff --git a/src/ui.attract.mode.a b/src/ui.attract.mode.a index 7af47f151..d11c5fd69 100644 --- a/src/ui.attract.mode.a +++ b/src/ui.attract.mode.a @@ -7,9 +7,6 @@ ; - AttractMode ; ; Public variables -; - gCurrentAttractIndex ; [byte] numeric index in gAttractModeStore of current Mega-Attract Module -; - gCurrentlyVisibleSlideshowIndex ; [byte] numeric index in gSlideshowStore of currently visible slideshow picture - ; (only valid during slideshows, not updated once a key is pressed) ; - gAttractIndex ; [byte] numeric index in gAttractModeStore of next Mega-Attract Module ; - gFXIndex ; [byte] numeric index in gFXStore of next HGR transition effect ; - gDFXIndex ; [byte] numeric index in gDFXStore of next DHGR transition effect @@ -141,608 +138,14 @@ gAttractIndex !word DHGRTitleSlideshow !word SHRArtworkSlideshow -HGRTitleSlideshow - jsr LoadHGRTransition ; load transition effect code at $6000 - jsr okvs_iter ; cycle through all listed HGR files - !word gSlideshowStore - !word HGRTitleCallback ; address of callback (called on each file) - rts ; exit with last picture still visible - -HGRActionSlideshow - jsr LoadHGRTransition ; load transition effect code at $6000 - jsr okvs_iter ; cycle through all listed HGR files - !word gSlideshowStore - !word HGRActionCallback ; address of callback (called on each file) - rts ; exit with last picture still visible - -DHGRTitleSlideshow - bit MachineStatus ; only run DHGR slideshow if we have 128K - bvs + - rts -+ jsr LoadDHGRTransition ; load transition effect code at $6000 - jsr BlankDHGR ; switch to DHGR mode with initial blank screen - jsr okvs_iter ; cycle through all listed DHGR files - !word gSlideshowStore - !word DHGRTitleCallback ; address of callback (called on each file) - jmp BlankHGR ; switch back to HGR mode with initial blank screen on exit - -SHRArtworkSlideshow - lda MachineStatus ; only run SHR slideshow on IIgs or if we have a VidHD card - and #%00110000 - bne + - rts -+ jsr LoadSHRTransition - jsr okvs_iter - !word gSlideshowStore - !word SHRArtworkCallback - jmp BlankHGR - kAttractModeConfFile !byte @kAttractModeConfFile_e-*-1 !text "ATTRACT.CONF" @kAttractModeConfFile_e -Play - jsr LoadFile ; load attract-mode configuration file at $8000 - !word kAttractModeConfFile - jsr ParseKeyValueList ; parse attract-mode configuration into OKVS data structure at $6000 - !word gAttractModeStore - !word ldrlo2 ; (ldrlo2) points to last load address, so $8000 - !byte 0 - - jsr okvs_nth ; get filename of current attract-mode module - !word gAttractModeStore -gCurrentAttractIndex - !byte $FD ; set in AttractMode - +STAY @key - jsr okvs_get - !word gAttractModeStore -@key !word $FDFD ; SMC - +STAY PTR - ldy #1 - lda (PTR),y - and #$0F - bne @playFromSlideshow - -; we reached here by pressing during a self-running demo, -; which means that @key points to the filename of the game we want to play - +LDAY @key - jmp Go - -@playFromSlideshow -; we reached here by pressing during a slideshow -; gSlideshowStore is still in memory, and gCurrentlyVisibleSlideshowIndex -; is the index into gSlideshowStore of the picture that is being displayed - jsr okvs_nth - !word gSlideshowStore -gCurrentlyVisibleSlideshowIndex - !byte $FD ; set in HGRTitleCallback, HGRActionCallback, DHGRTitleCallback - +STAY @sskey - +STAY @sskey2 - jsr okvs_get - !word gGamesListStore -@sskey !word $FDFD ; SMC - bcs + - +LDAY @sskey - jmp Go -+ -; if the key is not found, try getting the value of the current record -; from gSlideshowStore and using that instead -; (some games have multiple action screenshots, value points to the key in gGamesListStore) - jsr okvs_get - !word gSlideshowStore -@sskey2 !word $FDFD ; SMC - bcc Go - rts -Go - +STAY PTR - bit $C010 ; forget the key that was pressed - ldx #1 - sec - !byte $24 --- clc - php - ldy #0 - lda (PTR), y - tay - iny - sty @runlength+1 - ldy #0 - lda #'X' - sta ProDOS_prefix+1 - lda #'/' -- inx - sta ProDOS_prefix, x - iny - lda (PTR), y -@runlength - cpy #$D1 ; SMC - bne - - plp - bcs -- - stx ProDOS_prefix - - jsr LoadFile - !word ProDOS_prefix - - ldy #0 - lda (namlo), y - tay - iny - iny - sty ProDOS_prefix - -copy_prelaunch - 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 - dex - bpl - - jmp $106 ; jump to pre-launch code - ;------------------------------------------------------------------------------ ; internal functions -;------------------------------------------------------------------------------ -; HGRTitleCallback -; callback called by okvs_iter on gSlideshowStore -; to load and display a single HGR title screenshot - -; in: A/Y contains address of filename (name only, path is always /HGR/) -; X contains 0-based index of the current record in gSlideshowStore -; out: all registers and flags clobbered -; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) -; $2000..$BFFF clobbered by graphics data and transition code -;------------------------------------------------------------------------------ -HGRTitleCallback - +STAY PTR - - lda $C000 - bpl + - rts -+ - stx gCurrentlyVisibleSlideshowIndex - - ; load HGR screenshot at $4000 - +LOAD_FILE kHGRTitleDirectory, PTR - - jmp ExecuteTransition ; call transition effect code to display picture - -;------------------------------------------------------------------------------ -; HGRActionCallback -; callback called by okvs_iter on gSlideshowStore -; to load and display a single HGR action screenshot - -; in: A/Y contains address of filename (name only, path is always /ACTION/) -; X contains 0-based index of the current record in gSlideshowStore -; gGamesListStore must be initialized -; out: all registers and flags clobbered -; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) -; $2000..$BFFF clobbered by graphics data and transition code -;------------------------------------------------------------------------------ -HGRActionCallback - +STAY PTR - +STAY @key - +STAY @key2 - - lda $C000 - bpl + - rts -+ - stx gCurrentlyVisibleSlideshowIndex - - ; load HGR screenshot at $4000 - +LOAD_FILE kHGRActionDirectory, PTR - -; try to get the human-readable name of this game from gGamesListStore -; and display it in the bottom-left corner - jsr okvs_get - !word gGamesListStore -@key !word $FDFD ; SMC - bcc @foundname -; if the key is not found, try getting the value of the current record -; from gSlideshowStore and using that instead -; (some games have multiple action screenshots) - jsr okvs_get - !word gSlideshowStore -@key2 !word $FDFD ; SMC - bcs @noname ; should never happen - +STAY @key3 - jsr okvs_get - !word gGamesListStore -@key3 !word $FDFD ; SMC - bcs @noname ; should never happen -@foundname - +STAY PTR -@drawname - ldx #0 - stx HTAB - ldx #22 - stx VTAB - ldy #0 - lda (PTR),y - tax - +LDADDR @topline - sec - jsr DrawBuffer - ldx #3 - +LDADDR @toprightcorner - sec - jsr DrawBuffer - inc VTAB - ldx #0 - stx HTAB - inx - +LDADDR @rightline - sec - jsr DrawBuffer - +LDAY PTR - sec - jsr DrawString - ldx #2 - +LDADDR @rightline - sec - jsr DrawBuffer -@noname - jmp ExecuteTransition -@topline - !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -@toprightcorner - !byte 0,0,7 -@rightline - !text " " - !byte 3 - -;------------------------------------------------------------------------------ -; DHGRTitleCallback -; callback called by okvs_iter on gSlideshowStore -; to load and display a single DHGR title screenshot - -; in: A/Y contains address of filename (name only, path is always /DHGR/) -; X contains 0-based index of the current record in gSlideshowStore -; out: all registers and flags clobbered -; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) -; $2000..$BFFF clobbered by graphics data and transition code -; $2000..$5FFF/aux clobbered -;------------------------------------------------------------------------------ -DHGRTitleCallback - +STAY PTR - - lda $C000 - bpl + - rts -+ - stx gCurrentlyVisibleSlideshowIndex - - ; load DHGR screenshot at $4000/main and $4000/aux - jsr ResetPath - +LDADDR kDHGRTitleDirectory - jsr AddToPath - +LDADDR kPathSeparator - jsr AddToPath - +LDAY PTR - jsr AddToPath - jsr LoadDHRFile - !word gPathname - ; execution falls through here - -ExecuteTransition - jsr $6000 ; call transition effect code to display picture - ; execution falls through here - -WaitAfterTransition - ldx #$20 ; picture is already showing so just wait -- lda #0 - jsr WaitForKeyWithTimeout - bmi + - dex - bpl - -+ rts - -;------------------------------------------------------------------------------ -; SHRArtworkCallback -; callback called by okvs_iter on gSlideshowStore -; to load and display a single SHR graphic - -; in: A/Y contains address of filename (name only, path is always /SHR/) -; X contains 0-based index of the current record in gSlideshowStore -; out: all registers and flags clobbered -; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) -; $2000..$BFFF clobbered by graphics data and transition code -; $2000..$5FFF/aux clobbered -;------------------------------------------------------------------------------ -SHRArtworkCallback - +STAY PTR - - lda $C000 - bpl + - rts -+ - stx gCurrentlyVisibleSlideshowIndex - - jsr BlankSHR - - ; load SHR artwork at $2000/main (not aux) - jsr ResetPath - +LDADDR kSHRArtworkDirectory - jsr AddToPath - +LDADDR kPathSeparator - jsr AddToPath - +LDAY PTR - jsr AddToPath - jsr LoadFile - !word gPathname - - jsr $A000 - jmp WaitAfterTransition - -;------------------------------------------------------------------------------ -; LoadHGRTransition -; looks up name of next HGR transition effect in FX.CONF and loads that file -; at $6000 - -; in: gFXStore has been initialized -; gGlobalPrefsStore has been initialized -; out: all registers and flags clobbered -; $6000..$BFFF contains transition effect code -;------------------------------------------------------------------------------ -LoadHGRTransition - jsr LoadFile ; load HGR transition effects list into $8000 - !word kFXConfFile - jsr ParseKeyValueList ; parse HGR transition effects list into $6000 - !word gFXStore - !word ldrlo2 ; (ldrlo2) points to last load address - !byte 0 - - jsr okvs_get ; get next HGR transition effect from prefs - !word gGlobalPrefsStore - !word kNextFX - bcs @nofx - +STAY @fx - jsr okvs_get - !word gFXStore -@fx !word $FDFD ; SMC - bcc + -@nofx ldx #0 -+ stx gFXIndex - - jsr okvs_nth ; get filename of transition effect code - !word gFXStore -gFXIndex - !byte 0 - +STAY @fxkey - - inc gFXIndex ; increment transition effect index - jsr okvs_len - !word gFXStore - cmp gFXIndex - bne + - lda #0 - sta gFXIndex -+ - lda gFXIndex - sta @nexti - jsr okvs_nth ; get name of next HGR transition - !word gFXStore -@nexti !byte $FD ; SMC - +STAY @nextfx - - jsr okvs_update ; save name of next HGR transition in prefs store - !word gGlobalPrefsStore - !word kNextFX -@nextfx !word $FDFD ; SMC - - jsr SaveGlobalPreferences ; write prefs store to disk - - ; load transition effect code at $6000 - +LOAD_FILE kFXDirectory, @fxkey - rts -@fxkey !word $FDFD -kFXConfFile - !byte @kFXConfFile_e-*-1 - !text "FX.CONF" -@kFXConfFile_e - -;------------------------------------------------------------------------------ -; LoadDHGRTransition -; looks up name of next DHGR transition effect in DFX.CONF and loads that file -; at $6000 - -; in: gDFXStore has been initialized -; gGlobalPrefsStore has been initialized -; out: all registers and flags clobbered -; $6000..$BFFF/main contains transition effect code -;------------------------------------------------------------------------------ -LoadDHGRTransition - jsr LoadFile ; load DHGR transition effects list into $8000 - !word kDFXConfFile - jsr ParseKeyValueList ; parse DHGR transition effects list into $6000 - !word gDFXStore - !word ldrlo2 ; (ldrlo2) points to last load address - !byte 0 - - jsr okvs_get ; get next DHGR transition effect from prefs - !word gGlobalPrefsStore - !word kNextDFX - bcs @nodfx - +STAY @dfx - jsr okvs_get - !word gDFXStore -@dfx !word $FDFD ; SMC - bcc + -@nodfx ldx #0 -+ stx gDFXIndex - - jsr okvs_nth ; get filename of DHGR transition effect code - !word gDFXStore -gDFXIndex - !byte 0 - +STAY @dfxkey - - inc gDFXIndex ; increment transition effect index for next time - jsr okvs_len - !word gDFXStore - cmp gDFXIndex - bne + - lda #0 - sta gDFXIndex -+ - lda gDFXIndex - sta @nexti - jsr okvs_nth ; get name of next DHGR transition - !word gDFXStore -@nexti !byte $FD ; SMC - +STAY @nextdfx - - jsr okvs_update ; save name of next DHGR transition in prefs store - !word gGlobalPrefsStore - !word kNextDFX -@nextdfx !word $FDFD ; SMC - - jsr SaveGlobalPreferences ; write prefs store to disk - - ; load transition effect code at $6000 - +LOAD_FILE kFXDirectory, @dfxkey - rts -@dfxkey !word $FDFD -kDFXConfFile - !byte @kDFXConfFile_e-*-1 - !text "DFX.CONF" -@kDFXConfFile_e - -;------------------------------------------------------------------------------ -; LoadSHGRTransition -; [TODO] for now there is only 1 SHR transition so this always load the same file -; [TODO] but eventually it should look up name of next SHR transition effect in -; [TODO] SFX.CONF or something and loads that file at $A000 -; -; in: gSFXStore has been initialized -; gGlobalPrefsStore has been initialized -; out: all registers and flags clobbered -; $A000..$BFFF/main contains transition effect code -;------------------------------------------------------------------------------ -LoadSHRTransition - jsr LoadFile - !word kSFXFizzleFile - rts -kSFXFizzleFile - !byte @kSFXFizzleFile_e-*-1 - !text "FX/SHR.FIZZLE" -@kSFXFizzleFile_e - -;------------------------------------------------------------------------------ -; BlankHGR -; clear and show HGR page 1 without flickering -; -; in: none -; out: text page clobbered (but screen holes preserved) -; $2000..$3FFF cleared -;------------------------------------------------------------------------------ -BlankHGR - jsr Home - jsr ClearHGR1 ; clear hi-res screen 1 - lda $c057 ; show hi-res screen 1 (now blank) - lda $c054 - lda $c052 - lda $c050 - rts - -;------------------------------------------------------------------------------ -; BlankDHGR -; clear and show DHGR page 1 without flickering -; -; in: none -; out: text page clobbered (but screen holes preserved) -; $2000..$3FFF/main and /aux cleared -;------------------------------------------------------------------------------ -BlankDHGR - jsr Home - jsr ClearHGR1 ; clear hi-res screen 1 - sta $C005 - jsr ClearHGR1 ; clear hi-res screen 1 in auxmem - sta $C004 - sta $c00d - sta $c057 - sta $c054 - sta $c052 - sta $c050 - sta $c05e - rts - -;------------------------------------------------------------------------------ -; BlankSHR -; clear and show SHR mode without flickering -; -; in: machine is a IIgs or has a VidHD card that responds appropriately to -; IIgs-specific softswitches for graphics and memory modes -; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing $C029, -; so it is imperative that the caller ensure the machine type -; out: text page clobbered (but screen holes preserved) -; $2000..$9FFF/aux cleared -;------------------------------------------------------------------------------ -BlankSHR - jsr Home - - lda $C029 ; set GS NEWVIDEO mode to turn off linearize - ora #$40 - sta $C029 - - sta $C005 ; writes go to auxmem - - lda $C035 ; enable auxmem-to-bank-E1 shadowing on IIgs - and #$F7 - sta $C035 - - lda #$20 ; clear $2000..$9FFF in auxmem - sta @a+2 - ldx #$80 - lda #0 - tay -@a sta $2000,y - iny - bne @a - inc @a+2 - dex - bne @a - - sta $C004 ; writes go to main memory - - lda $C029 ; set GS NEWVIDEO mode to turn on SHR mode - ora #$81 - sta $C029 - - rts - -;------------------------------------------------------------------------------ -; ClearHGR1 -; clear $2000..$3FFF in current memory bank (main or auxmem) -; -; in: none -; out: $2000..$3FFF cleared -; A = 0 -; X = 0 -; Y = 0 -; Z = 1 -;------------------------------------------------------------------------------ -ClearHGR1 - ldx #$20 - stx @a+2 - lda #0 - tay -@a sta $2000,y - iny - bne @a - inc @a+2 - dex - bne @a - rts - ;------------------------------------------------------------------------------ ; Home ; clear and display text screen @@ -766,7 +169,7 @@ Home jsr $FC58 ; HOME +READ_RAM1_WRITE_RAM1 lda MachineStatus - and #%00110000 + and #SUPPORTS_SHR beq @noSHR lda $C029 and #$7F @@ -774,54 +177,3 @@ Home @noSHR rts @end - -;------------------------------------------------------------------------------ -; Prelaunch -; code to set up machine for running a self-running, self-terminating game demo -; DO NOT CALL DIRECTLY -; must be run from main memory -; contains multiple entry points -; -; in: none -; 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 bank 1 then JMP |Reenter| -;------------------------------------------------------------------------------ -Prelaunch ; this runs from main memory -; entry point used by some self-running demos - lda $C088 - jmp Reenter - -; 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 (some games like Pooyan - sta $4E ; require these to be non-zero) - lda #$02 - sta $4F - jsr $FE89 ; initialize machine like a cold boot (many - jsr $FE93 ; games assume a 'clean slate' and rely on - jsr $FE84 ; zero page values set by these ROM routines, - sta $C000 ; e.g. Wavy Navy just prints out text via $FDED - sta $C002 ; and expects it to work) - sta $C004 - sta $C00C - sta $C00E - jsr $FB2F - jsr $FC58 - ldx #$FD ; jump to game entry point via stack pop - txs - rts -End_Prelaunch diff --git a/src/ui.attract.shr.a b/src/ui.attract.shr.a new file mode 100644 index 000000000..bc6193737 --- /dev/null +++ b/src/ui.attract.shr.a @@ -0,0 +1,121 @@ +;license:MIT +;(c) 2018 by 4am +; +; Super hi-res slideshows +; +; Public functions +; - SHRArtworkSlideshow +; - BlankSHR +; + +SHRArtworkSlideshow + lda MachineStatus ; only run SHR slideshow on IIgs or if we have a VidHD card + and #SUPPORTS_SHR + bne + + rts ++ jsr LoadSHRTransition + jsr okvs_iter + !word gSlideshowStore + !word SHRArtworkCallback + jmp BlankHGR + +;------------------------------------------------------------------------------ +; LoadSHGRTransition +; [TODO] for now there is only 1 SHR transition so this always load the same file +; [TODO] but eventually it should look up name of next SHR transition effect in +; [TODO] SFX.CONF or something and loads that file at $A000 +; +; in: gSFXStore has been initialized +; gGlobalPrefsStore has been initialized +; out: all registers and flags clobbered +; $A000..$BFFF/main contains transition effect code +;------------------------------------------------------------------------------ +LoadSHRTransition + jsr LoadFile + !word kSFXFizzleFile + rts +kSFXFizzleFile + !byte @kSFXFizzleFile_e-*-1 + !text "FX/SHR.FIZZLE" +@kSFXFizzleFile_e + +;------------------------------------------------------------------------------ +; SHRArtworkCallback +; callback called by okvs_iter on gSlideshowStore +; to load and display a single SHR graphic + +; in: A/Y contains address of filename (name only, path is always /SHR/) +; X contains 0-based index of the current record in gSlideshowStore +; out: all registers and flags clobbered +; $0800..$1EFF preserved (this contains the gSlideshowStore OKVS data) +; $2000..$BFFF clobbered by graphics data and transition code +; $2000..$5FFF/aux clobbered +;------------------------------------------------------------------------------ +SHRArtworkCallback + +STAY PTR + + lda $C000 + bpl + + rts ++ + stx gCurrentlyVisibleSlideshowIndex + + jsr BlankSHR + + ; load SHR artwork at $2000/main (not aux) + jsr ResetPath + +LDADDR kSHRArtworkDirectory + jsr AddToPath + +LDADDR kPathSeparator + jsr AddToPath + +LDAY PTR + jsr AddToPath + jsr LoadFile + !word gPathname + + jsr $A000 + jmp WaitAfterTransition + +;------------------------------------------------------------------------------ +; BlankSHR +; clear and show SHR mode without flickering +; +; in: machine is a IIgs or has a VidHD card that responds appropriately to +; IIgs-specific softswitches for graphics and memory modes +; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing $C029, +; so it is imperative that the caller ensure the machine type +; out: text page clobbered (but screen holes preserved) +; $2000..$9FFF/aux cleared +;------------------------------------------------------------------------------ +BlankSHR + jsr Home + + lda $C029 ; set GS NEWVIDEO mode to turn off linearize + ora #$40 + sta $C029 + + sta $C005 ; writes go to auxmem + + lda $C035 ; enable auxmem-to-bank-E1 shadowing on IIgs + and #$F7 + sta $C035 + + lda #$20 ; clear $2000..$9FFF in auxmem + sta @a+2 + ldx #$80 + lda #0 + tay +@a sta $2000,y + iny + bne @a + inc @a+2 + dex + bne @a + + sta $C004 ; writes go to main memory + + lda $C029 ; set GS NEWVIDEO mode to turn on SHR mode + ora #$81 + sta $C029 + + rts