reordered and size-optimized some screen routines

This commit is contained in:
FeralChild64 committed 2019-10-08 16:27:07 +02:00
1 parent e6e921e740
commit a442bf910f
12 files changed
+183 -151

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
//
// Variables used:
// - BLNSW (cursor blink switch)
// - BLNCT (cursor blink countdown)
// - GDBLN (cursor saved character)
// - BLNON (if cursor is visible)
// - GDCOL (colour under cursor)
// - USER (current screen line colour pointer)
// - PNT (current screen line pointer)
// - PNTR (current screen x position)
//
cursor_blink:
// Is the cursor enabled?
lda BLNSW
bne cursor_blink_end
// Do we need to redraw things?
dec BLNCT
bpl cursor_blink_end
// Check if cursor was visible or not, and toggle
lda BLNON
bne cursor_undraw
// FALLTROUGH
cursor_draw:
jsr calculate_screen_line_pointer // XXX make sure this is not needed and remove the call
ldy PNTR
lda (PNT),y
sta GDBLN
eor #$80
sta (PNT),y
// Also set cursor colour
lda (USER),y
sta GDCOL
lda COLOR
sta (USER),y
lda #1
sta BLNON
bne cursor_blink_timer_reset // branches always
cursor_disable:
lda #$80
sta BLNSW
// FALLTHROUGH
cursor_hide_if_visible:
lda BLNON
beq cursor_blink_end
cursor_undraw:
lda GDBLN
ldy PNTR
sta (PNT),y
lda GDCOL
sta (USER),y
lda #0
sta BLNON
// FALLTROUGH
cursor_blink_timer_reset:
// Rest blink counter (Mapping the 64, p39-40)
lda #20
sta BLNCT
// FALLTROUGH
cursor_blink_end:
rts
+10
View File
@@ -0,0 +1,10 @@
//
// Variables used:
// - BLNSW (cursor blink switch)
//
cursor_enable:
lda #$00
sta BLNSW
rts
+12
View File
@@ -0,0 +1,12 @@
//
// Home the cursor (Compute's Mapping the 64 p216)
//
cursor_home:
lda #$00
sta PNTR // x position
sta TBLX // y position
jmp set_pointer_to_current_screen_line
+34
View File
@@ -0,0 +1,34 @@
//
// Variables used:
// - BLNSW (cursor blink switch)
// - BLNON (if cursor is visible)
// - BLNCT (cursor blink countdown)
//
cursor_show_if_enabled:
lda BLNSW
bne cursor_show_end
lda BLNON
bne cursor_show_end
// FALLTROUGH
cursor_show:
// Set cursor as though it had just finished the off phase,
// so that the call to cursor_blink paints it
lda #$00
sta BLNCT
sta BLNON
jsr cursor_blink
// Then set the timeout to 1 frame, so that the cursor
// blinks under key repeat conditions, like on the original KERNAL
lda #$01
sta BLNCT
// FALLTROUGH
cursor_show_end:
rts
@@ -0,0 +1,36 @@
screen_code_to_petscii:
cmp #$1B
bcc s2p_adc_40
s2p_not_alpha:
cmp #$40
bcc s2p_end
// FALLTROUGH
s2p_not_punctuation:
cmp #$5B
bcs s2p_not_shifted
// carry already clear here
adc #$80
rts
s2p_not_shifted:
cmp #$80
bcs s2p_end // not vendor
// $60-$7F -> $A0-$BF
s2p_adc_40:
clc
adc #$40
// FALLTROUGH
s2p_end:
rts