From e74fd4140acca358a8d99cda77d984ce30c667fb Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 21 Jun 2020 19:58:11 +0200 Subject: [PATCH] preparation for a couple of new BASIC commands --- Makefile | 2 + c64/basic/basic_commands/cmd__jumptable.s | 2 +- .../basic_commands_CC/cmd__jumptable_CC.s | 49 +++++++++++++++++++ c64/basic/basic_commands_CC/cmd_bload.s | 8 +++ c64/basic/basic_commands_CC/cmd_bsave.s | 8 +++ c64/basic/basic_commands_CC/cmd_bverify.s | 8 +++ c64/basic/basic_commands_CC/cmd_merge.s | 8 +++ .../basic_commands_CD/cmd__jumptable_CD.s | 46 +++++++++++++++++ c64/basic/basic_commands_CD/cmd_fast.s | 8 +++ c64/basic/basic_commands_CD/cmd_slow.s | 8 +++ c64/basic/basic_functions/fun__jumptable.s | 2 +- c64/basic/engine/do_error.s | 47 ++++++++++++------ tools/generate_strings.cc | 23 ++++++--- 13 files changed, 195 insertions(+), 24 deletions(-) create mode 100644 c64/basic/basic_commands_CC/cmd__jumptable_CC.s create mode 100644 c64/basic/basic_commands_CC/cmd_bload.s create mode 100644 c64/basic/basic_commands_CC/cmd_bsave.s create mode 100644 c64/basic/basic_commands_CC/cmd_bverify.s create mode 100644 c64/basic/basic_commands_CC/cmd_merge.s create mode 100644 c64/basic/basic_commands_CD/cmd__jumptable_CD.s create mode 100644 c64/basic/basic_commands_CD/cmd_fast.s create mode 100644 c64/basic/basic_commands_CD/cmd_slow.s diff --git a/Makefile b/Makefile index d65bbff7..5ed42036 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \ c64/basic/,stubs_math \ c64/basic/assets \ c64/basic/basic_commands \ + c64/basic/basic_commands_CC \ + c64/basic/basic_commands_CD \ c64/basic/basic_operators \ c64/basic/basic_functions \ c64/basic/board_m65 \ diff --git a/c64/basic/basic_commands/cmd__jumptable.s b/c64/basic/basic_commands/cmd__jumptable.s index 1fa25c49..d5f8e1ff 100644 --- a/c64/basic/basic_commands/cmd__jumptable.s +++ b/c64/basic/basic_commands/cmd__jumptable.s @@ -3,7 +3,7 @@ // #LAYOUT# * * #IGNORE // -// Jumptable for all known BASIC commands +// Jumptable for BASIC V2 dialect commands // diff --git a/c64/basic/basic_commands_CC/cmd__jumptable_CC.s b/c64/basic/basic_commands_CC/cmd__jumptable_CC.s new file mode 100644 index 00000000..72168c3e --- /dev/null +++ b/c64/basic/basic_commands_CC/cmd__jumptable_CC.s @@ -0,0 +1,49 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Jumptable for BASIC commands with tokens prefixed by $CC +// + + +.const command_CC_list = List().add( + + cmd_merge, + + cmd_bload, + cmd_bsave, + cmd_bverify +) + + +#if !HAS_OPCODES_65C02 + + +command_CC_jumptable_lo: + + put_jumptable_lo(command_CC_list) + + +command_CC_jumptable_hi: + + put_jumptable_hi(command_CC_list) + + +#else // HAS_OPCODES_65C02 + + +__before_command_CC_jumptable: + +.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary + +command_CC_jumptable: + + put_jumptable(command_CC_list) + + // Make sure routine size is always the same - build system limitation + +.if (__before_command_CC_jumptable == command_CC_jumptable) { brk } + + +#endif diff --git a/c64/basic/basic_commands_CC/cmd_bload.s b/c64/basic/basic_commands_CC/cmd_bload.s new file mode 100644 index 00000000..2feed6d0 --- /dev/null +++ b/c64/basic/basic_commands_CC/cmd_bload.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_bload: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_commands_CC/cmd_bsave.s b/c64/basic/basic_commands_CC/cmd_bsave.s new file mode 100644 index 00000000..3849a57d --- /dev/null +++ b/c64/basic/basic_commands_CC/cmd_bsave.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_bsave: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_commands_CC/cmd_bverify.s b/c64/basic/basic_commands_CC/cmd_bverify.s new file mode 100644 index 00000000..3fdfdf8a --- /dev/null +++ b/c64/basic/basic_commands_CC/cmd_bverify.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_bverify: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_commands_CC/cmd_merge.s b/c64/basic/basic_commands_CC/cmd_merge.s new file mode 100644 index 00000000..f464369e --- /dev/null +++ b/c64/basic/basic_commands_CC/cmd_merge.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_merge: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_commands_CD/cmd__jumptable_CD.s b/c64/basic/basic_commands_CD/cmd__jumptable_CD.s new file mode 100644 index 00000000..9cfa0c9a --- /dev/null +++ b/c64/basic/basic_commands_CD/cmd__jumptable_CD.s @@ -0,0 +1,46 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Jumptable for BASIC commands with tokens prefixed by $CD +// + + +.const command_CD_list = List().add( + + cmd_slow, + cmd_fast +) + + +#if !HAS_OPCODES_65C02 + + +command_CD_jumptable_lo: + + put_jumptable_lo(command_CD_list) + + +command_CD_jumptable_hi: + + put_jumptable_hi(command_CD_list) + + +#else // HAS_OPCODES_65C02 + + +__before_command_CD_jumptable: + +.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary + +command_CD_jumptable: + + put_jumptable(command_CD_list) + + // Make sure routine size is always the same - build system limitation + +.if (__before_command_CD_jumptable == command_CD_jumptable) { brk } + + +#endif diff --git a/c64/basic/basic_commands_CD/cmd_fast.s b/c64/basic/basic_commands_CD/cmd_fast.s new file mode 100644 index 00000000..056fed10 --- /dev/null +++ b/c64/basic/basic_commands_CD/cmd_fast.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_fast: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_commands_CD/cmd_slow.s b/c64/basic/basic_commands_CD/cmd_slow.s new file mode 100644 index 00000000..730fb203 --- /dev/null +++ b/c64/basic/basic_commands_CD/cmd_slow.s @@ -0,0 +1,8 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +cmd_slow: + + jmp do_NOT_IMPLEMENTED_error // XXX implement the command diff --git a/c64/basic/basic_functions/fun__jumptable.s b/c64/basic/basic_functions/fun__jumptable.s index 0d53bcdc..266ff347 100644 --- a/c64/basic/basic_functions/fun__jumptable.s +++ b/c64/basic/basic_functions/fun__jumptable.s @@ -3,7 +3,7 @@ // #LAYOUT# * * #IGNORE // -// Jumptable for all known BASIC functions +// Jumptable for BASIC V2 dialect functions // diff --git a/c64/basic/engine/do_error.s b/c64/basic/engine/do_error.s index 47a893f2..e86c82d6 100644 --- a/c64/basic/engine/do_error.s +++ b/c64/basic/engine/do_error.s @@ -33,18 +33,7 @@ // message that the $2C method would result in. -// XXX consider reworking the two errors below to reuse '$E6' mechanism - - -do_NOT_IMPLEMENTED_error: - - ldx #IDX__EV7_28 - bpl do_basic_error // branch always - -do_MEMORY_CORRUPT_error: - - ldx #IDX__EOR_2A - bpl do_basic_error // branch always + // Error messages reported by KERNAL do_kernal_error: // .A = KERNAL error code, also almost matches BASIC error codes @@ -52,9 +41,39 @@ do_kernal_error: // .A = KERNAL error code, also almost ma tax dex - bpl do_basic_error + bpl do_basic_error // branch always - // FALLTROUGN + // Error messages specific to OpenROMs BASIC dialect + +do_MEMORY_CORRUPT_error: + .byte $E6 + + // Error messages compatible with CBM BASIC V7 dialect + +do_FILE_READ_error: + .byte $E6 +do_NOT_IMPLEMENTED_error: + .byte $E6 +do_UNRESOLVED_REFERENCE_error: + .byte $E6 +do_LINE_NUMBER_TOO_LARGE_error: + .byte $E6 +do_BEND_NOT_FOUND_error: + .byte $E6 +do_BAD_DISK_error: + .byte $E6 +do_NO_GRAPHICS_AREA_error: + .byte $E6 +do_DIRECT_MODE_ONLY_error: + .byte $E6 +do_LOOP_WITHOUT_DO_error: + .byte $E6 +do_LOOP_NOT_FOUND_error: + .byte $E6 +do_CANT_RESUME_error: + .byte $E6 + + // Error messages compatible with CBM BASIC V2 dialect do_BREAK_error: .byte $E6 diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc index f381b616..16124a4a 100644 --- a/tools/generate_strings.cc +++ b/tools/generate_strings.cc @@ -180,10 +180,11 @@ const StringEntryList GLOBAL_Keywords_V2 = { ListType::KEYWORDS, "keywords_V2", const StringEntryList GLOBAL_Keywords_CC = { ListType::KEYWORDS, "keywords_CC", { - // STD M65 X16 - { false, false, false, "KCC_01", "BLOAD", }, // http://www.antonis.de/qbebooks/gwbasman/bload.html - { false, false, false, "KCC_02", "BSAVE", }, // http://www.antonis.de/qbebooks/gwbasman/bload.html - { false, false, false, "KCC_03", "BVERIFY", }, + // STD M65 X16 + { true, true, true, "KCC_01", "MERGE", }, // OpenROMs specific, not present in CBM BASIC dialects + { true, true, true, "KCC_02", "BLOAD", }, // http://www.antonis.de/qbebooks/gwbasman/bload.html + { true, true, true, "KCC_03", "BSAVE", }, // http://www.antonis.de/qbebooks/gwbasman/bsave.html + { true, true, true, "KCC_04", "BVERIFY", }, } }; // extended BASIC keywords - reserved for BASIC commands likely making sense on most C64-compatible machines @@ -191,8 +192,8 @@ const StringEntryList GLOBAL_Keywords_CC = { ListType::KEYWORDS, "keywords_CC", const StringEntryList GLOBAL_Keywords_CD = { ListType::KEYWORDS, "keywords_CD", { // STD M65 X16 - { false, false, false, "KCD_01", "SLOW", }, // https://en.wikipedia.org/wiki/Sinclair_BASIC - ZX81 variant - { false, false, false, "KCD_02", "FAST", }, // https://en.wikipedia.org/wiki/Sinclair_BASIC - ZX81 variant + { true, true, true, "KCD_01", "SLOW", }, // https://en.wikipedia.org/wiki/Sinclair_BASIC - ZX81 variant + { true, true, true, "KCD_02", "FAST", }, // https://en.wikipedia.org/wiki/Sinclair_BASIC - ZX81 variant } }; // extended BASIC keywords - reserved for board-specific BASIC commands @@ -289,13 +290,13 @@ const StringEntryList GLOBAL_Errors = { ListType::STRINGS_BASIC, "errors", { false, false, false, "EV7_1F", "CAN'T RESUME" }, // not used for now { false, false, false, "EV7_20", "LOOP NOT FOUND" }, // not used for now { false, false, false, "EV7_21", "LOOP WITHOUT DO" }, // not used for now - { false, false, false, "EV7_22", "DIRECT MODE ONLY" }, // not used for now + { true, true, true, "EV7_22", "DIRECT MODE ONLY" }, { false, false, false, "EV7_23", "NO GRAPHICS AREA" }, // not used for now { false, false, false, "EV7_24", "BAD DISK" }, // not used for now { false, false, false, "EV7_25", "BEND NOT FOUND" }, // not used for now { false, false, false, "EV7_26", "LINE NUMBER TOO LARGE" }, // not used for now { false, false, false, "EV7_27", "UNRESOLVED REFERENCE" }, // not used for now - { true, true, true, "EV7_28", "NOT IMPLEMENTED" }, // this message actually differs rom CBM one + { true, true, true, "EV7_28", "NOT IMPLEMENTED" }, // this message actually differs from the CBM one { false, false, false, "EV7_29", "FILE READ" }, // not used for now // STD M65 X16 --- error strings specific to OpenROMs, not present in CBM BASIC dialects { true, true, true, "EOR_2A", "MEMORY CORRUPT" }, @@ -926,14 +927,20 @@ void writeStrings() // Add input data to computation objects dataSetSTD.addStrings(GLOBAL_Keywords_V2); + dataSetSTD.addStrings(GLOBAL_Keywords_CC); + dataSetSTD.addStrings(GLOBAL_Keywords_CD); dataSetSTD.addStrings(GLOBAL_Errors); dataSetSTD.addStrings(GLOBAL_MiscStrings); dataSetM65.addStrings(GLOBAL_Keywords_V2); + dataSetM65.addStrings(GLOBAL_Keywords_CC); + dataSetM65.addStrings(GLOBAL_Keywords_CD); dataSetM65.addStrings(GLOBAL_Errors); dataSetM65.addStrings(GLOBAL_MiscStrings); dataSetX16.addStrings(GLOBAL_Keywords_V2); + dataSetX16.addStrings(GLOBAL_Keywords_CC); + dataSetX16.addStrings(GLOBAL_Keywords_CD); dataSetX16.addStrings(GLOBAL_Errors); dataSetX16.addStrings(GLOBAL_MiscStrings);