reordered and size-optimized some screen routines
This commit is contained in:
1 parent
e6e921e740
commit
a442bf910f
12 files changed
+183
-151
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
SRCDIR_COMMON = c64/aliases
|
||||
SRCDIR_BASIC_COMMON = $(SRCDIR_COMMON) c64/basic
|
||||
SRCDIR_KERNAL_COMMON = $(SRCDIR_COMMON) c64/kernal c64/kernal/assets c64/kernal/jumptable c64/kernal/iec c64/kernal/interrupts c64/kernal/print
|
||||
SRCDIR_KERNAL_COMMON = $(SRCDIR_COMMON) c64/kernal c64/kernal/assets c64/kernal/jumptable c64/kernal/iec c64/kernal/interrupts c64/kernal/print c64/kernal/screen
|
||||
|
||||
SRCDIR_BASIC_generic = $(SRCDIR_BASIC_COMMON) c64/basic/,target_generic
|
||||
SRCDIR_BASIC_mega65 = $(SRCDIR_BASIC_COMMON) c64/basic/,target_mega65
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
// We have the following variables:
|
||||
// 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)
|
||||
|
||||
show_cursor_if_enabled:
|
||||
lda BLNSW
|
||||
beq !+
|
||||
rts
|
||||
!: lda BLNON
|
||||
beq show_cursor
|
||||
rts
|
||||
|
||||
show_cursor:
|
||||
// Set cursor as though it had just finished the off phase,
|
||||
// so that the call to blink_cursor paints it
|
||||
lda #$00
|
||||
sta BLNCT
|
||||
sta BLNON
|
||||
jsr blink_cursor
|
||||
// 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
|
||||
rts
|
||||
|
||||
blink_cursor:
|
||||
// Is the cursor enabled?
|
||||
lda BLNSW
|
||||
bne no_blink_cursor
|
||||
|
||||
// Do we need to redraw things?
|
||||
dec BLNCT
|
||||
bpl no_blink_cursor
|
||||
|
||||
// Check if cursor was visible or not, and toggle
|
||||
lda BLNON
|
||||
bne undraw_cursor
|
||||
draw_cursor:
|
||||
jsr calculate_screen_line_pointer
|
||||
|
||||
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
|
||||
|
||||
jmp reset_blink_timer
|
||||
|
||||
undraw_cursor:
|
||||
jsr calculate_screen_line_pointer
|
||||
|
||||
lda GDBLN
|
||||
ldy PNTR
|
||||
sta (PNT),y
|
||||
lda GDCOL
|
||||
sta (USER),y
|
||||
|
||||
lda #0
|
||||
sta BLNON
|
||||
// Fall through
|
||||
reset_blink_timer:
|
||||
// Rest blink counter
|
||||
// (Compute's Mapping the 64, p39-40)
|
||||
lda #20
|
||||
sta BLNCT
|
||||
no_blink_cursor:
|
||||
rts
|
||||
|
||||
disable_cursor:
|
||||
lda #$80
|
||||
sta BLNSW
|
||||
// FALL THROUGH
|
||||
hide_cursor_if_visible:
|
||||
lda BLNON
|
||||
bne undraw_cursor
|
||||
rts
|
||||
|
||||
enable_cursor:
|
||||
lda #$00
|
||||
sta BLNSW
|
||||
rts
|
||||
|
||||
+7
-44
@@ -9,6 +9,7 @@
|
||||
//
|
||||
|
||||
// XXX keyboard part currently does not preserve register Y, to be fixed!
|
||||
// XXX try to make chrin_real unnecessary (try to fit this into original location)
|
||||
|
||||
// Reads a byte of input, unless from keyboard.
|
||||
// If from keyboard, then it gets a whole line of input, and returns the first char.
|
||||
@@ -84,8 +85,8 @@ not_end_of_input:
|
||||
|
||||
read_from_keyboard:
|
||||
|
||||
jsr enable_cursor
|
||||
|
||||
jsr cursor_enable
|
||||
|
||||
// Wait for a key
|
||||
lda NDX
|
||||
beq chrin_repeat
|
||||
@@ -94,12 +95,12 @@ read_from_keyboard:
|
||||
cmp #$0d
|
||||
bne not_enter
|
||||
|
||||
jsr disable_cursor
|
||||
|
||||
jsr cursor_disable
|
||||
|
||||
jsr pop_keyboard_buffer
|
||||
|
||||
jsr hide_cursor_if_visible
|
||||
|
||||
jsr cursor_hide_if_visible
|
||||
|
||||
// It was enter.
|
||||
// Note that we have a line of input to return, and return the first byte thereof
|
||||
// after computing and storing its length.
|
||||
@@ -170,41 +171,3 @@ pop_keyboard_buffer:
|
||||
cli
|
||||
|
||||
rts
|
||||
|
||||
screen_code_to_petscii:
|
||||
cmp #$1b
|
||||
bcs not_alpha
|
||||
|
||||
clc
|
||||
adc #$40
|
||||
rts
|
||||
|
||||
not_alpha:
|
||||
cmp #$40
|
||||
bcs not_punctuation
|
||||
|
||||
rts
|
||||
|
||||
not_punctuation:
|
||||
cmp #$5b
|
||||
bcs not_shifted
|
||||
|
||||
clc
|
||||
adc #$80
|
||||
|
||||
rts
|
||||
|
||||
not_shifted:
|
||||
|
||||
cmp #$80
|
||||
bcs not_vendor
|
||||
|
||||
// $60-$7F -> $A0-$BF
|
||||
|
||||
clc
|
||||
adc #$40
|
||||
|
||||
// FALLTROUGH
|
||||
not_vendor:
|
||||
rts
|
||||
|
||||
@@ -9,7 +9,7 @@ chrout_screen:
|
||||
// Crude implementation of character output
|
||||
sei // XXX why do we need to disable interrupts?
|
||||
|
||||
jsr hide_cursor_if_visible
|
||||
jsr cursor_hide_if_visible
|
||||
|
||||
lda SCHAR
|
||||
tax
|
||||
@@ -620,7 +620,7 @@ line_not_linked_del:
|
||||
|
||||
screen_advance_to_next_line:
|
||||
|
||||
// jsr hide_cursor_if_visible
|
||||
// jsr cursor_hide_if_visible
|
||||
|
||||
// Go to start of line
|
||||
lda #0
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
clear_screen:
|
||||
|
||||
// XXX it is probably a good idea to hide cursor first
|
||||
|
||||
// Clear line link table
|
||||
// (Compute's Mapping the 64 p215)
|
||||
|
||||
@@ -57,4 +59,4 @@ clearscreen_l3:
|
||||
bne clearscreen_l3
|
||||
|
||||
// (Compute's Mapping the 64 p216)
|
||||
jmp home_cursor
|
||||
jmp cursor_home
|
||||
@@ -41,7 +41,7 @@ chrout_iec:
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_done_fail:
|
||||
jsr show_cursor_if_enabled
|
||||
jsr cursor_show_if_enabled
|
||||
|
||||
plp
|
||||
|
||||
@@ -54,7 +54,7 @@ chrout_done_fail:
|
||||
rts
|
||||
|
||||
chrout_done_unknown_device:
|
||||
jsr show_cursor_if_enabled
|
||||
jsr cursor_show_if_enabled
|
||||
|
||||
plp
|
||||
|
||||
@@ -68,7 +68,7 @@ chrout_done_unknown_device:
|
||||
jmp lvs_device_not_found_error
|
||||
|
||||
chrout_done:
|
||||
jsr show_cursor_if_enabled
|
||||
jsr cursor_show_if_enabled
|
||||
|
||||
plp
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
default_irq_handler:
|
||||
|
||||
jsr blink_cursor
|
||||
jsr cursor_blink
|
||||
jsr JSCNKEY
|
||||
jsr JUDTIM // update jiffy clock
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
//
|
||||
// Variables used:
|
||||
// - BLNSW (cursor blink switch)
|
||||
//
|
||||
|
||||
cursor_enable:
|
||||
lda #$00
|
||||
sta BLNSW
|
||||
rts
|
||||
@@ -1,7 +1,9 @@
|
||||
// Home the cursor
|
||||
// (Compute's Mapping the 64 p216)
|
||||
|
||||
home_cursor:
|
||||
//
|
||||
// Home the cursor (Compute's Mapping the 64 p216)
|
||||
//
|
||||
|
||||
cursor_home:
|
||||
|
||||
lda #$00
|
||||
sta PNTR // x position
|
||||
@@ -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
|
||||
Reference in new issue
Block a user