moved most of the LIST command to Mega65 extra ROM
This commit is contained in:
1 parent
1665098ac9
commit
ebf8bf4eb7
12 files changed
+165
-113
No files matched your search
@@ -0,0 +1,127 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# M65 * #TAKE
|
||||
// #LAYOUT# X16 BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
list_single_line:
|
||||
|
||||
#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0)
|
||||
|
||||
jsr map_BASIC_1
|
||||
jsr_ind VB1__list_single_line
|
||||
jmp map_NORMAL
|
||||
|
||||
#else
|
||||
|
||||
// Print line number
|
||||
ldy #3
|
||||
|
||||
#if ROM_LAYOUT_M65 || CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
pha
|
||||
dey
|
||||
|
||||
#if ROM_LAYOUT_M65 || CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
tax
|
||||
pla
|
||||
jsr print_integer
|
||||
jsr print_space
|
||||
|
||||
// Iterate through printing out the line
|
||||
// contents
|
||||
lda #0
|
||||
sta QTSW
|
||||
|
||||
ldy #4
|
||||
list_print_loop:
|
||||
|
||||
#if ROM_LAYOUT_M65 || CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#else
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
beq list_end_of_line
|
||||
cmp #$22
|
||||
bne list_not_quote
|
||||
lda QTSW
|
||||
eor #$FF
|
||||
sta QTSW
|
||||
lda #$22
|
||||
jmp list_is_literal
|
||||
|
||||
list_not_quote:
|
||||
// Check quote mode, and display as literal if required
|
||||
ldx QTSW
|
||||
bne list_is_literal
|
||||
|
||||
cmp #$FF
|
||||
beq list_is_pi
|
||||
|
||||
cmp #$7F
|
||||
bcc list_is_literal
|
||||
|
||||
// Display a token
|
||||
|
||||
// Save registers
|
||||
tax
|
||||
pha
|
||||
phy_trash_a
|
||||
|
||||
// Get pointer to compressed keyword list
|
||||
lda #<packed_keywords
|
||||
sta FRESPC+0
|
||||
lda #>packed_keywords
|
||||
sta FRESPC+1
|
||||
|
||||
// Subtract $80 from token to get offset in word
|
||||
// list
|
||||
txa
|
||||
and #$7f
|
||||
tax
|
||||
|
||||
// Now ask for it to be printed
|
||||
ldy #$ff
|
||||
jsr packed_word_search
|
||||
|
||||
ply_trash_a
|
||||
pla
|
||||
|
||||
cmp #$8f
|
||||
bne list_not_rem
|
||||
// REM command locks quote flag on until the end of the line, allowing
|
||||
// funny characters in REM statements without problem.
|
||||
sta QTSW // Any value other than $00 or $FF will lock quote mode on, so the token value of REM is fine here
|
||||
// FALL THROUGH
|
||||
list_not_rem:
|
||||
|
||||
iny
|
||||
bne list_print_loop // branch always
|
||||
|
||||
list_is_pi:
|
||||
lda #$7E
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
list_is_literal:
|
||||
jsr JCHROUT
|
||||
iny
|
||||
bne list_print_loop
|
||||
|
||||
list_end_of_line:
|
||||
// Print end of line
|
||||
jmp print_return
|
||||
|
||||
|
||||
#endif // ROM layout
|
||||
@@ -0,0 +1,148 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// Works similar to $BDCD in original C64 BASIC
|
||||
// XXX Should eventually get replaced by a more flexible and optimal routine.
|
||||
// Temp result gets written to $0100-$0104
|
||||
|
||||
print_integer:
|
||||
|
||||
pha
|
||||
phx_trash_a
|
||||
|
||||
// Clear temporary output
|
||||
lda #$00
|
||||
ldy #5
|
||||
!: sta $0100,y
|
||||
dey
|
||||
bpl !-
|
||||
|
||||
pla
|
||||
ldy #23 // 8 x 3 - 1 = offset of last digit of 128
|
||||
lo_loop:
|
||||
cmp #$7f
|
||||
bcc bit_clear
|
||||
|
||||
// Bit set, so add the digits
|
||||
pha
|
||||
ldx #2
|
||||
clc
|
||||
lo_add_loop:
|
||||
lda $0102,x
|
||||
adc number_table_lo,y
|
||||
sta $0102,x
|
||||
|
||||
dey
|
||||
dex
|
||||
bpl lo_add_loop
|
||||
pla
|
||||
jmp next_lo_bit
|
||||
|
||||
bit_clear:
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
next_lo_bit:
|
||||
asl
|
||||
cpy #$7f
|
||||
bcc lo_loop
|
||||
|
||||
|
||||
// Now do the same for upper byte
|
||||
pla
|
||||
|
||||
ldy #39 // 8 x 5 - 1 = offset of last digit of 32768
|
||||
hi_loop:
|
||||
cmp #$7f
|
||||
bcc bit_clear_hi
|
||||
|
||||
|
||||
// Bit set, so add the digits
|
||||
pha
|
||||
ldx #4
|
||||
clc
|
||||
hi_add_loop:
|
||||
lda $0100,x
|
||||
adc number_table_hi,y
|
||||
sta $0100,x
|
||||
|
||||
dey
|
||||
dex
|
||||
bpl hi_add_loop
|
||||
pla
|
||||
jmp next_hi_bit
|
||||
|
||||
bit_clear_hi:
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
next_hi_bit:
|
||||
asl
|
||||
cpy #$7f
|
||||
bcc hi_loop
|
||||
|
||||
fix_carry:
|
||||
|
||||
// Deal with any carries
|
||||
ldx #3
|
||||
carry_fix_loop:
|
||||
lda $0101,x
|
||||
cmp #10
|
||||
bcc !+
|
||||
inc $0100,x
|
||||
sec
|
||||
sbc #10
|
||||
sta $0101,x
|
||||
|
||||
jmp carry_fix_loop
|
||||
|
||||
!: dex
|
||||
bpl carry_fix_loop
|
||||
|
||||
post_carry:
|
||||
|
||||
// Got digits.
|
||||
// Skip leading zeros, and print the resulting number
|
||||
|
||||
// Skip leading zeros
|
||||
ldy #0
|
||||
!: lda $0100,y
|
||||
bne found_start_of_number
|
||||
iny
|
||||
cpy #4
|
||||
bne !-
|
||||
|
||||
found_start_of_number:
|
||||
// Print digits
|
||||
!: lda $0100,y
|
||||
ora #$30
|
||||
jsr JCHROUT
|
||||
iny
|
||||
cpy #5
|
||||
bne !-
|
||||
|
||||
|
||||
rts
|
||||
|
||||
|
||||
number_table_lo:
|
||||
.byte 0,0,1
|
||||
.byte 0,0,2
|
||||
.byte 0,0,4
|
||||
.byte 0,0,8
|
||||
.byte 0,1,6
|
||||
.byte 0,3,2
|
||||
.byte 0,6,4
|
||||
.byte 1,2,8
|
||||
number_table_hi:
|
||||
.byte 0,0,2,5,6
|
||||
.byte 0,0,5,1,2
|
||||
.byte 0,1,0,2,4
|
||||
.byte 0,2,0,4,8
|
||||
.byte 0,4,0,9,6
|
||||
.byte 0,8,1,9,2
|
||||
.byte 1,6,3,8,4
|
||||
.byte 3,2,7,6,8
|
||||
@@ -0,0 +1,232 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// This routine prints messages that have been packed
|
||||
// using the make_error_tables program.
|
||||
// The general idea is to save space in the ROM.
|
||||
|
||||
// The output of make_error_tables is written to packed_messages.s, and
|
||||
// contains the following:
|
||||
//
|
||||
// packed_message_words - List of nybl packed words.
|
||||
// packed_message_tokens - List of tokens that get joined to make messages
|
||||
// packed_message_chars - List of characters in messages sorted by frequency.
|
||||
|
||||
|
||||
print_packed_message:
|
||||
// .X = message number
|
||||
|
||||
lda #$ff
|
||||
ldy #$ff
|
||||
packed_message_search:
|
||||
iny
|
||||
cpx #$00
|
||||
beq found_message_in_token_stream
|
||||
lda packed_message_tokens,y
|
||||
cmp #$ff
|
||||
bne !+
|
||||
dex
|
||||
!:
|
||||
cpy #$ff
|
||||
bne packed_message_search
|
||||
// Could not find message
|
||||
sec
|
||||
rts
|
||||
|
||||
found_message_in_token_stream: // XXX size-optimize this
|
||||
// Now print each word in the message
|
||||
phy_trash_a
|
||||
lda packed_message_tokens,y
|
||||
cmp #$FF
|
||||
beq found_message_in_token_stream_done
|
||||
|
||||
jsr print_packed_word
|
||||
ply_trash_a
|
||||
iny
|
||||
beq found_message_in_token_stream_done
|
||||
!:
|
||||
phy_trash_a
|
||||
lda packed_message_tokens,y
|
||||
cmp #$FF
|
||||
beq found_message_in_token_stream_done
|
||||
|
||||
pha
|
||||
jsr print_space
|
||||
pla
|
||||
|
||||
jsr print_packed_word
|
||||
ply_trash_a
|
||||
iny
|
||||
bne !-
|
||||
|
||||
found_message_in_token_stream_done:
|
||||
pla
|
||||
rts
|
||||
|
||||
print_packed_word:
|
||||
// A = the word to print
|
||||
tax
|
||||
|
||||
// Setup pointer to packed words
|
||||
lda #<packed_message_words
|
||||
sta FRESPC+0
|
||||
lda #>packed_message_words
|
||||
sta FRESPC+1
|
||||
|
||||
// Find the word in the list
|
||||
ldy #$ff
|
||||
packed_word_search:
|
||||
iny
|
||||
cpx #$00
|
||||
beq found_packed_word
|
||||
|
||||
// $x0 is an end of work marker
|
||||
lda (FRESPC),y
|
||||
and #$0f
|
||||
cmp #$00
|
||||
bne !+
|
||||
dex
|
||||
!:
|
||||
// $FE $xx is an end of work marker
|
||||
lda (FRESPC),y
|
||||
cmp #$fe
|
||||
bne !+
|
||||
dex
|
||||
iny // skip next byte
|
||||
!:
|
||||
cmp #$ff
|
||||
bne !+
|
||||
iny // skip next byte
|
||||
!:
|
||||
|
||||
// Advance to next page if required
|
||||
cpy #$ff
|
||||
bne packed_word_search
|
||||
inc FRESPC+1
|
||||
jmp packed_word_search
|
||||
|
||||
found_packed_word:
|
||||
|
||||
// Get pointer to start of packed word
|
||||
// Make sure we do not wrap on a page boundary
|
||||
tya
|
||||
clc
|
||||
adc FRESPC+0
|
||||
sta FRESPC+0
|
||||
lda FRESPC+1
|
||||
adc #$00
|
||||
sta FRESPC+1
|
||||
|
||||
print_packed_string:
|
||||
ldy #$ff
|
||||
|
||||
next_packed_word_char:
|
||||
// .Y = offset into packed word data - 1
|
||||
iny
|
||||
|
||||
// Check for end of word
|
||||
lda (FRESPC),y
|
||||
cmp #$00
|
||||
beq end_of_packed_word
|
||||
cmp #$fe
|
||||
beq last_literal
|
||||
cmp #$ff
|
||||
beq next_is_literal_char
|
||||
and #$f0
|
||||
beq end_of_packed_word
|
||||
|
||||
// Check if it is an uncommon char
|
||||
lda (FRESPC),y
|
||||
and #$f0
|
||||
cmp #$f0
|
||||
beq is_uncommon_char
|
||||
|
||||
// Is not an uncommon char, so get char of upper nybl
|
||||
lda (FRESPC),y
|
||||
|
||||
// Put high nybl into low bits of X
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tax
|
||||
|
||||
// X=1-14 = first 14 chars, so subtract one
|
||||
lda packed_message_chars-1,x
|
||||
jsr JCHROUT // preserves .Y
|
||||
|
||||
// See if there is a char in the low nybl to print
|
||||
lda (FRESPC),y
|
||||
and #$0f
|
||||
beq end_of_packed_word
|
||||
cmp #$0f
|
||||
beq no_lo_nybl_char
|
||||
|
||||
has_lo_nybl_char:
|
||||
// We need to print the low nybl char as well
|
||||
tax
|
||||
phy_trash_a
|
||||
|
||||
// Skip lower nybls of $F or $0 in nybl packed
|
||||
// bytes, as these do not encode characters
|
||||
cpx #$f
|
||||
beq !+
|
||||
has_nybl:
|
||||
cpx #0
|
||||
beq !+
|
||||
|
||||
// X=1-14 = first 14 chars, so subtract one
|
||||
lda packed_message_chars-1,x
|
||||
jsr JCHROUT
|
||||
!:
|
||||
ply_trash_a
|
||||
// FALLTHROUGH
|
||||
|
||||
no_lo_nybl_char:
|
||||
|
||||
// If current byte has $0F in low nybl, then the next
|
||||
// byte is a whole byte.
|
||||
lda (FRESPC),y
|
||||
and #$0f
|
||||
cmp #$0f
|
||||
beq next_is_literal_char
|
||||
|
||||
ready_for_next_char:
|
||||
cpy #$ff
|
||||
bne next_packed_word_char
|
||||
end_of_packed_word:
|
||||
// Hit end of packed data
|
||||
rts
|
||||
|
||||
last_literal:
|
||||
jsr unpack_literal_char
|
||||
rts
|
||||
|
||||
next_is_literal_char:
|
||||
jsr unpack_literal_char
|
||||
jmp ready_for_next_char
|
||||
|
||||
unpack_literal_char:
|
||||
// Output the literal char, and ready for next char
|
||||
iny
|
||||
phy_trash_a
|
||||
lda (FRESPC),y
|
||||
jsr JCHROUT
|
||||
pla
|
||||
tay
|
||||
rts
|
||||
|
||||
is_uncommon_char:
|
||||
// Lower nybl has offset into low-frequency part of the table
|
||||
|
||||
lda (FRESPC),y
|
||||
and #$0f
|
||||
clc
|
||||
adc #14
|
||||
|
||||
// We need to print the low nybl char as well
|
||||
tax
|
||||
phy_trash_a
|
||||
|
||||
jmp has_nybl
|
||||
Reference in new issue
Block a user