4cade/src/ui.offscreen.a

215 lines
6.7 KiB
Plaintext
Raw Normal View History

2019-09-24 19:50:40 +00:00
;License:MIT
2020-03-13 00:03:37 +00:00
;(c) 2018-2020 by 4am
2019-09-24 19:50:40 +00:00
;
; 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
2020-03-14 00:11:59 +00:00
; - ClearScreens
2019-09-24 19:50:40 +00:00
; - 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
jsr ForceHGRMode
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
2020-03-13 00:03:37 +00:00
;;and #HAS_DHGR_TITLE
bmi @dhgr
2020-03-09 21:24:30 +00:00
@hgr
jsr ForceHGRMode
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
2020-03-14 00:11:59 +00:00
;------------------------------------------------------------------------------
; 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
2019-09-24 19:50:40 +00:00
;------------------------------------------------------------------------------
; 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
2020-03-13 00:03:37 +00:00
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
2019-09-24 19:50:40 +00:00
lda #$80
2020-03-13 00:03:37 +00:00
ClearGR
2019-09-24 19:50:40 +00:00
ldy #0
2020-03-13 00:03:37 +00:00
PageFrom lda $FD00,y ; SMC
PageTo sta $FD00,y ; SMC
2019-09-24 19:50:40 +00:00
iny
2020-03-13 00:03:37 +00:00
bne PageFrom
inc PageFrom+2
inc PageTo+2
2019-09-24 19:50:40 +00:00
dex
2020-03-13 00:03:37 +00:00
bne PageFrom
2020-03-15 15:23:56 +00:00
sta READMAINMEM
2019-09-24 19:50:40 +00:00
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