;License:MIT ;(c) 2018-9 by 4am ; ; miscellaneous UI functions ; ; Public functions ; - SoftBell ; - Home ; - BlankHGR ; - BlankDHGR ; - IsSearchKey ; - IsUpDownOrRightArrow ; ;------------------------------------------------------------------------------ ; 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 to HGRMode ;------------------------------------------------------------------------------ ; 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 ;------------------------------------------------------------------------------ ; IsSearchKey ; test whether accumulator contains a key that might trigger a new textrank ; search ; ; in: A = key ; out: A &= 0x7F ; Y preserved ; X clobbered ; Z = 1 if this is a search key ; Z = 0 if this is not a search key ;------------------------------------------------------------------------------ IsSearchKey and #$7F ; strip high bit for search characters cmp #$30 ; control keys and punctuation ignored bcc @badkey cmp #$3A ; numbers are good input bcc @goodkey cmp #$41 ; more punctuation (also ignored) bcc @badkey cmp #$5B ; uppercase letters are good input bcs + ora #$20 ; convert uppercase letters to lowercase @goodkey ldx #0 rts + cmp #$61 ; more punctuation (also ignored) bcc @badkey cmp #$7B ; lowercase letters are good input bcc @goodkey @badkey ldx #1 rts IsUpDownOrRightArrow cmp #$8B ; up arrow beq @done cmp #$95 ; right arrow beq @done cmp #$8A ; down arrow @done rts