some preparations for string variables, added BASIC command COLD

This commit is contained in:
FeralChild64 committed 2020-07-02 17:24:34 +02:00
1 parent 34b56b1fd5
commit 164d090a43
21 files changed
+240 -42

No files matched your search

+4
View File
@@ -41,6 +41,10 @@ Launches a built-in tape head alignment tool. Destorys program in memory. Press
## Additional BASIC commands
### `COLD`
Resets the machine. In direct mode asks for confirmation firsts.
### `FAST`
Tries to switch the machine to turbo mode - details differ depending on the configured machine / motherboard.
+1 -7
View File
@@ -52,7 +52,7 @@
.label OPPTR = $4B // $4B-$4C helper variable for expression computation, [!] our usage details are different
.label OPMASK = $4D // -- NOT IMPLEMENTED --
.label DEFPNT = $4E // $4E-$4F -- NOT IMPLEMENTED --
.label DSCPNT = $50 // $50-$52 -- NOT IMPLEMENTED --
.label DSCPNT = $50 // $50-$52 temporary area fro string handling, [!] our usage might differ
.label FOUR6 = $53 // -- NOT IMPLEMENTED --
.label JMPER = $54 // $54-$56 -- NOT IMPLEMENTED --
.label TEMPF1 = $57 // $57-$5B BASIC numeric work area
@@ -71,12 +71,6 @@
.label FAC2_mantissa = $6A // $6A - $6D
.label FAC2_sign = $6E
// We re-use FAC2 for memory move pointers, since we cannot be doing calculations while moving memory
.label memmove__src = $69
.label memmove__dst = $6B
.label memmove__size = $6D
.label ARISGN = $6F // -- NOT IMPLEMENTED --
.label FACOV = $70 // FAC1 low order mantissa
.label FBUFPT = $71 // $71-$72 -- NOT IMPLEMENTED --
+1
View File
@@ -32,6 +32,7 @@
.label panic = KERNAL().panic
#endif
.label vector_reset = KERNAL().vector_reset
.label hw_entry_reset = KERNAL().hw_entry_reset
#if CONFIG_DBG_PRINTF
@@ -15,7 +15,8 @@
cmd_bsave,
cmd_bverify,
cmd_old
cmd_old,
cmd_cold
)
+12
View File
@@ -0,0 +1,12 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
cmd_cold:
jsr helper_ask_if_sure
bcs_16 execute_statements
jsr JCLALL // for extra safety
jmp (vector_reset) // hardware CPU vector
@@ -0,0 +1,65 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// For direct mode, asks the user if he is sure (sets Carry if not);
// otherwise returns with Carry clear
//
helper_ask_if_sure:
// First check, if we are in direct mode,; if not, do not ask
ldx CURLIN+1
inx
bne helper_ask_if_sure_ok // branch if not direct mode
// Not direct mode - display the question
ldx #IDX__STR_IF_SURE
jsr print_packed_misc_str
// Clear the keyboard queue
lda #$00
sta NDX
// Enable cursor, fetch the answer
lda #$00
sta BLNSW
!:
jsr JGETIN
cmp #$00
beq !-
// Check if 'Y'
cmp #$59
beq !+
lda #$4E // 'N'
jsr JCHROUT
sec
rts
!:
// Display 'Y' and wait a short moment for a better user experience
jsr JCHROUT
clc
lda TIME+0
adc #$0C
!:
cmp TIME+0
bne !-
// FALLTROUGH
helper_ask_if_sure_ok:
clc
rts
+1 -1
View File
@@ -58,7 +58,7 @@ oper_add_strings:
adc __FAC2+0
bcs_16 do_STRING_TOO_LONG_error
jsr alloc_temp_string
// jsr alloc_temp_string
.break
+5
View File
@@ -9,6 +9,11 @@ shell_main_loop:
ldx #IDX__STR_READY
jsr print_packed_misc_str
// Mark mode as direct
lda #$FF
sta CURLIN+1
// Enable Kernal messages
lda #$80
jsr JSETMSG
-26
View File
@@ -1,26 +0,0 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Allocates area for a temporary string
//
// Input:
// - .A - string length
//
// XXX - finish the implementation once string memory handling is done
alloc_temp_string:
// Check if temporary descriptor stack has a free slot
ldx LASTPT
cpx #$1F
bcs_16 do_FORMULA_TOO_COMPLEX_error
// XXX
jmp do_NOT_IMPLEMENTED_error
+106
View File
@@ -0,0 +1,106 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Allocates memory for string - lowers FRETOP (but not below STREND)
//
// Note: We are not going to use the C64-style memory management here, as it implies
// a very slow garbage collector. Instead, we are using a scheme similar to used in
// BASIC V3.5 and later, with 'back-pointers' after each string, telling about the
// location of the string descriptor.
//
// See:
// - https://www.c64-wiki.com/wiki/Memory_(BASIC)
// - https://sites.google.com/site/h2obsession/CBM/basic/variable-format
//
// Input:
// - DSCPNT+0, DSCPNT+1 - pointer to string descriptor, first pointed byte should contain desired length
//
varstr_alloc:
// Mark garbage collector as not run yet
lda #$00
// FALLTROUGH
varstr_alloc_retry:
sta GARBFL // Computes Mapping the Commodore 64, page 10
// Backup FRETOP in case of alocation problems
lda FRETOP+0
sta INDEX+0
lda FRETOP+1
sta INDEX+1
// Lower FRETOP to make space for string descriptor
#if !HAS_OPCODES_65CE02
lda #$02
jsr varstr_FRETOP_down
#else // HAS_OPCODES_65CE02
dew FRETOP
dew FRETOP
#endif
jsr varstr_FRETOP_check
bcs varstr_alloc_fail
// XXX finish this
varstr_alloc_fail:
// Unable to alocate memory - restore FRETOP value
lda INDEX+0
sta FRETOP+0
lda INDEX+1
sta FRETOP+1
// Check if it is worth to perform garbage collection and retry
bit GARBFL
// XXX finish this
// XXX move these helper routines to a better place
varstr_FRETOP_down: // memmove__tmp - length to lower FRETOP
sec
lda FRETOP+0
sbc memmove__tmp
sta FRETOP+0
bcs !+
dec FRETOP+1
!:
rts
varstr_FRETOP_check:
// Check if FRETOP > STREND, Carry set if not
lda STREND+1
cmp FRETOP+1
beq !+
rts
!:
lda STREND+0
cmp FRETOP+0
rts
+9
View File
@@ -0,0 +1,9 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
varstr_dealloc:
rts // XXX implement this
@@ -0,0 +1,8 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
varstr_garbage_collect:
rts // XXX implement this
+3 -3
View File
@@ -9,13 +9,13 @@
shift_mem_adapt_pointers:
sty RESHO+4
sty memmove__tmp
// Adapt source pointer
sec
lda memmove__src+0
sbc RESHO+4
sbc memmove__tmp
sta memmove__src+0
bcs !+
dec memmove__src+1
@@ -24,7 +24,7 @@ shift_mem_adapt_pointers:
sec
lda memmove__dst+0
sbc RESHO+4
sbc memmove__tmp
sta memmove__dst+0
bcs !+
dec memmove__dst+1
+9
View File
@@ -0,0 +1,9 @@
//
// Aliases for memory locations for memory block copy routines
//
.label memmove__src = INDEX+2
.label memmove__dst = RESHO+0
.label memmove__size = RESHO+2
.label memmove__tmp = RESHO+4
+1 -1
View File
@@ -11,7 +11,7 @@
// - memmove__dst - pointer to the first byte of destination
// - memmove__size - number of bytes to copy
//
// All the input variables, .A, and .Y register, are destroyed. Also uses RESHO+4 variable.
// All the input variables, .A, and .Y register, are destroyed. Also uses memmove__tmp variable.
//
+1 -1
View File
@@ -11,7 +11,7 @@
// - memmove__dst - pointer to the last byte of destination
// - memmove__size - number of bytes to copy
//
// All the input variables, .A, and .Y register, are destroyed. Also uses RESHO+4 variable.
// All the input variables, .A, and .Y register, are destroyed. Also uses memmove__tmp variable.
//
+2
View File
@@ -6,4 +6,6 @@
// $FFFC - CPU Reset Vector
// Uncontrovertial, as it is a CPU requirement, and nothing else.
vector_reset:
.word hw_entry_reset
+2
View File
@@ -6,4 +6,6 @@
// $FFFA - CPU NMI Hanlder
// Uncontrovertial as this is also a CPU requirement.
vector_nmi:
.word hw_entry_nmi
+2
View File
@@ -7,4 +7,6 @@
// This is non-controvertial, as it is a 6502 CPU requirement, and we just have to point
// it to whatever IRQ routine we make.
vector_irq:
.word hw_entry_irq
Binary file not shown.
+6 -2
View File
@@ -178,11 +178,14 @@ const StringEntryList GLOBAL_Keywords_V2 = { ListType::KEYWORDS, "keywords_V2",
const StringEntryList GLOBAL_Keywords_CC = { ListType::KEYWORDS, "keywords_CC",
{
// STD M65 U64 X16
{ true, true, true, true, "KCC_01", "MERGE", }, // OpenROMs specific, not present in CBM BASIC dialects
{ true, true, true, true, "KCC_01", "MERGE", }, // Not present in CBM BASIC dialects, but common to some extensions (*)
{ true, true, true, true, "KCC_02", "BLOAD", }, // http://www.antonis.de/qbebooks/gwbasman/bload.html
{ true, true, true, true, "KCC_03", "BSAVE", }, // http://www.antonis.de/qbebooks/gwbasman/bsave.html
{ true, true, true, true, "KCC_04", "BVERIFY", },
{ true, true, true, true, "KCC_05", "OLD", }, // OpenROMs specific, not present in CBM BASIC dialects
{ true, true, true, true, "KCC_05", "OLD", }, // Not present in CBM BASIC dialects, but common to some extensions (*)
{ true, true, true, true, "KCC_06", "COLD", }, // Not present in CBM BASIC dialects, but common to some extensions (*)
// (*) see https://sourceforge.net/p/vice-emu/code/HEAD/tree/trunk/vice/src/petcat.c
} };
// extended BASIC keywords - reserved for BASIC commands likely making sense on most C64-compatible machines
@@ -310,6 +313,7 @@ const StringEntryList GLOBAL_MiscStrings = { ListType::STRINGS_BASIC, "misc",
{ true, true, true, true, "STR_READY", "\rREADY.\r" }, // https://www.ibm.com/support/knowledgecenter/zosbasics/com.ibm.zos.zconcepts/zconc_whatistsonative.htm https://github.com/stefanhaustein/expressionparser
{ true, true, true, true, "STR_ERROR", " ERROR" }, // simply the word error that is attached to the other parts of messages https://fjkraan.home.xs4all.nl/comp/apple2faq/app2asoftfaq.html
{ true, true, true, true, "STR_IN", " IN " },
{ true, true, true, true, "STR_IF_SURE", "\rARE YOU SURE? " }, // https://docs.microsoft.com/en-us/windows/win32/uxguide/mess-confirm
// STD M65 U64 X16 --- misc strings specific to OpenROMs, not present in CBM ROMs
{ true, true, true, true, "STR_BRK_AT", "\rBRK AT $" },
// Note: depending on configuration, additional strings will be added here