more sane directory name, updated binaries
This commit is contained in:
1 parent
d4d32095d1
commit
76aaf298b8
697 files changed
+56
-56
No files matched your search
@@ -0,0 +1,128 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CHROUT routine - screen support (character output)
|
||||
//
|
||||
|
||||
|
||||
chrout_screen:
|
||||
|
||||
jsr cursor_hide_if_visible
|
||||
|
||||
lda SCHAR
|
||||
tax
|
||||
|
||||
// All the PETSCII control codes are within $0x, $1x, $8x, $9x, remaining
|
||||
// ones are always printable characters; separate away control codes
|
||||
|
||||
and #$60
|
||||
bne !+
|
||||
jmp chrout_screen_control
|
||||
!:
|
||||
txa
|
||||
|
||||
// Literals - first convert PETSCII to screen code
|
||||
|
||||
// Codes $C0-$DF become $40-$5F
|
||||
cmp #$E0
|
||||
bcs !+
|
||||
cmp #$C0
|
||||
bcc !+
|
||||
|
||||
and #$7F
|
||||
jmp chrout_screen_literal // not high char
|
||||
|
||||
!:
|
||||
// Range $20-$3F is unchanged
|
||||
cmp #$40
|
||||
bcc chrout_screen_literal // not high char
|
||||
|
||||
// Unshifted letters and symbols from $40-$5F
|
||||
// all end up being -$40
|
||||
// (C64 PRG p376)
|
||||
|
||||
// But anything >= $80 needs to be -$40
|
||||
// (C64 PRG p380-381)
|
||||
// And bit 7 should be cleared, only to be
|
||||
// set by reverse video
|
||||
sec
|
||||
sbc #$40
|
||||
|
||||
// Fix shifted chars by adding $20 again
|
||||
cmp #$20
|
||||
bcc chrout_screen_literal // not high char
|
||||
cmp #$40
|
||||
bcs chrout_screen_literal // not high char
|
||||
clc
|
||||
adc #$20
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_literal:
|
||||
|
||||
// Write normal character on the screen
|
||||
|
||||
tax // store screen code, we need .A for calculations
|
||||
|
||||
// First we need offset from PNT in .Y, we can take it from PNTR
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
|
||||
// Put the character on the screen
|
||||
|
||||
txa
|
||||
ora RVS // Computes Mapping the 64, page 38
|
||||
sta (PNT),y
|
||||
|
||||
// Decrement number of chars waiting to be inserted
|
||||
|
||||
lda INSRT
|
||||
beq !+
|
||||
dec INSRT
|
||||
!:
|
||||
// Toggle quote flag if required
|
||||
|
||||
txa
|
||||
jsr screen_check_toggle_quote
|
||||
|
||||
// Set colour of the newly printed character
|
||||
|
||||
lda COLOR
|
||||
sta (USER),y
|
||||
|
||||
// Advance the column
|
||||
|
||||
ldy PNTR
|
||||
iny
|
||||
sty PNTR
|
||||
|
||||
// Scroll down (extend logical line) if needed
|
||||
|
||||
cpy #40
|
||||
bne !+
|
||||
jsr screen_grow_logical_line
|
||||
inc TBLX
|
||||
ldy PNTR
|
||||
!:
|
||||
// If not the 80th character of the logical row, we are done
|
||||
|
||||
cpy #80
|
||||
bcc chrout_screen_calc_lptr_done
|
||||
|
||||
// Advance to the next line
|
||||
|
||||
jmp screen_advance_to_next_line
|
||||
|
||||
chrout_screen_calc_lptr_done:
|
||||
|
||||
jsr screen_calculate_pointers
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_done:
|
||||
|
||||
jsr cursor_show_if_enabled
|
||||
jmp chrout_done_success
|
||||
@@ -0,0 +1,14 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CLR key handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_CLR:
|
||||
|
||||
jsr clear_screen
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
@@ -0,0 +1,72 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CHROUT routine - screen support, control codes
|
||||
//
|
||||
|
||||
chrout_screen_control:
|
||||
|
||||
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
|
||||
#if !HAS_OPCODES_65C02
|
||||
lda chrout_screen_jumptable_hi, x
|
||||
pha
|
||||
lda chrout_screen_jumptable_lo, x
|
||||
pha
|
||||
rts
|
||||
#else
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
jmp (chrout_screen_jumptable, x)
|
||||
#endif
|
||||
!:
|
||||
dex
|
||||
bpl chrout_try_jumptable_loop
|
||||
|
||||
chrout_try_COLOR:
|
||||
|
||||
ldx #$0F
|
||||
|
||||
chrout_try_color_loop:
|
||||
|
||||
cmp colour_codes,x
|
||||
bne !+
|
||||
stx COLOR
|
||||
jmp chrout_screen_done
|
||||
!:
|
||||
dex
|
||||
bpl chrout_try_color_loop
|
||||
|
||||
// Unknown code, or key not requiring any handling
|
||||
jmp chrout_screen_done
|
||||
@@ -0,0 +1,59 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Cursor keys handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_CRSR_UP:
|
||||
|
||||
lda TBLX
|
||||
beq chrout_screen_CRSR_done
|
||||
dec TBLX
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_CRSR_done:
|
||||
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
|
||||
chrout_screen_CRSR_DOWN:
|
||||
|
||||
lda TBLX
|
||||
cmp #24
|
||||
bne !+
|
||||
jsr screen_scroll_up
|
||||
!:
|
||||
inc TBLX
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
|
||||
chrout_screen_CRSR_RIGHT:
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
cpy #39
|
||||
beq_16 screen_advance_to_next_line
|
||||
|
||||
iny
|
||||
!:
|
||||
sty PNTR
|
||||
bpl chrout_screen_CRSR_done // branch always
|
||||
|
||||
|
||||
chrout_screen_CRSR_LEFT:
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
dey
|
||||
bpl !-
|
||||
|
||||
lda TBLX
|
||||
beq chrout_screen_CRSR_done
|
||||
|
||||
dec TBLX
|
||||
lda #39
|
||||
sta PNTR
|
||||
bne chrout_screen_CRSR_done // branch always
|
||||
@@ -0,0 +1,122 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CHROUT routine - screen support, DEL key handling
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_DEL:
|
||||
|
||||
// In insert mode it embeds control character
|
||||
ldx INSRT
|
||||
beq !+
|
||||
lda #KEY_DEL
|
||||
jmp chrout_screen_quote
|
||||
!:
|
||||
ldy PNTR
|
||||
beq chrout_screen_del_column_0
|
||||
cpy #40
|
||||
bne chrout_screen_del_column_normal
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_del_column_40:
|
||||
|
||||
// First column of the extended line - decrement USER/PNT for copying
|
||||
|
||||
#if HAS_OPCODES_65CE02
|
||||
dew USER
|
||||
dew PNT
|
||||
#else
|
||||
lda USER+0
|
||||
bne !+
|
||||
dec USER+1
|
||||
dec PNT+1
|
||||
!:
|
||||
dec USER+0
|
||||
dec PNT+0
|
||||
#endif
|
||||
|
||||
// Copy characters
|
||||
ldx #39
|
||||
ldy #0
|
||||
|
||||
jsr chrout_screen_del_copy_loop
|
||||
|
||||
// Finish by moving the cursor left
|
||||
jmp chrout_screen_CRSR_LEFT
|
||||
|
||||
chrout_screen_del_column_normal:
|
||||
|
||||
// We need to scroll back the rest of the logical line
|
||||
|
||||
// First reduce PNTR to 0-39 range
|
||||
jsr screen_get_clipped_PNTR
|
||||
sty PNTR
|
||||
|
||||
// Now get the offset to the last logical line character
|
||||
jsr screen_get_logical_line_end_ptr
|
||||
tya
|
||||
|
||||
// Substract the PNTR value, this will tell us how many characters we need to move
|
||||
sec
|
||||
sbc PNTR
|
||||
tax
|
||||
|
||||
// Perform the character copy (scroll back) in a loop
|
||||
ldy PNTR
|
||||
dey
|
||||
jsr chrout_screen_del_copy_loop
|
||||
|
||||
dec PNTR
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_del_done:
|
||||
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
chrout_screen_del_copy_loop:
|
||||
|
||||
iny
|
||||
lda (USER),y
|
||||
dey
|
||||
sta (USER),y
|
||||
iny
|
||||
lda (PNT),y
|
||||
dey
|
||||
sta (PNT),y
|
||||
iny
|
||||
|
||||
dex
|
||||
bpl chrout_screen_del_copy_loop
|
||||
|
||||
// Clear char at end of line (just the character - not color!)
|
||||
lda #$20
|
||||
sta (PNT),y
|
||||
|
||||
rts
|
||||
|
||||
chrout_screen_del_column_0:
|
||||
|
||||
ldy TBLX
|
||||
beq chrout_screen_del_done // delete from row 0, col 0 does nothing
|
||||
|
||||
// Move cursor to end of previous line
|
||||
dec TBLX
|
||||
lda #39
|
||||
sta PNTR
|
||||
|
||||
// Update PNT and USER pointers
|
||||
jsr screen_calculate_PNT_USER
|
||||
|
||||
// Put space character at the current cursor position (do not clear the color!)
|
||||
ldy #39
|
||||
lda #$20
|
||||
sta (PNT),y
|
||||
|
||||
// Finish with recalculating all the variables
|
||||
bne chrout_screen_del_done
|
||||
@@ -0,0 +1,23 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// GFX/TXT mode switch handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_GFX:
|
||||
|
||||
lda VIC_YMCSB
|
||||
and #$02 // to upper case
|
||||
!:
|
||||
sta VIC_YMCSB
|
||||
jmp chrout_screen_done
|
||||
|
||||
chrout_screen_TXT:
|
||||
|
||||
lda VIC_YMCSB
|
||||
ora #$02 // to lower case
|
||||
bne !- // branch always
|
||||
@@ -0,0 +1,14 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// HOME key handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_HOME:
|
||||
|
||||
jsr cursor_home
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
@@ -0,0 +1,97 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CHROUT routine - screen support, INS key handling
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_INS:
|
||||
|
||||
// First check if last character of the logical line is space
|
||||
|
||||
jsr screen_check_space_ends_line
|
||||
beq chrout_screen_ins_possible
|
||||
|
||||
// Not space, we cannot insert anything
|
||||
|
||||
bne_16 chrout_screen_done
|
||||
|
||||
chrout_screen_ins_possible:
|
||||
|
||||
// Move chars towards end of the line
|
||||
jsr screen_get_logical_line_end_ptr
|
||||
|
||||
// Special handling for cursor in second line
|
||||
ldx TBLX
|
||||
lda LDTB1+0, x
|
||||
bpl chrout_screen_ins_second_line
|
||||
|
||||
// Perform character copy
|
||||
jsr chrout_screen_ins_copy_loop
|
||||
|
||||
// Put space in the inserted gap
|
||||
lda #$20
|
||||
sta (PNT), y
|
||||
|
||||
// If line does not end with space now, try to grow the logical line
|
||||
|
||||
jsr screen_check_space_ends_line
|
||||
beq chrout_screen_ins_done
|
||||
jsr screen_grow_logical_line
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
chrout_screen_ins_done:
|
||||
|
||||
// End of processing
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
chrout_screen_ins_second_line:
|
||||
|
||||
// Adapt PNTR for copying
|
||||
lda PNTR
|
||||
sec
|
||||
sbc #40
|
||||
sta PNTR
|
||||
|
||||
// Perform character copy
|
||||
jsr chrout_screen_ins_copy_loop
|
||||
|
||||
// Put space in the inserted gap
|
||||
lda #$20
|
||||
sta (PNT), y
|
||||
|
||||
// End of processing
|
||||
bne chrout_screen_ins_done // branch always
|
||||
|
||||
chrout_screen_ins_copy_loop:
|
||||
|
||||
// Note: While the following routine is obvious to any skilled
|
||||
// in the art as the most obvious simple and efficient solution,
|
||||
// if the screen writes are before the colour writes, it results
|
||||
// in a relatively long verbatim stretch of bytes when compared to
|
||||
// the C64 KERNAL. Thus we have swapped the order, just to reduce
|
||||
// the potential for any argument of copyright infringement, even
|
||||
// though we really do not believe that the routine can be copyrighted
|
||||
// due to the lack of creativity.
|
||||
dey
|
||||
lda (USER),y
|
||||
iny
|
||||
sta (USER),y
|
||||
dey
|
||||
lda (PNT),y
|
||||
iny
|
||||
sta (PNT),y
|
||||
|
||||
dey
|
||||
cpy PNTR
|
||||
bne chrout_screen_ins_copy_loop
|
||||
|
||||
// Increase insert mode count (which causes quote-mode like behaviour)
|
||||
inc INSRT
|
||||
|
||||
// Return from loop
|
||||
rts
|
||||
@@ -0,0 +1,100 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Jumptable for screen control codes support. To improve performance, should be sorted
|
||||
// starting from the least probable routine.
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_jumptable_codes:
|
||||
|
||||
.byte KEY_CLR
|
||||
.byte KEY_HOME
|
||||
.byte KEY_SHIFT_OFF
|
||||
.byte KEY_SHIFT_ON
|
||||
.byte KEY_TXT
|
||||
.byte KEY_GFX
|
||||
.byte KEY_RVS_OFF
|
||||
.byte KEY_RVS_ON
|
||||
.byte KEY_CRSR_RIGHT
|
||||
.byte KEY_CRSR_LEFT
|
||||
.byte KEY_CRSR_DOWN
|
||||
.byte KEY_CRSR_UP
|
||||
.byte KEY_INS
|
||||
|
||||
__chrout_screen_jumptable_quote_guard:
|
||||
|
||||
#if CONFIG_EDIT_STOPQUOTE
|
||||
.byte KEY_STOP
|
||||
#endif
|
||||
#if CONFIG_EDIT_TABULATORS
|
||||
.byte KEY_TAB_BW
|
||||
.byte KEY_TAB_FW
|
||||
#endif
|
||||
.byte KEY_DEL
|
||||
.byte KEY_RETURN
|
||||
|
||||
__chrout_screen_jumptable_codes_end:
|
||||
|
||||
|
||||
|
||||
.const chrout_list = List().add(
|
||||
|
||||
chrout_screen_CLR,
|
||||
chrout_screen_HOME,
|
||||
chrout_screen_SHIFT_OFF,
|
||||
chrout_screen_SHIFT_ON,
|
||||
chrout_screen_TXT,
|
||||
chrout_screen_GFX,
|
||||
chrout_screen_RVS_OFF,
|
||||
chrout_screen_RVS_ON,
|
||||
chrout_screen_CRSR_RIGHT,
|
||||
chrout_screen_CRSR_LEFT,
|
||||
chrout_screen_CRSR_DOWN,
|
||||
chrout_screen_CRSR_UP,
|
||||
chrout_screen_INS,
|
||||
#if CONFIG_EDIT_STOPQUOTE
|
||||
chrout_screen_STOP,
|
||||
#endif
|
||||
#if CONFIG_EDIT_TABULATORS
|
||||
chrout_screen_TAB_BW,
|
||||
chrout_screen_TAB_FW,
|
||||
#endif
|
||||
chrout_screen_DEL,
|
||||
chrout_screen_RETURN
|
||||
)
|
||||
|
||||
|
||||
#if !HAS_OPCODES_65C02
|
||||
|
||||
|
||||
chrout_screen_jumptable_lo:
|
||||
|
||||
put_jumptable_lo(chrout_list)
|
||||
|
||||
|
||||
chrout_screen_jumptable_hi:
|
||||
|
||||
put_jumptable_hi(chrout_list)
|
||||
|
||||
|
||||
#else // HAS_OPCODES_65C02
|
||||
|
||||
|
||||
__before_chrout_screen_jumptable:
|
||||
|
||||
.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary
|
||||
|
||||
chrout_screen_jumptable:
|
||||
|
||||
put_jumptable(chrout_list)
|
||||
|
||||
// Make sure routine size is always the same - build system limitation
|
||||
|
||||
.if (__before_chrout_screen_jumptable == chrout_screen_jumptable) { brk }
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// CHROUT routine - screen support, control codes in quote mode
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_quote:
|
||||
|
||||
// Low control codes are just +$80
|
||||
clc
|
||||
adc #$80
|
||||
|
||||
// If it overflowed, then it is a high control code,
|
||||
// so we need to make it be $80 + $40 + char
|
||||
// as we will have flipped back to just $00 + char, we should
|
||||
// now add $c0 if C is set from overflow
|
||||
bcc !+
|
||||
adc #$BF // C=1, so adding $BF + C = add $C0
|
||||
!:
|
||||
jmp chrout_screen_literal
|
||||
@@ -0,0 +1,33 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// RETURN key handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_RETURN:
|
||||
|
||||
// RETURN clears quote and insert modes, it also clears reverse flag
|
||||
|
||||
lda #$00
|
||||
sta QTSW
|
||||
sta INSRT
|
||||
sta RVS
|
||||
|
||||
// RETURN key moves cursor two lines down in case
|
||||
// of first line of the extended logical line
|
||||
|
||||
ldy TBLX
|
||||
cpy #24
|
||||
beq !+ // last line on screen - no need for a double line skip
|
||||
|
||||
lda LDTB1+1, y
|
||||
bmi !+ // current line is not continued
|
||||
|
||||
inc TBLX
|
||||
jsr screen_calculate_PNT_USER
|
||||
!:
|
||||
jmp screen_advance_to_next_line
|
||||
@@ -0,0 +1,21 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// RVS ON/OFF handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_RVS_ON:
|
||||
|
||||
lda #$80
|
||||
bne !+ // branch always
|
||||
|
||||
chrout_screen_RVS_OFF:
|
||||
|
||||
lda #$00
|
||||
!:
|
||||
sta RVS
|
||||
jmp chrout_screen_done
|
||||
@@ -0,0 +1,21 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// SHIFT ON/OFF handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
chrout_screen_SHIFT_ON:
|
||||
|
||||
lda #$00 // enable SHIFT+VENDOR combination
|
||||
!:
|
||||
sta MODE
|
||||
jmp chrout_screen_done
|
||||
|
||||
chrout_screen_SHIFT_OFF:
|
||||
|
||||
lda #$80 // disable SHIFT+VENDOR combination
|
||||
bne !- // branch always
|
||||
@@ -0,0 +1,22 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// STOP key handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
#if CONFIG_EDIT_STOPQUOTE
|
||||
|
||||
|
||||
chrout_screen_STOP:
|
||||
|
||||
lda #$00
|
||||
sta QTSW
|
||||
sta INSRT
|
||||
jmp chrout_screen_done
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Tabulation keys handling within CHROUT
|
||||
//
|
||||
|
||||
|
||||
#if CONFIG_EDIT_TABULATORS
|
||||
|
||||
|
||||
chrout_screen_TAB_FW:
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
tya
|
||||
ora #%00000111
|
||||
tay
|
||||
iny
|
||||
cpy #40
|
||||
bcc !+
|
||||
ldy #39
|
||||
!:
|
||||
sty PNTR
|
||||
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
|
||||
chrout_screen_TAB_BW:
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
beq !+ // column 0, recalculating pointers is not necessary, but this is a rare case nevertheless
|
||||
|
||||
dey
|
||||
tya
|
||||
and #%11111000
|
||||
sta PNTR
|
||||
!:
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
|
||||
|
||||
#endif // CONFIG_EDIT_TABULATORS
|
||||
@@ -0,0 +1,84 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// 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 screen_get_clipped_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:
|
||||
|
||||
jsr screen_get_clipped_PNTR
|
||||
lda GDBLN
|
||||
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,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Variables used:
|
||||
// - BLNSW (cursor blink switch)
|
||||
//
|
||||
|
||||
|
||||
cursor_enable:
|
||||
|
||||
lda #$00
|
||||
sta BLNSW
|
||||
rts
|
||||
@@ -0,0 +1,39 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// 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,34 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Clear screen and initialise line link table, described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - pages 215-216
|
||||
//
|
||||
|
||||
|
||||
clear_screen:
|
||||
|
||||
// Clear the line link table - cheecked on original ROMs,
|
||||
// the highest bit set means that the line is NOT a logical
|
||||
// continuation of the previous one
|
||||
|
||||
lda #$80
|
||||
ldy #24
|
||||
!:
|
||||
sta LDTB1,y
|
||||
dey
|
||||
bpl !-
|
||||
|
||||
// Clear all the rows
|
||||
ldx #24
|
||||
!:
|
||||
jsr screen_clear_line
|
||||
dex
|
||||
bpl !-
|
||||
|
||||
// Fall to cursor home routine
|
||||
jmp cursor_home
|
||||
@@ -0,0 +1,19 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Home the cursor, described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 216
|
||||
//
|
||||
|
||||
|
||||
cursor_home:
|
||||
|
||||
lda #$00
|
||||
sta PNTR // current column (logical)
|
||||
sta TBLX // current row
|
||||
|
||||
// FALLTROUGH to the next routine
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
This is a well-known address, needed even for some BASIC programming - it's a common target for a SYS command. See for example here:
|
||||
|
||||
- http://ready64.org/articoli/_files/043_pokesc64.txt
|
||||
sys 58726 - CLR/HOME
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
This is a well-known address, probably used by lots of software. See for example here:
|
||||
|
||||
- https://www.lemon64.com/forum/viewtopic.php?t=69526&sid=836d087e9759db667ba3bb1732eea266
|
||||
@@ -0,0 +1,19 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Set pointer (PNT) to current screen line , described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 216
|
||||
// - http://sta.c64.org/cbm64scrfunc.html
|
||||
//
|
||||
|
||||
// XXX find out what the original ROM really recalculate
|
||||
|
||||
|
||||
screen_calculate_pointers:
|
||||
|
||||
jsr screen_calculate_PNT_USER
|
||||
jmp screen_calculate_PNTR_LNMX
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
This is a well-known address, needed even for some BASIC programming - it's a common target for a SYS command. See for example here:
|
||||
|
||||
- http://ready64.org/articoli/_files/043_pokesc64.txt
|
||||
sys 59626 - Scrolls a Line
|
||||
@@ -0,0 +1,134 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Scroll the whole screen up by 1 logical line, described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 218
|
||||
//
|
||||
|
||||
|
||||
screen_scroll_up:
|
||||
|
||||
// First handle CTRL and NO_SCRL keys
|
||||
|
||||
#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65
|
||||
|
||||
// Do not scroll if NO_SCRL is pressed and interrupts are enabled
|
||||
!:
|
||||
php
|
||||
pla
|
||||
and #%00000010
|
||||
bne !+ // branch if IRQs disabled, we cannot detect NO_SCRL status
|
||||
|
||||
lda SHFLAG
|
||||
and #KEY_FLAG_NO_SCRL
|
||||
bne !-
|
||||
!:
|
||||
|
||||
#endif
|
||||
|
||||
// Check if CTRL key pressed - if so, perform a delay
|
||||
|
||||
lda SHFLAG
|
||||
and #KEY_FLAG_CTRL
|
||||
beq screen_scroll_up_delay_done
|
||||
|
||||
ldy #$09
|
||||
!:
|
||||
ldx #$FF
|
||||
jsr wait_x_bars
|
||||
dey
|
||||
bne !-
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_scroll_up_delay_done: // entry point for cursor move control codes
|
||||
|
||||
// Scroll the LDTB1 (line link table)
|
||||
|
||||
ldy #$00
|
||||
!:
|
||||
lda LDTB1+1, y
|
||||
sta LDTB1+0, y
|
||||
iny
|
||||
cpy #24
|
||||
bne !-
|
||||
|
||||
lda #$80
|
||||
sta LDTB1+24
|
||||
|
||||
// Preserve SAL and EAL, prepare initial SAL/EAL/PNT/USER values
|
||||
|
||||
jsr screen_preserve_sal_eal
|
||||
|
||||
lda HIBASE
|
||||
sta SAL+1
|
||||
sta EAL+1
|
||||
|
||||
lda #>COLOR_RAM
|
||||
sta PNT+1
|
||||
sta USER+1
|
||||
|
||||
lda #$00
|
||||
sta EAL+0
|
||||
sta USER+0
|
||||
lda #40
|
||||
sta SAL+0
|
||||
sta PNT+0
|
||||
|
||||
// Now copy, SAL->EAL, PNT->USER, in a loop
|
||||
|
||||
ldy #$00
|
||||
|
||||
screen_scroll_up_loop:
|
||||
|
||||
lda (SAL), y
|
||||
sta (EAL), y
|
||||
lda (PNT), y
|
||||
sta (USER), y
|
||||
|
||||
// Check if this was the last byte (last destination byte for color copy is #DBBF)
|
||||
|
||||
cpy #$BF
|
||||
bne !+ // definitely not the last byte
|
||||
lda USER+1
|
||||
cmp #$DB
|
||||
beq screen_scroll_up_loop_done
|
||||
!:
|
||||
// Increment .Y, possibly advance pointers
|
||||
|
||||
iny
|
||||
bne screen_scroll_up_loop
|
||||
|
||||
inc SAL+1
|
||||
inc EAL+1
|
||||
inc USER+1
|
||||
inc PNT+1
|
||||
bne screen_scroll_up_loop // branch alwayys
|
||||
|
||||
screen_scroll_up_loop_done:
|
||||
|
||||
// Restore SAL and EAL
|
||||
|
||||
jsr screen_restore_sal_eal
|
||||
|
||||
// Clear the newly introduced line
|
||||
|
||||
ldx #24
|
||||
jsr screen_clear_line
|
||||
|
||||
// Decrement the current physical line number
|
||||
|
||||
dec TBLX
|
||||
|
||||
// If the first line is linked, scroll once more
|
||||
|
||||
bit LDTB1+0
|
||||
bpl screen_scroll_up
|
||||
|
||||
// Recalculate PNT and USER
|
||||
|
||||
jmp screen_calculate_PNT_USER
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
This is a well-known address, needed even for some BASIC programming - it's a common target for a SYS command. See for example here:
|
||||
|
||||
- http://ready64.org/articoli/_files/043_pokesc64.txt
|
||||
sys 59903 - Clears Line of Text
|
||||
@@ -0,0 +1,38 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Well-known routine, described in:
|
||||
//
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 219
|
||||
// - http://sta.c64.org/cbm64scrfunc.html
|
||||
//
|
||||
// input: .X - screen line to clear
|
||||
//
|
||||
// Checked that original routine preserves X (convenient for loops),
|
||||
// and leaves space screen code in .A, so duplicate this behaviour
|
||||
//
|
||||
|
||||
|
||||
screen_clear_line:
|
||||
|
||||
// First, calculate PNT and USER
|
||||
phx_trash_a
|
||||
jsr screen_calculate_PNT_USER_from_X
|
||||
plx_trash_a
|
||||
|
||||
// Now clear the line
|
||||
ldy #39
|
||||
!:
|
||||
lda COLOR
|
||||
sta (USER), y
|
||||
lda #$20 // space character screen code
|
||||
sta (PNT), y
|
||||
|
||||
dey
|
||||
bpl !-
|
||||
|
||||
// Done
|
||||
rts
|
||||
@@ -0,0 +1,24 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmer's Reference Guide - page 295
|
||||
// - [CM64] Compute's Mapping the Commodore 64 - page 215
|
||||
//
|
||||
// CPU registers that has to be preserved (see [RG64]): .A
|
||||
//
|
||||
|
||||
|
||||
SCREEN:
|
||||
|
||||
// There are only 2 sane ways to implement this routine,
|
||||
// I hope this one is different than what Commodore picked :)
|
||||
|
||||
ldy #25 // 25 columns
|
||||
ldx #40 // 40 rows
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,23 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_advance_to_next_line:
|
||||
|
||||
// Check if we are at the bottom of the screen
|
||||
ldy TBLX
|
||||
cpy #24
|
||||
bne !+
|
||||
|
||||
// We need to scroll the screen up
|
||||
jsr screen_scroll_up
|
||||
!:
|
||||
inc TBLX
|
||||
|
||||
// Set PNTR to 0 (for continued line will be fixed later)
|
||||
lda #$00
|
||||
sta PNTR
|
||||
|
||||
jmp chrout_screen_calc_lptr_done
|
||||
@@ -0,0 +1,56 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Set pointers PNT and USER to current screen line
|
||||
//
|
||||
|
||||
|
||||
screen_calculate_PNT_USER:
|
||||
|
||||
ldx TBLX
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_PNT_USER_from_X: // entry point for screen_clear_line
|
||||
|
||||
// Reset pointer to start of screen
|
||||
|
||||
lda HIBASE
|
||||
sta PNT+1
|
||||
lda #$00
|
||||
sta PNT+0
|
||||
|
||||
// Add 40 to PNT for every line
|
||||
|
||||
cpx #$00
|
||||
beq screen_calculate_USER
|
||||
!:
|
||||
lda #40
|
||||
clc
|
||||
adc PNT+0
|
||||
sta PNT+0
|
||||
bcc !+
|
||||
inc PNT+1
|
||||
!:
|
||||
dex
|
||||
bne !--
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_USER:
|
||||
|
||||
// Calculate USER (pointer to the current line in color RAM)
|
||||
|
||||
lda PNT+0
|
||||
sta USER+0
|
||||
lda PNT+1
|
||||
sec
|
||||
sbc HIBASE
|
||||
clc
|
||||
adc #>COLOR_RAM
|
||||
sta USER+1
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,64 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Sets PNTR in a proper range (0-39 or 40-79)
|
||||
// Sets LNMX to 39 or 79
|
||||
//
|
||||
|
||||
|
||||
screen_calculate_PNTR_LNMX:
|
||||
|
||||
ldy TBLX
|
||||
lda LDTB1, y
|
||||
php
|
||||
jsr screen_get_clipped_PNTR
|
||||
plp
|
||||
bmi screen_calculate_PNTR_0_39
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_PNTR_40_79:
|
||||
|
||||
tya
|
||||
clc
|
||||
adc #40
|
||||
tay
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_PNTR_0_39:
|
||||
|
||||
sty PNTR
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_LNMX:
|
||||
|
||||
ldy TBLX
|
||||
lda LDTB1, y
|
||||
bpl screen_calculate_lnmx_79 // this line is a continuation
|
||||
|
||||
cpy #24
|
||||
beq screen_calculate_lnmx_39 // this is the last line, which is not a continuation
|
||||
|
||||
iny
|
||||
lda LDTB1, y
|
||||
bpl screen_calculate_lnmx_79 // line is continued
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_lnmx_39:
|
||||
|
||||
lda #39
|
||||
skip_2_bytes_trash_nvz
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_calculate_lnmx_79:
|
||||
|
||||
lda #79
|
||||
sta LNMX
|
||||
rts
|
||||
@@ -0,0 +1,14 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_check_space_ends_line:
|
||||
|
||||
jsr screen_get_logical_line_end_ptr
|
||||
|
||||
lda (PNT), y
|
||||
cmp #$20
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,21 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper routine - check character in .A, toggles quote flag if needed
|
||||
//
|
||||
|
||||
screen_check_toggle_quote:
|
||||
|
||||
cmp #$22
|
||||
bne !+
|
||||
|
||||
lda QTSW
|
||||
eor #$80
|
||||
sta QTSW
|
||||
|
||||
lda #$22 // restore previous .A valuee
|
||||
!:
|
||||
rts
|
||||
@@ -0,0 +1,72 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Screen code to PETSCII conversion - see:
|
||||
//
|
||||
// - https://www.lemon64.com/forum/viewtopic.php?t=66362
|
||||
// - https://sta.c64.org/cbm64scrtopetext.html
|
||||
//
|
||||
|
||||
|
||||
screen_code_to_petscii:
|
||||
|
||||
cmp #$20
|
||||
bcc s2p_adc_40 // $00-$1F -> $40-$5F
|
||||
|
||||
cmp #$40
|
||||
bcc s2p_end // $20-$3F -> $20-$3F
|
||||
|
||||
cmp #$60
|
||||
bcc s2p_adc_80 // $40-$5F -> $C0-$DF
|
||||
|
||||
cmp #$80
|
||||
bcc s2p_adc_40 // $60-$7F -> $A0-$BF
|
||||
|
||||
// Here we have to check for quote mode
|
||||
|
||||
bit QTSW
|
||||
bmi screen_code_to_petscii_quote
|
||||
|
||||
// Not quote mode - continue
|
||||
|
||||
cmp #$A0
|
||||
bcc s2p_adc_C0 // $80-$9F -> $40-$5F
|
||||
|
||||
cmp #$C0
|
||||
bcc s2p_adc_80 // $A0-$BF -> $20-$3F
|
||||
|
||||
cmp #$E0
|
||||
bcc s2p_end // $C0-$DF -> $C0-$DF
|
||||
|
||||
clc
|
||||
bcc s2p_adc_C0 // $E0-$FF -> $A0-$BF
|
||||
|
||||
s2p_adc_40:
|
||||
|
||||
adc #$40 // Carry already clear
|
||||
|
||||
s2p_end:
|
||||
|
||||
rts
|
||||
|
||||
s2p_adc_80:
|
||||
|
||||
adc #$80 // Carry already clear
|
||||
rts
|
||||
|
||||
screen_code_to_petscii_quote:
|
||||
|
||||
cmp #$C0
|
||||
bcc s2p_adc_80 // $80-$BF -> $00-$3F
|
||||
|
||||
clc
|
||||
|
||||
// FALLTROUGH $C0-$FF -> $80-$BF
|
||||
|
||||
s2p_adc_C0:
|
||||
|
||||
adc #$C0 // Carry already clear
|
||||
rts
|
||||
@@ -0,0 +1,20 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Get PNTR value clipped to 0-39 range in .Y, sets flags to compare with 0, can trash .A
|
||||
//
|
||||
|
||||
screen_get_clipped_PNTR:
|
||||
|
||||
ldy PNTR
|
||||
cpy #40
|
||||
bcc !+
|
||||
tya
|
||||
sbc #40
|
||||
tay
|
||||
!:
|
||||
cpy #$00
|
||||
rts
|
||||
@@ -0,0 +1,29 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_get_logical_line_end_ptr:
|
||||
|
||||
ldy TBLX
|
||||
cpy #24
|
||||
bcs screen_get_logical_line_end_39 // last line of the screen
|
||||
|
||||
lda LDTB1+0, y
|
||||
bpl screen_get_logical_line_end_39 // current line continues previous one
|
||||
|
||||
lda LDTB1+1, y
|
||||
bmi screen_get_logical_line_end_39 // current line is not continued
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_get_logical_line_end_79:
|
||||
|
||||
ldy #79
|
||||
rts
|
||||
|
||||
screen_get_logical_line_end_39:
|
||||
|
||||
ldy #39
|
||||
rts
|
||||
@@ -0,0 +1,144 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_grow_logical_line_done_scroll:
|
||||
|
||||
inc TBLX
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_grow_logical_line_done:
|
||||
|
||||
jmp screen_calculate_PNT_USER
|
||||
|
||||
|
||||
screen_grow_logical_line_screen_up:
|
||||
|
||||
jsr screen_scroll_up
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
|
||||
screen_grow_logical_line:
|
||||
|
||||
// Do not grow line if previus one is grown
|
||||
ldy TBLX
|
||||
lda LDTB1+0, y
|
||||
bpl screen_grow_logical_line_done_scroll
|
||||
|
||||
// If last line, scroll the screen up
|
||||
cpy #24
|
||||
beq screen_grow_logical_line_screen_up
|
||||
|
||||
// Do not grow line if already grown
|
||||
lda LDTB1+1, y
|
||||
bpl screen_grow_logical_line_done
|
||||
|
||||
// Preserve SAL and EAL
|
||||
|
||||
jsr screen_preserve_sal_eal
|
||||
|
||||
// Scroll LDTB1 down (start from the end)
|
||||
ldy #23
|
||||
!:
|
||||
cpy TBLX
|
||||
beq !+
|
||||
bcc !+
|
||||
|
||||
lda LDTB1+0, y
|
||||
sta LDTB1+1, y
|
||||
|
||||
dey
|
||||
bne !-
|
||||
!:
|
||||
// Mark current line as grown
|
||||
ldy TBLX
|
||||
lda #$00
|
||||
sta LDTB1+1, y
|
||||
|
||||
// Now we have to scroll lines downwards to make space. We start from the end,
|
||||
// and work backwards. We cannot be as simple and efficient here as we are
|
||||
// for scrolling up, because we do not know how much must be scrolled.
|
||||
|
||||
// Work out how many physical lines to scroll down
|
||||
|
||||
lda #23
|
||||
sec
|
||||
sbc TBLX
|
||||
beq screen_grow_logical_line_copy_done // branch if no need to copyy
|
||||
tax
|
||||
|
||||
// Prepare initial SAL/EAL/PNT/USER values
|
||||
|
||||
lda HIBASE
|
||||
clc
|
||||
adc #3
|
||||
sta SAL+1
|
||||
sta EAL+1
|
||||
|
||||
lda #>$DB00 // 3rd page of the color memory
|
||||
sta PNT+1
|
||||
sta USER+1
|
||||
|
||||
lda #<$03C0 // start of destination row
|
||||
sta EAL+0
|
||||
sta USER+0
|
||||
lda #<$0398 // start of source row
|
||||
sta SAL+0
|
||||
sta PNT+0
|
||||
|
||||
screen_grow_logical_line_loop:
|
||||
|
||||
// Scroll down one line each loop iteration
|
||||
|
||||
ldy #39
|
||||
!:
|
||||
lda (SAL), y
|
||||
sta (EAL), y
|
||||
lda (PNT), y
|
||||
sta (USER), y
|
||||
dey
|
||||
bpl !-
|
||||
|
||||
// Decrement SAL/PNT pointers by 40 (optimized due to fact they share LSB)
|
||||
|
||||
lda SAL+0
|
||||
sec
|
||||
sbc #40
|
||||
sta SAL+0
|
||||
sta PNT+0
|
||||
bcs !+
|
||||
dec SAL+1
|
||||
dec PNT+1
|
||||
!:
|
||||
// Decrement EAL/USER pointers by 40 (optimized due to fact they share LSB)
|
||||
|
||||
lda EAL+0
|
||||
sec
|
||||
sbc #40
|
||||
sta EAL+0
|
||||
sta USER+0
|
||||
bcs !+
|
||||
dec EAL+1
|
||||
dec USER+1
|
||||
!:
|
||||
// Next loop iteration
|
||||
|
||||
dex
|
||||
bne screen_grow_logical_line_loop
|
||||
|
||||
screen_grow_logical_line_copy_done:
|
||||
|
||||
// Restore SAL and EAL
|
||||
|
||||
jsr screen_restore_sal_eal
|
||||
|
||||
// Erase newly inserted line and quit
|
||||
|
||||
ldx TBLX
|
||||
inx
|
||||
jsr screen_clear_line
|
||||
jmp screen_calculate_PNTR_LNMX
|
||||
@@ -0,0 +1,32 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper routine to blank screen
|
||||
//
|
||||
|
||||
|
||||
#if ((CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) && !CONFIG_MB_MEGA_65) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K)
|
||||
|
||||
|
||||
screen_off:
|
||||
|
||||
lda VIC_SCROLY
|
||||
and #($FF - $10)
|
||||
sta VIC_SCROLY
|
||||
|
||||
// To be sure there are no badlines we have to wait till the next screen,
|
||||
// as the bit is checked by VIC-II at the start of the frame only
|
||||
!:
|
||||
lda VIC_SCROLY // wait for higher part of screen
|
||||
bpl !-
|
||||
!:
|
||||
lda VIC_SCROLY // wait for lower part of the screen
|
||||
bmi !-
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper routine to show screen
|
||||
//
|
||||
|
||||
|
||||
#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) && !CONFIG_MB_MEGA_65
|
||||
|
||||
|
||||
screen_on:
|
||||
|
||||
lda VIC_SCROLY
|
||||
ora #$10
|
||||
sta VIC_SCROLY
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_preserve_sal_eal:
|
||||
|
||||
plx_trash_a
|
||||
ply_trash_a
|
||||
|
||||
// Note: While the following routine is obvious to any skilled
|
||||
// in the art as the most obvious simple and efficient solution,
|
||||
// it results in a relatively long verbatim stretch of bytes when
|
||||
// compared to the C64 KERNAL. Thus we have swapped the order,
|
||||
// just to reduce the potential for any argument of copyright
|
||||
// infringement, even though we really do not believe that the
|
||||
// routine can be copyrighted due to the lack of creativity.
|
||||
|
||||
lda SAL+0
|
||||
pha
|
||||
lda EAL+0
|
||||
pha
|
||||
lda SAL+1
|
||||
pha
|
||||
lda EAL+1
|
||||
pha
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
screen_common_sal_eal:
|
||||
|
||||
phy_trash_a
|
||||
phx_trash_a
|
||||
rts
|
||||
@@ -0,0 +1,30 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
screen_restore_sal_eal:
|
||||
|
||||
plx_trash_a
|
||||
ply_trash_a
|
||||
|
||||
// Note: While the following routine is obvious to any skilled
|
||||
// in the art as the most obvious simple and efficient solution,
|
||||
// it results in a relatively long verbatim stretch of bytes when
|
||||
// compared to the C64 KERNAL. Thus we have swapped the order,
|
||||
// just to reduce the potential for any argument of copyright
|
||||
// infringement, even though we really do not believe that the
|
||||
// routine can be copyrighted due to the lack of creativity.
|
||||
|
||||
pla
|
||||
sta EAL+1
|
||||
pla
|
||||
sta SAL+1
|
||||
pla
|
||||
sta EAL+0
|
||||
pla
|
||||
sta SAL+0
|
||||
|
||||
jmp screen_common_sal_eal
|
||||
|
||||
Reference in new issue
Block a user