4cade/src/ui.common.a

111 lines
3.3 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
; - Home
; - BlankDHGR
2019-10-08 17:19:20 +00:00
; - IsSearchKey
; - IsUpDownOrRightArrow
2019-09-10 04:19:07 +00:00
;
2019-07-03 22:31:50 +00:00
2019-06-26 02:44:39 +00:00
;------------------------------------------------------------------------------
; 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-10-08 17:19:20 +00:00
;------------------------------------------------------------------------------
; 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