all screen control codes are now handled via jumptable

This commit is contained in:
FeralChild64 committed 2019-10-30 23:10:48 +01:00
1 parent 1682587d12
commit 01024278f4
5 files changed
+77 -54

No files matched your search

+23 -51
View File
@@ -7,62 +7,32 @@ chrout_screen_control:
txa
// Order here is not random
// 1. First handle the ones that do not depend on quote mode
// 2. Handle remaining control codes starting from the most commonly used
// We want to be as snappy as possible
chrout_try_RETURN:
cmp #KEY_RETURN
bne !+
// RETURN clears quote and insert modes, it also clears reverse flag
lda #$00
sta QTSW
sta INSRT
sta RVS
jmp chrout_screen_advance_to_next_line
!:
chrout_try_DEL:
cmp #KEY_DEL
beq_far chrout_screen_DEL
chrout_try_INS:
cmp #KEY_INS
beq_far chrout_screen_INS
#if CONFIG_EDIT_STOPQUOTE
chrout_try_STOP:
cmp #KEY_STOP
bne !+
lda #$00
sta QTSW
sta INSRT
// Let it run, we are saving 3 bytes on JMP this way
// and the performance hit is not going to be visible nevertheless
!:
#endif
chrout_try_quote:
lda QTSW
ora INSRT
beq !+
txa
jmp chrout_screen_quote
!:
txa
chrout_try_jumptable:
ldx #(__chrout_screen_jumptable_codes_end - chrout_screen_jumptable_codes - 1)
chrout_try_jumptable_loop:
cpx #(__chrout_screen_jumptable_quote_guard - chrout_screen_jumptable_codes - 1)
bne chrout_try_jumptable_loop_noquote
// Is this insert/quote mode?
tay
lda QTSW
ora INSRT
beq !+
tya
jmp chrout_screen_quote
!:
tya
// FALLTROUGH
chrout_try_jumptable_loop_noquote:
cmp chrout_screen_jumptable_codes, x
bne !+
// Found, perform a jump to subroutine
lda chrout_screen_jumptable_hi, x
pha
@@ -76,7 +46,9 @@ chrout_try_jumptable_loop:
chrout_try_COLOR:
ldx #$0F
chrout_try_color_loop:
chrout_try_color_loop:
cmp colour_codes,x
bne !+
stx COLOR