mirror of
https://github.com/a2-4am/4cade.git
synced 2024-11-19 02:10:39 +00:00
215 lines
6.7 KiB
Plaintext
215 lines
6.7 KiB
Plaintext
;License:MIT
|
|
;(c) 2018-2020 by 4am
|
|
;
|
|
; functions for managing which HGR page is showing, and doing things on the other one
|
|
;
|
|
; - GetOffscreenAddress
|
|
; - LoadTitleOffscreen
|
|
; - LoadCoverOffscreen
|
|
; - LoadHelpOffscreen
|
|
; - LoadGameTitleOffscreen
|
|
; - ResyncPage
|
|
; - ShowOtherPage
|
|
; - ToggleOffscreenPage
|
|
; - ClearScreens
|
|
; - ClearOffscreen
|
|
; - ClearHGR1
|
|
; - ClearMem
|
|
;
|
|
; Public variables
|
|
; - OffscreenPage
|
|
;
|
|
|
|
;------------------------------------------------------------------------------
|
|
; GetOffscreenAddress
|
|
; get high byte of HGR page that is currently not showing
|
|
;
|
|
; in: none
|
|
; out: A = high byte of offscreen HGR page (#$20 or #$40)
|
|
; preserves X/Y
|
|
;------------------------------------------------------------------------------
|
|
GetOffscreenAddress
|
|
Ignore = * + 1 ; discard IRQs, particularly on the IIc
|
|
lda #$40
|
|
OffscreenPage = * + 1
|
|
bne + ; SMC
|
|
; 0 = currently showing HGR page 2
|
|
; (so offscreen is page 1 @ $2000)
|
|
; 1 = currently showing HGR page 1
|
|
; (so offscreen is page 2 @ $4000)
|
|
+ lsr
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; LoadTitleOffscreen
|
|
; load title screen in the HGR page that is currently not showing
|
|
;
|
|
; in: none
|
|
; out: all flags and registers clobbered
|
|
;------------------------------------------------------------------------------
|
|
LoadTitleOffscreen
|
|
lda #<kTitleFile
|
|
+HIDE_NEXT_2_BYTES
|
|
;------------------------------------------------------------------------------
|
|
; LoadHelpOffscreen
|
|
; load help screen in the HGR page that is currently not showing
|
|
;
|
|
; in: none
|
|
; out: all flags and registers clobbered
|
|
;------------------------------------------------------------------------------
|
|
LoadHelpOffscreen
|
|
lda #<kHelpBackgroundFile
|
|
+HIDE_NEXT_2_BYTES
|
|
;------------------------------------------------------------------------------
|
|
; LoadCoverOffscreen
|
|
; load cover screen in the HGR page that is currently not showing
|
|
;
|
|
; in: none
|
|
; out: all flags and registers clobbered
|
|
;------------------------------------------------------------------------------
|
|
LoadCoverOffscreen
|
|
lda #<kCoverFile
|
|
LoadOffscreenFromAY
|
|
sta @fname
|
|
jsr ForceHGRMode
|
|
jsr GetOffscreenAddress
|
|
sta +
|
|
jsr LoadFile
|
|
!word kRootDirectory
|
|
@fname !byte $FD ; SMC
|
|
!byte >kCoverFile ; all of these are on the same page
|
|
!byte $00
|
|
+ !byte $FD ; SMC
|
|
rts
|
|
|
|
LoadGameTitleOffscreen
|
|
; in: gGameToLaunch = index into gGamesListStore (word)
|
|
jsr GetGameToLaunch
|
|
+ST16 @fname
|
|
bit MachineStatus ; if < 128K, don't bother checking for DHGR title
|
|
bvc @hgr
|
|
jsr okvs_get_current
|
|
; (PTR) -> game display name + bitfield of game info
|
|
; Y = 0
|
|
lda (PTR),y ; A = game display name length + 1
|
|
sta SAVE
|
|
tay
|
|
lda (PTR),y ; A = game info bitfield
|
|
;;and #HAS_DHGR_TITLE
|
|
bmi @dhgr
|
|
@hgr
|
|
jsr ForceHGRMode
|
|
jsr GetOffscreenAddress
|
|
sta @addrhi
|
|
jsr LoadFile
|
|
!word kHGRTitleDirectory
|
|
@fname !word $FDFD ; SMC
|
|
!byte $00
|
|
@addrhi !byte $FD ; SMC
|
|
rts
|
|
@dhgr
|
|
jsr BlankDHGR
|
|
+LD16 @fname
|
|
+ST16 +
|
|
jsr LoadDHRFile
|
|
!word kDHGRTitleDirectory
|
|
+ !word $FDFD
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; ClearScreens
|
|
; clear and display text screen and then clear both hires screens
|
|
; (in this order so that the erasing isn't visible)
|
|
;
|
|
; in: none
|
|
; out: $400..$7FF and $2000..$5FFF cleared
|
|
;------------------------------------------------------------------------------
|
|
ClearScreens
|
|
jsr Home
|
|
lda #$20 ; clear both hi-res pages
|
|
ldx #$40 ; to flash previous bits of the launcher UI)
|
|
bne ClearMem ; always
|
|
|
|
;------------------------------------------------------------------------------
|
|
; ClearOffscreen
|
|
; clear $2000..$3FFF or $4000..$5FFF, depending on which HGR page is not
|
|
; visible right now
|
|
; does not change HGR mode
|
|
;
|
|
; in: none
|
|
; out: $2000..$3FFF or $4000..$5FFF cleared
|
|
; A = #$80
|
|
; X = #$00
|
|
; Y = #$00
|
|
; Z = 1
|
|
;------------------------------------------------------------------------------
|
|
ClearOffscreen
|
|
jsr GetOffscreenAddress
|
|
+HIDE_NEXT_2_BYTES
|
|
ClearHGR1
|
|
lda #$20 ; note to self: LDX #$20 can't move here
|
|
ldx #$20
|
|
ClearMem
|
|
ldy #$2C ; BIT
|
|
bne + ; always
|
|
|
|
;------------------------------------------------------------------------------
|
|
; CopyHGR
|
|
;
|
|
; in: source and destination page pointers set
|
|
; out: all registers clobbered
|
|
; 8kb memory region duplicated
|
|
;------------------------------------------------------------------------------
|
|
CopyHGR
|
|
ldx #$20
|
|
ldy #$B9 ; LDY
|
|
+ sty PageFrom
|
|
sta PageTo+2
|
|
lda #$00
|
|
ClearGR
|
|
ldy #0
|
|
PageFrom lda $FD00,y ; SMC
|
|
PageTo sta $FD00,y ; SMC
|
|
iny
|
|
bne PageFrom
|
|
inc PageFrom+2
|
|
inc PageTo+2
|
|
dex
|
|
bne PageFrom
|
|
sta READMAINMEM
|
|
rts
|
|
|
|
ResyncPage
|
|
jsr ToggleOffscreenPage
|
|
; /!\ execution falls through here to ShowOtherPage
|
|
;------------------------------------------------------------------------------
|
|
; ShowOtherPage
|
|
; switch to the HGR page that is not currently showing
|
|
;
|
|
; in: none
|
|
; out: A = new value of OffscreenPage
|
|
; preserves X/Y
|
|
;------------------------------------------------------------------------------
|
|
ShowOtherPage
|
|
jsr ToggleOffscreenPage
|
|
bne +
|
|
bit PAGE2 ; show page 2
|
|
rts
|
|
+ bit PAGE1 ; show page 1
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; ToggleOffscreenPage
|
|
; switch the internal variable that tracks which HGR page is showing
|
|
; (does not affect screen)
|
|
;
|
|
; in: none
|
|
; out: A = new value of OffscreenPage
|
|
; preserves X/Y
|
|
;------------------------------------------------------------------------------
|
|
ToggleOffscreenPage
|
|
lda OffscreenPage
|
|
eor #$01
|
|
sta OffscreenPage
|
|
rts
|