diff --git a/CONFIG.md b/CONFIG.md
index e94e7ac6..88b6b7c9 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -84,7 +84,7 @@ It enables some speed/size code optimizations and allows C65 memory mapping to w
### `CONFIG_CPU_M65_45GS02`
-Choose if you have a Mega65 FPGA board. It enables some speed/size code optimizations and allows Mega65 memory mapping to work.
+Choose if you have a MEGA65 FPGA board. It enables some speed/size code optimizations and allows MEGA65 memory mapping to work.
### `CONFIG_CPU_WDC_65816`
@@ -111,7 +111,7 @@ These models additionaly use RAM under BASIC, and the 50K additionally takes ove
Uses RAM under BASIC, I/O and KERNAL, takes over `$C000`-`$CFFF` area requires special helper routines installed in `$2A7`-`$2FF` area (normally unused and free for the user). Gives the most free memory for BASIC programs, but it's the slowest (for example, forces disabling optimized LOAD loop for JiffyDOS) and the least compatible model.
-It is currently not compatible with Mega65 extended ROMs.
+It is currently not compatible with MEGA65 extended ROMs.
Comparing to standard memory model, it needs about 180 bytes in BASIC segment and 80 bytes in KERNAL segment - at the moment of doing the test, these values are expected to change often.
@@ -147,7 +147,7 @@ Causes screen blanking during JiffyDOS file loading to increase performance.
## Tape support
-Note: for Mega65 most of the tape support code is placed in it's extended ROM; very little of the (tiny) KERNAL segment is used.
+Note: for MEGA65 most of the tape support code is placed in it's extended ROM; very little of the (tiny) KERNAL segment is used.
### `CONFIG_TAPE_NORMAL`
@@ -175,12 +175,6 @@ Enable this option if you are using a tape interface adapter with some audio sig
Enable this option if you are using a tape interface adapter lacking tape motor control (most likely every adapter currently being sold) - this will eliminate the need to quickly press space when the program header information gets displayed. Note: if you are using a cassette player with REM port, and your adapter is connected to this port too, than you do not need this option.
-### `CONFIG_TAPE_NO_ERROR_CORRECTION`
-
-Normal tape format contains two copies of each data block - in case some bytes from the first one are damaged, they can be corrected by reading them from the second copy. Enabling this option omits the core to read the second block.
-
-If used with `CONFIG_TAPE_NORMAL`, saves about 125 bytes in KERNAL segment. Not recommended when using real magnetic tapes.
-
## Multiple SID support
The SID is a sound chip - the original Commodore 64 had one installed. However, mods exists to add more of them for improved sound capabilities. Emulators and FPGA machines typically allow to simulate more than one too. Unfortunately, there is no standard regarding how these additional chips are visible in the processor address space, and there is no sane way to detect it - thus, it has to be configurable.
@@ -293,7 +287,7 @@ Feature needs several bytes in BASIC segment. If unsure - enable.
If enabled, embeds a tape head align tool into the ROM, it can be started with `←H`. Requires `CONFIG_TAPE_WEDGE`.
-Feature needs about 800 bytes in KERNAL segment. Only recomended for machines with extended ROM, like Mega65.
+Feature needs about 800 bytes in KERNAL segment. Only recomended for machines with extended ROM, like MEGA65.
### `CONFIG_BCD_SAFE_INTERRUPTS`
@@ -307,9 +301,9 @@ Feature needs 2 bytes in KERNAL segmment (for CPUs needing the patch), but at th
Tries to adjust the color scheme to the selected brand. Some brands might not support this.
-### `CONFIG_BANNER_SIMPLE`, `CONFIG_BANNER_FANCY`, `CONFIG_BANNER_BRAND`
+### `CONFIG_BANNER_SIMPLE`, `CONFIG_BANNER_FANCY`
-Select startup banner - either a simple one, or with some colorful elements. `CONFIG_BANNER_BRAND` heavily depends on the selected brand, not all the brands support it.
+Select startup banner - either a simple one, or with some colorful elements.
Richer banners need more BASIC segment, varies between brands.
diff --git a/CREDITS.md b/CREDITS.md
index c1a3082a..76bd4e40 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -3,7 +3,7 @@
## for source code/assets we reused
-* Retrofan - for his Mega65 banner artwork and PXLfont
+* Retrofan - for his MEGA65 banner artwork and PXLfont
* TWW/CTR - for his keyboard handling code
* Graham - for his PAL/NTSC detection code and compact 8x8 multiplication routine
* enthusi/Onslaught - for his example Turbo Tape 64 compatible loader
@@ -26,8 +26,10 @@
## other
-* Gábor Lénárt - for his work on [XEMU Mega65 emulator](https://github.com/lgblgblgb/xemu)
+* Gábor Lénárt - for [his work](https://github.com/lgblgblgb/xemu) on XEMU MEGA65 emulator
+* Hernán Di Pietro - for [his work](https://github.com/hernandp/xemu) on XEMU MEGA65 emulator
* Mads Nielsen - for the [Kick Assembler](http://www.theweb.dk/KickAssembler/Main.html#frontpage)
+* Simon Jameson - for his Kick Assembler [pseudocommands](https://github.com/smnjameson/M65_KickAsm_PseudoCommands) for MEGA65 CPU support
diff --git a/Makefile b/Makefile
index 498de7f4..62da0476 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \
src/basic/basic_commands \
src/basic/basic_commands_01 \
src/basic/basic_commands_02 \
+ src/basic/basic_commands_03_m65 \
src/basic/basic_operators \
src/basic/basic_functions \
src/basic/board_m65 \
@@ -32,12 +33,16 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \
src/basic/rom_revision \
src/basic/wedge
+SRCDIR_DOS_M65 = $(SRCDIR_COMMON) \
+ src/dos_m65 \
+
SRCDIR_KERNAL = $(SRCDIR_COMMON) \
src/kernal \
src/kernal/,stubs \
src/kernal/assets \
src/kernal/board_m65 \
src/kernal/board_x16 \
+ src/kernal/extapi_m65 \
src/kernal/iec \
src/kernal/iec_fast \
src/kernal/init \
@@ -50,17 +55,19 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \
src/kernal/rom_revision \
src/kernal/rs232 \
src/kernal/screen \
+ src/kernal/screen_m65 \
src/kernal/tape \
src/kernal/time
-SRC_BASIC = $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s))
-SRC_KERNAL = $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s))
-SRC_TOOLS = $(wildcard tools/*.c,tools/*.cc)
+SRC_BASIC = $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s))
+SRC_DOS_M65 = $(foreach dir,$(SRCDIR_DOS_M65),$(wildcard $(dir)/*.s))
+SRC_KERNAL = $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s))
+SRC_TOOLS = $(wildcard tools/*.c,tools/*.cc)
# Generated files
-GEN_BASIC = build/,generated/float_constants.s
-GEN_KERNAL =
+GEN_BASIC = build/,generated/float_constants.s
+GEN_KERNAL =
# List of build directories
@@ -91,8 +98,9 @@ GEN_STR_X16 = $(DIR_X16)/,generated/packed_strings.s
# Dependencies - helper variables
-DEP_BASIC = $(SRC_BASIC) $(SRCDIR_BASIC) $(GEN_BASIC)
-DEP_KERNAL = $(SRC_KERNAL) $(SRCDIR_KERNAL) $(GEN_KERNAL)
+DEP_BASIC = $(SRC_BASIC) $(SRCDIR_BASIC) $(GEN_BASIC)
+DEP_DOS_M65 = $(SRC_DOS_M65) $(SRCDIR_DOS_M65)
+DEP_KERNAL = $(SRC_KERNAL) $(SRCDIR_KERNAL) $(GEN_KERNAL)
# List of tools
@@ -140,6 +148,7 @@ TARGET_LIST = build/chargen_openroms.rom \
SEG_LIST_M65 = $(DIR_M65)/basic.seg_0 \
$(DIR_M65)/basic.seg_1 \
+ $(DIR_M65)/dos.seg_1 \
$(DIR_M65)/kernal.seg_0 \
$(DIR_M65)/kernal.seg_1
@@ -204,7 +213,7 @@ build/chargen_openroms.patched: $(TOOL_PATCH_CHARGEN) build/chargen_openroms.rom
build/chargen_pxlfont.patched: $(TOOL_PATCH_CHARGEN) build/chargen_pxlfont.rom
$(TOOL_PATCH_CHARGEN) -i build/chargen_pxlfont.rom -o $@ -n 6px-PXLfont
-# Dependencies - BASIC and KERNAL
+# Dependencies - BASIC, DOS, and KERNAL
$(DIR_CUS)/OUTB_x.BIN $(DIR_CUS)/BASIC_combined.vs: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_CUS) $(GEN_STR_CUS) $(DIR_CUS)/KERNAL_combined.sym
@@ -236,6 +245,8 @@ $(DIR_X16)/OUTK_0.BIN $(DIR_X16)/KERNAL_0_combined.vs $(DIR_X16)/KERNAL_0_combin
$(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1_combined.vs $(DIR_M65)/BASIC_1_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_M65) $(GEN_STR_M65) $(DIR_M65)/KERNAL_0_combined.sym $(DIR_M65)/BASIC_0_combined.sym
+$(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1_combined.vs $(DIR_M65)/DOS_1_combined.sym: \
+ $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_DOS) $(CFG_M65)
$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym: \
$(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_M65) $(GEN_STR_M65) $(DIR_M65)/KERNAL_0_combined.sym
@@ -315,7 +326,7 @@ build/target_%/OUTK_x.BIN build/target_%/KERNAL_combined.vs build/target_%/KERNA
@rm -f $@* build/target_$*/KERNAL*
@$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r STD -s KERNAL -i KERNAL-$* -o OUTK_x.BIN -d build/target_$* -l e4d3 -h ffff src/,,config_$*.s $(SRCDIR_KERNAL) $(GEN_KERNAL) $(GEN_STR_$*)
-# Rules - BASIC and KERNAL intermediate files, for Mega65
+# Rules - BASIC and KERNAL intermediate files, for MEGA65
$(DIR_M65)/OUTB_0.BIN $(DIR_M65)/BASIC_0_combined.vs $(DIR_M65)/BASIC_0_combined.sym:
@mkdir -p $(DIR_M65)
@@ -332,6 +343,11 @@ $(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1_combined.vs $(DIR_M65)/BASIC_1_combine
@rm -f $@* $(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1*
@$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s BASIC_1 -i BASIC_1-mega65 -o basic.seg_1 -d $(DIR_M65) -l 4000 -h 7fff $(CFG_M65) $(GEN_STR_M65) $(SRCDIR_BASIC) $(GEN_BASIC)
+$(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1_combined.vs $(DIR_M65)/DOS_1_combined.sym:
+ @mkdir -p $(DIR_M65)
+ @rm -f $@* $(DIR_M65)/dos.seg_1 $(DIR_M65)/DOS_1*
+ @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s DOS_1 -i DOS_1-mega65 -o dos.seg_1 -d $(DIR_M65) -l 4000 -h 7fff $(CFG_M65) $(SRCDIR_DOS_M65)
+
$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym:
@mkdir -p $(DIR_M65)
@rm -f $@* $(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1*
@@ -407,18 +423,15 @@ build/kernal_hybrid.rom: kernal $(DIR_GEN)/OUTK_x.BIN
build/symbols_hybrid.vs: $(DIR_GEN)/KERNAL_combined.vs
sort $(DIR_GEN)/KERNAL_combined.vs | uniq | grep -v "__" > $@
-# Rules - platform 'Mega65' specific
+# Rules - MEGA65 platform specific
-build/padding_16_KB:
- @mkdir -p build
- dd if=/dev/zero bs=8192 count=2 of=build/padding_16_KB
build/padding_64_KB:
@mkdir -p build
dd if=/dev/zero bs=8192 count=8 of=build/padding_64_KB
-$(TARGET_M65_x) $(TARGET_M65_x_PXL): build/padding_16_KB build/padding_64_KB $(SEG_LIST_M65) build/chargen_openroms.rom build/chargen_openroms.patched build/chargen_pxlfont.rom build/chargen_pxlfont.patched
+$(TARGET_M65_x) $(TARGET_M65_x_PXL): $(SEG_LIST_M65) build/padding_64_KB build/chargen_openroms.rom build/chargen_openroms.patched build/chargen_pxlfont.rom build/chargen_pxlfont.patched
@echo
- cat build/padding_16_KB > $(TARGET_M65_x)
+ cat $(DIR_M65)/dos.seg_1 > $(TARGET_M65_x)
cat $(DIR_M65)/kernal.seg_1 >> $(TARGET_M65_x)
cat $(DIR_M65)/basic.seg_1 >> $(TARGET_M65_x)
cat $(DIR_M65)/basic.seg_0 >> $(TARGET_M65_x)
@@ -427,7 +440,7 @@ $(TARGET_M65_x) $(TARGET_M65_x_PXL): build/padding_16_KB build/padding_64_KB $(S
cat $(DIR_M65)/kernal.seg_0 >> $(TARGET_M65_x)
cat build/padding_64_KB >> $(TARGET_M65_x)
@echo
- cat build/padding_16_KB > $(TARGET_M65_x_PXL)
+ cat $(DIR_M65)/dos.seg_1 > $(TARGET_M65_x_PXL)
cat $(DIR_M65)/kernal.seg_1 >> $(TARGET_M65_x_PXL)
cat $(DIR_M65)/basic.seg_1 >> $(TARGET_M65_x_PXL)
cat $(DIR_M65)/basic.seg_0 >> $(TARGET_M65_x_PXL)
diff --git a/README.md b/README.md
index fa697474..0bb0f62b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Open ROMs
-
+
+
A project to create unencumbered open-source ROMs for use on selected retro computers. Besides this manifest, the following documents are available:
@@ -21,7 +22,7 @@ which typically requires the inclusion of firmware, i.e, "ROMs", while respectin
the owners of the copyrights in the ROMs.
Therefore the goal of this project is to create a fully open-source and unencumbered set of ROMs for various systems.
-The initial focus is the C64 and C65 computers, because of the desire to be able to include open ROMs with the MEGA65
+The initial focus is the C64 and C65 computers, because of the desire to be able to include Open ROMs with the MEGA65
retro computer.
In short, this project exists precisely because we respect, and want to help others to respect the intellectual property
diff --git a/STATUS.md b/STATUS.md
index ed8966a0..c0b3c7aa 100644
--- a/STATUS.md
+++ b/STATUS.md
@@ -22,7 +22,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8
* normal tape load error log is limited by free stack space only (no artificial limitation like in original ROMs)
* tape format autodetection; normal vs turbo is mostly transparent to user
* improved support for tape adapters (for using regular casette players and other audio devices instead of Datasette) and emulators
-* built-in tape head align tool (only feasible to use on machines with extended memory, like Mega65)
+* built-in tape head align tool (only feasible to use on machines with extended memory, like MEGA65)
* uses RAM under ROM and I/O: 51199 bytes free (up to `$CFFF`) by default, but 61438 is also possible
* cold/warm start silences multiple SID chips
@@ -58,7 +58,7 @@ The following ROM features are currently missing:
| :----------------: | :------: | :------------------------------------------------: |
| C64 | DONE | |
| C128 | DONE | |
-| Mega65 | NOT DONE | code should be complete, but is not tested yet |
+| MEGA65 | PARTIAL | code mostly complete, but not tested yet |
@@ -70,7 +70,7 @@ The following ROM features are currently missing:
| :----------------: | :------: | :------------------------------------------------: |
| VIC-II | DONE | |
| 80 columns, VDC | NOT DONE | |
-| 80 columns, Mega65 | NOT DONE | |
+| 80 columns, MEGA65 | PARTIAL | no windowing mode and C65/M65 extra keys support |
@@ -103,7 +103,7 @@ The following ROM features are currently missing:
| JiffyDOS | PARTIAL | LOAD needs improvement for better performance |
| DolphinDOS | DONE | |
| CIA burst mod | NOT DONE | |
-| Mega65 burst | NOT DONE | |
+| MEGA65 burst | NOT DONE | |
@@ -121,6 +121,17 @@ The following ROM features are currently missing:
+## MEGA65 storage
+
+
+
+| Driver | Status | Remarks |
+| :----------------: | :------: | :-------------------------------------------------------------------------: |
+| internal floppy | NOT DONE | try to reuse https://github.com/commanderx16/x16-rom/tree/master/dos |
+| SD card access | NOT DONE | tryy to reuse https://github.com/commanderx16/x16-rom/tree/master/dos/fat32 |
+
+
+
## RS-232
* modems (telephone, WiFi)
diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom
index 447fd20d..fbaa3d1d 100644
Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ
diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom
index 5ae0f03b..ab9365d2 100644
Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ
diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom
index 9a23705a..990b2455 100644
Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ
diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom
index 76f62af3..67f8e1ac 100644
Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ
diff --git a/bin/mega65.rom b/bin/mega65.rom
index 643e1484..a80de589 100644
Binary files a/bin/mega65.rom and b/bin/mega65.rom differ
diff --git a/bin/mega65_pxlfont.rom b/bin/mega65_pxlfont.rom
index 92655da7..3f2626dd 100644
Binary files a/bin/mega65_pxlfont.rom and b/bin/mega65_pxlfont.rom differ
diff --git a/doc/Development.md b/doc/Development.md
index 29655ae6..5f06dd42 100644
--- a/doc/Development.md
+++ b/doc/Development.md
@@ -18,16 +18,16 @@ Most important: always test your software on the original ROMs too. If your code
Please, do not use any internal/unofficial Open ROMs API. They WILL change in an incompatible way, you may believe me. Using unofficial API of the original ROMs is OK if the routine is marked as supported in the [implementation status](../STATUS.md) document.
-### Compatibility with Open ROMs for Mega65
+### Compatibility with Open ROMs for MEGA65
-The Mega65 Open ROMs build aims to provide a C64-compatible memory map in range `$00000-$0FFFF`. For `$10000` and above, everything is still subject to change.
+The MEGA65 Open ROMs build aims to provide a C64-compatible memory map in range `$00000-$0FFFF`. For `$10000` and above, everything is still subject to change.
-Please note, that certain ROM routines are moved to additional Mega65 ROM area (2x8KB is not enough to implement full ROM functionality and additional features) - original locations contain just short compatibility code which remaps memory, calls the real routine, and restores default mapping (that means all blocks unmapped). This shouldn't be a problem for original C64 software, but can make a difference for Mega65-aware code; thus, please follow these simple rules:
+Please note, that certain ROM routines are moved to additional MEGA65 ROM area (2x8KB is not enough to implement full ROM functionality and additional features) - original locations contain just short compatibility code which remaps memory, calls the real routine, and restores default mapping (that means all blocks unmapped). This shouldn't be a problem for original C64 software, but can make a difference for MEGA65-aware code; thus, please follow these simple rules:
- do not call ROM routines with .B set to anything other than 0 (and .B set to 0x40 or above is a receipe for disaster!)
- be aware that ROM routines may restore the default memory mapping by means of MAP/EOM
-Open ROMs interrupt handlers do not touch the ROM mapping, range `0x4000-0xBFFF` can be freely mapped without disabling IRQ or NMI. The .Z register is mostly safe to use too - some routines might use it, but they will alwayys restore it's previous state. Please be aware, that for maximum compatibility our IRQ/NMI handlers DO NOT store/restore .Z register.
+Open ROMs interrupt handlers do not touch the ROM mapping, range `0x4000-0xBFFF` can be freely mapped without disabling IRQ or NMI. The .Z register is mostly safe to use too - some routines might use it, but they will always restore it's previous state. Please be aware, that for maximum compatibility our IRQ/NMI handlers DO NOT store/restore .Z register.
### API extensions
@@ -63,10 +63,11 @@ Bits 3 and 4 are extension to the original variable, compatible with the C128 RO
Before modifying NMI vector, set it's high byte to 0. The ROM routine considers such address invalid and won't try to call the custom code, thus preventing a crash if interrupt happens in the worst possible moment.
-#### Mega65 native mode
+#### MEGA65 native mode
-Mega65 build starts in legacy mode, which is intended to be reasonably compatible with the C64 ROMs. However, a native Mega65 mode is planned too, to make it easier to utilise extra features of this machine. Soo far the following has been done:
+MEGA65 native mode imlementation has started. Important changes so far:
+- Uses VIC-IV features to implement 80-column screen mode; the $0400-$07FF area is utilized by ROM to provide additional features.
- Slightly different chargen. On C64 machines pressing C= + G or C= + M key combinations produces the same visual result as C= + H or C= + N, respectively - despite keycap printing suggests they should produce tinner bars. This was intentional change in the C64 ROMs (compared to VIC-20), to prevent colour problems on 80s era TVs. Screen font used in the legacy mode duplicates this change, but the font intended for native mode has this change reverted back. Additionally, the π sign is available for lower/upper case set too.
## Tinkering with Open ROMs
@@ -86,7 +87,7 @@ List of the most important make targets:
| `test` | builds the 'custom' configuration, launches it using VICE emulator |
| `test_generic` | builds the default ROMs, for generic C64/C128, launches using VICE |
| `test_generic_x128` | as above, but launches C128 emulator instead |
-| `test_mega65` | builds the Mega65 ROM, launches it using XEMU emulator |
+| `test_mega65` | builds the MEGA65 ROM, launches it using XEMU emulator |
| `test_ultimate64` | builds the Ultimate 64 configuration, launches it using VICE emulator |
| `test_hybrid` | builds a hybrid ROM (Open ROMs Kernal + original BASIC), launches it using VICE |
| `test_testing` | builds a rather odd testing configuration, launches it using VICE emulator |
@@ -158,7 +159,7 @@ This can be found in a private (internal) vector table of `KERNAL_1` segment of
// #LAYOUT# * * #IGNORE
```
-This is used for memory mapping helper routines, which are only needed for Mega65 build. They will be placed in `KERNAL_0` segment in such case. And the last example:
+This is used for memory mapping helper routines, which are only needed for MEGA65 build. They will be placed in `KERNAL_0` segment in such case. And the last example:
```
// #LAYOUT# STD * #TAKE
@@ -167,7 +168,7 @@ This is used for memory mapping helper routines, which are only needed for Mega6
// #LAYOUT# * * #IGNORE
```
-This is for the routine, that on Mega65 goes to `KERNAL_1` segment, but can still be transparently called using fixed location in `KERNAL_0` segment. The code might, for example, look this way:
+This is for the routine, that on MEGA65 goes to `KERNAL_1` segment, but can still be transparently called using fixed location in `KERNAL_0` segment. The code might, for example, look this way:
```
ROUTINE_NAME:
@@ -187,6 +188,10 @@ ROUTINE_NAME:
Last, but not least - the `#TAKE-HIGH` is intended to be used for BASIC routines, which should still be available after the main BASIC ROM is banked out.
+### MEGA65 computer-based DOS
+
+TODO
+
### CPU-specific optimizations
TODO
diff --git a/doc/Extended-BASIC-TODO.md b/doc/Extended-BASIC-TODO.md
index 7f2ce4a7..347d79a4 100644
--- a/doc/Extended-BASIC-TODO.md
+++ b/doc/Extended-BASIC-TODO.md
@@ -1,7 +1,7 @@
# Planned BASIC features, when V2 compatibility is reached
-Ideas for the future, most of them suitable for Mega65 or other power machines only
+Ideas for the future, most of them suitable for MEGA65 or other power machines only
* sound support
* 2D graphics support
@@ -18,16 +18,15 @@ Ideas for the future, most of them suitable for Mega65 or other power machines o
* `CGOTO` and `CGOSUB` - computatiuonal versions, should accept expressions
* `LABEL`, `LGOTO` and `LGOSUB` - jump to label
* some kind of subroutines with local variable namespace, possibly loaded from disc (like in Warsaw Basic 3.2)
-* for Mega65 mode, move variables to a separate memory area, consider extending variable name length
+* for MEGA65 mode, move variables to a separate memory area, consider extending variable name length
* `←V` (verify from tape) - if Kernal is extended to offer this feature
* modulo function or opeerator
* `DPEEK`, `DPOKE`, `QPEEK`, `QPOKE` - 2/4 byte `PEEK` and `POKE` variants
-* all the functions/commands accepting memory addresses should be able to access the whole Mega65 memory
+* all the functions/commands accepting memory addresses should be able to access the whole MEGA65 memory
* ability to limit memory used by basic to standard 38K or to 46K (memory model switch)
* `XOR` operator
* `AUTO` - line auto numbering
* `RENUMBER` for chanign the line numbers
-* `IF ... THEN ... ELSE`, `BEGIN ... BEND`
* consider `BOOT` command
* possibly some commands for creating menus and dialog boxes
* more configurable `INPUT`
@@ -38,10 +37,8 @@ Ideas for the future, most of them suitable for Mega65 or other power machines o
* `DELETE` command to delete several BASIC lines, as in BASIC V10
* `FOR` loop should accept integer variable as index
* `FETCH`, `STASH`, `SWAP` - REU support
-* `DMA` command for Mega65
+* `DMA` command for MEGA65
* geoRAM support
-* `GO 64` / `GO 65` should enable/disable C64 compatibility mode on Mega65
-* `NSYS` for Mega65 - native `SYS` for Mega65, should not switch to C64 compatibilty mode
* `DO ... LOOP`, `DO ... UNTIL`, `DO ... WHILE`, `EXIT`
* `SEEK#` to read-and-forget n bytes
* `RECORD#` command from BASIC V10
@@ -63,3 +60,8 @@ Ideas for the future, most of them suitable for Mega65 or other power machines o
* function to generate string of n duplicated characters
* function to retrieve fractional part of a number
* command to fill text screen area with a character, inverse screen area, scroll, or change fg/bg color of screen area
+
+# Features not planned
+
+* `ELSE` - it would have slown down the execution, can be easily substituted
+* `BEGIN ... BEND` - similarly, using these would hurt the performance
diff --git a/doc/Extended-BASIC.md b/doc/Extended-BASIC.md
index 42765376..3de5a66d 100644
--- a/doc/Extended-BASIC.md
+++ b/doc/Extended-BASIC.md
@@ -1,7 +1,7 @@
# Extended BASIC
-NOTE: Command syntax, behaviour details, and tokens are still subject to change! Currently the availability of some depends on the build configuration, in the future most (if not all) extended commands will be available only on machines with extended ROM, like the Mega65 or Ultimate 64.
+NOTE: Command syntax, behaviour details, and tokens are still subject to change! Currently the availability of some depends on the build configuration, in the future most (if not all) extended commands will be available only on machines with extended ROM, like the MEGA65 or Ultimate 64.
## DOS Wedge
@@ -35,7 +35,7 @@ Loads the file from tape. Depending on the configuration, it tries to load the f
Like above, but merges a BASIC program to the one already stored in memory.
-### `←H` (Mega65)
+### `←H` (MEGA65)
Launches a built-in tape head alignment tool. Destroys program in memory. Press `RUN/STOP` to terminate the tool.
@@ -59,7 +59,7 @@ Saves the binary data from the given memory area. NOTE: for now syntax differs f
## Additional BASIC commands - misc
-### `COLD` (Mega65)
+### `COLD` (MEGA65)
Resets the machine. In direct mode asks for confirmation first.
@@ -75,7 +75,7 @@ Tries to switch the machine back to 1 MHz operation mode.
Tries to restore program destroyed by the `NEW` command or a reset.
-### `MEM` (Mega65)
+### `MEM` (MEGA65)
Displays BASIC memory usage information:
* `TEXT` - size of BASIC program text, always at least 2 bytes are used
@@ -84,6 +84,10 @@ Displays BASIC memory usage information:
* `STRS` - bytes occupied by strings, also the ones belonging to arrays
* `FREE` - unused space
+### `SYSINFO` (MEGA65)
+
+Displays various system information.
+
### `CLEAR` (all)
Clears the screen content.
@@ -91,3 +95,15 @@ Clears the screen content.
### `DISPOSE` (all)
Runs the garbage collector - disposes outdated strings.
+
+### `GO SYS` (MEGA65)
+
+Same as `SYS`, but does not switch to C64 compatibility mode.
+
+### `GO 64`, `GO 65` (MEGA65)
+
+Switches machine to C64 compatibility mode or to MEGA65 native mode. Performs `CLR`
+
+### `IF MEGA65 THEN`, `IF MEGA65 GOTO` (MEGA65)
+
+Special check for running under MEGA65. The `MEGA65` string is not tokenized, therefore it will be listed properly even under original BASIC V2. `MEGA65` is not a variable here - it is still possible to normally use the `ME` variable.
diff --git a/doc/screenshot-demo.png b/doc/screenshot-demo-generic.png
similarity index 100%
rename from doc/screenshot-demo.png
rename to doc/screenshot-demo-generic.png
diff --git a/doc/screenshot-demo-mega65.png b/doc/screenshot-demo-mega65.png
new file mode 100644
index 00000000..3a836c17
Binary files /dev/null and b/doc/screenshot-demo-mega65.png differ
diff --git a/src/,,config_custom.s b/src/,,config_custom.s
index ad83a50a..da8d626c 100644
--- a/src/,,config_custom.s
+++ b/src/,,config_custom.s
@@ -22,7 +22,6 @@
#define CONFIG_BRAND_CUSTOM_BUILD
// #define CONFIG_BRAND_GENERIC
// #define CONFIG_BRAND_TESTING
-// #define CONFIG_BRAND_MEGA_65
// #define CONFIG_BRAND_ULTIMATE_64
.const CONFIG_CUSTOM_BRAND = @"CUSTOM BUILD"
@@ -61,7 +60,6 @@
#define CONFIG_TAPE_AUTODETECT
// #define CONFIG_TAPE_NO_KEY_SENSE
// #define CONFIG_TAPE_NO_MOTOR_CONTROL
-// #define CONFIG_TAPE_NO_ERROR_CORRECTION
// #define CONFIG_RS232_UP2400 // please keep disabled for now
// #define CONFIG_RS232_UP9600 // please keep disabled for now
@@ -134,7 +132,6 @@
// #define CONFIG_COLORS_BRAND
// #define CONFIG_BANNER_SIMPLE
#define CONFIG_BANNER_FANCY
-// #define CONFIG_BANNER_BRAND
#define CONFIG_SHOW_FEATURES
diff --git a/src/,,config_cx16.s b/src/,,config_cx16.s
index 61056fb2..a36527e9 100644
--- a/src/,,config_cx16.s
+++ b/src/,,config_cx16.s
@@ -21,7 +21,6 @@
#define CONFIG_BRAND_CUSTOM_BUILD
// #define CONFIG_BRAND_GENERIC
// #define CONFIG_BRAND_TESTING
-// #define CONFIG_BRAND_MEGA_65
// #define CONFIG_BRAND_ULTIMATE_64
.const CONFIG_CUSTOM_BRAND = @"FOR COMMANDER X16"
@@ -57,7 +56,6 @@
// #define CONFIG_TAPE_AUTODETECT
// #define CONFIG_TAPE_NO_KEY_SENSE
// #define CONFIG_TAPE_NO_MOTOR_CONTROL
-// #define CONFIG_TAPE_NO_ERROR_CORRECTION
// Multiple SID support
@@ -128,7 +126,6 @@
// #define CONFIG_COLORS_BRAND
// #define CONFIG_BANNER_SIMPLE
#define CONFIG_BANNER_FANCY
-// #define CONFIG_BANNER_BRAND
// #define CONFIG_SHOW_FEATURES
diff --git a/src/,,config_generic.s b/src/,,config_generic.s
index 391de569..49ba908e 100644
--- a/src/,,config_generic.s
+++ b/src/,,config_generic.s
@@ -21,7 +21,6 @@
#define CONFIG_BRAND_GENERIC
// #define CONFIG_BRAND_TESTING
-// #define CONFIG_BRAND_MEGA_65
// #define CONFIG_BRAND_ULTIMATE_64
@@ -55,7 +54,6 @@
#define CONFIG_TAPE_AUTODETECT
// #define CONFIG_TAPE_NO_KEY_SENSE
// #define CONFIG_TAPE_NO_MOTOR_CONTROL
-// #define CONFIG_TAPE_NO_ERROR_CORRECTION
// Multiple SID support
@@ -126,7 +124,6 @@
#define CONFIG_COLORS_BRAND
// #define CONFIG_BANNER_SIMPLE
#define CONFIG_BANNER_FANCY
-// #define CONFIG_BANNER_BRAND
#define CONFIG_SHOW_FEATURES
diff --git a/src/,,config_mega65.s b/src/,,config_mega65.s
index 1c9cdbf5..7a742ee2 100644
--- a/src/,,config_mega65.s
+++ b/src/,,config_mega65.s
@@ -12,18 +12,11 @@
-// Hardware platform and brand
+// Hardware platform
#define CONFIG_PLATFORM_COMMODORE_64
#define CONFIG_MB_MEGA_65
-// #define CONFIG_MB_ULTIMATE_64
-
-// #define CONFIG_BRAND_GENERIC
-// #define CONFIG_BRAND_TESTING
-#define CONFIG_BRAND_MEGA_65
-// #define CONFIG_BRAND_ULTIMATE_64
-
// Processor instruction set
@@ -55,7 +48,6 @@
#define CONFIG_TAPE_AUTODETECT
#define CONFIG_TAPE_NO_KEY_SENSE
#define CONFIG_TAPE_NO_MOTOR_CONTROL
-// #define CONFIG_TAPE_NO_ERROR_CORRECTION
// Multiple SID support
@@ -75,8 +67,8 @@
// #define CONFIG_LEGACY_SCNKEY
// #define CONFIG_KEYBOARD_C128
// #define CONFIG_KEYBOARD_C128_CAPS_LOCK
-#define CONFIG_KEYBOARD_C65 // untested
-#define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested
+// #define CONFIG_KEYBOARD_C65 // untested
+// #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested
// #define CONFIG_KEY_REPEAT_DEFAULT
// #define CONFIG_KEY_REPEAT_ALWAYS
#define CONFIG_KEY_FAST_SCAN
@@ -121,13 +113,11 @@
#define CONFIG_BCD_SAFE_INTERRUPTS
-// Eye candy
+// Built-in DOS configuration
-#define CONFIG_COLORS_BRAND
-// #define CONFIG_BANNER_SIMPLE
-// #define CONFIG_BANNER_FANCY
-#define CONFIG_BANNER_BRAND
-// #define CONFIG_SHOW_FEATURES
+.const CONFIG_UNIT_SDCARD = 0 // do not change, DOS is not implemented yet
+.const CONFIG_UNIT_FLOPPY = 0 // do not change, DOS is not implemented yet
+.const CONFIG_UNIT_RAMDISK = 0 // do not change, DOS is not implemented yet
// Debug options
diff --git a/src/,,config_testing.s b/src/,,config_testing.s
index b56027c3..24010994 100644
--- a/src/,,config_testing.s
+++ b/src/,,config_testing.s
@@ -21,7 +21,6 @@
// #define CONFIG_BRAND_GENERIC
#define CONFIG_BRAND_TESTING
-// #define CONFIG_BRAND_MEGA_65
// #define CONFIG_BRAND_ULTIMATE_64
@@ -55,7 +54,6 @@
// #define CONFIG_TAPE_AUTODETECT
// #define CONFIG_TAPE_NO_KEY_SENSE
// #define CONFIG_TAPE_NO_MOTOR_CONTROL
-#define CONFIG_TAPE_NO_ERROR_CORRECTION
// Multiple SID support
@@ -126,7 +124,6 @@
// #define CONFIG_COLORS_BRAND
#define CONFIG_BANNER_SIMPLE
// #define CONFIG_BANNER_FANCY
-// #define CONFIG_BANNER_BRAND
#define CONFIG_SHOW_FEATURES
diff --git a/src/,,config_ultimate64.s b/src/,,config_ultimate64.s
index b463c918..b2373db5 100644
--- a/src/,,config_ultimate64.s
+++ b/src/,,config_ultimate64.s
@@ -21,7 +21,6 @@
// #define CONFIG_BRAND_GENERIC
// #define CONFIG_BRAND_TESTING
-// #define CONFIG_BRAND_MEGA_65
#define CONFIG_BRAND_ULTIMATE_64
@@ -55,7 +54,6 @@
#define CONFIG_TAPE_AUTODETECT
// #define CONFIG_TAPE_NO_KEY_SENSE
// #define CONFIG_TAPE_NO_MOTOR_CONTROL
-// #define CONFIG_TAPE_NO_ERROR_CORRECTION
// Multiple SID support
@@ -126,7 +124,6 @@
#define CONFIG_COLORS_BRAND
// #define CONFIG_BANNER_SIMPLE
#define CONFIG_BANNER_FANCY
-// #define CONFIG_BANNER_BRAND
#define CONFIG_SHOW_FEATURES
diff --git a/src/aliases/,aliases_config.s b/src/aliases/,aliases_config.s
index ae1798de..18f9bb24 100644
--- a/src/aliases/,aliases_config.s
+++ b/src/aliases/,aliases_config.s
@@ -63,18 +63,21 @@
#if CONFIG_BRAND_TESTING
.eval selected++
#endif
-#if CONFIG_BRAND_MEGA_65
- .eval selected++
-#endif
#if CONFIG_BRAND_ULTIMATE_64
.eval selected++
#endif
+#if !CONFIG_MB_MEGA_65
.if (selected != 1) .error "Please select exactly one CONFIG_BRAND_* option"
-
-#if CONFIG_MB_MEGA_65 && !(CONFIG_BRAND_MEGA_65 || CONFIG_BRAND_TESTING || CONFIG_BRAND_CUSTOM_BUILD)
- .error "Please select brand either matching the CONFIG_MB_*, or a testing/custom one"
#endif
+#if CONFIG_MB_MEGA_65
+ .if (selected != 0) .error "Do not use CONFIG_BRAND_* options for MEGA65"
+#endif
+
+#if CONFIG_MB_MEGA_65 && CONFIG_SHOW_FEATURES
+ .if (selected != 0) .error "Do not use CONFIG_SHOW_FEATURES options for MEGA65"
+#endif
+
#if CONFIG_MB_ULTIMATE_64 && !(CONFIG_BRAND_ULTIMATE_64 || CONFIG_BRAND_TESTING || CONFIG_BRAND_CUSTOM_BUILD)
.error "Please select brand either matching the CONFIG_MB_*, or a testing/custom one"
#endif
@@ -110,10 +113,10 @@
// Check that memory model and ROM layout configurations is correct
{
#if ROM_LAYOUT_M65 && !CONFIG_CPU_M65_45GS02
- .error "Mega65 ROM layout requires CONFIG_CPU_M65_45GS02"
+ .error "MEGA65 ROM layout requires CONFIG_CPU_M65_45GS02"
#endif
#if ROM_LAYOUT_M65 && !CONFIG_MB_MEGA_65
- .error "Mega65 ROM layout requires CONFIG_MB_MEGA_65"
+ .error "MEGA65 ROM layout requires CONFIG_MB_MEGA_65"
#endif
.var selected = 0;
@@ -218,18 +221,17 @@
#if CONFIG_BANNER_FANCY
.eval selected++
#endif
-#if CONFIG_BANNER_BRAND
- .eval selected++
-#endif
+#if !CONFIG_MB_MEGA_65
.if (selected != 1) .error "Please select exactly one CONFIG_BANNER_* option"
-
-#if CONFIG_BANNER_BRAND && !CONFIG_BRAND_MEGA_65
- .error "CONFIG_BANNER_BRAND is not supported for your CONFIG_BRAND_*"
#endif
-#if CONFIG_MB_MEGA_65 && CONFIG_SHOW_PAL_NTSC
- .error "MEGA65 can switch PAL/NTSC during run-time, CONFIG_SHOW_PAL_NTSC makes no sense"
+#if CONFIG_MB_MEGA_65
+ .if (selected != 0) .error "Do not use CONFIG_BANNER_* options for MEGA65"
+#endif
+
+#if CONFIG_MB_MEGA_65 && CONFIG_COLORS_BRAND
+ .error "Do not use CONFIG_COLORS_BRAND options for MEGA65"
#endif
}
diff --git a/src/aliases/,aliases_cpu.s b/src/aliases/,aliases_cpu.s
index 3cf72b6a..7ea9898c 100644
--- a/src/aliases/,aliases_cpu.s
+++ b/src/aliases/,aliases_cpu.s
@@ -86,7 +86,7 @@
//
-// Memory mapping for C65 and Mega65
+// Memory mapping for C65 and MEGA65
//
#if HAS_OPCODES_4510
@@ -97,6 +97,16 @@
#endif
+//
+// Some additional 65C02 instructions
+//
+
+#if HAS_OPCODES_65C02
+
+.pseudocommand inc_a { .byte $1A }
+.pseudocommand dec_a { .byte $3A }
+
+#endif
//
// Some additional 65CE02 instructions
@@ -261,6 +271,101 @@
.byte $22, mod(arg, $100), floor(arg / $100)
}
+.pseudocommand jsr_ind_x addr
+{
+ .var arg = addr.getValue()
+ .byte $23, mod(arg, $100), floor(arg / $100)
+}
+
+
+// Others, taken from https://github.com/smnjameson/M65_KickAsm_PseudoCommands
+
+.const z = -999 // allows (base page),z addressing mode
+.const sy = -998 // allows (base page, s),y addressing mode
+.const AT_IZEROPAGEZ = 13 // adds a pseudo addressing mode
+.const AT_INDIRECTX = -5 // adds a pseudo addressing mode
+
+.function GetAdressingModeType(arg) {
+ .if(arg == AT_NONE) .return "AT_NONE"
+ .if(arg == AT_IMMEDIATE) .return "AT_IMMEDIATE"
+ .if(arg == AT_INDIRECT) .return "AT_INDIRECT"
+ .if(arg == AT_INDIRECTX) .return "AT_INDIRECTX"
+ .if(arg == AT_ABSOLUTE) .return "AT_ABSOLUTE"
+ .if(arg == AT_ABSOLUTEX) .return "AT_ABSOLUTEX"
+ .if(arg == AT_ABSOLUTEY) .return "AT_ABSOLUTEY"
+ .if(arg == AT_IZEROPAGEX) .return "AT_IZEROPAGEX"
+ .if(arg == AT_IZEROPAGEY) .return "AT_IZEROPAGEY"
+ .if(arg == AT_IZEROPAGEZ) .return "AT_IZEROPAGEZ"
+ .return arg
+}
+
+.pseudocommand cpz arg {
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type == AT_IMMEDIATE) {
+ .byte $C2, value
+ } else .if(type == AT_ABSOLUTE) {
+ .if(value <= $FF ) {
+ .byte $D4, value
+ } else {
+ .byte $DC, value
+ }
+ } else {
+ .error "Invalid adressingmode. 'cpz' doesn't support "+GetAdressingModeType(type)+" mode"
+ }
+}
+
+.pseudocommand lda arg {
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type != AT_IZEROPAGEZ) .error "':lda' only accepts AT_IZEROPAGEZ"
+ .if(value > $FF ) .error "':lda ($nn),z' requires zeropage address"
+ .byte $B2, value
+}
+
+.pseudocommand ldz arg
+{
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type == AT_IMMEDIATE) {
+ .byte $A3, value
+ } else .if(type == AT_ABSOLUTE) {
+ .byte $AB, value
+ } else .if(type == AT_ABSOLUTEX) {
+ .byte $BB, value
+ } else {
+ .error "Invalid adressingmode. 'ldz' doesn't support "+GetAdressingModeType(type)+" mode"
+ }
+}
+
+.pseudocommand sta arg {
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type != AT_IZEROPAGEZ) .error "':sta' only accepts AT_IZEROPAGEZ"
+ .if(value > $FF ) .error "':sta ($nn),z' requires zeropage address"
+ .byte $92, value
+}
+
+// Flat memory access support
+
+.pseudocommand lda_lp arg {
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type != AT_IZEROPAGEZ) .error "'lda_lp' only accepts AT_IZEROPAGEZ"
+ .if(value > $FF ) .error "'lda_lp' requires zeropage address"
+ nop
+ .byte $B2, value
+}
+
+.pseudocommand sta_lp arg {
+ .var value = arg.getValue()
+ .var type = arg.getType()
+ .if(type != AT_IZEROPAGEZ) .error "'sta_lp' only accepts AT_IZEROPAGEZ"
+ .if(value > $FF ) .error "'sta_lp' requires zeropage address"
+ nop
+ .byte $92, value
+}
+
#endif
diff --git a/src/aliases/,aliases_hardware.s b/src/aliases/,aliases_hardware.s
index f0096f81..ae0ae762 100644
--- a/src/aliases/,aliases_hardware.s
+++ b/src/aliases/,aliases_hardware.s
@@ -70,13 +70,6 @@
.label VIC_XSCAN = $D02F // C128 only
.label VIC_CLKRATE = $D030 // C128 only
-#endif
-
-#if CONFIG_MB_MEGA_65
-
- .label VIC_KEY = $D02F
- .label VIC_XPOS = $D050
-
#endif
// SID registers
@@ -190,9 +183,9 @@
.label C65_EXTKEYS_PR = $D607
.label C65_EXTKEYS_DDR = $D608
- .label M65_BADL_SLI = $D710
+#endif
-#else
+#if !CONFIG_MB_MEGA_65
// SuperCPU registers
diff --git a/src/aliases/,aliases_hardware_m65.s b/src/aliases/,aliases_hardware_m65.s
new file mode 100644
index 00000000..80cc491e
--- /dev/null
+++ b/src/aliases/,aliases_hardware_m65.s
@@ -0,0 +1,45 @@
+
+//
+// Names of hardware registers
+//
+// See https://github.com/MEGA65/mega65-core/blob/master/iomap.txt
+//
+
+
+#if CONFIG_MB_MEGA_65
+
+ // VIC-IV registers
+
+ .label VIC_KEY = $D02F
+ .label VIC_CTRLA = $D030
+ .label VIC_CTRLB = $D031
+
+ .label VIC_XPOS = $D050
+
+ .label VIC_CTRLC = $D054
+
+ .label VIC_CHARSTEP = $D058 // 2 bytes - logical characters per line
+
+ .label VIC_SRH = $D05D // - various flags, bit 7 = hot registers
+
+ .label VIC_SCRNPTR = $D060 // 4 bytes - pointer to start of screen memory
+ .label VIC_COLPTR = $D064 // 2 bytes - pointer to start of color memory
+
+ .label VIC_CHARPTR = $D068 // 3 bytes - pointer to start of character generator
+
+ // DMAgic
+
+ .label DMA_ADDRLSBTRIG = $D700
+ .label DMA_ADDRMSB = $D701
+ .label DMA_ADDRBANK = $D702
+ .label DMA_EN018B = $D703
+ .label DMA_ADDRMB = $D704
+ .label DMA_ETRIG = $D705
+ .label DMA_ADDRLSB = $D70E
+
+ // MISC registers
+
+ .label MISC_BOARDID = $D629 // board identification byte
+ .label MISC_EMU = $D710 // to enable badlines and slow interrupts
+
+#endif
diff --git a/src/aliases/,aliases_petscii_codes.s b/src/aliases/,aliases_petscii_codes.s
index 0156cfff..cde7575f 100644
--- a/src/aliases/,aliases_petscii_codes.s
+++ b/src/aliases/,aliases_petscii_codes.s
@@ -17,7 +17,7 @@
.const KEY_FLAG_VENDOR = %00000010
.const KEY_FLAG_CTRL = %00000100
-#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65
+#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
.const KEY_FLAG_ALT = %00001000
#if CONFIG_KEYBOARD_C128_CAPS_LOCK || CONFIG_KEYBOARD_C65_CAPS_LOCK
.const KEY_CAPS_LOCK = %00010000
@@ -25,27 +25,35 @@
.const KEY_FLAG_NO_SCRL = %00100000 // Open ROMs unofficial
#endif
-// Note - the following PETSCII codes are currently unassigned, can be used for further extensions:
-//
-// $01, $02, $04, $06, $0A, $0B, $0C, $0F, $18, $82
+// Note - the following PETSCII codes are currently unassigned, can be used for further extensions: $01, $04, $06, ($80 ?)
.const KEY_NA = $00 // to indicate that no key is presed
+
// PETSCII codes for our extended screen editor
-.const KEY_TAB_FW = $8F // CTRL+>, TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII
-.const KEY_TAB_BW = $80 // CTRL+<, SHIFT+TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII
+.const KEY_C64_TAB_FW = $8F // CTRL+>, TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove?
+.const KEY_C64_TAB_BW = $80 // CTRL+<, SHIFT+TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove?
// PETSCII codes for certain C128 and C65 functionalities
-#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65
-.const KEY_BELL = $07 // no key, originally CTRL+G // XXX implement BELL
+#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
+.const KEY_BELL = $07 // no key, originally CTRL+G // XXX implement, add to C65 keyboard matrix
.const KEY_ESC = $1B
#endif
+#if CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
+.const KEY_TAB = $09 // XXX add to C65 keyboard matrix
+.const KEY_LINE_FEED = $0A // XXX add to C65 keyboard matrix
+.const KEY_TAB_SET_CLR = $18 // XXX add to C65 keyboard matrix
+.const KEY_UNDERLINE_ON = $02 // XXX add to C65 keyboard matrix
+.const KEY_UNDERLINE_OFF = $82 // XXX add to C65 keyboard matrix
+.const KEY_FLASHING_ON = $0F // XXX add to C65 keyboard matrix
+.const KEY_FLASHING_OFF = $8F // XXX add to C65 keyboard matrix
+#endif
// PETSCII codes for programmable keys
@@ -61,7 +69,7 @@
.const KEY_F7 = $88
.const KEY_F8 = $8C
-#if CONFIG_KEYBOARD_C65
+#if CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
.const KEY_F9 = $10
.const KEY_F10 = $15
.const KEY_F11 = $16
@@ -70,8 +78,8 @@
.const KEY_F14 = $1A
#endif
-#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65
-.const KEY_HELP = $84 // normally C65 only, also used for our C128 support
+#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
+.const KEY_HELP = $84
#endif
@@ -109,10 +117,14 @@
// PETSCII codes for case toggle
-.const KEY_SHIFT_ON = $09 // no key
-.const KEY_SHIFT_OFF = $08 // no key
-.const KEY_TXT = $0E // no key
-.const KEY_GFX = $8E // no key
+.const KEY_C64_SHIFT_ON = $09 // no key
+.const KEY_C64_SHIFT_OFF = $08 // no key
+#if CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65
+.const KEY_C65_SHIFT_OFF = $0B // no key
+.const KEY_C65_SHIFT_ON = $0C // no key
+#endif
+.const KEY_TXT = $0E // no key
+.const KEY_GFX = $8E // no key
// PETSCII codes for other non-printable characters
diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s
index ef37b7ac..09f1a861 100644
--- a/src/aliases/,aliases_ram_lowmem.s
+++ b/src/aliases/,aliases_ram_lowmem.s
@@ -103,11 +103,7 @@
.label PTR1 = $9E // for tape support, counter of errorneous bytes
.label PTR2 = $9F // for tape support, counter for errorneous bytes correction
.label TIME = $A0 // $A0-$A2 jiffy clock
-#if !CONFIG_IEC_JIFFYDOS && !CONFIG_IEC_DOLPHINDOS && !CONFIG_IEC_BURST_CIA1 && !CONFIG_IEC_BURST_CIA2 && !CONFIG_IEC_BURST_MEGA_65
- .label TSFCNT = $A3 // temporary variable for tape and IEC, [!] our usage differs
-#else
- .label IECPROTO = $A3 // -- WIP -- [!] 0 = normal, 1 = JiffyDOS, >= $80 for unknown
-#endif
+ .label IECPROTO = $A3 // [!] IEC or pseudo-IEC protocol, >= $80 for unknown; originally named TSFCNT
.label TBTCNT = $A4 // temporary variable for tape and IEC, [!] our usage probably differs in details
.label CNTDN = $A5 // -- NOT IMPLEMENTED --
.label BUFPNT = $A6 // -- NOT IMPLEMENTED --
@@ -151,7 +147,7 @@
.label BLNCT = $CD // cursor blink countdown
.label GDBLN = $CE // cursor saved character
.label BLNON = $CF // cursor visibility flag
- .label CRSW = $D0 // whether to input from screen or keyboard
+ .label CRSW = $D0 // whether to input from screen or keyboard (if from screen, stores input offset)
.label PNT = $D1 // $D1-$D2 pointer to the current screen line
.label PNTR = $D3 // current screen X position (logical column), 0-79
.label QTSW = $D4 // quote mode flag
@@ -290,6 +286,25 @@
// $3FC $3FC-$3FF -- UNUSED -- free for user software
+//
+// Definitions for extended IEC functionality
+//
+
+ .const IEC_NORMAL = 0 // has to be 0, always!
+#if CONFIG_IEC_JIFFYDOS
+ .const IEC_JIFFY = 1 // has to be 1, always!
+#endif
+#if CONFIG_IEC_DOLPHINDOS
+ .const IEC_DOLPHIN = 2
+#endif
+#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || ROM_LAYOUT_M65
+ .const IEC_BURST = 3
+#endif
+#if ROM_LAYOUT_M65
+ .const IEC_ROMDOS = 4
+#endif
+
+
//
// Definitions for tape functionality
//
diff --git a/src/aliases/,aliases_ram_lowmem_m65.s b/src/aliases/,aliases_ram_lowmem_m65.s
new file mode 100644
index 00000000..c109804e
--- /dev/null
+++ b/src/aliases/,aliases_ram_lowmem_m65.s
@@ -0,0 +1,76 @@
+// #LAYOUT# M65 * #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Names of ZP and low memory locations for the native MEGA65 mode
+//
+
+
+ //
+ // Page 0 - reused LDTB1 and USER
+ //
+
+ .label M65_TMP__K1 = $D9 // $D9 -- UNUSED -- temporary value for various Kernal routines
+ .label M65_LPNT_BAS1 = $DA // $DA-$DD 4-byte pointer for temporary usage within BASIC
+ .label M65_LPNT_BAS2 = $DE // $DE-$E1 4-byte pointer for temporary usage within BASIC
+ .label M65_LPNT_SCR = $E2 // $E2-$E5 4-byte pointer for temporary usage within BASIC and screen editor
+ // E6 reserved for BASIC error handling routines, also in native mode
+ .label M65_MAGICSTR = $E7 // $E7-$E9 if equals 'M65' it means we are in native mode
+ // EA reserved for BASIC error handling routines, also in native mode
+ .label M65_LPNT_IRQ = $EB // $EB-$EE 4-byte pointer for temporary usage within interrupts
+ .label M65_LPNT_KERN = $EF // $EF-$F3 4-byte pointer for temporary usage by KERNAL
+ .label M65_TMP__K2 = $F4 // $F4 -- UNUSED -- temporary value for various Kernal routines
+
+ //
+ // Page 0 - other reused values
+ //
+
+ .label M65__TXTROW = TBLX // screen row
+ .label M65__TXTCOL = PNTR // screen column
+ .label M65__SCRINPUT = LSXP // pointer to the screen input, within the screen segment
+
+ //
+ // Pages 4-7 - reused screen memory
+ //
+
+ // $400-$57F - reserved for BASIC
+
+ // $400-$57F -- UNUSED -- reserved for BASIC
+
+ // $580-$5FF - reserved for KERNAL
+
+ .label M65_SCRSEG = $580 // $580-$581 segment address (2 higher bytes) of the screen memory
+ .label M65_SCRBASE = $582 // $582-$583 first byte of screen memory
+ .label M65_SCRGUARD = $584 // $584-$585 last byte of screen memory + 1 XXX is it needed?
+ .label M65_COLGUARD = $586 // $586-$587 last byte of colour memory + 1
+ .label M65_COLVIEW = $588 // $588-$589 first byte of color memory viewport
+ .label M65_COLVIEWMAX = $58A // $58A-$58B largest allowed value of M65_COLVIEW
+ .label M65_SCRMODE = $58C // 0 = 40x25, 1 = 80x25, 2 = 80x50
+ .label M65_SCRWINMODE = $58D // $00 = normal mode, $FF = window enabled
+ .label M65_TXTWIN_X0 = $58E // text window - top-left X coordinate, starting from 0
+ .label M65_TXTWIN_Y0 = $58F // text window - top-left Y coordinate, starting from 0
+ .label M65_TXTWIN_X1 = $590 // text window - bottom-right X coordinate + 1
+ .label M65_TXTWIN_Y1 = $591 // text window - bottom-right Y coordinate + 1
+ .label M65_TXTROW_OFF = $592 // $592-$593 offset to the current text row from the viewport start
+ .label M65_SCRCOLMAX = $594 // maximum allowed column
+ // $595-$5EB -- UNUSED --
+ .label M65_DMAGIC_LIST = $5EF // $5EF-$5FF reserved for DMAgic list, 17 bytes
+ .label M65_RS232_INBUF = $600 // $600-$6FF -- reserved for RS-232 input buffer --
+ .label M65_RS232_OUTBUF = $700 // $700-$7FF -- reserved for RS-232 output buffer --
+
+ //
+ // Addresses for configuring the DMA job
+ //
+
+ .label M65_DMAJOB_SIZE_0 = M65_DMAGIC_LIST + 7
+ .label M65_DMAJOB_SIZE_1 = M65_DMAGIC_LIST + 8
+
+ .label M65_DMAJOB_SRC_0 = M65_DMAGIC_LIST + 9
+ .label M65_DMAJOB_SRC_1 = M65_DMAGIC_LIST + 10
+ .label M65_DMAJOB_SRC_2 = M65_DMAGIC_LIST + 11
+ .label M65_DMAJOB_SRC_3 = M65_DMAGIC_LIST + 2
+
+ .label M65_DMAJOB_DST_0 = M65_DMAGIC_LIST + 12
+ .label M65_DMAJOB_DST_1 = M65_DMAGIC_LIST + 13
+ .label M65_DMAJOB_DST_2 = M65_DMAGIC_LIST + 14
+ .label M65_DMAJOB_DST_3 = M65_DMAGIC_LIST + 4
diff --git a/src/aliases/,aliases_ram_over64K_m65.s b/src/aliases/,aliases_ram_over64K_m65.s
new file mode 100644
index 00000000..0c49297d
--- /dev/null
+++ b/src/aliases/,aliases_ram_over64K_m65.s
@@ -0,0 +1,24 @@
+// #LAYOUT# M65 * #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+ // XXX target High RAM memory map concept - TODO: update current code
+
+ // $10000-$17FFF (32KB) - reserved for DOS
+ // $18000-$18FFF (4KB) - chargen copied to RAM, to allow character redefinition
+
+.const MEMCONF_CHRBASE = $8000
+
+ // $19000-$1B7FF (10KB) - reserved for virtual text screen, 80x128
+
+.const MEMCONF_SCRBASE = $9000
+.const MEMCONF_SCRROWS = 128
+
+ // $1B800-$1DFFF (10KB) - reserved for a color RAM backup when switchin between text/graphics modes
+ // (4KB) - reserved for sprites
+ // (2KB) - reserved for future use
+ // (2KB) - color RAM mirror, not useable
+ // $20000-$2FFFF (64KB) - ROM, the essential part
+ // $30000-$4FFFF (64KB) - ROM, additions
+ // $50000-$57FFF (32KB) - reserved for graphics screen
+ // $58000-... - extended BASIC variables, RAM disk, etc.
diff --git a/src/basic/,imports.s b/src/basic/,imports.s
index 6af1d667..86959543 100644
--- a/src/basic/,imports.s
+++ b/src/basic/,imports.s
@@ -51,3 +51,13 @@
#endif
.label filename_any = KERNAL().filename_any
+
+.label SELDEV = KERNAL().SELDEV
+
+#if ROM_LAYOUT_M65
+.label M65_MODEGET = KERNAL().M65_MODEGET
+.label M65_MODESET = KERNAL().M65_MODESET
+.label M65_SLOW = KERNAL().M65_SLOW
+.label M65_FAST = KERNAL().M65_FAST
+.label M65_SETWIN_Y = KERNAL().M65_SETWIN_Y
+#endif
diff --git a/src/basic/assets/packed_keywords_03.s b/src/basic/assets/packed_keywords_03.s
new file mode 100644
index 00000000..10edc998
--- /dev/null
+++ b/src/basic/assets/packed_keywords_03.s
@@ -0,0 +1,12 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# M65 BASIC_1 #TAKE
+// #LAYOUT# X16 BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+#if ROM_LAYOUT_M65
+
+packed_freq_keywords_03:
+
+ put_packed_freq_keywords_03()
+
+#endif
diff --git a/src/basic/assets/startup_banner.s b/src/basic/assets/startup_banner.s
new file mode 100644
index 00000000..d1096c4f
--- /dev/null
+++ b/src/basic/assets/startup_banner.s
@@ -0,0 +1,56 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# X16 BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Startup banner, to be displayed during cold start
+//
+
+.encoding "petscii_upper"
+
+
+.macro BANNER_TEXT() {
+
+#if CONFIG_BRAND_CUSTOM_BUILD
+ .text "OPEN ROMS "
+ .text CONFIG_CUSTOM_BRAND
+#elif CONFIG_BRAND_GENERIC
+ .text "OPEN ROMS GENERIC BUILD"
+#elif CONFIG_BRAND_TESTING
+ .text "OPEN ROMS TESTING BUILD"
+#elif CONFIG_BRAND_ULTIMATE_64
+ .text "OPEN ROMS FOR ULTIMATE 64"
+#endif
+
+}
+
+startup_banner:
+
+#if CONFIG_BANNER_SIMPLE
+
+ .text " "
+ BANNER_TEXT()
+ .byte $00
+
+#elif CONFIG_BANNER_FANCY
+
+ BANNER_TEXT()
+ .byte $00
+
+rainbow_logo:
+
+{
+ .var SET_COLOR_0 = $05
+ .var SET_COLOR_1 = $1C
+ .var SET_COLOR_2 = $9E
+ .var SET_COLOR_3 = $1E
+ .var SET_COLOR_4 = $9F
+
+ .byte SET_COLOR_1, $12, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $0D
+ .byte SET_COLOR_2, $12, $A4, $A4, $A4, $A4, $A4, $A4, $0D
+ .byte SET_COLOR_3, $12, $A4, $A4, $A4, $A4, $A4, $0D
+ .byte SET_COLOR_4, $12, $A4, $A4, $A4, $A4, $92
+ .byte SET_COLOR_0, $00
+}
+
+#endif
diff --git a/src/basic/init/startup_banner.s b/src/basic/assets/startup_banner_m65.s
similarity index 50%
rename from src/basic/init/startup_banner.s
rename to src/basic/assets/startup_banner_m65.s
index 68fb173a..a09193ed 100644
--- a/src/basic/init/startup_banner.s
+++ b/src/basic/assets/startup_banner_m65.s
@@ -1,6 +1,4 @@
-// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 BASIC_1 #TAKE
-// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
@@ -10,96 +8,33 @@
.encoding "petscii_upper"
-.macro BANNER_TEXT() {
-
-#if CONFIG_BRAND_CUSTOM_BUILD
- .text "OPEN ROMS "
- .text CONFIG_CUSTOM_BRAND
-#elif CONFIG_BRAND_GENERIC
- .text "OPEN ROMS GENERIC BUILD"
-#elif CONFIG_BRAND_TESTING
- .text "OPEN ROMS TESTING BUILD"
-#elif CONFIG_BRAND_MEGA_65
- .text "OPEN ROMS FOR MEGA65"
-#elif CONFIG_BRAND_ULTIMATE_64
- .text "OPEN ROMS FOR ULTIMATE 64"
-#endif
-
-}
-
startup_banner:
-#if CONFIG_BANNER_SIMPLE
+ // Fancy MEGA65 banner - from Retrofan, slightly tweaked
- .text " "
- BANNER_TEXT()
- .byte $00
-#elif CONFIG_BANNER_FANCY
+ // remove unneeded $1F's (blue) and $9A's (light blue)
- BANNER_TEXT()
- .byte $00
-rainbow_logo:
-
-{
-#if CONFIG_COLORS_BRAND && CONFIG_BRAND_MEGA_65
-
- .var SET_COLOR_0 = $05
- .var SET_COLOR_1 = $9A
- .var SET_COLOR_2 = $1E
- .var SET_COLOR_3 = $9E
- .var SET_COLOR_4 = $96
-
-#else
-
- .var SET_COLOR_0 = $05
- .var SET_COLOR_1 = $1C
- .var SET_COLOR_2 = $9E
- .var SET_COLOR_3 = $1E
- .var SET_COLOR_4 = $9F
-
-#endif
-
- .byte SET_COLOR_1, $12, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $0D
- .byte SET_COLOR_2, $12, $A4, $A4, $A4, $A4, $A4, $A4, $0D
- .byte SET_COLOR_3, $12, $A4, $A4, $A4, $A4, $A4, $0D
- .byte SET_COLOR_4, $12, $A4, $A4, $A4, $A4, $92
- .byte SET_COLOR_0, $00
-}
-
-#if !CONFIG_BRAND_CUSTOM_BUILD
-
-pre_revision_string:
-
- .text "RELEASE "
- .byte $00
-
-#endif // no CONFIG_BRAND_CUSTOM_BUILD
-
-#elif CONFIG_BANNER_BRAND && CONFIG_BRAND_MEGA_65
-
- // Fancy Mega65 banner - from Retrofan, slightly tweaked
-
- .byte $9A, $12, $20, $20, $7F, $A9, $20, $20, $1F, $20, $9A, $20, $20, $20, $20, $1F
- .byte $20, $9A, $A9, $20, $20, $20, $92, $A1, $1F, $12, $20, $9A, $A9, $20, $20, $20
- .byte $7F, $1F, $20, $20, $9A, $A3, $A3, $A3, $A3, $A3, $A3, $A3, $1F
+ .byte $9A, $12, $20, $20, $7F, $A9, $20, $20, $92, $20, $12, $20, $20, $20, $20, $92
+ .byte $20, $12, $A9, $20, $20, $20, $92, $A1, $20, $12, $A9, $20, $20, $20, $7F, $92
+ .byte $20, $20, $12, $A3, $A3, $A3, $A3, $A3, $A3, $A3
.byte $0D
.byte $9A, $12, $20, $20, $20, $20, $20
- .byte $20, $1F, $20, $9A, $20, $20, $92, $A2, $bb, $1F, $12, $20, $9A, $20, $20, $92
- .byte $Ac, $A2, $A2, $1F, $12, $20, $9A, $20, $20, $1F, $20, $9A, $20, $20, $1F, $20
- .byte $20, $1e, $A3, $A3, $A3, $A3, $A3, $A3, $1F
+ .byte $20, $92, $20, $12, $20, $20, $92, $A2, $BB, $92, $20, $12, $20, $20, $92, $AC
+ .byte $A2, $A2, $20, $9A, $12, $20, $20, $92, $20, $12, $20, $20, $92, $20, $20, $12
+ .byte $1E, $A3, $A3, $A3, $A3, $A3, $A3
.byte $0D
- .byte $9A, $12, $20, $20, $92, $7F, $A9, $12, $20, $20, $1F, $20, $9A, $20, $20, $A2
- .byte $92, $be, $1F, $12, $20, $9A, $20, $20, $92, $bc, $12, $20, $20, $1F, $20, $9A
- .byte $20, $20, $20, $20, $20, $1F, $20, $20, $9e, $A3, $A3, $A3, $A3, $A3, $1F
+ .byte $9A, $12, $20, $20, $92, $7F, $A9, $12, $20, $20, $92, $20, $12, $20, $20, $A2
+ .byte $92, $BE, $92, $20, $12, $20, $20, $92, $BC, $12, $20, $20, $92, $20, $12, $20
+ .byte $20, $20, $20, $20, $92, $20, $20, $12, $9E, $A3, $A3, $A3, $A3, $A3
.byte $0D
- .byte $9A, $12, $20, $20, $1F, $20, $20, $9A, $20, $20, $1F, $20, $9A, $20, $20, $20
- .byte $20, $1F, $20, $9A, $20, $20, $20, $20, $20, $1F, $20, $9A, $20, $20, $1F, $20
- .byte $9A, $20, $20, $1F, $20, $20, $96, $A3, $A3, $A3, $A3, $1F, $92
+ .byte $9A, $12, $20, $20, $92, $20, $20, $12, $20, $20, $92, $20, $12, $20, $20, $20
+ .byte $20, $92, $20, $12, $20, $20, $20, $20, $20, $92, $20, $12, $20, $20, $92, $20
+ .byte $12, $20, $20, $92, $20, $20, $12, $96, $A3, $A3, $A3, $A3, $1F, $92
.byte $0D, $0D, $05, $00
- // Fancy Mega65 banner - from Retrofan
+ // Fancy MEGA65 banner - from Retrofan
//
// .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20
// .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20
@@ -117,7 +52,7 @@ pre_revision_string:
// .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f
// .byte $92, $0D, $0D, $05, $00
- // Original Mega65 banner - supplied by Deft
+ // Original MEGA65 banner - supplied by Deft
//
// .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0
// .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0
@@ -134,16 +69,3 @@ pre_revision_string:
// .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F
// .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D
// .byte $0D,$05,$92,$00
-
-#if ROM_LAYOUT_M65
-
-text_mode_64:
-
- .text "LEGACY"
- .byte $11, $9D, $9D, $9D, $9D, $9D
- .text "MODE"
- .byte $00
-
-#endif
-
-#endif
diff --git a/src/basic/basic_commands/cmd__jumptable.s b/src/basic/basic_commands/cmd__jumptable.s
index 321ebb31..3f541ef8 100644
--- a/src/basic/basic_commands/cmd__jumptable.s
+++ b/src/basic/basic_commands/cmd__jumptable.s
@@ -55,14 +55,12 @@
cmd_tab, // XXX this token probably does not belong here
do_SYNTAX_error, // 'TO' is not a standalone command
do_SYNTAX_error, // 'FN' is not a standalone command
- cmd_spc, // XXX this token probably does not belong here
+ cmd_spc // XXX this token probably does not belong here
// 'THEN' ($A7) and 'STEP' ($A9) are not standalone commands
// 'NOT' ($A8) is an operator, not a command
- // $CB, but remapped to $A7
-
- cmd_go
+ // 'GO' ($CB) is handled separately
)
diff --git a/src/basic/basic_commands/cmd__unimplemented.s b/src/basic/basic_commands/cmd__unimplemented.s
index 18c9fb1c..9b76d5f6 100644
--- a/src/basic/basic_commands/cmd__unimplemented.s
+++ b/src/basic/basic_commands/cmd__unimplemented.s
@@ -21,8 +21,6 @@ cmd_input:
nop
cmd_read:
nop
-cmd_if:
- nop
cmd_gosub:
nop
cmd_return:
@@ -51,8 +49,6 @@ cmd_tab:
nop
cmd_spc:
nop
-cmd_go:
- nop
// Unimplemented tokens
diff --git a/src/basic/basic_commands/cmd_run_goto.s b/src/basic/basic_commands/cmd_go_goto_run.s
similarity index 50%
rename from src/basic/basic_commands/cmd_run_goto.s
rename to src/basic/basic_commands/cmd_go_goto_run.s
index 043862c3..5bfb7281 100644
--- a/src/basic/basic_commands/cmd_run_goto.s
+++ b/src/basic/basic_commands/cmd_go_goto_run.s
@@ -3,6 +3,77 @@
// #LAYOUT# * * #IGNORE
+cmd_go:
+
+ jsr fetch_character_skip_spaces
+ cmp #$A4 // 'TO' keyword
+ beq cmd_goto
+
+#if !ROM_LAYOUT_M65
+
+ // FALLTROUGH
+
+cmd_go_syntax_error:
+
+ jmp do_SYNTAX_error
+
+#else
+
+ cmp #$9E // 'SYS' keyword, for 'GO SYS'
+ beq_16 cmd_gosys
+
+ dew TXTPTR // unconsume character
+
+ // Fetch desired mode
+
+ jsr fetch_uint8
+
+ cmp #64
+ bne !+
+
+ // If in native mode - switch to C64 compatibilty
+
+ jsr M65_MODEGET
+ bcs cmd_go_rts
+
+ jsr helper_ask_if_sure
+ bcs_16 cmd_end
+ sec
+ jsr M65_MODESET // Carry set = switch to C64 mode
+ jmp_8 cmd_go_switchmode_clr_banner
+!:
+ cmp #65
+ bne_16 do_ILLEGAL_QUANTITY_error
+
+ // If in C64 compatibility mode - switch to native mode
+
+ jsr M65_MODEGET
+ bcc cmd_go_rts
+
+ jsr helper_ask_if_sure
+ bcs_16 cmd_end
+ jsr M65_MODESET // Carry clear = switch to M65 mode
+
+ // FALLTROUGH
+
+cmd_go_switchmode_clr_banner:
+
+ jsr do_clr
+
+ ldx CURLIN+1
+ inx
+ beq_16 INITMSG
+
+ lda #147
+ jmp JCHROUT
+
+cmd_go_rts:
+
+ rts
+
+
+#endif
+
cmd_run:
// RUN clears all variables
@@ -25,9 +96,15 @@ cmd_run:
cmd_goto:
// GOTO requires line number
+ // XXX in case of no parameter, go to line 0 - checked with original ROMs
+
jsr fetch_line_number
+#if !ROM_LAYOUT_M65
+ bcs cmd_go_syntax_error
+#else
bcs_16 do_SYNTAX_error
+#endif
// Check for direct mode
diff --git a/src/basic/basic_commands/cmd_if.s b/src/basic/basic_commands/cmd_if.s
new file mode 100644
index 00000000..7e3a4488
--- /dev/null
+++ b/src/basic/basic_commands/cmd_if.s
@@ -0,0 +1,40 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+cmd_if:
+
+#if ROM_LAYOUT_M65
+
+ jsr helper_if_mega65
+ bcc cmd_if_true
+
+#endif
+
+ // Calculate expression
+
+ jsr FRMEVL
+
+ // Check the result - either string size or floating point 0 vs non-0
+
+ lda FAC1_exponent
+ beq_16 cmd_rem
+
+ // FALLTROUGH
+
+cmd_if_true:
+
+ // Condition fulfilled - look for GOTO or THEN
+
+ jsr fetch_character_skip_spaces
+ cmp #$89 // 'GOTO'
+ beq_16 cmd_goto
+
+ cmp #$A7 // 'THEN'
+ bne_16 do_SYNTAX_error
+
+ pla
+ pla
+
+ jmp execute_statements
diff --git a/src/basic/basic_commands/cmd_rem.s b/src/basic/basic_commands/cmd_rem.s
index 3247ab0f..ea139303 100644
--- a/src/basic/basic_commands/cmd_rem.s
+++ b/src/basic/basic_commands/cmd_rem.s
@@ -7,6 +7,8 @@
cmd_rem:
+ // XXX do we need these PHA's?
+
pha
pha
jmp execute_statements_end_of_line
diff --git a/src/basic/basic_commands/cmd_sys.s b/src/basic/basic_commands/cmd_sys.s
index 01dcf833..f3e63e2c 100644
--- a/src/basic/basic_commands/cmd_sys.s
+++ b/src/basic/basic_commands/cmd_sys.s
@@ -3,15 +3,41 @@
// #LAYOUT# * * #IGNORE
+#if ROM_LAYOUT_M65
+
+cmd_gosys:
+
+ // NSYS requires an argument
+
+ jsr is_end_of_statement
+ bcs_16 do_SYNTAX_error
+ bra cmd_sys_nsys_common
+
+#endif
+
cmd_sys:
- jsr is_end_of_statement
- bcc !+
-
// SYS requires an argument
- jmp do_SYNTAX_error
-
-!:
+
+ jsr is_end_of_statement
+ bcs_16 do_SYNTAX_error
+
+#if ROM_LAYOUT_M65
+
+ // Make sure we are in C64 compatibility mode
+
+ jsr M65_MODEGET
+ bcs cmd_sys_nsys_common
+ sec
+ jsr M65_MODESET // set legacy C64 compatibility mode
+ jsr INITMSG_autoswitch
+
+ // FALLTROUGH
+
+cmd_sys_nsys_common:
+
+#endif
+
//
// XXX Temporary ugly hack to support 'SYS PI*656'
//
diff --git a/src/basic/basic_commands/helper_if_mega65_38K.s b/src/basic/basic_commands/helper_if_mega65_38K.s
new file mode 100644
index 00000000..fd93f63e
--- /dev/null
+++ b/src/basic/basic_commands/helper_if_mega65_38K.s
@@ -0,0 +1,52 @@
+// #LAYOUT# M65 BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+#if CONFIG_MEMORY_MODEL_38K
+
+helper_if_mega65:
+
+ // Injest all spaces
+
+ ldy #$00
+!:
+ lda (TXTPTR), Y
+ cmp #$20
+ bne !+
+ inw TXTPTR
+ bra !-
+!:
+
+ // Check for MEGA65 untokenized keyword
+
+ ldy #$05
+!:
+ lda (TXTPTR), Y
+ cmp str_mega65, Y
+ bne_16 helper_if_mega65_fail
+ dey
+ bpl !-
+
+ // Increment TXTPTR by 6
+
+ clc
+ lda TXTPTR+0
+ adc #$06
+ sta TXTPTR+0
+ bcc !+
+ inc TXTPTR+1
+!:
+ // Report successful check
+
+ clc
+ rts
+
+helper_if_mega65_fail:
+
+ sec
+ rts
+
+str_mega65:
+
+ .byte $4D, $45, $47, $41, $36, $35
+
+#endif
diff --git a/src/basic/basic_commands/helper_if_mega65_46K_50K.s b/src/basic/basic_commands/helper_if_mega65_46K_50K.s
new file mode 100644
index 00000000..24b76024
--- /dev/null
+++ b/src/basic/basic_commands/helper_if_mega65_46K_50K.s
@@ -0,0 +1,54 @@
+// #LAYOUT# M65 BASIC_0 #TAKE-HIGH
+// #LAYOUT# * * #IGNORE
+
+// This has to go $E000 or above - routine below banks out the main BASIC ROM!
+
+#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
+
+helper_if_mega65:
+
+ // Unmap BASIC lower ROM
+
+ lda #$26
+ sta CPU_R6510
+
+ // Injest all spaces
+
+ ldy #$00
+!:
+ lda (TXTPTR), Y
+ cmp #$20
+ bne !+
+ inw TXTPTR
+ bra !-
+!:
+
+ // Check for MEGA65 untokenized keyword
+
+ ldy #$05
+!:
+ lda (TXTPTR), Y
+ cmp str_mega65, Y
+ bne_16 remap_BASIC_sec_rts
+ dey
+ bpl !-
+
+ // Increment TXTPTR by 6
+
+ clc
+ lda TXTPTR+0
+ adc #$06
+ sta TXTPTR+0
+ bcc !+
+ inc TXTPTR+1
+!:
+ // Report successful check
+
+ jmp remap_BASIC_clc_rts
+
+str_mega65:
+
+ .byte $4D, $45, $47, $41, $36, $35
+
+
+#endif
diff --git a/src/basic/basic_commands/helper_load_init_param.s b/src/basic/basic_commands/helper_load_init_param.s
index 3e48bbdb..e070b2be 100644
--- a/src/basic/basic_commands/helper_load_init_param.s
+++ b/src/basic/basic_commands/helper_load_init_param.s
@@ -22,6 +22,6 @@ helper_load_init_params_no_VERCKB:
// Set default device, set secondary address to 0
- jsr select_device
+ jsr SELDEV
ldy #$00 // secondary address
jmp JSETFLS
diff --git a/src/basic/basic_commands_01/cmd__jumptable_01.s b/src/basic/basic_commands_01/cmd__jumptable_01.s
index 6e3f4f61..269ff014 100644
--- a/src/basic/basic_commands_01/cmd__jumptable_01.s
+++ b/src/basic/basic_commands_01/cmd__jumptable_01.s
@@ -9,8 +9,14 @@
.const command_01_list = List().add(
+#if CONFIG_MB_MEGA_65
+ M65_SLOW,
+ M65_FAST,
+#else
cmd_slow,
cmd_fast,
+#endif
+
cmd_old,
// NOTE! These commands are temporarily placed here, they should be a part of list 02!
diff --git a/src/basic/basic_commands_01/cmd_fast_slow.s b/src/basic/basic_commands_01/cmd_fast_slow.s
index e8b9ed5d..bd740ee3 100644
--- a/src/basic/basic_commands_01/cmd_fast_slow.s
+++ b/src/basic/basic_commands_01/cmd_fast_slow.s
@@ -5,23 +5,7 @@
#if CONFIG_MB_MEGA_65
- // Command implementation for Mega65
-
- // XXX - I think there are some bit-set instructions in 65CE02...
-
-cmd_slow:
-
- lda #$40
- skip_2_bytes_trash_nvz
-
- // FALLTROUGH
-
-cmd_fast:
-
- lda #$41
- sta CPU_D6510
- rts
-
+ // For MEGA65 Kernal routines are called directly
#elif CONFIG_MB_ULTIMATE_64
diff --git a/src/basic/basic_commands_02/cmd__jumptable_02.s b/src/basic/basic_commands_02/cmd__jumptable_02.s
index f554611f..32285618 100644
--- a/src/basic/basic_commands_02/cmd__jumptable_02.s
+++ b/src/basic/basic_commands_02/cmd__jumptable_02.s
@@ -22,7 +22,8 @@
// varstr_garbage_collect, // cmd_dispose
cmd_cold,
- cmd_mem
+ cmd_mem,
+ cmd_sysinfo
)
diff --git a/src/basic/basic_commands_02/cmd_sysinfo.s b/src/basic/basic_commands_02/cmd_sysinfo.s
new file mode 100644
index 00000000..094b6996
--- /dev/null
+++ b/src/basic/basic_commands_02/cmd_sysinfo.s
@@ -0,0 +1,145 @@
+// #LAYOUT# M65 * #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+#if SEGMENT_BASIC_0
+
+cmd_sysinfo:
+
+ jsr map_BASIC_1
+ jsr_ind VB1__cmd_sysinfo
+ jmp map_NORMAL
+
+#else
+
+cmd_sysinfo:
+
+ jsr print_return
+
+ // Print mode and build information
+
+ ldx #IDX__STR_SI_HEADER
+ jsr print_packed_misc_str
+
+ jsr M65_MODEGET
+ bcc !+
+
+ ldx #IDX__STR_SI_MODE64
+ skip_2_bytes_trash_nvz
+!:
+ ldx #IDX__STR_SI_MODE65
+ jsr print_packed_misc_str
+
+ ldx #IDX__STR_SI_HDR_REL
+ jsr print_packed_misc_str
+
+ lda #rom_revision_basic_string
+ jsr STROUT
+
+ jsr print_return
+
+ jsr M65_MODEGET
+ bcs print_sysinfo_video
+
+ jsr print_return
+
+ // FALLTROUGH
+
+print_sysinfo_banner:
+
+ // Print board type (information not accessible in native mode)
+
+ ldx #IDX__STR_SI_HDR_HW
+ jsr print_packed_misc_str
+
+ lda MISC_BOARDID
+ ldy #(__cmd_sysinfo_hw_ids_end - cmd_sysinfo_hw_ids - 1)
+!:
+ cmp cmd_sysinfo_hw_ids, y
+ beq !+
+ dey
+ bpl !-
+ ldy #(__cmd_sysinfo_hw_ids_end - cmd_sysinfo_hw_ids)
+!:
+ ldx cmd_sysinfo_hw_str, y
+ phx
+ jsr print_packed_misc_str
+ plx
+ cpx #IDX__STR_SI_HW_XX
+ bne !+
+
+ lda MISC_BOARDID
+ jsr print_hex_byte
+!:
+
+ // FALLTROUGH
+
+print_sysinfo_video:
+
+ // Print video system information
+
+ ldx #IDX__STR_SI_HDR_VID
+ jsr print_packed_misc_str
+
+ jsr JSCREEN
+
+ phy
+ lda #$00
+ jsr print_integer
+
+ lda #$58
+ jsr JCHROUT
+
+ ply
+ tya
+ tax
+ lda #$00
+ jsr print_integer
+
+ jsr print_space
+
+ ldx #IDX__STR_NTSC
+ lda TVSFLG
+ beq !+
+ ldx #IDX__STR_PAL
+!:
+ jsr print_packed_misc_str
+
+ // Print build featires information
+
+ ldx #IDX__STR_SI_FEATURES
+ jmp print_packed_misc_str
+
+
+
+cmd_sysinfo_hw_ids:
+
+ .byte $01
+ .byte $02
+ .byte $03
+ .byte $21
+ .byte $40
+ .byte $41
+ .byte $42
+ .byte $FD
+ .byte $FE
+
+__cmd_sysinfo_hw_ids_end:
+
+cmd_sysinfo_hw_str:
+
+ .byte IDX__STR_SI_HW_01
+ .byte IDX__STR_SI_HW_02
+ .byte IDX__STR_SI_HW_03
+ .byte IDX__STR_SI_HW_21
+ .byte IDX__STR_SI_HW_40
+ .byte IDX__STR_SI_HW_41
+ .byte IDX__STR_SI_HW_42
+ .byte IDX__STR_SI_HW_FD
+ .byte IDX__STR_SI_HW_FE
+ .byte IDX__STR_SI_HW_XX
+
+
+
+#endif
diff --git a/src/basic/basic_commands_03_m65/cmd__jumptable_03.s b/src/basic/basic_commands_03_m65/cmd__jumptable_03.s
new file mode 100644
index 00000000..4af16cb7
--- /dev/null
+++ b/src/basic/basic_commands_03_m65/cmd__jumptable_03.s
@@ -0,0 +1,17 @@
+// #LAYOUT# M65 BASIC_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Jumptable for BASIC commands with tokens prefixed by $03
+//
+
+.const command_03_list = List().add(
+
+ cmd_rem // XXX just for testing
+)
+
+
+command_03_jumptable:
+
+ // Note: 65C02 has the page boundary vector bug fixed!
+ put_jumptable(command_03_list)
diff --git a/src/basic/board_m65/4000.mega65_vectable_basic_1.s b/src/basic/board_m65/4000.mega65_vectable_basic_1.s
index 17f96e1b..20633a43 100644
--- a/src/basic/board_m65/4000.mega65_vectable_basic_1.s
+++ b/src/basic/board_m65/4000.mega65_vectable_basic_1.s
@@ -3,7 +3,7 @@
// #LAYOUT# * * #IGNORE
//
-// Definitions for communication with Mega65 segment BASIC_1 from BASIC_0
+// Definitions for communication with MEGA65 segment BASIC_1 from BASIC_0
//
@@ -13,20 +13,22 @@
// Label definitions
.label VB1__INITMSG = $4000 + 2 * 0
- .label VB1__LINKPRG = $4000 + 2 * 1
- .label VB1__tokenise_line = $4000 + 2 * 2
- .label VB1__list_single_line = $4000 + 2 * 3
- .label VB1__print_packed_error = $4000 + 2 * 4
- .label VB1__print_packed_misc_str = $4000 + 2 * 5
- .label VB1__do_new = $4000 + 2 * 6
- .label VB1__do_clr = $4000 + 2 * 7
- .label VB1__do_restore = $4000 + 2 * 8
- .label VB1__cmd_mem_cont = $4000 + 2 * 9
- .label VB1__prepare_direct_execution = $4000 + 2 * 10
- .label VB1__helper_ask_if_sure = $4000 + 2 * 11
+ .label VB1__INITMSG_autoswitch = $4000 + 2 * 1
+ .label VB1__LINKPRG = $4000 + 2 * 2
+ .label VB1__tokenise_line = $4000 + 2 * 3
+ .label VB1__list_single_line = $4000 + 2 * 4
+ .label VB1__print_packed_error = $4000 + 2 * 5
+ .label VB1__print_packed_misc_str = $4000 + 2 * 6
+ .label VB1__do_new = $4000 + 2 * 7
+ .label VB1__do_clr = $4000 + 2 * 8
+ .label VB1__do_restore = $4000 + 2 * 9
+ .label VB1__cmd_mem_cont = $4000 + 2 * 10
+ .label VB1__cmd_sysinfo = $4000 + 2 * 11
+ .label VB1__prepare_direct_execution = $4000 + 2 * 12
+ .label VB1__helper_ask_if_sure = $4000 + 2 * 13
#if CONFIG_DOS_WEDGE
- .label VB1__wedge_dos = $4000 + 2 * 12
+ .label VB1__wedge_dos = $4000 + 2 * 14
#endif
#else
@@ -34,6 +36,7 @@
// Vector table (Open ROMs private!)
.word INITMSG
+ .word INITMSG_autoswitch
.word LINKPRG
.word tokenise_line
.word list_single_line
@@ -43,6 +46,7 @@
.word do_clr
.word do_restore
.word cmd_mem_cont
+ .word cmd_sysinfo
.word prepare_direct_execution
.word helper_ask_if_sure
diff --git a/src/basic/board_m65/mega65_imports.s b/src/basic/board_m65/mega65_imports.s
index a9891af5..34ff2132 100644
--- a/src/basic/board_m65/mega65_imports.s
+++ b/src/basic/board_m65/mega65_imports.s
@@ -2,7 +2,7 @@
// #LAYOUT# * * #IGNORE
//
-// Definitions for calling Mega65 segments BASIC_0 and KERNAL_0 routines from BASIC_1
+// Definitions for calling MEGA65 segments BASIC_0 and KERNAL_0 routines from BASIC_1
//
#import "BASIC_0_combined.sym"
@@ -12,6 +12,7 @@
.label poke_via_OLDTXT = BASIC_0.proxy_B1_poke_via_OLDTXT
.label JCHROUT = BASIC_0.proxy_B1_JCHROUT
.label JCLALL = BASIC_0.proxy_B1_JCLALL
+.label plot_set = BASIC_0.proxy_B1_plot_set
#if CONFIG_DOS_WEDGE
.label JCLOSE = BASIC_0.proxy_B1_JCLOSE
.label JOPEN = BASIC_0.proxy_B1_JOPEN
@@ -20,10 +21,16 @@
.label JSETFLS = KERNAL_0.JSETFLS
.label JSETNAM = KERNAL_0.JSETNAM
.label JGETIN = KERNAL_0.JGETIN
-.label JCHKIN = KERNAL_0.JCHKIN
-.label JCHRIN = KERNAL_0.JCHRIN
+.label JCHKIN = BASIC_0.proxy_B1_JCHKIN
+.label JCHRIN = BASIC_0.proxy_B1_JCHRIN
.label JREADST = KERNAL_0.JREADST
-.label plot_set = KERNAL_0.plot_set
+.label JSCREEN = KERNAL_0.JSCREEN
+.label SELDEV = KERNAL_0.SELDEV
+.label M65_MODEGET = KERNAL_0.M65_MODEGET
+.label M65_SETWIN_XY = KERNAL_0.M65_SETWIN_XY
+.label M65_SETWIN_WH = KERNAL_0.M65_SETWIN_WH
+.label M65_SETWIN_Y = BASIC_0.proxy_B1_M65_SETWIN_Y
+.label M65_SETWIN_N = KERNAL_0.M65_SETWIN_N
.label init_oldtxt = BASIC_0.init_oldtxt
.label tmpstr_free_all_reset = BASIC_0.tmpstr_free_all_reset
.label rom_revision_basic_string = BASIC_0.rom_revision_basic_string
diff --git a/src/basic/board_m65/mega65_map_helpers.s b/src/basic/board_m65/mega65_map_helpers.s
index 2ed00bff..7c92e022 100644
--- a/src/basic/board_m65/mega65_map_helpers.s
+++ b/src/basic/board_m65/mega65_map_helpers.s
@@ -2,7 +2,7 @@
// #LAYOUT# * * #IGNORE
//
-// ROM mapping routines for Mega65
+// ROM mapping routines for MEGA65
//
// Available memory maps:
@@ -23,6 +23,6 @@ map_BASIC_1:
taz
lda #$20
- ldx #$C2 // 0x4000 <- map 16KB from 0x22000
+ ldx #$C2 // $4000 <- map 16KB from $22000
jmp map_end
diff --git a/src/basic/board_m65/mega65_proxies.s b/src/basic/board_m65/mega65_proxies.s
index 2891b466..afc9d6d9 100644
--- a/src/basic/board_m65/mega65_proxies.s
+++ b/src/basic/board_m65/mega65_proxies.s
@@ -2,13 +2,14 @@
// #LAYOUT# * * #IGNORE
//
-// Proxies for calling Mega65 segment BASIC_0 and KERNAL_0 routines from BASIC_1
+// Proxies for calling MEGA65 segment BASIC_0 and KERNAL_0 routines from BASIC_1
//
proxy_B1_peek_via_OLDTXT:
jsr map_NORMAL
+
#if CONFIG_MEMORY_MODEL_60K
.error "not implemented"
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
@@ -17,6 +18,7 @@ proxy_B1_peek_via_OLDTXT:
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
+!:
jmp map_BASIC_1
proxy_B1_poke_via_OLDTXT:
@@ -27,14 +29,14 @@ proxy_B1_poke_via_OLDTXT:
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
sta (OLDTXT),y
#endif
+!:
jmp map_BASIC_1
-
proxy_B1_JCLALL:
jsr map_NORMAL
jsr JCLALL
- jmp map_BASIC_1
+ jmp_8 !-
#if CONFIG_DOS_WEDGE
@@ -42,59 +44,69 @@ proxy_B1_JCLOSE:
jsr map_NORMAL
jsr JCLOSE
- jmp map_BASIC_1
-
+ jmp_8 !-
proxy_B1_JOPEN:
jsr map_NORMAL
jsr JOPEN
- jmp map_BASIC_1
+ jmp_8 !-
#endif
+proxy_B1_JCHKIN:
+
+ jsr map_NORMAL
+ jsr JCHKIN
+ jmp_8 !-
+
+proxy_B1_JCHRIN:
+
+ jsr map_NORMAL
+ jsr JCHRIN
+ jmp_8 !-
+
proxy_B1_JCHROUT:
jsr map_NORMAL
jsr JCHROUT
- jmp map_BASIC_1
+ jmp_8 !-
proxy_B1_print_hex_byte:
jsr map_NORMAL
jsr print_hex_byte
- jmp map_BASIC_1
+ jmp_8 !-
proxy_B1_print_integer:
jsr map_NORMAL
jsr print_integer
- jmp map_BASIC_1
-
+ jmp_8 !-
proxy_B1_print_return:
jsr map_NORMAL
jsr print_return
- jmp map_BASIC_1
-
+ jmp_8 !-
proxy_B1_print_space:
jsr map_NORMAL
jsr print_space
- jmp map_BASIC_1
+ jmp_8 !-
-
-#if CONFIG_SHOW_FEATURES
-
-proxy_B1_print_features:
+proxy_B1_plot_set:
jsr map_NORMAL
- jsr print_features
- jmp map_BASIC_1
+ jsr plot_set
+ jmp_8 !-
-#endif
+proxy_B1_M65_SETWIN_Y:
+
+ jsr map_NORMAL
+ jsr M65_SETWIN_Y
+ jmp_8 !-
#if CONFIG_DOS_WEDGE
@@ -102,18 +114,19 @@ proxy_B1_fetch_character:
jsr map_NORMAL
jsr fetch_character
- jmp map_BASIC_1
+ jmp_8 !+
proxy_B1_fetch_character_skip_spaces:
jsr map_NORMAL
jsr fetch_character_skip_spaces
- jmp map_BASIC_1
+ jmp_8 !+
proxy_B1_fetch_uint8:
jsr map_NORMAL
jsr fetch_uint8
+!:
jmp map_BASIC_1
proxy_B1_shell_main_loop:
diff --git a/src/basic/engine_editor/tokenise_line.s b/src/basic/engine_editor/tokenise_line.s
index 06ddf755..13f1fcfd 100644
--- a/src/basic/engine_editor/tokenise_line.s
+++ b/src/basic/engine_editor/tokenise_line.s
@@ -98,6 +98,18 @@ tokenise_line_loop:
jsr tk_search
bcc tokenise_line_keyword_02 // branch if keyword identified
+#endif
+
+#if ROM_LAYOUT_M65
+
+ lda #packed_freq_keywords_03
+ sta FRESPC+1
+
+ jsr tk_search
+ bcc tokenise_line_keyword_03 // branch if keyword identified
+
#endif
// Shorten packed keyword candidate and try again
@@ -173,6 +185,19 @@ tokenise_line_char:
// Support for extended keyword lists
+#if ROM_LAYOUT_M65
+
+tokenise_line_keyword_03:
+
+ // Store the token list index
+
+ lda #$03
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+#endif
+
#if !HAS_SMALL_BASIC
tokenise_line_keyword_02:
diff --git a/src/basic/engine_runtime/do_error.s b/src/basic/engine_runtime/do_error.s
index a3d64f63..56501647 100644
--- a/src/basic/engine_runtime/do_error.s
+++ b/src/basic/engine_runtime/do_error.s
@@ -163,7 +163,7 @@ do_error_fetch:
// $E6 has even part
asl
ora $EA
- and #$7f
+ and #$7F
tax
// Restore $EA to correct value in case the NOP above is used
diff --git a/src/basic/engine_runtime/execute_line_statements.s b/src/basic/engine_runtime/execute_line_statements.s
index 17624201..dd1d3b99 100644
--- a/src/basic/engine_runtime/execute_line_statements.s
+++ b/src/basic/engine_runtime/execute_line_statements.s
@@ -46,7 +46,11 @@ execute_statements:
#else
+#if ROM_LAYOUT_M65
+ cpx #$04
+#else
cpx #$03
+#endif
bcc execute_statements_extended
#endif
@@ -57,6 +61,9 @@ execute_statements:
cpx #$7F
bcc_16 execute_statements_var_assign // not a token - try variable assign
+ cpx #$A7
+ bcs_16 do_SYNTAX_error
+
#if !HAS_OPCODES_65C02
// Get the jump table entry for it, push it on the stack, and then RTS to start it.
@@ -93,6 +100,13 @@ execute_statements_extended:
cpx #$02
beq execute_statements_02
+#if ROM_LAYOUT_M65
+
+ cpx #$03
+ beq execute_statements_03
+
+#endif
+
jmp do_SYNTAX_error
#endif
@@ -171,6 +185,27 @@ execute_statements_02:
#endif // !HAS_SMALL_BASIC
+#if ROM_LAYOUT_M65
+
+execute_statements_03:
+
+ // Get the sub-token, check that it is valid
+
+ jsr fetch_character
+ cmp #$00
+ beq_16 do_SYNTAX_error
+
+ cmp #(TK__MAXTOKEN_keywords_03+1)
+ bcs_16 do_SYNTAX_error
+
+ // Use jumptable to go to the command routine
+
+ asl
+ tax
+ jmp (command_03_jumptable - 2, x)
+
+#endif // ROM_LAYOUT_M65
+
execute_statements_end_of_line:
// First check, if we are in direct mode - if so,
diff --git a/src/basic/init/basic_cold_start_internal.s b/src/basic/init/basic_cold_start_internal.s
index e321d9e7..4e14a127 100644
--- a/src/basic/init/basic_cold_start_internal.s
+++ b/src/basic/init/basic_cold_start_internal.s
@@ -41,5 +41,8 @@ basic_cold_start_internal:
// Print startup messages
jsr INITMSG
+ // Initialize other variables by performing NEW
+ jsr do_new
+
// jump into warm start loop
jmp basic_warm_start
diff --git a/src/basic/init/e422.initmsg.jmp.s b/src/basic/init/e422.initmsg.jmp.s
index 591ed9ac..f0de165f 100644
--- a/src/basic/init/e422.initmsg.jmp.s
+++ b/src/basic/init/e422.initmsg.jmp.s
@@ -16,8 +16,15 @@ INITMSG:
jsr map_BASIC_1
jsr_ind VB1__INITMSG
+!:
jmp map_NORMAL
+INITMSG_autoswitch:
+
+ jsr map_BASIC_1
+ jsr_ind VB1__INITMSG_autoswitch
+ bra !-
+
#else
jmp initmsg_real
diff --git a/src/basic/init/initmsg_bytes_free.s b/src/basic/init/initmsg_bytes_free.s
index ed8db16f..97f9f32b 100644
--- a/src/basic/init/initmsg_bytes_free.s
+++ b/src/basic/init/initmsg_bytes_free.s
@@ -55,12 +55,6 @@ initmsg_bytes_free:
#endif
sta MEMSIZ+0
- // XXX move the part above to a more suitable place
-
- // Initialize other variables by performing NEW
-
- jsr do_new
-
// Print number of bytes free
sec
diff --git a/src/basic/init/initmsg_m65.s b/src/basic/init/initmsg_m65.s
new file mode 100644
index 00000000..bbe77b95
--- /dev/null
+++ b/src/basic/init/initmsg_m65.s
@@ -0,0 +1,101 @@
+// #LAYOUT# M65 BASIC_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+// Routine is too long to fit in the original location
+
+// XXX banner-related code needs cleanup, move MEGA65 stuff to a separate file
+
+
+INITMSG:
+
+ jsr INITMSG_main_banner
+
+ // Display additional information, depending on the mode
+
+ jsr M65_MODEGET
+ bcc !+
+
+ // Legacy C64 compatibility mode
+
+ jsr INITMSG_partial
+
+ ldx #IDX__STR_ORS_LEGACY_2
+ jsr print_packed_misc_str
+
+ bra INITMSG_end
+!:
+ // Native mode
+
+ ldx #48
+ ldy #0
+ jsr M65_SETWIN_XY
+
+ ldx #32
+ ldy #9
+ jsr M65_SETWIN_WH
+
+ jsr M65_SETWIN_Y
+ jsr print_sysinfo_banner
+ jsr M65_SETWIN_N
+
+ // Native mode - display revision and available memory
+
+ ldx #$05
+ ldy #$00
+ jsr plot_set
+
+ ldx #IDX__STR_ORS
+ jsr print_packed_misc_str
+
+ jsr INITMSG_revision
+
+ jsr print_return
+ jsr print_return
+
+ // FALLTROUGH
+
+INITMSG_end:
+
+ jsr initmsg_bytes_free
+
+ ldx #$09
+ ldy #$00
+ jmp plot_set
+
+INITMSG_main_banner:
+
+ // Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen
+
+ lda #147
+ jsr JCHROUT
+
+ // Display main banner
+
+ lda #startup_banner
+ jmp STROUT
+
+INITMSG_autoswitch: // entry point for 'SYS command'
+
+ jsr INITMSG_main_banner
+ jsr INITMSG_partial
+
+ jsr print_return
+ jmp print_return
+
+INITMSG_partial:
+
+ ldx #IDX__STR_ORS_LEGACY_1
+ jsr print_packed_misc_str
+
+ // FALLTROUGH
+
+INITMSG_revision:
+
+ ldx #IDX__STR_PRE_REV
+ jsr print_packed_misc_str
+
+ lda #rom_revision_basic_string
+ jmp STROUT
diff --git a/src/basic/init/initmsg_real.s b/src/basic/init/initmsg_real.s
index 98df977a..8a38e3e6 100644
--- a/src/basic/init/initmsg_real.s
+++ b/src/basic/init/initmsg_real.s
@@ -1,5 +1,4 @@
// #LAYOUT# STD * #TAKE
-// #LAYOUT# M65 BASIC_1 #TAKE
// #LAYOUT# X16 BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
@@ -7,16 +6,8 @@
// Routine is too long to fit in the original location
-#if ROM_LAYOUT_M65
-
-INITMSG:
-
-#else
-
initmsg_real:
-#endif
-
// Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen
lda #147
jsr JCHROUT
@@ -82,9 +73,8 @@ initmsg_real:
ldy #$0A
jsr plot_set
- lda #pre_revision_string
- jsr STROUT
+ ldx #IDX__STR_PRE_REV
+ jsr print_packed_misc_str
lda #rom_revision_basic_string
@@ -115,50 +105,4 @@ initmsg_real:
jmp plot_set
#endif
-#elif CONFIG_BANNER_BRAND && CONFIG_BRAND_MEGA_65
-
- lda #startup_banner
- jsr STROUT
-
-#if ROM_LAYOUT_M65
-
- // XXX make it different for future Mega65 native mode
-
- ldx #$02
- ldy #$21
- jsr plot_set
-
- lda #text_mode_64
- jsr STROUT
-
-#endif
-
- ldx #$05
- ldy #$00
- jsr plot_set
-
- lda #rom_revision_basic_string
- jsr STROUT
-
- ldx #$05
- ldy #$12
- jsr plot_set
-
- jsr initmsg_bytes_free
-
-#if CONFIG_SHOW_FEATURES
- ldx #$08
- ldy #$00
- jsr plot_set
- jmp print_features
-#else
- ldx #$07
- ldy #$00
- jmp plot_set
-#endif
-
-
#endif
diff --git a/src/basic/print/list_single_line.s b/src/basic/print/list_single_line.s
index 51f90887..6a0eab20 100644
--- a/src/basic/print/list_single_line.s
+++ b/src/basic/print/list_single_line.s
@@ -94,6 +94,10 @@ list_not_quote:
cmp #$02
beq list_display_token_02
#endif
+#if ROM_LAYOUT_M65
+ cmp #$03
+ beq list_display_token_03
+#endif
// Check for literals
cmp #$7F
@@ -228,6 +232,24 @@ list_display_token_02:
#endif
+#if ROM_LAYOUT_M65
+
+list_display_token_03:
+
+ // Display a 2-byte token - for extended BASIC
+ jsr list_fetch_subtoken
+
+ // Check if token is known
+ cpx #TK__MAXTOKEN_keywords_03
+ bcs list_is_unknown
+
+ // Now ask for it to be printed
+ phy_trash_a
+ jsr print_packed_keyword_03
+ jmp_8 list_display_token_ext_done
+
+#endif
+
list_fetch_subtoken:
// Fetch the sub-token
diff --git a/src/basic/print/print_packed_freq_string.s b/src/basic/print/print_packed_freq_string.s
index cc5d36c9..100da364 100644
--- a/src/basic/print/print_packed_freq_string.s
+++ b/src/basic/print/print_packed_freq_string.s
@@ -55,6 +55,16 @@ print_packed_keyword_02: // .X - token number
#endif
+#if ROM_LAYOUT_M65
+
+print_packed_keyword_03: // .X - token number
+
+ lda #packed_freq_keywords_03
+ bne print_freq_packed_string // branch always
+
+#endif
+
print_packed_keyword_V2: // .X - token number
lda #M65_DMAGIC_LIST
+ sta DMA_ADDRMSB // $D701
+ lda #MEMCONF_CHRBASE
+ sta M65_DMAJOB_DST_1
+ lda #= $80 needs to be -$40
- // (C64 PRG p380-381)
- // And bit 7 should be cleared, only to be
- // set by reverse video
- sec
- sbc #$40
-
- // Fix shifted chars by adding $20 again
- cmp #$20
- bcc chrout_screen_literal // not high char
- cmp #$40
- bcs chrout_screen_literal // not high char
- clc
- adc #$20
+ jsr chrout_to_screen_code
// FALLTROUGH
-chrout_screen_literal:
+chrout_screen_literal: // entry point for chrout_screen_quote
// Write normal character on the screen
diff --git a/src/kernal/screen/chrout_screen_jumptable_codes.s b/src/kernal/screen/chrout_screen_jumptable_codes.s
index 07d30cd4..4299d42a 100644
--- a/src/kernal/screen/chrout_screen_jumptable_codes.s
+++ b/src/kernal/screen/chrout_screen_jumptable_codes.s
@@ -13,8 +13,8 @@ chrout_screen_jumptable_codes:
.byte KEY_CLR
.byte KEY_HOME
- .byte KEY_SHIFT_OFF
- .byte KEY_SHIFT_ON
+ .byte KEY_C64_SHIFT_OFF
+ .byte KEY_C64_SHIFT_ON
.byte KEY_TXT
.byte KEY_GFX
.byte KEY_RVS_OFF
@@ -31,8 +31,8 @@ __chrout_screen_jumptable_quote_guard:
.byte KEY_STOP
#endif
#if CONFIG_EDIT_TABULATORS
- .byte KEY_TAB_BW
- .byte KEY_TAB_FW
+ .byte KEY_C64_TAB_BW
+ .byte KEY_C64_TAB_FW
#endif
.byte KEY_DEL
.byte KEY_RETURN
diff --git a/src/kernal/screen/chrout_screen_rvs.s b/src/kernal/screen/chrout_screen_rvs.s
index 47dce95f..5703cacc 100644
--- a/src/kernal/screen/chrout_screen_rvs.s
+++ b/src/kernal/screen/chrout_screen_rvs.s
@@ -11,11 +11,13 @@
chrout_screen_RVS_ON:
lda #$80
- bne !+ // branch always
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
chrout_screen_RVS_OFF:
lda #$00
-!:
+
sta RVS
jmp chrout_screen_done
diff --git a/src/kernal/screen/chrout_screen_shift_onoff.s b/src/kernal/screen/chrout_screen_shift_onoff.s
index 24369ada..0058e836 100644
--- a/src/kernal/screen/chrout_screen_shift_onoff.s
+++ b/src/kernal/screen/chrout_screen_shift_onoff.s
@@ -11,11 +11,13 @@
chrout_screen_SHIFT_ON:
lda #$00 // enable SHIFT+VENDOR combination
-!:
- sta MODE
- jmp chrout_screen_done
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
chrout_screen_SHIFT_OFF:
lda #$80 // disable SHIFT+VENDOR combination
- bne !- // branch always
+
+ sta MODE
+ jmp chrout_screen_done
diff --git a/src/kernal/screen/chrout_to_screen_code.s b/src/kernal/screen/chrout_to_screen_code.s
new file mode 100644
index 00000000..207c512d
--- /dev/null
+++ b/src/kernal/screen/chrout_to_screen_code.s
@@ -0,0 +1,44 @@
+// #LAYOUT# STD * #TAKE
+// #LAYOUT# * KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// CHROUT routine - convert PETSCII to screen code
+//
+
+
+chrout_to_screen_code:
+
+ // Codes $C0-$DF become $40-$5F
+ cmp #$E0
+ bcs !+
+ cmp #$C0
+ bcc !+
+
+ and #$7F
+ rts // not high char
+!:
+ // Range $20-$3F is unchanged
+ cmp #$40
+ bcc !+ // not high char
+
+ // Unshifted letters and symbols from $40-$5F
+ // all end up being -$40
+ // (C64 PRG p376)
+
+ // But anything >= $80 needs to be -$40
+ // (C64 PRG p380-381)
+ // And bit 7 should be cleared, only to be
+ // set by reverse video
+ sec
+ sbc #$40
+
+ // Fix shifted chars by adding $20 again
+ cmp #$20
+ bcc !+ // not high char
+ cmp #$40
+ bcs !+ // not high char
+ clc
+ adc #$20
+!:
+ rts
diff --git a/src/kernal/screen/cursor.s b/src/kernal/screen/cursor.s
index 7021133a..4058778b 100644
--- a/src/kernal/screen/cursor.s
+++ b/src/kernal/screen/cursor.s
@@ -17,6 +17,7 @@
cursor_blink:
+
// Is the cursor enabled?
lda BLNSW
bne cursor_blink_end
@@ -47,17 +48,29 @@ cursor_draw:
lda #1
sta BLNON
- bne cursor_blink_timer_reset // branches always
+ bne cursor_timer_reset // branches always
+
+
+// XXX code below is probably not 100% safe
cursor_disable:
+
lda #$80
sta BLNSW
// FALLTHROUGH
cursor_hide_if_visible:
+
+ // Set countdown to high value, to prevent IRQ interference
+ lda #$FF
+ sta BLNCT
+
+ // If cursor is not visible, not much to do
lda BLNON
- beq cursor_blink_end
+ beq cursor_timer_reset
+
+ // FALLTROUGH
cursor_undraw:
@@ -67,12 +80,17 @@ cursor_undraw:
lda GDCOL
sta (USER),y
+ // FALLTROUGH
+
+cursor_undraw_cont: // entry point used by MEGA65 screen editor
+
+ // Mark cursor as not drawn
lda #0
sta BLNON
// FALLTROUGH
-cursor_blink_timer_reset:
+cursor_timer_reset:
// Rest blink counter (Mapping the 64, p39-40)
lda #20
@@ -81,4 +99,5 @@ cursor_blink_timer_reset:
// FALLTROUGH
cursor_blink_end:
+
rts
diff --git a/src/kernal/screen/cursor_enable.s b/src/kernal/screen/cursor_enable.s
index d5322360..2208768b 100644
--- a/src/kernal/screen/cursor_enable.s
+++ b/src/kernal/screen/cursor_enable.s
@@ -13,4 +13,5 @@ cursor_enable:
lda #$00
sta BLNSW
+
rts
diff --git a/src/kernal/screen/cursor_show.s b/src/kernal/screen/cursor_show.s
index d700679f..585ce97e 100644
--- a/src/kernal/screen/cursor_show.s
+++ b/src/kernal/screen/cursor_show.s
@@ -12,28 +12,23 @@
cursor_show_if_enabled:
+
lda BLNSW
- bne cursor_show_end
+ bne !+
lda BLNON
- bne cursor_show_end
+ bne !+
// FALLTROUGH
cursor_show:
- // Set cursor as though it had just finished the off phase,
- // so that the call to cursor_blink paints it
- lda #$00
- sta BLNCT
- sta BLNON
- jsr cursor_blink
+ // Set the cursor so that it is going to be repainted by the next IRQ
- // Then set the timeout to 1 frame, so that the cursor
- // blinks under key repeat conditions, like on the original KERNAL
lda #$01
sta BLNCT
- // FALLTROUGH
+ lda #$00
+ sta BLNON
-cursor_show_end:
+!:
rts
diff --git a/src/kernal/screen/e544.clear_screen.s b/src/kernal/screen/e544.clear_screen.s
index 8c3abe1d..a153885e 100644
--- a/src/kernal/screen/e544.clear_screen.s
+++ b/src/kernal/screen/e544.clear_screen.s
@@ -12,6 +12,14 @@
clear_screen:
+
+#if ROM_LAYOUT_M65
+
+ jsr M65_MODEGET
+ bcc_16 M65_CLRSCR
+
+#endif
+
// Clear the line link table - cheecked on original ROMs,
// the highest bit set means that the line is NOT a logical
// continuation of the previous one
diff --git a/src/kernal/screen/e56c.screen_calculate_pointers.s b/src/kernal/screen/e56c.screen_calculate_pointers.s
index cb4194b9..3c30b0b4 100644
--- a/src/kernal/screen/e56c.screen_calculate_pointers.s
+++ b/src/kernal/screen/e56c.screen_calculate_pointers.s
@@ -15,5 +15,12 @@
screen_calculate_pointers:
+#if ROM_LAYOUT_M65
+
+ jsr M65_MODEGET
+ bcc_16 m65_screen_upd_txtrow_off
+
+#endif
+
jsr screen_calculate_PNT_USER
jmp screen_calculate_PNTR_LNMX
diff --git a/src/kernal/screen/screen.s b/src/kernal/screen/screen.s
index 6b98bdb3..f83b39b1 100644
--- a/src/kernal/screen/screen.s
+++ b/src/kernal/screen/screen.s
@@ -15,6 +15,8 @@
SCREEN:
+#if !ROM_LAYOUT_M65
+
// There are only 2 sane ways to implement this routine,
// I hope this one is different than what Commodore picked :)
@@ -22,3 +24,31 @@ SCREEN:
ldx #40 // 40 rows
rts
+
+#else
+
+ php
+ jsr M65_MODEGET
+ bcc !+
+
+ plp
+
+ ldy #25 // 25 columns
+ ldx #40 // 40 rows
+
+ rts
+!:
+ // Screen dimensions depends on text mode
+
+ plp
+ pha
+ ldy M65_SCRMODE
+
+ ldx m65_scrtab_txtwidth, y
+ lda m65_scrtab_txtheight, y
+ tay
+
+ pla
+ rts
+
+#endif
diff --git a/src/kernal/screen/screen_off.s b/src/kernal/screen/screen_off.s
index 133127a3..21ee078e 100644
--- a/src/kernal/screen/screen_off.s
+++ b/src/kernal/screen/screen_off.s
@@ -8,7 +8,7 @@
//
-#if ((CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) && !CONFIG_MB_MEGA_65) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K)
+#if ((CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO)) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K)
screen_off:
diff --git a/src/kernal/screen/screen_on.s b/src/kernal/screen/screen_on.s
index 22853c22..57e81c02 100644
--- a/src/kernal/screen/screen_on.s
+++ b/src/kernal/screen/screen_on.s
@@ -8,7 +8,7 @@
//
-#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) && !CONFIG_MB_MEGA_65
+#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K)
screen_on:
diff --git a/src/kernal/screen_m65/mega65_chrin_keyboard.s b/src/kernal/screen_m65/mega65_chrin_keyboard.s
new file mode 100644
index 00000000..9ed62009
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrin_keyboard.s
@@ -0,0 +1,170 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Keyboard part of the CHRIN routine, version for MEGA65 native mode
+//
+
+
+m65_chrin_keyboard: // XXX connnect this function to Kernal
+
+ // Preserve .X, .Y and .Z register
+
+ phx
+ phy
+ phz
+
+ // FALLTROUGH
+
+m65_chrin_keyboard_repeat:
+
+ // Do we have a line of input we are currently returning?
+ // If so, return the next byte, and clear the flag when we reach the end.
+
+ lda CRSW
+ beq m65_chrin_keyboard_read
+
+ // We have input waiting at [M65__SCRINPUT]+CRSW
+ // When CRSW = INDX, then we return a carriage return and clear the flag
+
+ cmp INDX
+ bne m65_chrin_keyboard_not_end_of_input
+
+ // Clear pending input and quote flags
+
+ lda #$00
+ sta CRSW
+ sta QTSW
+
+ // FALLTROUGH
+
+m65_chrin_keyboard_empty_line:
+
+ // For an empty line, just return the carriage return
+
+ lda #$0D
+
+ // FALLTROUGH
+
+m65_chrin_keyboard_end:
+
+ plz
+ ply
+ plx
+ clc
+ rts
+
+m65_chrin_keyboard_not_end_of_input:
+
+ // Advance index, return the next byte
+
+ inc CRSW
+ tay
+
+ // FALLTROUGH
+
+m65_chrin_keyboard_return_byte:
+
+ jsr m65_helper_scrlpnt_chrin
+
+ tya
+ taz
+ lda_lp (M65_LPNT_SCR), z
+
+ jsr screen_check_toggle_quote
+ jsr screen_code_to_petscii
+
+ jmp_8 m65_chrin_keyboard_end
+
+m65_chrin_keyboard_read:
+
+ jsr cursor_enable
+
+ // Wait for a key
+ lda NDX
+ beq m65_chrin_keyboard_repeat
+ lda KEYD
+ cmp #$0D
+ bne m65_chrin_keyboard_not_enter
+
+ // FALLTROUGH
+
+m65_chrin_keyboard_enter:
+
+ // Disable cursor, retrieve code from keyboard buffer
+
+ jsr m65_cursor_disable
+ jsr pop_keyboard_buffer
+ jsr m65_cursor_hide_if_visible
+
+ // It was enter. Note that we have a line of input to return, and return the first byte
+ // after computing and storing its length (Computes Mapping the 64, p96)
+
+ // Set pointer to the input, start for the viewport offset + screen memory base
+ clc
+ lda M65_COLVIEW+0
+ adc M65_SCRBASE+0
+ sta M65__SCRINPUT+0
+ lda M65_COLVIEW+1
+ adc M65_SCRBASE+1
+ sta M65__SCRINPUT+1
+ // Add current row offset
+ clc
+ lda M65__SCRINPUT+0
+ adc M65_TXTROW_OFF+0
+ sta M65__SCRINPUT+0
+ lda M65__SCRINPUT+1
+ adc M65_TXTROW_OFF+1
+ sta M65__SCRINPUT+1
+
+ // Retrieve first byte which is not space
+
+ jsr m65_helper_scrlpnt_chrin
+ ldy M65_COLVIEWMAX // XXX add support for windowed mode here
+ iny
+
+ // FALLTROUGH
+
+m65_chrin_enter_loop:
+
+ // Skip spaces at the end of line
+ dey
+ bmi m65_chrin_keyboard_empty_line
+
+ tya
+ taz
+ lda_lp (M65_LPNT_SCR), z
+ cmp #$20
+ beq m65_chrin_enter_loop
+ iny
+ sty INDX
+
+ // XXX add windowed mode support here - correct INDX and M65__SCRINPUT
+
+ // Set mark informing that we are returning a line
+ ldy #$01
+ sty CRSW
+
+ // Clear quote mode mark
+ dey
+ sty QTSW
+
+ // Return first char of line
+ jmp_8 m65_chrin_keyboard_return_byte // branch always
+
+
+m65_chrin_keyboard_not_enter:
+
+ lda KEYD
+
+#if CONFIG_PROGRAMMABLE_KEYS
+
+ jsr chrin_programmable_keys
+ bcc m65_chrin_keyboard_enter
+
+#endif // CONFIG_PROGRAMMABLE_KEYS
+
+ // Print character, keep looking for input from keyboard until carriage return
+ jsr CHROUT
+ jsr pop_keyboard_buffer
+ jmp m65_chrin_keyboard_repeat
diff --git a/src/kernal/screen_m65/mega65_chrout_screen.s b/src/kernal/screen_m65/mega65_chrout_screen.s
new file mode 100644
index 00000000..c2533579
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrout_screen.s
@@ -0,0 +1,289 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// CHROUT routine - screen support (character output), MEGA65 native mode version
+//
+
+
+m65_chrout_screen:
+
+ jsr m65_cursor_hide_if_visible
+
+ // Retrieve the character to output
+
+ lda SCHAR
+ tax
+
+ // All the PETSCII control codes are within $0x, $1x, $8x, $9x, remaining
+ // ones are always printable characters; separate away control codes
+
+ and #$60
+ beq_16 m65_chrout_screen_control
+ txa
+
+ // Literals - first convert PETSCII to screen code
+
+ jsr chrout_to_screen_code
+
+ // FALLTROUGH
+
+m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote
+
+ // Write normal character on the screen
+
+ tax // store screen code, we need .A for calculations
+
+ // Preserve .Z on stack
+
+ phz
+
+ // Prepare .Z and M65_LPNT_SCR for colour memory manipulation
+
+ ldz M65__TXTCOL
+ jsr m65_helper_scrlpnt_color
+
+ // Store the new color in screen memory
+
+ lda COLOR
+ sta_lp (M65_LPNT_SCR),z
+
+ // Now change M65_LPNT_SCR to point to screen memory
+
+ jsr m65_helper_scrlpnt_to_screen
+
+ // Decrement number of chars waiting to be inserted
+
+ lda INSRT
+ beq !+
+ dec INSRT
+!:
+ // Toggle quote flag if required
+
+ txa
+ jsr screen_check_toggle_quote
+
+ // Store the new character in screen memory, restore .Z
+
+ txa
+
+ bit RVS
+ bpl !+
+ ora #$80 // reverse the character XXX consider doing this within chrout_to_screen_code
+!:
+ sta_lp (M65_LPNT_SCR),z
+
+ // Restore .Z
+
+ plz
+
+ // Increment screen column by 1
+
+ inc M65__TXTCOL
+
+ // FALLTROUGH
+
+m65_chrout_fix_column_row:
+
+ ldy M65_SCRMODE
+
+ bit M65_SCRWINMODE
+ bmi m65_chrout_fix_column_row_win
+
+ // Non-windowed mode
+
+ // Check for column below 0
+
+ lda M65__TXTCOL
+ bpl !++
+
+ lda M65_COLVIEW+0
+ ora M65_COLVIEW+1
+ ora M65__TXTROW
+ bne !+
+ lda #$00
+ sta M65__TXTCOL
+ jmp_8 !++
+!:
+ dec M65__TXTROW
+ lda m65_scrtab_txtwidth,y
+ sta M65__TXTCOL
+ dec M65__TXTCOL
+!:
+ // Check for column above maximum
+
+ lda M65__TXTCOL
+ cmp m65_scrtab_txtwidth,y
+ bcc !+
+
+ inc M65__TXTROW
+ lda #$00
+ sta M65__TXTCOL
+!:
+ // Check for row below 0
+
+ lda M65__TXTROW
+ bpl !+
+
+ jsr m65_chrout_fix_scroll_down
+!:
+ // Check for row above maximum
+
+ lda M65__TXTROW
+ cmp m65_scrtab_txtheight,y
+ bcc !+
+
+ jsr m65_chrout_fix_scroll_up
+!:
+ jmp_8 m65_chrout_fix_txtrow_off
+
+m65_chrout_fix_column_row_win:
+
+ // Windowed mode
+
+ // XXX
+ // XXX provide implementation
+ // XXX
+
+ nop
+
+ // FALLTROUGH
+
+m65_chrout_fix_txtrow_off:
+
+ jsr m65_screen_upd_txtrow_off
+
+ // FALLTROUGH
+
+m65_chrout_screen_done:
+
+ jsr cursor_show_if_enabled
+
+ // XXX make sure it return success
+ rts
+
+
+
+// Try to fix coordinates by scrolling the screen down
+
+m65_chrout_fix_scroll_down:
+
+ inc M65__TXTROW
+
+ // Check if we can simply adapt the viewport
+
+ lda M65_COLVIEW+0
+ ora M65_COLVIEW+1
+ beq m65_chrout_fix_scroll_down_end
+
+ // Yes, we can simply adapt the viewport
+
+ sec
+ lda M65_COLVIEW+0
+ sbc #$50
+ sta M65_COLVIEW+0
+ sta VIC_COLPTR+0
+ bcs !+
+ dec M65_COLVIEW+1
+ dec VIC_COLPTR+1
+!:
+ sec
+ lda VIC_SCRNPTR+0
+ sbc #$50
+ sta VIC_SCRNPTR+0
+ bcs !+
+ dec VIC_SCRNPTR+1
+!:
+ // FALLTROUGH
+
+m65_chrout_fix_scroll_down_end:
+
+ rts
+
+
+// Try to fix coordinates by scrolling the screen up
+
+m65_chrout_fix_scroll_up:
+
+ dec M65__TXTROW
+
+ // Check if we can simply adapt the viewport
+
+ lda M65_COLVIEW+1
+ cmp M65_COLVIEWMAX+1
+ bne !+
+
+ lda M65_COLVIEW+0
+ cmp M65_COLVIEWMAX+0
+ beq m65_chrout_fix_scroll_up_scroll
+!:
+ // Yes, we can simply adapt the viewport
+
+ clc
+ lda M65_COLVIEW+0
+ adc #$50
+ sta M65_COLVIEW+0
+ sta VIC_COLPTR+0
+ bcc !+
+ inc M65_COLVIEW+1
+ inc VIC_COLPTR+1
+!:
+ clc
+ lda VIC_SCRNPTR+0
+ adc #$50
+ sta VIC_SCRNPTR+0
+ bcc !+
+ inc VIC_SCRNPTR+1
+!:
+ rts
+
+m65_chrout_fix_scroll_up_scroll:
+
+ // Virtual screen is too small - we will lose one row
+
+ // Calculate size of data to copy
+
+ sec
+ lda M65_COLGUARD+0
+ sbc #$50
+ sta M65_DMAJOB_SIZE_0
+ lda M65_COLGUARD+1
+ sbc #$00
+ sta M65_DMAJOB_SIZE_1
+
+ // Scroll up screen memory
+
+ jsr m65_screen_dmasrcdst_screen
+ jsr m65_screen_dmasrc_add_row
+ jsr m65_dmagic_oper_copy
+
+ // Scroll up color memory
+
+ jsr m65_screen_dmasrcdst_color
+ jsr m65_screen_dmasrc_add_row
+ jsr m65_dmagic_oper_copy
+
+ // Clear the last row - color and screen memory
+
+ phz
+
+ jsr m65_helper_scrlpnt_color
+ lda COLOR
+ and #$0F
+ ldz M65_SCRCOLMAX
+!:
+ sta_lp (M65_LPNT_SCR), z
+ dez
+ bpl !-
+
+ jsr m65_helper_scrlpnt_to_screen
+ lda #$20
+ ldz M65_SCRCOLMAX
+!:
+ sta_lp (M65_LPNT_SCR), z
+ dez
+ bpl !-
+
+ plz
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s
new file mode 100644
index 00000000..3ad9551a
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s
@@ -0,0 +1,96 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_chrout_screen_control:
+
+ txa
+
+m65_chrout_try_jumptable:
+
+ ldx #(__m65_chrout_screen_jumptable_codes_end - m65_chrout_screen_jumptable_codes - 1)
+
+m65_chrout_try_jumptable_loop:
+
+ cpx #(__m65_chrout_screen_jumptable_quote_guard - m65_chrout_screen_jumptable_codes - 1)
+ bne m65_chrout_try_jumptable_loop_noquote
+
+ // Is this insert/quote mode?
+
+ tay
+ lda QTSW
+ ora INSRT
+ beq !+
+ tya
+ jmp m65_chrout_screen_quote
+!:
+ tya
+
+ // FALLTROUGH
+
+m65_chrout_try_jumptable_loop_noquote:
+
+ cmp m65_chrout_screen_jumptable_codes, x
+ bne !+
+
+ // Found, perform a jump to subroutine
+
+ txa
+ asl
+ tax
+ jmp (m65_chrout_screen_jumptable, x)
+
+!:
+ dex
+ bpl m65_chrout_try_jumptable_loop
+
+m65_chrout_try_COLOR:
+
+ ldx #$0F
+
+m65_chrout_try_color_loop:
+
+ cmp colour_codes,x
+ bne !+
+
+ lda COLOR
+ and #$F0
+ sta COLOR
+
+ txa
+ ora COLOR
+ sta COLOR
+
+ jmp m65_chrout_screen_done
+!:
+ dex
+ bpl m65_chrout_try_color_loop
+
+ // Unknown code, or key not requiring any handling
+
+ jmp m65_chrout_screen_done
+
+
+
+
+// XXX: implement screen routines below:
+
+m65_chrout_screen_TAB:
+ nop
+m65_chrout_screen_LINE_FEED:
+ nop
+m65_chrout_screen_UNDERLINE_ON:
+ nop
+m65_chrout_screen_UNDERLINE_OFF:
+ nop
+m65_chrout_screen_FLASHING_ON:
+ nop
+m65_chrout_screen_FLASHING_OFF:
+ nop
+m65_chrout_screen_TAB_SET_CLR:
+ nop
+m65_chrout_screen_ESC:
+ nop
+m65_chrout_screen_BELL:
+
+ jmp m65_chrout_screen_done
diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control_1.s b/src/kernal/screen_m65/mega65_chrout_screen_control_1.s
new file mode 100644
index 00000000..9264e959
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrout_screen_control_1.s
@@ -0,0 +1,62 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+// Cursor movement
+
+m65_chrout_screen_CRSR_RIGHT:
+
+ inc M65__TXTCOL
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+m65_chrout_screen_CRSR_LEFT:
+
+ dec M65__TXTCOL
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+m65_chrout_screen_CRSR_DOWN:
+
+ inc M65__TXTROW
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+m65_chrout_screen_CRSR_UP:
+
+ dec M65__TXTROW
+ jmp_8 m65_chrout_screen_ctrl1_end
+
+
+// 'RETURN' key
+
+m65_chrout_screen_RETURN:
+
+ // RETURN clears quote and insert modes, it also clears reverse flag
+
+ lda #$00
+ sta QTSW
+ sta INSRT
+ sta RVS
+
+ // Move cursor to the beginning of the next line
+
+ bit M65_SCRWINMODE
+ bpl !+
+ lda M65_TXTWIN_X0
+ skip_2_bytes_trash_nvz
+!:
+ lda #$00
+ sta M65__TXTCOL
+ inc M65__TXTROW
+
+ // FALLTROUGH
+
+m65_chrout_screen_ctrl1_end:
+
+ // Correct the column/row values
+
+ jmp m65_chrout_fix_column_row
diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s
new file mode 100644
index 00000000..606d7cb0
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s
@@ -0,0 +1,152 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+// 'REVERSE' mode support
+
+m65_chrout_screen_RVS_ON:
+
+ lda #$80
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+m65_chrout_screen_RVS_OFF:
+
+ lda #$00
+
+ sta RVS
+
+ // FALLTROUGH
+
+m65_chrout_screen_ctrl2_end:
+
+ jmp m65_chrout_screen_done
+
+
+// 'SHIFT ON/OFF' support
+
+m65_chrout_screen_SHIFT_ON:
+
+ lda #$00 // enable SHIFT+VENDOR combination
+ skip_2_bytes_trash_nvz
+
+ // FALLTROUGH
+
+m65_chrout_screen_SHIFT_OFF:
+
+ lda #$80 // disable SHIFT+VENDOR combination
+
+ sta MODE
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+
+// STOP key support
+
+m65_chrout_screen_STOP:
+
+ lda #$00
+ sta QTSW
+ sta INSRT
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+// CLR/HOME key support
+
+m65_chrout_screen_CLR:
+
+ jsr M65_CLRWIN
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+m65_chrout_screen_HOME:
+
+ jsr M65_HOME
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+// Character set switching
+
+m65_chrout_screen_GFX:
+
+ lda VIC_CHARPTR+1
+ ora #%00001000
+!:
+ sta VIC_CHARPTR+1
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+m65_chrout_screen_TXT:
+
+ lda VIC_CHARPTR+1
+ and #%11110111
+ jmp_8 !-
+
+// INS key
+
+m65_chrout_screen_INS:
+
+ // First prepare the pointer to the current row
+
+ jsr m65_helper_scrlpnt_color
+ jsr m65_helper_scrlpnt_to_screen
+
+ // Check for windowed mode
+
+ lda M65_SCRWINMODE
+ bmi_16 m65_chrout_screen_INS_winmode
+
+ // Check if last character of the line is space
+
+ ldy M65_SCRMODE
+ lda m65_scrtab_txtwidth,y
+ dec_a
+ taz
+ lda_lp (M65_LPNT_SCR), z
+ cmp #$20
+ bne_16 m65_chrout_screen_ctrl2_end
+ phz
+
+ // Last character is space - move the characters
+
+ jsr m65_chrout_screen_INS_copy
+
+ // Store space in the current character cell
+
+ lda #$20
+ sta_lp (M65_LPNT_SCR), z
+
+ // Move the color memory
+
+ jsr m65_helper_scrlpnt_color
+ plz
+ jsr m65_chrout_screen_INS_copy
+
+ // Store current colour in the current character cell
+
+ lda COLOR
+ and #$0F
+ sta_lp (M65_LPNT_SCR), z
+
+ // Increase insert mode count (which causes quote-mode like behaviour) and quit
+
+ inc INSRT
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+m65_chrout_screen_INS_winmode:
+
+ // Check if last character of the line within window is space
+
+ // XXX provide implementation
+
+ jmp_8 m65_chrout_screen_ctrl2_end
+
+
+
+m65_chrout_screen_INS_copy:
+
+ dez
+ lda_lp (M65_LPNT_SCR), z
+ inz
+ sta_lp (M65_LPNT_SCR), z
+ dez
+ cpz M65__TXTCOL
+ bne m65_chrout_screen_INS_copy
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control_del.s b/src/kernal/screen_m65/mega65_chrout_screen_control_del.s
new file mode 100644
index 00000000..54462dd6
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_chrout_screen_control_del.s
@@ -0,0 +1,102 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+// 'DEL' key support
+
+m65_chrout_screen_DEL:
+
+ // First check for window mode
+
+ lda M65_SCRWINMODE
+ bmi m65_chrout_screen_DEL_winmode
+
+ // Not a window mode; check if we are in the first column
+
+ lda M65__TXTCOL
+ beq m65_chrout_screen_DEL_1stcol
+
+ // Not a window mode, not a first column - we can safely
+ // delete the character and sroll back the rest of the row
+
+ phz
+
+ jsr m65_helper_scrlpnt_color
+ jsr m65_chrout_screen_DEL_copy
+
+ ldz M65_SCRCOLMAX
+ lda COLOR
+ and #$0F
+ sta_lp (M65_LPNT_SCR), z
+
+ jsr m65_helper_scrlpnt_to_screen
+ jsr m65_chrout_screen_DEL_copy
+
+ ldz M65_SCRCOLMAX
+ lda #$20
+ sta_lp (M65_LPNT_SCR), z
+
+ plz
+
+ // End by moving cursor one position left
+
+ jmp m65_chrout_screen_CRSR_LEFT
+
+m65_chrout_screen_DEL_copy:
+
+ ldz M65__TXTCOL
+ dez
+!:
+ cpz M65_SCRCOLMAX
+ beq !+
+
+ inz
+ lda_lp (M65_LPNT_SCR), z
+ dez
+ sta_lp (M65_LPNT_SCR), z
+
+ inz
+ jmp_8 !-
+!:
+ rts
+
+
+m65_chrout_screen_DEL_1stcol:
+
+ // Start by moving one position left
+
+ jsr m65_chrout_screen_CRSR_LEFT
+
+ // If we are still in the first column - nothing to do
+
+ lda M65__TXTCOL
+ beq !+
+
+ // Deleta character under cursor
+
+ phz
+
+ jsr m65_helper_scrlpnt_color
+ ldz M65__TXTCOL
+
+ lda COLOR
+ and #$0F
+ sta_lp (M65_LPNT_SCR), z
+
+ jsr m65_helper_scrlpnt_to_screen
+ lda #$20
+ sta_lp (M65_LPNT_SCR), z
+
+ plz
+
+ // End of character deletion
+!:
+ jmp m65_chrout_screen_done
+
+
+m65_chrout_screen_DEL_winmode:
+
+ // XXX provide implementation for window mode
+
+ jmp m65_chrout_screen_done
+
diff --git a/src/kernal/screen_m65/mega65_clrscr.s b/src/kernal/screen_m65/mega65_clrscr.s
new file mode 100644
index 00000000..41913d29
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_clrscr.s
@@ -0,0 +1,83 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+M65_CLRSCR:
+
+ // Clear additional attributes from the color code
+
+ jsr m65_screen_clear_colorattr
+
+ // Disable the window mode
+
+ lda #$00
+ sta M65_SCRWINMODE
+
+ // FALLTROUGH
+
+m65_clrscr_takeover:
+
+ // Clear the whole screen + colour memory
+
+ // Screen size
+ lda M65_COLGUARD+0
+ sta M65_DMAJOB_SIZE_0
+ lda M65_COLGUARD+1
+ sta M65_DMAJOB_SIZE_1
+
+
+ // Fill screen memory with spaces
+ jsr m65_screen_dmasrcdst_screen
+ lda #$20
+ jsr m65_dmagic_oper_fill
+
+ // Fill color memory with the current color
+ jsr m65_screen_dmasrcdst_color
+ lda COLOR
+ and #$0F
+ jsr m65_dmagic_oper_fill
+
+ // Set the viewport to the beginning of virtual screen
+ // XXX deduplicate with mode setting routine
+
+ lda #$00
+ sta M65_COLVIEW+0
+ sta M65_COLVIEW+1
+
+ // Set screen+color base address in VIC IV
+ // XXX deduplicate with mode setting routine
+
+ sta VIC_COLPTR+0
+ sta VIC_COLPTR+1
+ sta M65_COLVIEW+0
+ sta M65_COLVIEW+1
+
+ lda M65_SCRBASE+0
+ sta VIC_SCRNPTR+0
+ lda M65_SCRBASE+1
+ sta VIC_SCRNPTR+1
+
+ // Set logical row length
+
+ jsr m65_screen_set_indx
+
+ // FALLTROUGH
+
+M65_HOME:
+
+ lda M65_SCRWINMODE
+ bmi M65_HOME_winmode
+
+ lda #$00
+ sta M65__TXTROW
+ sta M65__TXTCOL
+ sta M65_TXTROW_OFF+0
+ sta M65_TXTROW_OFF+1
+
+ rts
+
+M65_HOME_winmode:
+
+ // XXX provide implementation
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_clrwin.s b/src/kernal/screen_m65/mega65_clrwin.s
new file mode 100644
index 00000000..c519f8b4
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_clrwin.s
@@ -0,0 +1,106 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+// XXX deduplicate pointer manipulation, see M65_CLRSCR
+// XXX consider using DMAgic for this - FILL command
+
+M65_CLRWIN:
+
+ // Clear additional attributes from the color code
+
+ jsr m65_screen_clear_colorattr
+
+ // Check if windowed mode; if not, go to M65_CLRSCR
+
+ lda M65_SCRWINMODE
+ bpl_16 m65_clrscr_takeover
+
+ // To clear the window, two zeropage long pointers will be used:
+ // - M65_LPNT_SCR for screen memory
+ // - M65_LPNT_KERN for colour memory (starts from $FF80000) // XXX preserve this on stack, restore afterwards
+
+ // First initialize both pointers
+
+ // XXX use m65_helper_scrlpnt_color and m65_helper_scrlpnt_to_screen instead
+
+ clc
+ lda M65_COLVIEW+0
+ adc M65_SCRBASE+0
+ sta M65_LPNT_SCR+0
+ lda M65_COLVIEW+1
+ adc M65_SCRBASE+1
+ sta M65_LPNT_SCR+1
+ lda M65_SCRSEG+0
+ sta M65_LPNT_SCR+2
+ lda M65_SCRSEG+1
+ sta M65_LPNT_SCR+3
+
+ lda M65_COLVIEW+0
+ sta M65_LPNT_KERN+0
+ lda M65_COLVIEW+1
+ sta M65_LPNT_KERN+1
+ // XXX deduplicate part below with M65_CLRSCR
+ lda #$F8
+ sta M65_LPNT_KERN+2
+ lda #$0F
+ sta M65_LPNT_KERN+3
+
+ // Go trough all the rows
+
+ phz
+ ldy #$00
+
+ // FALLTROUGH
+
+m65_clrwin_loop:
+
+ // Check if .Y cordinate is not below the window
+
+ cpy M65_TXTWIN_Y0
+ bcc m65_clrwin_loop_next // branch if we should skip this row
+
+ // Clear the row
+
+ ldz M65_TXTWIN_X0
+!:
+ lda #$20
+ sta_lp (M65_LPNT_SCR),z
+ lda COLOR
+ sta_lp (M65_LPNT_KERN),z
+ inz
+ cpz M65_TXTWIN_X1
+ bne !-
+
+ // FALLTROUGH
+
+m65_clrwin_loop_next:
+
+ // Increment M65_LPNT_SCR and M65_LPNT_KERN by the logical row length (always 80 = $50)
+
+ clc
+ lda #$50
+ adc M65_LPNT_SCR+0
+ sta M65_LPNT_SCR+0
+ bcc !+
+ inc M65_LPNT_SCR+1
+!:
+ clc
+ lda #$50
+ adc M65_LPNT_KERN+0
+ sta M65_LPNT_KERN+0
+ bcc !+
+ inc M65_LPNT_KERN+1
+!:
+ // Increment row counter, check if new row is valid
+
+ iny
+ cpy M65_TXTWIN_Y1
+ bne m65_clrwin_loop
+ plz
+
+ // Set screen variables
+
+ // XXX implement this
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_cursor.s b/src/kernal/screen_m65/mega65_cursor.s
new file mode 100644
index 00000000..3df29bf2
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_cursor.s
@@ -0,0 +1,54 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Variables used:
+// - BLNSW (cursor blink switch)
+// - BLNCT (cursor blink countdown)
+// - GDBLN (cursor saved character)
+// - BLNON (if cursor is visible)
+// - GDCOL (colour under cursor)
+//
+
+
+m65_cursor_disable: // XXX utilize this!
+
+ // Disable cursor blinking
+ lda #$80
+ sta BLNSW
+
+ // FALLTHROUGH
+
+m65_cursor_hide_if_visible:
+
+ // Set countdown to high value, to prevent IRQ interference
+ lda #$FF
+ sta BLNCT
+
+ // If cursor is not visible, not much to do
+ lda BLNON
+ beq_16 cursor_timer_reset
+
+ // FALLTROUGH
+
+m65_cursor_undraw:
+
+ // Preserve .Z
+ phz
+
+ // Cursor undraw - color
+
+ jsr m65_helper_scrlpnt_color
+ ldz M65__TXTCOL
+ lda GDCOL
+ sta_lp (M65_LPNT_SCR),z
+
+ // Cursor undraw - character
+
+ jsr m65_helper_scrlpnt_to_screen
+ lda GDBLN
+ sta_lp (M65_LPNT_SCR),z
+
+ // Restore .Z and continue as with normal editor
+ plz
+ jmp cursor_undraw_cont
diff --git a/src/kernal/screen_m65/mega65_cursor_blink.s b/src/kernal/screen_m65/mega65_cursor_blink.s
new file mode 100644
index 00000000..80fd31c8
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_cursor_blink.s
@@ -0,0 +1,103 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Variables used:
+// - BLNSW (cursor blink switch)
+// - BLNCT (cursor blink countdown)
+// - GDBLN (cursor saved character)
+// - BLNON (if cursor is visible)
+// - GDCOL (colour under cursor)
+//
+
+
+m65_cursor_blink:
+
+ // Preserve .Z
+ phz
+
+ // Is the cursor enabled?
+ lda BLNSW
+ bne m65_cursor_blink_end
+
+ // Do we need to redraw things?
+ dec BLNCT
+ bpl m65_cursor_blink_end
+
+ // Prepare .Z for offset within row
+ ldz M65__TXTCOL
+
+ // Prepare long pointer to color memory
+ lda #$0F
+ sta M65_LPNT_IRQ+3
+ lda #$F8
+ sta M65_LPNT_IRQ+2
+
+ lda M65_COLVIEW+1
+ sta M65_LPNT_IRQ+1
+ lda M65_COLVIEW+0
+ sta M65_LPNT_IRQ+0
+
+ // Add screen row to the address
+ clc
+ lda M65_TXTROW_OFF+0
+ adc M65_LPNT_IRQ+0
+ sta M65_LPNT_IRQ+0
+ lda M65_TXTROW_OFF+1
+ adc M65_LPNT_IRQ+1
+ sta M65_LPNT_IRQ+1
+
+ // Check if cursor was visible or not, and toggle
+ lda BLNON
+ bne m65_cursor_blink_undraw
+
+ // FALLTROUGH
+
+m65_cursor_blink_draw:
+
+ lda #1
+ sta BLNON
+
+ // Cursor draw - color
+ lda_lp (M65_LPNT_IRQ),z
+ sta GDCOL
+ lda COLOR
+ and #$0F // take current colour, but not extended attributes
+ sta_lp (M65_LPNT_IRQ),z
+
+ // Cursor draw - character
+ jsr m65_cursor_blink_irqpnt_to_screen
+ lda_lp (M65_LPNT_IRQ),z
+ sta GDBLN
+ eor #$80
+ sta_lp (M65_LPNT_IRQ),z
+
+m65_cursor_blink_timer_reset:
+
+ // Rest blink counter (Mapping the 64, p39-40)
+ lda #20
+ sta BLNCT
+
+ // FALLTROUGH
+
+m65_cursor_blink_end:
+
+ plz
+ rts
+
+m65_cursor_blink_undraw:
+
+ // Cursor undraw - color
+ lda GDCOL
+ sta_lp (M65_LPNT_IRQ),z
+
+ // Cursor undraw - character
+ jsr m65_cursor_blink_irqpnt_to_screen
+ lda GDBLN
+ sta_lp (M65_LPNT_IRQ),z
+
+ // Mark cursor as not drawn
+ lda #0
+ sta BLNON
+
+ jmp_8 m65_cursor_blink_timer_reset
diff --git a/src/kernal/screen_m65/mega65_screen_helpers.s b/src/kernal/screen_m65/mega65_screen_helpers.s
new file mode 100644
index 00000000..a8192463
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_helpers.s
@@ -0,0 +1,71 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_screen_clear_colorattr:
+
+ lda COLOR
+ and #$0F
+ sta COLOR
+
+ rts
+
+
+m65_screen_upd_txtrow_off:
+
+ ldy M65__TXTROW
+ lda m65_scrtab_rowoffset_lo,y
+ sta M65_TXTROW_OFF+0
+ lda m65_scrtab_rowoffset_hi,y
+ sta M65_TXTROW_OFF+1
+
+ rts
+
+
+m65_screen_dmasrcdst_screen:
+
+ // Set screen memory as start/end addresses
+
+ lda M65_SCRBASE+0
+ sta M65_DMAJOB_SRC_0
+ sta M65_DMAJOB_DST_0
+ lda M65_SCRBASE+1
+ sta M65_DMAJOB_SRC_1
+ sta M65_DMAJOB_DST_1
+ lda M65_SCRSEG+0
+ sta M65_DMAJOB_SRC_2
+ sta M65_DMAJOB_DST_2
+ lda M65_SCRSEG+1
+!:
+ sta M65_DMAJOB_SRC_3
+ sta M65_DMAJOB_DST_3
+
+ rts
+
+
+m65_screen_dmasrcdst_color:
+
+ // Set color memory as start/end addresses
+
+ lda #$00
+ sta M65_DMAJOB_SRC_0
+ sta M65_DMAJOB_DST_0
+ sta M65_DMAJOB_SRC_1
+ sta M65_DMAJOB_DST_1
+ lda #$F8
+ sta M65_DMAJOB_SRC_2
+ sta M65_DMAJOB_DST_2
+ lda #$0F
+ jmp_8 !-
+
+
+m65_screen_dmasrc_add_row:
+
+ clc
+ lda M65_DMAJOB_SRC_0
+ adc #$50
+ sta M65_DMAJOB_SRC_0
+ bcc !+
+ inc M65_DMAJOB_SRC_1
+!:
+ rts
diff --git a/src/kernal/screen_m65/mega65_screen_helpers_K0.s b/src/kernal/screen_m65/mega65_screen_helpers_K0.s
new file mode 100644
index 00000000..edcd9382
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_helpers_K0.s
@@ -0,0 +1,30 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Set the INDX variable - logical row length
+//
+
+m65_screen_set_indx: // leaves value in .A
+
+ lda M65_SCRWINMODE
+ bmi !+
+
+ // Non-windowed mode
+
+ phx
+ ldx M65_SCRMODE
+ lda m65_scrtab_txtwidth,x
+ dec_a
+ sta INDX
+ plx
+ rts
+!:
+ // Windowed mode
+
+ sec
+ lda M65_TXTWIN_X1
+ sbc M65_TXTWIN_X0
+ dec_a
+ sta INDX
+ rts
diff --git a/src/kernal/screen_m65/mega65_screen_helpers_irq.s b/src/kernal/screen_m65/mega65_screen_helpers_irq.s
new file mode 100644
index 00000000..a5e851a2
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_helpers_irq.s
@@ -0,0 +1,22 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_cursor_blink_irqpnt_to_screen:
+
+ // Adapt pointer to point to screen memory
+
+ lda M65_SCRSEG+1
+ sta M65_LPNT_IRQ+3
+ lda M65_SCRSEG+0
+ sta M65_LPNT_IRQ+2
+
+ clc
+ lda M65_SCRBASE+0
+ adc M65_LPNT_IRQ+0
+ sta M65_LPNT_IRQ+0
+ lda M65_SCRBASE+1
+ adc M65_LPNT_IRQ+1
+ sta M65_LPNT_IRQ+1
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s
new file mode 100644
index 00000000..31630d11
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s
@@ -0,0 +1,67 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_helper_scrlpnt_color:
+
+ // Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000)
+
+ lda #$0F
+ sta M65_LPNT_SCR+3
+ lda #$F8
+ sta M65_LPNT_SCR+2
+
+ lda M65_COLVIEW+1
+ sta M65_LPNT_SCR+1
+ lda M65_COLVIEW+0
+ sta M65_LPNT_SCR+0
+
+ // Add screen row to the address
+
+ clc
+ lda M65_TXTROW_OFF+0
+ adc M65_LPNT_SCR+0
+ sta M65_LPNT_SCR+0
+ lda M65_TXTROW_OFF+1
+ adc M65_LPNT_SCR+1
+ sta M65_LPNT_SCR+1
+
+ rts
+
+
+
+m65_helper_scrlpnt_to_screen:
+
+ // Change M65_LPNT_SCR to point to screen memory (when it points to color memory)
+
+ clc
+ lda M65_SCRBASE+0
+ adc M65_LPNT_SCR+0
+ sta M65_LPNT_SCR+0
+ lda M65_SCRBASE+1
+ adc M65_LPNT_SCR+1
+ sta M65_LPNT_SCR+1
+
+ // FALLTROUGH
+
+m65_helper_scrlpnt_to_screen_hi:
+
+ lda M65_SCRSEG+1
+ sta M65_LPNT_SCR+3
+ lda M65_SCRSEG+0
+ sta M65_LPNT_SCR+2
+
+ rts
+
+
+
+m65_helper_scrlpnt_chrin:
+
+ // Prepare the pointer for CHRIN
+
+ lda M65__SCRINPUT+0
+ sta M65_LPNT_SCR+0
+ lda M65__SCRINPUT+1
+ sta M65_LPNT_SCR+1
+
+ jmp_8 m65_helper_scrlpnt_to_screen_hi
diff --git a/src/kernal/screen_m65/mega65_screen_quote.s b/src/kernal/screen_m65/mega65_screen_quote.s
new file mode 100644
index 00000000..7e89455c
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_quote.s
@@ -0,0 +1,23 @@
+
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// CHROUT routine - screen support, control codes in quote mode, MEGA65 native mode version
+//
+
+
+m65_chrout_screen_quote:
+
+ // Low control codes are just +$80
+ clc
+ adc #$80
+
+ // If it overflowed, then it is a high control code,
+ // so we need to make it be $80 + $40 + char
+ // as we will have flipped back to just $00 + char, we should
+ // now add $c0 if C is set from overflow
+ bcc !+
+ adc #$BF // C=1, so adding $BF + C = add $C0
+!:
+ jmp m65_chrout_screen_literal
diff --git a/src/kernal/screen_m65/mega65_screen_table_height.s b/src/kernal/screen_m65/mega65_screen_table_height.s
new file mode 100644
index 00000000..7c531313
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_table_height.s
@@ -0,0 +1,9 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_scrtab_txtheight: // height of the text screen
+
+ .byte 25
+ .byte 25
+ .byte 50
diff --git a/src/kernal/screen_m65/mega65_screen_table_width.s b/src/kernal/screen_m65/mega65_screen_table_width.s
new file mode 100644
index 00000000..1a9a5850
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_table_width.s
@@ -0,0 +1,9 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_scrtab_txtwidth: // width of the text screen (logical width is always set to 80)
+
+ .byte 40
+ .byte 80
+ .byte 80
diff --git a/src/kernal/screen_m65/mega65_screen_tables_misc.s b/src/kernal/screen_m65/mega65_screen_tables_misc.s
new file mode 100644
index 00000000..10c14d36
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s
@@ -0,0 +1,114 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+m65_scrtab_vic_ctrlb: // parameters for VIC control register B
+
+ .byte %00100000 // 40x25 + extended attributes
+ .byte %10100000 // 80x25 + extended attributes
+ .byte %10101000 // 80x50 + extended attributes
+
+m65_scrtab_colviewmax_lo: // maximum allowed color viewport start - low byte
+
+ .byte <((MEMCONF_SCRROWS - 25) * 80)
+ .byte <((MEMCONF_SCRROWS - 25) * 80)
+ .byte <((MEMCONF_SCRROWS - 50) * 80)
+
+m65_scrtab_colviewmax_hi: // maximum allowed color viewport start - high byte
+
+ .byte >((MEMCONF_SCRROWS - 25) * 80)
+ .byte >((MEMCONF_SCRROWS - 25) * 80)
+ .byte >((MEMCONF_SCRROWS - 50) * 80)
+
+m65_scrtab_scrolx: // values for VIC_SCROLX
+
+ .byte $C8
+ .byte $CA
+ .byte $CA
+
+m65_scrtab_rowoffset_lo: // row offsets - low bytes
+
+ .byte <(80 * 0), <(80 * 1), <(80 * 2), <(80 * 3), <(80 * 4), <(80 * 5), <(80 * 6), <(80 * 7), <(80 * 8), <(80 * 9)
+ .byte <(80 * 10), <(80 * 11), <(80 * 12), <(80 * 13), <(80 * 14), <(80 * 15), <(80 * 16), <(80 * 17), <(80 * 18), <(80 * 19)
+ .byte <(80 * 20), <(80 * 21), <(80 * 22), <(80 * 23), <(80 * 24), <(80 * 25), <(80 * 26), <(80 * 27), <(80 * 28), <(80 * 29)
+ .byte <(80 * 30), <(80 * 31), <(80 * 32), <(80 * 33), <(80 * 34), <(80 * 35), <(80 * 36), <(80 * 37), <(80 * 38), <(80 * 39)
+ .byte <(80 * 40), <(80 * 41), <(80 * 42), <(80 * 43), <(80 * 44), <(80 * 45), <(80 * 46), <(80 * 47), <(80 * 48), <(80 * 49)
+
+m65_scrtab_rowoffset_hi: // row offsets - high bytes
+
+ .byte >(80 * 0), >(80 * 1), >(80 * 2), >(80 * 3), >(80 * 4), >(80 * 5), >(80 * 6), >(80 * 7), >(80 * 8), >(80 * 9)
+ .byte >(80 * 10), >(80 * 11), >(80 * 12), >(80 * 13), >(80 * 14), >(80 * 15), >(80 * 16), >(80 * 17), >(80 * 18), >(80 * 19)
+ .byte >(80 * 20), >(80 * 21), >(80 * 22), >(80 * 23), >(80 * 24), >(80 * 25), >(80 * 26), >(80 * 27), >(80 * 28), >(80 * 29)
+ .byte >(80 * 30), >(80 * 31), >(80 * 32), >(80 * 33), >(80 * 34), >(80 * 35), >(80 * 36), >(80 * 37), >(80 * 38), >(80 * 39)
+ .byte >(80 * 40), >(80 * 41), >(80 * 42), >(80 * 43), >(80 * 44), >(80 * 45), >(80 * 46), >(80 * 47), >(80 * 48), >(80 * 49)
+
+// Jumptable for screen control codes support. To improve performance, should be sorted
+// starting from the least probable routine.
+
+m65_chrout_screen_jumptable_codes:
+
+ .byte KEY_CLR
+ .byte KEY_HOME
+ .byte KEY_C65_SHIFT_OFF
+ .byte KEY_C65_SHIFT_ON
+ .byte KEY_TXT
+ .byte KEY_GFX
+ .byte KEY_RVS_OFF
+ .byte KEY_RVS_ON
+ .byte KEY_CRSR_RIGHT
+ .byte KEY_CRSR_LEFT
+ .byte KEY_CRSR_DOWN
+ .byte KEY_CRSR_UP
+ .byte KEY_TAB
+ .byte KEY_LINE_FEED
+ .byte KEY_UNDERLINE_ON
+ .byte KEY_UNDERLINE_OFF
+ .byte KEY_FLASHING_ON
+ .byte KEY_FLASHING_OFF
+ .byte KEY_TAB_SET_CLR
+ .byte KEY_ESC
+ .byte KEY_BELL
+
+__m65_chrout_screen_jumptable_quote_guard:
+
+ .byte KEY_INS
+ .byte KEY_STOP
+ .byte KEY_DEL
+ .byte KEY_RETURN
+
+__m65_chrout_screen_jumptable_codes_end:
+
+
+.const m65_chrout_list = List().add(
+
+ m65_chrout_screen_CLR,
+ m65_chrout_screen_HOME,
+ m65_chrout_screen_SHIFT_OFF,
+ m65_chrout_screen_SHIFT_ON,
+ m65_chrout_screen_TXT,
+ m65_chrout_screen_GFX,
+ m65_chrout_screen_RVS_OFF,
+ m65_chrout_screen_RVS_ON,
+ m65_chrout_screen_CRSR_RIGHT,
+ m65_chrout_screen_CRSR_LEFT,
+ m65_chrout_screen_CRSR_DOWN,
+ m65_chrout_screen_CRSR_UP,
+ m65_chrout_screen_TAB,
+ m65_chrout_screen_LINE_FEED,
+ m65_chrout_screen_UNDERLINE_ON,
+ m65_chrout_screen_UNDERLINE_OFF,
+ m65_chrout_screen_FLASHING_ON,
+ m65_chrout_screen_FLASHING_OFF,
+ m65_chrout_screen_TAB_SET_CLR,
+ m65_chrout_screen_ESC,
+ m65_chrout_screen_BELL,
+ m65_chrout_screen_INS,
+ m65_chrout_screen_STOP,
+ m65_chrout_screen_DEL,
+ m65_chrout_screen_RETURN
+)
+
+m65_chrout_screen_jumptable:
+
+ // Note: 65C02 has the page boundary vector bug fixed!
+ put_jumptable(m65_chrout_list)
diff --git a/src/kernal/screen_m65/mega65_scrmodeget.s b/src/kernal/screen_m65/mega65_scrmodeget.s
new file mode 100644
index 00000000..b541aa37
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_scrmodeget.s
@@ -0,0 +1,14 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Output:
+// .A - current screen mode
+//
+
+
+M65_SCRMODEGET:
+
+ lda M65_SCRMODE
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_scrmodeset.s b/src/kernal/screen_m65/mega65_scrmodeset.s
new file mode 100644
index 00000000..51edf6cd
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_scrmodeset.s
@@ -0,0 +1,128 @@
+// #LAYOUT# M65 KERNAL_1 #TAKE
+// #LAYOUT# * * #IGNORE
+
+//
+// Input:
+// - .A - desired screen mode
+//
+// Output:
+// - Carry set = unsupported screen mode
+// - Carry clear = screen mode switched correctly
+//
+
+
+M65_SCRMODESET:
+
+ cmp #$03
+ bcs m65_scrmodeset_rts // branch if unsupported screen mode
+
+ // Preserve .X, move desired mode to .X, disable interrupts
+
+ phx
+ sei
+
+ // Perform the switch
+
+ jsr m65_scrmodeset_internal
+
+ // Re-enable interrupts, restore .X
+
+ cli
+ plx
+
+ // FALLTROUGH
+
+m65_scrmodeset_rts:
+
+ rts
+
+m65_scrmodeset_internal: // entry point for M65_MODE65
+
+ // Store desired screen mode
+
+ sta M65_SCRMODE
+
+ // Set flags/variables for 40/80 columns and 25/50 rows
+
+ tax
+
+ jsr viciv_hotregs_on
+
+ lda m65_scrtab_scrolx,x
+ sta VIC_SCROLX
+ lda m65_scrtab_vic_ctrlb,x
+ sta VIC_CTRLB
+
+ jsr viciv_hotregs_off
+
+ // Set the logical row length to 80
+
+ ldx #$50
+ stx VIC_CHARSTEP+0
+ ldx #$00
+ stx VIC_CHARSTEP+1
+
+ // Set the following locations:
+ // - M65_SCRWINMODE - for scroll-console mode
+ // - M65_SCRSEG, VIC_SCRNPTR+2/+3 - for screen in $0001xxxx area
+
+ stx M65_SCRWINMODE // .X = 0
+ stx M65_SCRSEG+1
+ stx VIC_SCRNPTR+3
+ inx
+ stx M65_SCRSEG+0
+ stx VIC_SCRNPTR+2
+
+ // Set the following locations:
+ // - M65_SCRBASE - for screen starting from $xxxx9000
+ // - VIC_SCRNPTR+0/+1 - for screen viewport start
+ // - M65_COLVIEW, VIC_COLPTR - for using color memory from the start
+
+ ldx #>MEMCONF_SCRBASE
+ stx M65_SCRBASE+1
+ stx VIC_SCRNPTR+1
+
+ ldx #MEMCONF_CHRBASE
+ sta VIC_CHARPTR+1
+ lda #$01
+ sta VIC_CHARPTR+2
+
+ // Set the following locations:
+ // - M65_SCRGUARD, M65_COLGUARD - guards for virtual screen end
+ // - M65_COLVIEWMAX - guard for viewport start
+ // - M65_SCRCOLMAX - maximum allowed column
+
+ ldx #<(MEMCONF_SCRBASE + 80 * MEMCONF_SCRROWS)
+ stx M65_SCRGUARD+0
+ ldx #>(MEMCONF_SCRBASE + 80 * MEMCONF_SCRROWS)
+ stx M65_SCRGUARD+1
+
+ ldx #<(80 * MEMCONF_SCRROWS)
+ stx M65_COLGUARD+0
+ ldx #>(80 * MEMCONF_SCRROWS)
+ stx M65_COLGUARD+1
+
+ ldx M65_SCRMODE
+ lda m65_scrtab_colviewmax_lo, x
+ sta M65_COLVIEWMAX+0
+ lda m65_scrtab_colviewmax_hi, x
+ sta M65_COLVIEWMAX+1
+ lda m65_scrtab_txtwidth,x
+ dec_a
+ sta M65_SCRCOLMAX
+
+ rts
diff --git a/src/kernal/screen_m65/mega65_setwin.s b/src/kernal/screen_m65/mega65_setwin.s
new file mode 100644
index 00000000..4aecdc27
--- /dev/null
+++ b/src/kernal/screen_m65/mega65_setwin.s
@@ -0,0 +1,64 @@
+// #LAYOUT# M65 KERNAL_0 #TAKE
+// #LAYOUT# * * #IGNORE
+
+
+M65_SETWIN_XY:
+
+ stx M65_TXTWIN_X0
+ sty M65_TXTWIN_Y0
+
+ rts
+
+
+M65_SETWIN_WH:
+
+ pha
+
+ clc
+ txa
+ adc M65_TXTWIN_X0
+ sta M65_TXTWIN_X1
+
+ clc
+ tya
+ adc M65_TXTWIN_Y0
+ sta M65_TXTWIN_Y1
+
+ pla
+ rts
+
+
+M65_SETWIN_N:
+
+ pha
+
+ lda #$00
+ sta M65_SCRWINMODE
+
+ jsr m65_screen_set_indx
+
+ pla
+ rts
+
+
+M65_SETWIN_Y:
+
+ pha
+
+ lda #$FF
+ sta M65_SCRWINMODE
+
+ jsr m65_screen_set_indx
+
+ // XXX consider calling HOME instead
+
+ lda M65_TXTWIN_X0
+ sta M65__TXTCOL
+
+ lda M65_TXTWIN_Y0
+ sta M65__TXTROW
+
+ jsr m65_screen_upd_txtrow_off
+
+ pla
+ rts
diff --git a/src/kernal/tape/load_tape_normal.s b/src/kernal/tape/load_tape_normal.s
index c1ecd776..3a38500b 100644
--- a/src/kernal/tape/load_tape_normal.s
+++ b/src/kernal/tape/load_tape_normal.s
@@ -80,13 +80,9 @@ load_tape_normal_switch_turbo:
!:
#endif
-#if CONFIG_TAPE_NO_ERROR_CORRECTION
- lda RIPRTY
- cmp #$01 // sets Carry if checksum verification fails
-#else
jsr load_TAPE1_to_MEMUSS
jsr tape_normal_get_data_2
-#endif
+
#if !CONFIG_TAPE_AUTODETECT
bcs load_tape_normal_header // block load error, try again
#else
@@ -137,13 +133,9 @@ load_tape_normal_payload:
jsr lvs_check_EAL
bne_16 tape_load_error // amount of data read does not match header info
-#if CONFIG_TAPE_NO_ERROR_CORRECTION
- lda RIPRTY
- cmp #$01 // sets Carry if checksum verification fails
-#else
jsr lvs_STAL_to_MEMUSS
jsr tape_normal_get_data_2
-#endif
+
bcs_16 tape_load_error
jmp tape_load_success
diff --git a/src/kernal/tape/tape_common.s b/src/kernal/tape/tape_common.s
index e46ce6b1..4b896671 100644
--- a/src/kernal/tape/tape_common.s
+++ b/src/kernal/tape/tape_common.s
@@ -223,6 +223,14 @@ tape_handle_header:
jsr lvs_STAL_to_MEMUSS
+#if ROM_LAYOUT_M65
+
+ // Switch to legacy mode if needed
+
+ jsr m65_load_autoswitch_tape
+
+#endif
+
// Print LOADING and start address
jsr lvs_display_loading_verifying
diff --git a/src/kernal/tape/tape_common_screen.s b/src/kernal/tape/tape_common_screen.s
index 19264dee..9aa968e8 100644
--- a/src/kernal/tape/tape_common_screen.s
+++ b/src/kernal/tape/tape_common_screen.s
@@ -11,8 +11,6 @@
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
-// XXX for Mega65 do not disable screen, just disable badline emulation
-
tape_screen_on_motor_off:
@@ -21,18 +19,14 @@ tape_screen_on_motor_off:
lda COLSTORE
sta VIC_EXTCOL
-#if !CONFIG_MB_MEGA_65
+#if !ROM_LAYOUT_M65
jmp screen_on
#else
- // On Mega65 just reenable badline emulation
-
- lda #$FF
- sta M65_BADL_SLI
- sta VIC_KEY
-
+ jsr M65_MODEGET
+ bcs_16 screen_on // MEGA65 native mode does not have badlines, no need to enable/disable screen
rts
#endif
@@ -51,22 +45,20 @@ tape_screen_off_motor_on:
lda VIC_EXTCOL
sta COLSTORE
-#if !CONFIG_MB_MEGA_65
-
+#if !ROM_LAYOUT_M65
+
jsr screen_off
#else
- // On Mega65 we do not have to turn the screen off;
- // it is enough to disable badline emulation
-
- jsr mega65_unhide
- lda #$00
- sta M65_BADL_SLI
+ jsr M65_MODEGET
+ // XXX optimize this
+ bcs !+ // MEGA65 native mode does not have badlines, no need to enable/disable screen
+ jsr screen_off
+!:
#endif
-
jmp tape_motor_on
#endif
diff --git a/src/kernal/tape/tape_normal_get_data_1.s b/src/kernal/tape/tape_normal_get_data_1.s
index fd1242c6..963fcea9 100644
--- a/src/kernal/tape/tape_normal_get_data_1.s
+++ b/src/kernal/tape/tape_normal_get_data_1.s
@@ -9,9 +9,6 @@
// .Y not equal to 0 - returns error if data block is longer (length includes checksum)
-// XXX improve error handling - do not ignore second copy, handle damaged sync part
-
-
#if CONFIG_TAPE_NORMAL
@@ -21,10 +18,9 @@ tape_normal_get_data_1:
// and pointers for error log and correction mechanism
lda #$00
sta RIPRTY
-#if !CONFIG_TAPE_NO_ERROR_CORRECTION
+
sta PTR2
sta PTR1
-#endif
// FALLTROUGH
@@ -44,12 +40,6 @@ tape_normal_get_data_1_loop:
jsr tape_normal_get_byte
bcc tape_normal_get_data_1_loop_byte_OK
-
-#if CONFIG_TAPE_NO_ERROR_CORRECTION
-
- bcs tape_normal_get_data_1_fail
-
-#else
// Problem reading a byte, try to add it to the error log
@@ -71,8 +61,6 @@ tape_normal_get_data_1_loop:
bcc tape_normal_get_data_1_loop_advance
bcs tape_normal_get_data_1_success
-#endif
-
tape_normal_get_data_1_loop_byte_OK:
jsr tape_normal_get_marker
diff --git a/src/kernal/tape/tape_normal_get_data_2.s b/src/kernal/tape/tape_normal_get_data_2.s
index cf2a3763..2b88c12c 100644
--- a/src/kernal/tape/tape_normal_get_data_2.s
+++ b/src/kernal/tape/tape_normal_get_data_2.s
@@ -7,15 +7,13 @@
//
-#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_NO_ERROR_CORRECTION
+#if CONFIG_TAPE_NORMAL
tape_normal_get_data_2:
- // First check if there is a need to read anything
-
- lda PTR1
- beq tape_normal_get_data_2_log_checksum
+ // NOTE: Always read all the bytes fro second copy, to taht we stop
+ // at the moment when it is safe to start recording!
// Read sync of the block
@@ -28,11 +26,6 @@ tape_normal_get_data_2:
tape_normal_get_data_2_loop:
- // Check if there are missing bytes to read
- lda PTR1
- cmp PTR2
- beq tape_normal_get_data_2_log_checksum // branch if no more errors to correct
-
// Read missing bytes
jsr tape_normal_get_byte
diff --git a/src/kernal/tape/tape_normal_get_marker.s b/src/kernal/tape/tape_normal_get_marker.s
index 2055c581..350e8c49 100644
--- a/src/kernal/tape/tape_normal_get_marker.s
+++ b/src/kernal/tape/tape_normal_get_marker.s
@@ -29,18 +29,14 @@ tape_normal_get_marker_type:
-!: // Not an entry point!!!
-
- // XXX check for short pulses of turbo here
-
+ // Not an entry point!!!
+!:
jsr tape_normal_calibrate_during_pilot // while sync use short pulses for calibration
// FALLTROUGH
tape_normal_get_marker_while_sync:
- // (L,M) - end of byte, (L,S) - end of data
-
jsr tape_common_get_pulse
bcs !- // branch if short pulse
diff --git a/src/kernal/tape/tape_normal_get_pilot.s b/src/kernal/tape/tape_normal_get_pilot.s
index 214a7e1f..fad10a1d 100644
--- a/src/kernal/tape/tape_normal_get_pilot.s
+++ b/src/kernal/tape/tape_normal_get_pilot.s
@@ -27,7 +27,13 @@ tape_normal_get_pilot_header: // entry point, reset calibration, requir
sta __pulse_threshold_ML
lda #$80
+
+#if CONFIG_TAPE_AUTODETECT
+ ldy #$FF // marker: try to detect turbo
+ bmi tape_normal_get_pilot_header_cont
+#else
skip_2_bytes_trash_nvz
+#endif
// FALLTROUGH
@@ -42,6 +48,15 @@ tape_normal_get_pilot_short: // entry point, require 1x $40 pulses
lda #$01
+#if CONFIG_TAPE_AUTODETECT
+ ldy #$00 // marker: do not try to detect turbo
+ // FALLTROUGH
+tape_normal_get_pilot_header_cont:
+ sty INBIT
+#else
+ skip_2_bytes_trash_nvz
+#endif
+
// FALLTROUGH
tape_normal_get_pilot_common:
@@ -72,9 +87,12 @@ tape_normal_get_pilot_common_loop_inner:
bcc tape_normal_get_pilot_common_restart // not a pilot - try again
#if CONFIG_TAPE_AUTODETECT
+ bit INBIT
+ bpl !+
// Try to distinguish turbo by cheecking for short signals
cmp #$B9 // see comment in tape_common_autodetect.s
- bcs !+
+ bcs !++
+!:
#endif
jsr tape_normal_calibrate_during_pilot
diff --git a/src/kernal/tape/tape_normal_sync.s b/src/kernal/tape/tape_normal_sync.s
index e7ba9eb9..8a749e36 100644
--- a/src/kernal/tape/tape_normal_sync.s
+++ b/src/kernal/tape/tape_normal_sync.s
@@ -21,7 +21,7 @@ tape_normal_sync:
jsr tape_normal_get_marker_while_sync
bcs tape_normal_sync_fail // branch if end of data marker
-
+
jsr tape_normal_get_byte
bcs tape_normal_sync_fail
diff --git a/strings/00A54591 b/strings/00A54591
new file mode 100644
index 00000000..ceb2ae9a
--- /dev/null
+++ b/strings/00A54591
@@ -0,0 +1,3 @@
+$00 + LDA $45 + STA (zeropage addres does not match), Y
+
+Instruction + some parts. Trivial - not copyrightable.
diff --git a/strings/4241534943 b/strings/4241534943
new file mode 100644
index 00000000..7fa01f86
--- /dev/null
+++ b/strings/4241534943
@@ -0,0 +1,3 @@
+'BASIC' in PETSCII
+
+Programming language name. Not copyrightable.
diff --git a/strings/48A94648 b/strings/48A94648
new file mode 100644
index 00000000..c31ba8e6
--- /dev/null
+++ b/strings/48A94648
@@ -0,0 +1,4 @@
+PHA + LDA #$46 + PHA
+
+Pushing return address to stack (one byte matched by accident). Not creative - not copyrightable.
+
diff --git a/strings/490FDAA2A5 b/strings/490FDAA2A5
new file mode 100644
index 00000000..13c5eb0a
--- /dev/null
+++ b/strings/490FDAA2A5
@@ -0,0 +1,4 @@
+2*PI mantissa + LDA (zeropage address does not match)
+
+Part of widely used floating point constant (which is generated automatically) + a part of instruction - not creative, not copyrightable.
+
diff --git a/strings/60A9802CA9 b/strings/60A9802CA9
new file mode 100644
index 00000000..4cd8f179
--- /dev/null
+++ b/strings/60A9802CA9
@@ -0,0 +1,3 @@
+RTS + LDA #$80 + BIT (to skip 2 bytes) + LDA (value does not match)
+
+Routine starting with .A loaded with one of 2 values, depending on entrance address. Common technique on 6502. Not creative - not copyrightable.
diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc
index e54a6ef3..4a021996 100644
--- a/tools/generate_strings.cc
+++ b/tools/generate_strings.cc
@@ -202,10 +202,22 @@ const StringEntryList GLOBAL_Keywords_02 = { ListType::KEYWORDS, "keywords_02",
{ false, true, false, false, "K02_07", "COLD", }, // Not present in CBM BASIC dialects, but common to some extensions (*)
{ false, true, false, false, "K02_08", "MEM", }, // Not present in CBM BASIC dialects, Open ROMs specific
+ { false, true, false, false, "K02_09", "SYSINFO", }, // Not present in CBM BASIC dialects, Open ROMs specific
// (*) see https://sourceforge.net/p/vice-emu/code/HEAD/tree/trunk/vice/src/petcat.c
} };
+// extended BASIC keywords - list reserved for hardware dependent BASIC commands
+
+const StringEntryList GLOBAL_Keywords_03_M65 = { ListType::KEYWORDS, "keywords_03",
+{
+ // STD M65 U64 X16
+
+ { false, true, false, false, "K03_01", "TEST", }, // Not present in CBM BASIC dialects, Open ROMs specific
+
+} };
+
+
// BASIC errors - all dialects
/*
@@ -272,22 +284,44 @@ const StringEntryList GLOBAL_Errors = { ListType::STRINGS_BASIC, "errors",
const StringEntryList GLOBAL_MiscStrings = { ListType::STRINGS_BASIC, "misc",
{
// STD M65 U64 X16 --- misc strings as on CBM machines
- { true, true, true, true, "STR_RET_QM", "\r?" },
- { true, true, true, true, "STR_BYTES", " BASIC BYTES FREE" }, // https://github.com/stefanhaustein/expressionparser
- { 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 " },
- { false, true, false, false, "STR_IF_SURE", "\rARE YOU SURE? " }, // https://docs.microsoft.com/en-us/windows/win32/uxguide/mess-confirm
+ { true, true, true, true, "STR_RET_QM", "\r?" },
+ { true, true, true, true, "STR_BYTES", " BASIC BYTES FREE" }, // https://github.com/stefanhaustein/expressionparser
+ { 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 " },
+ { false, true, false, false, "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 Open ROMs, not present in CBM ROMs
- { true, true, true, true, "STR_BRK_AT", "\rBRK AT $" },
- { false, true, false, false, "STR_MEM_HDR", "\r\x12 AREA START SIZE \r" },
- { false, true, false, false, "STR_MEM_1", " $" },
- { false, true, false, false, "STR_MEM_2", " " },
- { false, true, false, false, "STR_MEM_TEXT", "\r TEXT" },
- { false, true, false, false, "STR_MEM_VARS", "\r VARS" },
- { false, true, false, false, "STR_MEM_ARRS", "\r ARRS" },
- { false, true, false, false, "STR_MEM_STRS", "\r STRS" },
- { false, true, false, false, "STR_MEM_FREE", "\r\r FREE" },
+ { true, true, true, true, "STR_BRK_AT", "\rBRK AT $" },
+
+ { false, true, false, false, "STR_ORS", "OPEN ROMS BASIC & KERNAL\r" },
+ { false, true, false, false, "STR_ORS_LEGACY_1", "OPEN ROMS " },
+ { false, true, false, false, "STR_ORS_LEGACY_2", "\r\rLEGACY MODE " },
+
+ { false, true, false, false, "STR_MEM_HDR", "\r\x12 AREA START SIZE \r" },
+ { false, true, false, false, "STR_MEM_1", " $" },
+ { false, true, false, false, "STR_MEM_2", " " },
+ { false, true, false, false, "STR_MEM_TEXT", "\r TEXT" },
+ { false, true, false, false, "STR_MEM_VARS", "\r VARS" },
+ { false, true, false, false, "STR_MEM_ARRS", "\r ARRS" },
+ { false, true, false, false, "STR_MEM_STRS", "\r STRS" },
+ { false, true, false, false, "STR_MEM_FREE", "\r\r FREE" },
+
+ { false, true, false, false, "STR_SI_HEADER", "OPEN ROMS, " },
+ { false, true, false, false, "STR_SI_MODE64", "LEGACY MODE" },
+ { false, true, false, false, "STR_SI_MODE65", "NATIVE MODE" },
+ { false, true, false, false, "STR_SI_HDR_REL", "\rRELEASE " },
+ { false, true, false, false, "STR_SI_HDR_HW", "BOARD : " },
+ { false, true, false, false, "STR_SI_HW_01", "MEGA65 R1" },
+ { false, true, false, false, "STR_SI_HW_02", "MEGA65 R2" },
+ { false, true, false, false, "STR_SI_HW_03", "MEGA65 R3" },
+ { false, true, false, false, "STR_SI_HW_21", "MEGAPHONE R1" },
+ { false, true, false, false, "STR_SI_HW_40", "NEXYS4 PSRAM" },
+ { false, true, false, false, "STR_SI_HW_41", "NEXYS4 DDR" },
+ { false, true, false, false, "STR_SI_HW_42", "NEXYS4 DDR WIDGET" },
+ { false, true, false, false, "STR_SI_HW_FD", "WUKONG A100T" },
+ { false, true, false, false, "STR_SI_HW_FE", "SIMULATION VHDL" },
+ { false, true, false, false, "STR_SI_HW_XX", "UNKNOWN ID $" },
+ { false, true, false, false, "STR_SI_HDR_VID", "\rVIDEO : " },
// Note: depending on configuration, additional strings will be added here
} };
@@ -1097,68 +1131,91 @@ void DataSet::generateConfigDepStrings()
// Generate string to show the build features
std::string featureStr;
-
+ std::string featureStrM65 = "\r";
+
// Tape support features
if (GLOBAL_ConfigOptions["CONFIG_TAPE_NORMAL"] && GLOBAL_ConfigOptions["CONFIG_TAPE_TURBO"])
{
- featureStr = "TAPE LOAD NORMAL TURBO\r";
+ featureStr += "TAPE LOAD NORMAL TURBO\r";
+ featureStrM65 += "TAPE : LOAD NORMAL TURBO\r";
}
else if (GLOBAL_ConfigOptions["CONFIG_TAPE_NORMAL"])
{
- featureStr = "TAPE LOAD NORMAL\r";
+ featureStr += "TAPE LOAD NORMAL\r";
+ featureStrM65 += "TAPE : LOAD NORMAL\r";
}
else if (GLOBAL_ConfigOptions["CONFIG_TAPE_TURBO"])
{
- featureStr = "TAPE LOAD TURBO\r";
+ featureStr += "TAPE LOAD TURBO\r";
+ featureStrM65 += "TAPE : LOAD TURBO\r";
}
// IEC support features
if (GLOBAL_ConfigOptions["CONFIG_IEC"])
{
- featureStr += "IEC";
+ featureStr += "IEC";
+ featureStrM65 += "IEC :";
bool extendedIEC = false;
if (GLOBAL_ConfigOptions["CONFIG_IEC_BURST_CIA1"])
{
- featureStr += " BURST1";
- extendedIEC = true;
+ featureStr += " BURST1";
+ extendedIEC = true;
}
if (GLOBAL_ConfigOptions["CONFIG_IEC_BURST_CIA2"])
{
- featureStr += " BURST2";
- extendedIEC = true;
+ featureStr += " BURST2";
+ extendedIEC = true;
}
if (GLOBAL_ConfigOptions["CONFIG_IEC_BURST_MEGA65"])
{
- featureStr += " BURST";
- extendedIEC = true;
+ featureStr += " BURST";
+ featureStrM65 += " BURST";
+ extendedIEC = true;
}
if (GLOBAL_ConfigOptions["CONFIG_IEC_DOLPHINDOS"])
{
- featureStr += " DOLPHIN";
- extendedIEC = true;
+ featureStr += " DOLPHIN";
+ featureStrM65 += " DOLPHIN";
+ extendedIEC = true;
}
if (GLOBAL_ConfigOptions["CONFIG_IEC_JIFFYDOS"])
{
- featureStr += " JIFFY";
- extendedIEC = true;
+ featureStr += " JIFFY";
+ featureStrM65 += " JIFFY";
+ extendedIEC = true;
}
- if (!extendedIEC) featureStr += " NORMAL";
-
- featureStr += "\r";
+ if (!extendedIEC)
+ {
+ featureStr += " NORMAL ONLY";
+ featureStrM65 += " NORMAL ONLY";
+ }
+
+ featureStr += "\r";
+ featureStrM65 += "\r";
}
-
+ else
+ {
+ featureStrM65 += "IEC : NO\r";
+ }
+
// RS-232 support features
if (GLOBAL_ConfigOptions["CONFIG_RS232_UP2400"]) featureStr += "UP2400\r";
if (GLOBAL_ConfigOptions["CONFIG_RS232_UP9600"]) featureStr += "UP9600\r";
+ featureStrM65 += "RS-232 : NO\r";
+
+ // CBDOS features
+
+ featureStrM65 += "CBDOS : NO FDD/SD/RAM SUPPORT\r";
+
// Keyboard support features
if (GLOBAL_ConfigOptions["CONFIG_KEYBOARD_C128"]) featureStr += "KBD 128\r";
@@ -1172,18 +1229,34 @@ void DataSet::generateConfigDepStrings()
// List found
- if (GLOBAL_ConfigOptions["CONFIG_SHOW_FEATURES"])
+ if (GLOBAL_ConfigOptions["CONFIG_SHOW_FEATURES"] || GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"])
{
StringEntry newEntry1 = { true, true, true, true, "STR_PAL", "PAL\r" };
StringEntry newEntry2 = { true, true, true, true, "STR_NTSC", "NTSC\r" };
- StringEntry newEntry3 = { true, true, true, true, "STR_FEATURES", featureStr };
stringEntryList.list.push_back(newEntry1);
stringEntryList.list.push_back(newEntry2);
- stringEntryList.list.push_back(newEntry3);
-
- break;
}
+
+ if (GLOBAL_ConfigOptions["CONFIG_SHOW_FEATURES"])
+ {
+ StringEntry newEntry = { true, true, true, true, "STR_FEATURES", featureStr };
+ stringEntryList.list.push_back(newEntry);
+ }
+
+ if (GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"])
+ {
+ StringEntry newEntry = { false, true, false, false, "STR_SI_FEATURES", featureStrM65 };
+ stringEntryList.list.push_back(newEntry);
+ }
+
+ if (!GLOBAL_ConfigOptions["CONFIG_BRAND_CUSTOM_BUILD"] || GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"])
+ {
+ StringEntry newEntry = { true, true, true, true, "STR_PRE_REV", "RELEASE " };
+ stringEntryList.list.push_back(newEntry);
+ }
+
+ break;
}
}
@@ -1760,6 +1833,7 @@ void writeStrings()
dataSetM65.addStrings(GLOBAL_Keywords_V2);
dataSetM65.addStrings(GLOBAL_Keywords_01);
dataSetM65.addStrings(GLOBAL_Keywords_02);
+ dataSetM65.addStrings(GLOBAL_Keywords_03_M65);
dataSetM65.addStrings(GLOBAL_Errors);
dataSetM65.addStrings(GLOBAL_MiscStrings);
diff --git a/tools/patch_chargen.cc b/tools/patch_chargen.cc
index 49bef286..325aee72 100644
--- a/tools/patch_chargen.cc
+++ b/tools/patch_chargen.cc
@@ -1,6 +1,6 @@
//
// Utility to patch the character generator file to create
-// font for Mega65 native mode and possibly other uses
+// font for MEGA65 native mode and possibly other uses
//
#include "common.h"
diff --git a/tools/release.cc b/tools/release.cc
index 38d00872..573d0dba 100644
--- a/tools/release.cc
+++ b/tools/release.cc
@@ -34,7 +34,7 @@ const std::vector ROM_DEFINITIONS =
8192, // file size
0x1F52, // signature offset 1
0, // signature offset 2
- 0x0004, // BASIC ID offset
+ 0x0007, // BASIC ID offset
0 // KERNAL ID offset
},
@@ -52,14 +52,14 @@ const std::vector ROM_DEFINITIONS =
128 * 1024, // file size
0xBF52, // signature offset 1
0xE4B9, // signature offset 2
- 0xA004, // BASIC ID offset
+ 0xA007, // BASIC ID offset
0xFF80 // KERNAL ID offset
},
};
const uint32_t MAX_FILE_SIZE = 128 * 1024;
-const std::vector STR_MEGABAS = { 0x4D, 0x45, 0x47, 0x41, 0x42, 0x41, 0x53, 0x32 };
+const std::vector STR_BASIC = { 0x42, 0x41, 0x53, 0x49, 0x43 };
const std::vector STR_OR = { 0x4F, 0x52 };
const std::vector STR_SNAPSHOT = { 0x28, 0x44, 0x45, 0x56, 0x45, 0x4C, 0x20, 0x53,
0x4E, 0x41, 0x50, 0x53, 0x48, 0x4F, 0x54, 0x29,
@@ -409,7 +409,7 @@ void ROMFile::recognizeSrcFile()
if (srcFileContent.size() != SPEC.fileSize) continue;
if ((SPEC.idBasicOffset != 0) &&
- memcmp(&srcFileContent[SPEC.idBasicOffset], STR_MEGABAS.data(), STR_MEGABAS.size()) != 0)
+ memcmp(&srcFileContent[SPEC.idBasicOffset], STR_BASIC.data(), STR_BASIC.size()) != 0)
{
continue;
}
@@ -440,7 +440,7 @@ void ROMFile::dropUnmatchingDst()
// Drop unmatching destination file data
if (!dstFileContent.empty() && (descPtr->idBasicOffset != 0) &&
- memcmp(&dstFileContent[descPtr->idBasicOffset], STR_MEGABAS.data(), STR_MEGABAS.size()) != 0)
+ memcmp(&dstFileContent[descPtr->idBasicOffset], STR_BASIC.data(), STR_BASIC.size()) != 0)
{
dstFileContent.clear();
}