reorganized extended BASIC tokens

This commit is contained in:
FeralChild64 committed 2020-10-24 09:08:57 +02:00
1 parent f2b7abfdb9
commit 678c38a3e0
47 files changed
+235 -260

No files matched your search

-12
View File
@@ -1,12 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# CRT BASIC_1 #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
!ifndef HAS_SMALL_BASIC {
packed_freq_keywords_02:
+PUT_PACKED_FREQ_keywords_02
}
-13
View File
@@ -1,13 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# CRT BASIC_1 #TAKE
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
!ifdef CONFIG_MB_M65 {
packed_freq_keywords_03:
+PUT_PACKED_FREQ_keywords_03
}
+7
View File
@@ -0,0 +1,7 @@
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# * * #IGNORE
packed_freq_keywords_04:
+PUT_PACKED_FREQ_keywords_04
+7
View File
@@ -0,0 +1,7 @@
;; #LAYOUT# M65 BASIC_1 #TAKE
;; #LAYOUT# * * #IGNORE
packed_freq_keywords_06:
+PUT_PACKED_FREQ_keywords_06
+28 -14
View File
@@ -6,33 +6,42 @@
; Jumptable for BASIC commands with tokens prefixed by $01
;
!set ITEM_01 = cmd_slow
!set ITEM_02 = cmd_fast
!set ITEM_03 = cmd_old
!set ITEM_00 = cmd_slow
!set ITEM_01 = cmd_fast
!set ITEM_02 = cmd_old
!ifndef HAS_SMALL_BASIC {
; NOTE! These commands are temporarily placed here, they should be a part of list 02!
!set ITEM_04 = cmd_clear
!set ITEM_05 = varstr_garbage_collect ; cmd_dispose
!set ITEM_06 = cmd_merge
!set ITEM_07 = cmd_bload
!set ITEM_08 = cmd_bsave
!set ITEM_09 = cmd_bverify
!set ITEM_0A = cmd_cold
!set ITEM_0B = cmd_mem
!set ITEM_03 = cmd_merge
}
!set ITEM_04 = cmd_bload
!set ITEM_05 = cmd_bsave
!set ITEM_06 = cmd_bverify
!set ITEM_07 = cmd_clear
!set ITEM_08 = varstr_garbage_collect ; cmd_dispose
!ifndef HAS_OPCODES_65C02 {
command_01_jumptable_lo:
!byte <(ITEM_00-1), <(ITEM_01-1), <(ITEM_02-1), <(ITEM_03-1), <(ITEM_04-1), <(ITEM_05-1), <(ITEM_06-1), <(ITEM_07-1), <(ITEM_08-1)
!byte <(ITEM_01-1), <(ITEM_02-1), <(ITEM_03-1)
!ifndef HAS_SMALL_BASIC {
!byte <(ITEM_04-1), <(ITEM_05-1), <(ITEM_06-1), <(ITEM_07-4), <(ITEM_08-1), <(ITEM_09-1), <(ITEM_0A-1), <(ITEM_0B-1)
}
command_01_jumptable_hi:
!byte >(ITEM_00-1), >(ITEM_01-1), >(ITEM_02-1), >(ITEM_03-1), >(ITEM_04-1), >(ITEM_05-1), >(ITEM_06-1), >(ITEM_07-1), >(ITEM_08-1)
!byte >(ITEM_01-1), >(ITEM_02-1), >(ITEM_03-1)
!ifndef HAS_SMALL_BASIC {
!byte >(ITEM_04-1), >(ITEM_05-1), >(ITEM_06-1), >(ITEM_07-4), >(ITEM_08-1), >(ITEM_09-1), >(ITEM_0A-1), >(ITEM_0B-1)
}
} else { ; HAS_OPCODES_65C02
@@ -40,5 +49,10 @@ command_01_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_00, ITEM_01, ITEM_02, ITEM_03, ITEM_04, ITEM_05, ITEM_06, ITEM_07, ITEM_08
!word ITEM_01, ITEM_02, ITEM_03
!ifndef HAS_SMALL_BASIC {
!word ITEM_04, ITEM_05, ITEM_06, ITEM_07, ITEM_08, ITEM_09, ITEM_0A, ITEM_0B
}
}
@@ -3,6 +3,8 @@
;; #LAYOUT# * * #IGNORE
!ifndef HAS_SMALL_BASIC {
cmd_bverify:
; LOAD and VERIFY are very similar, from BASIC perspective there is almost no difference;
@@ -40,3 +42,4 @@ cmd_bload:
; Execute next statement
rts
}
@@ -3,6 +3,8 @@
;; #LAYOUT# * * #IGNORE
!ifndef HAS_SMALL_BASIC {
cmd_bsave:
; Set default device and secondary address
@@ -40,3 +42,4 @@ cmd_bsave:
; Perform SAVE - reuse regular command
jmp cmd_save_do
}
@@ -3,8 +3,11 @@
;; #LAYOUT# * * #IGNORE
!ifndef HAS_SMALL_BASIC {
cmd_clear:
; XXX in the future add separate implementation for graphics screen
jmp clear_screen
}
File renamed without changes.
@@ -3,6 +3,8 @@
;; #LAYOUT# * * #IGNORE
!ifndef HAS_SMALL_BASIC {
cmd_merge:
lda #$00 ; mark operation as LOAD
@@ -45,3 +47,4 @@ cmd_merge_no_error:
; Relink loaded program, clear variables, execute next statement
jmp update_LINKPRG_VARTAB_do_clr
}
@@ -7,6 +7,8 @@
;
!ifndef HAS_SMALL_BASIC {
helper_bload_fetch_address:
jsr injest_comma
@@ -20,3 +22,4 @@ helper_bload_fetch_address:
ldy LINNUM+1
rts
}
@@ -7,6 +7,8 @@
;
!ifndef HAS_SMALL_BASIC {
helper_bload_fetch_filename:
; Fetch the file name
@@ -24,3 +26,4 @@ helper_bload_fetch_filename:
sta FNLEN
@1:
rts
}
@@ -1,49 +0,0 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Jumptable for BASIC commands with tokens prefixed by $02
;
!ifndef HAS_SMALL_BASIC {
; NOTE! These commands are temporarily placed in list 01!
; cmd_merge,
; cmd_bload,
; cmd_bsave,
; cmd_bverify,
; cmd_clear,
; varstr_garbage_collect, ; cmd_dispose
!set ITEM_00 = cmd_cold
!set ITEM_01 = cmd_mem
!ifdef CONFIG_MB_M65 {
!set ITEM_02 = cmd_sysinfo
}
!ifndef HAS_OPCODES_65C02 {
command_02_jumptable_lo:
!byte <(ITEM_00-1), <(ITEM_01-1)
!ifdef CONFIG_MB_M65 { !byte <(ITEM_02-1) }
command_02_jumptable_hi:
!byte >(ITEM_00-1), >(ITEM_01-1)
!ifdef CONFIG_MB_M65 { !byte >(ITEM_02-1) }
} else { ; HAS_OPCODES_65C02
command_02_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_00, ITEM_01
!ifdef CONFIG_MB_M65 { !word ITEM_02 }
} }
@@ -1,15 +0,0 @@
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Jumptable for BASIC commands with tokens prefixed by $03
;
!set ITEM_00 = cmd_rem ; XXX just for testing
command_03_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_00
@@ -0,0 +1,29 @@
;; #LAYOUT# M65 * #TAKE
;; #LAYOUT# * * #IGNORE
;
; Jumptable for BASIC commands with tokens prefixed by $04
;
!set ITEM_01 = cmd_sysinfo
!ifndef HAS_OPCODES_65C02 {
command_04_jumptable_lo:
!byte <(ITEM_01-1)
command_04_jumptable_hi:
!byte >(ITEM_01-1)
} else { ; HAS_OPCODES_65C02
command_04_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_01
}
@@ -0,0 +1,28 @@
;; #LAYOUT# M65 BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
;
; Jumptable for BASIC commands with tokens prefixed by $03
;
!set ITEM_01 = do_NOT_IMPLEMENTED_error ; just for testing
!ifndef HAS_OPCODES_65C02 {
function_06_jumptable_lo:
!byte <(ITEM_01-1)
function_06_jumptable_hi:
!byte >(ITEM_01-1)
} else { ; HAS_OPCODES_65C02
function_06_jumptable:
; Note: 65C02 has the page boundary vector bug fixed!
!word ITEM_01
}
+15 -23
View File
@@ -92,26 +92,23 @@ tokenise_line_loop:
jsr tk_search
bcc tokenise_line_keyword_01 ; branch if keyword identified
!ifndef HAS_SMALL_BASIC {
lda #<packed_freq_keywords_02
sta FRESPC+0
lda #>packed_freq_keywords_02
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_02 ; branch if keyword identified
}
!ifdef CONFIG_MB_M65 {
lda #<packed_freq_keywords_03
lda #<packed_freq_keywords_04
sta FRESPC+0
lda #>packed_freq_keywords_03
lda #>packed_freq_keywords_04
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_03 ; branch if keyword identified
bcc tokenise_line_keyword_04 ; branch if keyword identified
lda #<packed_freq_keywords_06
sta FRESPC+0
lda #>packed_freq_keywords_06
sta FRESPC+1
jsr tk_search
bcc tokenise_line_keyword_06 ; branch if keyword identified
}
; Shorten packed keyword candidate and try again
@@ -189,23 +186,18 @@ tokenise_line_char:
!ifdef CONFIG_MB_M65 {
tokenise_line_keyword_03:
tokenise_line_keyword_04:
; Store the token list index
lda #$03
lda #$04
+skip_2_bytes_trash_nvz
; FALLTROUGH
}
!ifndef HAS_SMALL_BASIC {
tokenise_line_keyword_02:
tokenise_line_keyword_06:
; Store the token list index
lda #$02
lda #$06
+skip_2_bytes_trash_nvz
; FALLTROUGH
@@ -39,23 +39,19 @@ execute_statements:
; Check if token is valid for execution
!ifdef HAS_SMALL_BASIC {
!ifndef CONFIG_MB_M65 {
cpx #$01
beq execute_statements_01
} else {
!ifdef CONFIG_MB_M65 {
cpx #$04
} else {
cpx #$03
}
cpx #$05
bcc execute_statements_extended
}
cpx #$CB
+beq cmd_go ; 'GO' command has a strange token, placed after function tokens
+beq cmd_go ; 'GO' command has a strange token, placed after function tokens
cpx #$7F
+bcc execute_statements_var_assign ; not a token - try variable assign
@@ -84,25 +80,17 @@ execute_statements:
jmp (command_jumptable, x)
}
!ifndef HAS_SMALL_BASIC {
!ifdef CONFIG_MB_M65 {
execute_statements_extended:
; Support for extended BASIC commands
; XXX consider jumpable here
cpx #$01
beq execute_statements_01
cpx #$02
beq execute_statements_02
!ifdef CONGIH_MB_M65 {
cpx #$03
beq execute_statements_03
}
cpx #$04
beq execute_statements_04
jmp do_SYNTAX_error
}
@@ -141,9 +129,9 @@ execute_statements_01:
jmp (command_01_jumptable - 2, x)
}
!ifndef HAS_SMALL_BASIC {
!ifdef CONFIG_MB_M65 {
execute_statements_02:
execute_statements_04:
; Get the sub-token, check that it is valid
@@ -151,7 +139,7 @@ execute_statements_02:
cmp #$00
+beq do_SYNTAX_error
cmp #(TK__MAXTOKEN_keywords_02+1)
cmp #(TK__MAXTOKEN_keywords_04+1)
+bcs do_SYNTAX_error
; Execute command
@@ -161,9 +149,9 @@ execute_statements_02:
; Get the jump table entry for it, push it on the stack, and then RTS to start it.
tax
lda command_02_jumptable_hi - 1, x
lda command_04_jumptable_hi - 1, x
pha
lda command_02_jumptable_lo - 1, x
lda command_04_jumptable_lo - 1, x
pha
rts
@@ -174,31 +162,10 @@ execute_statements_02:
asl
tax
jmp (command_02_jumptable - 2, x)
jmp (command_04_jumptable - 2, x)
}
} ; !HAS_SMALL_BASIC
!ifdef CONFIG_MB_M65 {
execute_statements_03:
; Get the sub-token, check that it is valid
jsr fetch_character
cmp #$00
+beq do_SYNTAX_error
cmp #(TK__MAXTOKEN_keywords_03+1)
+bcs do_SYNTAX_error
; Use jumptable to go to the command routine
asl
tax
jmp (command_03_jumptable - 2, x)
} ; CONFIG_MB_M65
}
execute_statements_end_of_line:
+21 -26
View File
@@ -104,13 +104,11 @@ list_not_quote:
; Check for extended BASIC tokens
cmp #$01
beq list_display_token_01
!ifndef HAS_SMALL_BASIC {
cmp #$02
beq list_display_token_02
}
!ifdef CONFIG_MB_M65 {
cmp #$03
beq list_display_token_03
cmp #$04
beq list_display_token_04
cmp #$06
beq list_display_token_06
}
; Check for literals
@@ -232,37 +230,34 @@ list_display_token_ext_done:
; Next iteration
+bra list_not_rem
!ifndef HAS_SMALL_BASIC {
list_display_token_02:
; Display a 2-byte token - for extended BASIC
jsr list_fetch_subtoken
; Check if token is known
cpx #TK__MAXTOKEN_keywords_02
bcs list_is_unknown
; Now ask for it to be printed
+phy_trash_a
jsr print_packed_keyword_02
+bra list_display_token_ext_done
}
!ifdef CONFIG_MB_M65 {
list_display_token_03:
list_display_token_04:
; Display a 2-byte token - for extended BASIC
jsr list_fetch_subtoken
; Check if token is known
cpx #TK__MAXTOKEN_keywords_03
cpx #TK__MAXTOKEN_keywords_04
bcs list_is_unknown
; Now ask for it to be printed
+phy_trash_a
jsr print_packed_keyword_03
jsr print_packed_keyword_04
+bra list_display_token_ext_done
list_display_token_06:
; Display a 2-byte token - for extended BASIC
jsr list_fetch_subtoken
; Check if token is known
cpx #TK__MAXTOKEN_keywords_06
bcs list_is_unknown
; Now ask for it to be printed
+phy_trash_a
jsr print_packed_keyword_06
+bra list_display_token_ext_done
}
+9 -12
View File
@@ -59,21 +59,18 @@ print_packed_keyword_01: ; .X - token number
ldy #>packed_freq_keywords_01
bne print_freq_packed_string ; branch always
!ifndef HAS_SMALL_BASIC {
print_packed_keyword_02: ; .X - token number
lda #<packed_freq_keywords_02
ldy #>packed_freq_keywords_02
bne print_freq_packed_string ; branch always
}
!ifdef CONFIG_MB_M65 {
print_packed_keyword_03: ; .X - token number
print_packed_keyword_04: ; .X - token number
lda #<packed_freq_keywords_03
ldy #>packed_freq_keywords_03
lda #<packed_freq_keywords_04
ldy #>packed_freq_keywords_04
bne print_freq_packed_string ; branch always
print_packed_keyword_06: ; .X - token number
lda #<packed_freq_keywords_06
ldy #>packed_freq_keywords_06
bne print_freq_packed_string ; branch always
}
+8
View File
@@ -19,8 +19,12 @@ wedge_tape:
cmp #$4C ; 'L'
beq wedge_arrow_L
!ifndef HAS_SMALL_BASIC {
cmp #$4D ; 'M'
beq wedge_arrow_M
}
!ifdef CONFIG_TAPE_HEAD_ALIGN {
@@ -68,6 +72,9 @@ wedge_arrow_L:
jmp cmd_load_got_params
!ifndef HAS_SMALL_BASIC {
wedge_arrow_M:
jsr wedge_tape_prepare_load
@@ -77,5 +84,6 @@ wedge_arrow_M:
; Perform merging
jmp cmd_merge_got_params
}
} ; CONFIG_TAPE_WEDGE