added panic screen, added versioning mechanism proposal
This commit is contained in:
1 parent
890558213a
commit
5a231c1847
40 files changed
+363
-182
No files matched your search
@@ -0,0 +1,22 @@
|
||||
cmd_stop:
|
||||
ldx #30 // "BREAK"
|
||||
jsr print_packed_message
|
||||
|
||||
// Are we in direct mode
|
||||
lda CURLIN+1
|
||||
cmp #$FF
|
||||
beq !+
|
||||
|
||||
// Not direct mode
|
||||
ldx #31
|
||||
jsr print_packed_message
|
||||
|
||||
lda CURLIN+1
|
||||
ldx CURLIN+0
|
||||
jsr print_integer
|
||||
|
||||
!:
|
||||
jsr print_return
|
||||
|
||||
cmd_end:
|
||||
jmp basic_main_loop
|
||||
@@ -0,0 +1,150 @@
|
||||
// LIST basic text.
|
||||
// XXX - Doesn't currently support line number ranges
|
||||
|
||||
cmd_list:
|
||||
|
||||
// Set current line pointer to start of memory
|
||||
jsr init_oldtxt
|
||||
|
||||
list_loop:
|
||||
|
||||
ldy #1
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT+0
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
bne list_more_lines
|
||||
|
||||
// LIST terminates any running program,
|
||||
// because it has fiddled with the current line pointer.
|
||||
// (Confirmed by testing on a C64)
|
||||
jmp basic_main_loop
|
||||
|
||||
list_more_lines:
|
||||
lda STKEY
|
||||
bmi !+
|
||||
jmp cmd_stop
|
||||
!:
|
||||
jsr list_single_line
|
||||
// Now link to the next line
|
||||
jsr basic_find_next_line
|
||||
jmp list_loop
|
||||
|
||||
list_single_line: // entry point needed by DOS wedge
|
||||
// Print line number
|
||||
ldy #3
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (OLDTXT),y
|
||||
#endif
|
||||
|
||||
pha
|
||||
dey
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
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 CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<OLDTXT
|
||||
jsr peek_under_roms
|
||||
cmp #$00
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
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.
|
||||
inc $0427
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
cmd_load:
|
||||
|
||||
// Parse filename
|
||||
// (we can tell the KERNAL where it is in memory directly, since the
|
||||
// KERNAL will be able to peek under ROMs to read it, since it will have
|
||||
// to be able to peek under the ROMs for SAVE and VERIFY).
|
||||
// Parse optional device #
|
||||
// Parse optional secondary address
|
||||
|
||||
// XXX - C64 BASIC apparently doesn't clear variables after a LOAD in the
|
||||
// middle of a program. For safety, we do.
|
||||
jsr basic_do_clr
|
||||
|
||||
// Set filename and length
|
||||
lda #$00
|
||||
sta FNLEN
|
||||
|
||||
// Without tape support, LOAD must have a filename
|
||||
// (This also skips any leading spaces)
|
||||
jsr basic_end_of_statement_check
|
||||
bcc !+
|
||||
jmp do_MISSING_FILENAME_error
|
||||
!:
|
||||
jsr basic_fetch_and_consume_character
|
||||
cmp #$22
|
||||
beq !+
|
||||
jmp do_SYNTAX_error
|
||||
!:
|
||||
// Filename starts here so set pointer
|
||||
lda TXTPTR+0
|
||||
sta FNADDR+0
|
||||
lda TXTPTR+1
|
||||
sta FNADDR+1
|
||||
|
||||
// Now search for end of line or closing quote
|
||||
// so that we know the length of the filename
|
||||
getting_filename:
|
||||
jsr basic_fetch_and_consume_character
|
||||
cmp #$22
|
||||
beq got_filename
|
||||
cmp #$00
|
||||
bne !+
|
||||
jsr basic_unconsume_character
|
||||
|
||||
jmp got_filename
|
||||
!:
|
||||
inc FNLEN
|
||||
jmp getting_filename
|
||||
|
||||
got_filename:
|
||||
|
||||
// Now fetch the file number, start from the default one
|
||||
jsr select_device
|
||||
stx FA
|
||||
jsr injest_comma
|
||||
bcs got_devicenumber
|
||||
|
||||
jsr basic_parse_line_number
|
||||
lda LINNUM+1
|
||||
beq !+
|
||||
jmp do_ILLEGAL_QUANTITY_error
|
||||
!:
|
||||
lda LINNUM+0
|
||||
sta FA
|
||||
|
||||
got_devicenumber:
|
||||
|
||||
// Now fetch the secondary address
|
||||
lda #$00
|
||||
sta SA
|
||||
jsr injest_comma
|
||||
bcs got_secondaryaddress
|
||||
jsr basic_parse_line_number
|
||||
lda LINNUM+1
|
||||
bne !+
|
||||
lda LINNUM+0
|
||||
sta SA
|
||||
jmp got_secondaryaddress
|
||||
!:
|
||||
// Second parameter is above 255, this can't be a secondary address
|
||||
// Use it as load address instead
|
||||
// XXX temporary syntax, it would be better to use something
|
||||
// XXX like 'LOAD"FILE",8 TO 49152'
|
||||
ldx LINNUM+0
|
||||
ldy LINNUM+1
|
||||
bne got_loadaddress
|
||||
|
||||
got_secondaryaddress:
|
||||
ldy TXTTAB+1
|
||||
ldx TXTTAB+0
|
||||
|
||||
got_loadaddress:
|
||||
lda #$00 // LOAD not verify
|
||||
jsr JLOAD
|
||||
php
|
||||
pha
|
||||
jsr print_return
|
||||
pla
|
||||
plp
|
||||
bcc !+
|
||||
|
||||
// A = KERNAL error code, which also almost match
|
||||
// basic ERROR codes, so we can just copy the
|
||||
// error code to X, decrement, and handle normally
|
||||
tax
|
||||
dex
|
||||
jmp do_basic_error
|
||||
|
||||
!:
|
||||
// $YYXX is the last loaded address, so store it
|
||||
stx VARTAB+0
|
||||
sty VARTAB+1
|
||||
|
||||
// Now relink the loaded program, as we cannot trust the line
|
||||
// links supplied. For example, the VICE virtual drive emulation
|
||||
// always supplies $0101 as the address of the next line.
|
||||
jsr LINKPRG
|
||||
|
||||
// After LOADing, we either start the program from the beginning,
|
||||
// or go back to the READY prompt if LOAD was called from direct mode.
|
||||
|
||||
// Reset to start of program
|
||||
jsr init_oldtxt
|
||||
|
||||
// XXX - should run program if LOAD was used in program mode
|
||||
jmp basic_main_loop
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
cmd_new:
|
||||
jsr basic_do_new
|
||||
|
||||
// NEW command terminates execution
|
||||
// (Confirmed on a C64)
|
||||
jmp basic_main_loop
|
||||
|
||||
cmd_clr:
|
||||
jsr basic_do_clr
|
||||
// CLR command does not stop execution
|
||||
// (Cconfirmed on a c64)
|
||||
jmp basic_execute_statement
|
||||
|
||||
basic_do_new:
|
||||
// Setup pointers to memory storage XXX should depend on text start vector
|
||||
lda #<$0801
|
||||
sta TXTTAB+0
|
||||
lda #>$0801
|
||||
sta TXTTAB+1
|
||||
sta VARTAB+1
|
||||
lda #<$0803
|
||||
sta VARTAB+0
|
||||
|
||||
// Zero line pointer
|
||||
// XXX - We should also zero $0800, i.e., TXTTAB - 1
|
||||
ldy #$00
|
||||
tya
|
||||
sta (TXTTAB),y
|
||||
iny
|
||||
sta (TXTTAB),y
|
||||
|
||||
|
||||
// Get top of memory.
|
||||
// If a cart is present, then it is $7FFF,
|
||||
// if not, then it is $F7FF, since we support having
|
||||
// programs and variables under ROM.
|
||||
// i.e., we support 56KB RAM for BASIC, keeping some space
|
||||
// free for some optimisation structures, e.g., FOR/NEXT loop
|
||||
// records (without them going on the stack), GOSUB stack
|
||||
// (same story), expression value cache?
|
||||
|
||||
sec // Read, not write value
|
||||
jsr JMEMTOP
|
||||
cpx #$80
|
||||
beq !+
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
lda #>$F7FF
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda #>$A000
|
||||
#endif
|
||||
.byte $2C
|
||||
!:
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
lda #>$F7FF
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda #>$A000
|
||||
#endif
|
||||
sta MEMSIZ+1
|
||||
sta FRETOP+1
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
lda #<$F7FF
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda #<$A000
|
||||
#endif
|
||||
sta MEMSIZ+0
|
||||
sta FRETOP+0
|
||||
|
||||
// FALL THROUGH
|
||||
|
||||
basic_do_clr:
|
||||
// Clear variables, arrays and strings
|
||||
lda VARTAB+0
|
||||
sta ARYTAB+0
|
||||
sta STREND+0
|
||||
lda VARTAB+1
|
||||
sta ARYTAB+1
|
||||
sta STREND+1
|
||||
|
||||
rts
|
||||
@@ -0,0 +1,4 @@
|
||||
// REM statement just skips to the next line
|
||||
|
||||
cmd_rem:
|
||||
jmp basic_end_of_line
|
||||
@@ -0,0 +1,22 @@
|
||||
cmd_run:
|
||||
// RUN clears all variables
|
||||
jsr basic_do_clr
|
||||
cmd_goto:
|
||||
// Disable Kernal messages
|
||||
lda #$00
|
||||
jsr JSETMSG
|
||||
|
||||
// Reset line pointer to first line of program.
|
||||
jsr init_oldtxt
|
||||
|
||||
jsr basic_end_of_statement_check
|
||||
bcs !+
|
||||
|
||||
jsr basic_parse_line_number
|
||||
jsr basic_find_line
|
||||
bcc !+
|
||||
// Line doesn't exist, so report error
|
||||
jmp do_UNDEFD_STATEMENT_error
|
||||
!:
|
||||
// Run it!
|
||||
jmp basic_execute_from_current_line
|
||||
@@ -0,0 +1,68 @@
|
||||
cmd_sys:
|
||||
|
||||
jsr basic_end_of_statement_check
|
||||
bcc !+
|
||||
|
||||
// SYS requires an argument
|
||||
jmp do_SYNTAX_error
|
||||
|
||||
!:
|
||||
//
|
||||
// XXX Temporary ugly hack to support 'SYS PI*656'
|
||||
//
|
||||
|
||||
ldy #$00
|
||||
|
||||
cmd_sys_hack_loop:
|
||||
lda (TXTPTR), y
|
||||
cmp cmd_sys_hack_str, y
|
||||
bne cmd_sys_hack_not_needed
|
||||
lda (TXTPTR), y
|
||||
beq cmd_sys_hack_apply
|
||||
iny
|
||||
bne cmd_sys_hack_loop // branch always
|
||||
|
||||
cmd_sys_hack_apply:
|
||||
|
||||
lda #<2060
|
||||
sta LINNUM+0
|
||||
lda #>2060
|
||||
sta LINNUM+1
|
||||
bne cmd_sys_setup_call // always jumps
|
||||
|
||||
cmd_sys_hack_not_needed:
|
||||
|
||||
//
|
||||
// XXX End of hack
|
||||
//
|
||||
|
||||
jsr basic_parse_line_number
|
||||
|
||||
cmd_sys_setup_call:
|
||||
lda #$4C // JMP opcode
|
||||
sta USRPOK
|
||||
lda LINNUM+0
|
||||
sta USRADD+0
|
||||
lda LINNUM+1
|
||||
sta USRADD+1
|
||||
|
||||
// Setup the register values
|
||||
lda SPREG
|
||||
pha
|
||||
ldy SYREG
|
||||
ldx SXREG
|
||||
lda SAREG
|
||||
plp
|
||||
|
||||
// Call the routine.
|
||||
jsr USRPOK
|
||||
|
||||
jmp basic_execute_statement
|
||||
|
||||
|
||||
//
|
||||
// XXX Temporary ugly hack to support 'SYS PI*656'
|
||||
//
|
||||
|
||||
cmd_sys_hack_str:
|
||||
.byte $FF, $AC, $36, $35, $36, $00
|
||||
@@ -0,0 +1,156 @@
|
||||
//
|
||||
// Default handler for all not-yet-implemented commands
|
||||
//
|
||||
// Note: NOPs are here just to make debugging easier!
|
||||
//
|
||||
|
||||
cmd_for:
|
||||
nop
|
||||
cmd_next:
|
||||
nop
|
||||
cmd_data:
|
||||
nop
|
||||
cmd_inputhash:
|
||||
nop
|
||||
cmd_input:
|
||||
nop
|
||||
cmd_dim:
|
||||
nop
|
||||
cmd_read:
|
||||
nop
|
||||
cmd_let:
|
||||
nop
|
||||
cmd_if:
|
||||
nop
|
||||
cmd_restore:
|
||||
nop
|
||||
cmd_gosub:
|
||||
nop
|
||||
cmd_return:
|
||||
nop
|
||||
|
||||
// $90-$9F
|
||||
|
||||
cmd_on:
|
||||
nop
|
||||
cmd_wait:
|
||||
nop
|
||||
cmd_save:
|
||||
nop
|
||||
cmd_verify:
|
||||
nop
|
||||
cmd_def:
|
||||
nop
|
||||
cmd_poke:
|
||||
nop
|
||||
cmd_printhash:
|
||||
nop
|
||||
cmd_print:
|
||||
nop
|
||||
cmd_cont:
|
||||
nop
|
||||
cmd_cmd:
|
||||
nop
|
||||
cmd_open:
|
||||
nop
|
||||
|
||||
// $A0-$AF
|
||||
|
||||
cmd_close:
|
||||
nop
|
||||
cmd_get:
|
||||
nop
|
||||
cmd_tab:
|
||||
nop
|
||||
cmd_to:
|
||||
nop
|
||||
cmd_fn:
|
||||
nop
|
||||
cmd_spc:
|
||||
nop
|
||||
cmd_then:
|
||||
nop
|
||||
cmd_not:
|
||||
nop
|
||||
cmd_step:
|
||||
nop
|
||||
cmd_plus:
|
||||
nop
|
||||
cmd_minus:
|
||||
nop
|
||||
cmd_mult:
|
||||
nop
|
||||
cmd_div:
|
||||
nop
|
||||
cmd_exponent:
|
||||
nop
|
||||
cmd_and:
|
||||
nop
|
||||
|
||||
// $B0-$BF
|
||||
|
||||
cmd_or:
|
||||
nop
|
||||
cmd_greater:
|
||||
nop
|
||||
cmd_equal:
|
||||
nop
|
||||
cmd_less:
|
||||
nop
|
||||
cmd_sgn:
|
||||
nop
|
||||
cmd_int:
|
||||
nop
|
||||
cmd_abs:
|
||||
nop
|
||||
cmd_usr:
|
||||
nop
|
||||
cmd_fre:
|
||||
nop
|
||||
cmd_pos:
|
||||
nop
|
||||
cmd_sqr:
|
||||
nop
|
||||
cmd_rnd:
|
||||
nop
|
||||
cmd_log:
|
||||
nop
|
||||
cmd_exp:
|
||||
nop
|
||||
cmd_cos:
|
||||
nop
|
||||
cmd_sin:
|
||||
nop
|
||||
|
||||
// $C0-$CF
|
||||
|
||||
cmd_tan:
|
||||
nop
|
||||
cmd_atn:
|
||||
nop
|
||||
cmd_peek:
|
||||
nop
|
||||
cmd_len:
|
||||
nop
|
||||
cmd_str:
|
||||
nop
|
||||
cmd_val:
|
||||
nop
|
||||
cmd_asc:
|
||||
nop
|
||||
cmd_chr:
|
||||
nop
|
||||
cmd_left:
|
||||
nop
|
||||
cmd_right:
|
||||
nop
|
||||
cmd_mid:
|
||||
nop
|
||||
cmd_go:
|
||||
nop
|
||||
|
||||
// Undefined tokens
|
||||
|
||||
cmd_unimplemented:
|
||||
|
||||
jmp do_NOT_IMPLEMENTED_error
|
||||
Reference in new issue
Block a user