;License:MIT ;(c) 2018-9 by 4am ; ; miscellaneous UI functions ; ; Public functions ; - SoftBell ; - Home ; - BlankHGR ; - BlankDHGR ; - ExecuteTransitionAndWait ; - WaitForKeyFor30Seconds ; - CoverFade ; ;------------------------------------------------------------------------------ ; SoftBell ; yell at the user, but, like, gently ; ; in: none ; out: C clear ; Y preserved ; A=0 ; X=0 ; all flags preserved ;------------------------------------------------------------------------------ SoftBell ldx #32 - lda #2 jsr @wait bit SPEAKER lda #33 jsr @wait bit SPEAKER dex bne - clc 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 and #SUPPORTS_SHR beq @noSHR lda NEWVIDEO and #$3F sta NEWVIDEO ; get out of SHR mode and linear mode lda #$F0 sta TBCOLOR ; white text on black background lda #$00 sta CLOCKCTL ; black border sta CLOCKCTL ; set twice for VidHD @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 sta CLR80VID ; get out of DHGR mode sta DHIRESOFF ; get out of DHGR mode jsr ROM_TEXT ; TEXT jsr ROM_HOME ; HOME +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 jsr ClearHGR1 ; clear hi-res screen 1 sta WRITEAUXMEM jsr ClearHGR1 ; clear hi-res screen 1 in auxmem sta WRITEMAINMEM sta SET80VID sta DHIRESON bit PAGE1 jmp HGRMode ;------------------------------------------------------------------------------ ; 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 jsr ClearHGR1 ; clear hi-res screen 1 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 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 ;------------------------------------------------------------------------------ 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 bne ConvenientlyPlacedRTS bit CLEARKBD ConvenientlyPlacedRTS rts ; /!\ 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 ; and X/Y preserved ; otherwise exits via MegaAttractMode and everything is clobbered ;------------------------------------------------------------------------------ WaitForKeyFor30Seconds lda #$16 ; initialize timeout counters sta Timeout sta Timeout+1 sta Timeout+2 @loop lda KBD bmi ConvenientlyPlacedRTS inc RNDSEED+1 ; these are only ever incremented, never bne + ; reset (may be used as a pseudorandom inc RNDSEED ; seed) + dec Timeout ; these are a 3-byte timeout counter bne @loop ; that counts down from a number set dec Timeout+1 ; in .ResetInputTimeout and reset bne @loop ; on every keypress (whether or not dec Timeout+2 ; the key leads to an action) bne @loop ; 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