4cade/src/ui.offscreen.a

180 lines
5.5 KiB
Plaintext
Raw Normal View History

2019-09-24 19:50:40 +00:00
;License:MIT
;(c) 2018-9 by 4am
;
; functions for managing which HGR page is showing, and doing things on the other one
;
; - GetOffscreenAddress
; - LoadTitleOffscreen
; - LoadCoverOffscreen
; - LoadHelpOffscreen
2019-09-24 19:50:40 +00:00
; - LoadGameTitleOffscreen
2019-09-28 12:35:48 +00:00
; - ResyncPage
2019-09-24 19:50:40 +00:00
; - ShowOtherPage
; - ToggleOffscreenPage
; - ClearOffscreen
; - ClearHGR1
2019-10-10 01:02:46 +00:00
; - ClearMem
2019-09-24 19:50:40 +00:00
;
; 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
2019-12-03 18:02:39 +00:00
Ignore = * + 1 ; discard IRQs, particularly on the IIc
2019-10-10 01:02:46 +00:00
lda #$40
2019-10-09 02:25:22 +00:00
OffscreenPage = * + 1
2019-10-10 01:02:46 +00:00
bne + ; SMC
2019-10-09 02:25:22 +00:00
; 0 = currently showing HGR page 2
; (so offscreen is page 1 @ $2000)
; 1 = currently showing HGR page 1
; (so offscreen is page 2 @ $4000)
2019-10-10 01:02:46 +00:00
+ lsr
2019-09-24 19:50:40 +00:00
rts
;------------------------------------------------------------------------------
; LoadTitleOffscreen
; load title screen in the HGR page that is currently not showing
;
; in: none
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
LoadTitleOffscreen
2019-10-10 04:26:18 +00:00
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
2019-10-10 04:26:18 +00:00
+HIDE_NEXT_2_BYTES
2019-09-24 19:50:40 +00:00
;------------------------------------------------------------------------------
; LoadCoverOffscreen
; load cover screen in the HGR page that is currently not showing
;
; in: none
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
LoadCoverOffscreen
2019-10-10 04:26:18 +00:00
lda #<kCoverFile
LoadOffscreenFromAY
2019-10-10 04:26:18 +00:00
sta @fname
2019-09-24 19:50:40 +00:00
jsr GetOffscreenAddress
sta +
jsr LoadFile
!word kRootDirectory
2019-10-10 04:26:18 +00:00
@fname !byte $FD ; SMC
!byte >kCoverFile ; all of these are on the same page
2019-09-24 19:50:40 +00:00
!byte $00
+ !byte $FD ; SMC
rts
LoadGameTitleOffscreen
2019-10-08 18:43:41 +00:00
; in: gGameToLaunch = index into gGamesListStore
jsr GetGameToLaunch
2020-03-09 21:24:30 +00:00
+STAY @fname
bit MachineStatus ; if < 128K, don't bother checking for DHGR title
bvc @hgr
jsr okvs_get_current
; (PTR) -> game title + bitfield of game info
; Y = 0
lda (PTR),y ; A = game title length + 1
sta SAVE
tay
lda (PTR),y ; A = game info bitfield
and #HAS_DHGR_TITLE
bne @dhgr
@hgr
2019-09-24 19:50:40 +00:00
jsr GetOffscreenAddress
2020-03-09 21:24:30 +00:00
sta @addrhi
2019-09-24 19:50:40 +00:00
jsr LoadFile
!word kHGRTitleDirectory
2020-03-09 21:24:30 +00:00
@fname !word $FDFD ; SMC
2019-09-24 19:50:40 +00:00
!byte $00
2020-03-09 21:24:30 +00:00
@addrhi !byte $FD ; SMC
rts
@dhgr
jsr BlankDHGR
+LDAY @fname
+STAY +
jsr LoadDHRFile
!word kDHGRTitleDirectory
+ !word $FDFD
2019-09-24 19:50:40 +00:00
rts
;------------------------------------------------------------------------------
; 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
2019-10-08 23:40:38 +00:00
; A = #$80
; X = #$00
; Y = #$00
2019-09-24 19:50:40 +00:00
; Z = 1
;------------------------------------------------------------------------------
ClearOffscreen
jsr GetOffscreenAddress
+HIDE_NEXT_2_BYTES
ClearHGR1
2019-09-26 03:01:59 +00:00
lda #$20 ; note to self: LDX #$20 can't move here
2019-09-24 19:50:40 +00:00
ldx #$20
2019-10-10 01:02:46 +00:00
ClearMem
sta @a+2
2019-09-24 19:50:40 +00:00
lda #$80
ldy #0
@a sta $2000,y
iny
bne @a
inc @a+2
dex
bne @a
rts
2019-09-28 12:35:48 +00:00
ResyncPage
jsr ToggleOffscreenPage
2019-10-08 17:19:20 +00:00
; /!\ execution falls through here to ShowOtherPage
2019-09-24 19:50:40 +00:00
;------------------------------------------------------------------------------
; 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