4cade/src/ui.common.a

198 lines
5.9 KiB
Plaintext
Raw Normal View History

;License:MIT
2019-06-26 02:44:39 +00:00
;(c) 2018-9 by 4am
;
2019-09-24 19:50:40 +00:00
; miscellaneous UI functions
2019-06-26 02:44:39 +00:00
;
; Public functions
; - SoftBell
; - Home
; - BlankHGR
; - BlankDHGR
2019-09-21 22:04:38 +00:00
; - ExecuteTransitionAndWait
2019-09-24 19:50:40 +00:00
; - WaitForKeyFor30Seconds
2019-09-21 22:04:38 +00:00
; - CoverFade
2019-09-10 04:19:07 +00:00
;
2019-07-03 22:31:50 +00:00
2019-06-26 02:44:39 +00:00
;------------------------------------------------------------------------------
; SoftBell
; yell at the user, but, like, gently
;
; in: none
2019-09-07 18:15:53 +00:00
; out: C clear
; Y preserved
; A=0
; X=0
; all flags preserved
2019-06-26 02:44:39 +00:00
;------------------------------------------------------------------------------
SoftBell
ldx #32
- lda #2
jsr @wait
2019-06-27 14:55:07 +00:00
bit SPEAKER
2019-06-26 02:44:39 +00:00
lda #33
jsr @wait
2019-06-27 14:55:07 +00:00
bit SPEAKER
2019-06-26 02:44:39 +00:00
dex
bne -
2019-09-07 18:15:53 +00:00
clc
2019-06-26 02:44:39 +00:00
rts
@wait ; identical to $FCA8 ROM routine, but ROM is switched out when we need it
sec
-- pha
- sbc #1
bne -
pla
sbc #1
bne --
rts
;------------------------------------------------------------------------------
; Home
; clear and display text screen (HARDER THAN IT SOUNDS)
;
; in: none
; out: $0106..$011F clobbered
;------------------------------------------------------------------------------
Home
lda MachineStatus
2019-06-26 02:44:39 +00:00
and #SUPPORTS_SHR
beq @noSHR
2019-06-27 14:55:07 +00:00
lda NEWVIDEO
2019-06-30 17:59:06 +00:00
and #$3F
sta NEWVIDEO ; get out of SHR mode and linear mode
2019-06-28 03:42:01 +00:00
lda #$F0
sta TBCOLOR ; white text on black background
lda #$00
sta CLOCKCTL ; black border
2019-06-28 03:50:25 +00:00
sta CLOCKCTL ; set twice for VidHD
2019-06-26 02:44:39 +00:00
@noSHR
ldx #(@end-@start-1)
- lda @start,x
sta $106,x
dex
bpl -
jmp $106
@start
; this will be run from main memory
+READ_ROM_NO_WRITE
2019-06-27 14:55:07 +00:00
sta CLR80VID ; get out of DHGR mode
sta DHIRESOFF ; get out of DHGR mode
jsr ROM_TEXT ; TEXT
jsr ROM_HOME ; HOME
2019-06-26 02:44:39 +00:00
+READ_RAM1_WRITE_RAM1
rts
@end
;------------------------------------------------------------------------------
; 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
2019-09-24 19:50:40 +00:00
jsr ClearHGR1 ; clear hi-res screen 1
2019-06-27 14:55:07 +00:00
sta WRITEAUXMEM
2019-09-24 19:50:40 +00:00
jsr ClearHGR1 ; clear hi-res screen 1 in auxmem
2019-06-27 14:55:07 +00:00
sta WRITEMAINMEM
sta SET80VID
sta DHIRESON
bit PAGE1
jmp HGRMode
;------------------------------------------------------------------------------
2019-09-10 04:24:54 +00:00
; 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
2019-09-24 19:50:40 +00:00
jsr ClearHGR1 ; clear hi-res screen 1
2019-09-10 04:24:54 +00:00
bit PAGE1 ; show hi-res screen 1 (now blank)
; execution falls through here
;------------------------------------------------------------------------------
; HGRMode
; twiddles softswitches to set HGR mode (does not set page 1 or 2)
;
; in: none
; out: all registers preserved
;------------------------------------------------------------------------------
HGRMode
bit $C057
bit $C052
bit $C050
2019-06-26 02:44:39 +00:00
rts
;------------------------------------------------------------------------------
; ExecuteTransitionAndWait
; call transition effect code (address passed in) and wait a period of time
; or until the user presses a key
;
; in: A/Y = address of transition effect code
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
2019-06-26 02:44:39 +00:00
ExecuteTransitionAndWait
+STAY @j+1
@j jsr $FDFD ; SMC call transition effect code
ldx #$20 ; picture is showing so now we wait
- lda #0
jsr WaitForKeyWithTimeout
bmi +
dex
bpl -
+ lda KBD
cmp #$95
2019-09-24 19:50:40 +00:00
bne ConvenientlyPlacedRTS
bit CLEARKBD
2019-09-10 04:22:28 +00:00
ConvenientlyPlacedRTS
2019-09-06 19:21:38 +00:00
rts
2019-09-10 04:19:07 +00:00
; /!\ keep this last in the file to ensure it doesn't cross a page boundary /!\
;------------------------------------------------------------------------------
; WaitForKeyFor30Seconds
; does what it says on the tin
;
; in: none
; out: if user presses a key before the timer runs out, exits with A = key
2019-09-24 19:50:40 +00:00
; and X/Y preserved
; otherwise exits via MegaAttractMode and everything is clobbered
2019-09-10 04:19:07 +00:00
;------------------------------------------------------------------------------
WaitForKeyFor30Seconds
lda #$16 ; initialize timeout counters
sta Timeout
sta Timeout+1
sta Timeout+2
@loop
lda KBD
2019-09-10 04:22:28 +00:00
bmi ConvenientlyPlacedRTS
2019-09-10 04:19:07 +00:00
inc RNDSEED+1 ; these are only ever incremented, never
bne + ; reset (may be used as a pseudorandom
inc RNDSEED ; seed)
+
2019-10-08 04:05:33 +00:00
dec Timeout
bne @loop
dec Timeout+1
bne @loop
dec Timeout+2
2019-09-10 04:19:07 +00:00
bne @loop
2019-09-21 22:04:38 +00:00
; execution falls through here
CoverFade
jsr LoadCoverOffscreen
jsr ShowOtherPage
lda OffscreenPage
bne +
jsr LoadCoverOffscreen
jsr ShowOtherPage
+ jsr LoadFile ; load transition effect code at $6000
!word kFXDirectory
!word kCoverFadeFile
!word $6000
jsr $6000 ; call transition effect
jmp MegaAttractMode ; exit via mega attract mode