4cade/src/ui.offscreen.a

265 lines
7.6 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
2021-10-28 00:08:03 +00:00
; in: gGameToLaunch = index into gSearchStore (word)
2021-10-28 05:28:20 +00:00
jsr GetGameToLaunch
2020-03-24 20:30:14 +00:00
+ST16 @fname
2020-03-09 21:24:30 +00:00
bit MachineStatus ; if < 128K, don't bother checking for DHGR title
bvc @hgr
jsr okvs_next_field
jsr okvs_next_field_PTR_is_already_set
2021-10-28 00:08:03 +00:00
; (PTR) -> length-prefixed game info bitfield
2020-03-09 21:24:30 +00:00
; Y = 0
2021-10-28 00:08:03 +00:00
iny ; Y = 1
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
jsr UnpackHGRTitle
2020-03-09 21:24:30 +00:00
rts
@dhgr
jsr BlankDHGR
2020-03-24 20:30:14 +00:00
+LD16 @fname
+ST16 +
2020-03-09 21:24:30 +00:00
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
lda #$00
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
;------------------------------------------------------------------------------
; UnpackHGRTitle
; unpack data from screen holes of the off screen HGR page
;
;------------------------------------------------------------------------------
UnpackHGRTitle
jsr GetOffscreenAddress
sta src+2
ora #$1E
sta dest+2
lda #$00
sta src+1
sta dest+1
lda #3
sta $E0
loop
ldx #0
-- ldy #$78
src
- lda $0000,y ;smc
dest
sta $0000,x ;smc
inx
iny
bpl -
tya ; y = #$80
eor src+1
sta src+1
bne +
inc src+2
+ cpx #$78
bne --
lda dest+1
eor #$80
sta dest+1
bne +
inc dest+2
+ dec $E0
bpl loop
rts