4cade/src/ui.common.a

156 lines
5.1 KiB
Plaintext
Raw Normal View History

;License:MIT
2020-03-17 01:58:05 +00:00
;(c) 2018-2020 by 4am
2019-06-26 02:44:39 +00:00
;
2019-09-24 19:50:40 +00:00
; miscellaneous UI functions
2019-06-26 02:44:39 +00:00
;
; Public functions
; - Home
; - BlankDHGR
; - DHGRMode
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: none
2019-06-26 02:44:39 +00:00
;------------------------------------------------------------------------------
Home
lda MachineStatus
2019-06-26 02:44:39 +00:00
and #SUPPORTS_SHR
beq @noSHR
lda #%00000001 ; bit 7 = 0 -> IIgs Apple II-compatible video modes
2019-10-12 16:23:15 +00:00
; bit 6 = 0 -> IIgs 128K memory map is the same as the Apple IIe
; bit 5 = 0 -> IIgs DHGR is color, not monochrome
; bits 1-4 reserved
; bit 0 = 1 -> disable bank latch
2019-10-12 16:23:15 +00:00
sta NEWVIDEO
2020-11-09 20:22:38 +00:00
ldy #$F0
sty TBCOLOR ; white text on black background
lsr
2019-06-28 03:42:01 +00: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
2020-03-13 14:41:09 +00:00
sta gMachineInDHGRMode ; A=0 here
2020-03-14 00:11:59 +00:00
ldy #$2C ; BIT
sty PageFrom
ldx #$04
stx PageTo+2
lda #$A0 ; clear text screen page 1
2020-03-14 00:11:59 +00:00
jsr ClearGR
sta WRITEAUXMEM
ldx #$04
stx PageTo+2
jsr ClearGR
sta WRITEMAINMEM
2020-03-14 00:11:59 +00:00
jsr WaitForVBL
2019-06-27 14:55:07 +00:00
sta DHIRESOFF ; get out of DHGR mode
sta CLR80VID ; /!\ order of operations matters for RGB card
2019-12-02 01:48:36 +00:00
lda PAGE1
lda TEXTMODE
jmp UnwaitForVBL
2019-06-26 02:44:39 +00:00
;------------------------------------------------------------------------------
; 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
2021-11-15 18:24:53 +00:00
lda #1
sta OffscreenPage
2019-12-22 00:28:59 +00:00
; /!\ execution falls through here to DHGRMode
;------------------------------------------------------------------------------
; DHGRMode
; switch to DHGR mode (HARDER THAN IT SOUNDS)
;
; in: none
; out: none
;------------------------------------------------------------------------------
DHGRMode
2019-12-22 00:28:59 +00:00
; magic sequence to set colour mode on an RGB card
; SET80VID clears the RGB-card shift-register
; DHIRESON/OFF shifts that bit into the mode register
; we do that twice because the mode register is two bits wide
; we need mode 00 for colour
jsr WaitForVBL
2019-06-27 14:55:07 +00:00
sta SET80VID
sta DHIRESON
2019-12-21 21:02:54 +00:00
sta DHIRESOFF
sta DHIRESON
sta DHIRESOFF
2019-12-22 00:28:59 +00:00
sta DHIRESON ; then turn DHGR on
2021-11-15 18:24:53 +00:00
jsr ToggleOffscreenPage
jsr ShowOtherPage
2020-03-09 21:24:30 +00:00
lda #1
sta gMachineInDHGRMode
jsr UnwaitForVBL
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
2019-10-10 01:02:46 +00:00
; Z = 1 and C = 0 if this is a search key
2019-10-08 17:19:20 +00:00
; 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
2019-11-27 21:51:43 +00:00
ldx #kInputError ; also #kSoftBell
2019-10-08 17:19:20 +00:00
rts
2019-10-14 02:22:47 +00:00
;------------------------------------------------------------------------------
; IsUpDownOrRightArrow
; test whether accumulator contains ASCII code for up, down, or right arrow
; search
;
; in: A = key
; out: all registers preserved
; Z = 1 if accumulator was one of those 3 keys
; Z = 0 otherwise
;------------------------------------------------------------------------------
2019-10-08 17:19:20 +00:00
IsUpDownOrRightArrow
cmp #$8B ; up arrow
beq @done
cmp #$95 ; right arrow
beq @done
cmp #$8A ; down arrow
@done rts