diff --git a/.gitignore b/.gitignore index 1f3eaccc..58427e72 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ build/* # Various IDE project files, temporary files, etc. dump.mem +vgcore* *project .*swp *.log diff --git a/.gitmodules b/.gitmodules index e69de29b..1ea12891 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "assembler/acme"] + path = assembler/acme + url = https://github.com/MEGA65/acme diff --git a/CONFIG.md b/CONFIG.md index 88b6b7c9..3b096f4a 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -13,7 +13,7 @@ Just edit them and recompile the project. To enable particular option - uncommen Note however, that features do not came for free - enabling them needs some additional ROM space (in BASIC segment, in KERNAL segment, or in both), which is VERY limited on the target machines. Some options might be unavailable for speecific targets - read the comments in the configuration files. Some options might also carry compatibility and/or performance hit - so choose wisely. -## Hardware platform and brand +## Hardware platform ### `CONFIG_PLATFORM_COMMODORE_64` @@ -25,13 +25,17 @@ Since Open ROMs is highly modular, it should be possible to add other platforms * 8KB ROM area `$A000`-`$BFFF` * 8KB ROM area `$E000`-`$FFFF` -### `CONFIG_MB_MEGA_65`, `CONFIG_MB_ULTIMATE_64` +### `CONFIG_MB_M65`, `CONFIG_MB_U64` -Select if the ROM is going to be used exclusively on the specific motherboard. It prevents from enabling options not having sense, skips initialization of C128-only registers, etc. +Select if the ROM is going to be used exclusively on the specified motherboard. It prevents from enabling options not having sense, skips initialization of C128-only registers, and enables motherboard-specific features. + +## Brand + +Branding is only allowed for C64 platform, if no motherboard is specified. ### `CONFIG_BRAND_CUSTOM` -Intended for custom builds, which are not to be redistributed. Allows to configure branding with `CONFIG_CUSTOM_BRAND` varaible +Intended for custom builds, for private purposes. Allows to configure branding with `CONFIG_CUSTOM_BRAND` macro. ### `CONFIG_BRAND_GENERIC` @@ -41,12 +45,10 @@ If you don't know which variant to choose - select this one. Use this one for any kind of testing/experimental build. -### `CONFIG_BRAND_MEGA_65`, `CONFIG_BRAND_ULTIMATE_64` - -Select if you are using appropriate motherboard. - ## Processor instruction set +Processor type should be set only for C64 platform, if no motherboard is specified. Otherwise, it will be selected automatically. Setting proper CPU allows to enable various size/performance optimizations. + ### `CONFIG_CPU_MOS_6502` Choose if your CPU only supports the original MOS Technology 6502 instruction set, like: @@ -57,35 +59,20 @@ Choose if your CPU only supports the original MOS Technology 6502 instruction se If unsure - select this one. +### `CONFIG_CPU_DTV_6502` + +Choose if your CPU only supports extended C64 DTV instruction set. + +### `CONFIG_CPU_RCW_65C02` + +Choose if your CPU supports the Rockwell 65C02 instruction set. + ### `CONFIG_CPU_WDC_65C02` Choose if your CPU supports the Western Design Center 65C02 instruction set, like: * WDC 65C02 - used in the Turbo Master accelerator -It enables some speed/size code optimizations. - -### `CONFIG_CPU_CSG_65CE02` - -Choose if your CPU supports the Commodore Semiconductor Group 65CE02 instruction set, like: - -* CSG 65CE02 -* CSG 4510 - microcontroller used in the Commodore 65 prototypes - -It enables some speed/size code optimizations. - -### `CONFIG_CPU_CSG_4510` - -Choose if your CPU supports the Commodore Semiconductor Group 4510 instruction set, like: - -* CSG 4510 - microcontroller used in the Commodore 65 prototypes - -It enables some speed/size code optimizations and allows C65 memory mapping to work. - -### `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. - ### `CONFIG_CPU_WDC_65816` Choose if your CPU supports the 16-bit Western Design Center 65816 instruction set, like: @@ -93,7 +80,12 @@ Choose if your CPU supports the 16-bit Western Design Center 65816 instruction s * WDC 65C816 - used in the Flash 8 accelerator * WDC 65C816S - used in the SuperCPU accelerator -It enables some speed/size code optimizations. +### `CONFIG_CPU_CSG_65CE02` + +Choose if your CPU supports the Commodore Semiconductor Group 65CE02 instruction set, like: + +* CSG 65CE02 +* CSG 4510 - microcontroller used in the Commodore 65 prototypes ## Memory model @@ -115,7 +107,9 @@ 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. -## IEC devices +## IEC bus + +IEC bus, also known as Serial Port, is a standard interface to connect disk drives, printers, SD2IEC device, etc. ### `CONFIG_IEC` @@ -145,7 +139,7 @@ Needs about 430 bytes in KERNAL segment. If unsure - enable. Causes screen blanking during JiffyDOS file loading to increase performance. -## Tape support +## Tape deck 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. @@ -175,15 +169,15 @@ 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. -## Multiple SID support +## Sound 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. +The original Commodore 64 had one SID sound chip 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. The SID support in the ROM is very limited - it only disables the sound during startup or warm restart (when STOP+RESTORE is pressed or BRK assembler instruction is executed). -### `CONFIG_SID_2ND` and `CONFIG_SID_3RD` +### `CONFIG_SID_2ND_ADDRESS` and `CONFIG_SID_3RD_ADDRESS` -Each of them add support for one additional SID - addresses should be given in `CONFIG_SID_2ND_ADDRESS` and `CONFIG_SID_3RD_ADDRESS`, respectively. Do not use when `CONFIG_MB_MEGA_65` is selected - the motherboard support code already knows the SID locations. +Each of them add support for one additional SID - addresses should be given as parameter, respectively. Do not use when `CONFIG_MB_M65` is selected - the motherboard support code already knows the SID locations. Each of these options needs 3 bytes in KERNAL segment. @@ -191,7 +185,7 @@ Each of these options needs 3 bytes in KERNAL segment. Cause the system to support SIDs in `$D4xx` and `$D5xx` ranges, respectively. -Each of them needs a couple of bytes in KERNAL segment - but they can share some code, and `$D4xx` range support replaces the standard `$D400` address handling, so exact amount depends on the exact configuration. Do not use when `CONFIG_MB_MEGA_65` is selected - the motherboard support code already knows the SID locations. +Each of them needs a couple of bytes in KERNAL segment - but they can share some code, and `$D4xx` range support replaces the standard `$D400` address handling, so exact amount depends on the exact configuration. Do not use when `CONFIG_MB_M65` is selected - the motherboard support code already knows the SID locations. ## Keyboard diff --git a/Makefile b/Makefile index 62da0476..171ef80f 100644 --- a/Makefile +++ b/Makefile @@ -64,9 +64,17 @@ 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) +DIR_ACME = assembler/acme/src +HDR_ACME = $(filter-out $(wildcard $(DIR_ACME)/_*.h),$(wildcard $(DIR_ACME)/*.h)) +SRC_ACME = $(DIR_ACME)/acme.c $(DIR_ACME)/platform.c $(DIR_ACME)/alu.c $(DIR_ACME)/typesystem.c \ + $(DIR_ACME)/cliargs.c $(DIR_ACME)/global.c $(DIR_ACME)/output.c $(DIR_ACME)/flow.c \ + $(DIR_ACME)/macro.c $(DIR_ACME)/cpu.c $(DIR_ACME)/encoding.c $(DIR_ACME)/pseudoopcodes.c \ + $(DIR_ACME)/dynabuf.c $(DIR_ACME)/mnemo.c $(DIR_ACME)/input.c $(DIR_ACME)/section.c \ + $(DIR_ACME)/symbol.c $(DIR_ACME)/tree.c + # Generated files -GEN_BASIC = build/,generated/float_constants.s +GEN_BASIC = build/,generated/,float_constants.s GEN_KERNAL = # List of build directories @@ -89,12 +97,12 @@ CFG_X16 = src/,,config_cx16.s # List of files with generated strings -GEN_STR_CUS = $(DIR_CUS)/,generated/packed_strings.s -GEN_STR_GEN = $(DIR_GEN)/,generated/packed_strings.s -GEN_STR_TST = $(DIR_TST)/,generated/packed_strings.s -GEN_STR_M65 = $(DIR_M65)/,generated/packed_strings.s -GEN_STR_U64 = $(DIR_U64)/,generated/packed_strings.s -GEN_STR_X16 = $(DIR_X16)/,generated/packed_strings.s +GEN_STR_CUS = $(DIR_CUS)/,generated/,packed_strings.s +GEN_STR_GEN = $(DIR_GEN)/,generated/,packed_strings.s +GEN_STR_TST = $(DIR_TST)/,generated/,packed_strings.s +GEN_STR_M65 = $(DIR_M65)/,generated/,packed_strings.s +GEN_STR_U64 = $(DIR_U64)/,generated/,packed_strings.s +GEN_STR_X16 = $(DIR_X16)/,generated/,packed_strings.s # Dependencies - helper variables @@ -104,7 +112,6 @@ DEP_KERNAL = $(SRC_KERNAL) $(SRCDIR_KERNAL) $(GEN_KERNAL) # List of tools -TOOL_COLLECT_DATA = build/tools/collect_data TOOL_GENERATE_CONSTANTS = build/tools/generate_constants TOOL_GENERATE_STRINGS = build/tools/generate_strings TOOL_PATCH_CHARGEN = build/tools/patch_chargen @@ -112,9 +119,16 @@ TOOL_PNGPREPARE = build/tools/pngprepare TOOL_BUILD_SEGMENT = build/tools/build_segment TOOL_RELEASE = build/tools/release TOOL_SIMILARITY = build/tools/similarity -TOOL_ASSEMBLER = assembler/KickAss.jar +TOOL_ASSEMBLER = build/tools/acme -TOOLS_LIST = $(pathsubst tools/%,build/tools/%,$(basename $(SRC_TOOLS))) +TOOLS_LIST = $(TOOL_GENERATE_CONSTANTS) \ + $(TOOL_GENERATE_STRINGS) \ + $(TOOL_PATCH_CHARGEN) \ + $(TOOL_PNGPREPARE) \ + $(TOOL_BUILD_SEGMENT) \ + $(TOOL_RELEASE) \ + $(TOOL_SIMILARITY) \ + $(TOOL_ASSEMBLER) # List of targets @@ -149,13 +163,13 @@ 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 + $(DIR_M65)/kernal.seg_0 \ + $(DIR_M65)/kernal.seg_1 SEG_LIST_X16 = $(DIR_X16)/basic.seg_0 \ $(DIR_X16)/basic.seg_1 \ - $(DIR_X16)/kernal.seg_0 \ - $(DIR_X16)/kernal.seg_1 + $(DIR_X16)/kernal.seg_0 \ + $(DIR_X16)/kernal.seg_1 REL_TARGET_LIST = $(TARGET_LIST_GEN) $(TARGET_M65_x) $(TARGET_M65_x_PXL) $(TARGET_LIST_U64) @@ -169,14 +183,18 @@ GIT_COMMIT:= $(shell git log -1 --pretty='%h' | tr '[:lower:]' '[:upper:]') # Rules - main XXX fast build does not always succeed, not yet clear, why -.PHONY: all fast clean updatebin +.PHONY: all clean updatebin all: + @echo + @echo --- Building tools --- + @echo + $(MAKE) -j64 --output-sync=target $(TOOLS_LIST) + @echo + @echo --- Building Open ROMs --- + @echo $(MAKE) $(TARGET_LIST) $(EXT_TARGET_LIST) -fast: - $(MAKE) -j64 --output-sync=target $(TARGET_LIST) $(EXT_TARGET_LIST) - clean: @rm -rf build src/basic/combined.s src/kernal/combined.s @@ -187,6 +205,15 @@ updatebin: # Rules - tools +$(DIR_ACME) $(SRC_ACME) $(HDR_ACME): + git submodule init + git submodule update + +$(TOOL_ASSEMBLER): $(DIR_ACME) $(SRC_ACME) $(HDR_ACME) + @mkdir -p build/tools + echo $(OUT_ACME) + $(CC) -o $(TOOL_ASSEMBLER) $(SRC_ACME) -lm -I./assembler/acme/src + $(TOOL_PNGPREPARE): tools/pngprepare.c @mkdir -p build/tools $(CC) -O2 -Wall -I/usr/local/include -L/usr/local/lib -o $@ $< -lpng @@ -303,9 +330,9 @@ $(GEN_STR_X16): $(TOOL_GENERATE_STRINGS) $(CFG_X16) @mkdir -p $(DIR_X16)/,generated $(TOOL_GENERATE_STRINGS) -o $@ -c $(CFG_X16) -build/,generated/float_constants.s: $(TOOL_GENERATE_CONSTANTS) +build/,generated/,float_constants.s: $(TOOL_GENERATE_CONSTANTS) @mkdir -p build/,generated - $(TOOL_GENERATE_CONSTANTS) -o build/,generated/float_constants.s + $(TOOL_GENERATE_CONSTANTS) -o build/,generated/,float_constants.s GEN_STR_custom = $(GEN_STR_CUS) GEN_STR_generic = $(GEN_STR_GEN) diff --git a/assembler/KickAss.cfg b/assembler/KickAss.cfg deleted file mode 100644 index 919ec309..00000000 --- a/assembler/KickAss.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# These are the defaults - not needed for Open ROMs build system -# -showmem -# -symbolfile diff --git a/assembler/KickAss.jar b/assembler/KickAss.jar deleted file mode 100644 index 77fa9f23..00000000 Binary files a/assembler/KickAss.jar and /dev/null differ diff --git a/assembler/KickAssembler.pdf b/assembler/KickAssembler.pdf deleted file mode 100644 index 2ef23c87..00000000 Binary files a/assembler/KickAssembler.pdf and /dev/null differ diff --git a/assembler/LICENSE b/assembler/LICENSE deleted file mode 100644 index 618974a5..00000000 --- a/assembler/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -KickAssembler is NOT LGPL: - -http://theweb.dk/KickAssembler/Main.html#frontpage diff --git a/assembler/acme b/assembler/acme new file mode 160000 index 00000000..dbddab48 --- /dev/null +++ b/assembler/acme @@ -0,0 +1 @@ +Subproject commit dbddab48a1eaaeee41333178a8964aec23e84961 diff --git a/src/,,config_custom.s b/src/,,config_custom.s index da8d626c..cc95848d 100644 --- a/src/,,config_custom.s +++ b/src/,,config_custom.s @@ -1,145 +1,158 @@ -.const CONFIG_ID = $00 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $00 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - configuration for custom builds and for development -// - file contains options to enable unfinished functionalities +; Idea: +; - configuration for custom builds and for development +; - file contains options to enable unfinished functionalities -// Hardware platform and brand +; Hardware platform and brand -#define CONFIG_PLATFORM_COMMODORE_64 - -// #define CONFIG_MB_MEGA_65 -// #define CONFIG_MB_ULTIMATE_64 - -#define CONFIG_BRAND_CUSTOM_BUILD -// #define CONFIG_BRAND_GENERIC -// #define CONFIG_BRAND_TESTING -// #define CONFIG_BRAND_ULTIMATE_64 - -.const CONFIG_CUSTOM_BRAND = @"CUSTOM BUILD" +!set CONFIG_PLATFORM_COMMODORE_64 = 1 +!set CONFIG_BRAND_CUSTOM_BUILD = 1 +!macro CONFIG_CUSTOM_BRAND { !pet "custom build" } -// Processor instruction set +; Processor instruction set -#define CONFIG_CPU_MOS_6502 -// #define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -// #define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +!set CONFIG_CPU_MOS_6502 = 1 +; !set CONFIG_CPU_DTV_6502 = 1 +; !set CONFIG_CPU_RCW_65C02 = 1 +; !set CONFIG_CPU_WDC_65C02 = 1 +; !set CONFIG_CPU_WDC_65816 = 1 +; !set CONFIG_CPU_CSG_65CE02 = 1 -// Memory model +; Memory model -// #define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -#define CONFIG_MEMORY_MODEL_50K -// #define CONFIG_MEMORY_MODEL_60K +; !set CONFIG_MEMORY_MODEL_38K = 1 +; !set CONFIG_MEMORY_MODEL_46K = 1 +!set CONFIG_MEMORY_MODEL_50K = 1 +; !set CONFIG_MEMORY_MODEL_60K = 1 -// I/O devices +; IEC bus configuration -#define CONFIG_IEC -#define CONFIG_IEC_DOLPHINDOS -#define CONFIG_IEC_DOLPHINDOS_FAST -#define CONFIG_IEC_JIFFYDOS -// #define CONFIG_IEC_JIFFYDOS_BLANK -// #define CONFIG_IEC_BURST_CIA1 // please keep disabled for now -// #define CONFIG_IEC_BURST_CIA2 // please keep disabled for now -// #define CONFIG_IEC_BURST_MEGA_65 // please keep disabled for now +!set CONFIG_IEC = 1 +!set CONFIG_IEC_DOLPHINDOS = 1 +!set CONFIG_IEC_DOLPHINDOS_FAST = 1 +!set CONFIG_IEC_JIFFYDOS = 1 +; !set CONFIG_IEC_JIFFYDOS_BLANK = 1 +; !set CONFIG_IEC_BURST_CIA1 = 1 ; please keep disabled for now +; !set CONFIG_IEC_BURST_CIA2 = 1 ; please keep disabled for now + -#define CONFIG_TAPE_NORMAL -#define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT -// #define CONFIG_TAPE_NO_KEY_SENSE -// #define CONFIG_TAPE_NO_MOTOR_CONTROL +; Tape deck configuration -// #define CONFIG_RS232_UP2400 // please keep disabled for now -// #define CONFIG_RS232_UP9600 // please keep disabled for now +!set CONFIG_TAPE_NORMAL = 1 +!set CONFIG_TAPE_TURBO = 1 +!set CONFIG_TAPE_AUTODETECT = 1 +; !set CONFIG_TAPE_NO_KEY_SENSE = 1 +; !set CONFIG_TAPE_NO_MOTOR_CONTROL = 1 -// Multiple SID support +; RS-232 configuration -// #define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D420 - -// #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D440 - -// #define CONFIG_SID_D4XX -// #define CONFIG_SID_D5XX +; !set CONFIG_RS232_ACIA = 1 ; please keep disabled for now +; !set CONFIG_RS232_UP2400 = 1 ; please keep disabled for now +; !set CONFIG_RS232_UP9600 = 1 ; please keep disabled for now -// Keyboard settings +; Sound support -// #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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -#define CONFIG_KEY_FAST_SCAN -// #define CONFIG_JOY1_CURSOR -// #define CONFIG_JOY2_CURSOR - -#define CONFIG_PROGRAMMABLE_KEYS - -.const CONFIG_KEYCMD_RUN = @"\$5FL" - -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" - -.const CONFIG_KEYCMD_HELP = @"LIST" - -.const CONFIG_KEYCMD_F9 = @"" -.const CONFIG_KEYCMD_F10 = @"" -.const CONFIG_KEYCMD_F11 = @"" -.const CONFIG_KEYCMD_F12 = @"" -.const CONFIG_KEYCMD_F13 = @"" -.const CONFIG_KEYCMD_F14 = @"" +; !set CONFIG_SID_2ND_ADDRESS = $D420 +; !set CONFIG_SID_3RD_ADDRESS = $D440 +; !set CONFIG_SID_D4XX = 1 +; !set CONFIG_SID_D5XX = 1 -// Screen editor +; Keyboard settings -#define CONFIG_EDIT_STOPQUOTE -// #define CONFIG_EDIT_TABULATORS +; !set CONFIG_LEGACY_SCNKEY = 1 +; !set CONFIG_KEYBOARD_C128 = 1 +; !set CONFIG_KEYBOARD_C128_CAPS_LOCK = 1 +; !set CONFIG_KEYBOARD_C65 = 1 ; untested +; !set CONFIG_KEYBOARD_C65_CAPS_LOCK = 1 ; untested +; !set CONFIG_KEY_REPEAT_DEFAULT = 1 +; !set CONFIG_KEY_REPEAT_ALWAYS = 1 +!set CONFIG_KEY_FAST_SCAN = 1 +; !set CONFIG_JOY1_CURSOR = 1 +; !set CONFIG_JOY2_CURSOR = 1 + +!set CONFIG_PROGRAMMABLE_KEYS = 1 + +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { + !byte $5F + !pet "l" +} + +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "run:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "load" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } + +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "list" } + +; !set CONFIG_KEYCMD_F9 = 1 +; !macro CONFIG_KEYCMD_F9 { !pet "" } +; !set CONFIG_KEYCMD_F10 = 1 +; !macro CONFIG_KEYCMD_F10 { !pet "" } +; !set CONFIG_KEYCMD_F11 = 1 +; !macro CONFIG_KEYCMD_F11 { !pet "" } +; !set CONFIG_KEYCMD_F12 = 1 +; !macro CONFIG_KEYCMD_F12 { !pet "" } +; !set CONFIG_KEYCMD_F13 = 1 +; !macro CONFIG_KEYCMD_F13 { !pet "" } +; !set CONFIG_KEYCMD_F14 = 1 +; !macro CONFIG_KEYCMD_F14 { !pet "" } -// Software features +; Screen editor -#define CONFIG_PANIC_SCREEN -#define CONFIG_DOS_WEDGE -#define CONFIG_TAPE_WEDGE -// #define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS - -// Eye candy - -// #define CONFIG_COLORS_BRAND -// #define CONFIG_BANNER_SIMPLE -#define CONFIG_BANNER_FANCY -#define CONFIG_SHOW_FEATURES +!set CONFIG_EDIT_STOPQUOTE = 1 +; !set CONFIG_EDIT_TABULATORS = 1 -// Debug options +; Software features -// #define CONFIG_DBG_STUBS_BRK -// #define CONFIG_DBG_PRINTF +!set CONFIG_PANIC_SCREEN = 1 +!set CONFIG_DOS_WEDGE = 1 +!set CONFIG_TAPE_WEDGE = 1 +; !set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Other +; Eye candy -// #define CONFIG_COMPRESSION_LVL_2 +; !set CONFIG_COLORS_BRAND = 1 +; !set CONFIG_BANNER_SIMPLE = 1 +!set CONFIG_BANNER_FANCY = 1 +!set CONFIG_SHOW_FEATURES = 1 + + +; Debug options + +; !set CONFIG_DBG_STUBS_BRK = 1 +; !set CONFIG_DBG_PRINTF = 1 + +; Other + +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/,,config_cx16.s b/src/,,config_cx16.s index a36527e9..0dc96bb7 100644 --- a/src/,,config_cx16.s +++ b/src/,,config_cx16.s @@ -1,139 +1,94 @@ -.const CONFIG_ID = $04 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $04 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - settings file for the Commander X16 machine +; Idea: +; - settings file for the Commander X16 machine -// Hardware platform and brand +; Hardware platform and brand -#define CONFIG_PLATFORM_COMMANDER_X16 - -// #define CONFIG_MB_MEGA_65 -// #define CONFIG_MB_ULTIMATE_64 - -#define CONFIG_BRAND_CUSTOM_BUILD -// #define CONFIG_BRAND_GENERIC -// #define CONFIG_BRAND_TESTING -// #define CONFIG_BRAND_ULTIMATE_64 - -.const CONFIG_CUSTOM_BRAND = @"FOR COMMANDER X16" +!set CONFIG_PLATFORM_COMMANDER_X16 = 1 -// Processor instruction set +; Memory model -// #define CONFIG_CPU_MOS_6502 -#define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -// #define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +!set CONFIG_MEMORY_MODEL_38K = 1 -// Memory model +; Keyboard settings -#define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -// #define CONFIG_MEMORY_MODEL_50K -// #define CONFIG_MEMORY_MODEL_60K +; !set CONFIG_PROGRAMMABLE_KEYS = 1 + +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { !pet "load\"*\"" } + +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "run:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "load" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } + +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "list" } + +; !set CONFIG_KEYCMD_F9 = 1 +; !macro CONFIG_KEYCMD_F9 { !pet "" } +; !set CONFIG_KEYCMD_F10 = 1 +; !macro CONFIG_KEYCMD_F10 { !pet "" } +; !set CONFIG_KEYCMD_F11 = 1 +; !macro CONFIG_KEYCMD_F11 { !pet "" } +; !set CONFIG_KEYCMD_F12 = 1 +; !macro CONFIG_KEYCMD_F12 { !pet "" } +; !set CONFIG_KEYCMD_F13 = 1 +; !macro CONFIG_KEYCMD_F13 { !pet "" } +; !set CONFIG_KEYCMD_F14 = 1 +; !macro CONFIG_KEYCMD_F14 { !pet "" } -// I/O devices +; Screen editor -// #define CONFIG_IEC -// #define CONFIG_IEC_DOLPHINDOS -// #define CONFIG_IEC_DOLPHINDOS_FAST -// #define CONFIG_IEC_JIFFYDOS -// #define CONFIG_IEC_JIFFYDOS_BLANK - -// #define CONFIG_TAPE_NORMAL -// #define CONFIG_TAPE_TURBO -// #define CONFIG_TAPE_AUTODETECT -// #define CONFIG_TAPE_NO_KEY_SENSE -// #define CONFIG_TAPE_NO_MOTOR_CONTROL +; !set CONFIG_EDIT_STOPQUOTE = 1 +; !set CONFIG_EDIT_TABULATORS = 1 -// Multiple SID support +; Software features -// #define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D440 - -// #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D480 - -// #define CONFIG_SID_D4XX -// #define CONFIG_SID_D5XX +; !set CONFIG_PANIC_SCREEN = 1 +; !set CONFIG_DOS_WEDGE = 1 +; !set CONFIG_TAPE_WEDGE = 1 +; !set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Keyboard settings +; Eye candy -// #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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -// #define CONFIG_KEY_FAST_SCAN -// #define CONFIG_JOY1_CURSOR -// #define CONFIG_JOY2_CURSOR - -// #define CONFIG_PROGRAMMABLE_KEYS - -.const CONFIG_KEYCMD_RUN = @"LOAD\"*\"" - -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" - -.const CONFIG_KEYCMD_HELP = @"LIST" - -.const CONFIG_KEYCMD_F9 = @"REM F9" -.const CONFIG_KEYCMD_F10 = @"REM F10" -.const CONFIG_KEYCMD_F11 = @"REM F11" -.const CONFIG_KEYCMD_F12 = @"REM F12" -.const CONFIG_KEYCMD_F13 = @"REM F13" -.const CONFIG_KEYCMD_F14 = @"REM F14" +; !set CONFIG_COLORS_BRAND = 1 +; !set CONFIG_BANNER_SIMPLE = 1 +!set CONFIG_BANNER_FANCY = 1 +; !set CONFIG_SHOW_FEATURES = 1 -// Screen editor +; Debug options -// #define CONFIG_EDIT_STOPQUOTE -// #define CONFIG_EDIT_TABULATORS +; !set CONFIG_DBG_STUBS_BRK = 1 +; !set CONFIG_DBG_PRINTF = 1 +; Other -// Software features - -// #define CONFIG_PANIC_SCREEN -// #define CONFIG_DOS_WEDGE -// #define CONFIG_TAPE_WEDGE -// #define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS - - -// Eye candy - -// #define CONFIG_COLORS_BRAND -// #define CONFIG_BANNER_SIMPLE -#define CONFIG_BANNER_FANCY -// #define CONFIG_SHOW_FEATURES - - -// Debug options - -// #define CONFIG_DBG_STUBS_BRK -// #define CONFIG_DBG_PRINTF - -// Other - -// #define CONFIG_COMPRESSION_LVL_2 +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/,,config_generic.s b/src/,,config_generic.s index 49ba908e..ce434df3 100644 --- a/src/,,config_generic.s +++ b/src/,,config_generic.s @@ -1,137 +1,148 @@ -.const CONFIG_ID = $01 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $01 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - sane defaults for the original Commodore 64/128 machines -// - do not enable features which are a significant compatibility risk +; Idea: +; - sane defaults for the original Commodore 64/128 machines +; - do not enable features which are a significant compatibility risk -// Hardware platform and brand +; Hardware platform and brand -#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_ULTIMATE_64 +!set CONFIG_PLATFORM_COMMODORE_64 = 1 +!set CONFIG_BRAND_GENERIC = 1 -// Processor instruction set +; Processor instruction set -#define CONFIG_CPU_MOS_6502 -// #define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -// #define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +!set CONFIG_CPU_MOS_6502 = 1 +; !set CONFIG_CPU_DTV_6502 = 1 +; !set CONFIG_CPU_RCW_65C02 = 1 +; !set CONFIG_CPU_WDC_65C02 = 1 +; !set CONFIG_CPU_WDC_65816 = 1 +; !set CONFIG_CPU_CSG_65CE02 = 1 -// Memory model +; Memory model -// #define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -#define CONFIG_MEMORY_MODEL_50K -// #define CONFIG_MEMORY_MODEL_60K +; !set CONFIG_MEMORY_MODEL_38K = 1 +; !set CONFIG_MEMORY_MODEL_46K = 1 +!set CONFIG_MEMORY_MODEL_50K = 1 +; !set CONFIG_MEMORY_MODEL_60K = 1 -// I/O devices +; IEC bus configuration -#define CONFIG_IEC -#define CONFIG_IEC_DOLPHINDOS -#define CONFIG_IEC_DOLPHINDOS_FAST -#define CONFIG_IEC_JIFFYDOS -#define CONFIG_IEC_JIFFYDOS_BLANK - -#define CONFIG_TAPE_NORMAL -#define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT -// #define CONFIG_TAPE_NO_KEY_SENSE -// #define CONFIG_TAPE_NO_MOTOR_CONTROL +!set CONFIG_IEC = 1 +!set CONFIG_IEC_DOLPHINDOS = 1 +!set CONFIG_IEC_DOLPHINDOS_FAST = 1 +!set CONFIG_IEC_JIFFYDOS = 1 +!set CONFIG_IEC_JIFFYDOS_BLANK = 1 -// Multiple SID support +; Tape deck configuration -// #define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D420 - -// #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D440 - -// #define CONFIG_SID_D4XX -// #define CONFIG_SID_D5XX +!set CONFIG_TAPE_NORMAL = 1 +!set CONFIG_TAPE_TURBO = 1 +!set CONFIG_TAPE_AUTODETECT = 1 +; !set CONFIG_TAPE_NO_KEY_SENSE = 1 +; !set CONFIG_TAPE_NO_MOTOR_CONTROL = 1 -// Keyboard settings +; Sound support -// #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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -#define CONFIG_KEY_FAST_SCAN -#define CONFIG_JOY1_CURSOR -#define CONFIG_JOY2_CURSOR - -#define CONFIG_PROGRAMMABLE_KEYS - -.const CONFIG_KEYCMD_RUN = @"\$5FL" - -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" - -.const CONFIG_KEYCMD_HELP = @"LIST" - -.const CONFIG_KEYCMD_F9 = @"" -.const CONFIG_KEYCMD_F10 = @"" -.const CONFIG_KEYCMD_F11 = @"" -.const CONFIG_KEYCMD_F12 = @"" -.const CONFIG_KEYCMD_F13 = @"" -.const CONFIG_KEYCMD_F14 = @"" +; !set CONFIG_SID_2ND_ADDRESS = $D420 +; !set CONFIG_SID_3RD_ADDRESS = $D440 +; !set CONFIG_SID_D4XX = 1 +; !set CONFIG_SID_D5XX = 1 -// Screen editor +; Keyboard settings -#define CONFIG_EDIT_STOPQUOTE -// #define CONFIG_EDIT_TABULATORS +; !set CONFIG_LEGACY_SCNKEY = 1 +; !set CONFIG_KEYBOARD_C128 = 1 +; !set CONFIG_KEYBOARD_C128_CAPS_LOCK = 1 +; !set CONFIG_KEYBOARD_C65 = 1 ; untested +; !set CONFIG_KEYBOARD_C65_CAPS_LOCK = 1 ; untested +; !set CONFIG_KEY_REPEAT_DEFAULT = 1 +; !set CONFIG_KEY_REPEAT_ALWAYS = 1 +!set CONFIG_KEY_FAST_SCAN = 1 +!set CONFIG_JOY1_CURSOR = 1 +!set CONFIG_JOY2_CURSOR = 1 + +!set CONFIG_PROGRAMMABLE_KEYS = 1 + +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { + !byte $5F + !pet "l" } + +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "RUN:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "LOAD" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } + +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "LIST" } + +; !set CONFIG_KEYCMD_F9 = 1 +; !macro CONFIG_KEYCMD_F9 { !pet "" } +; !set CONFIG_KEYCMD_F10 = 1 +; !macro CONFIG_KEYCMD_F10 { !pet "" } +; !set CONFIG_KEYCMD_F11 = 1 +; !macro CONFIG_KEYCMD_F11 { !pet "" } +; !set CONFIG_KEYCMD_F12 = 1 +; !macro CONFIG_KEYCMD_F12 { !pet "" } +; !set CONFIG_KEYCMD_F13 = 1 +; !macro CONFIG_KEYCMD_F13 { !pet "" } +; !set CONFIG_KEYCMD_F14 = 1 +; !macro CONFIG_KEYCMD_F14 { !pet "" } -// Software features +; Screen editor -#define CONFIG_PANIC_SCREEN -#define CONFIG_DOS_WEDGE -#define CONFIG_TAPE_WEDGE -// #define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS +!set CONFIG_EDIT_STOPQUOTE = 1 +; !set CONFIG_EDIT_TABULATORS = 1 -// Eye candy +; Software features -#define CONFIG_COLORS_BRAND -// #define CONFIG_BANNER_SIMPLE -#define CONFIG_BANNER_FANCY -#define CONFIG_SHOW_FEATURES +!set CONFIG_PANIC_SCREEN = 1 +!set CONFIG_DOS_WEDGE = 1 +!set CONFIG_TAPE_WEDGE = 1 +; !set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Debug options +; Eye candy -// #define CONFIG_DBG_STUBS_BRK -// #define CONFIG_DBG_PRINTF +!set CONFIG_COLORS_BRAND = 1 +; !set CONFIG_BANNER_SIMPLE = 1 +!set CONFIG_BANNER_FANCY = 1 +!set CONFIG_SHOW_FEATURES = 1 -// Other -// #define CONFIG_COMPRESSION_LVL_2 +; Debug options + +; !set CONFIG_DBG_STUBS_BRK = 1 +; !set CONFIG_DBG_PRINTF = 1 + +; Other + +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/,,config_mega65.s b/src/,,config_mega65.s index 7a742ee2..da9418a7 100644 --- a/src/,,config_mega65.s +++ b/src/,,config_mega65.s @@ -1,130 +1,129 @@ -.const CONFIG_ID = $02 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $02 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - sane defaults for the Mega 65 FPGA computer -// - do not enable features which are a significant compatibility risk +; Idea: +; - sane defaults for the Mega 65 FPGA computer +; - do not enable features which are a significant compatibility risk -// Hardware platform +; Hardware platform -#define CONFIG_PLATFORM_COMMODORE_64 - -#define CONFIG_MB_MEGA_65 - -// Processor instruction set - -// #define CONFIG_CPU_MOS_6502 -// #define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -#define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +!set CONFIG_PLATFORM_COMMODORE_64 = 1 +!set CONFIG_MB_M65 = 1 -// Memory model +; Memory model -// #define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -#define CONFIG_MEMORY_MODEL_50K -// #define CONFIG_MEMORY_MODEL_60K +; !set CONFIG_MEMORY_MODEL_38K = 1 +; !set CONFIG_MEMORY_MODEL_46K = 1 +!set CONFIG_MEMORY_MODEL_50K = 1 -// I/O devices +; IEC bus configuration -#define CONFIG_IEC -// #define CONFIG_IEC_DOLPHINDOS -// #define CONFIG_IEC_DOLPHINDOS_FAST -#define CONFIG_IEC_JIFFYDOS -#define CONFIG_IEC_JIFFYDOS_BLANK - -#define CONFIG_TAPE_NORMAL -#define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT -#define CONFIG_TAPE_NO_KEY_SENSE -#define CONFIG_TAPE_NO_MOTOR_CONTROL +!set CONFIG_IEC = 1 +; !set CONFIG_IEC_DOLPHINDOS = 1 +; !set CONFIG_IEC_DOLPHINDOS_FAST = 1 +!set CONFIG_IEC_JIFFYDOS = 1 +!set CONFIG_IEC_JIFFYDOS_BLANK = 1 +; !set CONFIG_IEC_BURST_M65 = 1 ; please keep disabled for now -// Multiple SID support +; Tape deck configuration -// #define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D440 - -// #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D480 - -// #define CONFIG_SID_D4XX -// #define CONFIG_SID_D5XX +!set CONFIG_TAPE_NORMAL = 1 +!set CONFIG_TAPE_TURBO = 1 +!set CONFIG_TAPE_AUTODETECT = 1 +!set CONFIG_TAPE_NO_KEY_SENSE = 1 +!set CONFIG_TAPE_NO_MOTOR_CONTROL = 1 -// Keyboard settings +; Keyboard settings -// #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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -#define CONFIG_KEY_FAST_SCAN -#define CONFIG_JOY1_CURSOR -#define CONFIG_JOY2_CURSOR +; !set CONFIG_LEGACY_SCNKEY = 1 +; !set CONFIG_KEYBOARD_C128 = 1 +; !set CONFIG_KEYBOARD_C128_CAPS_LOCK = 1 +; !set CONFIG_KEYBOARD_C65 = 1 ; untested +; !set CONFIG_KEYBOARD_C65_CAPS_LOCK = 1 ; untested +; !set CONFIG_KEY_REPEAT_DEFAULT = 1 +; !set CONFIG_KEY_REPEAT_ALWAYS = 1 +!set CONFIG_KEY_FAST_SCAN = 1 +!set CONFIG_JOY1_CURSOR = 1 +!set CONFIG_JOY2_CURSOR = 1 -#define CONFIG_PROGRAMMABLE_KEYS +!set CONFIG_PROGRAMMABLE_KEYS = 1 -.const CONFIG_KEYCMD_RUN = @"\$5FL" +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { + !byte $5F + !pet "l" } -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "run:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "load" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } -.const CONFIG_KEYCMD_HELP = @"LIST" +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "list" } -.const CONFIG_KEYCMD_F9 = @"BOOT" -.const CONFIG_KEYCMD_F10 = @"REM F10" -.const CONFIG_KEYCMD_F11 = @"MONITOR" -.const CONFIG_KEYCMD_F12 = @"REM F12" -.const CONFIG_KEYCMD_F13 = @"\$5FH" -.const CONFIG_KEYCMD_F14 = @"REM F14" +!set CONFIG_KEYCMD_F9 = 1 +!macro CONFIG_KEYCMD_F9 { !pet "boot" } +!set CONFIG_KEYCMD_F10 = 1 +!macro CONFIG_KEYCMD_F10 { !pet "rem f10" } +!set CONFIG_KEYCMD_F11 = 1 +!macro CONFIG_KEYCMD_F11 { !pet "monitor" } +!set CONFIG_KEYCMD_F12 = 1 +!macro CONFIG_KEYCMD_F12 { !pet "rem f12" } +!set CONFIG_KEYCMD_F13 = 1 +!macro CONFIG_KEYCMD_F13 { !byte $5F !pet "h" } +!set CONFIG_KEYCMD_F14 = 1 +!macro CONFIG_KEYCMD_F14 { !pet "rem f14" } -// Screen editor +; Screen editor -#define CONFIG_EDIT_STOPQUOTE -#define CONFIG_EDIT_TABULATORS +!set CONFIG_EDIT_STOPQUOTE = 1 +!set CONFIG_EDIT_TABULATORS = 1 -// Software features +; Software features -#define CONFIG_PANIC_SCREEN -#define CONFIG_DOS_WEDGE -#define CONFIG_TAPE_WEDGE -#define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS +!set CONFIG_PANIC_SCREEN = 1 +!set CONFIG_DOS_WEDGE = 1 +!set CONFIG_TAPE_WEDGE = 1 +!set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Built-in DOS configuration +; Built-in DOS configuration -.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 +!set CONFIG_UNIT_SDCARD = 0 ; do not change, DOS is not implemented yet +!set CONFIG_UNIT_FLOPPY = 0 ; do not change, DOS is not implemented yet +!set CONFIG_UNIT_RAMDISK = 0 ; do not change, DOS is not implemented yet -// Debug options +; Debug options -// #define CONFIG_DBG_STUBS_BRK -// #define CONFIG_DBG_PRINTF +; !set CONFIG_DBG_STUBS_BRK = 1 +; !set CONFIG_DBG_PRINTF = 1 -// Other +; Other -// #define CONFIG_COMPRESSION_LVL_2 +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/,,config_testing.s b/src/,,config_testing.s index 24010994..2d4f0080 100644 --- a/src/,,config_testing.s +++ b/src/,,config_testing.s @@ -1,137 +1,149 @@ -.const CONFIG_ID = $F0 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $F0 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - enable compatibility-risky features -// - enable code not normally used - to make sure they still compile +; Idea: +; - enable compatibility-risky features +; - enable code not normally used - to make sure they still compile -// Hardware platform and brand +; Hardware platform and brand -#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_ULTIMATE_64 +!set CONFIG_PLATFORM_COMMODORE_64 = 1 +!set CONFIG_BRAND_TESTING = 1 -// Processor instruction set +; Processor instruction set -#define CONFIG_CPU_MOS_6502 -// #define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -// #define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +!set CONFIG_CPU_MOS_6502 = 1 +; !set CONFIG_CPU_DTV_6502 = 1 +; !set CONFIG_CPU_RCW_65C02 = 1 +; !set CONFIG_CPU_WDC_65C02 = 1 +; !set CONFIG_CPU_WDC_65816 = 1 +; !set CONFIG_CPU_CSG_65CE02 = 1 -// Memory model +; Memory model -// #define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -// #define CONFIG_MEMORY_MODEL_50K -#define CONFIG_MEMORY_MODEL_60K +; !set CONFIG_MEMORY_MODEL_38K = 1 +; !set CONFIG_MEMORY_MODEL_46K = 1 +; !set CONFIG_MEMORY_MODEL_50K = 1 +!set CONFIG_MEMORY_MODEL_60K = 1 -// I/O devices +; IEC bus configuration -#define CONFIG_IEC -#define CONFIG_IEC_DOLPHINDOS -// #define CONFIG_IEC_DOLPHINDOS_FAST -#define CONFIG_IEC_JIFFYDOS -// #define CONFIG_IEC_JIFFYDOS_BLANK - -// #define CONFIG_TAPE_NORMAL -#define CONFIG_TAPE_TURBO -// #define CONFIG_TAPE_AUTODETECT -// #define CONFIG_TAPE_NO_KEY_SENSE -// #define CONFIG_TAPE_NO_MOTOR_CONTROL +!set CONFIG_IEC = 1 +!set CONFIG_IEC_DOLPHINDOS = 1 +; !set CONFIG_IEC_DOLPHINDOS_FAST = 1 +!set CONFIG_IEC_JIFFYDOS = 1 +; !set CONFIG_IEC_JIFFYDOS_BLANK = 1 -// Multiple SID support +; Tape deck configuration -#define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D420 - -#define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D440 - -// #define CONFIG_SID_D4XX -// #define CONFIG_SID_D5XX +; !set CONFIG_TAPE_NORMAL = 1 +!set CONFIG_TAPE_TURBO = 1 +; !set CONFIG_TAPE_AUTODETECT = 1 +; !set CONFIG_TAPE_NO_KEY_SENSE = 1 +; !set CONFIG_TAPE_NO_MOTOR_CONTROL = 1 -// Keyboard settings +; Sound support -#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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -#define CONFIG_KEY_FAST_SCAN -#define CONFIG_JOY1_CURSOR -#define CONFIG_JOY2_CURSOR - -#define CONFIG_PROGRAMMABLE_KEYS - -.const CONFIG_KEYCMD_RUN = @"\$5FL" - -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" - -.const CONFIG_KEYCMD_HELP = @"LIST" - -.const CONFIG_KEYCMD_F9 = @"" -.const CONFIG_KEYCMD_F10 = @"" -.const CONFIG_KEYCMD_F11 = @"" -.const CONFIG_KEYCMD_F12 = @"" -.const CONFIG_KEYCMD_F13 = @"" -.const CONFIG_KEYCMD_F14 = @"" +!set CONFIG_SID_2ND_ADDRESS = $D420 +!set CONFIG_SID_3RD_ADDRESS = $D440 +; !set CONFIG_SID_D4XX = 1 +; !set CONFIG_SID_D5XX = 1 -// Screen editor +; Keyboard settings -#define CONFIG_EDIT_STOPQUOTE -#define CONFIG_EDIT_TABULATORS +!set CONFIG_LEGACY_SCNKEY = 1 +; !set CONFIG_KEYBOARD_C128 = 1 +; !set CONFIG_KEYBOARD_C128_CAPS_LOCK = 1 +; !set CONFIG_KEYBOARD_C65 = 1 ; untested +; !set CONFIG_KEYBOARD_C65_CAPS_LOCK = 1 ; untested +; !set CONFIG_KEY_REPEAT_DEFAULT = 1 +; !set CONFIG_KEY_REPEAT_ALWAYS = 1 +!set CONFIG_KEY_FAST_SCAN = 1 +!set CONFIG_JOY1_CURSOR = 1 +!set CONFIG_JOY2_CURSOR = 1 + +!set CONFIG_PROGRAMMABLE_KEYS = 1 + +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { + !byte $5F + !pet "l" } + +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "run:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "load" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } + +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "list" } + +; !set CONFIG_KEYCMD_F9 = 1 +; !macro CONFIG_KEYCMD_F9 { !pet "" } +; !set CONFIG_KEYCMD_F10 = 1 +; !macro CONFIG_KEYCMD_F10 { !pet "" } +; !set CONFIG_KEYCMD_F11 = 1 +; !macro CONFIG_KEYCMD_F11 { !pet "" } +; !set CONFIG_KEYCMD_F12 = 1 +; !macro CONFIG_KEYCMD_F12 { !pet "" } +; !set CONFIG_KEYCMD_F13 = 1 +; !macro CONFIG_KEYCMD_F13 { !pet "" } +; !set CONFIG_KEYCMD_F14 = 1 +; !macro CONFIG_KEYCMD_F14 { !pet "" } -// Software features -#define CONFIG_PANIC_SCREEN -#define CONFIG_DOS_WEDGE -#define CONFIG_TAPE_WEDGE -// #define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS +; Screen editor + +!set CONFIG_EDIT_STOPQUOTE = 1 +!set CONFIG_EDIT_TABULATORS = 1 -// Eye candy +; Software features -// #define CONFIG_COLORS_BRAND -#define CONFIG_BANNER_SIMPLE -// #define CONFIG_BANNER_FANCY -#define CONFIG_SHOW_FEATURES +!set CONFIG_PANIC_SCREEN = 1 +!set CONFIG_DOS_WEDGE = 1 +!set CONFIG_TAPE_WEDGE = 1 +; !set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Debug options +; Eye candy -// #define CONFIG_DBG_STUBS_BRK -#define CONFIG_DBG_PRINTF +; !set CONFIG_COLORS_BRAND = 1 +!set CONFIG_BANNER_SIMPLE = 1 +; !set CONFIG_BANNER_FANCY = 1 +!set CONFIG_SHOW_FEATURES = 1 -// Other -// #define CONFIG_COMPRESSION_LVL_2 +; Debug options + +; !set CONFIG_DBG_STUBS_BRK = 1 +!set CONFIG_DBG_PRINTF = 1 + +; Other + +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/,,config_ultimate64.s b/src/,,config_ultimate64.s index b2373db5..f08a2b72 100644 --- a/src/,,config_ultimate64.s +++ b/src/,,config_ultimate64.s @@ -1,137 +1,138 @@ -.const CONFIG_ID = $03 // should be 1 byte, different for each config file! -.encoding "petscii_upper" +!set CONFIG_ID = $03 ; should be 1 byte, different for each config file! -// -// Please read CONFIG.md before modifying this file! -// +; +; Please read CONFIG.md before modifying this file! +; -// Idea: -// - sane defaults for the Ultimate 64 FPGA computer -// - do not enable features which are a significant compatibility risk +; Idea: +; - sane defaults for the Ultimate 64 FPGA computer +; - do not enable features which are a significant compatibility risk -// Hardware platform and brand +; Hardware platform and brand -#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_ULTIMATE_64 +!set CONFIG_PLATFORM_COMMODORE_64 = 1 +!set CONFIG_MB_U64 = 1 -// Processor instruction set +; Memory model -#define CONFIG_CPU_MOS_6502 -// #define CONFIG_CPU_WDC_65C02 -// #define CONFIG_CPU_CSG_65CE02 -// #define CONFIG_CPU_M65_45GS02 -// #define CONFIG_CPU_WDC_65816 +; !set CONFIG_MEMORY_MODEL_38K = 1 +; !set CONFIG_MEMORY_MODEL_46K = 1 +!set CONFIG_MEMORY_MODEL_50K = 1 +; !set CONFIG_MEMORY_MODEL_60K = 1 -// Memory model +; IEC bus configuration -// #define CONFIG_MEMORY_MODEL_38K -// #define CONFIG_MEMORY_MODEL_46K -#define CONFIG_MEMORY_MODEL_50K -// #define CONFIG_MEMORY_MODEL_60K +!set CONFIG_IEC = 1 +!set CONFIG_IEC_DOLPHINDOS = 1 +!set CONFIG_IEC_DOLPHINDOS_FAST = 1 +!set CONFIG_IEC_JIFFYDOS = 1 +!set CONFIG_IEC_JIFFYDOS_BLANK = 1 -// I/O devices +; Tape deck configuration -#define CONFIG_IEC -#define CONFIG_IEC_DOLPHINDOS -#define CONFIG_IEC_DOLPHINDOS_FAST -#define CONFIG_IEC_JIFFYDOS -#define CONFIG_IEC_JIFFYDOS_BLANK - -#define CONFIG_TAPE_NORMAL -#define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT -// #define CONFIG_TAPE_NO_KEY_SENSE -// #define CONFIG_TAPE_NO_MOTOR_CONTROL +!set CONFIG_TAPE_NORMAL = 1 +!set CONFIG_TAPE_TURBO = 1 +!set CONFIG_TAPE_AUTODETECT = 1 +; !set CONFIG_TAPE_NO_KEY_SENSE = 1 +; !set CONFIG_TAPE_NO_MOTOR_CONTROL = 1 -// Multiple SID support +; Sound support -// #define CONFIG_SID_2ND -.const CONFIG_SID_2ND_ADDRESS = $D420 - -// #define CONFIG_SID_3RD -.const CONFIG_SID_3RD_ADDRESS = $D440 - -#define CONFIG_SID_D4XX -#define CONFIG_SID_D5XX +; !set CONFIG_SID_2ND_ADDRESS = $D420 +; !set CONFIG_SID_3RD_ADDRESS = $D440 +!set CONFIG_SID_D4XX = 1 +!set CONFIG_SID_D5XX = 1 -// Keyboard settings +; Keyboard settings -// #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_KEY_REPEAT_DEFAULT -// #define CONFIG_KEY_REPEAT_ALWAYS -#define CONFIG_KEY_FAST_SCAN -#define CONFIG_JOY1_CURSOR -#define CONFIG_JOY2_CURSOR +; !set CONFIG_LEGACY_SCNKEY = 1 +; !set CONFIG_KEYBOARD_C128 = 1 +; !set CONFIG_KEYBOARD_C128_CAPS_LOCK = 1 +; !set CONFIG_KEYBOARD_C65 = 1 ; untested +; !set CONFIG_KEYBOARD_C65_CAPS_LOCK = 1 ; untested +; !set CONFIG_KEY_REPEAT_DEFAULT = 1 +; !set CONFIG_KEY_REPEAT_ALWAYS = 1 +!set CONFIG_KEY_FAST_SCAN = 1 +!set CONFIG_JOY1_CURSOR = 1 +!set CONFIG_JOY2_CURSOR = 1 -#define CONFIG_PROGRAMMABLE_KEYS +!set CONFIG_PROGRAMMABLE_KEYS = 1 -.const CONFIG_KEYCMD_RUN = @"\$5FL" +!set CONFIG_KEYCMD_RUN = 1 +!macro CONFIG_KEYCMD_RUN { + !byte $5F + !pet "l" } -.const CONFIG_KEYCMD_F1 = @"@" -.const CONFIG_KEYCMD_F2 = @"" -.const CONFIG_KEYCMD_F3 = @"RUN:" -.const CONFIG_KEYCMD_F4 = @"" -.const CONFIG_KEYCMD_F5 = @"LOAD" -.const CONFIG_KEYCMD_F6 = @"" -.const CONFIG_KEYCMD_F7 = @"@$" -.const CONFIG_KEYCMD_F8 = @"" +!set CONFIG_KEYCMD_F1 = 1 +!macro CONFIG_KEYCMD_F1 { !pet "@" } +; !set CONFIG_KEYCMD_F2 = 1 +; !macro CONFIG_KEYCMD_F2 { !pet "" } +!set CONFIG_KEYCMD_F3 = 1 +!macro CONFIG_KEYCMD_F3 { !pet "run:" } +; !set CONFIG_KEYCMD_F4 = 1 +; !macro CONFIG_KEYCMD_F4 { !pet "" } +!set CONFIG_KEYCMD_F5 = 1 +!macro CONFIG_KEYCMD_F5 { !pet "load" } +; !set CONFIG_KEYCMD_F6 = 1 +; !macro CONFIG_KEYCMD_F6 { !pet "" } +!set CONFIG_KEYCMD_F7 = 1 +!macro CONFIG_KEYCMD_F7 { !pet "@$" } +; !set CONFIG_KEYCMD_F8 = 1 +; !macro CONFIG_KEYCMD_F8 { !pet "" } -.const CONFIG_KEYCMD_HELP = @"LIST" +!set CONFIG_KEYCMD_HELP = 1 +!macro CONFIG_KEYCMD_HELP { !pet "list" } -.const CONFIG_KEYCMD_F9 = @"" -.const CONFIG_KEYCMD_F10 = @"" -.const CONFIG_KEYCMD_F11 = @"" -.const CONFIG_KEYCMD_F12 = @"" -.const CONFIG_KEYCMD_F13 = @"" -.const CONFIG_KEYCMD_F14 = @"" +; !set CONFIG_KEYCMD_F9 = 1 +; !macro CONFIG_KEYCMD_F9 { !pet "" } +; !set CONFIG_KEYCMD_F10 = 1 +; !macro CONFIG_KEYCMD_F10 { !pet "" } +; !set CONFIG_KEYCMD_F11 = 1 +; !macro CONFIG_KEYCMD_F11 { !pet "" } +; !set CONFIG_KEYCMD_F12 = 1 +; !macro CONFIG_KEYCMD_F12 { !pet "" } +; !set CONFIG_KEYCMD_F13 = 1 +; !macro CONFIG_KEYCMD_F13 { !pet "" } +; !set CONFIG_KEYCMD_F14 = 1 +; !macro CONFIG_KEYCMD_F14 { !pet "" } -// Screen editor +; Screen editor -#define CONFIG_EDIT_STOPQUOTE -// #define CONFIG_EDIT_TABULATORS +!set CONFIG_EDIT_STOPQUOTE = 1 +; !set CONFIG_EDIT_TABULATORS = 1 -// Software features +; Software features -#define CONFIG_PANIC_SCREEN -#define CONFIG_DOS_WEDGE -#define CONFIG_TAPE_WEDGE -// #define CONFIG_TAPE_HEAD_ALIGN -#define CONFIG_BCD_SAFE_INTERRUPTS +!set CONFIG_PANIC_SCREEN = 1 +!set CONFIG_DOS_WEDGE = 1 +!set CONFIG_TAPE_WEDGE = 1 +; !set CONFIG_TAPE_HEAD_ALIGN = 1 +!set CONFIG_BCD_SAFE_INTERRUPTS = 1 -// Eye candy +; Eye candy -#define CONFIG_COLORS_BRAND -// #define CONFIG_BANNER_SIMPLE -#define CONFIG_BANNER_FANCY -#define CONFIG_SHOW_FEATURES +!set CONFIG_COLORS_BRAND = 1 +; !set CONFIG_BANNER_SIMPLE = 1 +!set CONFIG_BANNER_FANCY = 1 +!set CONFIG_SHOW_FEATURES = 1 -// Debug options +; Debug options -// #define CONFIG_DBG_STUBS_BRK -// #define CONFIG_DBG_PRINTF +; !set CONFIG_DBG_STUBS_BRK = 1 +; !set CONFIG_DBG_PRINTF = 1 -// Other +; Other -// #define CONFIG_COMPRESSION_LVL_2 +; !set CONFIG_COMPRESSION_LVL_2 = 1 diff --git a/src/aliases/,aliases_config.s b/src/aliases/,aliases_config.s index 18f9bb24..25bb5e3f 100644 --- a/src/aliases/,aliases_config.s +++ b/src/aliases/,aliases_config.s @@ -1,375 +1,415 @@ -// -// Various configuration dependent aliases/macros/checks -// - -.encoding "petscii_upper" +; +; Configuration dependent aliases/macros/checks +; -// Check that platform configuration is correct -{ - .var selected = 0; +; Check that platform is specified -#if CONFIG_PLATFORM_COMMODORE_64 - .eval selected++ -#endif -#if CONFIG_PLATFORM_COMMANDER_X16 - .eval selected++ -#endif +!set counter = 0 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { !set counter = counter + 1 } +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { !set counter = counter + 1 } - .if (selected != 1) .error "Please select exactly one CONFIG_PLATFORM_* option" +!if (counter != 1) { !error "Please select exactly one CONFIG_PLATFORM_* option" } + + + +; Check that motherboard configuration is correct + +!set counter = 0 +!ifdef CONFIG_MB_M65 { !set counter = counter + 1 } +!ifdef CONFIG_MB_U64 { !set counter = counter + 1 } + +!if (counter > 1) { !error "Please select at most one CONFIG_MB_* option" } + +!ifdef ROM_LAYOUT_M65 { !ifndef CONFIG_MB_M65 { !error "ROM layout requires CONFIG_MB_M65 option" } } +!ifdef ROM_LAYOUT_U16 { !ifndef CONFIG_MB_U64 { !error "ROM layout requires CONFIG_MB_U64 option" } } + +!ifdef CONFIG_MB_M65 { !ifndef ROM_LAYOUT_M65 { !error "CONFIG_MB_M65 can only be used with appropriate ROM layout" } } +; !ifdef CONFIG_MB_U64 { !ifndef ROM_LAYOUT_U64 { !error "CONFIG_MB_U64 can only be used with appropriate ROM layout" } } + +!ifdef CONFIG_MB_M65 { !ifndef CONFIG_PLATFORM_COMMODORE_64 { !error "CONFIG_MB_M65 can only be used with CONFIG_PLATFORM_COMMODORE_64" } } +!ifdef CONFIG_MB_U64 { !ifndef CONFIG_PLATFORM_COMMODORE_64 { !error "CONFIG_MB_U64 can only be used with CONFIG_PLATFORM_COMMODORE_64" } } + + + +; Check that brand configuration is correct + +!set counter = 0 +!ifdef CONFIG_BRAND_CUSTOM_BUILD { !set counter = counter + 1 } +!ifdef CONFIG_BRAND_GENERIC { !set counter = counter + 1 } +!ifdef CONFIG_BRAND_TESTING { !set counter = counter + 1 } + +!ifndef CONFIG_PLATFORM_COMMODORE_64 { + !if (counter != 0) { !error "Do not use CONFIG_BRAND_* options for non-C64 platforms" } +} else ifdef CONFIG_MB_M65 { + !if (counter != 0) { !error "Do not use CONFIG_BRAND_* options for the MEGA65 motherboard" } +} else ifdef CONFIG_MB_U64 { + !if (counter != 0) { !error "Do not use CONFIG_BRAND_* options for the Ultimate 64 motherboard" } +} else if (counter != 1) { + !error "Please select exactly one CONFIG_BRAND_* option" } -// Check that motherboard extras configuration is correct -{ - .var selected = 0; +; Check that processor configuration is correct -#if CONFIG_MB_MEGA_65 - .eval selected++ -#endif -#if CONFIG_MB_ULTIMATE_64 - .eval selected++ -#endif +!set counter = 0 +!ifdef CONFIG_CPU_MOS_6502 { !set counter = counter + 1 } +!ifdef CONFIG_CPU_DTV_6502 { !set counter = counter + 1 } +!ifdef CONFIG_CPU_RCW_65C02 { !set counter = counter + 1 } +!ifdef CONFIG_CPU_WDC_65C02 { !set counter = counter + 1 } +!ifdef CONFIG_CPU_WDC_65816 { !set counter = counter + 1 } +!ifdef CONFIG_CPU_CSG_65CE02 { !set counter = counter + 1 } - .if (selected > 1) .error "Please select at most one CONFIG_MB_* option" - -#if !CONFIG_PLATFORM_COMMODORE_64 && CONFIG_BRAND_MEGA_65 && - .error "CONFIG_BRAND_MEGA_65 can only be used with CONFIG_PLATFORM_COMMODORE_64" -#endif -#if !CONFIG_PLATFORM_COMMODORE_64 && CONFIG_BRAND_ULTIMATE_64 && - .error "CONFIG_BRAND_ULTIMATE_64 can only be used with CONFIG_PLATFORM_COMMODORE_64" -#endif - -#if CONFIG_MB_MEGA_65 && (CONFIG_SID_2ND || CONFIG_SID_3RD || CONFIG_SID_D4XX || CONFIG_SID_D5XX) - .error "CONFIG_MB_MEGA_65 cannot be used with CONFIG_SID_*" -#endif +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !if (counter != 0) { !error "Do not use CONFIG_CPU_* options for Commander X16 platform" } +} else ifdef CONFIG_MB_M65 { + !if (counter != 0) { !error "Do not use CONFIG_CPU_* options for MEGA65 motherboard" } +} else ifdef CONFIG_MB_U64 { + !if (counter != 0) { !error "Do not use CONFIG_CPU_* options for Ultimate 64 motherboard" } +} else if (counter != 1) { + !error "Please select exactly one CONFIG_CPU_* option" } -// Check that brand configuration is correct -{ - .var selected = 0; +; Check that memory model configuration is correct -#if CONFIG_BRAND_CUSTOM_BUILD - .eval selected++ -#endif -#if CONFIG_BRAND_GENERIC - .eval selected++ -#endif -#if CONFIG_BRAND_TESTING - .eval selected++ -#endif -#if CONFIG_BRAND_ULTIMATE_64 - .eval selected++ -#endif +!set counter = 0 +!ifdef CONFIG_MEMORY_MODEL_38K { !set counter = counter + 1 } +!ifdef CONFIG_MEMORY_MODEL_46K { !set counter = counter + 1 } +!ifdef CONFIG_MEMORY_MODEL_50K { !set counter = counter + 1 } +!ifdef CONFIG_MEMORY_MODEL_60K { !set counter = counter + 1 } -#if !CONFIG_MB_MEGA_65 - .if (selected != 1) .error "Please select exactly one CONFIG_BRAND_* option" -#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 +!ifdef CONFIG_MB_M65 { + !ifdef CONFIG_MEMORY_MODEL_60K { !error "Do not use CONFIG_MEMORY_MODEL_60K options for MEGA65 motherboard" } +} +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !ifndef CONFIG_MEMORY_MODEL_38K { !error "Select CONFIG_MEMORY_MODEL_38K options for Commander X16 platform" } +} +!if (counter != 1) { + !error "Please select exactly one CONFIG_MEMORY_MODEL_* option" } -// Check that processor configuration is correct -{ - .var selected = 0; +; Check that IEC configuration is correct -#if CONFIG_CPU_MOS_6502 - .eval selected++ -#endif -#if CONFIG_CPU_WDC_65C02 - .eval selected++ -#endif -#if CONFIG_CPU_CSG_65CE02 - .eval selected++ -#endif -#if CONFIG_CPU_M65_45GS02 - .eval selected++ -#endif -#if CONFIG_CPU_WDC_65816 - .eval selected++ -#endif - - .if (selected != 1) .error "Please select exactly one CONFIG_CPU_* option" +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !ifdef CONFIG_IEC { !error "Do not use CONFIG_IEC options for Commander X16 platform, it is not implemented" } +} +!ifdef CONFIG_MB_MEGA65 { + !ifdef CONFIG_IEC_BURST_CIA1 { !error "Do not use CONFIG_IEC_BURST_CIA1 options for MEGA65 motherboard, CONFIG_IEC_BURST_M65 instead" } + !ifdef CONFIG_IEC_BURST_CIA2 { !error "Do not use CONFIG_IEC_BURST_CIA2 options for MEGA65 motherboard, CONFIG_IEC_BURST_M65 instead" } +} +!ifndef CONFIG_MB_MEGA65 { + !ifdef CONFIG_IEC_BURST_M65 { !error "CONFIG_IEC_BURST_M65 is only possible for MEGA65 motherboard" } +} +!ifdef CONFIG_IEC_BURST_CIA1 { + !ifndef CONFIG_IEC { !error "CONFIG_IEC_BURST_CIA1 requires CONFIG_IEC" } +} +!ifdef CONFIG_IEC_BURST_CIA2 { + !ifndef CONFIG_IEC { !error "CONFIG_IEC_BURST_CIA2 requires CONFIG_IEC" } +} +!ifdef CONFIG_IEC_BURST_CIA1 { + !ifdef CONFIG_IEC_BURST_CIA2 { !error "CONFIG_IEC_BURST_CIA1 and CONFIG_IEC_BURST_CIA2 are mutually exclusive" } +} +!ifdef CONFIG_IEC_BURST_M65 { + !ifndef CONFIG_IEC { !error "CONFIG_IEC_BURST_M65 requires CONFIG_IEC" } +} +!ifdef CONFIG_IEC_DOLPHINDOS { + !ifndef CONFIG_IEC { !error "CONFIG_IEC_DOLPHINDOS requires CONFIG_IEC" } +} +!ifdef CONFIG_IEC_DOLPHINDOS_FAST { + !ifndef CONFIG_IEC_DOLPHINDOS { !error "CONFIG_IEC_DOLPHINDOS_FAST requires CONFIG_IEC_DOLPHINDOS" } +} +!ifdef CONFIG_IEC_JIFFYDOS { + !ifndef CONFIG_IEC { !error "CONFIG_IEC_JIFFYDOS requires CONFIG_IEC" } +} +!ifdef CONFIG_IEC_JIFFYDOS_BLANK { + !ifndef CONFIG_IEC_JIFFYDOS { !error "CONFIG_IEC_JIFFYDOS_BLANK requires CONFIG_IEC_JIFFYDOS" } } -// 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" -#endif -#if ROM_LAYOUT_M65 && !CONFIG_MB_MEGA_65 - .error "MEGA65 ROM layout requires CONFIG_MB_MEGA_65" -#endif +; Check that tape deck configuration is correct - .var selected = 0; +!set counter = 0 +!ifdef CONFIG_TAPE_NORMAL { !set counter = counter + 1 } +!ifdef CONFIG_TAPE_TURBO { !set counter = counter + 1 } -#if CONFIG_MEMORY_MODEL_38K - .eval selected++ -#endif -#if CONFIG_MEMORY_MODEL_46K - .eval selected++ -#endif -#if CONFIG_MEMORY_MODEL_50K - .eval selected++ -#endif -#if CONFIG_MEMORY_MODEL_60K - .eval selected++ -#endif - - .if (selected != 1) .error "Please select exactly one CONFIG_MEMORY_MODEL_* option" +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !ifdef CONFIG_TAPE_NORMAL { !error "Do not use CONFIG_TAPE_NORMAL options for Commander X16 platform, it is not implemented" } + !ifdef CONFIG_TAPE_TURBO { !error "Do not use CONFIG_TAPE_TURBO options for Commander X16 platform, it is not implemented" } +} +!ifdef CONFIG_TAPE_AUTODETECT { !ifndef CONFIG_TAPE_NORMAL { !ifndef CONFIG_TAPE_TURBO { + !error "CONFIG_TAPE_AUTODETECT requires both CONFIG_TAPE_NORMAL and CONFIG_TAPE_TURBO" +} } } +!ifdef CONFIG_TAPE_HEAD_ALIGN { + !ifndef CONFIG_TAPE_WEDGE { !error "CONFIG_TAPE_HEAD_ALIGN requires CONFIG_TAPE_WEDGE" } +} +!ifdef CONFIG_TAPE_WEDGE { + !if (counter = 0) { !error "CONFIG_TAPE_WEDGE requires CONFIG_TAPE_TURBO or CONFIG_TAPE_NORMAL"} } -// Check that IEC configuration is correct -{ -#if CONFIG_IEC_JIFFYDOS && !CONFIG_IEC - .error "CONFIG_IEC_JIFFYDOS requires CONFIG_IEC" -#endif +; Check that RS-232 configuration is correct -#if CONFIG_IEC_JIFFYDOS_BLANK && !CONFIG_IEC_JIFFYDOS - .error "CONFIG_IEC_JIFFYDOS_BLANK requires CONFIG_IEC_JIFFYDOS" -#endif +!set counter = 0 +!ifdef CONFIG_RS232_ACIA { !set counter = counter + 1 } +!ifdef CONFIG_RS232_UP2400 { !set counter = counter + 1 } +!ifdef CONFIG_RS232_UP9600 { !set counter = counter + 1 } -#if CONFIG_IEC_DOLPHINDOS && !CONFIG_IEC - .error "CONFIG_IEC_DOLPHINDOS requires CONFIG_IEC" -#endif +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !if (counter != 0) { !error "Do not use CONFIG_RS232_* options for Commander X16 platform, it is not implemented" } +} +!ifdef CONFIG_RS232_UP9600 { + !ifdef CONFIG_TAPE_NORMAL { !error "CONFIG_RS232_UP9600 is not compatible with CONFIG_TAPE_NORMAL" } + !ifdef CONFIG_TAPE_TURBO { !error "CONFIG_RS232_UP9600 is not compatible with CONFIG_TAPE_TURBO" } +} +!if (counter > 1) { !error "Please select at most one CONFIG_RS232_* option" } -#if CONFIG_IEC_DOLPHINDOS_FAST && !CONFIG_IEC_DOLPHINDOS - .error "CONFIG_IEC_DOLPHINDOS_FAST requires CONFIG_IEC_DOLPHINDOS" -#endif -#if (CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_MEGA_65) && !CONFIG_IEC - .error "CONFIG_IEC_BURST_* requires CONFIG_IEC" -#endif -#if CONFIG_IEC_BURST_MEGA_65 && !CONFIG_MB_MEGA_65 - .error "CONFIG_IEC_BURST_MEGA_65 requires CONFIG_MB_MEGA_65" -#endif +; Check that sound support configuration is correct - .var selected_iec_burst = 0; +!set counter = 0 +!ifdef CONFIG_SID_2ND_ADDRESS { !set counter = counter + 1 } +!ifdef CONFIG_SID_3RD_ADDRESS { !set counter = counter + 1 } +!ifdef CONFIG_SID_D4XX { !set counter = counter + 1 } +!ifdef CONFIG_SID_D5XX { !set counter = counter + 1 } -#if CONFIG_IEC_BURST_CIA1 - .eval selected_iec_burst++ -#endif -#if CONFIG_IEC_BURST_CIA2 - .eval selected_iec_burst++ -#endif -#if CONFIG_IEC_BURST_MEGA_65 - .eval selected_iec_burst++ -#endif +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !if (counter != 0) { !error "Do not use CONFIG_SID_* options for Commander X16 platform" } +} +!ifdef CONFIG_MB_M65 { + !if (counter != 0) { !error "Do not use CONFIG_SID_* options for MEGA65 motherboard" } +} +!ifdef CONFIG_SID_2ND_ADDRESS { + !if (CONFIG_SID_2ND_ADDRESS = $D400) { !error "CONFIG_SID_2ND_ADDRESS points to the 1st SID" } +} +!ifdef CONFIG_SID_3RD_ADDRESS { + !if (CONFIG_SID_3RD_ADDRESS = $D400) { !error "CONFIG_SID_3RD_ADDRESS points to the 1st SID" } +} +!ifdef CONFIG_SID_2ND_ADDRESS { !ifdef CONFIG_SID_3RD_ADDRESS { + !if (CONFIG_SID_2ND_ADDRESS = CONFIG_SID_3RD_ADDRESS) { !error "Configured SIDs have the same addresses" } +} } - .if (selected_iec_burst > 1) .error "Please select at most one CONFIG_IEC_BURST_* option" + + +; Check that keyboard settings are correct + +!ifdef CONFIG_LEGACY_SCNKEY { + !ifdef CONFIG_RS232_UP2400 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_RS232_UP2400" } + !ifdef CONFIG_RS232_UP9600 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_RS232_UP9600" } + !ifdef CONFIG_TAPE_NORMAL { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_TAPE_NORMAL" } + !ifdef CONFIG_KEYBOARD_C128 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C128" } + !ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" } + !ifdef CONFIG_KEYBOARD_C65 { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C65" } + !ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_KEYBOARD_C65_CAPS_LOCK" } +} +!ifdef CONFIG_MB_M65 { + !ifdef CONFIG_KEYBOARD_C128 { !error "MEGA65 motherboard is not compatible with CONFIG_KEYBOARD_C128" } + !ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "MEGA65 motherboard is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" } + !ifdef CONFIG_LEGACY_SCNKEY { !error "MEGA65 motherboard is not compatible with CONFIG_LEGACY_SCNKEY" } +} +!ifdef CONFIG_MB_U64 { + !ifdef CONFIG_KEYBOARD_C128 { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C128" } + !ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C128_CAPS_LOCK" } + !ifdef CONFIG_KEYBOARD_C65 { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C65" } + !ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !error "Ultimate 64 motherboard is not compatible with CONFIG_KEYBOARD_C65_CAPS_LOCK" } } -// Check that tape configuration is correct -{ -#if (!CONFIG_TAPE_NORMAL || !CONFIG_TAPE_TURBO) && CONFIG_TAPE_AUTODETECT - .error "CONFIG_TAPE_AUTODETECT requires both CONFIG_TAPE_NORMAL and CONFIG_TAPE_TURBO" -#endif +; Check that startup banner configuration is correct + +!set counter = 0 +!ifdef CONFIG_BANNER_SIMPLE { !set counter = counter + 1 } +!ifdef CONFIG_BANNER_FANCY { !set counter = counter + 1 } + +!ifdef CONFIG_MB_M65 { + !if (counter > 0) { !error "Do not use CONFIG_BANNER_* options for MEGA65" } + !ifdef CONFIG_COLORS_BRAND { !errror "Do not use CONFIG_COLORS_BRAND options for MEGA65" } + !ifdef CONFIG_SHOW_FEATURES { !errror "Do not use CONFIG_SHOW_FEATURES options for MEGA65" } +} else { + !if (counter != 1) { !error "Please select exactly one CONFIG_BANNER_* option" } } -// Check that RS-232 configuration is correct -{ -#if CONFIG_RS232_UP9600 && (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) - .error "CONFIG_RS232_UP9600 is not compatible with CONFIG_TAPE_*" -#endif +; +; Define some macros depending on the configuration +; - .var selected_rs232 = 0; -#if CONFIG_RS232_UP2400 - .eval selected_rs232++ -#endif -#if CONFIG_RS232_UP9600 - .eval selected_rs232++ -#endif - .if (selected_rs232 > 1) .error "Please select at most one CONFIG_RS232_* option" +; Handle CPU configuration + +!ifdef CONFIG_BCD_SAFE_INTERRUPTS { !set HAS_BCD_SAFE_INTERRUPTS = 1 } + +!ifdef CONFIG_CPU_MOS_6502 { + !cpu 6502 +} +!ifdef CONFIG_CPU_DTV_6502 { + !cpu c64dtv2 + !set HAS_OPCODE_BRA = 1 + ; XXX +} +!ifdef CONFIG_CPU_RCW_65C02 { + !cpu r65c02 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 +} +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { + !cpu w65c02 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 +} +!ifdef CONFIG_CPU_WDC_65C02 { + !cpu w65c02 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 +} +!ifdef CONFIG_CPU_WDC_65816 { + !cpu 65816 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 + !set HAS_OPCODES_65816 = 1 +} +!ifdef CONFIG_CPU_CSG_65CE02 { + !cpu 65ce02 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 + !set HAS_OPCODES_65CE02 = 1 +} +!ifdef CONFIG_MB_M65 { + !cpu m65 + !set HAS_BCD_SAFE_INTERRUPTS = 1 + !set HAS_OPCODE_BRA = 1 + !set HAS_OPCODES_65C02 = 1 + !set HAS_OPCODES_65CE02 = 1 } -// Check that startup banner configuration is correct -{ - .var selected = 0; +; Handle memory model -#if CONFIG_BANNER_SIMPLE - .eval selected++ -#endif -#if CONFIG_BANNER_FANCY - .eval selected++ -#endif - -#if !CONFIG_MB_MEGA_65 - .if (selected != 1) .error "Please select exactly one CONFIG_BANNER_* option" -#endif - -#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 - -} +!ifdef CONFIG_MEMORY_MODEL_46K { !set CONFIG_MEMORY_MODEL_46K_OR_50K = 1 } +!ifdef CONFIG_MEMORY_MODEL_50K { !set CONFIG_MEMORY_MODEL_46K_OR_50K = 1 } -// Check if keyboard options are correct -.function CHECK_KEYCMD(keycmd) -{ - .if (keycmd.size() > 0) .return 1 - .return 0 -} -{ -#if CONFIG_LEGACY_SCNKEY && CONFIG_RS232_UP9600 - .error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_RS232_UP9600" -#endif -#if CONFIG_LEGACY_SCNKEY && CONFIG_TAPE_NORMAL - .error "CONFIG_LEGACY_SCNKEY is not compatible with CONFIG_TAPE_NORMAL" -#endif -#if CONFIG_LEGACY_SCNKEY && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C128_CAPS_LOCK || CONFIG_KEYBOARD_C65 || CONFIG_KEYBOARD_C65_CAPS_LOCK) - .error "CONFIG_LEGACY_SCNKEY and CONFIG_KEYBOARD_C128* / CONFIG_KEYBOARD_C65* are mutually exclusive" -#endif +; Handle IEC configuration -#if (CONFIG_MB_MEGA_65 || CONFIG_MB_ULTIMATE_64) && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C128_CAPS_LOCK) - .error "Selected CONFIG_MB_* is not compatible with CONFIG_KEYBOARD_C128*" -#endif -#if CONFIG_MB_ULTIMATE_64 && (CONFIG_KEYBOARD_C65 || CONFIG_KEYBOARD_C65_CAPS_LOCK) - .error "Selected CONFIG_MB_* is not compatible with CONFIG_KEYBOARD_C65*" -#endif +!ifdef CONFIG_IEC_BURST_CIA1 { !set HAS_IEC_BURST = 1 } +!ifdef CONFIG_IEC_BURST_CIA2 { !set HAS_IEC_BURST = 1 } +!ifdef CONFIG_IEC_BURST_M65 { !set HAS_IEC_BURST = 1 } - .var num_pkeys_base = 0 - .var num_pkeys_ext1 = 0 - .var num_pkeys_ext2 = 0 - - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_RUN) - - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F1) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F2) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F3) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F4) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F5) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F6) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F7) - .eval num_pkeys_base += CHECK_KEYCMD(CONFIG_KEYCMD_F8) - - .eval num_pkeys_ext1 += CHECK_KEYCMD(CONFIG_KEYCMD_HELP) - - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F9) - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F10) - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F11) - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F12) - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F13) - .eval num_pkeys_ext2 += CHECK_KEYCMD(CONFIG_KEYCMD_F14) - - .var num_pkeys = num_pkeys_base -#if !CONFIG_LEGACY_SCNKEY && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65) - .eval num_pkeys += num_pkeys_ext1 -#endif -#if !CONFIG_LEGACY_SCNKEY && CONFIG_KEYBOARD_C65 - .eval num_pkeys += num_pkeys_ext2 -#endif - -#if CONFIG_PROGRAMMABLE_KEYS - .if (num_pkeys == 0) .error "CONFIG_PROGRAMMABLE_KEYS requires at least one defined key" -#endif -} +!ifdef CONFIG_IEC_JIFFYDOS { !set CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS = 1 } +!ifdef CONFIG_IEC_DOLPHINDOS { !set CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS = 1 } -// Check that features are configured correctly -{ -#if CONFIG_TAPE_WEDGE && !CONFIG_TAPE_TURBO && !CONFIG_TAPE_NORMAL - .error "CONFIG_TAPE_WEDGE requires CONFIG_TAPE_TURBO or CONFIG_TAPE_NORMAL" -#endif -#if !CONFIG_TAPE_WEDGE && CONFIG_TAPE_HEAD_ALIGN - .error "CONFIG_TAPE_HEAD_ALIGN requires CONFIG_TAPE_WEDGE" -#endif -} +; Handle tape configuration + +!ifdef CONFIG_TAPE_NORMAL { !set HAS_TAPE = 1 } +!ifdef CONFIG_TAPE_TURBO { !set HAS_TAPE = 1 } + +!ifdef CONFIG_TAPE_NORMAL { !set HAS_TAPE_OR_IEC = 1 } +!ifdef CONFIG_TAPE_TURBO { !set HAS_TAPE_OR_IEC = 1 } +!ifdef CONFIG_IEC { !set HAS_TAPE_OR_IEC = 1 } + +!ifdef CONFIG_DOS_WEDGE { !set HAS_WEDGE = 1 } +!ifdef CONFIG_TAPE_WEDGE { !set HAS_WEDGE = 1 } -// Handle I/O configuration +; Handle RS-232 configuration -#if CONFIG_RS232_UP2400 || CONFIG_RS232_UP9600 -#define HAS_RS232 -#endif +!ifdef CONFIG_RS232_ACIA { !set HAS_RS232 = 1 } +!ifdef CONFIG_RS232_UP2400 { !set HAS_RS232 = 1 } +!ifdef CONFIG_RS232_UP9600 { !set HAS_RS232 = 1 } -// Handle configuration of various features +; Handle sound configuration -#if CONFIG_BCD_SAFE_INTERRUPTS -#define HAS_BCD_SAFE_INTERRUPTS -#endif +!ifdef CONFIG_SID_D4XX { !set CONFIG_SID_D4XX_OR_D5XX = 1 } +!ifdef CONFIG_SID_D5XX { !set CONFIG_SID_D4XX_OR_D5XX = 1 } -// Handle configuration of debug infrastructure +; Handle keyboard configuration -.macro STUB_IMPLEMENTATION_RTS() { +!ifdef CONFIG_KEYBOARD_C128 { !set CONFIG_KEYBOARD_C128_OR_C65 = 1 } +!ifdef CONFIG_KEYBOARD_C65 { !set CONFIG_KEYBOARD_C128_OR_C65 = 1 } + +!ifdef CONFIG_KEYBOARD_C65 { !set CONFIG_KEYBOARD_C65_OR_CAPS_LOCK = 1 } +!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set CONFIG_KEYBOARD_C65_OR_CAPS_LOCK = 1 } + +!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !set CONFIG_KEYBOARD_CAPS_LOCK = 1 } +!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set CONFIG_KEYBOARD_CAPS_LOCK = 1 } + +!ifdef CONFIG_JOY1_CURSOR { !set CONFIG_JOY1_OR_JOY2_CURSOR = 1 } +!ifdef CONFIG_JOY2_CURSOR { !set CONFIG_JOY1_OR_JOY2_CURSOR = 1 } + + +; Handle debug configuration + +!macro STUB_IMPLEMENTATION_RTS { rts } -.macro STUB_IMPLEMENTATION_BRK() { - .break +!macro STUB_IMPLEMENTATION_BRK { + ; XXX set VICE breakpoint brk brk jmp *-2 } -.macro STUB_IMPLEMENTATION() -{ -#if CONFIG_DBG_STUBS_BRK - STUB_IMPLEMENTATION_BRK() -#else - STUB_IMPLEMENTATION_RTS() -#endif +!ifdef CONFIG_DBG_STUBS_BRK { + !macro STUB_IMPLEMENTATION { +STUB_IMPLEMENTATION_BRK } +} else { + !macro STUB_IMPLEMENTATION { +STUB_IMPLEMENTATION_RTS } } -// Setup colors +; Handle colors -#if CONFIG_COLORS_BRAND && CONFIG_BRAND_ULTIMATE_64 +!set CONFIG_COLOR_BG = $06 +!set CONFIG_COLOR_TXT = $01 - .const CONFIG_COLOR_BG = $00 - .const CONFIG_COLOR_TXT = $01 - -#else - - .const CONFIG_COLOR_BG = $06 - .const CONFIG_COLOR_TXT = $01 - -#endif +!ifdef CONFIG_COLORS_BRAND { + !ifdef CONFIG_MB_U64 { + !set CONFIG_COLOR_BG = $00 + !set CONFIG_COLOR_TXT = $01 + } +} -// Determine if we need space-savings in BASIC code -#if !ROM_LAYOUT_M65 -#define HAS_SMALL_BASIC -#endif +; Determine if we need space-savings in BASIC code + +!ifndef CONFIG_MB_M65 { + !set HAS_SMALL_BASIC = 1 +} + + + +; Defines for multi-segment ROMs + +!ifdef CONFIG_MB_M65 { + !ifdef SEGMENT_BASIC_0 { !set SEGMENT_M65_BASIC_0 = 1 } + !ifdef SEGMENT_BASIC_1 { !set SEGMENT_M65_BASIC_1 = 1 } + !ifdef SEGMENT_KERNAL_0 { !set SEGMENT_M65_KERNAL_0 = 1 } +} diff --git a/src/aliases/,aliases_cpu.s b/src/aliases/,aliases_cpu.s index 7ea9898c..faef48c8 100644 --- a/src/aliases/,aliases_cpu.s +++ b/src/aliases/,aliases_cpu.s @@ -1,546 +1,138 @@ -// -// Provide pseudocommands (and other goodies) to make CPU optimizations easier -// - -#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_CSG_4510 || CONFIG_CPU_M65_45GS02 || CONFIG_CPU_WDC_65816 - .cpu _65c02 - #define HAS_OPCODES_65C02 - #define HAS_BCD_SAFE_INTERRUPTS -#endif - -#if CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_CSG_4510 || CONFIG_CPU_M65_45GS02 - #define HAS_OPCODES_65CE02 -#endif - -#if CONFIG_CPU_CSG_4510 || CONFIG_CPU_M65_45GS02 - #define HAS_OPCODES_4510 -#endif - -#if CONFIG_CPU_M65_45GS02 - #define HAS_OPCODES_45GS02 -#endif - -#if CONFIG_CPU_WDC_65816 - #define HAS_OPCODES_65816 -#endif +; +; Various macros - mainly for making CPU-specific optimizations easier +; -// -// These are not exactly for optimization - but to encourage proper usage of panic screen -// - -.pseudocommand panic code -{ - // If case no panic screen is used, we can skip providing error codes within Kernal -#if CONFIG_PANIC_SCREEN - lda code -#endif +!macro panic @code { + ; If case no panic screen is used, we can skip providing error codes within Kernal + !ifdef CONFIG_PANIC_SCREEN { lda #@code } jmp ($E4B7) } - - -// -// Macros for generating jumptables -// - - -.macro put_jumptable_lo(list) -{ - .for (var i = 0; i < list.size(); i++) - { - .byte mod((list.get(i) - 1), $100) - } +!macro skip_2_bytes_trash_nvz { + ; Trick to skip a 2-byte instruction + !byte $2C } -.macro put_jumptable_hi(list) -{ - .for (var i = 0; i < list.size(); i++) - { - .byte floor((list.get(i) - 1) / $100) - } -} - -#if HAS_OPCODES_65C02 - -.macro put_jumptable(list) -{ - .for (var i = 0; i < list.size(); i++) - { - .word list.get(i) - } -} - -#endif - - - -// -// Trick to skip a 2-byte instruction -// - -.pseudocommand skip_2_bytes_trash_nvz { .byte $2C } - - - -// -// Memory mapping for C65 and MEGA65 -// - -#if HAS_OPCODES_4510 - -.pseudocommand map { .byte $5C } -.pseudocommand eom { .byte $EA } - -#endif - - -// -// Some additional 65C02 instructions -// - -#if HAS_OPCODES_65C02 - -.pseudocommand inc_a { .byte $1A } -.pseudocommand dec_a { .byte $3A } - -#endif - -// -// Some additional 65CE02 instructions -// - -#if HAS_OPCODES_65CE02 - -// CPU flags support - -.pseudocommand cle { .byte $02 } -.pseudocommand see { .byte $03 } - -// .B register support - -.pseudocommand tab { .byte $5B } -.pseudocommand tba { .byte $7B } - -// .Z register support - -.pseudocommand inz { .byte $1B } -.pseudocommand dez { .byte $3B } -.pseudocommand phz { .byte $DB } -.pseudocommand plz { .byte $FB } -.pseudocommand taz { .byte $4B } -.pseudocommand tza { .byte $6B } - -// 16-bit data processing - -.pseudocommand dew addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "DEW requires zeropage address" - .byte $C3, arg -} - -.pseudocommand inw addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "INW requires zeropage address" - .byte $E3, arg -} - -// Zero page bit handling - -.pseudocommand rmb0 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB0 requires zeropage address" - .byte $07, arg -} - -.pseudocommand rmb1 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB1 requires zeropage address" - .byte $17, arg -} - -.pseudocommand rmb2 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB2 requires zeropage address" - .byte $27, arg -} - -.pseudocommand rmb3 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB3 requires zeropage address" - .byte $37, arg -} - -.pseudocommand rmb4 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB4 requires zeropage address" - .byte $47, arg -} - -.pseudocommand rmb5 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB5 requires zeropage address" - .byte $57, arg -} - -.pseudocommand rmb6 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB6 requires zeropage address" - .byte $67, arg -} - -.pseudocommand rmb7 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "RMB7 requires zeropage address" - .byte $77, arg -} - -.pseudocommand smb0 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB0 requires zeropage address" - .byte $87, arg -} - -.pseudocommand smb1 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB1 requires zeropage address" - .byte $97, arg -} - -.pseudocommand smb2 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB2 requires zeropage address" - .byte $A7, arg -} - -.pseudocommand smb3 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB3 requires zeropage address" - .byte $B7, arg -} - -.pseudocommand smb4 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB4 requires zeropage address" - .byte $C7, arg -} - -.pseudocommand smb5 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB5 requires zeropage address" - .byte $D7, arg -} - -.pseudocommand smb6 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB6 requires zeropage address" - .byte $E7, arg -} - -.pseudocommand smb7 addr -{ - .var arg = addr.getValue() - .if (arg > $FF) .error "SMB7 requires zeropage address" - .byte $F7, arg -} - -// Additional addressing modes - -.pseudocommand jsr_ind addr -{ - .var arg = addr.getValue() - .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 - } +!macro lda_zero { + ; WARNING: this one can be dangerous in soem cases, use with care! + !ifdef HAS_OPCODES_65CE02 { + tba } else { - .error "Invalid adressingmode. 'cpz' doesn't support "+GetAdressingModeType(type)+" mode" + lda #$00 } } -.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 + +; Stack manipulation - some CPUs will leave .A unchanged, some will use it as temporary storage, so consider .A trashed + +!macro phx_trash_a { !ifdef HAS_OPCODES_65C02 { + phx } else { - .error "Invalid adressingmode. 'ldz' doesn't support "+GetAdressingModeType(type)+" mode" - } -} + txa + pha +} } -.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 -} +!macro phy_trash_a { !ifdef HAS_OPCODES_65C02 { + phy + } else { + tya + pha +} } -// Flat memory access support +!macro plx_trash_a { !ifdef HAS_OPCODES_65C02 { + plx + } else { + pla + tax +} } -.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 +!macro ply_trash_a { !ifdef HAS_OPCODES_65C02 { + ply + } else { + pla + tay +} } -// -// Calculation shortcuts -// +; Near jump, on some CPUs can be substituted with shorter instruction -.pseudocommand lda_zero // WARNING: do not use within interrupts -{ -#if HAS_OPCODES_65CE02 - tba -#else - lda #$00 -#endif -} +!macro bra @dst { !ifdef HAS_OPCODE_BRA { + bra @dst + } else { + jmp @dst +} } -// -// Stack manipulation - some CPUs will leave .A unchanged, some will use it as temporary storage, so consider .A trashed -// +; NOP definition, MEGA65 CPU uses EOM instead -.pseudocommand phx_trash_a -{ -#if HAS_OPCODES_65C02 - phx -#else - txa - pha -#endif -} - -.pseudocommand phy_trash_a -{ -#if HAS_OPCODES_65C02 - phy -#else - tya - pha -#endif -} - -.pseudocommand plx_trash_a -{ -#if HAS_OPCODES_65C02 - plx -#else - pla - tax -#endif -} - -.pseudocommand ply_trash_a -{ -#if HAS_OPCODES_65C02 - ply -#else - pla - tay -#endif -} +!macro nop { !ifdef CONFIG_MB_M65 { + eom + } else { + nop +} } -// -// Branches with far offsets, substitutes by Bxx + JMP for CPUs not supporting the instruction -// +; Branches with far offsets, substitutes by Bxx + JMP for CPUs not supporting the instruction -.pseudocommand bcs_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $B3, mod(offset, $100), floor(offset / $100) -#else - bcc __l - jmp dst -__l: -#endif -} +!macro bcs @dst { !ifdef HAS_OPCODES_65CE02 { + lbcs @dst + } else { + bcc *+5 + jmp @dst +} } -.pseudocommand bcc_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $93, mod(offset, $100), floor(offset / $100) -#else - bcs __l - jmp dst -__l: -#endif -} +!macro bcc @dst { !ifdef HAS_OPCODES_65CE02 { + lbcc @dst + } else { + bcs *+5 + jmp @dst +} } -.pseudocommand beq_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $F3, mod(offset, $100), floor(offset / $100) -#else - bne __l - jmp dst -__l: -#endif -} +!macro beq @dst { !ifdef HAS_OPCODES_65CE02 { + lbeq @dst + } else { + bne *+5 + jmp @dst +} } -.pseudocommand bne_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $D3, mod(offset, $100), floor(offset / $100) -#else - beq __l - jmp dst -__l: -#endif -} +!macro bne @dst { !ifdef HAS_OPCODES_65CE02 { + lbne @dst + } else { + beq *+5 + jmp @dst +} } -.pseudocommand bmi_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $33, mod(offset, $100), floor(offset / $100) -#else - bpl __l - jmp dst -__l: -#endif -} +!macro bmi @dst { !ifdef HAS_OPCODES_65CE02 { + lbmi @dst + } else { + bpl *+5 + jmp @dst +} } -.pseudocommand bpl_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $13, mod(offset, $100), floor(offset / $100) -#else - bmi __l - jmp dst -__l: -#endif -} +!macro bpl @dst { !ifdef HAS_OPCODES_65CE02 { + lbpl @dst + } else { + bmi *+5 + jmp @dst +} } -.pseudocommand bvc_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $53, mod(offset, $100), floor(offset / $100) -#else - bvs __l - jmp dst -__l: -#endif -} +!macro bvc @dst { !ifdef HAS_OPCODES_65CE02 { + lbvc @dst + } else { + bvs *+5 + jmp @dst +} } -.pseudocommand bvs_16 dst -{ -#if HAS_OPCODES_65CE02 - .var offset = mod($10000 + dst.getValue() - *, $10000) -2 - .byte $73, mod(offset, $100), floor(offset / $100) -#else - bvc __l - jmp dst -__l: -#endif -} - - -// -// Near jump, on some CPUs can be substituted with shorter instruction -// - -.pseudocommand jmp_8 dst -{ -#if HAS_OPCODES_65C02 - bra dst -#else - jmp dst -#endif -} +!macro bvs @dst { !ifdef HAS_OPCODES_65CE02 { + lbvs @dst + } else { + bvc *+5 + jmp @dst +} } diff --git a/src/aliases/,aliases_error_codes.s b/src/aliases/,aliases_error_codes.s index fc30b384..a9fde15c 100644 --- a/src/aliases/,aliases_error_codes.s +++ b/src/aliases/,aliases_error_codes.s @@ -1,69 +1,69 @@ - // Error codes for 'panic' pseudocommand +; Error codes for 'panic' pseudocommand - .const P_ERR_NONE = $00 - .const P_ERR_ROM_MISMATCH = $01 // this value has to be stable as long as possible +!set P_ERR_NONE = $00 +!set P_ERR_ROM_MISMATCH = $01 ; this value has to be stable as long as possible - // Kernal error codes - returned in the A register - // Described in 'Commodore 64 Programmer's Reference Guide', page 306 +; Kernal error codes - returned in the A register +; Described in 'Commodore 64 Programmer's Reference Guide', page 306 - .const K_ERR_ROUTINE_TERMINATED = $00 - .const K_ERR_TOO_MANY_OPEN_FILES = $01 - .const K_ERR_FILE_ALREADY_OPEN = $02 - .const K_ERR_FILE_NOT_OPEN = $03 - .const K_ERR_FILE_NOT_FOUND = $04 - .const K_ERR_DEVICE_NOT_FOUND = $05 - .const K_ERR_FILE_NOT_INPUT = $06 - .const K_ERR_FILE_NOT_OUTPUT = $07 - .const K_ERR_FILE_NAME_MISSING = $08 - .const K_ERR_ILLEGAL_DEVICE_NUMBER = $09 - .const K_ERR_TOP_MEM_RS232 = $F0 +!set K_ERR_ROUTINE_TERMINATED = $00 +!set K_ERR_TOO_MANY_OPEN_FILES = $01 +!set K_ERR_FILE_ALREADY_OPEN = $02 +!set K_ERR_FILE_NOT_OPEN = $03 +!set K_ERR_FILE_NOT_FOUND = $04 +!set K_ERR_DEVICE_NOT_FOUND = $05 +!set K_ERR_FILE_NOT_INPUT = $06 +!set K_ERR_FILE_NOT_OUTPUT = $07 +!set K_ERR_FILE_NAME_MISSING = $08 +!set K_ERR_ILLEGAL_DEVICE_NUMBER = $09 +!set K_ERR_TOP_MEM_RS232 = $F0 - // Kernal status codes for READST routine (IOSTATUS) - // Described in 'Commodore 64 Programmer's Reference Guide', page 292 +; Kernal status codes for READST routine (IOSTATUS) +; Described in 'Commodore 64 Programmer's Reference Guide', page 292 - // For IEC devices - .const K_STS_TIMEOUT_WRITE = $01 - .const K_STS_TIMEOUT_READ = $02 - .const K_STS_EOI = $40 - .const K_STS_DEVICE_NOT_FOUND = $80 - // For tape deck - .const K_STS_SHORT_BLOCK = $04 - .const K_STS_LONG_BLOCK = $08 - .const K_STS_READ_ERROR = $10 - .const K_STS_CHECKSUM_ERROR = $20 - .const K_STS_END_OF_FILE = $40 - .const K_STS_END_OF_TAPE = $80 +; For IEC devices +!set K_STS_TIMEOUT_WRITE = $01 +!set K_STS_TIMEOUT_READ = $02 +!set K_STS_EOI = $40 +!set K_STS_DEVICE_NOT_FOUND = $80 +; For tape deck +!set K_STS_SHORT_BLOCK = $04 +!set K_STS_LONG_BLOCK = $08 +!set K_STS_READ_ERROR = $10 +!set K_STS_CHECKSUM_ERROR = $20 +!set K_STS_END_OF_FILE = $40 +!set K_STS_END_OF_TAPE = $80 - // BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html - .const B_ERR_TOO_MANY_FILES = $01 - .const B_ERR_FILE_OPEN = $02 - .const B_ERR_FILE_NOT_OPEN = $03 - .const B_ERR_FILE_NOT_FOUND = $04 - .const B_ERR_DEVICE_NOT_PRESENT = $05 - .const B_ERR_NOT_INPUT_FILE = $06 - .const B_ERR_NOT_OUTPUT_FILE = $07 - .const B_ERR_MISSING_FILENAME = $08 - .const B_ERR_ILLEGAL_DEVICE_NUMBER = $09 - .const B_ERR_NEXT_WITHOUT_FOR = $0A - .const B_ERR_SYNTAX = $0B - .const B_ERR_RETURN_WITHOUT_GOSUB = $0C - .const B_ERR_OUT_OF_DATA = $0D - .const B_ERR_ILLEGAL_QUANTITY = $0E - .const B_ERR_OVERFLOW = $0F - .const B_ERR_OUT_OF_MEMORY = $10 - .const B_ERR_UNDEFD_STATEMENT = $11 - .const B_ERR_BAD_SUBSCRIPT = $12 - .const B_ERR_REDIMD_ARRAY = $13 - .const B_ERR_DIVISION_BY_ZERO = $14 - .const B_ERR_ILLEGAL_DIRECT = $15 - .const B_ERR_TYPE_MISMATCH = $16 - .const B_ERR_STRING_TOO_LONG = $17 - .const B_ERR_FILE_DATA = $18 - .const B_ERR_FORMULA_TOO_COMPLEX = $19 - .const B_ERR_CANT_CONTINUE = $1A - .const B_ERR_UNDEFD_FUNCTION = $1B - .const B_ERR_VERIFY = $1C - .const B_ERR_LOAD = $1D - .const B_ERR_BREAK = $1E +; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html +!set B_ERR_TOO_MANY_FILES = $01 +!set B_ERR_FILE_OPEN = $02 +!set B_ERR_FILE_NOT_OPEN = $03 +!set B_ERR_FILE_NOT_FOUND = $04 +!set B_ERR_DEVICE_NOT_PRESENT = $05 +!set B_ERR_NOT_INPUT_FILE = $06 +!set B_ERR_NOT_OUTPUT_FILE = $07 +!set B_ERR_MISSING_FILENAME = $08 +!set B_ERR_ILLEGAL_DEVICE_NUMBER = $09 +!set B_ERR_NEXT_WITHOUT_FOR = $0A +!set B_ERR_SYNTAX = $0B +!set B_ERR_RETURN_WITHOUT_GOSUB = $0C +!set B_ERR_OUT_OF_DATA = $0D +!set B_ERR_ILLEGAL_QUANTITY = $0E +!set B_ERR_OVERFLOW = $0F +!set B_ERR_OUT_OF_MEMORY = $10 +!set B_ERR_UNDEFD_STATEMENT = $11 +!set B_ERR_BAD_SUBSCRIPT = $12 +!set B_ERR_REDIMD_ARRAY = $13 +!set B_ERR_DIVISION_BY_ZERO = $14 +!set B_ERR_ILLEGAL_DIRECT = $15 +!set B_ERR_TYPE_MISMATCH = $16 +!set B_ERR_STRING_TOO_LONG = $17 +!set B_ERR_FILE_DATA = $18 +!set B_ERR_FORMULA_TOO_COMPLEX = $19 +!set B_ERR_CANT_CONTINUE = $1A +!set B_ERR_UNDEFD_FUNCTION = $1B +!set B_ERR_VERIFY = $1C +!set B_ERR_LOAD = $1D +!set B_ERR_BREAK = $1E diff --git a/src/aliases/,aliases_hardware.s b/src/aliases/,aliases_hardware.s index ae0ae762..5b6d5167 100644 --- a/src/aliases/,aliases_hardware.s +++ b/src/aliases/,aliases_hardware.s @@ -1,198 +1,179 @@ -// -// Names of hardware registers - names from C64 Programmer's Reference Guide, sometimes slightly modified -// +; +; Names of hardware registers - names from C64 Programmer's Reference Guide, sometimes slightly modified +; -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { - // CPU memory registers + ; CPU memory registers - .label CPU_D6510 = $00 - .label CPU_R6510 = $01 + !addr CPU_D6510 = $00 + !addr CPU_R6510 = $01 - // VIC-II registers + ; VIC-II registers - .label __VIC_BASE = $D000 // base address of the chip + !addr __VIC_BASE = $D000 ; base address of the chip - .label VIC_SP0X = $D000 - .label VIC_SP0Y = $D001 - .label VIC_SP1X = $D002 - .label VIC_SP1Y = $D003 - .label VIC_SP2X = $D004 - .label VIC_SP2Y = $D005 - .label VIC_SP3X = $D006 - .label VIC_SP3Y = $D007 - .label VIC_SP4X = $D008 - .label VIC_SP4Y = $D009 - .label VIC_SP5X = $D00A - .label VIC_SP5Y = $D00B - .label VIC_SP6X = $D00C - .label VIC_SP6Y = $D00D - .label VIC_SP7X = $D00E - .label VIC_SP7Y = $D00F + !addr VIC_SP0X = $D000 + !addr VIC_SP0Y = $D001 + !addr VIC_SP1X = $D002 + !addr VIC_SP1Y = $D003 + !addr VIC_SP2X = $D004 + !addr VIC_SP2Y = $D005 + !addr VIC_SP3X = $D006 + !addr VIC_SP3Y = $D007 + !addr VIC_SP4X = $D008 + !addr VIC_SP4Y = $D009 + !addr VIC_SP5X = $D00A + !addr VIC_SP5Y = $D00B + !addr VIC_SP6X = $D00C + !addr VIC_SP6Y = $D00D + !addr VIC_SP7X = $D00E + !addr VIC_SP7Y = $D00F - .label VIC_MSIGX = $D010 - .label VIC_SCROLY = $D011 - .label VIC_RASTER = $D012 - .label VIC_LPENX = $D013 - .label VIC_LPENY = $D014 - .label VIC_SPENA = $D015 - .label VIC_SCROLX = $D016 - .label VIC_YXPAND = $D017 - .label VIC_YMCSB = $D018 - .label VIC_IRQ = $D019 - .label VIC_IRQMSK = $D01A - .label VIC_SPBGPR = $D01B - .label VIC_SPMC = $D01C - .label VIC_XXPAND = $D01D - .label VIC_SPSPCL = $D01E - .label VIC_SPBGCL = $D01F + !addr VIC_MSIGX = $D010 + !addr VIC_SCROLY = $D011 + !addr VIC_RASTER = $D012 + !addr VIC_LPENX = $D013 + !addr VIC_LPENY = $D014 + !addr VIC_SPENA = $D015 + !addr VIC_SCROLX = $D016 + !addr VIC_YXPAND = $D017 + !addr VIC_YMCSB = $D018 + !addr VIC_IRQ = $D019 + !addr VIC_IRQMSK = $D01A + !addr VIC_SPBGPR = $D01B + !addr VIC_SPMC = $D01C + !addr VIC_XXPAND = $D01D + !addr VIC_SPSPCL = $D01E + !addr VIC_SPBGCL = $D01F - .label VIC_EXTCOL = $D020 - .label VIC_BGCOL0 = $D021 - .label VIC_BGCOL1 = $D022 - .label VIC_BGCOL2 = $D023 - .label VIC_BGCOL3 = $D024 - .label VIC_SPMC0 = $D025 - .label VIC_SPMC1 = $D026 - .label VIC_SP0COL = $D027 - .label VIC_SP1COL = $D028 - .label VIC_SP2COL = $D029 - .label VIC_SP3COL = $D02A - .label VIC_SP4COL = $D02B - .label VIC_SP5COL = $D02C - .label VIC_SP6COL = $D02D - .label VIC_SP7COL = $D02E + !addr VIC_EXTCOL = $D020 + !addr VIC_BGCOL0 = $D021 + !addr VIC_BGCOL1 = $D022 + !addr VIC_BGCOL2 = $D023 + !addr VIC_BGCOL3 = $D024 + !addr VIC_SPMC0 = $D025 + !addr VIC_SPMC1 = $D026 + !addr VIC_SP0COL = $D027 + !addr VIC_SP1COL = $D028 + !addr VIC_SP2COL = $D029 + !addr VIC_SP3COL = $D02A + !addr VIC_SP4COL = $D02B + !addr VIC_SP5COL = $D02C + !addr VIC_SP6COL = $D02D + !addr VIC_SP7COL = $D02E -#if !CONFIG_MB_MEGA_65 && !CONFIG_MB_ULTIMATE_64 +!ifndef CONFIG_MB_M65 { !ifndef CONFIG_MB_U64 { - .label VIC_XSCAN = $D02F // C128 only - .label VIC_CLKRATE = $D030 // C128 only + !addr VIC_XSCAN = $D02F ; C128 only + !addr VIC_CLKRATE = $D030 ; C128 only +} } -#endif + ; SID registers - // SID registers + !addr __SID_BASE = $D400 ; base address of the chip - .label __SID_BASE = $D400 // base address of the chip + !addr SID_FRELO1 = $D400 + !addr SID_FREHI1 = $D401 + !addr SID_PWLO1 = $D402 + !addr SID_PWHI1 = $D403 + !addr SID_VCREG1 = $D404 + !addr SID_ATDCY1 = $D405 + !addr SID_SUREL1 = $D406 -#if CONFIG_MB_MEGA_65 + !addr SID_FRELO2 = $D407 + !addr SID_FREHI2 = $D408 + !addr SID_PWLO2 = $D409 + !addr SID_PWHI2 = $D40A + !addr SID_VCREG2 = $D40B + !addr SID_ATDCY2 = $D40C + !addr SID_SUREL2 = $D40D - .label __SID_R1_OFFSET = $00 // right SID 1, $D400 - .label __SID_R2_OFFSET = $20 // right SID 2, $D420 - .label __SID_L1_OFFSET = $40 // left SID 1, $D440 - .label __SID_L2_OFFSET = $60 // left SID 2, $D460 + !addr SID_FRELO3 = $D40E + !addr SID_FREHI3 = $D40F + !addr SID_PWLO3 = $D410 + !addr SID_PWHI3 = $D411 + !addr SID_VCREG3 = $D412 + !addr SID_ATDCY3 = $D413 + !addr SID_SUREL3 = $D414 -#endif + !addr SID_CUTLO = $D415 + !addr SID_CUTHI = $D416 + !addr SID_RESON = $D417 + !addr SID_SIGVOL = $D418 + !addr SID_POTX = $D419 + !addr SID_POTY = $D41A + !addr SID_RANDOM = $D41B + !addr SID_ENV3 = $D41C - .label SID_FRELO1 = $D400 - .label SID_FREHI1 = $D401 - .label SID_PWLO1 = $D402 - .label SID_PWHI1 = $D403 - .label SID_VCREG1 = $D404 - .label SID_ATDCY1 = $D405 - .label SID_SUREL1 = $D406 + ; Color COLOR_RAM - .label SID_FRELO2 = $D407 - .label SID_FREHI2 = $D408 - .label SID_PWLO2 = $D409 - .label SID_PWHI2 = $D40A - .label SID_VCREG2 = $D40B - .label SID_ATDCY2 = $D40C - .label SID_SUREL2 = $D40D + !addr COLOR_RAM = $D800 - .label SID_FRELO3 = $D40E - .label SID_FREHI3 = $D40F - .label SID_PWLO3 = $D410 - .label SID_PWHI3 = $D411 - .label SID_VCREG3 = $D412 - .label SID_ATDCY3 = $D413 - .label SID_SUREL3 = $D414 + ; CIA #1 registers - .label SID_CUTLO = $D415 - .label SID_CUTHI = $D416 - .label SID_RESON = $D417 - .label SID_SIGVOL = $D418 - .label SID_POTX = $D419 - .label SID_POTY = $D41A - .label SID_RANDOM = $D41B - .label SID_ENV3 = $D41C + !addr __CIA1_BASE = $DC00 ; base address of the chip - // Color COLOR_RAM + !addr CIA1_PRA = $DC00 + !addr CIA1_PRB = $DC01 + !addr CIA1_DDRA = $DC02 + !addr CIA1_DDRB = $DC03 - .label COLOR_RAM = $D800 + !addr CIA1_TIMALO = $DC04 + !addr CIA1_TIMAHI = $DC05 + !addr CIA1_TIMBLO = $DC06 + !addr CIA1_TIMBHI = $DC07 - // CIA #1 registers + !addr CIA1_TODTEN = $DC08 + !addr CIA1_TODSEC = $DC09 + !addr CIA1_TODMIN = $DC0A + !addr CIA1_TODHRS = $DC0B - .label __CIA1_BASE = $DC00 // base address of the chip + !addr CIA1_SDR = $DC0C + !addr CIA1_ICR = $DC0D + !addr CIA1_CRA = $DC0E + !addr CIA1_CRB = $DC0F - .label CIA1_PRA = $DC00 - .label CIA1_PRB = $DC01 - .label CIA1_DDRA = $DC02 - .label CIA1_DDRB = $DC03 + ; CIA #2 registers - .label CIA1_TIMALO = $DC04 - .label CIA1_TIMAHI = $DC05 - .label CIA1_TIMBLO = $DC06 - .label CIA1_TIMBHI = $DC07 + !addr __CIA2_BASE = $DD00 ; base address of the chip - .label CIA1_TODTEN = $DC08 - .label CIA1_TODSEC = $DC09 - .label CIA1_TODMIN = $DC0A - .label CIA1_TODHRS = $DC0B + !addr CIA2_PRA = $DD00 ; VIC bank switching and IEC port + !addr CIA2_PRB = $DD01 + !addr CIA2_DDRA = $DD02 + !addr CIA2_DDRB = $DD03 - .label CIA1_SDR = $DC0C - .label CIA1_ICR = $DC0D - .label CIA1_CRA = $DC0E - .label CIA1_CRB = $DC0F + !addr CIA2_TIMALO = $DD04 + !addr CIA2_TIMAHI = $DD05 + !addr CIA2_TIMBLO = $DD06 + !addr CIA2_TIMBHI = $DD07 - // CIA #2 registers + !addr CIA2_TODTEN = $DD08 + !addr CIA2_TODSEC = $DD09 + !addr CIA2_TODMIN = $DD0A + !addr CIA2_TODHRS = $DD0B - .label __CIA2_BASE = $DD00 // base address of the chip + !addr CIA2_SDR = $DD0C + !addr CIA2_ICR = $DD0D + !addr CIA2_CRA = $DD0E + !addr CIA2_CRB = $DD0F - .label CIA2_PRA = $DD00 // VIC bank switching and IEC port - .label CIA2_PRB = $DD01 - .label CIA2_DDRA = $DD02 - .label CIA2_DDRB = $DD03 - - .label CIA2_TIMALO = $DD04 - .label CIA2_TIMAHI = $DD05 - .label CIA2_TIMBLO = $DD06 - .label CIA2_TIMBHI = $DD07 - - .label CIA2_TODTEN = $DD08 - .label CIA2_TODSEC = $DD09 - .label CIA2_TODMIN = $DD0A - .label CIA2_TODHRS = $DD0B - - .label CIA2_SDR = $DD0C - .label CIA2_ICR = $DD0D - .label CIA2_CRA = $DD0E - .label CIA2_CRB = $DD0F - - // CIA #2 helper bits - IEC bus + ; CIA #2 helper bits - IEC bus - .const BIT_CIA2_PRA_ATN_OUT = $08 // 1 - low (pulled), 0 - high (released) - .const BIT_CIA2_PRA_CLK_OUT = $10 // 1 - low (pulled), 0 - high (released) - .const BIT_CIA2_PRA_DAT_OUT = $20 // 1 - low (pulled), 0 - high (released) - .const BIT_CIA2_PRA_CLK_IN = $40 // 0 - low (pulled), 1 - high (released) - .const BIT_CIA2_PRA_DAT_IN = $80 // 0 - low (pulled), 1 - high (released) + !set BIT_CIA2_PRA_ATN_OUT = $08 ; 1 - low (pulled), 0 - high (released) + !set BIT_CIA2_PRA_CLK_OUT = $10 ; 1 - low (pulled), 0 - high (released) + !set BIT_CIA2_PRA_DAT_OUT = $20 ; 1 - low (pulled), 0 - high (released) + !set BIT_CIA2_PRA_CLK_IN = $40 ; 0 - low (pulled), 1 - high (released) + !set BIT_CIA2_PRA_DAT_IN = $80 ; 0 - low (pulled), 1 - high (released) -#if CONFIG_MB_MEGA_65 + ; SuperCPU registers - .label C65_EXTKEYS_PR = $D607 - .label C65_EXTKEYS_DDR = $D608 +!ifndef CONFIG_MB_M65 { -#endif + !addr SCPU_SPEED_NORMAL = $D07A + !addr SCPU_SPEED_TURBO = $D07B +} -#if !CONFIG_MB_MEGA_65 - - // SuperCPU registers - - .label SCPU_SPEED_NORMAL = $D07A - .label SCPU_SPEED_TURBO = $D07B - -#endif - - -#endif +} diff --git a/src/aliases/,aliases_hardware_cx16.s b/src/aliases/,aliases_hardware_cx16.s index 79bfbb4a..f803555f 100644 --- a/src/aliases/,aliases_hardware_cx16.s +++ b/src/aliases/,aliases_hardware_cx16.s @@ -1,73 +1,72 @@ -// -// Names of hardware registers -// +; +; Names of hardware registers +; -#if CONFIG_PLATFORM_COMMANDER_X16 +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { - // VERA registers + ; VERA registers - .label __VERA_BASE = $9F20 // base address of the chip + !addr __VERA_BASE = $9F20 ; base address of the chip - .label VERA_ADDR_LO = $9F20 - .label VERA_ADDR_MID = $9F21 - .label VERA_ADDR_HI = $9F22 + !addr VERA_ADDR_LO = $9F20 + !addr VERA_ADDR_MID = $9F21 + !addr VERA_ADDR_HI = $9F22 - .label VERA_DATA0 = $9F23 - .label VERA_DATA1 = $9F24 + !addr VERA_DATA0 = $9F23 + !addr VERA_DATA1 = $9F24 - .label VERA_CTRL = $9F25 + !addr VERA_CTRL = $9F25 - .label VERA_IEN = $9F26 - .label VERA_ISR = $9F27 + !addr VERA_IEN = $9F26 + !addr VERA_ISR = $9F27 - // VIA #1 registers + ; VIA #1 registers - .label __VIA1_BASE = $9F60 // base address of the chip + !addr __VIA1_BASE = $9F60 ; base address of the chip - .label VIA1_PRB = $9F60 - .label VIA1_PRA = $9F61 - .label VIA1_DDRB = $9F62 - .label VIA1_DDRA = $9F63 + !addr VIA1_PRB = $9F60 + !addr VIA1_PRA = $9F61 + !addr VIA1_DDRB = $9F62 + !addr VIA1_DDRA = $9F63 - .label VIA1_T1C_L = $9F64 - .label VIA1_T1C_H = $9F65 - .label VIA1_T1L_L = $9F66 - .label VIA1_T1L_H = $9F67 - .label VIA1_T2C_L = $9F68 - .label VIA1_T2C_H = $9F69 + !addr VIA1_T1C_L = $9F64 + !addr VIA1_T1C_H = $9F65 + !addr VIA1_T1L_L = $9F66 + !addr VIA1_T1L_H = $9F67 + !addr VIA1_T2C_L = $9F68 + !addr VIA1_T2C_H = $9F69 - .label VIA1_SR = $9F6A - .label VIA1_ACR = $9F6B - .label VIA1_PCR = $9F6C - .label VIA1_IFR = $9F6D - .label VIA1_IER = $9F6E + !addr VIA1_SR = $9F6A + !addr VIA1_ACR = $9F6B + !addr VIA1_PCR = $9F6C + !addr VIA1_IFR = $9F6D + !addr VIA1_IER = $9F6E - .label VIA1_PRA_NH = $9F6F + !addr VIA1_PRA_NH = $9F6F - // VIA #2 registers + ; VIA #2 registers - .label __VIA2_BASE = $9F70 // base address of the chip + !addr __VIA2_BASE = $9F70 ; base address of the chip - .label VIA2_PRB = $9F70 - .label VIA2_PRA = $9F71 - .label VIA2_DDRB = $9F72 - .label VIA2_DDRA = $9F73 + !addr VIA2_PRB = $9F70 + !addr VIA2_PRA = $9F71 + !addr VIA2_DDRB = $9F72 + !addr VIA2_DDRA = $9F73 - .label VIA2_T1C_L = $9F74 - .label VIA2_T1C_H = $9F75 - .label VIA2_T1L_L = $9F76 - .label VIA2_T1L_H = $9F77 - .label VIA2_T2C_L = $9F78 - .label VIA2_T2C_H = $9F79 + !addr VIA2_T1C_L = $9F74 + !addr VIA2_T1C_H = $9F75 + !addr VIA2_T1L_L = $9F76 + !addr VIA2_T1L_H = $9F77 + !addr VIA2_T2C_L = $9F78 + !addr VIA2_T2C_H = $9F79 - .label VIA2_SR = $9F7A - .label VIA2_ACR = $9F7B - .label VIA2_PCR = $9F7C - .label VIA2_IFR = $9F7D - .label VIA2_IER = $9F7E + !addr VIA2_SR = $9F7A + !addr VIA2_ACR = $9F7B + !addr VIA2_PCR = $9F7C + !addr VIA2_IFR = $9F7D + !addr VIA2_IER = $9F7E - .label VIA2_PRA_NH = $9F7F - -#endif + !addr VIA2_PRA_NH = $9F7F +} diff --git a/src/aliases/,aliases_hardware_m65.s b/src/aliases/,aliases_hardware_m65.s index 80cc491e..ad72e0e2 100644 --- a/src/aliases/,aliases_hardware_m65.s +++ b/src/aliases/,aliases_hardware_m65.s @@ -1,45 +1,56 @@ -// -// Names of hardware registers -// -// See https://github.com/MEGA65/mega65-core/blob/master/iomap.txt -// +; +; Names of hardware registers +; +; See https://github.com/MEGA65/mega65-core/blob/master/iomap.txt +; -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { - // VIC-IV registers + ; VIC-IV registers - .label VIC_KEY = $D02F - .label VIC_CTRLA = $D030 - .label VIC_CTRLB = $D031 + !addr VIC_KEY = $D02F + !addr VIC_CTRLA = $D030 + !addr VIC_CTRLB = $D031 - .label VIC_XPOS = $D050 + !addr VIC_XPOS = $D050 - .label VIC_CTRLC = $D054 + !addr VIC_CTRLC = $D054 - .label VIC_CHARSTEP = $D058 // 2 bytes - logical characters per line + !addr VIC_CHARSTEP = $D058 ; 2 bytes - logical characters per line - .label VIC_SRH = $D05D // - various flags, bit 7 = hot registers + !addr 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 + !addr VIC_SCRNPTR = $D060 ; 4 bytes - pointer to start of screen memory + !addr VIC_COLPTR = $D064 ; 2 bytes - pointer to start of color memory - .label VIC_CHARPTR = $D068 // 3 bytes - pointer to start of character generator + !addr VIC_CHARPTR = $D068 ; 3 bytes - pointer to start of character generator - // DMAgic + ; Keyboard - .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 + !addr C65_EXTKEYS_PR = $D607 + !addr C65_EXTKEYS_DDR = $D608 - // MISC registers + ; DMAgic - .label MISC_BOARDID = $D629 // board identification byte - .label MISC_EMU = $D710 // to enable badlines and slow interrupts + !addr DMA_ADDRLSBTRIG = $D700 + !addr DMA_ADDRMSB = $D701 + !addr DMA_ADDRBANK = $D702 + !addr DMA_EN018B = $D703 + !addr DMA_ADDRMB = $D704 + !addr DMA_ETRIG = $D705 + !addr DMA_ADDRLSB = $D70E -#endif + ; MISC registers + + !addr MISC_BOARDID = $D629 ; board identification byte + !addr MISC_EMU = $D710 ; to enable badlines and slow interrupts + + ; SID offsets + + !set __SID_R1_OFFSET = $00 ; right SID 1, $D400 + !set __SID_R2_OFFSET = $20 ; right SID 2, $D420 + !set __SID_L1_OFFSET = $40 ; left SID 1, $D440 + !set __SID_L2_OFFSET = $60 ; left SID 2, $D460 +} diff --git a/src/aliases/,aliases_petscii_codes.s b/src/aliases/,aliases_petscii_codes.s index cde7575f..5beb2c43 100644 --- a/src/aliases/,aliases_petscii_codes.s +++ b/src/aliases/,aliases_petscii_codes.s @@ -1,176 +1,191 @@ -// -// PETSCII codes for all the supported keys, for all the keyboards -// -// - [CM64] Compute's Mapping the Commodore 64 -// - [CM128] Compute's Mapping the Commodore 128 -// - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt -// - https://en.wikipedia.org/wiki/PETSCII -// +; +; PETSCII codes for all the supported keys, for all the keyboards +; +; - [CM64] Compute's Mapping the Commodore 64 +; - [CM128] Compute's Mapping the Commodore 128 +; - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt +; - https://en.wikipedia.org/wiki/PETSCII +; -// Not really PETSCII codes, but bitmask values for SHFLAG variable -// [CM64] page 68, [CM128] page 212 +; First determine what to define -.const KEY_FLAG_SHIFT = %00000001 -.const KEY_FLAG_VENDOR = %00000010 -.const KEY_FLAG_CTRL = %00000100 - -#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 -#endif -.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, $04, $06, ($80 ?) - - -.const KEY_NA = $00 // to indicate that no key is presed +!ifdef CONFIG_KEYBOARD_C128 { !set _NEED_EXTENDED = 1 } +!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { !set _NEED_CAPS_LOCK = 1 } +!ifdef CONFIG_KEYBOARD_C65 { !set _NEED_EXTENDED = 1 } +!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { !set _NEED_CAPS_LOCK = 1 } +!ifdef CONFIG_MB_M65 { !set _NEED_EXTENDED = 1 } +!ifdef CONFIG_KEYBOARD_C65 { !set _NEED_C65KB = 1 } +!ifdef CONFIG_MB_M65 { !set _NEED_C65KB = 1 } -// PETSCII codes for our extended screen editor +; Not really PETSCII codes, but bitmask values for SHFLAG variable +; [CM64] page 68, [CM128] page 212 -.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? +!set KEY_FLAG_SHIFT = %00000001 +!set KEY_FLAG_VENDOR = %00000010 +!set KEY_FLAG_CTRL = %00000100 + +!ifdef _NEED_EXTENDED { + !set KEY_FLAG_ALT = %00001000 + !set KEY_FLAG_NO_SCRL = %00100000 +} +!ifdef _NEED_CAPS_LOCK { + !set KEY_CAPS_LOCK = %00010000 +} -// PETSCII codes for certain C128 and C65 functionalities -#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 - -.const KEY_STOP = $03 -.const KEY_RUN = $83 - -.const KEY_F1 = $85 -.const KEY_F2 = $89 -.const KEY_F3 = $86 -.const KEY_F4 = $8A -.const KEY_F5 = $87 -.const KEY_F6 = $8B -.const KEY_F7 = $88 -.const KEY_F8 = $8C - -#if CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65 -.const KEY_F9 = $10 -.const KEY_F10 = $15 -.const KEY_F11 = $16 -.const KEY_F12 = $17 -.const KEY_F13 = $19 -.const KEY_F14 = $1A -#endif - -#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 || ROM_LAYOUT_M65 -.const KEY_HELP = $84 -#endif +; Note - the following PETSCII codes are currently unassigned, can be used for further extensions: $01, $04, $06, ($80 ?) -// PETSCII codes for cursor keys -.const KEY_CRSR_UP = $91 -.const KEY_CRSR_DOWN = $11 -.const KEY_CRSR_LEFT = $9D -.const KEY_CRSR_RIGHT = $1D +!set KEY_NA = $00 ; to indicate that no key is presed -// PETSCII codes for colors +; PETSCII codes for our extended screen editor -.const KEY_RVS_ON = $12 // CTRL+9 -.const KEY_RVS_OFF = $92 // CTRL+0 - -.const KEY_BLACK = $90 // CTRL+1 -.const KEY_WHITE = $05 // CTRL+2 -.const KEY_RED = $1C // CTRL+3 -.const KEY_CYAN = $9F // CTRL+4 -.const KEY_PURPLE = $9C // CTRL+5 -.const KEY_GREEN = $1E // CTRL+6 -.const KEY_BLUE = $1F // CTRL+7 -.const KEY_YELLOW = $9E // CTRL+8 - -.const KEY_ORANGE = $81 // VENDOR+1 -.const KEY_BROWN = $95 // VENDOR+2 -.const KEY_LT_RED = $96 // VENDOR+3 -.const KEY_GREY_1 = $97 // VENDOR+4 -.const KEY_GREY_2 = $98 // VENDOR+5 -.const KEY_LT_GREEN = $99 // VENDOR+6 -.const KEY_LT_BLUE = $9A // VENDOR+7 -.const KEY_GREY_3 = $9B // VENDOR+8 +!set KEY_C64_TAB_FW = $8F ; CTRL+>, TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove? +!set KEY_C64_TAB_BW = $80 ; CTRL+<, SHIFT+TAB - Open ROMs unofficial, original TAB conflicts with C64 PETSCII, XXX remove? -// PETSCII codes for case toggle +; PETSCII codes for certain C128 and C65 functionalities -.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 +!ifdef _NEED_EXTENDED { + !set KEY_BELL = $07 ; no key, originally CTRL+G ; XXX implement, add to C65 keyboard matrix + !set KEY_ESC = $1B +} + +!ifdef _NEED_C65KB { + !set KEY_TAB = $09 ; XXX add to C65 keyboard matrix + !set KEY_LINE_FEED = $0A ; XXX add to C65 keyboard matrix + !set KEY_TAB_SET_CLR = $18 ; XXX add to C65 keyboard matrix + !set KEY_UNDERLINE_ON = $02 ; XXX add to C65 keyboard matrix + !set KEY_UNDERLINE_OFF = $82 ; XXX add to C65 keyboard matrix + !set KEY_FLASHING_ON = $0F ; XXX add to C65 keyboard matrix + !set KEY_FLASHING_OFF = $8F ; XXX add to C65 keyboard matrix +} -// PETSCII codes for other non-printable characters +; PETSCII codes for programmable keys -.const KEY_RETURN = $0D -.const KEY_CLR = $93 -.const KEY_HOME = $13 -.const KEY_INS = $94 -.const KEY_DEL = $14 +!set KEY_STOP = $03 +!set KEY_RUN = $83 + +!set KEY_F1 = $85 +!set KEY_F2 = $89 +!set KEY_F3 = $86 +!set KEY_F4 = $8A +!set KEY_F5 = $87 +!set KEY_F6 = $8B +!set KEY_F7 = $88 +!set KEY_F8 = $8C + +!ifdef _NEED_C65KB { + !set KEY_F9 = $10 + !set KEY_F10 = $15 + !set KEY_F11 = $16 + !set KEY_F12 = $17 + !set KEY_F13 = $19 + !set KEY_F14 = $1A +} + +!ifdef _NEED_EXTENDED { + !set KEY_HELP = $84 +} -// PETSCII codes for printable characters +; PETSCII codes for cursor keys -.const KEY_SPACE = $20 -.const KEY_EXCLAMATION = $21 -.const KEY_QUOTE = $22 -.const KEY_HASH = $23 -.const KEY_DOLLAR = $24 -.const KEY_PERCENT = $25 -.const KEY_AMPERSAND = $26 -.const KEY_APOSTROPHE = $27 -.const KEY_R_BRACKET_L = $28 -.const KEY_R_BRACKET_R = $29 -.const KEY_ASTERISK = $2A -.const KEY_PLUS = $2B -.const KEY_COMA = $2C -.const KEY_MINUS = $2D -.const KEY_FULLSTOP = $2E -.const KEY_SLASH = $2F - -.const KEY_0 = $30 -.const KEY_1 = $31 -.const KEY_2 = $32 -.const KEY_3 = $33 -.const KEY_4 = $34 -.const KEY_5 = $35 -.const KEY_6 = $36 -.const KEY_7 = $37 -.const KEY_8 = $38 -.const KEY_9 = $39 -.const KEY_COLON = $3A -.const KEY_SEMICOLON = $3B -.const KEY_LT = $3C -.const KEY_EQ = $3D -.const KEY_GT = $3E -.const KEY_QUESTION = $3F +!set KEY_CRSR_UP = $91 +!set KEY_CRSR_DOWN = $11 +!set KEY_CRSR_LEFT = $9D +!set KEY_CRSR_RIGHT = $1D -// XXX finish this: $4x, $5x, $6x, $7x, $Ax, $Bx, $Cx, $Dx, $Ex, $Fx +; PETSCII codes for colors + +!set KEY_RVS_ON = $12 ; CTRL+9 +!set KEY_RVS_OFF = $92 ; CTRL+0 + +!set KEY_BLACK = $90 ; CTRL+1 +!set KEY_WHITE = $05 ; CTRL+2 +!set KEY_RED = $1C ; CTRL+3 +!set KEY_CYAN = $9F ; CTRL+4 +!set KEY_PURPLE = $9C ; CTRL+5 +!set KEY_GREEN = $1E ; CTRL+6 +!set KEY_BLUE = $1F ; CTRL+7 +!set KEY_YELLOW = $9E ; CTRL+8 + +!set KEY_ORANGE = $81 ; VENDOR+1 +!set KEY_BROWN = $95 ; VENDOR+2 +!set KEY_LT_RED = $96 ; VENDOR+3 +!set KEY_GREY_1 = $97 ; VENDOR+4 +!set KEY_GREY_2 = $98 ; VENDOR+5 +!set KEY_LT_GREEN = $99 ; VENDOR+6 +!set KEY_LT_BLUE = $9A ; VENDOR+7 +!set KEY_GREY_3 = $9B ; VENDOR+8 + + +; PETSCII codes for case toggle + +!set KEY_C64_SHIFT_ON = $09 ; no key +!set KEY_C64_SHIFT_OFF = $08 ; no key +!ifdef _NEED_C65KB { + !set KEY_C65_SHIFT_OFF = $0B ; no key + !set KEY_C65_SHIFT_ON = $0C ; no key +} +!set KEY_TXT = $0E ; no key +!set KEY_GFX = $8E ; no key + + +; PETSCII codes for other non-printable characters + +!set KEY_RETURN = $0D +!set KEY_CLR = $93 +!set KEY_HOME = $13 +!set KEY_INS = $94 +!set KEY_DEL = $14 + + +; PETSCII codes for printable characters + +!set KEY_SPACE = $20 +!set KEY_EXCLAMATION = $21 +!set KEY_QUOTE = $22 +!set KEY_HASH = $23 +!set KEY_DOLLAR = $24 +!set KEY_PERCENT = $25 +!set KEY_AMPERSAND = $26 +!set KEY_APOSTROPHE = $27 +!set KEY_R_BRACKET_L = $28 +!set KEY_R_BRACKET_R = $29 +!set KEY_ASTERISK = $2A +!set KEY_PLUS = $2B +!set KEY_COMA = $2C +!set KEY_MINUS = $2D +!set KEY_FULLSTOP = $2E +!set KEY_SLASH = $2F + +!set KEY_0 = $30 +!set KEY_1 = $31 +!set KEY_2 = $32 +!set KEY_3 = $33 +!set KEY_4 = $34 +!set KEY_5 = $35 +!set KEY_6 = $36 +!set KEY_7 = $37 +!set KEY_8 = $38 +!set KEY_9 = $39 +!set KEY_COLON = $3A +!set KEY_SEMICOLON = $3B +!set KEY_LT = $3C +!set KEY_EQ = $3D +!set KEY_GT = $3E +!set KEY_QUESTION = $3F + + +; XXX finish this: $4x, $5x, $6x, $7x, $Ax, $Bx, $Cx, $Dx, $Ex, $Fx diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index 09f1a861..50f8edec 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -1,329 +1,326 @@ -// -// Names of ZP and low memory locations: -// - Computes Mapping the Commodore 64 -// - https://www.c64-wiki.com/wiki/Zeropage -// - http://unusedino.de/ec64/technical/project64/memory_maps.html -// +; +; Names of ZP and low memory locations: +; - Computes Mapping the Commodore 64 +; - https://www.c64-wiki.com/wiki/Zeropage +; - http://unusedino.de/ec64/technical/project64/memory_maps.html +; - // $00-$01 - 6502 CPU registers are here + ; $00-$01 - 6502 CPU registers are here - // - // Page 0 - BASIC area ($02-$8F) - // + ; + ; Page 0 - BASIC area ($02-$8F) + ; - // $02 -- UNUSED -- free for user software - .label ADRAY1 = $03 // $03-$04 - .label ADRAY2 = $05 // $05-$06 - .label CHARAC = $07 // [!] our implementation might be different XXX give more details - .label ENDCHR = $08 // [!] our implementation might be different XXX give more details - .label TRMPOS = $09 // -- NOT IMPLEMENTED -- - .label VERCKB = $0A // flag used by BASIC, 0 - LOAD, 1 - VERIFY - .label COUNT = $0B // [!] our implementation might be different XXX give more details - .label DIMFLG = $0C // [!] our implementation might be different XXX give more details - .label VALTYP = $0D // expression eveluation result; $00 - float, $FF - string - .label INTFLG = $0E // -- NOT IMPLEMENTED -- - .label GARBFL = $0F // [!] our implementation might be different XXX give more details - .label SUBFLG = $10 // -- NOT IMPLEMENTED -- - .label INPFLG = $11 // -- NOT IMPLEMENTED -- - .label TANSGN = $12 // -- NOT IMPLEMENTED -- - .label CHANNL = $13 // -- NOT IMPLEMENTED -- - .label LINNUM = $14 // $14-$15 BASIC line number, [!] also used by DOS Wedge - .label TEMPPT = $16 // pointer to the first available slot in the temporary string descriptor stack - .label LASTPT = $17 // $17-$18 pointer to the last used slot in the temporary string descriptor - .label TEMPST = $19 // $19-$21 temporary string stack descriptors - .label INDEX = $22 // $22-$25 temporary variables, [!] our usage might be different - .label RESHO = $26 // $26-$2A temporary variables, [!] our usage might be different - .label TXTTAB = $2B // $2B-$2C start of BASIC code - .label VARTAB = $2D // $2D-$2E end of BASIC code, start of variables - .label ARYTAB = $2F // $2F-$30 pointer to start of array storage - .label STREND = $31 // $31-$32 pointer to start of free RAM - .label FRETOP = $33 // $33-$34 pointer to bottom of strings area - .label FRESPC = $35 // $35-$36 [!] our implementation uses this as temporary string pointer - .label MEMSIZ = $37 // $37-$38 highest address of BASIC memory + 1 - .label CURLIN = $39 // $39-$3A current BASIC line number - .label OLDLIN = $3B // $3B-$3C previous BASIC line number - .label OLDTXT = $3D // $3D-$3E current BASIC line pointer - .label DATLIN = $3F // $3F-$40 -- NOT IMPLEMENTED -- - .label DATPTR = $41 // $41-$42 pointer for READ/DATA copmmands - .label INPPTR = $43 // $43-$44 -- NOT IMPLEMENTED -- - .label VARNAM = $45 // $45-$46 current variable name - .label VARPNT = $47 // $47-$48 current variable/descriptor pointer - .label FORPNT = $49 // $49-$4A -- NOT IMPLEMENTED -- - .label OPPTR = $4B // $4B-$4C helper variable for expression computation, [!] our usage details are different - .label OPMASK = $4D // -- NOT IMPLEMENTED -- - .label DEFPNT = $4E // $4E-$4F -- NOT IMPLEMENTED -- - .label DSCPNT = $50 // $50-$52 temporary area fro string handling, [!] our usage might differ - .label FOUR6 = $53 // size of variable content (float = 5, integer = 2, string descriptor = 3) - .label JMPER = $54 // $54-$56 -- NOT IMPLEMENTED -- - .label TEMPF1 = $57 // $57-$5B BASIC numeric work area - .label TEMPF2 = $5C // $5C-$60 BASIC numeric work area + ; $02 -- UNUSED -- free for user software + !addr ADRAY1 = $03 ; $03-$04 + !addr ADRAY2 = $05 ; $05-$06 + !addr CHARAC = $07 ; [!] our implementation might be different XXX give more details + !addr ENDCHR = $08 ; [!] our implementation might be different XXX give more details + !addr TRMPOS = $09 ; -- NOT IMPLEMENTED -- + !addr VERCKB = $0A ; flag used by BASIC, 0 - LOAD, 1 - VERIFY + !addr COUNT = $0B ; [!] our implementation might be different XXX give more details + !addr DIMFLG = $0C ; [!] our implementation might be different XXX give more details + !addr VALTYP = $0D ; expression eveluation result; $00 - float, $FF - string + !addr INTFLG = $0E ; -- NOT IMPLEMENTED -- + !addr GARBFL = $0F ; [!] our implementation might be different XXX give more details + !addr SUBFLG = $10 ; -- NOT IMPLEMENTED -- + !addr INPFLG = $11 ; -- NOT IMPLEMENTED -- + !addr TANSGN = $12 ; -- NOT IMPLEMENTED -- + !addr CHANNL = $13 ; -- NOT IMPLEMENTED -- + !addr LINNUM = $14 ; $14-$15 BASIC line number, [!] also used by DOS Wedge + !addr TEMPPT = $16 ; pointer to the first available slot in the temporary string descriptor stack + !addr LASTPT = $17 ; $17-$18 pointer to the last used slot in the temporary string descriptor + !addr TEMPST = $19 ; $19-$21 temporary string stack descriptors + !addr INDEX = $22 ; $22-$25 temporary variables, [!] our usage might be different + !addr RESHO = $26 ; $26-$2A temporary variables, [!] our usage might be different + !addr TXTTAB = $2B ; $2B-$2C start of BASIC code + !addr VARTAB = $2D ; $2D-$2E end of BASIC code, start of variables + !addr ARYTAB = $2F ; $2F-$30 pointer to start of array storage + !addr STREND = $31 ; $31-$32 pointer to start of free RAM + !addr FRETOP = $33 ; $33-$34 pointer to bottom of strings area + !addr FRESPC = $35 ; $35-$36 [!] our implementation uses this as temporary string pointer + !addr MEMSIZ = $37 ; $37-$38 highest address of BASIC memory + 1 + !addr CURLIN = $39 ; $39-$3A current BASIC line number + !addr OLDLIN = $3B ; $3B-$3C previous BASIC line number + !addr OLDTXT = $3D ; $3D-$3E current BASIC line pointer + !addr DATLIN = $3F ; $3F-$40 -- NOT IMPLEMENTED -- + !addr DATPTR = $41 ; $41-$42 pointer for READ/DATA copmmands + !addr INPPTR = $43 ; $43-$44 -- NOT IMPLEMENTED -- + !addr VARNAM = $45 ; $45-$46 current variable name + !addr VARPNT = $47 ; $47-$48 current variable/descriptor pointer + !addr FORPNT = $49 ; $49-$4A -- NOT IMPLEMENTED -- + !addr OPPTR = $4B ; $4B-$4C helper variable for expression computation, [!] our usage details are different + !addr OPMASK = $4D ; -- NOT IMPLEMENTED -- + !addr DEFPNT = $4E ; $4E-$4F -- NOT IMPLEMENTED -- + !addr DSCPNT = $50 ; $50-$52 temporary area fro string handling, [!] our usage might differ + !addr FOUR6 = $53 ; size of variable content (float = 5, integer = 2, string descriptor = 3) + !addr JMPER = $54 ; $54-$56 -- NOT IMPLEMENTED -- + !addr TEMPF1 = $57 ; $57-$5B BASIC numeric work area + !addr TEMPF2 = $5C ; $5C-$60 BASIC numeric work area - .label __FAC1 = $61 // $61-$66 floating point accumulator 1 - .label FAC1_exponent = $61 - .label FAC1_mantissa = $62 // $62 - $65 - .label FAC1_sign = $66 + !addr __FAC1 = $61 ; $61-$66 floating point accumulator 1 + !addr FAC1_exponent = $61 + !addr FAC1_mantissa = $62 ; $62 - $65 + !addr FAC1_sign = $66 - .label SGNFLG = $67 // -- NOT IMPLEMENTED -- - .label BITS = $68 // FAC1 overflow + !addr SGNFLG = $67 ; -- NOT IMPLEMENTED -- + !addr BITS = $68 ; FAC1 overflow - .label __FAC2 = $69 // $69-$6E floating point accumulator 2 [!] also used for memory move pointers - .label FAC2_exponent = $69 - .label FAC2_mantissa = $6A // $6A - $6D - .label FAC2_sign = $6E + !addr __FAC2 = $69 ; $69-$6E floating point accumulator 2 [!] also used for memory move pointers + !addr FAC2_exponent = $69 + !addr FAC2_mantissa = $6A ; $6A - $6D + !addr FAC2_sign = $6E - .label ARISGN = $6F // -- NOT IMPLEMENTED -- - .label FACOV = $70 // FAC1 low order mantissa - .label FBUFPT = $71 // $71-$72 -- NOT IMPLEMENTED -- - .label CHRGET = $73 // $73-$8A -- NOT IMPLEMENTED -- - .label TXTPTR = $7A // $7A-$7B current BASIC statement pointer - .label RNDX = $8B // $8B-$8F random number seed + !addr ARISGN = $6F ; -- NOT IMPLEMENTED -- + !addr FACOV = $70 ; FAC1 low order mantissa + !addr FBUFPT = $71 ; $71-$72 -- NOT IMPLEMENTED -- + !addr CHRGET = $73 ; $73-$8A -- NOT IMPLEMENTED -- + !addr TXTPTR = $7A ; $7A-$7B current BASIC statement pointer + !addr RNDX = $8B ; $8B-$8F random number seed - // - // Page 0 - Kernal area ($90-$FF) - // + ; + ; Page 0 - Kernal area ($90-$FF) + ; - .label IOSTATUS = $90 - .label STKEY = $91 // keys down clears bits. STOP - bit 7, C= - bit 6, SPACE - bit 4, CTRL - bit 2 - .label SVXT = $92 // tape reading constant [!] our tape routines use it differently - .label VERCKK = $93 // 0 = LOAD, 1 = VERIFY - .label C3PO = $94 // flag - is BSOUR content valid - .label BSOUR = $95 // serial bus buffered output byte - .label SYNO = $96 // temporary tape routines storage, [!] our usage differs - .label XSAV = $97 // temporary register storage for ASCII/tape related routines [!] usage details might differ - .label LDTND = $98 // number of entries in LAT / FAT / SAT tables - .label DFLTN = $99 // default input device - .label DFLTO = $9A // default output device - .label PRTY = $9B // tape storage for parity/checksum -#if !CONFIG_TAPE_NORMAL && !CONFIG_TAPE_TURBO - .label DPSW = $9C // -- NOT IMPLEMENTED -- -#else - .label COLSTORE = $9C // [!] screen border storage for tape routines -#endif - .label MSGFLG = $9D // bit 6 = error messages, bit 7 = control message - .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 - .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 -- - .label INBIT = $A7 // temporary storage for tape / RS-232 received bits -#if !CONFIG_LEGACY_SCNKEY - .label BITCI = $A8 // -- NOT IMPLEMENTED -- - .label RINONE = $A9 // -- WIP -- (UP9600 only) RS-232 check for start bit flag - .label RIDDATA = $AA // -- NOT IMPLEMENTED -- - .label RIPRTY = $AB // -- WIP -- checksum while reading tape -#endif - .label SAL = $AC // $AC-$AD -- XXX: describe -- (implemented screen part) - .label EAL = $AE // $AE-$AF -- XXX: describe -- [!] used also by screen editor, for temporary color storage when scrolling - .label CMP0 = $B0 // $B0-$B1 temporary tape storage, [!] here used for BRK instruction address - .label TAPE1 = $B2 // $B2-$B3 tape buffer pointer -#if !CONFIG_LEGACY_SCNKEY - .label BITTS = $B4 // -- NOT IMPLEMENTED -- -#endif - .label NXTBIT = $B5 // -- NOT IMPLEMENTED -- -#if !CONFIG_LEGACY_SCNKEY - .label RODATA = $B6 // -- NOT IMPLEMENTED -- -#endif + !addr IOSTATUS = $90 + !addr STKEY = $91 ; keys down clears bits. STOP - bit 7, C= - bit 6, SPACE - bit 4, CTRL - bit 2 + !addr SVXT = $92 ; tape reading constant [!] our tape routines use it differently + !addr VERCKK = $93 ; 0 = LOAD, 1 = VERIFY + !addr C3PO = $94 ; flag - is BSOUR content valid + !addr BSOUR = $95 ; serial bus buffered output byte + !addr SYNO = $96 ; temporary tape routines storage, [!] our usage differs + !addr XSAV = $97 ; temporary register storage for ASCII/tape related routines [!] usage details might differ + !addr LDTND = $98 ; number of entries in LAT / FAT / SAT tables + !addr DFLTN = $99 ; default input device + !addr DFLTO = $9A ; default output device + !addr PRTY = $9B ; tape storage for parity/checksum +!ifndef HAS_TAPE { + !addr DPSW = $9C ; -- NOT IMPLEMENTED -- +} else { + !addr COLSTORE = $9C ; [!] screen border storage for tape routines +} + !addr MSGFLG = $9D ; bit 6 = error messages, bit 7 = control message + !addr PTR1 = $9E ; for tape support, counter of errorneous bytes + !addr PTR2 = $9F ; for tape support, counter for errorneous bytes correction + !addr TIME = $A0 ; $A0-$A2 jiffy clock + !addr IECPROTO = $A3 ; [!] IEC or pseudo-IEC protocol, >= $80 for unknown; originally named TSFCNT + !addr TBTCNT = $A4 ; temporary variable for tape and IEC, [!] our usage probably differs in details + !addr CNTDN = $A5 ; -- NOT IMPLEMENTED -- + !addr BUFPNT = $A6 ; -- NOT IMPLEMENTED -- + !addr INBIT = $A7 ; temporary storage for tape / RS-232 received bits +!ifndef CONFIG_LEGACY_SCNKEY { + !addr BITCI = $A8 ; -- NOT IMPLEMENTED -- + !addr RINONE = $A9 ; -- WIP -- (UP9600 only) RS-232 check for start bit flag + !addr RIDDATA = $AA ; -- NOT IMPLEMENTED -- + !addr RIPRTY = $AB ; -- WIP -- checksum while reading tape +} + !addr SAL = $AC ; $AC-$AD -- XXX: describe -- (implemented screen part) + !addr EAL = $AE ; $AE-$AF -- XXX: describe -- [!] used also by screen editor, for temporary color storage when scrolling + !addr CMP0 = $B0 ; $B0-$B1 temporary tape storage, [!] here used for BRK instruction address + !addr TAPE1 = $B2 ; $B2-$B3 tape buffer pointer +!ifndef CONFIG_LEGACY_SCNKEY { + !addr BITTS = $B4 ; -- NOT IMPLEMENTED -- +} + !addr NXTBIT = $B5 ; -- NOT IMPLEMENTED -- +!ifndef CONFIG_LEGACY_SCNKEY { + !addr RODATA = $B6 ; -- NOT IMPLEMENTED -- +} + !addr FNLEN = $B7 ; current file name length + !addr LA = $B8 ; current logical_file number + !addr SA = $B9 ; current secondary address + !addr FA = $BA ; current device number + !addr FNADDR = $BB ; $BB-$BC current file name pointer + !addr ROPRTY = $BD ; -- NOT IMPLEMENTED -- tape / RS-232 temporary storage + !addr FSBLK = $BE ; -- NOT IMPLEMENTED -- tape / RS-232 temporary storage + !addr MYCH = $BF ; -- NOT IMPLEMENTED -- + !addr CAS1 = $C0 ; tape motor interlock + !addr STAL = $C1 ; $C1-$C2 LOAD/SAVE start address + !addr MEMUSS = $C3 ; $C3-$C4 temporary address for tape LOAD/SAVE + !addr LSTX = $C5 ; last key matrix position [!] our usage probably differs in details + !addr NDX = $C6 ; number of chars in keyboard buffer + !addr RVS = $C7 ; flag, whether to print reversed characters + !addr INDX = $C8 ; end of logical line (column, 0-79) + !addr LSXP = $C9 ; $C9-$CA start of input, X/Y position (typo in Mapping the C64, fixed in Mapping the C128) + !addr SFDX = $CB ; -- NOT IMPLEMENTED -- + !addr BLNSW = $CC ; cursor blink disable flag + !addr BLNCT = $CD ; cursor blink countdown + !addr GDBLN = $CE ; cursor saved character + !addr BLNON = $CF ; cursor visibility flag + !addr CRSW = $D0 ; whether to input from screen or keyboard (if from screen, stores input offset) + !addr PNT = $D1 ; $D1-$D2 pointer to the current screen line + !addr PNTR = $D3 ; current screen X position (logical column), 0-79 + !addr QTSW = $D4 ; quote mode flag + !addr LNMX = $D5 ; logical line length, 39 or 79 + !addr TBLX = $D6 ; current screen Y position (row), 0-24 + !addr SCHAR = $D7 ; ASCII value of the last printed character + !addr INSRT = $D8 ; insert mode flag/counter + !addr LDTB1 = $D9 ; $D9-$F2 screen line link table, [!] our usage is different XXX give more details + !addr USER = $F3 ; $F3-$F4 pointer to current color RAM location + !addr KEYTAB = $F5 ; $F5-$F6 pointer to keyboard lookup table + !addr RIBUF = $F7 ; $F7-$F8 -- WIP -- RS-232 receive buffer pointer + !addr ROBUF = $F9 ; $F9-$FA -- WIP -- RS-232 send buffer pointer + ; $FB $FB-$FE -- UNUSED -- free for user software + !addr BASZPT = $FF ; -- NOT IMPLEMENTED -- - .label FNLEN = $B7 // current file name length - .label LA = $B8 // current logical_file number - .label SA = $B9 // current secondary address - .label FA = $BA // current device number - .label FNADDR = $BB // $BB-$BC current file name pointer - .label ROPRTY = $BD // -- NOT IMPLEMENTED -- tape / RS-232 temporary storage - .label FSBLK = $BE // -- NOT IMPLEMENTED -- tape / RS-232 temporary storage - .label MYCH = $BF // -- NOT IMPLEMENTED -- - .label CAS1 = $C0 // tape motor interlock - .label STAL = $C1 // $C1-$C2 LOAD/SAVE start address - .label MEMUSS = $C3 // $C3-$C4 temporary address for tape LOAD/SAVE - .label LSTX = $C5 // last key matrix position [!] our usage probably differs in details - .label NDX = $C6 // number of chars in keyboard buffer - .label RVS = $C7 // flag, whether to print reversed characters - .label INDX = $C8 // end of logical line (column, 0-79) - .label LSXP = $C9 // $C9-$CA start of input, X/Y position (typo in Mapping the C64, fixed in Mapping the C128) - .label SFDX = $CB // -- NOT IMPLEMENTED -- - .label BLNSW = $CC // cursor blink disable flag - .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 (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 - .label LNMX = $D5 // logical line length, 39 or 79 - .label TBLX = $D6 // current screen Y position (row), 0-24 - .label SCHAR = $D7 // ASCII value of the last printed character - .label INSRT = $D8 // insert mode flag/counter - .label LDTB1 = $D9 // $D9-$F2 screen line link table, [!] our usage is different XXX give more details - .label USER = $F3 // $F3-$F4 pointer to current color RAM location - .label KEYTAB = $F5 // $F5-$F6 pointer to keyboard lookup table - .label RIBUF = $F7 // $F7-$F8 -- WIP -- RS-232 receive buffer pointer - .label ROBUF = $F9 // $F9-$FA -- WIP -- RS-232 send buffer pointer - // $FB $FB-$FE -- UNUSED -- free for user software - .label BASZPT = $FF // -- NOT IMPLEMENTED -- + ; + ; Page 1 + ; - // - // Page 1 - // + !addr STACK = $100 ; $100-$1FF, processor stack - .label STACK = $100 // $100-$1FF, processor stack - - // - // Pages 2 & 3 - // + ; + ; Pages 2 & 3 + ; - .label BUF = $200 // $200-$250, BASIC line editor input buffer (81 bytes) + !addr BUF = $200 ; $200-$250, BASIC line editor input buffer (81 bytes) - // $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20 - // and not used on C64 - they are used if CONFIG_LEGACY_SCNKEY is enabled. + ; $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20 + ; and not used on C64 - they are used if CONFIG_LEGACY_SCNKEY is enabled. - // [!] XXX document $251-$258 usage - .label LAT = $259 // $259-$262, logical file numbers (table, 10 bytes) - .label FAT = $263 // $263-$26C, device numbers (table, 10 bytes) - .label SAT = $26D // $26D-$276, secondary addresses (table, 10 bytes) - .label KEYD = $277 // $277-$280, keyboard buffer - .label MEMSTR = $281 // $281-$282, start of BASIC memory - .label MEMSIZK = $283 // $283-$284, NOTE: Mapping the 64 erroneously has the hex as $282 (DEC is correct) - .label TIMOUT = $285 // IEEE-488 timeout - .label COLOR = $286 // current text foreground color - .label GDCOL = $287 // color of character under cursor - .label HIBASE = $288 // high byte of start of screen - .label XMAX = $289 // max keyboard buffer size - .label RPTFLG = $28A // whether to repeat keys (highest bit set = repeat) - .label KOUNT = $28B // key repeat counter - .label DELAY = $28C // -- NOT IMPLEMENTED -- - .label SHFLAG = $28D // bucky keys (SHIFT/CTRL/C=) flags - .label LSTSHF = $28E // last bucky key flags - .label KEYLOG = $28F // $28F-$290 routine to setup keyboard decoding - .label MODE = $291 // flag, is case switch allowed - .label AUTODN = $292 // -- NOT IMPLEMENTED -- screen scroll disable -#if !CONFIG_LEGACY_SCNKEY - .label M51CRT = $293 // -- NOT IMPLEMENTED -- mock 6551 - .label M51CDR = $294 // -- NOT IMPLEMENTED -- mock 6551 - .label M51AJB = $295 // $295-$296 -- NOT IMPLEMENTED -- mock 6551 - .label RSSTAT = $297 // -- WIP -- (UP9600 only) mock 6551, RS-232 status - .label BITNUM = $298 // -- NOT IMPLEMENTED -- - .label BAUDOF = $299 // $299-$29A -- NOT IMPLEMENTED -- -#endif - .label RIDBE = $29B // -- WIP -- write pointer into RS-232 receive buffer - .label RIDBS = $29C // -- WIP -- read pointer into RS-232 receive buffer - .label RODBS = $29D // -- WIP -- read pointer into RS-232 send buffer - .label RODBE = $29E // -- WIP -- write pointer into RS-232 send buffer - .label IRQTMP = $29F // $29F-$2A0 temporary IRQ vector storage [!] we use it for tape speed calibration instead - .label ENABL = $2A1 // -- NOT IMPLEMENTED -- - .label TODSNS = $2A2 // -- NOT IMPLEMENTED -- - .label TRDTMP = $2A3 // -- NOT IMPLEMENTED -- - .label TD1IRQ = $2A4 // -- NOT IMPLEMENTED -- - .label TLNIDX = $2A5 // -- NOT IMPLEMENTED -- - .label TVSFLG = $2A6 // 0 = NTSC, 1 = PAL + ; [!] XXX document $251-$258 usage + !addr LAT = $259 ; $259-$262, logical file numbers (table, 10 bytes) + !addr FAT = $263 ; $263-$26C, device numbers (table, 10 bytes) + !addr SAT = $26D ; $26D-$276, secondary addresses (table, 10 bytes) + !addr KEYD = $277 ; $277-$280, keyboard buffer + !addr MEMSTR = $281 ; $281-$282, start of BASIC memory + !addr MEMSIZK = $283 ; $283-$284, NOTE: Mapping the 64 erroneously has the hex as $282 (DEC is correct) + !addr TIMOUT = $285 ; IEEE-488 timeout + !addr COLOR = $286 ; current text foreground color + !addr GDCOL = $287 ; color of character under cursor + !addr HIBASE = $288 ; high byte of start of screen + !addr XMAX = $289 ; max keyboard buffer size + !addr RPTFLG = $28A ; whether to repeat keys (highest bit set = repeat) + !addr KOUNT = $28B ; key repeat counter + !addr DELAY = $28C ; -- NOT IMPLEMENTED -- + !addr SHFLAG = $28D ; bucky keys (SHIFT/CTRL/C=) flags + !addr LSTSHF = $28E ; last bucky key flags + !addr KEYLOG = $28F ; $28F-$290 routine to setup keyboard decoding + !addr MODE = $291 ; flag, is case switch allowed + !addr AUTODN = $292 ; -- NOT IMPLEMENTED -- screen scroll disable +!ifndef CONFIG_LEGACY_SCNKEY { + !addr M51CRT = $293 ; -- NOT IMPLEMENTED -- mock 6551 + !addr M51CDR = $294 ; -- NOT IMPLEMENTED -- mock 6551 + !addr M51AJB = $295 ; $295-$296 -- NOT IMPLEMENTED -- mock 6551 + !addr RSSTAT = $297 ; -- WIP -- (UP9600 only) mock 6551, RS-232 status + !addr BITNUM = $298 ; -- NOT IMPLEMENTED -- + !addr BAUDOF = $299 ; $299-$29A -- NOT IMPLEMENTED -- +} + !addr RIDBE = $29B ; -- WIP -- write pointer into RS-232 receive buffer + !addr RIDBS = $29C ; -- WIP -- read pointer into RS-232 receive buffer + !addr RODBS = $29D ; -- WIP -- read pointer into RS-232 send buffer + !addr RODBE = $29E ; -- WIP -- write pointer into RS-232 send buffer + !addr IRQTMP = $29F ; $29F-$2A0 temporary IRQ vector storage [!] we use it for tape speed calibration instead + !addr ENABL = $2A1 ; -- NOT IMPLEMENTED -- + !addr TODSNS = $2A2 ; -- NOT IMPLEMENTED -- + !addr TRDTMP = $2A3 ; -- NOT IMPLEMENTED -- + !addr TD1IRQ = $2A4 ; -- NOT IMPLEMENTED -- + !addr TLNIDX = $2A5 ; -- NOT IMPLEMENTED -- + !addr TVSFLG = $2A6 ; 0 = NTSC, 1 = PAL - // [!] $2A7-$2FF is normally free, but in our case some extra functionality uses it + ; [!] $2A7-$2FF is normally free, but in our case some extra functionality uses it -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // IRQs are disabled when doing such accesses, and a default NMI handler only increments - // a counter, so that if an NMI occurs, it does not crash the machine, but can be captured. + ; IRQs are disabled when doing such accesses, and a default NMI handler only increments + ; a counter, so that if an NMI occurs, it does not crash the machine, but can be captured. - .label missed_nmi_flag = $2A7 - .label tiny_nmi_handler = $2A8 - .label peek_under_roms = tiny_nmi_handler + peek_under_roms_routine - tiny_nmi_handler_routine - .label poke_under_roms = tiny_nmi_handler + poke_under_roms_routine - tiny_nmi_handler_routine - .label memmap_allram = tiny_nmi_handler + memmap_allram_routine - tiny_nmi_handler_routine - .label memmap_normal = tiny_nmi_handler + memmap_normal_routine - tiny_nmi_handler_routine -#if SEGMENT_BASIC - .label shift_mem_up_internal = tiny_nmi_handler + shift_mem_up_routine - tiny_nmi_handler_routine - .label shift_mem_down_internal = tiny_nmi_handler + shift_mem_down_routine - tiny_nmi_handler_routine -#endif + !addr missed_nmi_flag = $2A7 + !addr tiny_nmi_handler = $2A8 + !addr peek_under_roms = tiny_nmi_handler + peek_under_roms_routine - tiny_nmi_handler_routine + !addr poke_under_roms = tiny_nmi_handler + poke_under_roms_routine - tiny_nmi_handler_routine + !addr memmap_allram = tiny_nmi_handler + memmap_allram_routine - tiny_nmi_handler_routine + !addr memmap_normal = tiny_nmi_handler + memmap_normal_routine - tiny_nmi_handler_routine +!ifdef SEGMENT_BASIC { + !addr shift_mem_up_internal = tiny_nmi_handler + shift_mem_up_routine - tiny_nmi_handler_routine + !addr shift_mem_down_internal = tiny_nmi_handler + shift_mem_down_routine - tiny_nmi_handler_routine +} -#endif // CONFIG_MEMORY_MODEL_60K +} ; CONFIG_MEMORY_MODEL_60K - // BASIC vectors - .label IERROR = $300 // $300-$301 - .label IMAIN = $302 // $302-$303 - .label ICRNCH = $304 // $304-$305 - .label IQPLOP = $306 // $306-$307 - .label IGONE = $308 // $308-$309 - .label IEVAL = $30A // $30A-$30B + ; BASIC vectors + !addr IERROR = $300 ; $300-$301 + !addr IMAIN = $302 ; $302-$303 + !addr ICRNCH = $304 ; $304-$305 + !addr IQPLOP = $306 ; $306-$307 + !addr IGONE = $308 ; $308-$309 + !addr IEVAL = $30A ; $30A-$30B - .label SAREG = $30C // .A storage, for SYS call - .label SXREG = $30D // .X storage, for SYS call - .label SYREG = $30E // .Y storage, for SYS call - .label SPREG = $30F // .P storage, for SYS call + !addr SAREG = $30C ; .A storage, for SYS call + !addr SXREG = $30D ; .X storage, for SYS call + !addr SYREG = $30E ; .Y storage, for SYS call + !addr SPREG = $30F ; .P storage, for SYS call - .label USRPOK = $310 // -- NOT IMPLEMENTED -- JMP instruction - .label USRADD = $311 // $311-$312 -- NOT IMPLEMENTED -- - // $313 -- UNUSED -- free for user software + !addr USRPOK = $310 ; -- NOT IMPLEMENTED -- JMP instruction + !addr USRADD = $311 ; $311-$312 -- NOT IMPLEMENTED -- + ; $313 -- UNUSED -- free for user software - // Kernal vectors - interrupts - .label CINV = $314 // $314-$315 - .label CBINV = $316 // $316-$317 - .label NMINV = $318 // $318-$319 + ; Kernal vectors - interrupts + !addr CINV = $314 ; $314-$315 + !addr CBINV = $316 ; $316-$317 + !addr NMINV = $318 ; $318-$319 - // Kernal vectors - routines - .label IOPEN = $31A // $31A-$31B - .label ICLOSE = $31C // $31C-$31D - .label ICHKIN = $31E // $31E-$31F - .label ICKOUT = $320 // $320-$321 - .label ICLRCH = $322 // $322-$323 - .label IBASIN = $324 // $324-$325 - .label IBSOUT = $326 // $326-$327 - .label ISTOP = $328 // $328-$329 - .label IGETIN = $32A // $32A-$32B - .label ICLALL = $32C // $32C-$32D - .label USRCMD = $32E // $32E-$32F - .label ILOAD = $330 // $330-$331 - .label ISAVE = $332 // $332-$333 + ; Kernal vectors - routines + !addr IOPEN = $31A ; $31A-$31B + !addr ICLOSE = $31C ; $31C-$31D + !addr ICHKIN = $31E ; $31E-$31F + !addr ICKOUT = $320 ; $320-$321 + !addr ICLRCH = $322 ; $322-$323 + !addr IBASIN = $324 ; $324-$325 + !addr IBSOUT = $326 ; $326-$327 + !addr ISTOP = $328 ; $328-$329 + !addr IGETIN = $32A ; $32A-$32B + !addr ICLALL = $32C ; $32C-$32D + !addr USRCMD = $32E ; $32E-$32F + !addr ILOAD = $330 ; $330-$331 + !addr ISAVE = $332 ; $332-$333 - // $314 $334-$33B -- UNUSED -- free for user software + ; $314 $334-$33B -- UNUSED -- free for user software -#if !CONFIG_RS232_UP9600 - .label TBUFFR = $33C // $33C-$3FB [!] tape buffer, our usage details differ -#else - .label REVTAB = $37C // $37C-$3FB -- WIP -- [!] RS-232 precalculated data -#endif +!ifndef CONFIG_RS232_UP9600 { + !addr TBUFFR = $33C ; $33C-$3FB [!] tape buffer, our usage details differ +} else { + !addr REVTAB = $37C ; $37C-$3FB -- WIP -- [!] RS-232 precalculated data +} - // $3FC $3FC-$3FF -- UNUSED -- free for user software + ; $3FC $3FC-$3FF -- UNUSED -- free for user software -// -// Definitions for extended IEC functionality -// +; +; 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 + !set IEC_NORMAL = 0 ; has to be 0, always! +!ifdef CONFIG_IEC_JIFFYDOS { + !set IEC_JIFFY = 1 ; has to be 1, always! +} +!ifdef CONFIG_IEC_DOLPHINDOS { + !set IEC_DOLPHIN = 2 +} +!ifdef HAS_IEC_BURST { + !set IEC_BURST = 3 +} +!ifdef CONFIG_MB_M65 { + !set IEC_ROMDOS = 4 +} -// -// Definitions for tape functionality -// +; +; Definitions for tape functionality +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { - .label __normal_time_S = IRQTMP+0 // duration of the short pulse - .label __normal_time_M = IRQTMP+1 // duration of the medium pulse + !addr __normal_time_S = IRQTMP+0 ; duration of the short pulse + !addr __normal_time_M = IRQTMP+1 ; duration of the medium pulse - .label __turbo_half_S = IRQTMP+0 // half-duration of the short pulse - .label __turbo_half_L = IRQTMP+1 // half-duration of the long pulse + !addr __turbo_half_S = IRQTMP+0 ; half-duration of the short pulse + !addr __turbo_half_L = IRQTMP+1 ; half-duration of the long pulse - .label __pulse_threshold = SVXT // pulse classification threshold - .label __pulse_threshold_ML = SYNO // M/L pulse classification threshold, for normal only + !addr __pulse_threshold = SVXT ; pulse classification threshold + !addr __pulse_threshold_ML = SYNO ; M/L pulse classification threshold, for normal only +} -#endif +!ifdef CONFIG_TAPE_TURBO { -#if CONFIG_TAPE_TURBO - - .label __tape_turbo_bytestore = STACK // location of byte storage helper routine - -#endif + !addr __tape_turbo_bytestore = STACK ; location of byte storage helper routine +} diff --git a/src/aliases/,aliases_ram_lowmem_m65.s b/src/aliases/,aliases_ram_lowmem_m65.s index c109804e..73b55d0f 100644 --- a/src/aliases/,aliases_ram_lowmem_m65.s +++ b/src/aliases/,aliases_ram_lowmem_m65.s @@ -1,76 +1,76 @@ -// #LAYOUT# M65 * #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# * * #IGNORE -// -// Names of ZP and low memory locations for the native MEGA65 mode -// +; +; Names of ZP and low memory locations for the native MEGA65 mode +; - // - // Page 0 - reused LDTB1 and USER - // + ; + ; 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 + !addr M65_TMP__K1 = $D9 ; $D9 -- UNUSED -- temporary value for various Kernal routines + !addr M65_LPNT_BAS1 = $DA ; $DA-$DD 4-byte pointer for temporary usage within BASIC + !addr M65_LPNT_BAS2 = $DE ; $DE-$E1 4-byte pointer for temporary usage within BASIC + !addr 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 + !addr 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 + !addr M65_LPNT_IRQ = $EB ; $EB-$EE 4-byte pointer for temporary usage within interrupts + !addr M65_LPNT_KERN = $EF ; $EF-$F3 4-byte pointer for temporary usage by KERNAL + !addr M65_TMP__K2 = $F4 ; $F4 -- UNUSED -- temporary value for various Kernal routines - // - // Page 0 - other reused values - // + ; + ; 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 + !addr M65__TXTROW = TBLX ; screen row + !addr M65__TXTCOL = PNTR ; screen column + !addr M65__SCRINPUT = LSXP ; pointer to the screen input, within the screen segment - // - // Pages 4-7 - reused screen memory - // + ; + ; Pages 4-7 - reused screen memory + ; - // $400-$57F - reserved for BASIC + ; $400-$57F - reserved for BASIC - // $400-$57F -- UNUSED -- reserved for BASIC + ; $400-$57F -- UNUSED -- reserved for BASIC - // $580-$5FF - reserved for KERNAL + ; $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 -- + !addr M65_SCRSEG = $580 ; $580-$581 segment address (2 higher bytes) of the screen memory + !addr M65_SCRBASE = $582 ; $582-$583 first byte of screen memory + !addr M65_SCRGUARD = $584 ; $584-$585 last byte of screen memory + 1 XXX is it needed? + !addr M65_COLGUARD = $586 ; $586-$587 last byte of colour memory + 1 + !addr M65_COLVIEW = $588 ; $588-$589 first byte of color memory viewport + !addr M65_COLVIEWMAX = $58A ; $58A-$58B largest allowed value of M65_COLVIEW + !addr M65_SCRMODE = $58C ; 0 = 40x25, 1 = 80x25, 2 = 80x50 + !addr M65_SCRWINMODE = $58D ; $00 = normal mode, $FF = window enabled + !addr M65_TXTWIN_X0 = $58E ; text window - top-left X coordinate, starting from 0 + !addr M65_TXTWIN_Y0 = $58F ; text window - top-left Y coordinate, starting from 0 + !addr M65_TXTWIN_X1 = $590 ; text window - bottom-right X coordinate + 1 + !addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1 + !addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start + !addr M65_SCRCOLMAX = $594 ; maximum allowed column + ; $595-$5EB -- UNUSED -- + !addr M65_DMAGIC_LIST = $5EF ; $5EF-$5FF reserved for DMAgic list, 17 bytes + !addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer -- + !addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer -- - // - // Addresses for configuring the DMA job - // + ; + ; Addresses for configuring the DMA job + ; - .label M65_DMAJOB_SIZE_0 = M65_DMAGIC_LIST + 7 - .label M65_DMAJOB_SIZE_1 = M65_DMAGIC_LIST + 8 + !addr M65_DMAJOB_SIZE_0 = M65_DMAGIC_LIST + 7 + !addr 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 + !addr M65_DMAJOB_SRC_0 = M65_DMAGIC_LIST + 9 + !addr M65_DMAJOB_SRC_1 = M65_DMAGIC_LIST + 10 + !addr M65_DMAJOB_SRC_2 = M65_DMAGIC_LIST + 11 + !addr 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 + !addr M65_DMAJOB_DST_0 = M65_DMAGIC_LIST + 12 + !addr M65_DMAJOB_DST_1 = M65_DMAGIC_LIST + 13 + !addr M65_DMAJOB_DST_2 = M65_DMAGIC_LIST + 14 + !addr 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 index 0c49297d..63a1ffcd 100644 --- a/src/aliases/,aliases_ram_over64K_m65.s +++ b/src/aliases/,aliases_ram_over64K_m65.s @@ -1,24 +1,24 @@ -// #LAYOUT# M65 * #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# * * #IGNORE - // XXX target High RAM memory map concept - TODO: update current code + ; 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 + ; $10000-$17FFF (32KB) - reserved for DOS + ; $18000-$18FFF (4KB) - chargen copied to RAM, to allow character redefinition -.const MEMCONF_CHRBASE = $8000 +!set MEMCONF_CHRBASE = $8000 - // $19000-$1B7FF (10KB) - reserved for virtual text screen, 80x128 + ; $19000-$1B7FF (10KB) - reserved for virtual text screen, 80x128 -.const MEMCONF_SCRBASE = $9000 -.const MEMCONF_SCRROWS = 128 +!set MEMCONF_SCRBASE = $9000 +!set 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. + ; $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/aliases/,aliases_rom_basic.s b/src/aliases/,aliases_rom_basic.s index 89963b51..cf763787 100644 --- a/src/aliases/,aliases_rom_basic.s +++ b/src/aliases/,aliases_rom_basic.s @@ -1,15 +1,14 @@ - // BASIC startup vectors + ; BASIC startup vectors -#if ROM_LAYOUT_X16 +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { - .label IBASIC_COLD_START = $C000 - .label IBASIC_WARM_START = $C002 + !addr IBASIC_COLD_START = $C000 + !addr IBASIC_WARM_START = $C002 -#else +} else { - .label IBASIC_COLD_START = $A000 - .label IBASIC_WARM_START = $A002 - -#endif + !addr IBASIC_COLD_START = $A000 + !addr IBASIC_WARM_START = $A002 +} diff --git a/src/aliases/,aliases_rom_cart.s b/src/aliases/,aliases_rom_cart.s index 620960a7..cc4fda07 100644 --- a/src/aliases/,aliases_rom_cart.s +++ b/src/aliases/,aliases_rom_cart.s @@ -1,10 +1,9 @@ -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { - // Cartridge ROM locations + ; Cartridge ROM locations - .label ICART_COLD_START = $8000 // $8000-$8001, cartridge cold start vector - .label ICART_WARM_START = $8002 // $8002-$8003, cartridge warm start vector (RESTORE key) - .label CART_SIG = $8004 // $8004-$8008, signature for cartridge detection - -#endif + !addr ICART_COLD_START = $8000 ; $8000-$8001, cartridge cold start vector + !addr ICART_WARM_START = $8002 ; $8002-$8003, cartridge warm start vector (RESTORE key) + !addr CART_SIG = $8004 ; $8004-$8008, signature for cartridge detection +} diff --git a/src/aliases/,aliases_rom_kernal.s b/src/aliases/,aliases_rom_kernal.s index 2f568ce2..92368db6 100644 --- a/src/aliases/,aliases_rom_kernal.s +++ b/src/aliases/,aliases_rom_kernal.s @@ -1,44 +1,44 @@ -// #LAYOUT# * BASIC_1 #IGNORE -// #LAYOUT# * * #TAKE +;; #LAYOUT# * BASIC_1 #IGNORE +;; #LAYOUT# * * #TAKE - // Kernal jump table + ; Kernal jump table - .label JCINT = $FF81 - .label JIOINIT = $FF84 - .label JRAMTAS = $FF87 - .label JRESTOR = $FF8A - .label JVECTOR = $FF8D - .label JSETMSG = $FF90 - .label JSECOND = $FF93 - .label JTKSA = $FF96 - .label JMEMTOP = $FF99 - .label JMEMBOT = $FF9C - .label JSCNKEY = $FF9F - .label JSETTMO = $FFA2 - .label JACPTR = $FFA5 - .label JCIOUT = $FFA8 - .label JUNTLK = $FFAB - .label JUNLSN = $FFAE - .label JLISTEN = $FFB1 - .label JTALK = $FFB4 - .label JREADST = $FFB7 - .label JSETFLS = $FFBA - .label JSETNAM = $FFBD - .label JOPEN = $FFC0 - .label JCLOSE = $FFC3 - .label JCHKIN = $FFC6 - .label JCKOUT = $FFC9 - .label JCLRCHN = $FFCC - .label JCHRIN = $FFCF - .label JCHROUT = $FFD2 - .label JLOAD = $FFD5 - .label JSAVE = $FFD8 - .label JSETTIM = $FFDB - .label JRDTIM = $FFDE - .label JSTOP = $FFE1 - .label JGETIN = $FFE4 - .label JCLALL = $FFE7 - .label JUDTIM = $FFEA - .label JSCREEN = $FFED - .label JPLOT = $FFF0 - .label JIOBASE = $FFF3 + !addr JCINT = $FF81 + !addr JIOINIT = $FF84 + !addr JRAMTAS = $FF87 + !addr JRESTOR = $FF8A + !addr JVECTOR = $FF8D + !addr JSETMSG = $FF90 + !addr JSECOND = $FF93 + !addr JTKSA = $FF96 + !addr JMEMTOP = $FF99 + !addr JMEMBOT = $FF9C + !addr JSCNKEY = $FF9F + !addr JSETTMO = $FFA2 + !addr JACPTR = $FFA5 + !addr JCIOUT = $FFA8 + !addr JUNTLK = $FFAB + !addr JUNLSN = $FFAE + !addr JLISTEN = $FFB1 + !addr JTALK = $FFB4 + !addr JREADST = $FFB7 + !addr JSETFLS = $FFBA + !addr JSETNAM = $FFBD + !addr JOPEN = $FFC0 + !addr JCLOSE = $FFC3 + !addr JCHKIN = $FFC6 + !addr JCKOUT = $FFC9 + !addr JCLRCHN = $FFCC + !addr JCHRIN = $FFCF + !addr JCHROUT = $FFD2 + !addr JLOAD = $FFD5 + !addr JSAVE = $FFD8 + !addr JSETTIM = $FFDB + !addr JRDTIM = $FFDE + !addr JSTOP = $FFE1 + !addr JGETIN = $FFE4 + !addr JCLALL = $FFE7 + !addr JUDTIM = $FFEA + !addr JSCREEN = $FFED + !addr JPLOT = $FFF0 + !addr JIOBASE = $FFF3 diff --git a/src/basic/,aliases.s b/src/basic/,aliases.s deleted file mode 100644 index 291df1a7..00000000 --- a/src/basic/,aliases.s +++ /dev/null @@ -1,13 +0,0 @@ - -// -// Helper aliases to make the code more readable -// Always use double underscore in label names -// to allow automatic VICE label conflict prevention -// - - // Temporary variables for various routines - .label __tokenise_work1 = $07 // CHARAC - .label __tokenise_work2 = $08 // ENDCHR - .label __tokenise_work3 = $0B // COUNT - .label __tokenise_work4 = $0F // GARBFL - .label __tokenise_work5 = $0C // DIMFLG diff --git a/src/basic/,basic_aliases.s b/src/basic/,basic_aliases.s new file mode 100644 index 00000000..b1242b1c --- /dev/null +++ b/src/basic/,basic_aliases.s @@ -0,0 +1,39 @@ + +; +; Aliases for memory locations for memory block copy routines +; + +!addr memmove__src = INDEX+2 +!addr memmove__dst = RESHO+0 +!addr memmove__size = RESHO+2 +!addr memmove__tmp = RESHO+4 + + + +; +; Helper aliases to make the code more readable +; Always use double underscore in label names +; to allow automatic VICE label conflict prevention +; + +!addr __tokenise_work1 = $07 ; CHARAC +!addr __tokenise_work2 = $08 ; ENDCHR +!addr __tokenise_work3 = $0B ; COUNT +!addr __tokenise_work4 = $0F ; GARBFL +!addr __tokenise_work5 = $0C ; DIMFLG + + + +; +; Aliases for the tokeniser - reuse the CPU stack +; + +!addr tk__offset = $100 ; offset into string +!addr tk__length = __tokenise_work1 ; length of the raw string + +!addr tk__len_unpacked = $101 ; length of unpacked data; it could replace 'tk__nibble_flag', but at the cost of code size/performance +!addr tk__shorten_bits = $102 ; 2 bytes for quick shortening of packed candidate +!addr tk__nibble_flag = $104 ; $00 = start from new byte, $FF = start from high nibble +!addr tk__byte_offset = $105 ; offset of the current byte (to place new data) in tk__packed + +!addr tk__packed = $106 ; packed candidate, 25 bytes is enough for worst case - a 16 byte keyword diff --git a/src/basic/,imports.s b/src/basic/,imports.s index 86959543..62a37c08 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -1,63 +1,39 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_0 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_0 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * * #IGNORE +;; #IMPORT# KERNAL_0 = KERNAL_combined.sym KERNAL_0_combined.sym -// Routines imported from Kernal - our private API +; +; Routines imported from Kernal - our private API +; -#if ROM_LAYOUT_STD - #import "KERNAL_combined.sym" -#else - #import "KERNAL_0_combined.sym" -#endif +;; #ALIAS# panic = KERNAL_0.panic +;; #ALIAS# vector_reset = KERNAL_0.vector_reset +;; #ALIAS# hw_entry_reset = KERNAL_0.hw_entry_reset -.function KERNAL() -{ -#if ROM_LAYOUT_STD - .return KERNAL -#else - .return KERNAL_0 -#endif -} +;; #ALIAS# clear_screen = KERNAL_0.clear_screen +;; #ALIAS# printf = KERNAL_0.printf -#if ROM_LAYOUT_M65 -.label map_end = KERNAL().map_end -.label map_NORMAL = KERNAL().map_NORMAL -#endif +;; #ALIAS# plot_set = KERNAL_0.plot_set +;; #ALIAS# print_hex_byte = KERNAL_0.print_hex_byte +;; #ALIAS# print_return = KERNAL_0.print_return +;; #ALIAS# print_space = KERNAL_0.print_space -#if CONFIG_PANIC_SCREEN -.label panic = KERNAL().panic -#endif +;; #ALIAS# tape_head_align = KERNAL_0.tape_head_align -.label vector_reset = KERNAL().vector_reset -.label hw_entry_reset = KERNAL().hw_entry_reset +;; #ALIAS# filename_any = KERNAL_0.filename_any -.label clear_screen = KERNAL().clear_screen +;; #ALIAS# SELDEV = KERNAL_0.SELDEV -#if CONFIG_DBG_PRINTF -.label printf = KERNAL().printf -#endif +;; #ALIAS# map_end = KERNAL_0.map_end +;; #ALIAS# map_NORMAL = KERNAL_0.map_NORMAL -.label plot_set = KERNAL().plot_set -.label print_hex_byte = KERNAL().print_hex_byte -.label print_return = KERNAL().print_return -.label print_space = KERNAL().print_space - -#if CONFIG_TAPE_HEAD_ALIGN -.label tape_head_align = KERNAL().tape_head_align -#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 +;; #ALIAS# M65_MODEGET = KERNAL_0.M65_MODEGET +;; #ALIAS# M65_MODESET = KERNAL_0.M65_MODESET +;; #ALIAS# M65_SLOW = KERNAL_0.M65_SLOW +;; #ALIAS# M65_FAST = KERNAL_0.M65_FAST +;; #ALIAS# M65_SETWIN_Y = KERNAL_0.M65_SETWIN_Y diff --git a/src/basic/,stubs/a408.reason.s b/src/basic/,stubs/a408.reason.s index 00e36030..722534db 100644 --- a/src/basic/,stubs/a408.reason.s +++ b/src/basic/,stubs/a408.reason.s @@ -1,10 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation REASON: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a453.unknown.s b/src/basic/,stubs/a453.unknown.s index 7a54c8b2..2dabd3b9 100644 --- a/src/basic/,stubs/a453.unknown.s +++ b/src/basic/,stubs/a453.unknown.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a483.main.s b/src/basic/,stubs/a483.main.s index 9533f2cb..3f50fcee 100644 --- a/src/basic/,stubs/a483.main.s +++ b/src/basic/,stubs/a483.main.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 69, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 69, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; MAIN: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a57c.chrnch.s b/src/basic/,stubs/a57c.chrnch.s index d320dd69..0d3862f5 100644 --- a/src/basic/,stubs/a57c.chrnch.s +++ b/src/basic/,stubs/a57c.chrnch.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 69, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 69, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; CHRNCH: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a644.new.s b/src/basic/,stubs/a644.new.s index 306c8228..e8b664c3 100644 --- a/src/basic/,stubs/a644.new.s +++ b/src/basic/,stubs/a644.new.s @@ -1,10 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and real implementation +; XXX provide documentation and real implementation new: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a659.setcharptr.s b/src/basic/,stubs/a659.setcharptr.s index 17f8cef5..4037628f 100644 --- a/src/basic/,stubs/a659.setcharptr.s +++ b/src/basic/,stubs/a659.setcharptr.s @@ -1,12 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation -// see: https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7 -// https://www.lemon64.com/forum/viewtopic.php?t=70680&sid=3ff66caf7f5fdf2a3c2ff2ee31fc3fd8 +; XXX provide documentation and implementation +; see: https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7 +; https://www.lemon64.com/forum/viewtopic.php?t=70680&sid=3ff66caf7f5fdf2a3c2ff2ee31fc3fd8 setcharptr: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a71a.qplop.s b/src/basic/,stubs/a71a.qplop.s index 03f00cd3..649a02d7 100644 --- a/src/basic/,stubs/a71a.qplop.s +++ b/src/basic/,stubs/a71a.qplop.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 69, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 69, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; QPLOP: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/a7e4.gone.s b/src/basic/,stubs/a7e4.gone.s index 33b6e87c..f7a1e47f 100644 --- a/src/basic/,stubs/a7e4.gone.s +++ b/src/basic/,stubs/a7e4.gone.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 70, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 70, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; GONE: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/ae86.eval.s b/src/basic/,stubs/ae86.eval.s index b790c094..56951d00 100644 --- a/src/basic/,stubs/ae86.eval.s +++ b/src/basic/,stubs/ae86.eval.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 70, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 70, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; EVAL: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/basic_adray1.s b/src/basic/,stubs/basic_adray1.s index 201195a2..7ed97079 100644 --- a/src/basic/,stubs/basic_adray1.s +++ b/src/basic/,stubs/basic_adray1.s @@ -1,9 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation basic_adray1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/basic_adray2.s b/src/basic/,stubs/basic_adray2.s index afb58e61..4f42a31e 100644 --- a/src/basic/,stubs/basic_adray2.s +++ b/src/basic/,stubs/basic_adray2.s @@ -1,8 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation basic_adray2: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/e38b.error.s b/src/basic/,stubs/e38b.error.s index e057f13a..c1c4534b 100644 --- a/src/basic/,stubs/e38b.error.s +++ b/src/basic/,stubs/e38b.error.s @@ -1,16 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official BASIC routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - XXX -// - [CM64] Computes Mapping the Commodore 64 - page 69, XXX -// -// CPU registers that has to be preserved (see [RG64]): XXX -// +; +; Official BASIC routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - XXX +; - [CM64] Computes Mapping the Commodore 64 - page 69, XXX +; +; CPU registers that has to be preserved (see [RG64]): XXX +; ERROR: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/e3bf.init.s b/src/basic/,stubs/e3bf.init.s index 25cf67c0..713b9a40 100644 --- a/src/basic/,stubs/e3bf.init.s +++ b/src/basic/,stubs/e3bf.init.s @@ -1,9 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation INIT: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs/e453.rvect.s b/src/basic/,stubs/e453.rvect.s index b8322901..085b6004 100644 --- a/src/basic/,stubs/e453.rvect.s +++ b/src/basic/,stubs/e453.rvect.s @@ -1,9 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX provide documentation and implementation +; XXX provide documentation and implementation RVECT: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s b/src/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s index 55b66169..991361f1 100644 --- a/src/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s +++ b/src/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - subtract FAC1 to integer in memory -// -// Output: -// - integer pointed by $49/$4A -// -// See also: -// - https://sta.c64.org/cbm64basconv.html -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - subtract FAC1 to integer in memory +; +; Output: +; - integer pointed by $49/$4A +; +; See also: +; - https://sta.c64.org/cbm64basconv.html +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; -// XXX implement, test +; XXX implement, test convert_FAC1_to_INT: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/aabc.print_FAC1.s b/src/basic/,stubs_math/aabc.print_FAC1.s index 163da77b..2aec74aa 100644 --- a/src/basic/,stubs_math/aabc.print_FAC1.s +++ b/src/basic/,stubs_math/aabc.print_FAC1.s @@ -1,18 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - print FAC1 value -// -// See also: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - print FAC1 value +; +; See also: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; -// XXX implement, test +; XXX implement, test print_FAC1: - STUB_IMPLEMENTATION() \ No newline at end of file + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/af7b.compute_TI.s b/src/basic/,stubs_math/af7b.compute_TI.s index 0bd1acfc..e360918a 100644 --- a/src/basic/,stubs_math/af7b.compute_TI.s +++ b/src/basic/,stubs_math/af7b.compute_TI.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - compute TI value -// -// See also: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - compute TI value +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; -// XXX implement, test +; XXX implement, test compute_TI: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/af7e.math_stub.s b/src/basic/,stubs_math/af7e.math_stub.s index c5eacf46..051a14e5 100644 --- a/src/basic/,stubs_math/af7e.math_stub.s +++ b/src/basic/,stubs_math/af7e.math_stub.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - sets mantissa to 00yyxxaa -// -// See also: -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - sets mantissa to 00yyxxaa +; +; See also: +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX add name, label, implement, test +; XXX add name, label, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/af87.math_stub.s b/src/basic/,stubs_math/af87.math_stub.s index 25746cdc..3a85250e 100644 --- a/src/basic/,stubs_math/af87.math_stub.s +++ b/src/basic/,stubs_math/af87.math_stub.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - set rest of FAC1 and JMP to $b8d2 -// -// See also: -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - set rest of FAC1 and JMP to $b8d2 +; +; See also: +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX add name, label, implement, test +; XXX add name, label, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/af9a.compute_ST.s b/src/basic/,stubs_math/af9a.compute_ST.s index 801fa221..8ffe15cc 100644 --- a/src/basic/,stubs_math/af9a.compute_ST.s +++ b/src/basic/,stubs_math/af9a.compute_ST.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - compute ST value -// -// See also: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - compute ST value +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; -// XXX implement, test +; XXX implement, test compute_ST: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b1aa.FACINX.s b/src/basic/,stubs_math/b1aa.FACINX.s index 11ab5ed0..fd913708 100644 --- a/src/basic/,stubs_math/b1aa.FACINX.s +++ b/src/basic/,stubs_math/b1aa.FACINX.s @@ -1,21 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - convert FAC1 to 16-bit signed integer -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 105 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - convert FAC1 to 16-bit signed integer +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 105 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; -// XXX provide implementation +; XXX provide implementation FACINX: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s b/src/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s index 601bf5d7..caa3e52d 100644 --- a/src/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s +++ b/src/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// See also: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - XXX +; +; See also: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; -// XXX implement, test +; XXX implement, test convert_FAC1_to_s16: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b391.GIVAYF.s b/src/basic/,stubs_math/b391.GIVAYF.s index 982b2262..b2b0d282 100644 --- a/src/basic/,stubs_math/b391.GIVAYF.s +++ b/src/basic/,stubs_math/b391.GIVAYF.s @@ -1,21 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - 16-bit signed integer to FAC1 -// -// Output: -// - .A - address high byte (XXX really, not the opposite?) -// - .Y - address low byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 107 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - 16-bit signed integer to FAC1 +; +; Output: +; - .A - address high byte (XXX really, not the opposite?) +; - .Y - address low byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 107 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; -// XXX provide implementation +; XXX provide implementation GIVAYF: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s b/src/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s index 7ec3f99a..dbd6d250 100644 --- a/src/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s +++ b/src/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://sta.c64.org/cbm64basconv.html -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// -// XXX add name, label, documentation, implement, test +; +; Math package - XXX +; +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; +; XXX add name, label, documentation, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b794.convert_A_to_FAC1.s b/src/basic/,stubs_math/b794.convert_A_to_FAC1.s index c79f363c..e33d3f30 100644 --- a/src/basic/,stubs_math/b794.convert_A_to_FAC1.s +++ b/src/basic/,stubs_math/b794.convert_A_to_FAC1.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// - https://sta.c64.org/cbm64basconv.html -// -// XXX add name, label, documentation, implement, test +; +; Math package - XXX +; +; - https://sta.c64.org/cbm64basconv.html +; +; XXX add name, label, documentation, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b7b5.STRVAL.s b/src/basic/,stubs_math/b7b5.STRVAL.s index f754d8f6..69acf4cc 100644 --- a/src/basic/,stubs_math/b7b5.STRVAL.s +++ b/src/basic/,stubs_math/b7b5.STRVAL.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - imports string to FAC1 - XXX: what about spaces? -// -// Input: -// - .A needs to be loaded with string length -// - string address in $22/$23 -// -// See also: -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - imports string to FAC1 - XXX: what about spaces? +; +; Input: +; - .A needs to be loaded with string length +; - string address in $22/$23 +; +; See also: +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; -// XXX provide implementation +; XXX provide implementation STRVAL: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s b/src/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s index f38d5a98..e9d87ff7 100644 --- a/src/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s +++ b/src/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - subtract FAC1 to memory address at $14/$15 and Y/A -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 -// - https://sta.c64.org/cbm64basconv.html -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - subtract FAC1 to memory address at $14/$15 and Y/A +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 +; - https://sta.c64.org/cbm64basconv.html +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; -// XXX implement, test +; XXX implement, test convert_FAC1_to_ADDR: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b947.inv_FAC1_mantissa.s b/src/basic/,stubs_math/b947.inv_FAC1_mantissa.s index ceadfe99..c0b60e54 100644 --- a/src/basic/,stubs_math/b947.inv_FAC1_mantissa.s +++ b/src/basic/,stubs_math/b947.inv_FAC1_mantissa.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - invert FAC1 mantissa -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://sta.c64.org/cbm64basconv.html -// +; +; Math package - invert FAC1 mantissa +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; -// XXX implement, test +; XXX implement, test inv_FAC1_mantissa: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/b9ea.log_FAC1.s b/src/basic/,stubs_math/b9ea.log_FAC1.s index 2bc2765c..8c6571d9 100644 --- a/src/basic/,stubs_math/b9ea.log_FAC1.s +++ b/src/basic/,stubs_math/b9ea.log_FAC1.s @@ -1,19 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - natural logarigthm -// -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - natural logarigthm +; +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation log_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s b/src/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s index 1e5b639a..4c2bfcaa 100644 --- a/src/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s +++ b/src/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// See also: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - XXX +; +; See also: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; -// XXX implement, test +; XXX implement, test get_FAC2_via_INDEX: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s b/src/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s index fc6675f6..81499d2f 100644 --- a/src/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s +++ b/src/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// See also: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - XXX +; +; See also: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; -// XXX implement, test +; XXX implement, test get_FAC1_via_INDEX: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc39.sgn_FAC1.s b/src/basic/,stubs_math/bc39.sgn_FAC1.s index 47af6ee9..7828f4e6 100644 --- a/src/basic/,stubs_math/bc39.sgn_FAC1.s +++ b/src/basic/,stubs_math/bc39.sgn_FAC1.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - evaluate FAC1 sign, to FAC1 -// -// Output: -// - FAC1 - 0 for FAC1 equal 0, 1 for FAC1 > 0, -1 for FAC1 < 0 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - evaluate FAC1 sign, to FAC1 +; +; Output: +; - FAC1 - 0 for FAC1 equal 0, 1 for FAC1 > 0, -1 for FAC1 < 0 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation sgn_FAC1: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc3c.convert_A_to_FAC1.s b/src/basic/,stubs_math/bc3c.convert_A_to_FAC1.s index 9187103d..5d34e1cd 100644 --- a/src/basic/,stubs_math/bc3c.convert_A_to_FAC1.s +++ b/src/basic/,stubs_math/bc3c.convert_A_to_FAC1.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// - https://codebase64.org/doku.php?id=base:asm_include_file_for_basic_routines -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// -// XXX add name, label, documentation, implement, test +; +; Math package - XXX +; +; - https://codebase64.org/doku.php?id=base:asm_include_file_for_basic_routines +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; +; XXX add name, label, documentation, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc44.convert_i16_to_FAC1.s b/src/basic/,stubs_math/bc44.convert_i16_to_FAC1.s index b0e1f2e7..c7992238 100644 --- a/src/basic/,stubs_math/bc44.convert_i16_to_FAC1.s +++ b/src/basic/,stubs_math/bc44.convert_i16_to_FAC1.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - XXX -// -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// -// XXX add name, label, documentation, implement, test +; +; Math package - XXX +; +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; +; XXX add name, label, documentation, implement, test - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc58.abs_FAC1.s b/src/basic/,stubs_math/bc58.abs_FAC1.s index 919f179a..caf41ff8 100644 --- a/src/basic/,stubs_math/bc58.abs_FAC1.s +++ b/src/basic/,stubs_math/bc58.abs_FAC1.s @@ -1,18 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - absolute value -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - absolute value +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation abs_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc5b.FCOMP.s b/src/basic/,stubs_math/bc5b.FCOMP.s index e0f00777..595c3a96 100644 --- a/src/basic/,stubs_math/bc5b.FCOMP.s +++ b/src/basic/,stubs_math/bc5b.FCOMP.s @@ -1,29 +1,30 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - compare FAC1 with RAM location -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// Output: -// - .A - $00 for equal, $01 for FAC1 > RAM, $FF for FAC1 < RAM -// - flags N/Z, depending on whether FAC1 is 0, positive, or negative -// -// Notes: -// - uses vector at $24, leaves FAC1 and FAC2 unchanged (Codebase64) -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - compare FAC1 with RAM location +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; Output: +; - .A - $00 for equal, $01 for FAC1 > RAM, $FF for FAC1 < RAM +; - flags N/Z, depending on whether FAC1 is 0, positive, or negative +; +; Notes: +; - uses vector at $24, leaves FAC1 and FAC2 unchanged (Codebase64) +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation FCOMP: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bc9b.QINT.s b/src/basic/,stubs_math/bc9b.QINT.s index 26ba5f71..57bc0803 100644 --- a/src/basic/,stubs_math/bc9b.QINT.s +++ b/src/basic/,stubs_math/bc9b.QINT.s @@ -1,20 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - convert FAC1 to 32 bit signed integer -// -// Output: -// - $62-$65, big-endian order -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - convert FAC1 to 32 bit signed integer +; +; Output: +; - $62-$65, big-endian order +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; -// XXX provide implementation +; XXX provide implementation QINT: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bccc.int_FAC1.s b/src/basic/,stubs_math/bccc.int_FAC1.s index 4a7c6d47..827fdaa5 100644 --- a/src/basic/,stubs_math/bccc.int_FAC1.s +++ b/src/basic/,stubs_math/bccc.int_FAC1.s @@ -1,18 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - rounds away the decimal to make an integer -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 116 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - rounds away the decimal to make an integer +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 116 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation int_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bcf3.FIN.s b/src/basic/,stubs_math/bcf3.FIN.s index f06e63eb..d5375a5e 100644 --- a/src/basic/,stubs_math/bcf3.FIN.s +++ b/src/basic/,stubs_math/bcf3.FIN.s @@ -1,24 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - imports string to FAC1, ignores spaces -// -// -// Input: -// - .A needs to be loaded with first char of the string -// - Carry flag must be clear -// - string address in $7A/$7B -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 116 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - imports string to FAC1, ignores spaces +; +; +; Input: +; - .A needs to be loaded with first char of the string +; - Carry flag must be clear +; - string address in $7A/$7B +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 116 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation FIN: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bd7e.FINLOG.s b/src/basic/,stubs_math/bd7e.FINLOG.s index 998ca32b..2172420a 100644 --- a/src/basic/,stubs_math/bd7e.FINLOG.s +++ b/src/basic/,stubs_math/bd7e.FINLOG.s @@ -1,18 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - add an ASCII digit that has been converted to a signed integer to FAC1 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 -// +; +; Math package - add an ASCII digit that has been converted to a signed integer to FAC1 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 +; -// XXX implement, test +; XXX implement, test FINLOG: - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bddd.FOUT.s b/src/basic/,stubs_math/bddd.FOUT.s index a9b3b2d8..4ee10301 100644 --- a/src/basic/,stubs_math/bddd.FOUT.s +++ b/src/basic/,stubs_math/bddd.FOUT.s @@ -1,22 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - outputs FAC1 to string at $0100 -// -// Output: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 116 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - outputs FAC1 to string at $0100 +; +; Output: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 116 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation FOUT: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bf74.sqr_FAC2.s b/src/basic/,stubs_math/bf74.sqr_FAC2.s index a0b8a412..1cb3db61 100644 --- a/src/basic/,stubs_math/bf74.sqr_FAC2.s +++ b/src/basic/,stubs_math/bf74.sqr_FAC2.s @@ -1,21 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - square root of FAC2 -// -// Note: -// - loads .5 into FAC1 and falling through to the exponentiation routine -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - square root of FAC2 +; +; Note: +; - loads .5 into FAC1 and falling through to the exponentiation routine +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation sqr_FAC2: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bf7b.pwr_FAC2_FAC1.s b/src/basic/,stubs_math/bf7b.pwr_FAC2_FAC1.s index 6bb1a7f6..5ea6028a 100644 --- a/src/basic/,stubs_math/bf7b.pwr_FAC2_FAC1.s +++ b/src/basic/,stubs_math/bf7b.pwr_FAC2_FAC1.s @@ -1,25 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - set FAC1 as FAC2 raised to the power of FAC1 -// -// Input: -// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag -// -// Note: -// - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) -// - uses exp(x*log(y)) formula to calculate y^x; slow and inaccurate -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - set FAC1 as FAC2 raised to the power of FAC1 +; +; Input: +; - .A - must load FAC1 exponent ($61) beforehand to set the zero flag +; +; Note: +; - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) +; - uses exp(x*log(y)) formula to calculate y^x; slow and inaccurate +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation pwr_FAC2_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/bfed.exp_FAC1.s b/src/basic/,stubs_math/bfed.exp_FAC1.s index 296a58a3..4eb007f9 100644 --- a/src/basic/,stubs_math/bfed.exp_FAC1.s +++ b/src/basic/,stubs_math/bfed.exp_FAC1.s @@ -1,19 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - exponential function, e raised to FAC1 power -// -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - exponential function, e raised to FAC1 power +; +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation exp_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/e043.poly1_FAC1.s b/src/basic/,stubs_math/e043.poly1_FAC1.s index 94639620..c4ca783b 100644 --- a/src/basic/,stubs_math/e043.poly1_FAC1.s +++ b/src/basic/,stubs_math/e043.poly1_FAC1.s @@ -1,27 +1,28 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - evaluate polynomial with odd powers only for FAC1 value -// -// Input: -// - .A - table address low byte -// - .Y - table address low byte -// - table format: -// - polynomial degree (8 bit integer) -// - oefficients (floats), starting from highest degree, times 1+degree -// -// Notes: -// - calls POLY2(table, X*X)*X -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 206 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://www.c64-wiki.com/wiki/POLY1 -// +; +; Math package - evaluate polynomial with odd powers only for FAC1 value +; +; Input: +; - .A - table address low byte +; - .Y - table address low byte +; - table format: +; - polynomial degree (8 bit integer) +; - oefficients (floats), starting from highest degree, times 1+degree +; +; Notes: +; - calls POLY2(table, X*X)*X +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 206 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://www.c64-wiki.com/wiki/POLY1 +; -// XXX provide implementation +; XXX provide implementation poly1_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/e059.poly2_FAC1.s b/src/basic/,stubs_math/e059.poly2_FAC1.s index 226c61b3..f7148ef3 100644 --- a/src/basic/,stubs_math/e059.poly2_FAC1.s +++ b/src/basic/,stubs_math/e059.poly2_FAC1.s @@ -1,27 +1,28 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - evaluate polynomial with odd and even powers for FAC1 value -// -// Input: -// - .A - table address low byte -// - .Y - table address low byte -// - table format: -// - polynomial degree (8 bit integer) -// - oefficients (floats), starting from highest degree, times 1+degree -// -// Notes: -// - uses Horner method -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 207 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://www.c64-wiki.com/wiki/POLY1 -// +; +; Math package - evaluate polynomial with odd and even powers for FAC1 value +; +; Input: +; - .A - table address low byte +; - .Y - table address low byte +; - table format: +; - polynomial degree (8 bit integer) +; - oefficients (floats), starting from highest degree, times 1+degree +; +; Notes: +; - uses Horner method +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 207 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://www.c64-wiki.com/wiki/POLY1 +; -// XXX provide implementation +; XXX provide implementation poly2_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/e264.cos_FAC1.s b/src/basic/,stubs_math/e264.cos_FAC1.s index bdf0b761..42999aa7 100644 --- a/src/basic/,stubs_math/e264.cos_FAC1.s +++ b/src/basic/,stubs_math/e264.cos_FAC1.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - cosine of FAC1 in radians -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 210 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - cosine of FAC1 in radians +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 210 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation COS: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/e26b.sin_FAC1.s b/src/basic/,stubs_math/e26b.sin_FAC1.s index 82a86d2f..f1f2f340 100644 --- a/src/basic/,stubs_math/e26b.sin_FAC1.s +++ b/src/basic/,stubs_math/e26b.sin_FAC1.s @@ -1,28 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - sine of FAC1 in radians -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 210 - XXX address does not match -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - sine of FAC1 in radians +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 210 - XXX address does not match +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation sin_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION poly_sin: - .byte $05 // series length - 1 + !byte $05 ; series length - 1 - put_const_POLY_SIN_1() - put_const_POLY_SIN_2() - put_const_POLY_SIN_3() - put_const_POLY_SIN_4() - put_const_POLY_SIN_5() - put_const_POLY_SIN_6() + +PUT_CONST_POLY_SIN_1 + +PUT_CONST_POLY_SIN_2 + +PUT_CONST_POLY_SIN_3 + +PUT_CONST_POLY_SIN_4 + +PUT_CONST_POLY_SIN_5 + +PUT_CONST_POLY_SIN_6 diff --git a/src/basic/,stubs_math/e2b4.tan_FAC1.s b/src/basic/,stubs_math/e2b4.tan_FAC1.s index 480991fc..778ffa21 100644 --- a/src/basic/,stubs_math/e2b4.tan_FAC1.s +++ b/src/basic/,stubs_math/e2b4.tan_FAC1.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - tangent of FAC1 in radians -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 210 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - tangent of FAC1 in radians +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 210 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation tan_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/,stubs_math/e30e.atn_FAC1.s b/src/basic/,stubs_math/e30e.atn_FAC1.s index 1fc04501..36e35274 100644 --- a/src/basic/,stubs_math/e30e.atn_FAC1.s +++ b/src/basic/,stubs_math/e30e.atn_FAC1.s @@ -1,17 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - arc tangent of FAC1 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 211 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - arc tangent of FAC1 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 211 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX provide implementation +; XXX provide implementation atn_FAC1: - STUB_IMPLEMENTATION() + + +STUB_IMPLEMENTATION diff --git a/src/basic/a68e.runc.s b/src/basic/a68e.runc.s index bda66edc..e63a84d9 100644 --- a/src/basic/a68e.runc.s +++ b/src/basic/a68e.runc.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Well-known BASIC routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 97 -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://csdb.dk/forums/?roomid=11&topicid=137233 -// +; Well-known BASIC routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 97 +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://csdb.dk/forums/?roomid=11&topicid=137233 +; -// XXX use this routine to initialize TXTPTR +; XXX use this routine to initialize TXTPTR RUNC: - // According to WIKI, we should load $7A/$7B with $2B-1/$2C-1), this does not makes sense. - // But CSDB claims, that it should 'set current character pointer to start of basic - 1' - this - // looks sane, also checked that the original BASIC routine does this (short test program) + ; According to WIKI, we should load $7A/$7B with $2B-1/$2C-1), this does not makes sense. + ; But CSDB claims, that it should 'set current character pointer to start of basic - 1' - this + ; looks sane, also checked that the original BASIC routine does this (short test program) - // Lets initialize TXTPTR using TXTTAB + ; Lets initialize TXTPTR using TXTTAB lda TXTTAB+0 sec diff --git a/src/basic/a7ae.newstt.s b/src/basic/a7ae.newstt.s index 069a1276..817d2824 100644 --- a/src/basic/a7ae.newstt.s +++ b/src/basic/a7ae.newstt.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Well-known BASIC routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 97 -// - https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7 -// - https://www.lemon64.com/forum/viewtopic.php?t=70680&sid=3ff66caf7f5fdf2a3c2ff2ee31fc3fd8 -// - https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image +; Well-known BASIC routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 97 +; - https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7 +; - https://www.lemon64.com/forum/viewtopic.php?t=70680&sid=3ff66caf7f5fdf2a3c2ff2ee31fc3fd8 +; - https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image NEWSTT: - // XXX Real implementation is more complicated, it iss actually a part - // of the BASIC main loop. It is, however, often called by various - // utilities to simply run the software which was just loaded or - // uncompressed. + ; XXX Real implementation is more complicated, it iss actually a part + ; of the BASIC main loop. It is, however, often called by various + ; utilities to simply run the software which was just loaded or + ; uncompressed. - // For now, lets cheat a little - this should provide some compatibility: + ; For now, lets cheat a little - this should provide some compatibility: jmp cmd_run diff --git a/src/basic/ab1e.strout.s b/src/basic/ab1e.strout.s index 9f99e7bf..3f88c657 100644 --- a/src/basic/ab1e.strout.s +++ b/src/basic/ab1e.strout.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE-FLOAT -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE-FLOAT +;; #LAYOUT# * * #IGNORE -// Print string at $YYAA -// Computes Mapping the 64 p101 +; Print string at $YYAA +; Computes Mapping the 64 p101 -// print string routine +; print string routine STROUT: - // Setup pointer + ; Setup pointer sty FRESPC+1 sta FRESPC+0 - phx_trash_a + +phx_trash_a - // Get offset ready + ; Get offset ready ldy #$00 -!: - // Save Y in X, since X is preserved by chrout, but Y is not +@1: + ; Save Y in X, since X is preserved by chrout, but Y is not tya tax lda (FRESPC),y - beq !+ + beq @2 jsr JCHROUT @@ -33,8 +33,8 @@ STROUT: tay iny - bne !- -!: - pla // XXX can we use plx_trash_a here? + bne @1 +@2: + pla ; XXX can we use plx_trash_a here? tax rts diff --git a/src/basic/assets/basic_vector_defaults.s b/src/basic/assets/basic_vector_defaults.s index 9e7ebb73..7cc2db03 100644 --- a/src/basic/assets/basic_vector_defaults.s +++ b/src/basic/assets/basic_vector_defaults.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Default values for BASIC vectors - described in: -// -// - [RG64] C64 Programmers Reference Guide - pages 68-70 -// - [CM64] Computes Mapping the Commodore 64 - page 318 -// +; +; Default values for BASIC vectors - described in: +; +; - [RG64] C64 Programmers Reference Guide - pages 68-70 +; - [CM64] Computes Mapping the Commodore 64 - page 318 +; basic_vector_defaults_1: - .word ERROR // IERROR - .word MAIN // IMAIN - .word CHRNCH // ICHRNCH - .word QPLOP // IQPLOP - .word GONE // IGONE - .word EVAL // IEVAL + !word ERROR ; IERROR + !word MAIN ; IMAIN + !word CHRNCH ; ICHRNCH + !word QPLOP ; IQPLOP + !word GONE ; IGONE + !word EVAL ; IEVAL basic_vector_defaults_2: - .word basic_adray1 // ADRAY1 - .word basic_adray2 // ADRAY2 + !word basic_adray1 ; ADRAY1 + !word basic_adray2 ; ADRAY2 diff --git a/src/basic/assets/c000.skip_gap.s b/src/basic/assets/c000.skip_gap.s index a8d678e6..54fa6e9e 100644 --- a/src/basic/assets/c000.skip_gap.s +++ b/src/basic/assets/c000.skip_gap.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Skip the gap between $C000-$DFFF +; Skip the gap between $C000-$DFFF - .fill $2000, $00 + !fill $2000, $00 diff --git a/src/basic/assets/packed_as_1n.s b/src/basic/assets/packed_as_1n.s index ba42d331..4deeadcf 100644 --- a/src/basic/assets/packed_as_1n.s +++ b/src/basic/assets/packed_as_1n.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE packed_as_1n: - put_packed_as_1n() + +PUT_PACKED_AS_1N diff --git a/src/basic/assets/packed_as_3n.s b/src/basic/assets/packed_as_3n.s index 27e7f9e3..f7e85a7c 100644 --- a/src/basic/assets/packed_as_3n.s +++ b/src/basic/assets/packed_as_3n.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE packed_as_3n: - put_packed_as_3n() + +PUT_PACKED_AS_3N diff --git a/src/basic/assets/packed_dictionary.s b/src/basic/assets/packed_dictionary.s index b7f9c640..f53559cc 100644 --- a/src/basic/assets/packed_dictionary.s +++ b/src/basic/assets/packed_dictionary.s @@ -1,13 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_COMPRESSION_LVL_2 +!ifdef CONFIG_COMPRESSION_LVL_2 { packed_dictionary: - put_packed_freq_DICTIONARY() - -#endif + +PUT_PACKED_FREQ_dictionary +} diff --git a/src/basic/assets/packed_errors.s b/src/basic/assets/packed_errors.s index d71177b0..ded0d7e1 100644 --- a/src/basic/assets/packed_errors.s +++ b/src/basic/assets/packed_errors.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_COMPRESSION_LVL_2 +!ifdef CONFIG_COMPRESSION_LVL_2 { packed_dict_errors: - put_packed_dict_errors() + +PUT_PACKED_DICT_errors -#else +} else { packed_freq_errors: - put_packed_freq_errors() + +PUT_PACKED_FREQ_errors -#endif +} diff --git a/src/basic/assets/packed_keywords.s b/src/basic/assets/packed_keywords.s index b6cd2eab..df83fd3b 100644 --- a/src/basic/assets/packed_keywords.s +++ b/src/basic/assets/packed_keywords.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE packed_freq_keywords_V2: - put_packed_freq_keywords_V2() + +PUT_PACKED_FREQ_keywords_V2 diff --git a/src/basic/assets/packed_keywords_01.s b/src/basic/assets/packed_keywords_01.s index 85093d48..b743b433 100644 --- a/src/basic/assets/packed_keywords_01.s +++ b/src/basic/assets/packed_keywords_01.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE packed_freq_keywords_01: - put_packed_freq_keywords_01() + +PUT_PACKED_FREQ_keywords_01 \ No newline at end of file diff --git a/src/basic/assets/packed_keywords_02.s b/src/basic/assets/packed_keywords_02.s index 37c9903a..34c1334b 100644 --- a/src/basic/assets/packed_keywords_02.s +++ b/src/basic/assets/packed_keywords_02.s @@ -1,12 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { packed_freq_keywords_02: - put_packed_freq_keywords_02() - -#endif + +PUT_PACKED_FREQ_keywords_02 +} diff --git a/src/basic/assets/packed_keywords_03.s b/src/basic/assets/packed_keywords_03.s index 10edc998..d7f57653 100644 --- a/src/basic/assets/packed_keywords_03.s +++ b/src/basic/assets/packed_keywords_03.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { packed_freq_keywords_03: - put_packed_freq_keywords_03() + +PUT_PACKED_FREQ_keywords_03 -#endif +} \ No newline at end of file diff --git a/src/basic/assets/packed_misc.s b/src/basic/assets/packed_misc.s index 3af051b7..d87ddb3b 100644 --- a/src/basic/assets/packed_misc.s +++ b/src/basic/assets/packed_misc.s @@ -1,19 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_COMPRESSION_LVL_2 +!ifdef CONFIG_COMPRESSION_LVL_2 { packed_dict_misc: - put_packed_dict_misc() + +PUT_PACKED_DICT_misc -#else +} else { packed_freq_misc: - put_packed_freq_misc() - -#endif + +PUT_PACKED_FREQ_misc +} diff --git a/src/basic/assets/startup_banner.s b/src/basic/assets/startup_banner.s index d1096c4f..c8f46dca 100644 --- a/src/basic/assets/startup_banner.s +++ b/src/basic/assets/startup_banner.s @@ -1,56 +1,52 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Startup banner, to be displayed during cold start -// - -.encoding "petscii_upper" +; +; Startup banner, to be displayed during cold start +; -.macro BANNER_TEXT() { +!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 +!ifdef CONFIG_BRAND_CUSTOM_BUILD { + !pet "open roms " + +CONFIG_CUSTOM_BRAND +} else ifdef CONFIG_BRAND_GENERIC { + !pet "open roms generic build" +} else ifdef CONFIG_BRAND_TESTING { + !pet "open roms testing build" +} else ifdef CONFIG_BRAND_ULTIMATE_64 { + !pet "open roms for ultimate 64" +} } startup_banner: -#if CONFIG_BANNER_SIMPLE +!ifdef CONFIG_BANNER_SIMPLE { - .text " " - BANNER_TEXT() - .byte $00 + !pet " " + +BANNER_TEXT + !byte $00 -#elif CONFIG_BANNER_FANCY +} else ifdef CONFIG_BANNER_FANCY { - BANNER_TEXT() - .byte $00 + +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 + !set SET_COLOR_0 = $05 + !set SET_COLOR_1 = $1C + !set SET_COLOR_2 = $9E + !set SET_COLOR_3 = $1E + !set 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 - .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/assets/startup_banner_m65.s b/src/basic/assets/startup_banner_m65.s index a09193ed..8e4b3830 100644 --- a/src/basic/assets/startup_banner_m65.s +++ b/src/basic/assets/startup_banner_m65.s @@ -1,71 +1,66 @@ -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Startup banner, to be displayed during cold start -// - -.encoding "petscii_upper" +; +; Startup banner, to be displayed during cold start +; startup_banner: - // Fancy MEGA65 banner - from Retrofan, slightly tweaked + ; Fancy MEGA65 banner - from Retrofan, slightly tweaked - // remove unneeded $1F's (blue) and $9A's (light blue) + !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, $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, $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, $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 + ; + ; !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 + ; !byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 + ; !byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $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, $20, $20, $20, $20, $05, $92, $42 + ; !byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 + ; !byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 + ; !byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 + ; !byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a + ; !byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 + ; !byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a + ; !byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f + ; !byte $92, $0D, $0D, $05, $00 - .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, $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, $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, $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 - // - // .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 - // .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 - // .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $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, $20, $20, $20, $20, $05, $92, $42 - // .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 - // .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 - // .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 - // .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a - // .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 - // .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a - // .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f - // .byte $92, $0D, $0D, $05, $00 - - // 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 - // .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 - // .byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 - // .byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 - // .byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF - // .byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E - // .byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 - // .byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 - // .byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 - // .byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 - // .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F - // .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 + ; 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 + ; !byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 + ; !byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 + ; !byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 + ; !byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF + ; !byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E + ; !byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 + ; !byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 + ; !byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 + ; !byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 + ; !byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F + ; !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 diff --git a/src/basic/assets/str_rev_question.s b/src/basic/assets/str_rev_question.s index ba0c8302..a0323ba7 100644 --- a/src/basic/assets/str_rev_question.s +++ b/src/basic/assets/str_rev_question.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// String - question mark in reverse +; String - question mark in reverse str_rev_question: - .byte $12, $3F, $92, $00 + !byte $12, $3F, $92, $00 diff --git a/src/basic/assets/table_ti_hi.s b/src/basic/assets/table_ti_hi.s index e0615a58..46504a30 100644 --- a/src/basic/assets/table_ti_hi.s +++ b/src/basic/assets/table_ti_hi.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Table to TI$ special variable support -// +; +; Table to TI$ special variable support +; table_TI_hi: -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { - .byte $20 // 10 hours = 2169000 ticks - .byte $03 // 1 hour = 216000 ticks - .byte $00 // 10 minutes = 36000 ticks - .byte $00 // 1 minute = 3600 ticks - .byte $00 // 10 seconds = 600 ticks - .byte $00 // 1 second = 60 ticks + !byte $20 ; 10 hours = 2169000 ticks + !byte $03 ; 1 hour = 216000 ticks + !byte $00 ; 10 minutes = 36000 ticks + !byte $00 ; 1 minute = 3600 ticks + !byte $00 ; 10 seconds = 600 ticks + !byte $00 ; 1 second = 60 ticks -#else +} else { - .byte $23 // 10 hours = 2304000 ticks - .byte $03 // 1 hour = 230400 ticks - .byte $00 // 10 minutes = 38400 ticks - .byte $00 // 1 minute = 3840 ticks - .byte $00 // 10 seconds = 640 ticks - .byte $00 // 1 second = 64 ticks + !byte $23 ; 10 hours = 2304000 ticks + !byte $03 ; 1 hour = 230400 ticks + !byte $00 ; 10 minutes = 38400 ticks + !byte $00 ; 1 minute = 3840 ticks + !byte $00 ; 10 seconds = 640 ticks + !byte $00 ; 1 second = 64 ticks -#endif \ No newline at end of file +} diff --git a/src/basic/assets/table_ti_lo.s b/src/basic/assets/table_ti_lo.s index 4f7ef5ae..2ad13a79 100644 --- a/src/basic/assets/table_ti_lo.s +++ b/src/basic/assets/table_ti_lo.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Table to TI$ special variable support -// +; +; Table to TI$ special variable support +; table_TI_lo: -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { - .byte $80 // 10 hours = 2169000 ticks - .byte $C0 // 1 hour = 216000 ticks - .byte $A0 // 10 minutes = 36000 ticks - .byte $10 // 1 minute = 3600 ticks - .byte $58 // 10 seconds = 600 ticks - .byte $3C // 1 second = 60 ticks + !byte $80 ; 10 hours = 2169000 ticks + !byte $C0 ; 1 hour = 216000 ticks + !byte $A0 ; 10 minutes = 36000 ticks + !byte $10 ; 1 minute = 3600 ticks + !byte $58 ; 10 seconds = 600 ticks + !byte $3C ; 1 second = 60 ticks -#else +} else { - .byte $00 // 10 hours = 2304000 ticks - .byte $00 // 1 hour = 230400 ticks - .byte $00 // 10 minutes = 38400 ticks - .byte $00 // 1 minute = 3840 ticks - .byte $80 // 10 seconds = 640 ticks - .byte $40 // 1 second = 64 ticks + !byte $00 ; 10 hours = 2304000 ticks + !byte $00 ; 1 hour = 230400 ticks + !byte $00 ; 10 minutes = 38400 ticks + !byte $00 ; 1 minute = 3840 ticks + !byte $80 ; 10 seconds = 640 ticks + !byte $40 ; 1 second = 64 ticks -#endif +} diff --git a/src/basic/assets/table_ti_mid.s b/src/basic/assets/table_ti_mid.s index 22b38fb8..1d816dfe 100644 --- a/src/basic/assets/table_ti_mid.s +++ b/src/basic/assets/table_ti_mid.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Table to TI$ special variable support -// +; +; Table to TI$ special variable support +; table_TI_mid: -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { - .byte $F5 // 10 hours = 2169000 ticks - .byte $4B // 1 hour = 216000 ticks - .byte $8C // 10 minutes = 36000 ticks - .byte $0E // 1 minute = 3600 ticks - .byte $02 // 10 seconds = 600 ticks - .byte $00 // 1 second = 60 ticks + !byte $F5 ; 10 hours = 2169000 ticks + !byte $4B ; 1 hour = 216000 ticks + !byte $8C ; 10 minutes = 36000 ticks + !byte $0E ; 1 minute = 3600 ticks + !byte $02 ; 10 seconds = 600 ticks + !byte $00 ; 1 second = 60 ticks -#else +} else { - .byte $28 // 10 hours = 2304000 ticks - .byte $84 // 1 hour = 230400 ticks - .byte $96 // 10 minutes = 38400 ticks - .byte $0F // 1 minute = 3840 ticks - .byte $02 // 10 seconds = 640 ticks - .byte $00 // 1 second = 64 ticks + !byte $28 ; 10 hours = 2304000 ticks + !byte $84 ; 1 hour = 230400 ticks + !byte $96 ; 10 minutes = 38400 ticks + !byte $0F ; 1 minute = 3840 ticks + !byte $02 ; 10 seconds = 640 ticks + !byte $00 ; 1 second = 64 ticks -#endif +} diff --git a/src/basic/basic_commands/cmd__jumptable.s b/src/basic/basic_commands/cmd__jumptable.s index 3f541ef8..a521f1e4 100644 --- a/src/basic/basic_commands/cmd__jumptable.s +++ b/src/basic/basic_commands/cmd__jumptable.s @@ -1,96 +1,86 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for BASIC V2 dialect commands -// +; +; Jumptable for BASIC V2 dialect commands +; +!set ITEM_80 = cmd_end +!set ITEM_81 = cmd_for +!set ITEM_82 = cmd_next +!set ITEM_83 = cmd_data +!set ITEM_84 = cmd_inputhash +!set ITEM_85 = cmd_input +!set ITEM_86 = array_create ; cmd_dim +!set ITEM_87 = cmd_read +!set ITEM_88 = assign_variable ; cmd_let +!set ITEM_89 = cmd_goto +!set ITEM_8A = cmd_run +!set ITEM_8B = cmd_if +!set ITEM_8C = do_restore ; cmd_restore +!set ITEM_8D = cmd_gosub +!set ITEM_8E = cmd_return +!set ITEM_8F = cmd_rem -.const command_list = List().add( +!set ITEM_90 = cmd_stop +!set ITEM_91 = cmd_on +!set ITEM_92 = cmd_wait +!set ITEM_93 = cmd_load +!set ITEM_94 = cmd_save +!set ITEM_95 = cmd_verify +!set ITEM_96 = cmd_def +!set ITEM_97 = cmd_poke +!set ITEM_98 = cmd_printhash +!set ITEM_99 = cmd_print +!set ITEM_9A = cmd_cont +!set ITEM_9B = cmd_list +!set ITEM_9C = do_clr ; cmd_clr +!set ITEM_9D = cmd_cmd +!set ITEM_9E = cmd_sys +!set ITEM_9F = cmd_open - // $80 - $8F - - cmd_end, - cmd_for, - cmd_next, - cmd_data, - cmd_inputhash, - cmd_input, - array_create, // cmd_dim - cmd_read, - assign_variable, // cmd_let - cmd_goto, - cmd_run, - cmd_if, - do_restore, // cmd_restore - cmd_gosub, - cmd_return, - cmd_rem, - - // $90-$9F - - cmd_stop, - cmd_on, - cmd_wait, - cmd_load, - cmd_save, - cmd_verify, - cmd_def, - cmd_poke, - cmd_printhash, - cmd_print, - cmd_cont, - cmd_list, - do_clr, // cmd_clr - cmd_cmd, - cmd_sys, - cmd_open, - - // $A0-$A6 - - cmd_close, - cmd_get, - cmd_new, - 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 +!set ITEM_A0 = cmd_close +!set ITEM_A1 = cmd_get +!set ITEM_A2 = cmd_new +!set ITEM_A3 = cmd_tab ; XXX this token probably does not belong here +!set ITEM_A4 = do_SYNTAX_error ; 'TO' is not a standalone command +!set ITEM_A5 = do_SYNTAX_error ; 'FN' is not a standalone command +!set ITEM_A6 = 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 + ; 'THEN' ($A7) and 'STEP' ($A9) are not standalone commands + ; 'NOT' ($A8) is an operator, not a command - // 'GO' ($CB) is handled separately -) + ; 'GO' ($CB) is handled separately -#if !HAS_OPCODES_65C02 - +!ifndef HAS_OPCODES_65C02 { command_jumptable_lo: - put_jumptable_lo(command_list) - + !byte <(ITEM_80-1), <(ITEM_81-1), <(ITEM_82-1), <(ITEM_83-1), <(ITEM_84-1), <(ITEM_85-1), <(ITEM_86-1), <(ITEM_87-1) + !byte <(ITEM_88-1), <(ITEM_89-1), <(ITEM_8A-1), <(ITEM_8B-1), <(ITEM_8C-1), <(ITEM_8D-1), <(ITEM_8E-1), <(ITEM_8F-1) + !byte <(ITEM_90-1), <(ITEM_91-1), <(ITEM_92-1), <(ITEM_93-1), <(ITEM_94-1), <(ITEM_95-1), <(ITEM_96-1), <(ITEM_97-1) + !byte <(ITEM_98-1), <(ITEM_99-1), <(ITEM_9A-1), <(ITEM_9B-1), <(ITEM_9C-1), <(ITEM_9D-1), <(ITEM_9E-1), <(ITEM_9F-1) + !byte <(ITEM_A0-1), <(ITEM_A1-1), <(ITEM_A2-1), <(ITEM_A3-1), <(ITEM_A4-1), <(ITEM_A5-1), <(ITEM_A6-1) command_jumptable_hi: - put_jumptable_hi(command_list) + !byte >(ITEM_80-1), >(ITEM_81-1), >(ITEM_82-1), >(ITEM_83-1), >(ITEM_84-1), >(ITEM_85-1), >(ITEM_86-1), >(ITEM_87-1) + !byte >(ITEM_88-1), >(ITEM_89-1), >(ITEM_8A-1), >(ITEM_8B-1), >(ITEM_8C-1), >(ITEM_8D-1), >(ITEM_8E-1), >(ITEM_8F-1) + !byte >(ITEM_90-1), >(ITEM_91-1), >(ITEM_92-1), >(ITEM_93-1), >(ITEM_94-1), >(ITEM_95-1), >(ITEM_96-1), >(ITEM_97-1) + !byte >(ITEM_98-1), >(ITEM_99-1), >(ITEM_9A-1), >(ITEM_9B-1), >(ITEM_9C-1), >(ITEM_9D-1), >(ITEM_9E-1), >(ITEM_9F-1) + !byte >(ITEM_A0-1), >(ITEM_A1-1), >(ITEM_A2-1), >(ITEM_A3-1), >(ITEM_A4-1), >(ITEM_A5-1), >(ITEM_A6-1) - -#else // HAS_OPCODES_65C02 - - -__before_command_jumptable: - -.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary +} else { ; HAS_OPCODES_65C02 command_jumptable: - put_jumptable(command_list) + ; Note: 65C02 has the page boundary vector bug fixed! - // Make sure routine size is always the same - build system limitation - -.if (__before_command_jumptable == command_jumptable) { brk } - - -#endif + !word ITEM_80, ITEM_81, ITEM_82, ITEM_83, ITEM_84, ITEM_85, ITEM_86, ITEM_87 + !word ITEM_88, ITEM_89, ITEM_8A, ITEM_8B, ITEM_8C, ITEM_8D, ITEM_8E, ITEM_8F + !word ITEM_90, ITEM_91, ITEM_92, ITEM_93, ITEM_94, ITEM_95, ITEM_96, ITEM_97 + !word ITEM_98, ITEM_99, ITEM_9A, ITEM_9B, ITEM_9C, ITEM_9D, ITEM_9E, ITEM_9F + !word ITEM_A0, ITEM_A1, ITEM_A2, ITEM_A3, ITEM_A4, ITEM_A5, ITEM_A6 +} diff --git a/src/basic/basic_commands/cmd__unimplemented.s b/src/basic/basic_commands/cmd__unimplemented.s index 9b76d5f6..37366ea2 100644 --- a/src/basic/basic_commands/cmd__unimplemented.s +++ b/src/basic/basic_commands/cmd__unimplemented.s @@ -1,55 +1,55 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Default handler for all not-yet-implemented commands -// -// Note: NOPs are here just to make debugging easier (no duplicated labels)! -// +; +; Default handler for all not-yet-implemented commands +; +; Note: NOPs are here just to make debugging easier (no duplicated labels)! +; cmd_for: - nop + +nop cmd_next: - nop + +nop cmd_data: - nop + +nop cmd_inputhash: - nop + +nop cmd_input: - nop + +nop cmd_read: - nop + +nop cmd_gosub: - nop + +nop cmd_return: - nop + +nop cmd_on: - nop + +nop cmd_wait: - nop + +nop cmd_def: - nop + +nop cmd_poke: - nop + +nop cmd_printhash: - nop + +nop cmd_cont: - nop + +nop cmd_cmd: - nop + +nop cmd_open: - nop + +nop cmd_close: - nop + +nop cmd_get: - nop + +nop cmd_tab: - nop + +nop cmd_spc: - nop + +nop - // Unimplemented tokens + ; Unimplemented tokens jmp do_NOT_IMPLEMENTED_error diff --git a/src/basic/basic_commands/cmd_clr.s b/src/basic/basic_commands/cmd_clr.s index 9305ec00..6554b554 100644 --- a/src/basic/basic_commands/cmd_clr.s +++ b/src/basic/basic_commands/cmd_clr.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// PLACEHOLDER for completeness - jumptable contains direct address +; PLACEHOLDER for completeness - jumptable contains direct address -// CLR command does not stop execution (confirmed on a C64) +; CLR command does not stop execution (confirmed on a C64) diff --git a/src/basic/basic_commands/cmd_dim.s b/src/basic/basic_commands/cmd_dim.s index cccb47e2..8d9470ca 100644 --- a/src/basic/basic_commands/cmd_dim.s +++ b/src/basic/basic_commands/cmd_dim.s @@ -1,6 +1,6 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// PLACEHOLDER for completeness - jumptable contains direct address +; PLACEHOLDER for completeness - jumptable contains direct address diff --git a/src/basic/basic_commands/cmd_go_goto_run.s b/src/basic/basic_commands/cmd_go_goto_run.s index 5bfb7281..4dbaf399 100644 --- a/src/basic/basic_commands/cmd_go_goto_run.s +++ b/src/basic/basic_commands/cmd_go_goto_run.s @@ -1,60 +1,60 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_go: jsr fetch_character_skip_spaces - cmp #$A4 // 'TO' keyword + cmp #$A4 ; 'TO' keyword beq cmd_goto -#if !ROM_LAYOUT_M65 +!ifndef CONFIG_MB_M65 { - // FALLTROUGH + ; FALLTROUGH cmd_go_syntax_error: jmp do_SYNTAX_error -#else +} else { - cmp #$9E // 'SYS' keyword, for 'GO SYS' - beq_16 cmd_gosys + cmp #$9E ; 'SYS' keyword, for 'GO SYS' + +beq cmd_gosys - dew TXTPTR // unconsume character + dew TXTPTR ; unconsume character - // Fetch desired mode + ; Fetch desired mode jsr fetch_uint8 cmp #64 - bne !+ + bne @1 - // If in native mode - switch to C64 compatibilty + ; If in native mode - switch to C64 compatibilty jsr M65_MODEGET bcs cmd_go_rts jsr helper_ask_if_sure - bcs_16 cmd_end + +bcs cmd_end sec - jsr M65_MODESET // Carry set = switch to C64 mode - jmp_8 cmd_go_switchmode_clr_banner -!: + jsr M65_MODESET ; Carry set = switch to C64 mode + +bra cmd_go_switchmode_clr_banner +@1: cmp #65 - bne_16 do_ILLEGAL_QUANTITY_error + +bne do_ILLEGAL_QUANTITY_error - // If in C64 compatibility mode - switch to native mode + ; 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 + +bcs cmd_end + jsr M65_MODESET ; Carry clear = switch to M65 mode - // FALLTROUGH + ; FALLTROUGH cmd_go_switchmode_clr_banner: @@ -62,7 +62,7 @@ cmd_go_switchmode_clr_banner: ldx CURLIN+1 inx - beq_16 INITMSG + +beq INITMSG lda #147 jmp JCHROUT @@ -70,90 +70,87 @@ cmd_go_switchmode_clr_banner: cmd_go_rts: rts - - -#endif +} cmd_run: - // RUN clears all variables + ; RUN clears all variables jsr do_clr - // Initialize OLDTXT pointer, disable Kernal messages + ; Initialize OLDTXT pointer, disable Kernal messages jsr init_oldtxt lda #$00 jsr JSETMSG - // Check if we have any paramenters + ; Check if we have any paramenters jsr is_end_of_statement bcs cmd_run_goto_launch - // FALLTROUGH + ; FALLTROUGH cmd_goto: - // GOTO requires line number - // XXX in case of no parameter, go to line 0 - checked with original ROMs - + ; 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 +!ifndef CONFIG_MB_M65 { bcs cmd_go_syntax_error -#else - bcs_16 do_SYNTAX_error -#endif +} else { + +bcs do_SYNTAX_error +} - // Check for direct mode + ; Check for direct mode lda CURLIN+1 bmi cmd_goto_direct - // Not a direct mode - compare desired line number (LINNUM) with the current one (CURLIN) + ; Not a direct mode - compare desired line number (LINNUM) with the current one (CURLIN) lda LINNUM+1 cmp CURLIN+1 - bne !+ + bne @2 lda LINNUM+0 cmp CURLIN+0 -!: - // If desired line number is lower - search line number from start +@2: + ; If desired line number is lower - search line number from start bcc cmd_goto_from_start - // Else - search from the current line + ; Else - search from the current line jsr find_line_from_current - jmp_8 cmd_goto_check + +bra cmd_goto_check cmd_goto_direct: - // Disable Kernal messages + ; Disable Kernal messages lda #$00 jsr JSETMSG - // FALLTROUGH + ; FALLTROUGH cmd_goto_from_start: - // Direct mode - find the line from the beginning + ; Direct mode - find the line from the beginning jsr find_line_from_start - // FALLTROUGH + ; FALLTROUGH cmd_goto_check: - bcs_16 do_UNDEFD_STATEMENT_error + +bcs do_UNDEFD_STATEMENT_error - // FALLTROUGH + ; FALLTROUGH cmd_run_goto_launch: - // Run it! + ; Run it! pha pha diff --git a/src/basic/basic_commands/cmd_if.s b/src/basic/basic_commands/cmd_if.s index 7e3a4488..4f821478 100644 --- a/src/basic/basic_commands/cmd_if.s +++ b/src/basic/basic_commands/cmd_if.s @@ -1,38 +1,37 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_if: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr helper_if_mega65 bcc cmd_if_true +} -#endif - - // Calculate expression + ; Calculate expression jsr FRMEVL - // Check the result - either string size or floating point 0 vs non-0 + ; Check the result - either string size or floating point 0 vs non-0 lda FAC1_exponent - beq_16 cmd_rem + +beq cmd_rem - // FALLTROUGH + ; FALLTROUGH cmd_if_true: - // Condition fulfilled - look for GOTO or THEN + ; Condition fulfilled - look for GOTO or THEN jsr fetch_character_skip_spaces - cmp #$89 // 'GOTO' - beq_16 cmd_goto + cmp #$89 ; 'GOTO' + +beq cmd_goto - cmp #$A7 // 'THEN' - bne_16 do_SYNTAX_error + cmp #$A7 ; 'THEN' + +bne do_SYNTAX_error pla pla diff --git a/src/basic/basic_commands/cmd_let.s b/src/basic/basic_commands/cmd_let.s index cccb47e2..8d9470ca 100644 --- a/src/basic/basic_commands/cmd_let.s +++ b/src/basic/basic_commands/cmd_let.s @@ -1,6 +1,6 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// PLACEHOLDER for completeness - jumptable contains direct address +; PLACEHOLDER for completeness - jumptable contains direct address diff --git a/src/basic/basic_commands/cmd_list.s b/src/basic/basic_commands/cmd_list.s index 6d7eecc3..b53c4eef 100644 --- a/src/basic/basic_commands/cmd_list.s +++ b/src/basic/basic_commands/cmd_list.s @@ -1,44 +1,43 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// LIST basic text. -// XXX - Does not currently support line number ranges +; LIST basic text. +; XXX - Does not currently support line number ranges cmd_list: - // Set current line pointer to start of memory + ; Set current line pointer to start of memory jsr init_oldtxt list_loop: ldy #1 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #2060 sta LINNUM+1 - bne cmd_sys_setup_call // always jumps + bne cmd_sys_setup_call ; always jumps cmd_sys_hack_not_needed: - // - // XXX End of hack - // + ; + ; XXX End of hack + ; - lda #IDX__EV2_0B // 'SYNTAX ERROR' + lda #IDX__EV2_0B ; 'SYNTAX ERROR' jsr fetch_uint16 - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error cmd_sys_setup_call: - lda #$4C // JMP opcode + lda #$4C ; JMP opcode sta USRPOK lda LINNUM+0 sta USRADD+0 lda LINNUM+1 sta USRADD+1 - // Setup the register values + ; Setup the register values lda SPREG pha ldy SYREG @@ -87,12 +86,13 @@ cmd_sys_setup_call: lda SAREG plp - // Call the routine. + ; Call the routine. jmp USRPOK - // - // XXX Temporary ugly hack to support 'SYS PI*656' - // + ; + ; XXX Temporary ugly hack to support 'SYS PI*656' + ; cmd_sys_hack_str: - .byte $FF, $AC, $36, $35, $36, $00 + + !byte $FF, $AC, $36, $35, $36, $00 diff --git a/src/basic/basic_commands/helper_if_mega65_38K.s b/src/basic/basic_commands/helper_if_mega65_38K.s index fd93f63e..1c77e940 100644 --- a/src/basic/basic_commands/helper_if_mega65_38K.s +++ b/src/basic/basic_commands/helper_if_mega65_38K.s @@ -1,41 +1,41 @@ -// #LAYOUT# M65 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_MEMORY_MODEL_38K +!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_if_mega65: - // Injest all spaces + ; Injest all spaces ldy #$00 -!: +@1: lda (TXTPTR), Y cmp #$20 - bne !+ + bne @2 inw TXTPTR - bra !- -!: + bra @1 +@2: - // Check for MEGA65 untokenized keyword + ; Check for MEGA65 untokenized keyword ldy #$05 -!: +@3: lda (TXTPTR), Y cmp str_mega65, Y - bne_16 helper_if_mega65_fail + +bne helper_if_mega65_fail dey - bpl !- + bpl @3 - // Increment TXTPTR by 6 + ; Increment TXTPTR by 6 clc lda TXTPTR+0 adc #$06 sta TXTPTR+0 - bcc !+ + bcc @4 inc TXTPTR+1 -!: - // Report successful check +@4: + ; Report successful check clc rts @@ -47,6 +47,5 @@ helper_if_mega65_fail: str_mega65: - .byte $4D, $45, $47, $41, $36, $35 - -#endif + !byte $4D, $45, $47, $41, $36, $35 +} diff --git a/src/basic/basic_commands/helper_if_mega65_46K_50K.s b/src/basic/basic_commands/helper_if_mega65_46K_50K.s index 24b76024..243ce3e3 100644 --- a/src/basic/basic_commands/helper_if_mega65_46K_50K.s +++ b/src/basic/basic_commands/helper_if_mega65_46K_50K.s @@ -1,54 +1,52 @@ -// #LAYOUT# M65 BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routine below banks out the main BASIC ROM! +; This has to go $E000 or above - routine below banks out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_if_mega65: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Injest all spaces + ; Injest all spaces ldy #$00 -!: +@1: lda (TXTPTR), Y cmp #$20 - bne !+ + bne @2 inw TXTPTR - bra !- -!: + bra @1 +@2: - // Check for MEGA65 untokenized keyword + ; Check for MEGA65 untokenized keyword ldy #$05 -!: +@3: lda (TXTPTR), Y cmp str_mega65, Y - bne_16 remap_BASIC_sec_rts + +bne remap_BASIC_sec_rts dey - bpl !- + bpl @3 - // Increment TXTPTR by 6 + ; Increment TXTPTR by 6 clc lda TXTPTR+0 adc #$06 sta TXTPTR+0 - bcc !+ + bcc @4 inc TXTPTR+1 -!: - // Report successful check +@4: + ; Report successful check jmp remap_BASIC_clc_rts str_mega65: - .byte $4D, $45, $47, $41, $36, $35 - - -#endif + !byte $4D, $45, $47, $41, $36, $35 +} diff --git a/src/basic/basic_commands/helper_load_fetch_devnum.s b/src/basic/basic_commands/helper_load_fetch_devnum.s index 5b6f66e4..5781fbcd 100644 --- a/src/basic/basic_commands/helper_load_fetch_devnum.s +++ b/src/basic/basic_commands/helper_load_fetch_devnum.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tries to fetch device number - sets Carry if failure -// +; +; Tries to fetch device number - sets Carry if failure +; helper_load_fetch_devnum: - // Fetch the device number + ; Fetch the device number jsr fetch_coma_uint8 - bcs !+ + bcs @1 sta FA -!: +@1: rts diff --git a/src/basic/basic_commands/helper_load_fetch_filename.s b/src/basic/basic_commands/helper_load_fetch_filename.s index 367b4cbf..256957c2 100644 --- a/src/basic/basic_commands/helper_load_fetch_filename.s +++ b/src/basic/basic_commands/helper_load_fetch_filename.s @@ -1,27 +1,27 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches file name, Carry set if not found -// +; +; Fetches file name, Carry set if not found +; helper_load_fetch_filename: - // Check if end of statement + ; Check if end of statement jsr is_end_of_statement - bcs !+ + bcs @1 - // Call the expression parser, make sure it returned a string + ; Call the expression parser, make sure it returned a string jsr FRMEVL lda VALTYP - bpl_16 do_SYNTAX_error + +bpl do_SYNTAX_error - // Set the filename address and pointer + ; Set the filename address and pointer lda __FAC1+0 sta FNLEN @@ -31,11 +31,11 @@ helper_load_fetch_filename: lda __FAC1+2 sta FNADDR+1 - // Mark success + ; Mark success clc - // FALLTROUGH + ; FALLTROUGH -!: +@1: rts diff --git a/src/basic/basic_commands/helper_load_fetch_secondary.s b/src/basic/basic_commands/helper_load_fetch_secondary.s index 89212e12..3fbfa94a 100644 --- a/src/basic/basic_commands/helper_load_fetch_secondary.s +++ b/src/basic/basic_commands/helper_load_fetch_secondary.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tries to fetch secondary address - sets Carry if failure -// +; +; Tries to fetch secondary address - sets Carry if failure +; helper_load_fetch_secondary: - // Fetch the device number + ; Fetch the device number jsr fetch_coma_uint8 - bcs !+ + bcs @1 sta SA -!: +@1: rts diff --git a/src/basic/basic_commands/helper_load_init_param.s b/src/basic/basic_commands/helper_load_init_param.s index e070b2be..68a225d2 100644 --- a/src/basic/basic_commands/helper_load_init_param.s +++ b/src/basic/basic_commands/helper_load_init_param.s @@ -1,27 +1,27 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Sets initial parameters for LOAD and simiar commands -// -// Input: -// - VERCKB content in .A -// +; +; Sets initial parameters for LOAD and simiar commands +; +; Input: +; - VERCKB content in .A +; helper_load_init_params: - // Set LOAD/VERIFY flag + ; Set LOAD/VERIFY flag sta VERCKB - // FALLTROUGH + ; FALLTROUGH helper_load_init_params_no_VERCKB: - // Set default device, set secondary address to 0 + ; Set default device, set secondary address to 0 jsr SELDEV - ldy #$00 // secondary address + ldy #$00 ; secondary address jmp JSETFLS diff --git a/src/basic/basic_commands/helper_load_setnam_any.s b/src/basic/basic_commands/helper_load_setnam_any.s index b702ed98..3f397457 100644 --- a/src/basic/basic_commands/helper_load_setnam_any.s +++ b/src/basic/basic_commands/helper_load_setnam_any.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Set '*' as file name -// +; +; Set '*' as file name +; helper_load_setnam_any: - lda #$01 // name length + lda #$01 ; name length ldx #filename_any jmp JSETNAM diff --git a/src/basic/basic_commands/helper_print_string_46K_50K.s b/src/basic/basic_commands/helper_print_string_46K_50K.s index 4902509e..98d956ca 100644 --- a/src/basic/basic_commands/helper_print_string_46K_50K.s +++ b/src/basic/basic_commands/helper_print_string_46K_50K.s @@ -1,27 +1,26 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routine below banks out the main BASIC ROM! +; This has to go $E000 or above - routine below banks out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_print_string: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Print the string + ; Print the string ldy #$00 -!: +@1: cpy __FAC1 + 0 - beq_16 remap_BASIC // branch if end of the string + +beq remap_BASIC ; branch if end of the string lda (__FAC1 + 1), y jsr JCHROUT iny - bpl !- - -#endif + bpl @1 +} diff --git a/src/basic/basic_commands_01/cmd__jumptable_01.s b/src/basic/basic_commands_01/cmd__jumptable_01.s index 269ff014..12152493 100644 --- a/src/basic/basic_commands_01/cmd__jumptable_01.s +++ b/src/basic/basic_commands_01/cmd__jumptable_01.s @@ -1,55 +1,53 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for BASIC commands with tokens prefixed by $01 -// +; +; Jumptable for BASIC commands with tokens prefixed by $01 +; + +!ifdef CONFIG_MB_M65 { + +!set ITEM_00 = M65_SLOW +!set ITEM_01 = M65_FAST + +} else { + +!set ITEM_00 = cmd_slow +!set ITEM_01 = cmd_fast + +} + +!set ITEM_02 = cmd_old + + ; NOTE! These commands are temporarily placed here, they should be a part of list 02! + +!set ITEM_03 = cmd_merge + +!set ITEM_04 = cmd_bload +!set ITEM_05 = cmd_bsave +!set ITEM_06 = cmd_bverify + +!set ITEM_07 = cmd_clear +!set ITEM_08 = varstr_garbage_collect ; cmd_dispose -.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! - - cmd_merge, - - cmd_bload, - cmd_bsave, - cmd_bverify, - - cmd_clear, - varstr_garbage_collect // cmd_dispose -) - - -#if !HAS_OPCODES_65C02 - +!ifndef HAS_OPCODES_65C02 { command_01_jumptable_lo: - put_jumptable_lo(command_01_list) + !byte <(ITEM_00-1), <(ITEM_01-1), <(ITEM_02-1), <(ITEM_03-1), <(ITEM_04-1), <(ITEM_05-1), <(ITEM_06-1), <(ITEM_07-1), <(ITEM_08-1) command_01_jumptable_hi: - put_jumptable_hi(command_01_list) + !byte >(ITEM_00-1), >(ITEM_01-1), >(ITEM_02-1), >(ITEM_03-1), >(ITEM_04-1), >(ITEM_05-1), >(ITEM_06-1), >(ITEM_07-1), >(ITEM_08-1) - -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 command_01_jumptable: - // Note: 65C02 has the page boundary vector bug fixed! - put_jumptable(command_01_list) + ; Note: 65C02 has the page boundary vector bug fixed! -#endif + !word ITEM_00, ITEM_01, ITEM_02, ITEM_03, ITEM_04, ITEM_05, ITEM_06, ITEM_07, ITEM_08 +} diff --git a/src/basic/basic_commands_01/cmd_fast_slow.s b/src/basic/basic_commands_01/cmd_fast_slow.s index bd740ee3..8789c50a 100644 --- a/src/basic/basic_commands_01/cmd_fast_slow.s +++ b/src/basic/basic_commands_01/cmd_fast_slow.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { - // For MEGA65 Kernal routines are called directly + ; For MEGA65 Kernal routines are called directly -#elif CONFIG_MB_ULTIMATE_64 +} else ifdef CONFIG_MB_U64 { - // Command implementation for Ultimate 64 - SuperCPU compatible way should be enough + ; Command implementation for Ultimate 64 - SuperCPU compatible way should be enough cmd_slow: @@ -21,41 +21,44 @@ cmd_fast: sta SCPU_SPEED_TURBO rts -#elif CONFIG_PLATFORM_COMMODORE_64 +} else ifdef CONFIG_PLATFORM_COMMODORE_64 { - // Command implementation for generic C64 platform + ; Command implementation for generic C64 platform cmd_slow: - // Try to disable turbo in SuperCPU compatible way + ; Try to disable turbo in SuperCPU compatible way sta SCPU_SPEED_NORMAL - // Try to disable turbo mode in C128 compatible way + ; Try to disable turbo mode in C128 compatible way lda #$00 - beq !+ // branch always + beq cmdfastslow_end ; branch always cmd_fast: - // Try to enable turbo in SuperCPU compatible way + ; Try to enable turbo in SuperCPU compatible way sta SCPU_SPEED_TURBO - // Try to enable turbo mode in C128 compatible way + ; Try to enable turbo mode in C128 compatible way lda #$01 -!: + + ; FALLTROUGH + +cmdfastslow_end: + sta VIC_CLKRATE rts -#else +} else { cmd_slow: - nop // just to prevent double label + nop ; just to prevent double label - // FALLTROUGH + ; FALLTROUGH cmd_fast: jmp do_NOT_IMPLEMENTED_error - -#endif +} diff --git a/src/basic/basic_commands_01/cmd_old.s b/src/basic/basic_commands_01/cmd_old.s index 1eeca8e9..6d2d4f9d 100644 --- a/src/basic/basic_commands_01/cmd_old.s +++ b/src/basic/basic_commands_01/cmd_old.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_old: - // First make sure we are in direct mode + ; First make sure we are in direct mode ldx CURLIN+1 inx - bne_16 do_DIRECT_MODE_ONLY_error + +bne do_DIRECT_MODE_ONLY_error - // Now try to restore program linkage and VARTAB + ; Now try to restore program linkage and VARTAB ldy #$01 tya @@ -19,6 +19,6 @@ cmd_old: jsr update_LINKPRG_VARTAB_do_clr - // Quit + ; Quit jmp end_of_program diff --git a/src/basic/basic_commands_02/cmd__jumptable_02.s b/src/basic/basic_commands_02/cmd__jumptable_02.s index 32285618..deb3dc4d 100644 --- a/src/basic/basic_commands_02/cmd__jumptable_02.s +++ b/src/basic/basic_commands_02/cmd__jumptable_02.s @@ -1,52 +1,44 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for BASIC commands with tokens prefixed by $02 -// +; +; Jumptable for BASIC commands with tokens prefixed by $02 +; -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { -.const command_02_list = List().add( + ; NOTE! These commands are temporarily placed in list 01! - // NOTE! These commands are temporarily placed in list 01! + ; cmd_merge, - // cmd_merge, + ; cmd_bload, + ; cmd_bsave, + ; cmd_bverify, - // cmd_bload, - // cmd_bsave, - // cmd_bverify, + ; cmd_clear, + ; varstr_garbage_collect, ; cmd_dispose - // cmd_clear, - // varstr_garbage_collect, // cmd_dispose - - cmd_cold, - cmd_mem, - cmd_sysinfo -) +!set ITEM_00 = cmd_cold +!set ITEM_01 = cmd_mem +!set ITEM_02 = cmd_sysinfo -#if !HAS_OPCODES_65C02 - +!ifndef HAS_OPCODES_65C02 { command_02_jumptable_lo: - put_jumptable_lo(command_02_list) - + !byte <(ITEM_00-1), <(ITEM_01-1), <(ITEM_02-1) command_02_jumptable_hi: - put_jumptable_hi(command_02_list) + !byte >(ITEM_00-1), >(ITEM_01-1), >(ITEM_02-1) - -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 command_02_jumptable: - // Note: 65C02 has the page boundary vector bug fixed! - put_jumptable(command_02_list) + ; Note: 65C02 has the page boundary vector bug fixed! -#endif - -#endif + !word ITEM_00, ITEM_01, ITEM_02 +} } diff --git a/src/basic/basic_commands_02/cmd_bload_bverify.s b/src/basic/basic_commands_02/cmd_bload_bverify.s index 149e7caa..87ab76d8 100644 --- a/src/basic/basic_commands_02/cmd_bload_bverify.s +++ b/src/basic/basic_commands_02/cmd_bload_bverify.s @@ -1,42 +1,42 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_bverify: - // LOAD and VERIFY are very similar, from BASIC perspective there is almost no difference; - // just different parameter passed to Kernal and different error message in case of failure + ; LOAD and VERIFY are very similar, from BASIC perspective there is almost no difference; + ; just different parameter passed to Kernal and different error message in case of failure - lda #$01 // mark operation as VERIFY - skip_2_bytes_trash_nvz + lda #$01 ; mark operation as VERIFY + +skip_2_bytes_trash_nvz cmd_bload: - lda #$00 // mark operation as LOAD + lda #$00 ; mark operation as LOAD jsr helper_load_init_params - // Fetch the file name + ; Fetch the file name jsr helper_bload_fetch_filename - // Fetch device number + ; Fetch device number jsr fetch_coma_uint8 - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error sta FA - // Fetch the start address + ; Fetch the start address jsr helper_bload_fetch_address - // Perform loading + ; Perform loading - lda VERCKB // LOAD or VERIFY + lda VERCKB ; LOAD or VERIFY jsr JLOAD - bcs_16 do_kernal_error + +bcs do_kernal_error - // Execute next statement + ; Execute next statement rts diff --git a/src/basic/basic_commands_02/cmd_bsave.s b/src/basic/basic_commands_02/cmd_bsave.s index 1e2dbdf8..f702a295 100644 --- a/src/basic/basic_commands_02/cmd_bsave.s +++ b/src/basic/basic_commands_02/cmd_bsave.s @@ -1,32 +1,32 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_bsave: - // Set default device and secondary address + ; Set default device and secondary address jsr helper_load_init_params_no_VERCKB - // Fetch the file name + ; Fetch the file name jsr helper_load_fetch_filename - bcs_16 do_MISSING_FILENAME_error + +bcs do_MISSING_FILENAME_error - // Fetch device number + ; Fetch device number jsr helper_load_fetch_devnum - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - // Fetch memory area start address + ; Fetch memory area start address jsr helper_bload_fetch_address - phx_trash_a - phy_trash_a + +phx_trash_a + +phy_trash_a - // Fetch memory area end address + ; Fetch memory area end address jsr helper_bload_fetch_address @@ -37,6 +37,6 @@ cmd_bsave: lda #LINNUM - // Perform SAVE - reuse regular command + ; Perform SAVE - reuse regular command jmp cmd_save_do diff --git a/src/basic/basic_commands_02/cmd_clear.s b/src/basic/basic_commands_02/cmd_clear.s index ef71e4ff..a4af3508 100644 --- a/src/basic/basic_commands_02/cmd_clear.s +++ b/src/basic/basic_commands_02/cmd_clear.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_clear: - // XXX in the future add separate implementation for graphics screen + ; XXX in the future add separate implementation for graphics screen jmp clear_screen diff --git a/src/basic/basic_commands_02/cmd_cold.s b/src/basic/basic_commands_02/cmd_cold.s index 21f9cc05..474f6b47 100644 --- a/src/basic/basic_commands_02/cmd_cold.s +++ b/src/basic/basic_commands_02/cmd_cold.s @@ -1,18 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { cmd_cold: jsr helper_ask_if_sure - bcs !+ + bcs @1 - jsr JCLALL // for extra safety - jmp (vector_reset) // hardware CPU vector -!: + jsr JCLALL ; for extra safety + jmp (vector_reset) ; hardware CPU vector +@1: rts - -#endif +} diff --git a/src/basic/basic_commands_02/cmd_dispose.s b/src/basic/basic_commands_02/cmd_dispose.s index cccb47e2..8d9470ca 100644 --- a/src/basic/basic_commands_02/cmd_dispose.s +++ b/src/basic/basic_commands_02/cmd_dispose.s @@ -1,6 +1,6 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// PLACEHOLDER for completeness - jumptable contains direct address +; PLACEHOLDER for completeness - jumptable contains direct address diff --git a/src/basic/basic_commands_02/cmd_mem.s b/src/basic/basic_commands_02/cmd_mem.s index debd0e0c..19c53e03 100644 --- a/src/basic/basic_commands_02/cmd_mem.s +++ b/src/basic/basic_commands_02/cmd_mem.s @@ -1,81 +1,85 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { -#if (!ROM_LAYOUT_M65 || SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { cmd_mem: - // First perform the garbage collection - to be able to determine real values + ; First perform the garbage collection - to be able to determine real values jsr varstr_garbage_collect -#endif // ROM layout -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) + jsr map_BASIC_1 + jsr (VB1__cmd_mem_cont) + jmp map_NORMAL - jsr map_BASIC_1 - jsr_ind VB1__cmd_mem_cont - jmp map_NORMAL - -#else - -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_1) +} else ifdef SEGMENT_M65_BASIC_1 { cmd_mem_cont: -#endif +} else { - // Print header +cmd_mem: + + ; First perform the garbage collection - to be able to determine real values + + jsr varstr_garbage_collect +} + +!ifndef SEGMENT_M65_BASIC_0 { + + ; Print header lda #$12 jsr JCHROUT ldx #IDX__STR_MEM_HDR jsr print_packed_misc_str - // Print all the information, in a loop, in reverse order + ; Print all the information, in a loop, in reverse order ldy #$04 - // FALLTROUGH + ; FALLTROUGH cmd_mem_loop: - // First print the information string + ; First print the information string ldx helper_mem_tab_str, y - phy_trash_a + +phy_trash_a jsr print_packed_misc_str - // Print start address + ; Print start address ldx #IDX__STR_MEM_1 jsr print_packed_misc_str -#if HAS_OPCODES_65C02 +!ifdef HAS_OPCODES_65C02 { ply phy -#else +} else { pla pha tay -#endif +} ldx helper_mem_tab_y, y lda $01, x jsr print_hex_byte -#if HAS_OPCODES_65C02 +!ifdef HAS_OPCODES_65C02 { ply phy -#else +} else { pla pha tay -#endif +} ldx helper_mem_tab_y, y lda $00, x jsr print_hex_byte @@ -84,22 +88,22 @@ cmd_mem_loop: ldx #IDX__STR_MEM_2 jsr print_packed_misc_str - // Fetch addresses of zeropage variables + ; Fetch addresses of zeropage variables -#if HAS_OPCODES_65C02 +!ifdef HAS_OPCODES_65C02 { ply phy -#else +} else { pla pha tay -#endif +} ldx helper_mem_tab_x, y lda helper_mem_tab_y, y tay - // Print difference between two zeropage variables + ; Print difference between two zeropage variables sec lda $00, x @@ -110,40 +114,40 @@ cmd_mem_loop: lda $00, x sbc $0000, y -#if HAS_OPCODES_65C02 +!ifdef HAS_OPCODES_65C02 { plx -#else +} else { tay pla tax tya -#endif +} - // Before printing, make sure the result is not negative + ; Before printing, make sure the result is not negative - bcs !+ + bcs @1 lda #$3F jsr JCHROUT - jmp_8 cmd_mem_next + +bra cmd_mem_next -!: +@1: jsr print_integer - // FALLTROUGH + ; FALLTROUGH cmd_mem_next: - // Check if more iterations needed + ; Check if more iterations needed - ply_trash_a + +ply_trash_a dey bpl cmd_mem_loop - // Finish + ; Finish jmp print_return -#endif // ROM layout +} ; ROM layout -#endif // !HAS_SMALL_BASIC +} ; !HAS_SMALL_BASIC diff --git a/src/basic/basic_commands_02/cmd_merge.s b/src/basic/basic_commands_02/cmd_merge.s index dab2f34f..75e5bc44 100644 --- a/src/basic/basic_commands_02/cmd_merge.s +++ b/src/basic/basic_commands_02/cmd_merge.s @@ -1,47 +1,47 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE cmd_merge: - lda #$00 // mark operation as LOAD + lda #$00 ; mark operation as LOAD jsr helper_load_init_params - // Fetch the file name + ; Fetch the file name jsr helper_bload_fetch_filename - // Fetch device number + ; Fetch device number jsr helper_load_fetch_devnum - // FALLTROUGH + ; FALLTROUGH cmd_merge_got_params: - // Make sure VARTAB is correctly set + ; Make sure VARTAB is correctly set jsr update_VARTAB_do_clr - // Perform loading - just for a different address + ; Perform loading - just for a different address sec lda VARTAB+0 sbc #$02 sta VARTAB+0 tax - bcs !+ + bcs @1 dec VARTAB+1 -!: +@1: ldy VARTAB+1 - lda VERCKB // LOAD or VERIFY + lda VERCKB ; LOAD or VERIFY jsr JLOAD - bcs_16 do_kernal_error + +bcs do_kernal_error cmd_merge_no_error: - // Relink loaded program, clear variables, execute next statement + ; Relink loaded program, clear variables, execute next statement jmp update_LINKPRG_VARTAB_do_clr diff --git a/src/basic/basic_commands_02/cmd_sysinfo.s b/src/basic/basic_commands_02/cmd_sysinfo.s index 094b6996..27f5c5b3 100644 --- a/src/basic/basic_commands_02/cmd_sysinfo.s +++ b/src/basic/basic_commands_02/cmd_sysinfo.s @@ -1,32 +1,32 @@ -// #LAYOUT# M65 * #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# * * #IGNORE -#if SEGMENT_BASIC_0 +!ifdef SEGMENT_BASIC_0 { cmd_sysinfo: - jsr map_BASIC_1 - jsr_ind VB1__cmd_sysinfo - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__cmd_sysinfo) + jmp map_NORMAL -#else +} else { cmd_sysinfo: jsr print_return - // Print mode and build information + ; Print mode and build information ldx #IDX__STR_SI_HEADER jsr print_packed_misc_str jsr M65_MODEGET - bcc !+ + bcc @1 ldx #IDX__STR_SI_MODE64 - skip_2_bytes_trash_nvz -!: + +skip_2_bytes_trash_nvz +@1: ldx #IDX__STR_SI_MODE65 jsr print_packed_misc_str @@ -44,40 +44,40 @@ cmd_sysinfo: jsr print_return - // FALLTROUGH + ; FALLTROUGH print_sysinfo_banner: - // Print board type (information not accessible in native mode) + ; 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) -!: +@2: cmp cmd_sysinfo_hw_ids, y - beq !+ + beq @3 dey - bpl !- + bpl @2 ldy #(__cmd_sysinfo_hw_ids_end - cmd_sysinfo_hw_ids) -!: +@3: ldx cmd_sysinfo_hw_str, y phx jsr print_packed_misc_str plx cpx #IDX__STR_SI_HW_XX - bne !+ + bne @4 lda MISC_BOARDID jsr print_hex_byte -!: +@4: - // FALLTROUGH + ; FALLTROUGH print_sysinfo_video: - // Print video system information + ; Print video system information ldx #IDX__STR_SI_HDR_VID jsr print_packed_misc_str @@ -101,12 +101,12 @@ print_sysinfo_video: ldx #IDX__STR_NTSC lda TVSFLG - beq !+ + beq @5 ldx #IDX__STR_PAL -!: +@5: jsr print_packed_misc_str - // Print build featires information + ; Print build featires information ldx #IDX__STR_SI_FEATURES jmp print_packed_misc_str @@ -115,31 +115,28 @@ print_sysinfo_video: cmd_sysinfo_hw_ids: - .byte $01 - .byte $02 - .byte $03 - .byte $21 - .byte $40 - .byte $41 - .byte $42 - .byte $FD - .byte $FE + !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 + !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 +} diff --git a/src/basic/basic_commands_02/helper_ask_if_sure.s b/src/basic/basic_commands_02/helper_ask_if_sure.s index e274b38e..5f52d7b9 100644 --- a/src/basic/basic_commands_02/helper_ask_if_sure.s +++ b/src/basic/basic_commands_02/helper_ask_if_sure.s @@ -1,74 +1,74 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// For direct mode, asks the user if he is sure (sets Carry if not); -// otherwise returns with Carry clear -// +; +; For direct mode, asks the user if he is sure (sets Carry if not); +; otherwise returns with Carry clear +; -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { helper_ask_if_sure: -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { - jsr map_BASIC_1 - jsr_ind VB1__helper_ask_if_sure - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__helper_ask_if_sure) + jmp map_NORMAL -#else +} else { - // First check, if we are in direct mode,; if not, do not ask + ; First check, if we are in direct mode,; if not, do not ask ldx CURLIN+1 inx - bne helper_ask_if_sure_ok // branch if not direct mode + bne helper_ask_if_sure_ok ; branch if not direct mode - // Not direct mode - display the question + ; Not direct mode - display the question ldx #IDX__STR_IF_SURE jsr print_packed_misc_str - // Clear the keyboard queue + ; Clear the keyboard queue lda #$00 sta NDX - // Enable cursor, fetch the answer + ; Enable cursor, fetch the answer lda #$00 sta BLNSW -!: +@1: jsr JGETIN cmp #$00 - beq !- + beq @1 - // Check if 'Y' + ; Check if 'Y' cmp #$59 - beq !+ + beq @2 - lda #$4E // 'N' + lda #$4E ; 'N' jsr JCHROUT sec rts -!: - // Display 'Y' and wait a short moment for a better user experience +@2: + ; Display 'Y' and wait a short moment for a better user experience jsr JCHROUT clc lda TIME+2 adc #$0C -!: +@3: cmp TIME+2 - bne !- + bne @3 - // FALLTROUGH + ; FALLTROUGH helper_ask_if_sure_ok: @@ -76,6 +76,6 @@ helper_ask_if_sure_ok: rts -#endif // ROM layout +} ; ROM layout -#endif // !HAS_SMALL_BASIC +} ; !HAS_SMALL_BASIC diff --git a/src/basic/basic_commands_02/helper_bload_fetch_address.s b/src/basic/basic_commands_02/helper_bload_fetch_address.s index e4a28e6d..f3ab147f 100644 --- a/src/basic/basic_commands_02/helper_bload_fetch_address.s +++ b/src/basic/basic_commands_02/helper_bload_fetch_address.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches address for BLOAD/BVERIFY/BSAVE, reports error if not found -// +; +; Fetches address for BLOAD/BVERIFY/BSAVE, reports error if not found +; helper_bload_fetch_address: jsr injest_comma - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - lda #IDX__EV2_0B // 'SYNTAX ERROR' + lda #IDX__EV2_0B ; 'SYNTAX ERROR' jsr fetch_uint16 - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error ldx LINNUM+0 ldy LINNUM+1 diff --git a/src/basic/basic_commands_02/helper_bload_fetch_filename.s b/src/basic/basic_commands_02/helper_bload_fetch_filename.s index 13da848c..e1b238de 100644 --- a/src/basic/basic_commands_02/helper_bload_fetch_filename.s +++ b/src/basic/basic_commands_02/helper_bload_fetch_filename.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches file name for BLOAD/BVERIFY/MERGE, reports error if not found -// +; +; Fetches file name for BLOAD/BVERIFY/MERGE, reports error if not found +; helper_bload_fetch_filename: - // Fetch the file name + ; Fetch the file name jsr helper_load_fetch_filename - bcc !+ + bcc @1 - // No filename supplied - this should only be allowed for tape (device number below 8) + ; No filename supplied - this should only be allowed for tape (device number below 8) lda FA and #%11111000 - bne_16 do_MISSING_FILENAME_error + +bne do_MISSING_FILENAME_error lda #$00 sta FNLEN -!: +@1: rts diff --git a/src/basic/basic_commands_02/helper_mem_tab_str.s b/src/basic/basic_commands_02/helper_mem_tab_str.s index 8bf56176..eca887b1 100644 --- a/src/basic/basic_commands_02/helper_mem_tab_str.s +++ b/src/basic/basic_commands_02/helper_mem_tab_str.s @@ -1,20 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper table for 'MEM' command - list of strings to print -// +; +; Helper table for 'MEM' command - list of strings to print +; -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { helper_mem_tab_str: - .byte IDX__STR_MEM_FREE - .byte IDX__STR_MEM_STRS - .byte IDX__STR_MEM_ARRS - .byte IDX__STR_MEM_VARS - .byte IDX__STR_MEM_TEXT - -#endif \ No newline at end of file + !byte IDX__STR_MEM_FREE + !byte IDX__STR_MEM_STRS + !byte IDX__STR_MEM_ARRS + !byte IDX__STR_MEM_VARS + !byte IDX__STR_MEM_TEXT +} diff --git a/src/basic/basic_commands_02/helper_mem_tab_x.s b/src/basic/basic_commands_02/helper_mem_tab_x.s index ec74d04a..825d0a59 100644 --- a/src/basic/basic_commands_02/helper_mem_tab_x.s +++ b/src/basic/basic_commands_02/helper_mem_tab_x.s @@ -1,20 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper table for 'MEM' command - list of minuend zeropage variables -// +; +; Helper table for 'MEM' command - list of minuend zeropage variables +; -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { helper_mem_tab_x: - .byte FRETOP - .byte MEMSIZ - .byte STREND - .byte ARYTAB - .byte VARTAB - -#endif + !byte FRETOP + !byte MEMSIZ + !byte STREND + !byte ARYTAB + !byte VARTAB +} diff --git a/src/basic/basic_commands_02/helper_mem_tab_y.s b/src/basic/basic_commands_02/helper_mem_tab_y.s index d8a02f22..083817d8 100644 --- a/src/basic/basic_commands_02/helper_mem_tab_y.s +++ b/src/basic/basic_commands_02/helper_mem_tab_y.s @@ -1,20 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper table for 'MEM' command - list of subtrahend zeropage variables -// +; +; Helper table for 'MEM' command - list of subtrahend zeropage variables +; -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { helper_mem_tab_y: - .byte STREND - .byte FRETOP - .byte ARYTAB - .byte VARTAB - .byte TXTTAB - -#endif + !byte STREND + !byte FRETOP + !byte ARYTAB + !byte VARTAB + !byte TXTTAB +} diff --git a/src/basic/basic_commands_03_m65/cmd__jumptable_03.s b/src/basic/basic_commands_03_m65/cmd__jumptable_03.s index 4af16cb7..cd3b7b54 100644 --- a/src/basic/basic_commands_03_m65/cmd__jumptable_03.s +++ b/src/basic/basic_commands_03_m65/cmd__jumptable_03.s @@ -1,17 +1,15 @@ -// #LAYOUT# M65 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for BASIC commands with tokens prefixed by $03 -// +; +; Jumptable for BASIC commands with tokens prefixed by $03 +; -.const command_03_list = List().add( - - cmd_rem // XXX just for testing -) +!set ITEM_00 = cmd_rem ; XXX just for testing command_03_jumptable: - // Note: 65C02 has the page boundary vector bug fixed! - put_jumptable(command_03_list) + ; Note: 65C02 has the page boundary vector bug fixed! + + !word ITEM_00 diff --git a/src/basic/basic_functions/fun__jumptable.s b/src/basic/basic_functions/fun__jumptable.s index d5b47811..0898ef1d 100644 --- a/src/basic/basic_functions/fun__jumptable.s +++ b/src/basic/basic_functions/fun__jumptable.s @@ -1,63 +1,61 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for BASIC V2 dialect functions -// +; +; Jumptable for BASIC V2 dialect functions +; + +!set ITEM_B4 = fun_sgn +!set ITEM_B5 = fun_int +!set ITEM_B6 = fun_abs +!set ITEM_B7 = fun_usr +!set ITEM_B8 = fun_fre +!set ITEM_B9 = fun_pos +!set ITEM_BA = fun_sqr +!set ITEM_BB = fun_rnd +!set ITEM_BC = fun_log +!set ITEM_BD = fun_exp +!set ITEM_BE = fun_cos +!set ITEM_BF = fun_sin + +!set ITEM_C0 = fun_tan +!set ITEM_C1 = fun_atn +!set ITEM_C2 = fun_peek +!set ITEM_C3 = fun_len +!set ITEM_C4 = fun_str +!set ITEM_C5 = fun_val +!set ITEM_C6 = fun_asc +!set ITEM_C7 = fun_chr +!set ITEM_C8 = fun_left +!set ITEM_C9 = fun_right +!set ITEM_CA = fun_mid -.const function_list = List().add( - - // $B4-$BF - - fun_sgn, - fun_int, - fun_abs, - fun_usr, - fun_fre, - fun_pos, - fun_sqr, - fun_rnd, - fun_log, - fun_exp, - fun_cos, - fun_sin, - - // $C0-$CA - - fun_tan, - fun_atn, - fun_peek, - fun_len, - fun_str, - fun_val, - fun_asc, - fun_chr, - fun_left, - fun_right, - fun_mid -) - - -#if !HAS_OPCODES_65C02 - +!ifndef HAS_OPCODES_65C02 { function_jumptable_lo: - put_jumptable_lo(function_list) - + !byte <(ITEM_B4-1), <(ITEM_B5-1), <(ITEM_B6-1), <(ITEM_B7-1) + !byte <(ITEM_B8-1), <(ITEM_B9-1), <(ITEM_BA-1), <(ITEM_BB-1), <(ITEM_BC-1), <(ITEM_BD-1), <(ITEM_BE-1), <(ITEM_BF-1) + !byte <(ITEM_C0-1), <(ITEM_C1-1), <(ITEM_C2-1), <(ITEM_C3-1), <(ITEM_C4-1), <(ITEM_C5-1), <(ITEM_C6-1), <(ITEM_C7-1) + !byte <(ITEM_C8-1), <(ITEM_C9-1), <(ITEM_CA-1) function_jumptable_hi: - put_jumptable_hi(function_list) + !byte >(ITEM_B4-1), >(ITEM_B5-1), >(ITEM_B6-1), >(ITEM_B7-1) + !byte >(ITEM_B8-1), >(ITEM_B9-1), >(ITEM_BA-1), >(ITEM_BB-1), >(ITEM_BC-1), >(ITEM_BD-1), >(ITEM_BE-1), >(ITEM_BF-1) + !byte >(ITEM_C0-1), >(ITEM_C1-1), >(ITEM_C2-1), >(ITEM_C3-1), >(ITEM_C4-1), >(ITEM_C5-1), >(ITEM_C6-1), >(ITEM_C7-1) + !byte >(ITEM_C8-1), >(ITEM_C9-1), >(ITEM_CA-1) - -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 function_jumptable: - // Note: 65C02 has the page boundary vector bug fixed! - put_jumptable(function_list) - -#endif + ; Note: 65C02 has the page boundary vector bug fixed! + + !word ITEM_B4, ITEM_B5, ITEM_B6, ITEM_B7 + !word ITEM_B8, ITEM_B9, ITEM_BA, ITEM_BB, ITEM_BC, ITEM_BD, ITEM_BE, ITEM_BF + !word ITEM_C0, ITEM_C1, ITEM_C2, ITEM_C3, ITEM_C4, ITEM_C5, ITEM_C6, ITEM_C7 + !word ITEM_C8, ITEM_C9, ITEM_CA +} diff --git a/src/basic/basic_functions/fun__unimplemented.s b/src/basic/basic_functions/fun__unimplemented.s index 8954996d..d4a23172 100644 --- a/src/basic/basic_functions/fun__unimplemented.s +++ b/src/basic/basic_functions/fun__unimplemented.s @@ -1,61 +1,61 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Default handler for all not-yet-implemented functions -// -// Note: NOPs are here just to make debugging easier (no duplicated labels)! -// +; +; Default handler for all not-yet-implemented functions +; +; Note: NOPs are here just to make debugging easier (no duplicated labels)! +; fun_sgn: - nop + +nop fun_int: - nop + +nop fun_abs: - nop + +nop fun_usr: - nop + +nop fun_fre: - nop + +nop fun_pos: - nop + +nop fun_sqr: - nop + +nop fun_rnd: - nop + +nop fun_log: - nop + +nop fun_exp: - nop + +nop fun_cos: - nop + +nop fun_sin: - nop + +nop fun_tan: - nop + +nop fun_atn: - nop + +nop fun_peek: - nop + +nop fun_len: - nop + +nop fun_str: - nop + +nop fun_val: - nop + +nop fun_asc: - nop + +nop fun_chr: - nop + +nop fun_left: - nop + +nop fun_right: - nop + +nop fun_mid: - nop + +nop - // Unimplemented tokens + ; Unimplemented tokens jmp do_NOT_IMPLEMENTED_error diff --git a/src/basic/basic_operators/oper__jumptable.s b/src/basic/basic_operators/oper__jumptable.s index 2edc0dc3..7eddf19e 100644 --- a/src/basic/basic_operators/oper__jumptable.s +++ b/src/basic/basic_operators/oper__jumptable.s @@ -1,68 +1,65 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable and priority list for all BASIC operators -// +; +; Jumptable and priority list for all BASIC operators +; + + ; Tokens $AA-$AF + +!set ITEM_00 = oper_add +!set ITEM_01 = oper_sub +!set ITEM_02 = oper_mul +!set ITEM_03 = oper_div +!set ITEM_04 = oper_pow +!set ITEM_05 = oper_and + + ; Tokens $B0-$B3 + +!set ITEM_06 = oper_or +!set ITEM_07 = oper_cmp_gt +!set ITEM_08 = oper_cmp_eq +!set ITEM_09 = oper_cmp_lt + + ; Combined two tokens + +!set ITEM_0A = oper_cmp_gteq +!set ITEM_0B = oper_cmp_lteq +!set ITEM_0C = oper_cmp_neq + + ; Unary operators + +!set ITEM_0D = oper_unary_minus +!set ITEM_0E = oper_unary_not -.const operator_list = List().add( - - // Tokens $AA-$B0 - - oper_add, // ID: $00 - oper_sub, // ID: $01 - oper_mul, // ID: $02 - oper_div, // ID: $03 - oper_pow, // ID: $04 - oper_and, // ID: $05 - oper_or, // ID: $06 - - // Tokens $B1-$B3 - - oper_cmp_gt, // ID: $07 - oper_cmp_eq, // ID: $08 - oper_cmp_lt, // ID: $09 - - // Combined two tokens - - oper_cmp_gteq, // ID: $0A - oper_cmp_lteq, // ID: $0B - oper_cmp_neq, // ID: $0C - - // Unary operators - - oper_unary_minus, // ID: $0D - oper_unary_not // ID: $0E -) - - -operator_priorities: // higher number = higher priority - - .byte $05 // oper_add - .byte $05 // oper_sub - .byte $06 // oper_mul - .byte $06 // oper_div - .byte $08 // oper_pow - .byte $02 // oper_and - .byte $01 // oper_or - .byte $04 // oper_cmp_gt - .byte $04 // oper_cmp_eq - .byte $04 // oper_cmp_lt - .byte $04 // oper_cmp_gteq - .byte $04 // oper_cmp_lteq - .byte $04 // oper_cmp_neq - .byte $07 // oper_unary_minus - .byte $03 // oper_unary_not +operator_priorities: ; higher number = higher priority + !byte $05 ; oper_add + !byte $05 ; oper_sub + !byte $06 ; oper_mul + !byte $06 ; oper_div + !byte $08 ; oper_pow + !byte $02 ; oper_and + !byte $01 ; oper_or + !byte $04 ; oper_cmp_gt + !byte $04 ; oper_cmp_eq + !byte $04 ; oper_cmp_lt + !byte $04 ; oper_cmp_gteq + !byte $04 ; oper_cmp_lteq + !byte $04 ; oper_cmp_neq + !byte $07 ; oper_unary_minus + !byte $03 ; oper_unary_not operator_jumptable_lo: - put_jumptable_lo(operator_list) + !byte <(ITEM_00-1), <(ITEM_01-1), <(ITEM_02-1), <(ITEM_03-1), <(ITEM_04-1), <(ITEM_05-1), <(ITEM_06-1), <(ITEM_07-1) + !byte <(ITEM_08-1), <(ITEM_09-1), <(ITEM_0A-1), <(ITEM_0B-1), <(ITEM_0C-1), <(ITEM_0D-1), <(ITEM_0E-1) operator_jumptable_hi: - put_jumptable_hi(operator_list) + !byte >(ITEM_00-1), >(ITEM_01-1), >(ITEM_02-1), >(ITEM_03-1), >(ITEM_04-1), >(ITEM_05-1), >(ITEM_06-1), >(ITEM_07-1) + !byte >(ITEM_08-1), >(ITEM_09-1), >(ITEM_0A-1), >(ITEM_0B-1), >(ITEM_0C-1), >(ITEM_0D-1), >(ITEM_0E-1) diff --git a/src/basic/basic_operators/oper_add.s b/src/basic/basic_operators/oper_add.s index e663af97..96a6cbd4 100644 --- a/src/basic/basic_operators/oper_add.s +++ b/src/basic/basic_operators/oper_add.s @@ -1,50 +1,50 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE oper_add: - // This operator can be used either with two strings, or with two floats - // First check whether arguments match and then choose the variant + ; This operator can be used either with two strings, or with two floats + ; First check whether arguments match and then choose the variant pla eor VALTYP - bmi_16 do_TYPE_MISMATCH_error + +bmi do_TYPE_MISMATCH_error lda VALTYP bmi oper_add_strings - // FALLTROUGH + ; FALLTROUGH oper_add_floats: - // XXX implement this + ; XXX implement this jmp do_NOT_IMPLEMENTED_error oper_add_strings: - // Retrieve string address + ; Retrieve string address pla sta __FAC2+2 pla sta __FAC2+1 - // Pull string length + ; Pull string length pla sta __FAC2+0 - // If string 2 is empty, release it and quit + ; If string 2 is empty, release it and quit beq oper_add_strings_end - // If string 1 is empty, just copy the metadata + ; If string 1 is empty, just copy the metadata lda __FAC1+0 - bne !+ + bne @1 jsr tmpstr_free_FAC1 @@ -56,16 +56,16 @@ oper_add_strings: sta __FAC1+2 jmp FRMEVL_continue -!: - // Allocate memory for the concatenated string +@1: + ; Allocate memory for the concatenated string clc adc __FAC2+0 - bcs_16 do_STRING_TOO_LONG_error + +bcs do_STRING_TOO_LONG_error jsr tmpstr_alloc - // Copy the temporary string pointer to INDEX + ; Copy the temporary string pointer to INDEX ldy #$01 lda (VARPNT), y @@ -74,86 +74,85 @@ oper_add_strings: lda (VARPNT), y sta INDEX+1 - // Perform the concatenation + ; Perform the concatenation -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // Copy data from the first string + ; Copy data from the first string ldy #$00 -!: +@2: ldx #<(__FAC2+1) jsr peek_under_roms ldx #OLDTXT - // .byte $f0,OLDTXT - // .byte $0d,0 + ; jsr printf + ; .text "DELETING LINE AT $" + ; .byte $f1,OLDTXT + ; .byte $f0,OLDTXT + ; .byte $0d,0 - // Get address of next line + ; Get address of next line ldy #$00 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #__tokenise_work4 - // .byte $f0,<__tokenise_work3,>__tokenise_work3 - // .byte $0d,0 + ; jsr printf + ; .text "LINE LENGTH IS $" + ; .byte $f0,<__tokenise_work4,>__tokenise_work4 + ; .byte $f0,<__tokenise_work3,>__tokenise_work3 + ; .byte $0d,0 lda __tokenise_work4 sbc #0 cmp #$00 - beq !+ - // Line length is <0 or >255 bytes. - // Either way, things are bad, so abort. + ; Line length is <0 or >255 bytes. + ; Either way, things are bad, so abort. - jmp do_MEMORY_CORRUPT_error -!: - // Length can now be safely assumed to be in the low - // byte only, i.e., stored in __tokenise_work3 + +bne do_MEMORY_CORRUPT_error + + ; Length can now be safely assumed to be in the low + ; byte only, i.e., stored in __tokenise_work3 ldx __tokenise_work3 - // Shuffle everything down + ; Shuffle everything down jsr shift_txt_down - // Finish by fixing program linkage and calculating new + ; Finish by fixing program linkage and calculating new jmp update_LINKPRG_VARTAB_do_clr diff --git a/src/basic/engine_editor/find_line_38K_60K.s b/src/basic/engine_editor/find_line_38K_60K.s index 309975da..2e16f69c 100644 --- a/src/basic/engine_editor/find_line_38K_60K.s +++ b/src/basic/engine_editor/find_line_38K_60K.s @@ -1,55 +1,55 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Find the BASIC line with number in LINNUM +; Find the BASIC line with number in LINNUM -#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K +!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K { find_line_from_start: - // Get pointer to start of BASIC text + ; Get pointer to start of BASIC text jsr init_oldtxt - // FALLTROUGH + ; FALLTROUGH find_line_from_current: - // Check if line is not empty + ; Check if line is not empty jsr is_line_pointer_null beq find_line_fail - // Fetch the high byte of line number and compare + ; Fetch the high byte of line number and compare ldy #$03 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #OLDTXT - // .byte $f0,OLDTXT - // .byte $0d,0 + ; jsr printf + ; .text "INSERTING LINE AT $" + ; .byte $f1,OLDTXT + ; .byte $f0,OLDTXT + ; .byte $0d,0 - // Get number of bytes in tokenised line after line number + ; Get number of bytes in tokenised line after line number lda __tokenise_work2 sec sbc __tokenise_work1 - // Add on the five bytes space we need (2 bytes for linkage, 2 bytes for line number, 1 byte for terminator) + ; Add on the five bytes space we need (2 bytes for linkage, 2 bytes for line number, 1 byte for terminator) clc adc #$05 tax - // Make the space + ; Make the space jsr shift_txt_up - // Put dummy linkage, we will correct it later + ; Put dummy linkage, we will correct it later ldy #$01 tya -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #BUF @@ -144,46 +141,46 @@ shell_process_line: jsr fetch_line_number - // Get pointer to next char + ; Get pointer to next char lda TXTPTR+0 sta __tokenise_work1 - // Got a valid line number - we will be adding/deleting a new line + ; Got a valid line number - we will be adding/deleting a new line - // Skip any spaces after the line number + ; Skip any spaces after the line number ldx __tokenise_work1 -!: +@3: lda BUF,x cmp #$20 - bne !+ + bne @4 inx - bne !- -!: + bne @3 +@4: stx __tokenise_work1 - // FALLTROUGH + ; FALLTROUGH shell_add_delete_line: - // First make sure VARTAB is correct and clear all the variables + ; First make sure VARTAB is correct and clear all the variables jsr update_VARTAB_do_clr - // Check if line already present + ; Check if line already present jsr find_line_from_start - bcs !+ + bcs @5 - // Line already present - delete it + ; Line already present - delete it jsr delete_line - jsr find_line_from_start // refresh OLDTXT -!: - // Insert new line if non-zero length, i.e., that - // we are not just deleting the line. + jsr find_line_from_start ; refresh OLDTXT +@5: + ; Insert new line if non-zero length, i.e., that + ; we are not just deleting the line. lda __tokenise_work1 cmp __tokenise_work2 - beq !+ + beq @6 jsr insert_line -!: - // No READY message after entering or deleting a line of BASIC +@6: + ; No READY message after entering or deleting a line of BASIC jmp shell_read_next_line @@ -191,4 +188,3 @@ shell_execute_line: jsr prepare_direct_execution jmp execute_statements - diff --git a/src/basic/engine_editor/shift_txt_down.s b/src/basic/engine_editor/shift_txt_down.s index c093f671..805738c1 100644 --- a/src/basic/engine_editor/shift_txt_down.s +++ b/src/basic/engine_editor/shift_txt_down.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Shift the BASIC program down to cover the area of removed line -// +; +; Shift the BASIC program down to cover the area of removed line +; shift_txt_down: - // First byte of destination is OLDTXT + ; First byte of destination is OLDTXT lda OLDTXT+0 sta memmove__dst+0 lda OLDTXT+1 sta memmove__dst+1 - // First byte of source is memmove__dst + .X + ; First byte of source is memmove__dst + .X clc txa @@ -28,7 +28,7 @@ shift_txt_down: adc #$00 sta memmove__src+1 - // Size is distance from source to the end of BASIC text (VARTAB) + ; Size is distance from source to the end of BASIC text (VARTAB) lda VARTAB+0 sec @@ -38,6 +38,6 @@ shift_txt_down: sbc memmove__src+1 sta memmove__size+1 - // Perform the copy + ; Perform the copy jmp shift_mem_down diff --git a/src/basic/engine_editor/shift_txt_up.s b/src/basic/engine_editor/shift_txt_up.s index 221e1460..5380067f 100644 --- a/src/basic/engine_editor/shift_txt_up.s +++ b/src/basic/engine_editor/shift_txt_up.s @@ -1,18 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Shift the BASIC program up to make space for a new line -// +; +; Shift the BASIC program up to make space for a new line +; shift_txt_up: - // Last byte of source is VARTAB-1 + ; Last byte of source is VARTAB-1 -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { sec lda VARTAB+0 @@ -22,17 +22,16 @@ shift_txt_up: sbc #$00 sta memmove__src+1 -#else // HAS_OPCODES_65CE02 +} else { ; HAS_OPCODES_65CE02 lda VARTAB+0 sta memmove__src+0 lda VARTAB+1 sta memmove__src+1 dew memmove__src +} -#endif - - // Last byte of destination is memmove__src + .X + ; Last byte of destination is memmove__src + .X clc txa @@ -43,7 +42,7 @@ shift_txt_up: adc #$00 sta memmove__dst+1 - // Size is distance from OLDTXT to the end of BASIC text (VARTAB) + ; Size is distance from OLDTXT to the end of BASIC text (VARTAB) lda VARTAB+0 sec @@ -53,6 +52,6 @@ shift_txt_up: sbc OLDTXT+1 sta memmove__size+1 - // Perform the copy + ; Perform the copy jmp shift_mem_up diff --git a/src/basic/engine_editor/tk_cut_away.s b/src/basic/engine_editor/tk_cut_away.s index 4741388c..0eeb2de3 100644 --- a/src/basic/engine_editor/tk_cut_away.s +++ b/src/basic/engine_editor/tk_cut_away.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Cuts away unnecessary characters after tokenizing a keyword -// +; +; Cuts away unnecessary characters after tokenizing a keyword +; -tk_cut_away_2: // for two-bytes tokenized keywords +tk_cut_away_2: ; for two-bytes tokenized keywords dec tk__len_unpacked - // FALLTROUGH + ; FALLTROUGH -tk_cut_away_1: // for single-byte tokenized keywords +tk_cut_away_1: ; for single-byte tokenized keywords - dec tk__len_unpacked // keyword length, afterwards number of bytes to cut away + dec tk__len_unpacked ; keyword length, afterwards number of bytes to cut away - // Correct the line length + ; Correct the line length sec lda tk__length sbc tk__len_unpacked sta tk__length - // Copy the remaining,. untokenized part in the proper place + ; Copy the remaining,. untokenized part in the proper place inc tk__offset ldy tk__offset @@ -34,13 +34,13 @@ tk_cut_away_1: // for single-byte tokenized keywords clc adc tk__offset tax -!: +@1: lda BUF, x sta BUF, y - beq !+ + beq @2 inx iny - bne !- -!: + bne @1 +@2: rts diff --git a/src/basic/engine_editor/tk_pack.s b/src/basic/engine_editor/tk_pack.s index 56d3db31..1b4c9d70 100644 --- a/src/basic/engine_editor/tk_pack.s +++ b/src/basic/engine_editor/tk_pack.s @@ -1,94 +1,85 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Packs a keyword candidate using a simple compression scheme, -// same as in 'generate_strings.cc'. -// -// This allows us to search through the compressed tokens directly -// using the compressed fragment of BASIC, and thus work out the -// token for a given piece of string. -// -// This also helps ensure that we have an implementation that is totally -// different to that of the original C64 BASIC, as well as likely -// saving a bit of space in the ROM, especially once we start implementing -// larger keyword vocabs for extended BASIC, since the compression and -// decompression machinery is of fixed size. -// -// Input: -// - .X = offset of string to pack, address is BUF ($0200) + .X -// Output: -// - see labels in 'tk_pack' -// +; +; Packs a keyword candidate using a simple compression scheme, +; same as in 'generate_strings.cc'. +; +; This allows us to search through the compressed tokens directly +; using the compressed fragment of BASIC, and thus work out the +; token for a given piece of string. +; +; This also helps ensure that we have an implementation that is totally +; different to that of the original C64 BASIC, as well as likely +; saving a bit of space in the ROM, especially once we start implementing +; larger keyword vocabs for extended BASIC, since the compression and +; decompression machinery is of fixed size. +; +; Input: +; - .X = offset of string to pack, address is BUF ($0200) + .X +; Output: +; - see labels in 'tk_pack' +; tk_pack: - // Reuse the CPU stack - address $100 is used by 'tokenise_line.s' - - .label tk__len_unpacked = $101 // length of unpacked data; it could replace 'tk__nibble_flag', but at the cost of code size/performance - .label tk__shorten_bits = $102 // 2 bytes for quick shortening of packed candidate - .label tk__nibble_flag = $104 // $00 = start from new byte, $FF = start from high nibble - .label tk__byte_offset = $105 // offset of the current byte (to place new data) in tk__packed - - .label tk__packed = $106 // packed candidate, 25 bytes is enough for worst case - a 16 byte keyword - - // Initialize variables + ; Initialize variables lda #$00 - ldy #($04 + 25) // initialize 5 bytes of data + 25 bytes of space for packing -!: + ldy #($04 + 25) ; initialize 5 bytes of data + 25 bytes of space for packing +@1: sta tk__len_unpacked, y dey - bpl !- + bpl @1 - // FALLTROUGH + ; FALLTROUGH tk_pack_loop: - // Get the next character + ; Get the next character lda BUF, x - // If character cannot be a part of a keyword - do not pack anything more + ; If character cannot be a part of a keyword - do not pack anything more - cmp #$23 // '#' - first sane character for a keyword - bcc tk_pack_done // branch if below '#' - cmp #$7B // 'Z' + 1 - bcs tk_pack_done // branch if above 'Z' + cmp #$23 ; '#' - first sane character for a keyword + bcc tk_pack_done ; branch if below '#' + cmp #$7B ; 'Z' + 1 + bcs tk_pack_done ; branch if above 'Z' - // Keywords should not contain digits, colons, or semicolons + ; Keywords should not contain digits, colons, or semicolons cmp #$30 - bcc !+ // branch if below '0' + bcc @2 ; branch if below '0' cmp #$3C - bcc tk_pack_done // branch if below '<' -!: - // Try to find a nibble to encode the character + bcc tk_pack_done ; branch if below '<' +@2: + ; Try to find a nibble to encode the character ldy #$0E -!: +@3: cmp packed_as_1n-1, y beq tk_pack_1n dey - bne !- + bne @3 - // Try to find a 3-nibble sequence to encode the character (1st nibble is always 0xF in this case) + ; Try to find a 3-nibble sequence to encode the character (1st nibble is always 0xF in this case) ldy #TK__PACKED_AS_3N -!: +@4: cmp packed_as_3n-1, y beq tk_pack_3n dey - bne !- + bne @4 - // If it is not on the list, it cannot be a part of token - quit + ; If it is not on the list, it cannot be a part of token - quit - // FALLTROUGH + ; FALLTROUGH tk_pack_done: @@ -96,12 +87,12 @@ tk_pack_done: tk_pack_1n: - // .Y contains our nibble; check whether we should start a new encoded byte + ; .Y contains our nibble; check whether we should start a new encoded byte bit tk__nibble_flag bpl tk_pack_1n_new_byte - // Store in the high nibble of the current byte + ; Store in the high nibble of the current byte tya @@ -114,112 +105,112 @@ tk_pack_1n: ora tk__packed, y sta tk__packed, y - // Adjust remaining counters / flags + ; Adjust remaining counters / flags inc tk__byte_offset - inc tk__nibble_flag // $FF -> $00 + inc tk__nibble_flag ; $FF -> $00 - // FALLTROUGH + ; FALLTROUGH tk_pack_1n_done: - // Put the bit mark - to indicate 1-nibble encoding + ; Put the bit mark - to indicate 1-nibble encoding clc ror tk__shorten_bits+0 ror tk__shorten_bits+1 - // FALLTROUGH + ; FALLTROUGH tk_pack_loop_next: - // Prepare for the next loop iteration - increment counters + ; Prepare for the next loop iteration - increment counters inx inc tk__len_unpacked - // Check length, if it is OK to pack one more byte; quit if not + ; Check length, if it is OK to pack one more byte; quit if not lda tk__len_unpacked cmp #TK__MAX_KEYWORD_LEN - beq !+ // if max length reached - quit + beq @5 ; if max length reached - quit - // Check for characters that can only end the keyword + ; Check for characters that can only end the keyword lda BUF-1, x cmp #$41 bcs tk_pack_loop -!: +@5: rts tk_pack_1n_new_byte: - // Store in the low nibble of the next byte + ; Store in the low nibble of the next byte tya ldy tk__byte_offset sta tk__packed, y - // Adjust remaining counters / flags + ; Adjust remaining counters / flags - dec tk__nibble_flag // $00 -> $FF + dec tk__nibble_flag ; $00 -> $FF bmi tk_pack_1n_done tk_pack_3n: - // .Y contains 2 nibbles to encode; check whether we should start a new encoded byte + ; .Y contains 2 nibbles to encode; check whether we should start a new encoded byte bit tk__nibble_flag bpl tk_pack_3n_new_byte - // Store 1st nibble (alwys 0xF) in the high nibble of the current byte + ; Store 1st nibble (alwys 0xF) in the high nibble of the current byte - phy_trash_a + +phy_trash_a lda #$F0 ldy tk__byte_offset ora tk__packed, y sta tk__packed, y - // Store byte in the next byte + ; Store byte in the next byte iny pla sta tk__packed, y - // Adjust remaining counters / flags + ; Adjust remaining counters / flags iny sty tk__byte_offset - inc tk__nibble_flag // $FF -> $00 + inc tk__nibble_flag ; $FF -> $00 - // FALLTROUGH + ; FALLTROUGH tk_pack_3n_done: - // Put the bit mark - to indicate 3-nibble encoding + ; Put the bit mark - to indicate 3-nibble encoding sec ror tk__shorten_bits+0 ror tk__shorten_bits+1 - bcc tk_pack_loop_next // branch always + bcc tk_pack_loop_next ; branch always tk_pack_3n_new_byte: - // First store everything in the current byte, we will set '0xF' mark later + ; First store everything in the current byte, we will set '0xF' mark later tya ldy tk__byte_offset sta tk__packed, y - // Now store just the low nibble in the next byte + ; Now store just the low nibble in the next byte iny and #$0F sta tk__packed, y - // Go back for a moment and set the '0xF' mark in the low nibble + ; Go back for a moment and set the '0xF' mark in the low nibble dey lda tk__packed, y @@ -227,9 +218,9 @@ tk_pack_3n_new_byte: sta tk__packed, y iny - // Adjust remaining counters / flags + ; Adjust remaining counters / flags sty tk__byte_offset - dec tk__nibble_flag // $00 -> $FF + dec tk__nibble_flag ; $00 -> $FF - bmi tk_pack_3n_done // branch always + bmi tk_pack_3n_done ; branch always diff --git a/src/basic/engine_editor/tk_search.s b/src/basic/engine_editor/tk_search.s index fb847b24..49be5178 100644 --- a/src/basic/engine_editor/tk_search.s +++ b/src/basic/engine_editor/tk_search.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Search for a token on the list pointed by FRESPC -// -// Input: -// - list address in FRESPC, has to be refreshed after routine call -// - uses same variables as 'tk_pack' -// Output: -// - Carry set = not found -// - .X = index of token found -// +; +; Search for a token on the list pointed by FRESPC +; +; Input: +; - list address in FRESPC, has to be refreshed after routine call +; - uses same variables as 'tk_pack' +; Output: +; - Carry set = not found +; - .X = index of token found +; tk_search: - ldx #$00 // initial token index + ldx #$00 ; initial token index - // FALLTROUGH + ; FALLTROUGH tk_search_loop: - // Check if end of the list + ; Check if end of the list ldy #$00 lda (FRESPC), y @@ -35,14 +35,14 @@ tk_search_loop: cmp #$FF bne tk_search_compare - // End of the list + ; End of the list sec rts tk_search_compare: - // Compare the packed candidate with the current keyword list entry + ; Compare the packed candidate with the current keyword list entry lda (FRESPC), y cmp tk__packed, y @@ -51,30 +51,30 @@ tk_search_compare: cmp #$00 beq tk_search_found - // For now everything matches, try the next byte + ; For now everything matches, try the next byte iny - bne tk_search_compare // branch always + bne tk_search_compare ; branch always tk_search_not_matching: - inx // increment token index + inx ; increment token index - // We need to find the end of the keyword on the list - // and proceed one byte further + ; We need to find the end of the keyword on the list + ; and proceed one byte further cmp #$00 beq tk_search_next -!: +@1: iny lda (FRESPC), y - bne !- + bne @1 - // FALLTROUGH + ; FALLTROUGH tk_search_next: - // Update FRESPC - advance by .Y + ; Update FRESPC - advance by .Y iny tya @@ -85,7 +85,7 @@ tk_search_next: adc #$00 sta FRESPC+1 - bcc tk_search_loop // branch always + bcc tk_search_loop ; branch always tk_search_found: diff --git a/src/basic/engine_editor/tk_shorten.s b/src/basic/engine_editor/tk_shorten.s index 977b0c02..10ed762c 100644 --- a/src/basic/engine_editor/tk_shorten.s +++ b/src/basic/engine_editor/tk_shorten.s @@ -1,44 +1,44 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Shortens a keyword candidate previously packed by tk_pack by 1 character -// -// Input: -// - uses same variables as 'tk_pack' -// +; +; Shortens a keyword candidate previously packed by tk_pack by 1 character +; +; Input: +; - uses same variables as 'tk_pack' +; tk_shorten: - // First make sure we actually can shorten anything + ; First make sure we actually can shorten anything dec tk__len_unpacked beq tk_shorten_end - // Now check if the last character was encoded as 1 nibble or 3 nibbles + ; Now check if the last character was encoded as 1 nibble or 3 nibbles asl tk__shorten_bits+1 rol tk__shorten_bits+0 bcs tk_shorten_3n - // FALLTROUGH + ; FALLTROUGH tk_shorten_1n: - ldy tk__byte_offset // will be needed in both cases + ldy tk__byte_offset ; will be needed in both cases - // Now we need to check which nibble to cut away + ; Now we need to check which nibble to cut away bit tk__nibble_flag bmi tk_shorten_1n_lo - // FALLTROUGH + ; FALLTROUGH -tk_shorten_1n_hi: // tk__nibble_flag = $00, both nibbles free +tk_shorten_1n_hi: ; tk__nibble_flag = $00, both nibbles free - // Go back one byte and clear the high nibble only + ; Go back one byte and clear the high nibble only dey sty tk__byte_offset @@ -47,62 +47,62 @@ tk_shorten_1n_hi: // tk__nibble_flag = $00, both nibbles fr and #$0F sta tk__packed, y - // Adjust remaining counters / flags, and quit + ; Adjust remaining counters / flags, and quit - dec tk__nibble_flag // $00 -> $FF + dec tk__nibble_flag ; $00 -> $FF - // FALLTROUGH + ; FALLTROUGH tk_shorten_end: rts -tk_shorten_1n_lo: // tk__nibble_flag = $FF, only the high nibble is free +tk_shorten_1n_lo: ; tk__nibble_flag = $FF, only the high nibble is free - // Clear the whole byte, it will be faster + ; Clear the whole byte, it will be faster lda #$00 sta tk__packed, y - // Adjust remaining counters / flags, and quit + ; Adjust remaining counters / flags, and quit - inc tk__nibble_flag // $FF -> $00 + inc tk__nibble_flag ; $FF -> $00 rts tk_shorten_3n: - ldy tk__byte_offset // will be needed in both cases + ldy tk__byte_offset ; will be needed in both cases lda #$00 - // Now we need to check which nibble to cut away + ; Now we need to check which nibble to cut away bit tk__nibble_flag bmi tk_shorten_3n_2bytes - // FALLTROUGH + ; FALLTROUGH -tk_shorten_3n_byte_nibble: // tk__nibble_flag = $00, both nibbles free +tk_shorten_3n_byte_nibble: ; tk__nibble_flag = $00, both nibbles free - // Go back one byte, clear it, go back and clear the high nibble only + ; Go back one byte, clear it, go back and clear the high nibble only dey sta tk__packed, y - // Reuse 'tk_shorten_1n_hi' + ; Reuse 'tk_shorten_1n_hi' sty tk__byte_offset - jmp_8 tk_shorten_1n_hi + +bra tk_shorten_1n_hi -tk_shorten_3n_2bytes: // tk__nibble_flag = $FF, only the high nibble is free +tk_shorten_3n_2bytes: ; tk__nibble_flag = $FF, only the high nibble is free - // Clear the byte, go back, clear one more byte + ; Clear the byte, go back, clear one more byte sta tk__packed, y dey sta tk__packed, y - // Adjust remaining counters / flags, and quit + ; Adjust remaining counters / flags, and quit sty tk__byte_offset - inc tk__nibble_flag // $FF -> $00 + inc tk__nibble_flag ; $FF -> $00 rts diff --git a/src/basic/engine_editor/tokenise_line.s b/src/basic/engine_editor/tokenise_line.s index 13f1fcfd..4141f2a4 100644 --- a/src/basic/engine_editor/tokenise_line.s +++ b/src/basic/engine_editor/tokenise_line.s @@ -1,53 +1,48 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tokenise a line of BASIC stored at $0200 -// -// Input: -// - length in __tokenise_work1 -// +; +; Tokenise a line of BASIC stored at $0200 +; +; Input: +; - length in __tokenise_work1 +; tokenise_line: -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { - jsr map_BASIC_1 - jsr_ind VB1__tokenise_line - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__tokenise_line) + jmp map_NORMAL -#else +} else { - // Reuse the CPU stack - addresses above $100 are used by 'tk_pack.s' - - .label tk__offset = $100 // offset into string - .label tk__length = __tokenise_work1 // length of the raw string - - // Initialize variables + ; Initialize variables lda #$00 sta tk__offset - // Terminate input string with $00 + ; Terminate input string with $00 - // XXX do we need this? + ; XXX do we need this? ldx tk__length sta BUF, x - // FALLTROUGH + ; FALLTROUGH tokenise_line_loop: - // Check if we have reached end of the line + ; Check if we have reached end of the line lda tk__offset cmp tk__length beq tokenise_line_done - // Check for some special characters + ; Check for some special characters ldx tk__offset lda BUF, x @@ -59,16 +54,16 @@ tokenise_line_loop: beq tokenise_line_pi cmp #$3F - beq tokenise_line_question_mark // shortcut for PRINT command + beq tokenise_line_question_mark ; shortcut for PRINT command - // Try to tokenise + ; Try to tokenise jsr tk_pack -!: +@1: lda tk__len_unpacked - beq tokenise_line_char // branch if attempt to tokenise failed + beq tokenise_line_char ; branch if attempt to tokenise failed - // Check for BASIC V2 tokens + ; Check for BASIC V2 tokens lda # + ; We were in a program, so show IN ldx #IDX__STR_IN jsr print_packed_misc_str @@ -211,12 +211,12 @@ do_basic_error: // error code in .X lda CURLIN+1 ldx CURLIN+0 jsr print_integer -!: - // Reset stack, and go back to main loop +@1: + ; Reset stack, and go back to main loop ldx #$FE txs jmp shell_main_loop -#endif // ROM layout +} ; ROM layout diff --git a/src/basic/engine_runtime/do_new_clr_restore.s b/src/basic/engine_runtime/do_new_clr_restore.s index 28fbfed7..9a96cc25 100644 --- a/src/basic/engine_runtime/do_new_clr_restore.s +++ b/src/basic/engine_runtime/do_new_clr_restore.s @@ -1,35 +1,40 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// See https://www.c64-wiki.com/wiki/Memory_(BASIC) for BASIC memory organization +; See https://www.c64-wiki.com/wiki/Memory_(BASIC) for BASIC memory organization -do_new: +do_new: -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { - jsr map_BASIC_1 - jsr_ind VB1__do_new - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__do_new) + +bra do_restore_end do_clr: - jsr map_BASIC_1 - jsr_ind VB1__do_clr - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__do_clr) + +bra do_restore_end do_restore: - jsr map_BASIC_1 - jsr_ind VB1__do_restore - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__do_restore) + + ; FALLTROUGH + +do_restore_end: -#else + jmp map_NORMAL - // See Computes Mapping the Commodore 64 - page 96 +} else { + + ; See Computes Mapping the Commodore 64 - page 96 ldy #$00 tya @@ -37,7 +42,7 @@ do_restore: iny sta (TXTTAB),y - // The book does not mention this, but IMHO it is necessary to initialize VARTAB here too + ; The book does not mention this, but IMHO it is necessary to initialize VARTAB here too clc lda TXTTAB+0 @@ -49,9 +54,9 @@ do_restore: do_clr: - // See Computes Mapping the Commodore 64 - page 96 + ; See Computes Mapping the Commodore 64 - page 96 - // XXX check if original ROM does this too + ; XXX check if original ROM does this too jsr JCLALL lda MEMSIZ+0 @@ -59,7 +64,7 @@ do_clr: lda MEMSIZ+1 sta FRETOP+1 - // The book is not precise here $31-$32 is definitely not the end of BASIC text + ; The book is not precise here $31-$32 is definitely not the end of BASIC text lda VARTAB+0 sta ARYTAB+0 @@ -69,18 +74,18 @@ do_clr: sta ARYTAB+1 sta STREND+1 - // This is a good place to reset the temporary string stack + ; This is a good place to reset the temporary string stack jsr tmpstr_free_all_reset - // FALLTROUGH (confirmed on real C64 that CLR indeed resets DATPTR) + ; FALLTROUGH (confirmed on real C64 that CLR indeed resets DATPTR) do_restore: - // See Computes Mapping the Commodore 64 - page 98 - // Initial DATPTR value checked on real C64 + ; See Computes Mapping the Commodore 64 - page 98 + ; Initial DATPTR value checked on real C64 -#if HAS_OPCODES_65CE02 +!ifdef HAS_OPCODES_65CE02 { lda TXTTAB+0 sta DATPTR+0 @@ -89,7 +94,7 @@ do_restore: dew DATPTR -#else +} else { sec lda TXTTAB+0 @@ -98,10 +103,8 @@ do_restore: lda TXTTAB+1 sbc #$00 sta DATPTR+1 - -#endif +} rts - -#endif // ROM layout +} ; ROM layout diff --git a/src/basic/engine_runtime/end_of_statement.s b/src/basic/engine_runtime/end_of_statement.s index 8216d144..9b9af397 100644 --- a/src/basic/engine_runtime/end_of_statement.s +++ b/src/basic/engine_runtime/end_of_statement.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Executes the next command - after previous got finished -// +; +; Executes the next command - after previous got finished +; end_of_statement: @@ -12,12 +12,12 @@ end_of_statement: jsr tmpstr_free_all jsr fetch_character_skip_spaces - cmp #$3A // check for colon - beq_16 execute_statements + cmp #$3A ; check for colon + +beq execute_statements - cmp #$00 // check for end of the line - beq_16 execute_statements_end_of_line + cmp #$00 ; check for end of the line + +beq execute_statements_end_of_line - // Unexpected character + ; Unexpected character jmp do_SYNTAX_error diff --git a/src/basic/engine_runtime/execute_line_statements.s b/src/basic/engine_runtime/execute_line_statements.s index dd1d3b99..cd9dcfd3 100644 --- a/src/basic/engine_runtime/execute_line_statements.s +++ b/src/basic/engine_runtime/execute_line_statements.s @@ -1,72 +1,71 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tries to execute the statement, and all the subsequent ones -// +; +; Tries to execute the statement, and all the subsequent ones +; execute_statements: - // Check for RUN/STOP + ; Check for RUN/STOP lda STKEY - bpl_16 cmd_stop + +bpl cmd_stop - // Skip over any white spaces and colons (':') -!: + ; Skip over any white spaces and colons (':') +@1: jsr fetch_character_skip_spaces - cmp #$3A // colon, can be skipped - beq !- + cmp #$3A ; colon, can be skipped + beq @1 - // Check if end of the line + ; Check if end of the line cmp #$00 beq execute_statements_end_of_line - // Not end of the line - it seems we actually have something to execute + ; Not end of the line - it seems we actually have something to execute - // Move token code to .X + ; Move token code to .X tax - // Push the 'end_of_statement' address for RTS + ; Push the 'end_of_statement' address for RTS lda #>(end_of_statement - 1) pha lda #<(end_of_statement - 1) pha - // Check if token is valid for execution + ; Check if token is valid for execution -#if HAS_SMALL_BASIC +!ifdef HAS_SMALL_BASIC { cpx #$01 beq execute_statements_01 -#else +} else { -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { cpx #$04 -#else +} else { cpx #$03 -#endif +} bcc execute_statements_extended - -#endif +} cpx #$CB - beq_16 cmd_go // // 'GO' command has a strange token, placed after function tokens + +beq cmd_go ; 'GO' command has a strange token, placed after function tokens cpx #$7F - bcc_16 execute_statements_var_assign // not a token - try variable assign + +bcc execute_statements_var_assign ; not a token - try variable assign cpx #$A7 - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error -#if !HAS_OPCODES_65C02 +!ifndef HAS_OPCODES_65C02 { - // Get the jump table entry for it, push it on the stack, and then RTS to start it. + ; Get the jump table entry for it, push it on the stack, and then RTS to start it. lda command_jumptable_hi - $80, x pha @@ -75,24 +74,23 @@ execute_statements: rts -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 - // Use jumptable to go to the command routine + ; Use jumptable to go to the command routine txa asl tax jmp (command_jumptable, x) +} -#endif - -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { execute_statements_extended: - // Support for extended BASIC commands + ; Support for extended BASIC commands - // XXX consider jumpable here + ; XXX consider jumpable here cpx #$01 beq execute_statements_01 @@ -100,33 +98,31 @@ execute_statements_extended: cpx #$02 beq execute_statements_02 -#if ROM_LAYOUT_M65 +!ifdef CONGIH_MB_M65 { cpx #$03 beq execute_statements_03 - -#endif +} jmp do_SYNTAX_error - -#endif +} execute_statements_01: - // Get the sub-token, check that it is valid + ; Get the sub-token, check that it is valid jsr fetch_character cmp #$00 - beq_16 do_SYNTAX_error + +beq do_SYNTAX_error cmp #(TK__MAXTOKEN_keywords_01+1) - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - // Execute command + ; Execute command -#if !HAS_OPCODES_65C02 +!ifndef HAS_OPCODES_65C02 { - // Get the jump table entry for it, push it on the stack, and then RTS to start it. + ; Get the jump table entry for it, push it on the stack, and then RTS to start it. tax lda command_01_jumptable_hi - 1, x @@ -136,34 +132,33 @@ execute_statements_01: rts -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 - // Use jumptable to go to the command routine + ; Use jumptable to go to the command routine asl tax jmp (command_01_jumptable - 2, x) +} -#endif - -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { execute_statements_02: - // Get the sub-token, check that it is valid + ; Get the sub-token, check that it is valid jsr fetch_character cmp #$00 - beq_16 do_SYNTAX_error + +beq do_SYNTAX_error cmp #(TK__MAXTOKEN_keywords_02+1) - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - // Execute command + ; Execute command -#if !HAS_OPCODES_65C02 +!ifndef HAS_OPCODES_65C02 { - // Get the jump table entry for it, push it on the stack, and then RTS to start it. + ; Get the jump table entry for it, push it on the stack, and then RTS to start it. tax lda command_02_jumptable_hi - 1, x @@ -173,75 +168,74 @@ execute_statements_02: rts -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 - // Use jumptable to go to the command routine + ; Use jumptable to go to the command routine asl tax jmp (command_02_jumptable - 2, x) +} -#endif +} ; !HAS_SMALL_BASIC -#endif // !HAS_SMALL_BASIC - -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { execute_statements_03: - // Get the sub-token, check that it is valid + ; Get the sub-token, check that it is valid jsr fetch_character cmp #$00 - beq_16 do_SYNTAX_error + +beq do_SYNTAX_error cmp #(TK__MAXTOKEN_keywords_03+1) - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - // Use jumptable to go to the command routine + ; Use jumptable to go to the command routine asl tax jmp (command_03_jumptable - 2, x) -#endif // ROM_LAYOUT_M65 +} ; CONFIG_MB_M65 execute_statements_end_of_line: - // First check, if we are in direct mode - if so, - // end the execution and go to main loop + ; First check, if we are in direct mode - if so, + ; end the execution and go to main loop ldx CURLIN+1 inx - beq_16 shell_main_loop + +beq shell_main_loop - // Advance to the next line - first copy the line number - // to previous line number + ; Advance to the next line - first copy the line number + ; to previous line number lda CURLIN+0 sta OLDLIN+0 lda CURLIN+1 sta OLDLIN+1 - // Advance the basic line pointer to the next line; if end, - // go to the main loop + ; Advance the basic line pointer to the next line; if end, + ; go to the main loop jsr follow_link_to_next_line lda OLDTXT+0 ora OLDTXT+1 - beq_16 shell_main_loop + +beq shell_main_loop - // FALLTROUGH + ; FALLTROUGH execute_line: - // Check if pointer is null, if so, we are at the end of the program + ; Check if pointer is null, if so, we are at the end of the program jsr is_line_pointer_null - beq_16 shell_main_loop // branch if end of program reached + +beq shell_main_loop ; branch if end of program reached - // Skip pointer and line number to get address of first statement + ; Skip pointer and line number to get address of first statement lda OLDTXT+0 clc @@ -253,25 +247,25 @@ execute_line: ldy #$02 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #=', '<=' and '<>' operators + ; Now we have to recognize '>=', '<=' and '<>' operators cmp #$07 beq fetch_operator_try_gteq @@ -32,7 +32,7 @@ fetch_operator: // XXX change the operator code to start from 0 cmp #$09 beq fetch_operator_try_lteq_neq - // FALLTROUGH + ; FALLTROUGH fetch_operator_success: @@ -41,11 +41,11 @@ fetch_operator_success: fetch_operator_failed: -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} sec rts @@ -53,54 +53,54 @@ fetch_operator_failed: fetch_operator_try_gteq: - // Here we distinguish between '>' and '>=' + ; Here we distinguish between '>' and '>=' jsr fetch_character - cmp #$B2 // '=' - beq !+ + cmp #$B2 ; '=' + beq @1 - // This is a '>' + ; This is a '>' -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} lda #$07 - bne fetch_operator_success // branch always -!: - // This is a '>=' + bne fetch_operator_success ; branch always +@1: + ; This is a '>=' lda #$0A - bne fetch_operator_success // branch always + bne fetch_operator_success ; branch always fetch_operator_try_lteq_neq: - // Here we distinguish between '<', '<=', and '<>' + ; Here we distinguish between '<', '<=', and '<>' jsr fetch_character - cmp #$B2 // '=' - beq !+ - cmp #$B1 // '>' - beq !++ + cmp #$B2 ; '=' + beq @2 + cmp #$B1 ; '>' + beq @3 - // This is a '<' + ; This is a '<' -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} lda #$09 - bne fetch_operator_success // branch always -!: - // This is a '<=' + bne fetch_operator_success ; branch always +@2: + ; This is a '<=' lda #$0B - bne fetch_operator_success // branch always -!: - // This is a '<>' + bne fetch_operator_success ; branch always +@3: + ; This is a '<>' lda #$0C - bne fetch_operator_success // branch always + bne fetch_operator_success ; branch always diff --git a/src/basic/engine_runtime/fetch_uint16.s b/src/basic/engine_runtime/fetch_uint16.s index 6a960a4a..8217a330 100644 --- a/src/basic/engine_runtime/fetch_uint16.s +++ b/src/basic/engine_runtime/fetch_uint16.s @@ -1,49 +1,49 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches unsigned 16-bit integer, stores it in LINNUM, sets Carry to indicate failure (not a number) -// -// If value above 65535, error depends on .A opn entry -// -// Preserves both .X and .Y -// +; +; Fetches unsigned 16-bit integer, stores it in LINNUM, sets Carry to indicate failure (not a number) +; +; If value above 65535, error depends on .A opn entry +; +; Preserves both .X and .Y +; fetch_uint16: - // Push the error code to stack + ; Push the error code to stack pha - // Fetch the first character (skip spaces), check if 0-9 + ; Fetch the first character (skip spaces), check if 0-9 jsr fetch_character_skip_spaces jsr convert_PETSCII_to_digit bcs fetch_uint16_rts - // First character seems to be correct - store it + ; First character seems to be correct - store it sta LINNUM+0 lda #$00 sta LINNUM+1 - // FALLTROUGH + ; FALLTROUGH fetch_uint16_loop: - // Try to fetch another digit + ; Try to fetch another digit jsr fetch_character jsr convert_PETSCII_to_digit bcs fetch_uint16_end - // We got another digit - store it + ; We got another digit - store it pha - // Multiply current LINNUM by 10 (x * 10 = (x * 2) + (x * 2) * 4) + ; Multiply current LINNUM by 10 (x * 10 = (x * 2) + (x * 2) * 4) jsr fetch_uint16_mul_LINNUM_2 bcs fetch_uint16_1PLA_error @@ -67,7 +67,7 @@ fetch_uint16_loop: sta LINNUM+1 bcs fetch_uint16_1PLA_error - // Add the new digit to LINNUM + ; Add the new digit to LINNUM pla clc @@ -78,20 +78,20 @@ fetch_uint16_loop: sta LINNUM+1 bcs fetch_uint16_error - // Next iteration + ; Next iteration - jmp_8 fetch_uint16_loop + +bra fetch_uint16_loop fetch_uint16_end: -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} clc - // FALLTROUGH + ; FALLTROUGH fetch_uint16_rts: @@ -110,15 +110,15 @@ fetch_uint16_3PLA_error: pla pla - // FALLTROUGH + ; FALLTROUGH fetch_uint16_1PLA_error: pla - // FALLTROUGH + ; FALLTROUGH fetch_uint16_error: - plx_trash_a + +plx_trash_a jmp do_basic_error diff --git a/src/basic/engine_runtime/fetch_uint8.s b/src/basic/engine_runtime/fetch_uint8.s index 75d8c685..03233205 100644 --- a/src/basic/engine_runtime/fetch_uint8.s +++ b/src/basic/engine_runtime/fetch_uint8.s @@ -1,27 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches 8-bit unsigned integer -// +; +; Fetches 8-bit unsigned integer +; fetch_coma_uint8: jsr injest_comma - bcs !+ + bcs fetch_uint8_end - // FALLTROUGH + ; FALLTROUGH fetch_uint8: - lda #IDX__EV2_0E // 'ILLEGAL QUANTITY ERROR' + lda #IDX__EV2_0E ; 'ILLEGAL QUANTITY ERROR' jsr fetch_uint16 - bcs !+ + bcs fetch_uint8_end lda LINNUM+1 - bne_16 do_ILLEGAL_QUANTITY_error + +bne do_ILLEGAL_QUANTITY_error lda LINNUM+0 clc -!: + + ; FALLTROUGH + +fetch_uint8_end: + rts diff --git a/src/basic/engine_runtime/follow_link_to_next_line.s b/src/basic/engine_runtime/follow_link_to_next_line.s index 99899f20..42b697b4 100644 --- a/src/basic/engine_runtime/follow_link_to_next_line.s +++ b/src/basic/engine_runtime/follow_link_to_next_line.s @@ -1,30 +1,32 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE follow_link_to_next_line: ldy #0 -#if CONFIG_MEMORY_MODEL_60K + ; XXX! for models 46K/50K provide optimized version + +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #const_PI jsr mov_MEM_FAC1 - jmp_8 FRMEVL_got_value_float + +bra FRMEVL_got_value_float -// -// This subroutine fetches the floating point value from the 'outside world' -// +; +; This subroutine fetches the floating point value from the 'outside world' +; FRMEVL_fetch_float: - // XXX implement this + ; XXX implement this jmp do_NOT_IMPLEMENTED_error - // FALLTROUGH + ; FALLTROUGH FRMEVL_got_value_float: @@ -187,13 +186,13 @@ FRMEVL_got_value_float: sta VALTYP beq FRMEVL_got_value -// -// This subroutine fetches the string value from the 'outside world' -// +; +; This subroutine fetches the string value from the 'outside world' +; FRMEVL_fetch_string: - // Mark return value as a string, set initial length as 0 + ; Mark return value as a string, set initial length as 0 ldx #$FF stx VALTYP @@ -201,69 +200,69 @@ FRMEVL_fetch_string: inx stx __FAC1 + 0 - // Set pointer to start of the string + ; Set pointer to start of the string ldx TXTPTR + 0 stx __FAC1 + 1 ldx TXTPTR + 1 stx __FAC1 + 2 -!: - // Search for closing quote +@1: + ; Search for closing quote jsr fetch_character cmp #$22 beq FRMEVL_got_value cmp #$00 - beq !+ + beq @2 inc __FAC1 + 0 - bne !- + bne @1 jmp do_STRING_TOO_LONG_error -!: - // No closing quote, but end of the data +@2: + ; No closing quote, but end of the data -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} - // FALLTROUGH + ; FALLTROUGH -// -// This subroutine handles the situation after fetching the value from 'outside world': -// - either there is nothing sane remaining there; if so, this value is or final result -// - or there is an operator following the value; in such case we have much more work to do; -// we push the current value and the operator to the stack and we proceed to fetch the next -// value (which is mandatory) -// small catch: if the priority of the new operator is not higher than priority of the last -// operator on the stack (sentinel is considered as the lowest priority operator) we first -// compute what currently is present on the stack - this enforces proper operator precedence -// +; +; This subroutine handles the situation after fetching the value from 'outside world': +; - either there is nothing sane remaining there; if so, this value is or final result +; - or there is an operator following the value; in such case we have much more work to do; +; we push the current value and the operator to the stack and we proceed to fetch the next +; value (which is mandatory) +; small catch: if the priority of the new operator is not higher than priority of the last +; operator on the stack (sentinel is considered as the lowest priority operator) we first +; compute what currently is present on the stack - this enforces proper operator precedence +; FRMEVL_got_value: jsr is_end_of_statement - bcs FRMEVL_compute_all // compute the stack if expression ended + bcs FRMEVL_compute_all ; compute the stack if expression ended - // FALLTROUGH + ; FALLTROUGH FRMEVL_fetch_operator: - // We have a value, but this is not the end of expression. Check if - // there is an operator waiting to be served + ; We have a value, but this is not the end of expression. Check if + ; there is an operator waiting to be served jsr fetch_operator - bcs FRMEVL_compute_all // if operator not recognized, compute what we have - // on stack and quit + bcs FRMEVL_compute_all ; if operator not recognized, compute what we have + ; on stack and quit - // Move the new operator ID to .Y + ; Move the new operator ID to .Y tay - // Compare the priority of the last operator with the new one + ; Compare the priority of the last operator with the new one pla pha @@ -271,39 +270,43 @@ FRMEVL_fetch_operator: cmp operator_priorities, y bcc FRMEVL_push_value_operator - // Here the priority is not higher - so compute what we already have on stack - // but do not finish proccessing + ; Here the priority is not higher - so compute what we already have on stack + ; but do not finish proccessing - sty OPPTR+1 // store .Y, we want to preserve it - lda #$FF // mark that we want to return here + sty OPPTR+1 ; store .Y, we want to preserve it + lda #$FF ; mark that we want to return here sta OPPTR+0 -!: + + ; FALLTROUGH + +FRMEVL_fetch_operator_end: + jmp FRMEVL_compute_partial FRMEVL_compute_partial_return: pla pha - bne !- + bne FRMEVL_fetch_operator_end ldy OPPTR+1 - // FALLTROUGH + ; FALLTROUGH FRMEVL_push_value_operator: - // Push the value from FAC1 + ; Push the value from FAC1 ldx VALTYP bmi FRMEVL_push_string - // Push float + ; Push float - // XXX implement this + ; XXX implement this FRMEVL_push_string: - // Push string - length, address, type + ; Push string - length, address, type lda __FAC1+0 pha @@ -316,56 +319,56 @@ FRMEVL_push_string: txa pha - // FALLTROUGH + ; FALLTROUGH FRMEVL_push_operator_address: - // Check if there is enough stack space; this could not have been done earlier, - // as this is the place where unary operator support calls + ; Check if there is enough stack space; this could not have been done earlier, + ; as this is the place where unary operator support calls jsr check_stack_space - // Push the operator address to stack, in a form - // suitable for RTS + ; Push the operator address to stack, in a form + ; suitable for RTS lda operator_jumptable_hi, y pha lda operator_jumptable_lo, y pha - // Push operator priority + ; Push operator priority lda operator_priorities, y pha - // Continue + ; Continue jmp FRMEVL_loop -// -// This part serves two purposes: -// - it is an exit point for the concrete operator implementations -// - it causes computation of everything which is stored on the stack -// +; +; This part serves two purposes: +; - it is an exit point for the concrete operator implementations +; - it causes computation of everything which is stored on the stack +; FRMEVL_compute_all: lda #$00 sta OPPTR+0 - // FALLTROUGH + ; FALLTROUGH FRMEVL_continue: lda OPPTR+0 bne FRMEVL_compute_partial_return - // FALLTROUGH + ; FALLTROUGH FRMEVL_compute_partial: - // Now, we have to compute operation; at this point we should have a value - // in FAC1 and (most likely) operator on a stack + ; Now, we have to compute operation; at this point we should have a value + ; in FAC1 and (most likely) operator on a stack - pla // priority does not matter here, get rid of it - rts // this either jumps to operator, or quits FRMEVL + pla ; priority does not matter here, get rid of it + rts ; this either jumps to operator, or quits FRMEVL diff --git a/src/basic/engine_runtime/helper_frmevl_strdesccpy_46K_50K.s b/src/basic/engine_runtime/helper_frmevl_strdesccpy_46K_50K.s index 249dbb7d..75d2f552 100644 --- a/src/basic/engine_runtime/helper_frmevl_strdesccpy_46K_50K.s +++ b/src/basic/engine_runtime/helper_frmevl_strdesccpy_46K_50K.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routines below banks out the main BASIC ROM! +; This has to go $E000 or above - routines below banks out the main BASIC ROM! -// -// Helper routine to copy string descriptor, for expression evaluator -// +; +; Helper routine to copy string descriptor, for expression evaluator +; -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_frmevl_strdesccpy: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Copy string descriptor + ; Copy string descriptor ldy #$00 lda (VARPNT),y @@ -30,15 +30,14 @@ helper_frmevl_strdesccpy: lda (VARPNT),y sta __FAC1+2 - // FALLTROUGH + ; FALLTROUGH remap_BASIC: - // Restore default memory mapping + ; Restore default memory mapping lda #$27 sta CPU_R6510 rts - -#endif +} diff --git a/src/basic/engine_runtime/init_oldtxt.s b/src/basic/engine_runtime/init_oldtxt.s index 9879e463..3078170a 100644 --- a/src/basic/engine_runtime/init_oldtxt.s +++ b/src/basic/engine_runtime/init_oldtxt.s @@ -1,6 +1,6 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE init_oldtxt: diff --git a/src/basic/engine_runtime/injest_assign.s b/src/basic/engine_runtime/injest_assign.s index 56456299..360aed7f 100644 --- a/src/basic/engine_runtime/injest_assign.s +++ b/src/basic/engine_runtime/injest_assign.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Consummes assign operator in a BASIC code, triggers error if not found -// +; +; Consummes assign operator in a BASIC code, triggers error if not found +; injest_assign: jsr fetch_character_skip_spaces - cmp #$B2 // assign operator character - bne_16 do_SYNTAX_error + cmp #$B2 ; assign operator character + +bne do_SYNTAX_error rts diff --git a/src/basic/engine_runtime/injest_comma.s b/src/basic/engine_runtime/injest_comma.s index ff712d0e..7a17f8bd 100644 --- a/src/basic/engine_runtime/injest_comma.s +++ b/src/basic/engine_runtime/injest_comma.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Consummes a comma in a BASIC code, Carry set if not found. Injests all spaces. -// +; +; Consummes a comma in a BASIC code, Carry set if not found. Injests all spaces. +; injest_comma: jsr fetch_character_skip_spaces - cmp #$2C // comma character + cmp #$2C ; comma character beq injest_comma_found - // Not found + ; Not found -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} sec rts diff --git a/src/basic/engine_runtime/is_alphanumeric.s b/src/basic/engine_runtime/is_alphanumeric.s index fa85c4c5..317833a0 100644 --- a/src/basic/engine_runtime/is_alphanumeric.s +++ b/src/basic/engine_runtime/is_alphanumeric.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Check .A content, if within 0-9, A-Z ranges, sets Carry if check fails -// +; +; Check .A content, if within 0-9, A-Z ranges, sets Carry if check fails +; is_09_AZ: @@ -17,19 +17,19 @@ is_09_AZ: is_09: - cmp #$30 // if below '0' - check failed + cmp #$30 ; if below '0' - check failed bcc is_alphanumeric_fail - cmp #$3A // if above '9' - check failed + cmp #$3A ; if above '9' - check failed rts is_AZ: - cmp #$41 // if below 'A' - check failed + cmp #$41 ; if below 'A' - check failed bcc is_alphanumeric_fail - cmp #$7B // if above 'Z' - check failed + cmp #$7B ; if above 'Z' - check failed rts diff --git a/src/basic/engine_runtime/is_end_of_statement.s b/src/basic/engine_runtime/is_end_of_statement.s index 32cbfcb0..a14fb6fb 100644 --- a/src/basic/engine_runtime/is_end_of_statement.s +++ b/src/basic/engine_runtime/is_end_of_statement.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Check for end of statement, sets Carry if so. Injests all spaces. -// +; +; Check for end of statement, sets Carry if so. Injests all spaces. +; is_end_of_statement: @@ -12,28 +12,28 @@ is_end_of_statement: jsr fetch_character_skip_spaces cmp #$00 - beq !+ + beq @1 cmp #$3A - beq !+ + beq @1 - // Not end of statement + ; Not end of statement -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} clc rts -!: - // End of statement +@1: + ; End of statement -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { jsr unconsume_character -#else +} else { dew TXTPTR -#endif +} sec rts diff --git a/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s b/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s index 5ca5b151..2650d389 100644 --- a/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s +++ b/src/basic/engine_runtime/is_line_pointer_null_38K_60K.s @@ -1,37 +1,36 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Return pointer in BASIC memory space status in Z flag +; Return pointer in BASIC memory space status in Z flag -#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K +!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K { is_line_pointer_null: - // Check the pointer + ; Check the pointer - ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL + ldy #$01 ; for non-NULL pointer, high byte is almost certainly not NULL -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #BUF sta TXTPTR+1 - // There is no stored line, so zero that pointer out + ; There is no stored line, so zero that pointer out lda #$00 sta OLDTXT+0 sta OLDTXT+1 - // Put invalid line number in current line number value, - // so that we know we are in direct mode (Computes Mapping the 64 p19) + ; Put invalid line number in current line number value, + ; so that we know we are in direct mode (Computes Mapping the 64 p19) lda #$FF sta CURLIN+1 rts -#endif // ROM layout +} ; ROM layout diff --git a/src/basic/engine_runtime/unconsume_character.s b/src/basic/engine_runtime/unconsume_character.s index 73609eff..13ff587a 100644 --- a/src/basic/engine_runtime/unconsume_character.s +++ b/src/basic/engine_runtime/unconsume_character.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Reverses character fetch -// +; +; Reverses character fetch +; -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { unconsume_character: @@ -19,5 +19,4 @@ unconsume_character: sta TXTPTR+1 rts - -#endif +} diff --git a/src/basic/engine_variables/array_create.s b/src/basic/engine_variables/array_create.s index 15a0f982..1e97df8c 100644 --- a/src/basic/engine_variables/array_create.s +++ b/src/basic/engine_variables/array_create.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE array_create: - // First retrieve array name + ; First retrieve array name jsr fetch_variable_name - bcs_16 do_SYNTAX_error + +bcs do_SYNTAX_error - // Make sure the array does not exist + ; Make sure the array does not exist jsr find_array - bcc_16 do_REDIMD_ARRAY_error + +bcc do_REDIMD_ARRAY_error - // Push variable name and FOUR6 on the stack - fetching dimensions might cause - // the to be overwritten by the expression parser + ; Push variable name and FOUR6 on the stack - fetching dimensions might cause + ; the to be overwritten by the expression parser lda VARNAM+1 pha @@ -25,7 +25,7 @@ array_create: lda FOUR6 pha - // Check if the array dimension is given - if not, assume '10' was specified + ; Check if the array dimension is given - if not, assume '10' was specified bit DIMFLG bmi array_create_fetch_dims @@ -35,78 +35,78 @@ array_create: lda #$00 pha ldx #$01 - bne array_create_store_dims // branch always + bne array_create_store_dims ; branch always array_create_fetch_dims: - ldx #$00 // counts number of dimensions + ldx #$00 ; counts number of dimensions - // FALLTROUGH + ; FALLTROUGH array_create_fetch_dims_loop: inx - // Fetch the dimension, increment it by 1, and put it on the stack; - // confirmed with original ROM, that it also stores dimensions in the reverse order + ; Fetch the dimension, increment it by 1, and put it on the stack; + ; confirmed with original ROM, that it also stores dimensions in the reverse order jsr helper_fetch_arr_coord -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { inc LINNUM+0 - bne !+ + bne @1 inc LINNUM+1 -!: -#else +@1: +} else { inw LINNUM -#endif +} - beq_16 do_OUT_OF_MEMORY_error + +beq do_OUT_OF_MEMORY_error lda LINNUM+0 pha lda LINNUM+1 pha - // Check if more dimensions are given + ; Check if more dimensions are given cpy #$00 beq array_create_fetch_dims_loop - // FALLTROUGH + ; FALLTROUGH array_create_store_dims: - // We got the dimensions, time to alocate memory. Arrays are not declared too often, - // it will be easier if we perform the garbage collection now + ; We got the dimensions, time to alocate memory. Arrays are not declared too often, + ; it will be easier if we perform the garbage collection now - phx_trash_a + +phx_trash_a jsr varstr_garbage_collect - // __FAC1+1/+2 will be used to calculate number of elements + ; __FAC1+1/+2 will be used to calculate number of elements ldy #$01 sty __FAC1+1 dey sty __FAC1+2 - // Check if there is enough free memory for the header + ; Check if there is enough free memory for the header - pla // .A - number of dimensions + pla ; .A - number of dimensions sta __FAC1+0 jsr helper_array_create_checkmem lda __FAC1+0 - // Create the initial array structure (header) - format checked by creating arrays with original ROM + ; Create the initial array structure (header) - format checked by creating arrays with original ROM - // Bytes 0/1 - array name, but we can not fetch it easily now, so skip it for now - // Bytes 2/3 - offset to the next array, skip it for now too - // Byte 4 - number of dimensions - // Bytes 5+ - max index in each dimension (big endian!), this will be set in a loop + ; Bytes 0/1 - array name, but we can not fetch it easily now, so skip it for now + ; Bytes 2/3 - offset to the next array, skip it for now too + ; Byte 4 - number of dimensions + ; Bytes 5+ - max index in each dimension (big endian!), this will be set in a loop ldy #$04 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { stx INDEX+2 @@ -115,20 +115,19 @@ array_create_store_dims: ldx INDEX+2 -#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K sta (STREND), y +} -#endif + iny ; .Y - index to store dimension sizes + tax ; .X - dimensions not stored yet - iny // .Y - index to store dimension sizes - tax // .X - dimensions not stored yet - - // FALLTROUGH + ; FALLTROUGH array_create_store_loop: -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { stx INDEX+2 ldx #(assign_variable_arr_ret-1) pha lda #<(assign_variable_arr_ret-1) pha - // Store FOUR6 on tha stack + ; Store FOUR6 on tha stack lda FOUR6 pha - // Retrieve all the coordinates + ; Retrieve all the coordinates ldx #$00 -!: +@1: inx jsr helper_fetch_arr_coord @@ -39,44 +39,44 @@ assign_variable: lda LINNUM+0 pha - // Check if more dimensions are given + ; Check if more dimensions are given cpy #$00 - beq !- + beq @1 - // Store number of dimensions on the stack + ; Store number of dimensions on the stack - phx_trash_a + +phx_trash_a - // Fetch assignment operator and continue + ; Fetch assignment operator and continue jsr injest_assign - lda #$FF // force DIMFLG to be array - jmp_8 assign_variable_common_1 + lda #$FF ; force DIMFLG to be array + +bra assign_variable_common_1 assign_variable_not_array_1: - // Require assignment operator + ; Require assignment operator jsr injest_assign - // Check for special variables + ; Check for special variables jsr is_var_TI_string - beq_16 assign_variable_TI_string + +beq assign_variable_TI_string jsr is_var_TI - beq_16 do_SYNTAX_error + +beq do_SYNTAX_error jsr is_var_ST - beq_16 do_SYNTAX_error + +beq do_SYNTAX_error - // Push the DIMFLG and VARNAM to the stack - it might get overridden + ; Push the DIMFLG and VARNAM to the stack - it might get overridden lda DIMFLG - // FALLTROUGH + ; FALLTROUGH assign_variable_common_1: @@ -86,191 +86,188 @@ assign_variable_common_1: lda VARNAM+1 pha - // Evaluate the expression + ; Evaluate the expression jsr FRMEVL - // Restore VARNAM and DIMFLG + ; Restore VARNAM and DIMFLG pla sta VARNAM+1 pla sta VARNAM+0 pla - sta DIMFLG // XXX is it needed? + sta DIMFLG ; XXX is it needed? - // Check if array + ; Check if array bpl assign_variable_not_array_2 - // Yes, this is an array - preserve FAC1 values which might get overwritten - // XXX adapt this for floats! + ; Yes, this is an array - preserve FAC1 values which might get overwritten + ; XXX adapt this for floats! ldx #$04 -!: +@2: lda __FAC1,x sta __FAC2,x dex - bpl !- + bpl @2 - // Get array address + ; Get array address jsr find_array - bcc !+ + bcc @3 - // Array does not exist - we will have to create one with default parameters + ; Array does not exist - we will have to create one with default parameters - // XXX implement this + ; XXX implement this jmp do_NOT_IMPLEMENTED_error -!: - // Fetch the number of dimensions +@3: + ; Fetch the number of dimensions pla sta __FAC1+0 tax - // Fetch the address of the variable + ; Fetch the address of the variable - jmp fetch_variable_arr_calc_pos // RTS goes to assign_variable_arr_ret + jmp fetch_variable_arr_calc_pos ; RTS goes to assign_variable_arr_ret assign_variable_arr_ret: - // Restore FAC1 values - // XXX adapt this for floats! + ; Restore FAC1 values + ; XXX adapt this for floats! ldx #$04 -!: +@4: lda __FAC2,x sta __FAC1,x dex - bpl !- - bmi assign_variable_common_2 // branch always + bpl @4 + bmi assign_variable_common_2 ; branch always assign_variable_not_array_2: - // Retrieve the variable address + ; Retrieve the variable address jsr fetch_variable_find_addr - // FALLTROUGH + ; FALLTROUGH assign_variable_common_2: - // Determine variable type + ; Determine variable type lda #$00 clc bit VARNAM+0 - bpl !+ + bpl @5 adc #$01 -!: +@5: bit VARNAM+1 - bpl !+ + bpl @6 adc #$80 -!: - // Determine what to assign +@6: + ; Determine what to assign bmi assign_string beq assign_float - // FALLTROUGH + ; FALLTROUGH - // XXX integer and float probably have much in common + ; XXX integer and float probably have much in common assign_integer: lda VALTYP - bmi_16 do_TYPE_MISMATCH_error + +bmi do_TYPE_MISMATCH_error -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // XXX - // XXX: implement this - // XXX + ; XXX + ; XXX: implement this + ; XXX -#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K - // XXX consider optimized version without multiple JSRs +} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { + ; XXX consider optimized version without multiple JSRs - // XXX - // XXX: implement this - // XXX + ; XXX + ; XXX: implement this + ; XXX -#else // CONFIG_MEMORY_MODEL_38K - - // XXX - // XXX: implement this - // XXX - -#endif +} else { ; CONFIG_MEMORY_MODEL_38K + ; XXX + ; XXX: implement this + ; XXX +} jmp do_NOT_IMPLEMENTED_error assign_float: lda VALTYP - bmi_16 do_TYPE_MISMATCH_error + +bmi do_TYPE_MISMATCH_error -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // XXX - // XXX: implement this - // XXX + ; XXX + ; XXX: implement this + ; XXX -#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K - // XXX consider optimized version without multiple JSRs +} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { + ; XXX consider optimized version without multiple JSRs - // XXX - // XXX: implement this - // XXX + ; XXX + ; XXX: implement this + ; XXX -#else // CONFIG_MEMORY_MODEL_38K +} else { ; CONFIG_MEMORY_MODEL_38K - // XXX - // XXX: implement this - // XXX - -#endif + ; XXX + ; XXX: implement this + ; XXX +} jmp do_NOT_IMPLEMENTED_error assign_string: - // Check if value type matches + ; Check if value type matches lda VALTYP - bpl_16 do_TYPE_MISMATCH_error + +bpl do_TYPE_MISMATCH_error - // Copy the string descriptor to DSCPNT + ; Copy the string descriptor to DSCPNT jsr helper_strdesccpy - // First special case - check if the new string has size 0 + ; First special case - check if the new string has size 0 lda __FAC1+0 bne assign_string_not_empty - // Yes, it is empty - free the old one + ; Yes, it is empty - free the old one jsr varstr_free - // Set the new variable as empty string + ; Set the new variable as empty string ldy #$00 lda #$00 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #= 7) + ; First check if we have enough space for a new descriptor (if FRETOP - STREND >= 7) sec lda FRETOP+0 @@ -102,21 +102,21 @@ fetch_variable_alocate: pha lda FRETOP+1 sbc STREND+1 - bne !+ // branch if high byte of result > 0 + bne @3 ; branch if high byte of result > 0 pla cmp #$07 bcs fetch_variable_alocate_space_OK jmp do_OUT_OF_MEMORY_error -!: +@3: pla - // FALLTROUGH + ; FALLTROUGH fetch_variable_alocate_space_OK: - // If arrays exist, we need to move them upwards + ; If arrays exist, we need to move them upwards sec lda STREND+0 @@ -131,12 +131,12 @@ fetch_variable_alocate_space_OK: ora memmove__size+0 beq fetch_variable_alocate_adjust_vars - // Indeed, there are arrays - adjust size, calculate the destination and perform copying + ; Indeed, there are arrays - adjust size, calculate the destination and perform copying inc memmove__size+0 - bne !+ + bne @4 inc memmove__size+1 -!: +@4: clc lda memmove__src+0 @@ -148,38 +148,38 @@ fetch_variable_alocate_space_OK: jsr shift_mem_up - // FALLTROUGH + ; FALLTROUGH fetch_variable_alocate_adjust_vars: - // Adjust ARYTAB and STREND + ; Adjust ARYTAB and STREND clc lda STREND+0 adc #$07 sta STREND+0 - bcc !+ + bcc @5 inc STREND+1 -!: +@5: clc lda ARYTAB+0 adc #$07 sta ARYTAB+0 - bcc !+ + bcc @6 inc ARYTAB+1 -!: - // VARPNT already points to the start of the variable descriptor +@6: + ; VARPNT already points to the start of the variable descriptor - // We need to recreate the back-pointers to string arrays + ; We need to recreate the back-pointers to string arrays jsr helper_array_refresh_bptrs - // Fill-in the new variable name and descriptor (it is enough to zero first 2 bytes of content) + ; Fill-in the new variable name and descriptor (it is enough to zero first 2 bytes of content) ldy #$00 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx # 0, then we certainly have enough space + ; If high byte (INDEX+3) > 0, then we certainly have enough space lda INDEX+3 bne helper_array_create_checkmem_success - // We have very little memory left - we need at least number of dimensions*2 + 5 bytes + ; We have very little memory left - we need at least number of dimensions*2 + 5 bytes lda __FAC1+0 asl @@ -51,7 +51,7 @@ helper_array_create_checkmem: cmp INDEX+2 bcs helper_array_create_checkmem_fail - // FALLTROUGH + ; FALLTROUGH helper_array_create_checkmem_success: diff --git a/src/basic/engine_variables/helper_array_create_mul.s b/src/basic/engine_variables/helper_array_create_mul.s index fca065b5..b974a2d2 100644 --- a/src/basic/engine_variables/helper_array_create_mul.s +++ b/src/basic/engine_variables/helper_array_create_mul.s @@ -1,51 +1,51 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// 16-bit multiplication, INDEX+0/+1 = __FAC1+1/+2 * __FAC1+3/+4; __FAC1+1/+2 = INDEX+0/+1 -// uses INDEX+2/+3 (for helper routine) as work area +; 16-bit multiplication, INDEX+0/+1 = __FAC1+1/+2 * __FAC1+3/+4; __FAC1+1/+2 = INDEX+0/+1 +; uses INDEX+2/+3 (for helper routine) as work area -helper_array_create_mul: // preserves .X and .Y +helper_array_create_mul: ; preserves .X and .Y - phx_trash_a + +phx_trash_a - // We will reuse 8x8 multiplication routine used by floating point operations + ; We will reuse 8x8 multiplication routine used by floating point operations - // __FAC1+1 (lo byte) * __FAC1+3 (lo byte) + ; __FAC1+1 (lo byte) * __FAC1+3 (lo byte) lda __FAC1+1 sta INDEX+3 lda __FAC1+3 - jsr mul_FAC2_FAC1_8x8 // this preserves .Y + jsr mul_FAC2_FAC1_8x8 ; this preserves .Y - sta INDEX+0 // result - lo byte - stx INDEX+1 // result - hi byte + sta INDEX+0 ; result - lo byte + stx INDEX+1 ; result - hi byte - // __FAC1+1 (lo byte) * __FAC1+4 (hi byte) + ; __FAC1+1 (lo byte) * __FAC1+4 (hi byte) lda __FAC1+1 sta INDEX+3 lda __FAC1+4 - jsr helper_array_create_mul_8x8_add // multiply and add to high byte of the result + jsr helper_array_create_mul_8x8_add ; multiply and add to high byte of the result - // __FAC1+2 (hi byte) * __FAC1+3 (lo byte) + ; __FAC1+2 (hi byte) * __FAC1+3 (lo byte) lda __FAC1+2 sta INDEX+3 lda __FAC1+3 - jsr helper_array_create_mul_8x8_add // multiply and add to high byte of the result + jsr helper_array_create_mul_8x8_add ; multiply and add to high byte of the result - // __FAC1+2 (hi byte) * __FAC1+4 (hi byte) has to be 0, - // otherwise the result would be out of range - // do not calculate + ; __FAC1+2 (hi byte) * __FAC1+4 (hi byte) has to be 0, + ; otherwise the result would be out of range + ; do not calculate lda __FAC1+2 beq helper_array_create_mul_success lda __FAC1+4 beq helper_array_create_mul_success - // FALLTROUGH + ; FALLTROUGH helper_array_create_mul_error: @@ -58,7 +58,7 @@ helper_array_create_mul_success: lda INDEX+1 sta __FAC1+2 - plx_trash_a + +plx_trash_a rts helper_array_create_mul_8x8_add: diff --git a/src/basic/engine_variables/helper_array_fetch_dimension_46K_50K.s b/src/basic/engine_variables/helper_array_fetch_dimension_46K_50K.s index c53efb9e..aec2f8b2 100644 --- a/src/basic/engine_variables/helper_array_fetch_dimension_46K_50K.s +++ b/src/basic/engine_variables/helper_array_fetch_dimension_46K_50K.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routine below banks out the main BASIC ROM! +; This has to go $E000 or above - routine below banks out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_array_fetch_dimension: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Fetch the dimension + ; Fetch the dimension lda (VARPNT), y sta __FAC1+4 @@ -22,11 +22,10 @@ helper_array_fetch_dimension: sta __FAC1+3 iny - // Restore default memory mapping + ; Restore default memory mapping lda #$27 sta CPU_R6510 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_array_refresh_bptrs.s b/src/basic/engine_variables/helper_array_refresh_bptrs.s index 616ed146..6a45f837 100644 --- a/src/basic/engine_variables/helper_array_refresh_bptrs.s +++ b/src/basic/engine_variables/helper_array_refresh_bptrs.s @@ -1,37 +1,37 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Refresh back-pointer to arrays -// +; +; Refresh back-pointer to arrays +; helper_array_refresh_bptrs: - // Refresh back-pointers to arrays + ; Refresh back-pointers to arrays lda ARYTAB+0 sta INDEX+0 lda ARYTAB+1 sta INDEX+1 - // FALLTROUGH + ; FALLTROUGH helper_array_refresh_bptrs_loop_1: - // Check if we reached end of arays + ; Check if we reached end of arrays lda INDEX+1 cmp STREND+1 - bne !+ + bne @1 lda INDEX+0 cmp STREND+0 - bne !+ + bne @1 rts -!: - // Calculate start address of the next array, store it in INDEX+2/+3 +@1: + ; Calculate start address of the next array, store it in INDEX+2/+3 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx # STREND, Carry set if not +helper_FRETOP_check: ; check if FRETOP > STREND, Carry set if not lda STREND+1 cmp FRETOP+1 - beq !+ + beq @2 rts -!: +@2: lda STREND+0 cmp FRETOP+0 rts diff --git a/src/basic/engine_variables/helper_fretop_up.s b/src/basic/engine_variables/helper_fretop_up.s index de5ee2b2..2444fde3 100644 --- a/src/basic/engine_variables/helper_fretop_up.s +++ b/src/basic/engine_variables/helper_fretop_up.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine for FRETOP handling -// +; +; Helper routine for FRETOP handling +; -helper_FRETOP_up: // DSCPNT+0 - bytes to increment FRETO +helper_FRETOP_up: ; DSCPNT+0 - bytes to increment FRETO clc lda FRETOP+0 adc DSCPNT+0 sta FRETOP+0 - bcc !+ + bcc @1 inc FRETOP+1 -!: +@1: rts diff --git a/src/basic/engine_variables/helper_gc_fetch_backpointer_46K_50K.s b/src/basic/engine_variables/helper_gc_fetch_backpointer_46K_50K.s index 1b72c7cd..4921d6c9 100644 --- a/src/basic/engine_variables/helper_gc_fetch_backpointer_46K_50K.s +++ b/src/basic/engine_variables/helper_gc_fetch_backpointer_46K_50K.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routine below banks out the main BASIC ROM! +; This has to go $E000 or above - routine below banks out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_gc_fetch_backpointer: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Copy the back-pointer to OLDTXT, check if it is NULL + ; Copy the back-pointer to OLDTXT, check if it is NULL ldy #$00 lda (TXTPTR),y @@ -25,8 +25,7 @@ helper_gc_fetch_backpointer: ora OLDTXT+0 - // Restore default memory mapping + ; Restore default memory mapping jmp remap_BASIC_preserve_P - -#endif +} diff --git a/src/basic/engine_variables/helper_gc_misc_46K_50K.s b/src/basic/engine_variables/helper_gc_misc_46K_50K.s index 503df2aa..03e93b5c 100644 --- a/src/basic/engine_variables/helper_gc_misc_46K_50K.s +++ b/src/basic/engine_variables/helper_gc_misc_46K_50K.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routines below bank out the main BASIC ROM! +; This has to go $E000 or above - routines below bank out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_gc_set_memmove_src: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Set memmove__src + ; Set memmove__src lda (OLDTXT),y sta memmove__src+0 @@ -21,18 +21,18 @@ helper_gc_set_memmove_src: lda (OLDTXT),y sta memmove__src+1 - // Restore default memory mapping + ; Restore default memory mapping - jmp_8 helper_gc_misc_end + +bra helper_gc_misc_end helper_gc_increase_oldtxt: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Increase OLDTXT accordingly + ; Increase OLDTXT accordingly lda (OLDTXT),y clc @@ -43,12 +43,11 @@ helper_gc_increase_oldtxt: adc INDEX+1 sta (OLDTXT),y - // FALLTROUGH + ; FALLTROUGH helper_gc_misc_end: - // Restore default memory mapping + ; Restore default memory mapping jmp remap_BASIC - -#endif +} diff --git a/src/basic/engine_variables/helper_index_up_a_38K_60K.s b/src/basic/engine_variables/helper_index_up_a_38K_60K.s index 54198e25..0a8e2fcb 100644 --- a/src/basic/engine_variables/helper_index_up_a_38K_60K.s +++ b/src/basic/engine_variables/helper_index_up_a_38K_60K.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine, used in several places -// +; +; Helper routine, used in several places +; -#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K +!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K { -helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSCPNT+0 +helper_INDEX_up_A: ; .A - bytes to increase INDEX, uses DSCPNT+0 sta DSCPNT+0 @@ -16,9 +16,8 @@ helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSC lda INDEX+0 adc DSCPNT+0 sta INDEX+0 - bcc !+ + bcc @1 dec INDEX+1 -!: +@1: rts - -#endif +} diff --git a/src/basic/engine_variables/helper_index_up_a_46K_50K.s b/src/basic/engine_variables/helper_index_up_a_46K_50K.s index 38ede00c..2e160b50 100644 --- a/src/basic/engine_variables/helper_index_up_a_46K_50K.s +++ b/src/basic/engine_variables/helper_index_up_a_46K_50K.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - it can be used by routines which bank out the main BASIC ROM! +; This has to go $E000 or above - it can be used by routines which bank out the main BASIC ROM! -// -// Helper routine, used in several places -// +; +; Helper routine, used in several places +; -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { -helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSCPNT+0 +helper_INDEX_up_A: ; .A - bytes to increase INDEX, uses DSCPNT+0 sta DSCPNT+0 @@ -18,9 +18,8 @@ helper_INDEX_up_A: // .A - bytes to increase INDEX, uses DSC lda INDEX+0 adc DSCPNT+0 sta INDEX+0 - bcc !+ + bcc @1 dec INDEX+1 -!: +@1: rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strconcat_46K_50K.s b/src/basic/engine_variables/helper_strconcat_46K_50K.s index e44ea918..c83ca61d 100644 --- a/src/basic/engine_variables/helper_strconcat_46K_50K.s +++ b/src/basic/engine_variables/helper_strconcat_46K_50K.s @@ -1,53 +1,52 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routines below banks out the main BASIC ROM! +; This has to go $E000 or above - routines below banks out the main BASIC ROM! -// -// Helper routine for string concatenation -// +; +; Helper routine for string concatenation +; -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_strconcat: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Copy data from the first string + ; Copy data from the first string ldy #$00 -!: +@1: lda (__FAC2+1),y sta (INDEX),y iny cpy __FAC2+0 - bne !- + bne @1 - // Increase INDEX pointer by the size of the 1st string + ; Increase INDEX pointer by the size of the 1st string tya jsr helper_INDEX_up_A - // Copy data from the second string + ; Copy data from the second string ldy #$00 -!: +@2: lda (__FAC1+1),y sta (INDEX),y iny cpy __FAC1+0 - bne !- + bne @2 - // Restore default memory mapping + ; Restore default memory mapping lda #$27 sta CPU_R6510 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strdesccpy_38K.s b/src/basic/engine_variables/helper_strdesccpy_38K.s index 04870841..3b337ee4 100644 --- a/src/basic/engine_variables/helper_strdesccpy_38K.s +++ b/src/basic/engine_variables/helper_strdesccpy_38K.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to copy string descriptor -// +; +; Helper routine to copy string descriptor +; -#if CONFIG_MEMORY_MODEL_38K +!ifdef CONFIG_MEMORY_MODEL_38K { helper_strdesccpy: @@ -22,5 +22,4 @@ helper_strdesccpy: sta DSCPNT+2 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strdesccpy_46K_50K.s b/src/basic/engine_variables/helper_strdesccpy_46K_50K.s index df7d4172..ac7a9f4d 100644 --- a/src/basic/engine_variables/helper_strdesccpy_46K_50K.s +++ b/src/basic/engine_variables/helper_strdesccpy_46K_50K.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routine below banks out the main BASIC ROM! +; This has to go $E000 or above - routine below banks out the main BASIC ROM! -// -// Helper routine to copy string descriptor -// +; +; Helper routine to copy string descriptor +; -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_strdesccpy: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve pointer to destination + ; Retrieve pointer to destination ldy #$00 lda (VARPNT), y @@ -30,11 +30,10 @@ helper_strdesccpy: lda (VARPNT), y sta DSCPNT+2 - // Restore default memory mapping + ; Restore default memory mapping lda #$27 sta CPU_R6510 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strdesccpy_60K.s b/src/basic/engine_variables/helper_strdesccpy_60K.s index 9e627a18..e3647853 100644 --- a/src/basic/engine_variables/helper_strdesccpy_60K.s +++ b/src/basic/engine_variables/helper_strdesccpy_60K.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to copy string descriptor -// +; +; Helper routine to copy string descriptor +; -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { helper_strdesccpy: @@ -24,5 +24,4 @@ helper_strdesccpy: sta DSCPNT+2 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strvarcpy_38K.s b/src/basic/engine_variables/helper_strvarcpy_38K.s index 8a15fe3e..9b01590a 100644 --- a/src/basic/engine_variables/helper_strvarcpy_38K.s +++ b/src/basic/engine_variables/helper_strvarcpy_38K.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to copy string descriptor -// +; +; Helper routine to copy string descriptor +; -#if CONFIG_MEMORY_MODEL_38K +!ifdef CONFIG_MEMORY_MODEL_38K { helper_strvarcpy: - // Retrieve pointer to destination + ; Retrieve pointer to destination ldy #$02 lda (VARPNT), y @@ -21,14 +21,13 @@ helper_strvarcpy: sta DSCPNT+1 dey - // .Y is now 0 - copy the content -!: + ; .Y is now 0 - copy the content +@1: lda (__FAC1+1),y sta (DSCPNT+1),y iny cpy __FAC1+0 - bne !- + bne @1 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strvarcpy_46K_50K.s b/src/basic/engine_variables/helper_strvarcpy_46K_50K.s index 6c7f9545..dbf907f9 100644 --- a/src/basic/engine_variables/helper_strvarcpy_46K_50K.s +++ b/src/basic/engine_variables/helper_strvarcpy_46K_50K.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - routines below banks out the main BASIC ROM! +; This has to go $E000 or above - routines below banks out the main BASIC ROM! -// -// Helper routine to copy string variable content -// +; +; Helper routine to copy string variable content +; -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { helper_strvarcpy: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve pointer to destination + ; Retrieve pointer to destination ldy #$02 lda (VARPNT), y @@ -28,19 +28,18 @@ helper_strvarcpy: sta DSCPNT+1 dey - // Copy the string content -!: + ; Copy the string content +@1: lda (__FAC1+1),y sta (DSCPNT+1),y iny cpy __FAC1+0 - bne !- + bne @1 - // Restore default memory mapping + ; Restore default memory mapping lda #$27 sta CPU_R6510 rts - -#endif +} diff --git a/src/basic/engine_variables/helper_strvarcpy_60K.s b/src/basic/engine_variables/helper_strvarcpy_60K.s index a3c05119..5a1c19b2 100644 --- a/src/basic/engine_variables/helper_strvarcpy_60K.s +++ b/src/basic/engine_variables/helper_strvarcpy_60K.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to copy string descriptor -// +; +; Helper routine to copy string descriptor +; -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { helper_strvarcpy: ldx # 0 -// -// Output: -// - VARPNT points to the newly alocated descriptor -// +; +; Allocates memory for a temporary string +; +; Input: +; -.A desired string length, has to be > 0 +; +; Output: +; - VARPNT points to the newly alocated descriptor +; tmpstr_alloc: tax - // First we need to find a free temporary string descriptor + ; First we need to find a free temporary string descriptor lda TEMPPT cmp #$22 @@ -28,36 +28,36 @@ tmpstr_alloc: adc #$03 sta TEMPPT - // FALLTROUGH + ; FALLTROUGH tmpstr_alloc_found: - // Store desired string length + ; Store desired string length stx $00, y - // Store descriptor address + ; Store descriptor address sty VARPNT+0 lda #$00 sta VARPNT+1 - // Jump to alocation routine + ; Jump to alocation routine jmp varstr_alloc tmpstr_alloc_try_reuse: - // It seems there is no space left - try to find empty entry + ; It seems there is no space left - try to find empty entry ldy #$19 - // FALLTROUGH + ; FALLTROUGH tmpstr_alloc_try_reuse_loop: lda $00, y - beq tmpstr_alloc_found // branch if free entry found + beq tmpstr_alloc_found ; branch if free entry found iny iny @@ -65,6 +65,6 @@ tmpstr_alloc_try_reuse_loop: cpy #$22 bne tmpstr_alloc_try_reuse_loop - // Everything failed - give up + ; Everything failed - give up jmp do_FORMULA_TOO_COMPLEX_error diff --git a/src/basic/engine_variables/tmpstr_free.s b/src/basic/engine_variables/tmpstr_free.s index 14d41291..b14dc43a 100644 --- a/src/basic/engine_variables/tmpstr_free.s +++ b/src/basic/engine_variables/tmpstr_free.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Frees the string if it belongs to temporary string stack -// -// Input: -// - DSCPNT+1/+2 - pointer to string (depending on the call addres, can fetch from FAC1/FAC2) -// +; +; Frees the string if it belongs to temporary string stack +; +; Input: +; - DSCPNT+1/+2 - pointer to string (depending on the call addres, can fetch from FAC1/FAC2) +; tmpstr_free_FAC1: @@ -16,39 +16,42 @@ tmpstr_free_FAC1: sta DSCPNT+1 lda __FAC1+2 - jmp_8 !+ - + +bra tmpstr_free_FAC2_cont tmpstr_free_FAC2: lda __FAC2+1 sta DSCPNT+1 lda __FAC2+2 -!: + + ; FALLTROUGH + +tmpstr_free_FAC2_cont: + sta DSCPNT+2 - // FALLTROUGH + ; FALLTROUGH tmpstr_free: - // First find the descriptor matching the given string + ; First find the descriptor matching the given string ldx #$19 - //FALLTROUGH + ;FALLTROUGH tmpstr_free_loop: cpx TEMPPT - bne !+ - rts // quit if not found -!: - // First fetch the string size - if 0, do not even try to compare + bne @1 + rts ; quit if not found +@1: + ; First fetch the string size - if 0, do not even try to compare ldy $00, x beq tmpstr_free_next_3 - // Check if current string + ; Check if current string inx lda $00, x @@ -60,14 +63,14 @@ tmpstr_free_loop: cmp DSCPNT+2 bne tmpstr_free_next_1 - // This is the string we need to free + ; This is the string we need to free sty DSCPNT+0 - phx_trash_a + +phx_trash_a jsr varstr_free_no_checks - plx_trash_a + +plx_trash_a - // Mark empty string as free and quit + ; Mark empty string as free and quit dex dex @@ -80,13 +83,13 @@ tmpstr_free_next_3: inx - // FALLTROUGH + ; FALLTROUGH tmpstr_free_next_2: inx - // FALLTROUGH + ; FALLTROUGH tmpstr_free_next_1: diff --git a/src/basic/engine_variables/tmpstr_free_all.s b/src/basic/engine_variables/tmpstr_free_all.s index bd0f3067..facf3971 100644 --- a/src/basic/engine_variables/tmpstr_free_all.s +++ b/src/basic/engine_variables/tmpstr_free_all.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE tmpstr_free_all: - // Go through all the temporary descriptors and free everything + ; Go through all the temporary descriptors and free everything ldx #$19 - //FALLTROUGH + ;FALLTROUGH tmpstr_free_all_loop: - // Free all the temporary strings, one by one + ; Free all the temporary strings, one by one cpx TEMPPT beq tmpstr_free_all_reset lda $00, x - beq !+ + beq @1 sta DSCPNT+0 lda $01, x @@ -27,18 +27,18 @@ tmpstr_free_all_loop: lda $02, x sta DSCPNT+2 - phx_trash_a + +phx_trash_a jsr varstr_free_no_checks - plx_trash_a -!: + +plx_trash_a +@1: inx inx inx - bne tmpstr_free_all_loop // branch always + bne tmpstr_free_all_loop ; branch always -tmpstr_free_all_reset: // entry point for CLR +tmpstr_free_all_reset: ; entry point for CLR - // RESET TEMPPT and LASTPT to default values + ; RESET TEMPPT and LASTPT to default values lda #$19 sta TEMPPT diff --git a/src/basic/engine_variables/varstr_alloc.s b/src/basic/engine_variables/varstr_alloc.s index 371116ef..00028bca 100644 --- a/src/basic/engine_variables/varstr_alloc.s +++ b/src/basic/engine_variables/varstr_alloc.s @@ -1,141 +1,140 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Allocates memory for string - lowers FRETOP (but not below STREND) -// -// Note: We are not going to use the C64-style memory management here, as it implies -// a very slow garbage collector. Instead, we are using a scheme similar to used in -// BASIC V3.5 and later, with 'back-pointers' after each string, telling about the -// location of the string descriptor. -// -// See: -// - https://www.c64-wiki.com/wiki/Memory_(BASIC) -// - https://sites.google.com/site/h2obsession/CBM/basic/variable-format -// -// Input: -// - VARPNT - pointer to string descriptor, first pointed byte should contain desired length -// Output: -// - fills-in pointer in the string descriptor -// +; +; Allocates memory for string - lowers FRETOP (but not below STREND) +; +; Note: We are not going to use the C64-style memory management here, as it implies +; a very slow garbage collector. Instead, we are using a scheme similar to used in +; BASIC V3.5 and later, with 'back-pointers' after each string, telling about the +; location of the string descriptor. +; +; See: +; - https://www.c64-wiki.com/wiki/Memory_(BASIC) +; - https://sites.google.com/site/h2obsession/CBM/basic/variable-format +; +; Input: +; - VARPNT - pointer to string descriptor, first pointed byte should contain desired length +; Output: +; - fills-in pointer in the string descriptor +; -// NOTE: if FAC1 or FAC2 contains a value (not a string descriptor - these are going to be updated -// if garbage collector starts), then preserve __FAC1+1/+2 and __FAC2+1/+2 somewhere, as there -// is a small chance they'll get damaged! +; NOTE: if FAC1 or FAC2 contains a value (not a string descriptor - these are going to be updated +; if garbage collector starts), then preserve __FAC1+1/+2 and __FAC2+1/+2 somewhere, as there +; is a small chance they'll get damaged! varstr_alloc: - // Mark garbage collector as not run yet + ; Mark garbage collector as not run yet lda #$00 - // FALLTROUGH + ; FALLTROUGH varstr_alloc_retry: - sta GARBFL // Computes Mapping the Commodore 64, page 10 + sta GARBFL ; Computes Mapping the Commodore 64, page 10 - // Backup FRETOP in case of alocation problems + ; Backup FRETOP in case of alocation problems lda FRETOP+0 sta INDEX+0 lda FRETOP+1 sta INDEX+1 - // Lower FRETOP to make space for the back-pointer + ; Lower FRETOP to make space for the back-pointer -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { lda #$02 jsr helper_FRETOP_down_A -#else // HAS_OPCODES_65CE02 - this time code is slightly longer, but faster +} else { ; HAS_OPCODES_65CE02 - this time code is slightly longer, but faster dew FRETOP dew FRETOP jsr helper_FRETOP_check - -#endif +} bcs varstr_alloc_fail - // Create the back-pointer to the string descriptor + ; Create the back-pointer to the string descriptor ldy #$00 lda VARPNT+0 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx # $FF + dec GARBFL ; $00 -> $FF jsr varstr_garbage_collect - jmp_8 varstr_alloc_retry + +bra varstr_alloc_retry diff --git a/src/basic/engine_variables/varstr_free.s b/src/basic/engine_variables/varstr_free.s index b4815d7a..dbd37622 100644 --- a/src/basic/engine_variables/varstr_free.s +++ b/src/basic/engine_variables/varstr_free.s @@ -1,65 +1,64 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Releases back memory used by string -// -// Input: -// - DSCPNT+0 - string size -// - DSCPNT+1, DSCPNT+2 - pointer to string -// +; +; Releases back memory used by string +; +; Input: +; - DSCPNT+0 - string size +; - DSCPNT+1, DSCPNT+2 - pointer to string +; varstr_free: - // Check the string size - do not do anything if 0 + ; Check the string size - do not do anything if 0 lda DSCPNT+0 - bne !+ + bne @1 rts -!: - // Check if string is above FRETOP (in string area) +@1: + ; Check if string is above FRETOP (in string area) jsr helper_cmp_fretop bcs varstr_free_no_checks - // No, it does not belong to string area - quit + ; No, it does not belong to string area - quit rts -varstr_free_no_checks: // entry point to be used when it is clear that string is not empty and above FRETOP +varstr_free_no_checks: ; entry point to be used when it is clear that string is not empty and above FRETOP - // Check if this is the lowest string + ; Check if this is the lowest string bne varstr_free_inside - // This is the lowest string - so just increase FRETOP, this way - // the garbage collector will not be needed that quickly + ; This is the lowest string - so just increase FRETOP, this way + ; the garbage collector will not be needed that quickly - jsr helper_FRETOP_up // free the string data + jsr helper_FRETOP_up ; free the string data -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { - lda #$02 // free the back-pointer + lda #$02 ; free the back-pointer sta DSCPNT+0 jmp helper_FRETOP_up -#else // HAS_OPCODES_65CE02 +} else { ; HAS_OPCODES_65CE02 - inw FRETOP // free the back-pointer + inw FRETOP ; free the back-pointer inw FRETOP rts - -#endif +} varstr_free_inside: - // This is not the lowest string; mark it as free - // First preserve the string size, it will make it easier for the garbage collector + ; This is not the lowest string; mark it as free + ; First preserve the string size, it will make it easier for the garbage collector - // Increase DSCPNT+1/+2 to point to the back-pointer minus 1 + ; Increase DSCPNT+1/+2 to point to the back-pointer minus 1 dec DSCPNT+0 @@ -67,37 +66,37 @@ varstr_free_inside: lda DSCPNT+1 adc DSCPNT+0 sta DSCPNT+1 - bcc !+ + bcc @2 inc DSCPNT+2 -!: - // Put the size-1, garbage collector will make use of this value +@2: + ; Put the size-1, garbage collector will make use of this value lda DSCPNT+0 ldy #$00 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #do_ILLEGAL_QUANTITY_error sta USRADD+1 - // Clear the BRK location address + ; Clear the BRK location address lda #$00 sta CMP0+0 sta CMP0+1 - // Print startup messages + ; Print startup messages jsr INITMSG - // Initialize other variables by performing NEW + ; Initialize other variables by performing NEW jsr do_new - // jump into warm start loop + ; jump into warm start loop jmp basic_warm_start diff --git a/src/basic/init/basic_warm_start_internal.s b/src/basic/init/basic_warm_start_internal.s index 81ff572c..90acdf91 100644 --- a/src/basic/init/basic_warm_start_internal.s +++ b/src/basic/init/basic_warm_start_internal.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Continuation of the BASIC cold start routine -// +; +; Continuation of the BASIC cold start routine +; basic_warm_start_real: -#if CONFIG_MEMORY_MODEL_60K - // We need our helpers to get to filenames under ROMs or IO area +!ifdef CONFIG_MEMORY_MODEL_60K { + ; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines -#endif +} - // If warm start caused by BRK, print it address - // XXX sys 58235 also triggers this - to be fixed + ; If warm start caused by BRK, print it address + ; XXX sys 58235 also triggers this - to be fixed lda CMP0 ora CMP0+1 - beq !+ + beq @1 ldx #IDX__STR_BRK_AT jsr print_packed_misc_str @@ -26,5 +26,5 @@ basic_warm_start_real: jsr print_hex_byte lda CMP0+0 jsr print_hex_byte -!: +@1: jmp shell_main_loop diff --git a/src/basic/init/e394.basic_cold_start.s b/src/basic/init/e394.basic_cold_start.s index a7ba4138..ef12b162 100644 --- a/src/basic/init/e394.basic_cold_start.s +++ b/src/basic/init/e394.basic_cold_start.s @@ -1,31 +1,30 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// BASIC Cold start entry point -// Computes Mapping the 64 p211 +; BASIC Cold start entry point +; Computes Mapping the 64 p211 basic_cold_start: -#if ROM_LAYOUT_STD // skip on non-sgtandard ROM layouts - they produce single image nevertheless +!ifdef ROM_LAYOUT_STD { ; skip on non-sgtandard ROM layouts - they produce single image nevertheless - // Before doing anything, check if we have a compatible BASIC/KERNAL pair + ; Before doing anything, check if we have a compatible BASIC/KERNAL pair ldy #(__rom_revision_basic_end - rom_revision_basic - 1) -!: +@1: lda rom_revision_basic, y cmp rom_revision_kernal, y - beq !+ + beq @2 - panic #P_ERR_ROM_MISMATCH + +panic P_ERR_ROM_MISMATCH -!: +@2: dey - bpl !-- + bpl @1 +} -#endif - - // Remaining part would not fit here + ; Remaining part would not fit here jmp basic_cold_start_internal diff --git a/src/basic/init/e3b7.basic_warm_start.jmp.s b/src/basic/init/e3b7.basic_warm_start.jmp.s index 144ba4b6..65810f95 100644 --- a/src/basic/init/e3b7.basic_warm_start.jmp.s +++ b/src/basic/init/e3b7.basic_warm_start.jmp.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Clear screen etc, show READY prompt. +; Clear screen etc, show READY prompt. basic_warm_start: diff --git a/src/basic/init/e422.initmsg.jmp.s b/src/basic/init/e422.initmsg.jmp.s index f0de165f..37cbe78e 100644 --- a/src/basic/init/e422.initmsg.jmp.s +++ b/src/basic/init/e422.initmsg.jmp.s @@ -1,32 +1,35 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Well-known BASIC routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 212 -// -// Prints the start-up messages -// +; +; Well-known BASIC routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 212 +; +; Prints the start-up messages +; INITMSG: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr map_BASIC_1 - jsr_ind VB1__INITMSG -!: + jsr (VB1__INITMSG) + + ; FALLTROUGH + +INITMSG_end: + jmp map_NORMAL INITMSG_autoswitch: jsr map_BASIC_1 - jsr_ind VB1__INITMSG_autoswitch - bra !- + jsr (VB1__INITMSG_autoswitch) + bra INITMSG_end -#else +} else { jmp initmsg_real - -#endif +} diff --git a/src/basic/init/initmsg_bytes_free.s b/src/basic/init/initmsg_bytes_free.s index 97f9f32b..379365bf 100644 --- a/src/basic/init/initmsg_bytes_free.s +++ b/src/basic/init/initmsg_bytes_free.s @@ -1,61 +1,61 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Print out the amount of free bytes - for the startup banner -// +; +; Print out the amount of free bytes - for the startup banner +; initmsg_bytes_free: - // Setup pointers to BASIC memory storage + ; Setup pointers to BASIC memory storage lda #<$0801 sta TXTTAB+0 lda #>$0801 sta TXTTAB+1 - // Get top of memory. - // If a cart is present, then it is $7FFF, - // if not, then it is $F7FF, since we support having - // programs and variables under ROM. - // i.e., we support 56KB RAM for BASIC, keeping some space - // free for some optimisation structures, e.g., FOR/NEXT loop - // records (without them going on the stack), GOSUB stack - // (same story), expression value cache? + ; Get top of memory. + ; If a cart is present, then it is $7FFF, + ; if not, then it is $F7FF, since we support having + ; programs and variables under ROM. + ; i.e., we support 56KB RAM for BASIC, keeping some space + ; free for some optimisation structures, e.g., FOR/NEXT loop + ; records (without them going on the stack), GOSUB stack + ; (same story), expression value cache? - sec // Read, not write value + sec ; Read, not write value jsr JMEMTOP cpx #$80 - beq !+ -#if CONFIG_MEMORY_MODEL_60K + beq @1 +!ifdef CONFIG_MEMORY_MODEL_60K { lda #>$F7FF -#elif CONFIG_MEMORY_MODEL_50K +} else ifdef CONFIG_MEMORY_MODEL_50K { lda #>$D000 -#elif CONFIG_MEMORY_MODEL_46K +} else ifdef CONFIG_MEMORY_MODEL_46K { lda #>$C000 -#else // CONFIG_MEMORY_MODEL_38K +} else { ; CONFIG_MEMORY_MODEL_38K lda #>$A000 -#endif - skip_2_bytes_trash_nvz -!: +} + +skip_2_bytes_trash_nvz +@1: lda #>$8000 sta MEMSIZ+1 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { cpx #$80 - beq !+ + beq @2 lda #$FF - skip_2_bytes_trash_nvz -!: + +skip_2_bytes_trash_nvz +@2: lda #<$00 -#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +} else { ; CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K lda #<$00 -#endif +} sta MEMSIZ+0 - // Print number of bytes free + ; Print number of bytes free sec lda MEMSIZ+0 diff --git a/src/basic/init/initmsg_m65.s b/src/basic/init/initmsg_m65.s index bbe77b95..baedbe52 100644 --- a/src/basic/init/initmsg_m65.s +++ b/src/basic/init/initmsg_m65.s @@ -1,22 +1,22 @@ -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# * * #IGNORE -// Routine is too long to fit in the original location +; Routine is too long to fit in the original location -// XXX banner-related code needs cleanup, move MEGA65 stuff to a separate file +; 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 + ; Display additional information, depending on the mode jsr M65_MODEGET - bcc !+ + bcc @1 - // Legacy C64 compatibility mode + ; Legacy C64 compatibility mode jsr INITMSG_partial @@ -24,8 +24,8 @@ INITMSG: jsr print_packed_misc_str bra INITMSG_end -!: - // Native mode +@1: + ; Native mode ldx #48 ldy #0 @@ -39,7 +39,7 @@ INITMSG: jsr print_sysinfo_banner jsr M65_SETWIN_N - // Native mode - display revision and available memory + ; Native mode - display revision and available memory ldx #$05 ldy #$00 @@ -53,7 +53,7 @@ INITMSG: jsr print_return jsr print_return - // FALLTROUGH + ; FALLTROUGH INITMSG_end: @@ -65,18 +65,18 @@ INITMSG_end: INITMSG_main_banner: - // Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen + ; Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen lda #147 jsr JCHROUT - // Display main banner + ; Display main banner lda #startup_banner jmp STROUT -INITMSG_autoswitch: // entry point for 'SYS command' +INITMSG_autoswitch: ; entry point for 'SYS command' jsr INITMSG_main_banner jsr INITMSG_partial @@ -89,7 +89,7 @@ INITMSG_partial: ldx #IDX__STR_ORS_LEGACY_1 jsr print_packed_misc_str - // FALLTROUGH + ; FALLTROUGH INITMSG_revision: diff --git a/src/basic/init/initmsg_real.s b/src/basic/init/initmsg_real.s index 8a38e3e6..57170601 100644 --- a/src/basic/init/initmsg_real.s +++ b/src/basic/init/initmsg_real.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Routine is too long to fit in the original location +; Routine is too long to fit in the original location initmsg_real: - // Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen + ; Clear the screen first, some cartridges (like IEEE-488) are leaving a mess on the screen lda #147 jsr JCHROUT -#if CONFIG_BANNER_SIMPLE +!ifdef CONFIG_BANNER_SIMPLE { lda #startup_banner jsr STROUT -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$01 ldy #$04 @@ -28,32 +28,32 @@ initmsg_real: ldy #>rom_revision_basic_string jsr STROUT -#endif // no CONFIG_BRAND_CUSTOM_BUILD +} ; no CONFIG_BRAND_CUSTOM_BUILD -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$03 -#else +} else { ldx #$02 -#endif +} ldy #$04 jsr plot_set jsr initmsg_bytes_free -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$06 -#else +} else { ldx #$05 -#endif +} ldy #$00 -#if CONFIG_SHOW_FEATURES +!ifdef CONFIG_SHOW_FEATURES { jsr plot_set jmp print_features -#else +} else { jmp plot_set -#endif +} -#elif CONFIG_BANNER_FANCY +} else ifdef CONFIG_BANNER_FANCY { lda #rainbow_logo @@ -67,7 +67,7 @@ initmsg_real: ldy #>startup_banner jsr STROUT -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$01 ldy #$0A @@ -80,29 +80,29 @@ initmsg_real: ldy #>rom_revision_basic_string jsr STROUT -#endif // no CONFIG_BRAND_CUSTOM_BUILD +} ; no CONFIG_BRAND_CUSTOM_BUILD -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$03 -#else +} else { ldx #$02 -#endif +} ldy #$0A jsr plot_set jsr initmsg_bytes_free -#if !CONFIG_BRAND_CUSTOM_BUILD +!ifndef CONFIG_BRAND_CUSTOM_BUILD { ldx #$06 -#else +} else { ldx #$05 -#endif +} ldy #$00 -#if CONFIG_SHOW_FEATURES +!ifdef CONFIG_SHOW_FEATURES { jsr plot_set jmp print_features -#else +} else { jmp plot_set -#endif +} -#endif +} diff --git a/src/basic/math/add_FAC2_FAC1_sub.s b/src/basic/math/add_FAC2_FAC1_sub.s index a045e1b8..d2fe2da1 100644 --- a/src/basic/math/add_FAC2_FAC1_sub.s +++ b/src/basic/math/add_FAC2_FAC1_sub.s @@ -1,46 +1,46 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - add FAC2 to FAC1, subtraction part -// +; +; Math package - add FAC2 to FAC1, subtraction part +; -// XXX test this +; XXX test this add_FAC2_FAC1_sub: - // First verify that |FAC1| > |FAC2|, branch to proper variant if it is not - // We ignore FACOV here. Note, that exponents are already equalized + ; First verify that |FAC1| > |FAC2|, branch to proper variant if it is not + ; We ignore FACOV here. Note, that exponents are already equalized lda FAC1_mantissa+0 cmp FAC2_mantissa+0 - bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch - bne !+ // if FAC1 > FAC2, branch + bcc add_FAC2_FAC1_sub_rev ; if FAC1 < FAC2, branch + bne @1 ; if FAC1 > FAC2, branch lda FAC1_mantissa+1 cmp FAC2_mantissa+1 - bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch - bne !+ // if FAC1 > FAC2, branch + bcc add_FAC2_FAC1_sub_rev ; if FAC1 < FAC2, branch + bne @1 ; if FAC1 > FAC2, branch lda FAC1_mantissa+2 cmp FAC2_mantissa+2 - bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch - bne !+ // if FAC1 > FAC2, branch + bcc add_FAC2_FAC1_sub_rev ; if FAC1 < FAC2, branch + bne @1 ; if FAC1 > FAC2, branch lda FAC1_mantissa+3 cmp FAC2_mantissa+3 - bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch - bne !+ // if FAC1 > FAC2, branch + bcc add_FAC2_FAC1_sub_rev ; if FAC1 < FAC2, branch + bne @1 ; if FAC1 > FAC2, branch - // If we are here, than FAC1 is equal to FAC2 - so just set FAC1 to 0 + ; If we are here, than FAC1 is equal to FAC2 - so just set FAC1 to 0 lda #$00 sta FAC1_exponent rts -!: - // Perform the subtration, FAC1 = FAC1 - FAC2 +@1: + ; Perform the subtration, FAC1 = FAC1 - FAC2 sec lda FAC1_mantissa+3 @@ -59,17 +59,17 @@ add_FAC2_FAC1_sub: sbc FAC2_mantissa+0 sta FAC1_mantissa+0 - // Exponent should never need adaptation here + ; Exponent should never need adaptation here jmp normal_FAC1 add_FAC2_FAC1_sub_rev: - // Since |FAC1| < |FAC2|, toggle FAC1 sign before subtraction + ; Since |FAC1| < |FAC2|, toggle FAC1 sign before subtraction jsr toggle_sign_FAC1_skipcheck - // Perform the subtration, FAC1 = FAC2 - FAC1 + ; Perform the subtration, FAC1 = FAC2 - FAC1 sec lda #$00 @@ -92,6 +92,6 @@ add_FAC2_FAC1_sub_rev: sbc FAC1_mantissa+0 sta FAC1_mantissa+0 - // Exponent should never need adaptation here + ; Exponent should never need adaptation here jmp normal_FAC1 diff --git a/src/basic/math/add_align_exponents.s b/src/basic/math/add_align_exponents.s index 882cb337..2060e0a9 100644 --- a/src/basic/math/add_align_exponents.s +++ b/src/basic/math/add_align_exponents.s @@ -1,44 +1,44 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - align FAC1 and FAC2 exponents for addition -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/BASIC-ROM +; +; Math package - align FAC1 and FAC2 exponents for addition +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/BASIC-ROM add_align_exponents: - // XXX assume here none of the exponents is 0, check if this is true for orignal ROMs + ; XXX assume here none of the exponents is 0, check if this is true for orignal ROMs lda FAC1_exponent cmp FAC2_exponent - beq add_align_exponents_done // branch if exponents the same + beq add_align_exponents_done ; branch if exponents the same bcs add_align_exponent_FAC2 - // FALLTROUGH + ; FALLTROUGH add_align_exponent_FAC1: - // First check the exponent difference + ; First check the exponent difference lda FAC2_exponent sec sbc FAC1_exponent cmp #$28 - bcs add_align_exponent_FAC1_zero // branch if difference is very high + bcs add_align_exponent_FAC1_zero ; branch if difference is very high cmp #$08 bcc add_align_exponent_FAC1_bit - // FALLTROUGH + ; FALLTROUGH add_align_exponent_FAC1_byte: - // Add 8 to exponent, divide mantissa by 256 + ; Add 8 to exponent, divide mantissa by 256 lda FAC1_exponent clc @@ -56,11 +56,11 @@ add_align_exponent_FAC1_byte: lda #$00 sta FAC1_mantissa+0 - beq add_align_exponent_FAC1 // branch always - next iteration + beq add_align_exponent_FAC1 ; branch always - next iteration add_align_exponent_FAC1_bit: - // Increment exponent, divide mantissa by 2 + ; Increment exponent, divide mantissa by 2 inc FAC1_exponent @@ -73,7 +73,7 @@ add_align_exponent_FAC1_bit: lda FAC1_exponent cmp FAC2_exponent - bne add_align_exponent_FAC1_bit // branch if next iteration needed + bne add_align_exponent_FAC1_bit ; branch if next iteration needed rts @@ -90,7 +90,7 @@ add_align_exponent_FAC1_zero: lda FAC2_exponent sta FAC1_exponent - // FALLTROUGH + ; FALLTROUGH add_align_exponents_done: @@ -100,22 +100,22 @@ add_align_exponents_done: add_align_exponent_FAC2: - // First check the exponent difference, Carry already set here + ; First check the exponent difference, Carry already set here lda FAC1_exponent sbc FAC2_exponent cmp #$20 - bcs add_align_exponent_FAC2_zero // branch if difference is very high + bcs add_align_exponent_FAC2_zero ; branch if difference is very high cmp #$08 bcc add_align_exponent_FAC2_bit - // FALLTROUGH + ; FALLTROUGH add_align_exponent_FAC2_byte: - // Add 8 to exponent, divide mantissa by 256 + ; Add 8 to exponent, divide mantissa by 256 lda FAC2_exponent clc @@ -131,11 +131,11 @@ add_align_exponent_FAC2_byte: lda #$00 sta FAC2_mantissa+0 - beq add_align_exponent_FAC2 // branch always - next iteration + beq add_align_exponent_FAC2 ; branch always - next iteration add_align_exponent_FAC2_bit: - // Increment exponent, divide mantissa by 2 + ; Increment exponent, divide mantissa by 2 inc FAC2_exponent @@ -147,7 +147,7 @@ add_align_exponent_FAC2_bit: lda FAC1_exponent cmp FAC2_exponent - bne add_align_exponent_FAC2_bit // branch if next iteration needed + bne add_align_exponent_FAC2_bit ; branch if next iteration needed rts diff --git a/src/basic/math/b849.add_HALF_FAC1.s b/src/basic/math/b849.add_HALF_FAC1.s index 76f21ff0..adb72fe7 100644 --- a/src/basic/math/b849.add_HALF_FAC1.s +++ b/src/basic/math/b849.add_HALF_FAC1.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - add 0.5 to FAC1 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 +; +; Math package - add 0.5 to FAC1 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 add_HALF_FAC1: diff --git a/src/basic/math/b850.sub_MEM_FAC1.s b/src/basic/math/b850.sub_MEM_FAC1.s index 72281c92..c1d759d6 100644 --- a/src/basic/math/b850.sub_MEM_FAC1.s +++ b/src/basic/math/b850.sub_MEM_FAC1.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - subtract FAC1 from memory variable -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - subtract FAC1 from memory variable +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; sub_MEM_FAC1: jsr mov_MEM_FAC2 - // FALLTROUGH to sub_FAC2_FAC1 + ; FALLTROUGH to sub_FAC2_FAC1 diff --git a/src/basic/math/b853.sub_FAC2_FAC1.s b/src/basic/math/b853.sub_FAC2_FAC1.s index e54a85a9..e2ce7e04 100644 --- a/src/basic/math/b853.sub_FAC2_FAC1.s +++ b/src/basic/math/b853.sub_FAC2_FAC1.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - subtract FAC1 from FAC2 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - subtract FAC1 from FAC2 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this sub_FAC2_FAC1: - // Toggle FAC1 sign + ; Toggle FAC1 sign lda FAC1_sign eor #$FF sta FAC1_sign - // Perform addition + ; Perform addition jmp add_FAC2_FAC1 diff --git a/src/basic/math/b862.add_align_exponent.jmp.s b/src/basic/math/b862.add_align_exponent.jmp.s index 03fef8c3..31973617 100644 --- a/src/basic/math/b862.add_align_exponent.jmp.s +++ b/src/basic/math/b862.add_align_exponent.jmp.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp add_align_exponents diff --git a/src/basic/math/b867.add_MEM_FAC1.s b/src/basic/math/b867.add_MEM_FAC1.s index 1d948ee0..87f33af4 100644 --- a/src/basic/math/b867.add_MEM_FAC1.s +++ b/src/basic/math/b867.add_MEM_FAC1.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - add memory variable to FAC1 -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - add memory variable to FAC1 +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; add_MEM_FAC1: jsr mov_MEM_FAC2 - // FALLTROUGH to add_FAC2_FAC1 + ; FALLTROUGH to add_FAC2_FAC1 diff --git a/src/basic/math/b86a.add_FAC2_FAC1.s b/src/basic/math/b86a.add_FAC2_FAC1.s index 9ae04a29..2ea751ae 100644 --- a/src/basic/math/b86a.add_FAC2_FAC1.s +++ b/src/basic/math/b86a.add_FAC2_FAC1.s @@ -1,49 +1,49 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - add FAC2 to FAC1 -// -// Input: -// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag -// -// Note: -// - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 112 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - add FAC2 to FAC1 +; +; Input: +; - .A - must load FAC1 exponent ($61) beforehand to set the zero flag +; +; Note: +; - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 112 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this add_FAC2_FAC1: - // Check if FAC2 is 0; if so leave FAC1 without changes + ; Check if FAC2 is 0; if so leave FAC1 without changes lda FAC2_exponent beq add_FAC2_FAC1_done - // If FAC1 is 0, if so just copy FAC2 to FAC1 + ; If FAC1 is 0, if so just copy FAC2 to FAC1 lda FAC1_exponent - beq_16 mov_FAC2_FAC1 + +beq mov_FAC2_FAC1 - // Make sure the exponents are aligned + ; Make sure the exponents are aligned jsr add_align_exponents - // Check whether signs are the same + ; Check whether signs are the same lda FAC1_sign eor FAC2_sign - bmi_16 add_FAC2_FAC1_sub // branch if signs are opposite + +bmi add_FAC2_FAC1_sub ; branch if signs are opposite - // Perform the addition + ; Perform the addition clc lda FAC2_mantissa+3 @@ -62,14 +62,14 @@ add_FAC2_FAC1: adc FAC1_mantissa+0 sta FAC1_mantissa+0 - bcc_16 normal_FAC1 // end if no need to adapt the exponent + +bcc normal_FAC1 ; end if no need to adapt the exponent inc FAC1_exponent - bne add_FAC2_FAC1_adapt_mantissa // end if no overflow + bne add_FAC2_FAC1_adapt_mantissa ; end if no overflow - // FALLTROUGH + ; FALLTROUGH -set_FAC1_max: // entry used by other routines too +set_FAC1_max: ; entry used by other routines too lda #$FF sta FAC1_exponent @@ -78,7 +78,7 @@ set_FAC1_max: // entry used by other routines too sta FAC1_mantissa+1 sta FAC1_mantissa+0 - // FALLTROUGH + ; FALLTROUGH add_FAC2_FAC1_done: diff --git a/src/basic/math/b8fe.normal_FAC1.jmp.s b/src/basic/math/b8fe.normal_FAC1.jmp.s index e40972f8..be867799 100644 --- a/src/basic/math/b8fe.normal_FAC1.jmp.s +++ b/src/basic/math/b8fe.normal_FAC1.jmp.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp normal_FAC1 diff --git a/src/basic/math/ba28.mul_MEM_FAC1.jmp.s b/src/basic/math/ba28.mul_MEM_FAC1.jmp.s index 02a35b91..9c927026 100644 --- a/src/basic/math/ba28.mul_MEM_FAC1.jmp.s +++ b/src/basic/math/ba28.mul_MEM_FAC1.jmp.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - multiplies FAC1 by RAM -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// Note: -// - C64 Wiki calls it FMULT, this looks like a mistake -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - multiplies FAC1 by RAM +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; Note: +; - C64 Wiki calls it FMULT, this looks like a mistake +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; mul_MEM_FAC1: jsr mov_MEM_FAC2 - // FALLTROUGH to mul_FAC2_FAC1 + ; FALLTROUGH to mul_FAC2_FAC1 diff --git a/src/basic/math/ba2b.mul_FAC2_FAC1.s b/src/basic/math/ba2b.mul_FAC2_FAC1.s index 1b918524..e3ddc14a 100644 --- a/src/basic/math/ba2b.mul_FAC2_FAC1.s +++ b/src/basic/math/ba2b.mul_FAC2_FAC1.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mul_FAC2_FAC1 diff --git a/src/basic/math/ba8c.mov_MEM_FAC2.jmp.s b/src/basic/math/ba8c.mov_MEM_FAC2.jmp.s index d556073a..2238045e 100644 --- a/src/basic/math/ba8c.mov_MEM_FAC2.jmp.s +++ b/src/basic/math/ba8c.mov_MEM_FAC2.jmp.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_MEM_FAC2 diff --git a/src/basic/math/bae2.mul10_FAC1.s b/src/basic/math/bae2.mul10_FAC1.s index 5b20e8a7..6eb6b434 100644 --- a/src/basic/math/bae2.mul10_FAC1.s +++ b/src/basic/math/bae2.mul10_FAC1.s @@ -1,38 +1,38 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - multiply FAC1 by 10 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 114 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - multiply FAC1 by 10 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 114 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; mul10_FAC1: - // Handle special case of FAC1 equal 0 + ; Handle special case of FAC1 equal 0 lda FAC1_exponent beq mul10_FAC1_done - // Start by multiplying FAC1 by 2 + ; Start by multiplying FAC1 by 2 jsr mul10_FAC1_mul2 - // Move FAC1 to FAC2, so that FAC1 = FAC2 = 2 * initial + ; Move FAC1 to FAC2, so that FAC1 = FAC2 = 2 * initial jsr mov_FAC1_FAC2 - // Multiply FAC1 by 4 + ; Multiply FAC1 by 4 jsr mul10_FAC1_mul2 jsr mul10_FAC1_mul2 - // Now we have FAC1 = 8 * initial and FAC2 = 2 * initial; so just add these 2 values + ; Now we have FAC1 = 8 * initial and FAC2 = 2 * initial; so just add these 2 values jmp add_FAC2_FAC1 diff --git a/src/basic/math/bafe.div10_FAC1_p.s b/src/basic/math/bafe.div10_FAC1_p.s index 0c1af809..a13dd084 100644 --- a/src/basic/math/bafe.div10_FAC1_p.s +++ b/src/basic/math/bafe.div10_FAC1_p.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - divide FAC1 by 10, result is always positive -// -// Notes: -// - shifts FAC1 to FAC2, loads FAC1 with the constant 10, falls through to the division routine +; +; Math package - divide FAC1 by 10, result is always positive +; +; Notes: +; - shifts FAC1 to FAC2, loads FAC1 with the constant 10, falls through to the division routine -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 114 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 114 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this div10_FAC1_p: diff --git a/src/basic/math/bb0f.div_MEM_FAC1.s b/src/basic/math/bb0f.div_MEM_FAC1.s index 2863958a..79b15cef 100644 --- a/src/basic/math/bb0f.div_MEM_FAC1.s +++ b/src/basic/math/bb0f.div_MEM_FAC1.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - divide RAM by FAC1 -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 114 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - divide RAM by FAC1 +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 114 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; div_MEM_FAC1: jsr mov_MEM_FAC2 - // FALLTROUGH to div_FAC2_FAC1 + ; FALLTROUGH to div_FAC2_FAC1 diff --git a/src/basic/math/bb12.div_FAC2_FAC1.s b/src/basic/math/bb12.div_FAC2_FAC1.s index 5bbf09d9..80efb11f 100644 --- a/src/basic/math/bb12.div_FAC2_FAC1.s +++ b/src/basic/math/bb12.div_FAC2_FAC1.s @@ -1,75 +1,75 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - divide FAC2 (dividend) by FAC1 (divisor) -// -// Input: -// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag (but our routine does not need this) -// -// Output: -// - FAC1 -// -// Note: -// - some documentation suggest this is a division leaving quotient and remainder (left in FAC2), -// but it seems (experimentation) that this is not true -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 114 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - divide FAC2 (dividend) by FAC1 (divisor) +; +; Input: +; - .A - must load FAC1 exponent ($61) beforehand to set the zero flag (but our routine does not need this) +; +; Output: +; - FAC1 +; +; Note: +; - some documentation suggest this is a division leaving quotient and remainder (left in FAC2), +; but it seems (experimentation) that this is not true +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 114 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; div_FAC2_FAC1: - // 'Pamiętaj, cholero - nie dziel przez zero!' - ancient polish proverb + ; 'Pamiętaj, cholero - nie dziel przez zero!' - ancient polish proverb lda FAC1_exponent - beq_16 do_DIVISION_BY_ZERO_error + +beq do_DIVISION_BY_ZERO_error - // Handle special case - dividing 0 by non-zero value + ; Handle special case - dividing 0 by non-zero value lda FAC2_exponent - beq_16 set_FAC1_zero + +beq set_FAC1_zero - // Multiply signs + ; Multiply signs lda FAC1_sign eor FAC2_sign sta FAC1_sign - // Subtract the exponents + ; Subtract the exponents - lda #$A0 // correction for bias and FAC2 digits + lda #$A0 ; correction for bias and FAC2 digits sta RESHO+0 lda #$00 sta RESHO+1 - lda FAC2_exponent // add FAC2 exponent to temporary variable + lda FAC2_exponent ; add FAC2 exponent to temporary variable jsr muldiv_RESHO_01_add_A - lda RESHO+0 // subtract FAC1 exponent from temporary variable + lda RESHO+0 ; subtract FAC1 exponent from temporary variable sec sbc FAC1_exponent sta RESHO+0 - bcs !+ + bcs @1 dec RESHO+1 - !: +@1: lda RESHO+1 - bmi_16 set_FAC1_zero // result too low, set 0 and quit + +bmi set_FAC1_zero ; result too low, set 0 and quit lda RESHO+0 sta FAC1_exponent - // Divide the mantissas + ; Divide the mantissas jsr div_FAC1_denorm jsr muldiv_RESHO_set_0 jsr div_mantissas - // Copy the result to FAC1 - XXX we probably already have similar code somewhere... + ; Copy the result to FAC1 - XXX we probably already have similar code somewhere... lda FAC2_mantissa+3 sta FAC1_mantissa+3 @@ -80,6 +80,6 @@ div_FAC2_FAC1: lda FAC2_mantissa+0 sta FAC1_mantissa+0 - // Normalize and quit + ; Normalize and quit jmp normal_FAC1 diff --git a/src/basic/math/bc1b.round_FAC1.jmp.s b/src/basic/math/bc1b.round_FAC1.jmp.s index 6658d65e..47f8b624 100644 --- a/src/basic/math/bc1b.round_FAC1.jmp.s +++ b/src/basic/math/bc1b.round_FAC1.jmp.s @@ -1,9 +1,9 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp round_FAC1 diff --git a/src/basic/math/bc2b.sgn_FAC1_A.s b/src/basic/math/bc2b.sgn_FAC1_A.s index 66f449e6..0fb477ce 100644 --- a/src/basic/math/bc2b.sgn_FAC1_A.s +++ b/src/basic/math/bc2b.sgn_FAC1_A.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - evaluate FAC1 sign, to .A -// -// Output: -// - .A - 0 for FAC1 equal 0, 1 for FAC1 > 0, -1 for FAC1 < 0 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - evaluate FAC1 sign, to .A +; +; Output: +; - .A - 0 for FAC1 equal 0, 1 for FAC1 > 0, -1 for FAC1 < 0 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; sgn_FAC1_A: lda FAC1_exponent - beq !+ + beq @1 lda FAC1_sign - bne !+ + bne @1 lda #$01 -!: +@1: rts diff --git a/src/basic/math/bf71.sqr_FAC1.s b/src/basic/math/bf71.sqr_FAC1.s index a670c052..aa43da5e 100644 --- a/src/basic/math/bf71.sqr_FAC1.s +++ b/src/basic/math/bf71.sqr_FAC1.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - square root of FAC1 -// -// Note: -// - transfers FAC1 to FAC2 and falls through to SQR2 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - square root of FAC1 +; +; Note: +; - transfers FAC1 to FAC2 and falls through to SQR2 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; sqr_FAC1: jsr mov_FAC1_FAC2 - // FALLLTROUGH to sqr_FAC2 + ; FALLLTROUGH to sqr_FAC2 diff --git a/src/basic/math/bf78.pwr_FAC2_MEM.s b/src/basic/math/bf78.pwr_FAC2_MEM.s index 8b785204..eebadd3a 100644 --- a/src/basic/math/bf78.pwr_FAC2_MEM.s +++ b/src/basic/math/bf78.pwr_FAC2_MEM.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - set FAC1 as RAM raised to the power of FAC2 -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 (FPWRT) -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - set FAC1 as RAM raised to the power of FAC2 +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 (FPWRT) +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; pwr_FAC2_MEM: jsr mov_MEM_FAC1 - // FALLTROUGH to pwr_FAC2_FAC1 + ; FALLTROUGH to pwr_FAC2_FAC1 diff --git a/src/basic/math/bfb4.toggle_sign_FAC1.s b/src/basic/math/bfb4.toggle_sign_FAC1.s index d3fa428a..c3b7b079 100644 --- a/src/basic/math/bfb4.toggle_sign_FAC1.s +++ b/src/basic/math/bfb4.toggle_sign_FAC1.s @@ -1,27 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - toggle FAC1 sign (if not 0) -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 117 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - toggle FAC1 sign (if not 0) +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 117 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; toggle_sign_FAC1: lda FAC1_exponent - beq !+ // do not toggle the sign if value is 0 + beq toggle_sign_FAC1_end ; do not toggle the sign if value is 0 - // FALLTROUGH + ; FALLTROUGH -toggle_sign_FAC1_skipcheck: // entry for other routines +toggle_sign_FAC1_skipcheck: ; entry for other routines lda FAC1_sign eor #$FF sta FAC1_sign -!: + + ; FALLTROUGH + +toggle_sign_FAC1_end: + rts diff --git a/src/basic/math/div_FAC1_denorm.s b/src/basic/math/div_FAC1_denorm.s index 9e8bc371..81f779a8 100644 --- a/src/basic/math/div_FAC1_denorm.s +++ b/src/basic/math/div_FAC1_denorm.s @@ -1,33 +1,33 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - denormalize FAC1 mantissa and adapt its exponent accordingly for division -// +; +; Math package - denormalize FAC1 mantissa and adapt its exponent accordingly for division +; div_FAC1_denorm: - // Set FACOV to 0, no need for increased precision here + ; Set FACOV to 0, no need for increased precision here lda #$00 sta FACOV - // Start by moving whole bytes, if possible + ; Start by moving whole bytes, if possible lda FAC1_mantissa+3 - bne div_FAC1_denorm_by_bit // branch if last byte of mantissa is non-zero + bne div_FAC1_denorm_by_bit ; branch if last byte of mantissa is non-zero lda FAC1_exponent cmp #$08 - bcc div_FAC1_denorm_by_bit // branch if not suitable to increment exponent by 8 + bcc div_FAC1_denorm_by_bit ; branch if not suitable to increment exponent by 8 - // Increment exponent + ; Increment exponent - sbc #$08 // Carry already sec + sbc #$08 ; Carry already sec sta FAC1_exponent - // Move mantissa bytes + ; Move mantissa bytes lda FAC1_mantissa+2 sta FAC1_mantissa+3 @@ -38,22 +38,22 @@ div_FAC1_denorm: lda #$00 sta FAC1_mantissa+0 - beq div_FAC1_denorm // branch always + beq div_FAC1_denorm ; branch always div_FAC1_denorm_by_bit: lda FAC1_mantissa+3 and #$01 - bne div_FAC1_denorm_done // branch if lowest bit of mantissa is already 1 + bne div_FAC1_denorm_done ; branch if lowest bit of mantissa is already 1 lda FAC1_exponent - beq div_FAC1_denorm_done // branch if not suitable to decrement exponent + beq div_FAC1_denorm_done ; branch if not suitable to decrement exponent - // Decrement exponent + ; Decrement exponent dec FAC1_exponent - // Move mantissa bits + ; Move mantissa bits clc ror FAC1_mantissa+0 @@ -61,7 +61,7 @@ div_FAC1_denorm_by_bit: ror FAC1_mantissa+2 ror FAC1_mantissa+3 - bcc div_FAC1_denorm_by_bit // branch always + bcc div_FAC1_denorm_by_bit ; branch always div_FAC1_denorm_done: diff --git a/src/basic/math/div_mantissas.s b/src/basic/math/div_mantissas.s index 06c274aa..eb064082 100644 --- a/src/basic/math/div_mantissas.s +++ b/src/basic/math/div_mantissas.s @@ -1,41 +1,41 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Math package - 32-bit mantissa division, based on code by Verz -// -// divident: FAC2_mantissa, divisor: FAC1_mantissa (without FACOV), result: FAC2_mantissa, remainder: RESHO -// temporary storage: INDEX+0, INDEX+1, INDEX+2, INDEX+3 -// -// RESHO (remainder) should be set to 0 before -// -// see https://codebase64.org/doku.php?id=base:24bit_division_24-bit_result +; Math package - 32-bit mantissa division, based on code by Verz +; +; divident: FAC2_mantissa, divisor: FAC1_mantissa (without FACOV), result: FAC2_mantissa, remainder: RESHO +; temporary storage: INDEX+0, INDEX+1, INDEX+2, INDEX+3 +; +; RESHO (remainder) should be set to 0 before +; +; see https://codebase64.org/doku.php?id=base:24bit_division_24-bit_result -// XXX test this +; XXX test this div_mantissas: - ldx #32 // repeat for each bit + ldx #32 ; repeat for each bit - // FALLTROUGH + ; FALLTROUGH div_mantissas_loop: - // Multiply divident by 2, msb -> Carry + ; Multiply divident by 2, msb -> Carry asl FAC2_mantissa+3 rol FAC2_mantissa+2 rol FAC2_mantissa+1 rol FAC2_mantissa+0 - // Multiply remainder by 2, lsb <- Carry + ; Multiply remainder by 2, lsb <- Carry rol RESHO+3 rol RESHO+2 rol RESHO+1 rol RESHO+0 - // Subtract divisor from the remainder, result to INDEX and .Y + ; Subtract divisor from the remainder, result to INDEX and .Y sec lda RESHO+3 @@ -53,10 +53,10 @@ div_mantissas_loop: lda RESHO+0 sbc FAC1_mantissa+0 - bcc div_mantissas_skip // if Carry is not set then divisor did not fit in remainder yet + bcc div_mantissas_skip ; if Carry is not set then divisor did not fit in remainder yet sta INDEX+0 - // Save subtraction result as new remainder + ; Save subtraction result as new remainder lda INDEX+3 sta RESHO+3 @@ -70,11 +70,11 @@ div_mantissas_loop: lda INDEX+0 sta RESHO+0 - // Increment result cause divisor fit in 1 times + ; Increment result cause divisor fit in 1 times inc FAC2_mantissa+3 - // FALLTROUGH + ; FALLTROUGH div_mantissas_skip: diff --git a/src/basic/math/e097.rnd_FAC1.s b/src/basic/math/e097.rnd_FAC1.s index 0091fe7f..09749b97 100644 --- a/src/basic/math/e097.rnd_FAC1.s +++ b/src/basic/math/e097.rnd_FAC1.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Random number generator routine -// -// Input: -// - FAC1 (0 - reinitialize the seed with random value, negative - create seed from FAC1) -// -// Output: -// - FAC1 -// +; +; Random number generator routine +; +; Input: +; - FAC1 (0 - reinitialize the seed with random value, negative - create seed from FAC1) +; +; Output: +; - FAC1 +; rnd_FAC1: jsr sgn_FAC1_A - // FALLTROUGH to rnd_A + ; FALLTROUGH to rnd_A diff --git a/src/basic/math/e09a.rnd_A.s b/src/basic/math/e09a.rnd_A.s index 1bb428f8..a3bc25ad 100644 --- a/src/basic/math/e09a.rnd_A.s +++ b/src/basic/math/e09a.rnd_A.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Random number generator routine -// -// Input: -// - .A (0 - reinitialize the seed with random value, $80 or above - create seed from FAC1) -// -// Output: -// - FAC1 -// -// See also: -// - https://www.atarimagazines.com/compute/issue72/random_numbers.php -// +; +; Random number generator routine +; +; Input: +; - .A (0 - reinitialize the seed with random value, $80 or above - create seed from FAC1) +; +; Output: +; - FAC1 +; +; See also: +; - https://www.atarimagazines.com/compute/issue72/random_numbers.php +; rnd_A: cmp #$00 - beq_16 rnd_seed_init + +beq rnd_seed_init cmp #$80 - bcc_16 rnd_generate + +bcc rnd_generate jmp rnd_seed_from_FAC1 diff --git a/src/basic/math/e0be.rnd_generate.s b/src/basic/math/e0be.rnd_generate.s index f33e2921..1692c0f6 100644 --- a/src/basic/math/e0be.rnd_generate.s +++ b/src/basic/math/e0be.rnd_generate.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// A fast pseudorandom generator, modified idea from: -// - https://codebase64.org/doku.php?id=base:32bit_galois_lfsr -// -// Output: -// - FAC1 -// -// See also: -// - https://www.atarimagazines.com/compute/issue72/random_numbers.php -// +; +; A fast pseudorandom generator, modified idea from: +; - https://codebase64.org/doku.php?id=base:32bit_galois_lfsr +; +; Output: +; - FAC1 +; +; See also: +; - https://www.atarimagazines.com/compute/issue72/random_numbers.php +; rnd_generate: @@ -38,13 +38,13 @@ rnd_generate: eor #$04 sta RNDX+4 - sec // make sure Carry is always set, for adc + sec ; make sure Carry is always set, for adc - // FALLTROUGH + ; FALLTROUGH rnd_generate_copy: - // Copy the generated number to FAC1, mangle it a little + ; Copy the generated number to FAC1, mangle it a little lda RNDX+3 adc #$C6 @@ -63,7 +63,7 @@ rnd_generate_copy: rol sta FAC1_mantissa+3 - // FALLTROUGH + ; FALLTROUGH rnd_generate_finalize: @@ -71,7 +71,7 @@ rnd_generate_finalize: sta FAC1_sign lda #$80 - sta FACOV // just to prevent 0 after normalization + sta FACOV ; just to prevent 0 after normalization sta FAC1_exponent jmp normal_FAC1 diff --git a/src/basic/math/mul10_FAC1_mul2.s b/src/basic/math/mul10_FAC1_mul2.s index 55b8f160..4498a60d 100644 --- a/src/basic/math/mul10_FAC1_mul2.s +++ b/src/basic/math/mul10_FAC1_mul2.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Multiply FAC1 by 2, do not normalize -// +; +; Multiply FAC1 by 2, do not normalize +; mul10_FAC1_mul2: - // Increment the exponent + ; Increment the exponent inc FAC1_exponent - beq_16 set_FAC1_max + +beq set_FAC1_max rts diff --git a/src/basic/math/mul_FAC2_FAC1.s b/src/basic/math/mul_FAC2_FAC1.s index 20cafdd0..64112040 100644 --- a/src/basic/math/mul_FAC2_FAC1.s +++ b/src/basic/math/mul_FAC2_FAC1.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - multiplies FAC1 by FAC2 -// -// Input: -// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag -// -// Note: -// - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 XXX address does not match -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - multiplies FAC1 by FAC2 +; +; Input: +; - .A - must load FAC1 exponent ($61) beforehand to set the zero flag +; +; Note: +; - load FAC2 after FAC1, or mimic the Kernals sign comparison (XXX do we need it?) +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 XXX address does not match +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; set_FAC1_zero: @@ -28,23 +28,23 @@ mul_FAC2_FAC1_done: mul_FAC2_FAC1: - // First handle special case of multiplying by 0 + ; First handle special case of multiplying by 0 lda FAC1_exponent beq mul_FAC2_FAC1_done lda FAC2_exponent - bne !+ + bne @1 sta FAC1_exponent beq mul_FAC2_FAC1_done -!: - // Multiply signs +@1: + ; Multiply signs lda FAC1_sign eor FAC2_sign sta FAC1_sign - // Add the exponents (subtract the bias) - XXX can this be optimized somehow? + ; Add the exponents (subtract the bias) - XXX can this be optimized somehow? jsr muldiv_RESHO_set_0 @@ -55,58 +55,58 @@ mul_FAC2_FAC1: jsr muldiv_RESHO_01_add_A lda RESHO+0 - sbc #$80 // we need to correct double BIAS + sbc #$80 ; we need to correct double BIAS sta RESHO+0 - bcs !+ + bcs @2 lda RESHO+1 sbc #$00 bcc set_FAC1_zero sta RESHO+1 -!: +@2: lda RESHO+1 - bne_16 set_FAC1_max // overflow + +bne set_FAC1_max ; overflow lda RESHO+0 sta FAC1_exponent - // Multiply the mantissas + ; Multiply the mantissas jsr muldiv_RESHO_set_0 clc - // XXX maybe we should preserve .X on stack? this will not cost us too much + ; XXX maybe we should preserve .X on stack? this will not cost us too much lda FACOV jsr mul_FAC2_FAC1_by_A jsr mul_FAC2_FAC1_shift - bcc !+ + bcc @3 inc RESHO+0 -!: +@3: lda FAC1_mantissa+3 jsr mul_FAC2_FAC1_by_A jsr mul_FAC2_FAC1_shift - bcc !+ + bcc @4 inc RESHO+0 -!: +@4: lda FAC1_mantissa+2 jsr mul_FAC2_FAC1_by_A jsr mul_FAC2_FAC1_shift - bcc !+ + bcc @5 inc RESHO+0 -!: +@5: lda FAC1_mantissa+1 jsr mul_FAC2_FAC1_by_A jsr mul_FAC2_FAC1_shift - bcc !+ + bcc @6 inc RESHO+0 -!: +@6: lda FAC1_mantissa+0 jsr mul_FAC2_FAC1_by_A jsr mul_FAC2_FAC1_shift - bcc !+ + bcc @7 inc RESHO+0 -!: - // Copy RESHO to FAC1 mantissa +@7: + ; Copy RESHO to FAC1 mantissa lda RESHO+4 sta FACOV @@ -119,12 +119,12 @@ mul_FAC2_FAC1: lda RESHO+0 sta FAC1_mantissa+0 - // Correct the exponent + ; Correct the exponent lda FAC1_exponent clc adc #$08 - bcs_16 set_FAC1_max // branch if overflow + +bcs set_FAC1_max ; branch if overflow sta FAC1_exponent jmp normal_FAC1 @@ -133,7 +133,7 @@ mul_FAC2_FAC1_by_A: beq mul_FAC2_FAC1_by_A_done sta INDEX+3 - // Multiply FAC2_mantissa+3 + ; Multiply FAC2_mantissa+3 lda FAC2_mantissa+3 jsr mul_FAC2_FAC1_8x8 @@ -143,14 +143,14 @@ mul_FAC2_FAC1_by_A: txa adc RESHO+3 sta RESHO+3 - bcc !+ + bcc @8 inc RESHO+2 - bne !+ + bne @8 inc RESHO+1 - bne !+ + bne @8 inc RESHO+0 -!: - // Multiply FAC2_mantissa+2 +@8: + ; Multiply FAC2_mantissa+2 lda FAC2_mantissa+2 jsr mul_FAC2_FAC1_8x8 @@ -160,12 +160,12 @@ mul_FAC2_FAC1_by_A: txa adc RESHO+2 sta RESHO+2 - bcc !+ + bcc @9 inc RESHO+1 - bne !+ + bne @9 inc RESHO+0 -!: - // Multiply FAC2_mantissa+1 +@9: + ; Multiply FAC2_mantissa+1 lda FAC2_mantissa+1 jsr mul_FAC2_FAC1_8x8 @@ -175,10 +175,10 @@ mul_FAC2_FAC1_by_A: txa adc RESHO+1 sta RESHO+1 - bcc !+ + bcc @10 inc RESHO+0 -!: - // Multiply FAC2_mantissa+0 +@10: + ; Multiply FAC2_mantissa+0 lda FAC2_mantissa+0 jsr mul_FAC2_FAC1_8x8 @@ -188,7 +188,7 @@ mul_FAC2_FAC1_by_A: adc RESHO+0 sta RESHO+0 - // FALLTROUGH + ; FALLTROUGH mul_FAC2_FAC1_by_A_done: diff --git a/src/basic/math/mul_FAC2_FAC1_8x8.s b/src/basic/math/mul_FAC2_FAC1_8x8.s index ff06c0c2..703f17f6 100644 --- a/src/basic/math/mul_FAC2_FAC1_8x8.s +++ b/src/basic/math/mul_FAC2_FAC1_8x8.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine, based on code by djmips (fast version) from: -// - https://codebase64.org/doku.php?id=base:8bit_multiplication_16bit_product_fast_no_tables -// or by code by Graham (small version) from: -// - https://codebase64.org/doku.php?id=base:short_8bit_multiplication_16bit_product -// -// input: .A (and Zero flag set according to .A), INDEX+3 -// output: .X (high byte), .A (low byte), carry always clear -// +; +; Helper routine, based on code by djmips (fast version) from: +; - https://codebase64.org/doku.php?id=base:8bit_multiplication_16bit_product_fast_no_tables +; or by code by Graham (small version) from: +; - https://codebase64.org/doku.php?id=base:short_8bit_multiplication_16bit_product +; +; input: .A (and Zero flag set according to .A), INDEX+3 +; output: .X (high byte), .A (low byte), carry always clear +; mul_FAC2_FAC1_8x8: - // Special cases - handle multiplication by 0 + ; Special cases - handle multiplication by 0 beq mul_FAC2_FAC1_8x8_zero sta INDEX+2 @@ -22,54 +22,54 @@ mul_FAC2_FAC1_8x8: lda INDEX+3 beq mul_FAC2_FAC1_8x8_zero - // Multiply INDEX+2 * INDEX+3 + ; Multiply INDEX+2 * INDEX+3 -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { - // Fast multiplication routine + ; Fast multiplication routine lda #$00 - dec INDEX+3 // decrement because we will be adding with carry set for speed (an extra one) + dec INDEX+3 ; decrement because we will be adding with carry set for speed (an extra one) ror INDEX+2 - bcc !+ + bcc @1 adc INDEX+3 -!: +@1: ror ror INDEX+2 - bcc !+ + bcc @2 adc INDEX+3 -!: +@2: ror ror INDEX+2 - bcc !+ + bcc @3 adc INDEX+3 -!: +@3: ror ror INDEX+2 - bcc !+ + bcc @4 adc INDEX+3 -!: +@4: ror ror INDEX+2 - bcc !+ + bcc @5 adc INDEX+3 -!: +@5: ror ror INDEX+2 - bcc !+ + bcc @6 adc INDEX+3 -!: +@6: ror ror INDEX+2 - bcc !+ + bcc @7 adc INDEX+3 -!: +@7: ror ror INDEX+2 - bcc !+ + bcc @8 adc INDEX+3 -!: +@8: ror ror INDEX+2 inc INDEX+3 @@ -77,32 +77,31 @@ mul_FAC2_FAC1_8x8: tax lda INDEX+2 -#else +} else { - // Small multiplication routine + ; Small multiplication routine lda #$00 ldx #$08 clc -!: - bcc !+ +@9: + bcc @10 clc adc INDEX+3 -!: +@10: ror ror INDEX+2 dex - bpl !-- + bpl @9 ldx INDEX+2 - // Reverse return byte order, to match fast version - // (such order is easier top handle for the callers) + ; Reverse return byte order, to match fast version + ; (such order is easier top handle for the callers) stx INDEX+2 tax lda INDEX+2 - -#endif +} clc rts diff --git a/src/basic/math/mul_FAC2_FAC1_shift.s b/src/basic/math/mul_FAC2_FAC1_shift.s index 6aed5169..7e3eaada 100644 --- a/src/basic/math/mul_FAC2_FAC1_shift.s +++ b/src/basic/math/mul_FAC2_FAC1_shift.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Shift RESHO by one byte - for multiplication -// +; +; Shift RESHO by one byte - for multiplication +; mul_FAC2_FAC1_shift: - // Check if rounding is needed + ; Check if rounding is needed php clc lda RESHO+4 - bpl !+ + bpl @1 sec -!: - // Copy bytes +@1: + ; Copy bytes lda RESHO+3 sta RESHO+4 @@ -28,19 +28,19 @@ mul_FAC2_FAC1_shift: sta RESHO+1 lda #$00 sta RESHO+0 - bcc !+ + bcc @2 - // Perform rounding + ; Perform rounding inc RESHO+4 - bne !+ + bne @2 inc RESHO+3 - bne !+ + bne @2 inc RESHO+2 - bne !+ + bne @2 inc RESHO+1 - bne !+ + bne @2 inc RESHO+0 -!: +@2: plp rts diff --git a/src/basic/math/muldiv_RESHO_helpers.s b/src/basic/math/muldiv_RESHO_helpers.s index 7f73037f..3097567d 100644 --- a/src/basic/math/muldiv_RESHO_helpers.s +++ b/src/basic/math/muldiv_RESHO_helpers.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - helper routines for RESHO manipulation -// +; +; Math package - helper routines for RESHO manipulation +; muldiv_RESHO_set_0: @@ -24,7 +24,7 @@ muldiv_RESHO_01_add_A: clc adc RESHO+0 sta RESHO+0 - bcc !+ + bcc @1 inc RESHO+1 -!: +@1: rts diff --git a/src/basic/math/normal_FAC1.s b/src/basic/math/normal_FAC1.s index 5c0cc405..64d8f938 100644 --- a/src/basic/math/normal_FAC1.s +++ b/src/basic/math/normal_FAC1.s @@ -1,48 +1,48 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - normalize FAC1 -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 113 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - normalize FAC1 +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 113 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this normal_FAC1: lda FAC1_exponent - beq normal_FAC1_end // branch if our float is 0 + beq normal_FAC1_end ; branch if our float is 0 - // FALLTROUGH + ; FALLTROUGH normal_FAC1_check_mantissa_byte: lda FAC1_mantissa+0 - beq normal_FAC1_by_byte // branch if we can move the whole byte + beq normal_FAC1_by_byte ; branch if we can move the whole byte - // FALLTROUGH + ; FALLTROUGH normal_FAC1_check_mantissa_bit: - lda FAC1_mantissa+0 // XXX optimize for 65CE02? + lda FAC1_mantissa+0 ; XXX optimize for 65CE02? and #$80 - bne normal_FAC1_end // branch if already normalized + bne normal_FAC1_end ; branch if already normalized - // FALLTROUGH + ; FALLTROUGH normal_FAC1_by_bit: - // Decrement the exponent + ; Decrement the exponent dec FAC1_exponent - beq normal_FAC1_end // exponent reached 0, nothing more to do + beq normal_FAC1_end ; exponent reached 0, nothing more to do - // Multiply the mantissa by 2 + ; Multiply the mantissa by 2 asl FACOV rol FAC1_mantissa+3 @@ -50,23 +50,23 @@ normal_FAC1_by_bit: rol FAC1_mantissa+1 rol FAC1_mantissa+0 - bcc normal_FAC1_check_mantissa_bit // branch if next iteration needed + bcc normal_FAC1_check_mantissa_bit ; branch if next iteration needed rts normal_FAC1_by_byte: - // First decrement the exponent by 8, but not below 0 + ; First decrement the exponent by 8, but not below 0 lda FAC1_exponent sec sbc #$08 - bcs !+ + bcs @1 lda #$00 -!: +@1: sta FAC1_exponent - beq normal_FAC1_end // branch if our float reached 0 + beq normal_FAC1_end ; branch if our float reached 0 - // Now multiply the mantissa by 8 by moving the whole bytes + ; Now multiply the mantissa by 8 by moving the whole bytes lda FAC1_mantissa+1 sta FAC1_mantissa+0 @@ -81,20 +81,20 @@ normal_FAC1_by_byte: lda #$00 sta FACOV - // Now check if mantissa is not 0 + ; Now check if mantissa is not 0 ora FAC1_mantissa+0 ora FAC1_mantissa+1 ora FAC1_mantissa+2 ora FAC1_mantissa+3 - bne normal_FAC1_check_mantissa_byte // not 0 - branch to next iteration + bne normal_FAC1_check_mantissa_byte ; not 0 - branch to next iteration - // Our mantissa reached 0 - mark exponent as 0 and finish + ; Our mantissa reached 0 - mark exponent as 0 and finish sta FAC1_exponent - // FALLTROUGH + ; FALLTROUGH normal_FAC1_end: diff --git a/src/basic/math/rnd_seed_from_FAC1.s b/src/basic/math/rnd_seed_from_FAC1.s index 0a288ca2..7c53738f 100644 --- a/src/basic/math/rnd_seed_from_FAC1.s +++ b/src/basic/math/rnd_seed_from_FAC1.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Initialize random seed using values from FAC1, -// afterwards generate random number in FAC1 -// +; +; Initialize random seed using values from FAC1, +; afterwards generate random number in FAC1 +; rnd_seed_from_FAC1: diff --git a/src/basic/math/rnd_seed_init.s b/src/basic/math/rnd_seed_init.s index a2510214..27924caa 100644 --- a/src/basic/math/rnd_seed_init.s +++ b/src/basic/math/rnd_seed_init.s @@ -1,33 +1,33 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Initialize random seed, afterwards generate random number in FAC1, -// try to gather as much entropy from different sources as possible -// +; +; Initialize random seed, afterwards generate random number in FAC1, +; try to gather as much entropy from different sources as possible +; rnd_seed_init: - eor CIA1_TIMALO // timer used for IRQ generation, use potential entropy from .A + eor CIA1_TIMALO ; timer used for IRQ generation, use potential entropy from .A sta RNDX+3 - txa // .X might contain some entropy - eor VIC_RASTER // lowest 8 bits of current raster line + txa ; .X might contain some entropy + eor VIC_RASTER ; lowest 8 bits of current raster line sta RNDX+1 - tya // .Y might contain some entropy + tya ; .Y might contain some entropy eor CIA1_TIMAHI sta RNDX+4 - lda TIME+2 // byte from jiffy counter might be useful too - eor SID_RANDOM // not sure if SID set correctly, but it will not hurt -#if CONFIG_MB_MEGA_65 - eor VIC_XPOS // not sure if VIC-IV visible, but it will not hurt -#endif + lda TIME+2 ; byte from jiffy counter might be useful too + eor SID_RANDOM ; not sure if SID set correctly, but it will not hurt +!ifdef CONFIG_MB_M65 { + eor VIC_XPOS ; not sure if VIC-IV visible, but it will not hurt +} sta RNDX+2 - // RNDX+0 will be overwritten by generator + ; RNDX+0 will be overwritten by generator jmp rnd_generate diff --git a/src/basic/math/round_FAC1.s b/src/basic/math/round_FAC1.s index 7cef4a05..0b401ef9 100644 --- a/src/basic/math/round_FAC1.s +++ b/src/basic/math/round_FAC1.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - rounds FAC1 before copying -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - rounds FAC1 before copying +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this round_FAC1: - // If number is 0, do not do anything + ; If number is 0, do not do anything lda FAC1_exponent beq round_FAC1_done lda FACOV - bpl round_FAC1_zero_FACOV // branch if it is enough to clear FACOV + bpl round_FAC1_zero_FACOV ; branch if it is enough to clear FACOV - // Increment the 4 bytes of matissa + ; Increment the 4 bytes of matissa - // Curse you, who invented this format! Had the mantissa been little endian, - // we could have used INW on 65C02 and above, the code would have been smaller! + ; Curse you, who invented this format! Had the mantissa been little endian, + ; we could have used INW on 65C02 and above, the code would have been smaller! inc FAC1_mantissa+3 bne round_FAC1_zero_FACOV @@ -36,25 +36,25 @@ round_FAC1: inc FAC1_mantissa+0 bne round_FAC1_zero_FACOV - // If we are here, it means mantissa is 0; put it to minimum allowed and increment exponent + ; If we are here, it means mantissa is 0; put it to minimum allowed and increment exponent lda #$80 sta FAC1_mantissa+0 inc FAC1_exponent bne round_FAC1_zero_FACOV - // If we are here, it means the exponent wrapped around to $00; put it back to $FF + ; If we are here, it means the exponent wrapped around to $00; put it back to $FF dec FAC1_exponent - // FALLTROUGH + ; FALLTROUGH round_FAC1_zero_FACOV: lda #$00 sta FACOV - // FALLTROUGH + ; FALLTROUGH round_FAC1_done: diff --git a/src/basic/math_consts/aea8.const_PI.s b/src/basic/math_consts/aea8.const_PI.s index d86c1687..cd7dd5b6 100644 --- a/src/basic/math_consts/aea8.const_PI.s +++ b/src/basic/math_consts/aea8.const_PI.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - Computes Mapping the Commodore 64, page 103 -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - Computes Mapping the Commodore 64, page 103 +; const_PI: - put_const_PI() + +PUT_CONST_PI diff --git a/src/basic/math_consts/b1a5.const_NEG_32768.s b/src/basic/math_consts/b1a5.const_NEG_32768.s index c45694fa..ffa7c0b9 100644 --- a/src/basic/math_consts/b1a5.const_NEG_32768.s +++ b/src/basic/math_consts/b1a5.const_NEG_32768.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - Computes Mapping the Commodore 64, page 105 -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - Computes Mapping the Commodore 64, page 105 +; CONST_NEG_32768: - put_const_NEG_32768() + +PUT_CONST_NEG_32768 diff --git a/src/basic/math_consts/b9bc.const_ONE.s b/src/basic/math_consts/b9bc.const_ONE.s index 38997280..9c044036 100644 --- a/src/basic/math_consts/b9bc.const_ONE.s +++ b/src/basic/math_consts/b9bc.const_ONE.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - Computes Mapping the Commodore 64, page 113 -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - Computes Mapping the Commodore 64, page 113 +; const_ONE: - put_const_ONE() + +PUT_CONST_ONE diff --git a/src/basic/math_consts/b9d6.const_INV_SQR_2.s b/src/basic/math_consts/b9d6.const_INV_SQR_2.s index e3733683..a538c7bc 100644 --- a/src/basic/math_consts/b9d6.const_INV_SQR_2.s +++ b/src/basic/math_consts/b9d6.const_INV_SQR_2.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; const_INV_SQR_2: - put_const_INV_SQR_2() + +PUT_CONST_INV_SQR_2 diff --git a/src/basic/math_consts/b9db.const_SQR_2.s b/src/basic/math_consts/b9db.const_SQR_2.s index ab9d0a51..27ef1d61 100644 --- a/src/basic/math_consts/b9db.const_SQR_2.s +++ b/src/basic/math_consts/b9db.const_SQR_2.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; const_SQR_2: - put_const_SQR_2() + +PUT_CONST_SQR_2 diff --git a/src/basic/math_consts/b9e0.const_NEG_HALF.s b/src/basic/math_consts/b9e0.const_NEG_HALF.s index 0227e546..cf98afdf 100644 --- a/src/basic/math_consts/b9e0.const_NEG_HALF.s +++ b/src/basic/math_consts/b9e0.const_NEG_HALF.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; const_NEG_HALF: - put_const_NEG_HALF() + +PUT_CONST_NEG_HALF diff --git a/src/basic/math_consts/b9e5.const_LOG_2.s b/src/basic/math_consts/b9e5.const_LOG_2.s index 559d1861..456f92ba 100644 --- a/src/basic/math_consts/b9e5.const_LOG_2.s +++ b/src/basic/math_consts/b9e5.const_LOG_2.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; const_LOG_2: - put_const_LOG_2() + +PUT_CONST_LOG_2 diff --git a/src/basic/math_consts/baf9.const_TEN.s b/src/basic/math_consts/baf9.const_TEN.s index e2610722..94762816 100644 --- a/src/basic/math_consts/baf9.const_TEN.s +++ b/src/basic/math_consts/baf9.const_TEN.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - Computes Mapping the Commodore 64, page 114 -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - Computes Mapping the Commodore 64, page 114 +; const_TEN: - put_const_TEN() + +PUT_CONST_TEN diff --git a/src/basic/math_consts/bf11.const_HALF.s b/src/basic/math_consts/bf11.const_HALF.s index 15e1f801..a9ae49f1 100644 --- a/src/basic/math_consts/bf11.const_HALF.s +++ b/src/basic/math_consts/bf11.const_HALF.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - Computes Mapping the Commodore 64, page 116 -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - Computes Mapping the Commodore 64, page 116 +; const_HALF: - put_const_HALF() + +PUT_CONST_HALF diff --git a/src/basic/math_consts/bfbf.const_INV_LOG_2.s b/src/basic/math_consts/bfbf.const_INV_LOG_2.s index 07d97253..854c6ad3 100644 --- a/src/basic/math_consts/bfbf.const_INV_LOG_2.s +++ b/src/basic/math_consts/bfbf.const_INV_LOG_2.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; const_INV_LOG_2: - put_const_INV_LOG_2() + +PUT_CONST_INV_LOG_2 diff --git a/src/basic/math_consts/bfe8.const_ONE.s b/src/basic/math_consts/bfe8.const_ONE.s index bea746ee..d39c248b 100644 --- a/src/basic/math_consts/bfe8.const_ONE.s +++ b/src/basic/math_consts/bfe8.const_ONE.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - a constant, for documentation see: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - put_const_ONE() // duplicated constant - no label + +PUT_CONST_ONE ; duplicated constant - no label diff --git a/src/basic/math_consts/e2e0.const_HALF_PI.s b/src/basic/math_consts/e2e0.const_HALF_PI.s index a75efb68..ff8fab44 100644 --- a/src/basic/math_consts/e2e0.const_HALF_PI.s +++ b/src/basic/math_consts/e2e0.const_HALF_PI.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - a constant, for documentation see: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; const_HALF_PI: - put_const_HALF_PI() + +PUT_CONST_HALF_PI diff --git a/src/basic/math_consts/e2e5.const_DOUBLE_PI.s b/src/basic/math_consts/e2e5.const_DOUBLE_PI.s index f8728ef7..731e51d8 100644 --- a/src/basic/math_consts/e2e5.const_DOUBLE_PI.s +++ b/src/basic/math_consts/e2e5.const_DOUBLE_PI.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - a constant, for documentation see: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; const_DOUBLE_PI: - put_const_DOUBLE_PI() + +PUT_CONST_DOUBLE_PI diff --git a/src/basic/math_consts/e2ea.const_QUARTER.s b/src/basic/math_consts/e2ea.const_QUARTER.s index 77962d8a..3cba4c8b 100644 --- a/src/basic/math_consts/e2ea.const_QUARTER.s +++ b/src/basic/math_consts/e2ea.const_QUARTER.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - a constant, for documentation see: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; const_QUARTER: - put_const_QUARTER() \ No newline at end of file + +PUT_CONST_QUARTER diff --git a/src/basic/math_consts/e309.const_DOUBLE_PI.s b/src/basic/math_consts/e309.const_DOUBLE_PI.s index 33a01f1b..50c149ca 100644 --- a/src/basic/math_consts/e309.const_DOUBLE_PI.s +++ b/src/basic/math_consts/e309.const_DOUBLE_PI.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - a constant, for documentation see: -// - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True -// +; +; Math package - a constant, for documentation see: +; - https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True +; - put_const_DOUBLE_PI() // duplicated constant - no label + +PUT_CONST_DOUBLE_PI ; duplicated constant - no label diff --git a/src/basic/math_mov/bba2.mov_MEM_FAC1.jmp.s b/src/basic/math_mov/bba2.mov_MEM_FAC1.jmp.s index 21e9f9ca..bad7d253 100644 --- a/src/basic/math_mov/bba2.mov_MEM_FAC1.jmp.s +++ b/src/basic/math_mov/bba2.mov_MEM_FAC1.jmp.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_MEM_FAC1 diff --git a/src/basic/math_mov/bbc7.mov_r_FAC1_TMP2.s b/src/basic/math_mov/bbc7.mov_r_FAC1_TMP2.s index a3651fd4..fd47291a 100644 --- a/src/basic/math_mov/bbc7.mov_r_FAC1_TMP2.s +++ b/src/basic/math_mov/bbc7.mov_r_FAC1_TMP2.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_r_FAC1_TMP2 diff --git a/src/basic/math_mov/bbca.mov_r_FAC1_TMP1.s b/src/basic/math_mov/bbca.mov_r_FAC1_TMP1.s index d9993d30..51494056 100644 --- a/src/basic/math_mov/bbca.mov_r_FAC1_TMP1.s +++ b/src/basic/math_mov/bbca.mov_r_FAC1_TMP1.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_r_FAC1_TMP1 diff --git a/src/basic/math_mov/bbd0.mov_r_FAC1_VAR.s b/src/basic/math_mov/bbd0.mov_r_FAC1_VAR.s index 59ac4b18..9de76027 100644 --- a/src/basic/math_mov/bbd0.mov_r_FAC1_VAR.s +++ b/src/basic/math_mov/bbd0.mov_r_FAC1_VAR.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - move FAC1 (rounds) to memory variable -// -// Input: -// - FORPNT ($49/$4A) - variable address -// -// See also: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// +; +; Math package - move FAC1 (rounds) to memory variable +; +; Input: +; - FORPNT ($49/$4A) - variable address +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; mov_r_FAC1_VAR: ldy #FORPNT+1 ldx #FORPNT+0 - // FALLTROUGH to mov_r_FAC1_MEM + ; FALLTROUGH to mov_r_FAC1_MEM diff --git a/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s b/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s index 8bf3182d..3fcad9d5 100644 --- a/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s +++ b/src/basic/math_mov/bbd4.mov_r_FAC1_MEM.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - copy FAC1 to memory location, do not round -// -// Input: -// - .X - address low byte -// - .Y - address high byte -// -// Output: -// - .A - FAC1 exponent -// -// See also: -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - copy FAC1 to memory location, do not round +; +; Input: +; - .X - address low byte +; - .Y - address high byte +; +; Output: +; - .A - FAC1 exponent +; +; See also: +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; mov_r_FAC1_MEM: - // Start by rounding FAC1 + ; Start by rounding FAC1 jsr round_FAC1 jmp mov_FAC1_MEM diff --git a/src/basic/math_mov/bbfc.mov_FAC2_FAC1.s b/src/basic/math_mov/bbfc.mov_FAC2_FAC1.s index a59de960..c320e722 100644 --- a/src/basic/math_mov/bbfc.mov_FAC2_FAC1.s +++ b/src/basic/math_mov/bbfc.mov_FAC2_FAC1.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_FAC2_FAC1 diff --git a/src/basic/math_mov/bc0c.mov_r_FAC1_FAC2.s b/src/basic/math_mov/bc0c.mov_r_FAC1_FAC2.s index edf6e9cd..dbaae34c 100644 --- a/src/basic/math_mov/bc0c.mov_r_FAC1_FAC2.s +++ b/src/basic/math_mov/bc0c.mov_r_FAC1_FAC2.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - round and move FAC1 to FAC2 -// -// Output: -// - .A - FAC1 exponent -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - round and move FAC1 to FAC2 +; +; Output: +; - .A - FAC1 exponent +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; mov_r_FAC1_FAC2: - // First round FAC1 + ; First round FAC1 jsr round_FAC1 - // FALLTROUGH to mov_FAC1_FAC2 + ; FALLTROUGH to mov_FAC1_FAC2 diff --git a/src/basic/math_mov/bc0f.mov_FAC1_FAC2.jmp.s b/src/basic/math_mov/bc0f.mov_FAC1_FAC2.jmp.s index 6cb71a8d..f7409462 100644 --- a/src/basic/math_mov/bc0f.mov_FAC1_FAC2.jmp.s +++ b/src/basic/math_mov/bc0f.mov_FAC1_FAC2.jmp.s @@ -1,8 +1,8 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a compatibility jump - our routine is longer than original one +; Just a compatibility jump - our routine is longer than original one jmp mov_FAC1_FAC2 diff --git a/src/basic/math_mov/mov_FAC1_FAC2.s b/src/basic/math_mov/mov_FAC1_FAC2.s index 8ce497d5..25202fc0 100644 --- a/src/basic/math_mov/mov_FAC1_FAC2.s +++ b/src/basic/math_mov/mov_FAC1_FAC2.s @@ -1,34 +1,34 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - move FAC1 to FAC2 -// -// Output (all found by experimentation): -// - .A - FAC1 exponent -// - .X - always 0 -// -// Preserves (found by experimentation): -// - .Y -// -// Note: -// - observed that original ROM always clears FACOV, not sure why -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// +; +; Math package - move FAC1 to FAC2 +; +; Output (all found by experimentation): +; - .A - FAC1 exponent +; - .X - always 0 +; +; Preserves (found by experimentation): +; - .Y +; +; Note: +; - observed that original ROM always clears FACOV, not sure why +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; mov_FAC1_FAC2: - // Copy the exponent + ; Copy the exponent lda FAC1_exponent sta FAC2_exponent - beq !+ // for 0 no need to copy mantissa and sign + beq @1 ; for 0 no need to copy mantissa and sign - // Copy the mantissa + ; Copy the mantissa lda FAC1_mantissa+0 sta FAC2_mantissa+0 lda FAC1_mantissa+1 @@ -38,13 +38,13 @@ mov_FAC1_FAC2: lda FAC1_mantissa+3 sta FAC2_mantissa+3 - // Copy the sign + ; Copy the sign lda FAC1_sign sta FAC2_sign lda FAC1_exponent -!: - // Duplicate the original ROM behaviour +@1: + ; Duplicate the original ROM behaviour ldx #$00 stx FACOV diff --git a/src/basic/math_mov/mov_FAC1_MEM.s b/src/basic/math_mov/mov_FAC1_MEM.s index 84d49903..a26e5684 100644 --- a/src/basic/math_mov/mov_FAC1_MEM.s +++ b/src/basic/math_mov/mov_FAC1_MEM.s @@ -1,54 +1,54 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - copy FAC1 to memory location, do not round -// -// Input: -// - .X - address low byte -// - .Y - address high byte -// -// Output: -// - .A - FAC1 exponent -// -// See also: -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - copy FAC1 to memory location, do not round +; +; Input: +; - .X - address low byte +; - .Y - address high byte +; +; Output: +; - .A - FAC1 exponent +; +; See also: +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; mov_FAC1_MEM: - // Original routines use $22/$23 location for a vector too, see here: - // - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics + ; Original routines use $22/$23 location for a vector too, see here: + ; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics sty INDEX+1 stx INDEX+0 ldy #$00 - // Copy exponent + ; Copy exponent lda FAC1_exponent sta (INDEX), y - beq mov_FAC1_MEM_end // for 0 no need to copy anything more + beq mov_FAC1_MEM_end ; for 0 no need to copy anything more - // Copy first byte of mantissa + ; Copy first byte of mantissa iny lda FAC2_mantissa+3 sta (INDEX), y - // Copy the sign XXX try to optimize this part + ; Copy the sign XXX try to optimize this part lda FAC1_sign - bne !+ + bne @1 lda FAC2_mantissa+3 and #$7F sta (INDEX), y -!: - // Copy remaining parts of mantissa +@1: + ; Copy remaining parts of mantissa iny lda FAC2_mantissa+2 @@ -62,8 +62,8 @@ mov_FAC1_MEM: lda FAC2_mantissa+0 sta (INDEX), y - // Checked, that mov_FAC1_MEM works on real ROM too (at $BBD7), - // and clears FACOV in a similar way as mov_FAC1_FAC2 does (not surprising) + ; Checked, that mov_FAC1_MEM works on real ROM too (at $BBD7), + ; and clears FACOV in a similar way as mov_FAC1_FAC2 does (not surprising) ldy #$00 sty FACOV diff --git a/src/basic/math_mov/mov_FAC2_FAC1.s b/src/basic/math_mov/mov_FAC2_FAC1.s index 231c0b91..b860cac2 100644 --- a/src/basic/math_mov/mov_FAC2_FAC1.s +++ b/src/basic/math_mov/mov_FAC2_FAC1.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - copy FAC2 to FAC1 -// -// Output (found by experimentation): -// - .A - FAC1 exponent -// - .X - always 0 -// -// Preserves: -// - .Y -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 115 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - copy FAC2 to FAC1 +; +; Output (found by experimentation): +; - .A - FAC1 exponent +; - .X - always 0 +; +; Preserves: +; - .Y +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 115 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; mov_FAC2_FAC1: - // Copy the mantissa + ; Copy the mantissa lda FAC2_mantissa+3 sta FAC1_mantissa+3 @@ -31,17 +31,17 @@ mov_FAC2_FAC1: lda FAC2_mantissa+0 sta FAC1_mantissa+0 - // Copy the sign + ; Copy the sign lda FAC2_sign sta FAC1_sign - // Copy the exponent + ; Copy the exponent lda FAC2_exponent sta FAC1_exponent - // Clear FACOV + ; Clear FACOV ldx #$00 stx FACOV diff --git a/src/basic/math_mov/mov_MEM_FAC1.s b/src/basic/math_mov/mov_MEM_FAC1.s index f99cb9ee..94ec6ad7 100644 --- a/src/basic/math_mov/mov_MEM_FAC1.s +++ b/src/basic/math_mov/mov_MEM_FAC1.s @@ -1,38 +1,38 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Math package - fetch FAC1 from RAM location -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// Output: -// - .A - FAC1 exponent, affects status flags -// - .Y - always 0 -// -// Preserves: -// - .X - (experimentation with original ROM) -// -// See also: -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; Math package - fetch FAC1 from RAM location +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; Output: +; - .A - FAC1 exponent, affects status flags +; - .Y - always 0 +; +; Preserves: +; - .X - (experimentation with original ROM) +; +; See also: +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// XXX test this +; XXX test this mov_MEM_FAC1: - // Original routines use $22/$23 location for a vector too, see here: - // - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics + ; Original routines use $22/$23 location for a vector too, see here: + ; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics sty INDEX+1 sta INDEX+0 - // Now copy the data from RAM to FAC2, for the format description see: - // - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 + ; Now copy the data from RAM to FAC2, for the format description see: + ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 - // Copy the mantissa + ; Copy the mantissa ldy #$04 lda (INDEX), y @@ -48,32 +48,32 @@ mov_MEM_FAC1: dey lda (INDEX), y - ora #$80 // clear the sign bit + ora #$80 ; clear the sign bit sta FAC1_mantissa+0 - // Copy the sign + ; Copy the sign lda (INDEX), y - bpl !+ // assumption: non-negative numbers are more frequent + bpl @1 ; assumption: non-negative numbers are more frequent lda #$FF - skip_2_bytes_trash_nvz -!: + +skip_2_bytes_trash_nvz +@1: lda #$00 sta FAC1_sign - // Copy the exponent + ; Copy the exponent dey lda (INDEX), y sta FAC1_exponent - // Set low order mantissa to 0 - this should give the - // most precision while operating on integers + ; Set low order mantissa to 0 - this should give the + ; most precision while operating on integers sty FACOV - // Return the FAC1 exponent + ; Return the FAC1 exponent lda FAC1_exponent rts diff --git a/src/basic/math_mov/mov_MEM_FAC2.s b/src/basic/math_mov/mov_MEM_FAC2.s index f461a667..4cce1956 100644 --- a/src/basic/math_mov/mov_MEM_FAC2.s +++ b/src/basic/math_mov/mov_MEM_FAC2.s @@ -1,41 +1,41 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - fetch FAC2 from memory location -// -// Input: -// - .A - address low byte -// - .Y - address high byte -// -// Output: -// - .A - FAC1 exponent (yes, really - Codebase64 is right) -// - .Y - 0 (experimentation with original ROM) -// -// Preserves: -// - .X - (experimentation with original ROM) -// -// See also: -// - [CM64] Computes Mapping the Commodore 64 - page 114 -// - https://www.c64-wiki.com/wiki/Floating_point_arithmetic -// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics -// +; +; Math package - fetch FAC2 from memory location +; +; Input: +; - .A - address low byte +; - .Y - address high byte +; +; Output: +; - .A - FAC1 exponent (yes, really - Codebase64 is right) +; - .Y - 0 (experimentation with original ROM) +; +; Preserves: +; - .X - (experimentation with original ROM) +; +; See also: +; - [CM64] Computes Mapping the Commodore 64 - page 114 +; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic +; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +; -// XXX test this +; XXX test this mov_MEM_FAC2: - // Original routines use $22/$23 location for a vector too, see here: - // - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics + ; Original routines use $22/$23 location for a vector too, see here: + ; - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics sty INDEX+1 sta INDEX+0 - // Now copy the data from RAM to FAC2, for the format description see: - // - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 + ; Now copy the data from RAM to FAC2, for the format description see: + ; - https://www.c64-wiki.com/wiki/Floating_point_arithmetic#Representation_in_the_C-64 - // Copy the mantissa + ; Copy the mantissa ldy #$04 lda (INDEX), y @@ -51,27 +51,27 @@ mov_MEM_FAC2: dey lda (INDEX), y - ora #$80 // clear the sign bit + ora #$80 ; clear the sign bit sta FAC2_mantissa+0 - // Copy the sign + ; Copy the sign lda (INDEX), y - bpl !+ // assumption: non-negative numbers are more frequent + bpl @1 ; assumption: non-negative numbers are more frequent lda #$FF - skip_2_bytes_trash_nvz -!: + +skip_2_bytes_trash_nvz +@1: lda #$00 sta FAC2_sign - // Copy the exponent + ; Copy the exponent dey lda (INDEX), y sta FAC2_exponent - // Return the FAC1 exponent + ; Return the FAC1 exponent lda FAC1_exponent rts diff --git a/src/basic/math_mov/mov_r_FAC1_TMP1.s b/src/basic/math_mov/mov_r_FAC1_TMP1.s index 7edcf115..79917784 100644 --- a/src/basic/math_mov/mov_r_FAC1_TMP1.s +++ b/src/basic/math_mov/mov_r_FAC1_TMP1.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - store FAC1 (rounds) in TEMPF1 -// -// See also: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://sta.c64.org/cbm64basconv.html -// +; +; Math package - store FAC1 (rounds) in TEMPF1 +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; mov_r_FAC1_TMP1: diff --git a/src/basic/math_mov/mov_r_FAC1_TMP2.s b/src/basic/math_mov/mov_r_FAC1_TMP2.s index 3897d02a..0b94bbee 100644 --- a/src/basic/math_mov/mov_r_FAC1_TMP2.s +++ b/src/basic/math_mov/mov_r_FAC1_TMP2.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Math package - store FAC1 (rounds) in TEMPF2 -// -// See also: -// - https://www.c64-wiki.com/wiki/BASIC-ROM -// - https://sta.c64.org/cbm64basconv.html -// +; +; Math package - store FAC1 (rounds) in TEMPF2 +; +; See also: +; - https://www.c64-wiki.com/wiki/BASIC-ROM +; - https://sta.c64.org/cbm64basconv.html +; mov_r_FAC1_TMP2: diff --git a/src/basic/memory/fetch_character.s b/src/basic/memory/fetch_character.s index 231cd086..90ebf514 100644 --- a/src/basic/memory/fetch_character.s +++ b/src/basic/memory/fetch_character.s @@ -1,56 +1,55 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Fetches a single character -// +; +; Fetches a single character +; +!set NEEDED = 0 +; For these configurations we have optimized version in another file +!ifndef CONFIG_MB_M65 { !set NEEDED = 1 } +!ifndef CONFIG_MEMORY_MODEL_46K_OR_50K { !set NEEDED = 1 } -// For these configurations we have optimized version in another file -#if !(ROM_LAYOUT_M65 && (CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K)) +!if NEEDED { fetch_character: ldy #0 -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx # memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized php -!: +@1: lda (memmove__src),y sta (memmove__dst),y iny - bne !- + bne @1 inc memmove__src+1 inc memmove__dst+1 dec memmove__size+1 - bne !- + bne @1 plp rts -#else +} else { jmp shift_mem_down_internal - -#endif +} diff --git a/src/basic/memory/shift_mem_up.s b/src/basic/memory/shift_mem_up.s index 7af21766..4a230d1c 100644 --- a/src/basic/memory/shift_mem_up.s +++ b/src/basic/memory/shift_mem_up.s @@ -1,56 +1,55 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Copies the memory up -// -// Input: -// - memmove__src - pointer to the last byte of source -// - memmove__dst - pointer to the last byte of destination -// - memmove__size - number of bytes to copy -// -// All the input variables, .A, and .Y register, are destroyed. Also uses memmove__tmp variable. -// +; +; Copies the memory up +; +; Input: +; - memmove__src - pointer to the last byte of source +; - memmove__dst - pointer to the last byte of destination +; - memmove__size - number of bytes to copy +; +; All the input variables, .A, and .Y register, are destroyed. Also uses memmove__tmp variable. +; shift_mem_up: - // The copy routine is simplified, so that it is fast and (for memory model 60K) - // can fit in a small RAM area - therefore it requires to pre-set .Y, so that - // the copy ends when it reaches 0; so if copying one byte we want .Y = $01 + ; The copy routine is simplified, so that it is fast and (for memory model 60K) + ; can fit in a small RAM area - therefore it requires to pre-set .Y, so that + ; the copy ends when it reaches 0; so if copying one byte we want .Y = $01 ldy memmove__size+0 - // Now we have to move down the memmove_src and memmove_dst pointers to compensate for .Y not being 0 + ; Now we have to move down the memmove_src and memmove_dst pointers to compensate for .Y not being 0 jsr shift_mem_adapt_pointers -#if CONFIG_MEMORY_MODEL_38K +!ifdef CONFIG_MEMORY_MODEL_38K { shift_mem_up_internal: - // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized php -!: +@1: lda (memmove__src),y sta (memmove__dst),y dey - bne !- + bne @1 dec memmove__src+1 dec memmove__dst+1 dec memmove__size+1 - bne !- + bne @1 plp rts -#else +} else { jmp shift_mem_up_internal - -#endif +} diff --git a/src/basic/memory/under_rom_60k.s b/src/basic/memory/under_rom_60k.s index a3b72346..5afdfc70 100644 --- a/src/basic/memory/under_rom_60k.s +++ b/src/basic/memory/under_rom_60k.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { -// IMPORTANT: -// These routines lengths cannot be changed without changing -// the aliases for peek_under_roms, poke_under_roms, etc. -// Thus those addresses are expressed using formulae. +; IMPORTANT: +; These routines lengths cannot be changed without changing +; the aliases for peek_under_roms, poke_under_roms, etc. +; Thus those addresses are expressed using formulae. install_ram_routines: - // Copy routines into place + ; Copy routines into place ldx #__ram_routines_end-__ram_routines_start-1 -!: +@1: lda __ram_routines_start,x sta tiny_nmi_handler,x dex - bpl !- + bpl @1 - // Point NMI handler to tiny_nmi_handler + ; Point NMI handler to tiny_nmi_handler lda #tiny_nmi_handler @@ -29,14 +29,14 @@ install_ram_routines: __ram_routines_start: - // XXX - Routine order must match that of the KERNAL version of the file. - // (since it has fewer routines) + ; XXX - Routine order must match that of the KERNAL version of the file. + ; (since it has fewer routines) tiny_nmi_handler_routine: inc missed_nmi_flag rti peek_under_roms_routine: php - // Offset of arg of lda ($00),y + ; Offset of arg of lda ($00),y stx peek_under_roms+pa-peek_under_roms_routine+1 jsr memmap_allram pa: lda ($00),y @@ -46,7 +46,7 @@ pa: lda ($00),y poke_under_roms_routine: php - // Offset of arg of lda ($00),y + ; Offset of arg of lda ($00),y stx poke_under_roms+pb-poke_under_roms_routine+1 jsr memmap_allram pb: sta ($00),y @@ -71,46 +71,46 @@ memmap_allram_routine: shift_mem_up_routine: - // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized php jsr memmap_allram -!: +@2: lda (memmove__src),y sta (memmove__dst),y dey - bne !- + bne @2 dec memmove__src+1 dec memmove__dst+1 dec memmove__size+1 - bne !- + bne @2 plp jmp memmap_normal shift_mem_down_routine: - // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized php jsr memmap_allram -!: +@3: lda (memmove__src),y sta (memmove__dst),y iny - bne !- + bne @3 inc memmove__src+1 inc memmove__dst+1 dec memmove__size+1 - bne !- + bne @3 plp jmp memmap_normal __ram_routines_end: -#endif +} diff --git a/src/basic/memory/under_rom_peek_fetch_46k_50k.s b/src/basic/memory/under_rom_peek_fetch_46k_50k.s index f4b652aa..edc90a9f 100644 --- a/src/basic/memory/under_rom_peek_fetch_46k_50k.s +++ b/src/basic/memory/under_rom_peek_fetch_46k_50k.s @@ -1,121 +1,116 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - as the routines below bank out the main BASIC ROM! +; This has to go $E000 or above - as the routines below bank out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { peek_under_roms_via_TXTPTR: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs + ; Retrieve value from under ROMs lda (TXTPTR), y - // FALLTROUGH + ; FALLTROUGH remap_BASIC_preserve_A: - // Restore memory mapping + ; Restore memory mapping pha lda #$27 sta CPU_R6510 pla - // Quit + ; Quit rts peek_under_roms_via_OLDTXT: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs + ; Retrieve value from under ROMs lda (OLDTXT), y - jmp_8 remap_BASIC_preserve_A + +bra remap_BASIC_preserve_A peek_under_roms_via_VARPNT: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs + ; Retrieve value from under ROMs lda (VARPNT), y - jmp_8 remap_BASIC_preserve_A + +bra remap_BASIC_preserve_A peek_under_roms_via_FAC1_PLUS_1: - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs + ; Retrieve value from under ROMs lda (__FAC1+1), y - jmp_8 remap_BASIC_preserve_A - -#if ROM_LAYOUT_M65 + +bra remap_BASIC_preserve_A +!ifdef CONFIG_MB_M65 { fetch_character: ldy #0 - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs, advance text pointer + ; Retrieve value from under ROMs, advance text pointer lda (TXTPTR), y inw TXTPTR - // Restore memory mapping + ; Restore memory mapping - jmp_8 remap_BASIC_preserve_A + +bra remap_BASIC_preserve_A fetch_character_skip_spaces: ldy #0 - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM lda #$26 sta CPU_R6510 - // Retrieve value from under ROMs, advance text pointer -!: + ; Retrieve value from under ROMs, advance text pointer +@1: lda (TXTPTR), y inw TXTPTR - // Skip space characters + ; Skip space characters cmp #$20 - beq !- + beq @1 - // Restore memory mapping + ; Restore memory mapping - jmp_8 remap_BASIC_preserve_A - - -#endif - -#endif + +bra remap_BASIC_preserve_A +} } diff --git a/src/basic/memory/under_rom_shift_46k_50k.s b/src/basic/memory/under_rom_shift_46k_50k.s index cd023d33..9e178c61 100644 --- a/src/basic/memory/under_rom_shift_46k_50k.s +++ b/src/basic/memory/under_rom_shift_46k_50k.s @@ -1,71 +1,71 @@ -// #LAYOUT# STD * #TAKE-HIGH -// #LAYOUT# * BASIC_0 #TAKE-HIGH -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE-HIGH +;; #LAYOUT# * BASIC_0 #TAKE-HIGH +;; #LAYOUT# * * #IGNORE -// This has to go $E000 or above - as the routines below bank out the main BASIC ROM! +; This has to go $E000 or above - as the routines below bank out the main BASIC ROM! -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +!ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { shift_mem_up_internal: - // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM php lda #$26 sta CPU_R6510 - // Perform the copying -!: + ; Perform the copying +@1: lda (memmove__src),y sta (memmove__dst),y dey - bne !- + bne @1 dec memmove__src+1 dec memmove__dst+1 dec memmove__size+1 - bne !- + bne @1 - jmp_8 shift_mem_internal_finalize + +bra shift_mem_internal_finalize shift_mem_down_internal: - // Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src - // - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized + ; Move memmove__size bytes from memmove__src to memmove__dst, where memmove__dst > memmove__src + ; + ; This means we have to copy from the back end down. + ; This routine assumes the pointers are already pointed to the end of the areas, and that .Y is correctly initialized - // Unmap BASIC lower ROM + ; Unmap BASIC lower ROM php lda #$26 sta CPU_R6510 - // Perform the copying -!: + ; Perform the copying +@2: lda (memmove__src),y sta (memmove__dst),y iny - bne !- + bne @2 inc memmove__src+1 inc memmove__dst+1 dec memmove__size+1 - bne !- + bne @2 - // FALLTROUGH + ; FALLTROUGH shift_mem_internal_finalize: - // Restore memory mapping and quit + ; Restore memory mapping and quit lda #$27 sta CPU_R6510 @@ -73,6 +73,4 @@ shift_mem_internal_finalize: plp rts - - -#endif +} diff --git a/src/basic/print/list_single_line.s b/src/basic/print/list_single_line.s index 6a0eab20..797b58ea 100644 --- a/src/basic/print/list_single_line.s +++ b/src/basic/print/list_single_line.s @@ -1,52 +1,53 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + list_single_line: -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { - jsr map_BASIC_1 - jsr_ind VB1__list_single_line - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__list_single_line) + jmp map_NORMAL -#else +} else { - // Print line number - in a new line + ; Print line number - in a new line jsr print_return ldy #3 -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr peek_via_OLDTXT -#elif CONFIG_MEMORY_MODEL_60K +} else ifdef CONFIG_MEMORY_MODEL_60K { jsr peek_under_roms -#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { jsr peek_under_roms_via_OLDTXT -#else // CONFIG_MEMORY_MODEL_38K +} else { ; CONFIG_MEMORY_MODEL_38K lda (OLDTXT),y -#endif +} pha dey -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr peek_via_OLDTXT -#elif CONFIG_MEMORY_MODEL_60K +} else ifdef CONFIG_MEMORY_MODEL_60K { jsr peek_under_roms -#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { jsr peek_under_roms_via_OLDTXT -#else // CONFIG_MEMORY_MODEL_38K +} else { ; CONFIG_MEMORY_MODEL_38K lda (OLDTXT),y -#endif +} tax pla jsr print_integer jsr print_space - // Iterate through printing out the line - // contents + ; Iterate through printing out the line + ; contents lda #0 sta QTSW @@ -54,22 +55,22 @@ list_single_line: list_print_loop: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr peek_via_OLDTXT -#elif CONFIG_MEMORY_MODEL_60K +} else ifdef CONFIG_MEMORY_MODEL_60K { ldx #str_rev_question jsr STROUT - ply_trash_a + +ply_trash_a - jmp_8 !+ + +bra list_is_literal_known_cont list_is_literal_known: pla jsr JCHROUT -!: + + ; FALLTROUGH + +list_is_literal_known_cont: + iny - bne_16 list_print_loop + +bne list_print_loop - rts // end of line + rts ; end of line list_display_unknown_token: pla pla - jmp_8 list_is_unknown + +bra list_is_unknown list_display_token_01: - // Display a 2-byte token - for extended BASIC + ; Display a 2-byte token - for extended BASIC jsr list_fetch_subtoken - // Check if token is known + ; Check if token is known cpx #TK__MAXTOKEN_keywords_01 bcs list_is_unknown - // Now ask for it to be printed - phy_trash_a + ; Now ask for it to be printed + +phy_trash_a jsr print_packed_keyword_01 - // FALLTROUGH + ; FALLTROUGH list_display_token_ext_done: - ply_trash_a + +ply_trash_a - // Next iteration - jmp_8 list_not_rem + ; Next iteration + +bra list_not_rem -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { list_display_token_02: - // Display a 2-byte token - for extended BASIC + ; Display a 2-byte token - for extended BASIC jsr list_fetch_subtoken - // Check if token is known + ; Check if token is known cpx #TK__MAXTOKEN_keywords_02 bcs list_is_unknown - // Now ask for it to be printed - phy_trash_a + ; Now ask for it to be printed + +phy_trash_a jsr print_packed_keyword_02 - jmp_8 list_display_token_ext_done + +bra list_display_token_ext_done +} -#endif - -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { list_display_token_03: - // Display a 2-byte token - for extended BASIC + ; Display a 2-byte token - for extended BASIC jsr list_fetch_subtoken - // Check if token is known + ; Check if token is known cpx #TK__MAXTOKEN_keywords_03 bcs list_is_unknown - // Now ask for it to be printed - phy_trash_a + ; Now ask for it to be printed + +phy_trash_a jsr print_packed_keyword_03 - jmp_8 list_display_token_ext_done - -#endif + +bra list_display_token_ext_done +} list_fetch_subtoken: - // Fetch the sub-token + ; Fetch the sub-token iny -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr peek_via_OLDTXT -#elif CONFIG_MEMORY_MODEL_60K +} else ifdef CONFIG_MEMORY_MODEL_60K { ldx #1 - .byte >10 - .byte >100 - .byte >1000 - .byte >10000 + !byte >1 + !byte >10 + !byte >100 + !byte >1000 + !byte >10000 diff --git a/src/basic/print/print_integer_tab_lo.s b/src/basic/print/print_integer_tab_lo.s index 47fef0ec..32f88836 100644 --- a/src/basic/print/print_integer_tab_lo.s +++ b/src/basic/print/print_integer_tab_lo.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper power of 10s table (low buytes) for 'print_integer' -// +; +; Helper power of 10s table (low buytes) for 'print_integer' +; print_integer_tab_lo: - .byte <1 - .byte <10 - .byte <100 - .byte <1000 - .byte <10000 + !byte <1 + !byte <10 + !byte <100 + !byte <1000 + !byte <10000 diff --git a/src/basic/print/print_packed_dict_string.s b/src/basic/print/print_packed_dict_string.s index 4683b730..a0bb463e 100644 --- a/src/basic/print/print_packed_dict_string.s +++ b/src/basic/print/print_packed_dict_string.s @@ -1,43 +1,43 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_COMPRESSION_LVL_2 +!ifdef CONFIG_COMPRESSION_LVL_2 { -print_packed_error: // .X - error string index +print_packed_error: ; .X - error string index lda #packed_dict_errors - bne print_dict_packed_string // branch always + bne print_dict_packed_string ; branch always -print_packed_misc_str: // .X - misc string index +print_packed_misc_str: ; .X - misc string index lda #packed_dict_misc - // FALLTROUGH + ; FALLTROUGH print_dict_packed_string: - // Search for the packed string on the list + ; Search for the packed string on the list jsr print_packed_search ldy #$00 -!: - // At this point FRESPC contains a pointer to the string to display - // Fetch a byte-code +@1: + ; At this point FRESPC contains a pointer to the string to display + ; Fetch a byte-code lda (FRESPC), y - beq print_dict_packed_string_end // branch if everything displayed + beq print_dict_packed_string_end ; branch if everything displayed tax dex - // Call 'print_freq_packed_string' - but preserve all the data needed to progress further + ; Call 'print_freq_packed_string' - but preserve all the data needed to progress further - phy_trash_a + +phy_trash_a lda FRESPC+0 pha lda FRESPC+1 @@ -52,16 +52,14 @@ print_dict_packed_string: sta FRESPC+1 pla sta FRESPC+0 - ply_trash_a + +ply_trash_a - // Next iteration + ; Next iteration iny - bne !- // branch always + bne @1 ; branch always print_dict_packed_string_end: rts - - -#endif +} diff --git a/src/basic/print/print_packed_freq_string.s b/src/basic/print/print_packed_freq_string.s index 100da364..8450317e 100644 --- a/src/basic/print/print_packed_freq_string.s +++ b/src/basic/print/print_packed_freq_string.s @@ -1,125 +1,122 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// This routine prints strings that have been packed using the 'generate_trings' tool. -// The general idea is to save space in the ROM. +; This routine prints strings that have been packed using the 'generate_trings' tool. +; The general idea is to save space in the ROM. -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { print_packed_error: - jsr map_BASIC_1 - jsr_ind VB1__print_packed_error - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__print_packed_error) + jmp map_NORMAL print_packed_misc_str: - jsr map_BASIC_1 - jsr_ind VB1__print_packed_misc_str - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__print_packed_misc_str) + jmp map_NORMAL -#else +} else { -#if !CONFIG_COMPRESSION_LVL_2 +!ifndef CONFIG_COMPRESSION_LVL_2 { -print_packed_error: // .X - error string index +print_packed_error: ; .X - error string index lda #packed_freq_errors - bne print_freq_packed_string // branch always + bne print_freq_packed_string ; branch always -print_packed_misc_str: // .X - misc string index +print_packed_misc_str: ; .X - misc string index lda #packed_freq_misc - bne print_freq_packed_string // branch always + bne print_freq_packed_string ; branch always +} -#endif - -print_packed_keyword_01: // .X - token number +print_packed_keyword_01: ; .X - token number lda #packed_freq_keywords_01 - bne print_freq_packed_string // branch always + bne print_freq_packed_string ; branch always -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { -print_packed_keyword_02: // .X - token number +print_packed_keyword_02: ; .X - token number lda #packed_freq_keywords_02 - bne print_freq_packed_string // branch always + bne print_freq_packed_string ; branch always +} -#endif +!ifdef CONFIG_MB_M65 { -#if ROM_LAYOUT_M65 - -print_packed_keyword_03: // .X - token number +print_packed_keyword_03: ; .X - token number lda #packed_freq_keywords_03 - bne print_freq_packed_string // branch always + bne print_freq_packed_string ; branch always +} -#endif - -print_packed_keyword_V2: // .X - token number +print_packed_keyword_V2: ; .X - token number lda #packed_freq_keywords_V2 - // FALLTROUGH + ; FALLTROUGH -print_freq_packed_string: // not to be used directly XXX rename to print_packed_string +print_freq_packed_string: ; not to be used directly XXX rename to print_packed_string - // Search for the packed string on the list + ; Search for the packed string on the list jsr print_packed_search - // At this point FRESPC contains a pointer to the string to display - // and we should start from the lower nibble + ; At this point FRESPC contains a pointer to the string to display + ; and we should start from the lower nibble ldy #$00 - // FALLTROUGH + ; FALLTROUGH print_freq_packed_string_nibble_lo: - // Get the low nibble and check for the end of packed string + ; Get the low nibble and check for the end of packed string lda (FRESPC), y and #$0F beq print_freq_packed_string_end - // Not the end - check if this is a common character, encoded by a single nibble + ; Not the end - check if this is a common character, encoded by a single nibble cmp #$0F beq print_freq_packed_string_3n_split - // Character is encoded by a single nibble - fetch it and display + ; Character is encoded by a single nibble - fetch it and display tax lda packed_as_1n-1, x - jsr JCHROUT // preserves .Y + jsr JCHROUT ; preserves .Y - // FALLTROUGH + ; FALLTROUGH print_freq_packed_string_nibble_hi: - // Get the high nibble and check for the end of packed string + ; Get the high nibble and check for the end of packed string lda (FRESPC), y and #$F0 beq print_freq_packed_string_end - // Not the end - check if this is a common character, encoded by a single nibble + ; Not the end - check if this is a common character, encoded by a single nibble cmp #$F0 beq print_freq_packed_string_3n_single - // Character is encoded by a single nibble - fetch it and display + ; Character is encoded by a single nibble - fetch it and display lsr lsr @@ -128,28 +125,32 @@ print_freq_packed_string_nibble_hi: tax lda packed_as_1n-1, x - jmp_8 !+ + +bra print_freq_packed_string_3n_single_cont print_freq_packed_string_3n_single: - // Character is encoded using 3 nibbles (1st is a mark, already interpreted) + ; Character is encoded using 3 nibbles (1st is a mark, already interpreted) iny lda (FRESPC), y tax lda packed_as_3n-1, x -!: - jsr JCHROUT // preserves .Y - // Advance to next nibble + ; FALLTROUGH + +print_freq_packed_string_3n_single_cont: + + jsr JCHROUT ; preserves .Y + + ; Advance to next nibble iny - bne print_freq_packed_string_nibble_lo // branch always + bne print_freq_packed_string_nibble_lo ; branch always print_freq_packed_string_3n_split: - // Character is encoded using 3 nibbles (1st is a mark, already interpreted), - // but the 2 remaining nibbles are in two neighbour bytes; use a stack to combine them + ; Character is encoded using 3 nibbles (1st is a mark, already interpreted), + ; but the 2 remaining nibbles are in two neighbour bytes; use a stack to combine them lda (FRESPC), y and #$F0 @@ -163,11 +164,11 @@ print_freq_packed_string_3n_split: clc adc STACK, x - txs // one cycle faster than PLA + txs ; one cycle faster than PLA tax lda packed_as_3n-1, x - jsr JCHROUT // preserves .Y + jsr JCHROUT ; preserves .Y jmp print_freq_packed_string_nibble_hi @@ -176,4 +177,4 @@ print_freq_packed_string_end: rts -#endif // ROM layout +} ; ROM layout diff --git a/src/basic/print/print_packed_search.s b/src/basic/print/print_packed_search.s index f536eb2e..8012727c 100644 --- a/src/basic/print/print_packed_search.s +++ b/src/basic/print/print_packed_search.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE print_packed_search: - // First store the initial address of the packed strings list + ; First store the initial address of the packed strings list sta FRESPC+0 sty FRESPC+1 - // Now find the address of the string to print out - // The implementation assumes no packed string is longer than 255 bytes, including trailing zero -!: + ; Now find the address of the string to print out + ; The implementation assumes no packed string is longer than 255 bytes, including trailing zero +@1: cpx #$00 - beq print_packed_done // branch if no need to advance anymore + beq print_packed_done ; branch if no need to advance anymore dex ldy #$00 -!: +@2: lda (FRESPC), y iny cmp #$00 - bne !- // branch if not the end of packed string + bne @2 ; branch if not the end of packed string - clc // advance FREESPC pointer + clc ; advance FREESPC pointer tya adc FRESPC+0 sta FRESPC+0 @@ -33,7 +33,7 @@ print_packed_search: adc FRESPC+1 sta FRESPC+1 - jmp !-- + +bra @1 print_packed_done: diff --git a/src/basic/rom_revision/a004.identifier.s b/src/basic/rom_revision/a004.identifier.s index c8c4e527..a07354d5 100644 --- a/src/basic/rom_revision/a004.identifier.s +++ b/src/basic/rom_revision/a004.identifier.s @@ -1,23 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Computes Mapping the 64, p89 - 8 character name +; Computes Mapping the 64, p89 - 8 character name -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { - // 'M65BASIC' + ; 'M65BASIC' - .byte $4D, $36, $35 // 'M65' + !byte $4D, $36, $35 ; 'M65' -#else +} else { - // 'ORGBASIC', Open ROMs Generic BASIC + ; 'ORGBASIC', Open ROMs Generic BASIC - .byte $4F, $52, $47 // 'ORG' + !byte $4F, $52, $47 ; 'ORG' +} -#endif - - .byte $42, $41, $53, $49, $43 // 'BASIC' + !byte $42, $41, $53, $49, $43 ; 'BASIC' diff --git a/src/basic/rom_revision/bf52.rom_revision_basic.s b/src/basic/rom_revision/bf52.rom_revision_basic.s index c3920eea..bb73cb60 100644 --- a/src/basic/rom_revision/bf52.rom_revision_basic.s +++ b/src/basic/rom_revision/bf52.rom_revision_basic.s @@ -1,36 +1,34 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// !!! PROPOSAL ONLY !!! PROPOSAL ONLY !!! NOT FOR USING EXTERNALLY YET !!! -// -// -// Do not change! Locations of the following data should be constant - now and forever! -// -// If you want to integrate Open ROMs support in your emulator, FPGA ccomputer, etc. - this -// is the official way to recognize the ROM and its revision. -// +; +; Do not change - unless there is a really important reason! +; Ideally, locations of the following data should be constant - now and forever! +; +; If you want to integrate Open ROMs support in your emulator, FPGA computer, etc. - this +; is the official way to recognize the ROM and its revision. +; rom_revision_basic: - // $BF52 + ; $BF52 - .text "OR" // project signature, after "Open ROMs" - .byte CONFIG_ID // config file ID, might change between revisions + !pet "or" ; project signature, "OR" stands for "Open ROMs" + !byte CONFIG_ID ; config file ID - this may change between revisions, without any warning rom_revision_basic_string: - // $BF55 + ; $BF55 -#if !CONFIG_BRAND_CUSTOM_BUILD - .text "(DEVEL SNAPSHOT)" // actual ROM revision string; up to 16 characters -#else - .text "(CUSTOM BUILD)" -#endif +!ifndef CONFIG_BRAND_CUSTOM_BUILD { + !pet "(devel snapshot)" ; ROM revision string; up to 16 characters, string format will change in the future +} else { + !pet "(custom build)" +} - .byte $00 // marks the end of string + !byte $00 ; marks the end of string __rom_revision_basic_end: diff --git a/src/basic/rom_revision/e4b7.rom_revision_kernal.s b/src/basic/rom_revision/e4b7.rom_revision_kernal.s index e9254347..9388caaf 100644 --- a/src/basic/rom_revision/e4b7.rom_revision_kernal.s +++ b/src/basic/rom_revision/e4b7.rom_revision_kernal.s @@ -1,49 +1,47 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// !!! PROPOSAL ONLY !!! PROPOSAL ONLY !!! NOT FOR USING EXTERNALLY YET !!! -// -// -// Do not change! Locations of the following data should be constant - now and forever! -// -// If you want to integrate Open ROMs support in your emulator, FPGA ccomputer, etc. - this -// is the official way to recognize the ROM and its revision. -// +; +; Do not change - unless there is a really important reason! +; Ideally, locations of the following data should be constant - now and forever! +; +; If you want to integrate Open ROMs support in your emulator, FPGA computer, etc. - this +; is the official way to recognize the ROM and its revision. +; - // $E4B7 + ; $E4B7 - // This vector is to be used by non-Kernal ROMs, if they want to - // complain about incompatible ROM releases - do not use it directly, - // use a 'panic' pseudocommand with error code (will be passed using .A) - // #P_ERR_ROM_MISMATCH - it should remain stable even between releases + ; This vector is to be used by non-Kernal ROMs, if they want to + ; complain about incompatible ROM releases - do not use it directly, + ; use a 'panic' pseudocommand with error code (will be passed using .A) + ; #P_ERR_ROM_MISMATCH - it should remain stable even between releases -#if CONFIG_PANIC_SCREEN - .word panic -#else - .word hw_entry_reset -#endif +!ifdef CONFIG_PANIC_SCREEN { + !word panic +} else { + !word hw_entry_reset +} rom_revision_kernal: - // $E4B9 + ; $E4B9 - .text "OR" // project signature, after "Open ROMs" - .byte CONFIG_ID // config file ID, might change between revisions + !pet "or" ; project signature, "OR" stands for "Open ROMs" + !byte CONFIG_ID ; config file ID - this may change between revisions, without any warning rom_revision_kernal_string: - // $E4BC + ; $E4BC -#if !CONFIG_BRAND_CUSTOM_BUILD - .text "(DEVEL SNAPSHOT)" // actual ROM revision string; up to 16 characters -#else - .text "(CUSTOM BUILD)" -#endif +!ifndef CONFIG_BRAND_CUSTOM_BUILD { + !pet "(devel snapshot)" ; ROM revision string; up to 16 characters, string format will change in the future +} else { + !pet "(custom build)" +} - .byte $00 // marks the end of string + !byte $00 ; marks the end of string __rom_revision_kernal_end: diff --git a/src/basic/wedge/wedge_dos.s b/src/basic/wedge/wedge_dos.s index 8ca489e0..eaa80fa4 100644 --- a/src/basic/wedge/wedge_dos.s +++ b/src/basic/wedge/wedge_dos.s @@ -1,92 +1,92 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 BASIC_1 #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 BASIC_1 #TAKE +;; #LAYOUT# * BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE -#if CONFIG_DOS_WEDGE +!ifdef CONFIG_DOS_WEDGE { -// .X has to contain size of the buffer +; .X has to contain size of the buffer wedge_dos: -#if (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +!ifdef SEGMENT_M65_BASIC_0 { - jsr map_BASIC_1 - jsr_ind VB1__wedge_dos - jmp map_NORMAL + jsr map_BASIC_1 + jsr (VB1__wedge_dos) + jmp map_NORMAL -#else +} else { - // Prepare buffer - finish it with '0' + ; Prepare buffer - finish it with '0' lda #$00 sta BUF,x - // Close all the channels, so that wedge has full control + ; Close all the channels, so that wedge has full control jsr JCLALL - // Set file parameters, channel 15 is a typical one for commands - jsr SELDEV // sets .X register + ; Set file parameters, channel 15 is a typical one for commands + jsr SELDEV ; sets .X register lda #$0F ldy #$0F jsr JSETFLS - // Setup necessary part of BASIC + ; Setup necessary part of BASIC jsr prepare_direct_execution jsr fetch_character - // Now we have to check what the user wants us to do + ; Now we have to check what the user wants us to do - // Check if user asked for a status + ; Check if user asked for a status ldy #$00 lda (TXTPTR), y - beq_16 wedge_dos_status + +beq wedge_dos_status - // Check if asked for a directory + ; Check if asked for a directory cmp #$24 - beq_16 wedge_dos_directory + +beq wedge_dos_directory - // Check if asked to change drive number, or if it is a regular command + ; Check if asked to change drive number, or if it is a regular command jsr is_09 bcc wedge_dos_change_drive - // FALLTROUGH + ; FALLTROUGH wedge_dos_command: -#if !HAS_SMALL_BASIC +!ifndef HAS_SMALL_BASIC { - // Check if command needs confirmation + ; Check if command needs confirmation ldy #$00 lda (TXTPTR), y - cmp #$52 // 'R' - because 'RD' is a directory removal command - bne !+ + cmp #$52 ; 'R' - because 'RD' is a directory removal command + bne @1 iny lda (TXTPTR), y - cmp #$44 // 'D' + cmp #$44 ; 'D' bne wedge_dos_command_confirmed beq wedge_dos_command_ask -!: - cmp #$4E // 'N' - for the disk format - beq !+ - cmp #$53 // 'S' - for the file scratch +@1: + cmp #$4E ; 'N' - for the disk format + beq @2 + cmp #$53 ; 'S' - for the file scratch bne wedge_dos_command_confirmed -!: - // This is probably a dangerous command - check further the syntax, - // if 'N:', 'S:', 'Nx:' or 'Sx:' (where 'x' is a digit) - ask for confirmation first +@2: + ; This is probably a dangerous command - check further the syntax, + ; if 'N:', 'S:', 'Nx:' or 'Sx:' (where 'x' is a digit) - ask for confirmation first iny lda (TXTPTR), y - cmp #$3A // ':' - colon + cmp #$3A ; ':' - colon beq wedge_dos_command_ask jsr is_09 @@ -94,125 +94,125 @@ wedge_dos_command: iny lda (TXTPTR), y - cmp #$3A // ':' - colon + cmp #$3A ; ':' - colon bne wedge_dos_command_confirmed - // FALLTROUGH + ; FALLTROUGH wedge_dos_command_ask: jsr helper_ask_if_sure - bcs_16 wedge_dos_clean_exit + +bcs wedge_dos_clean_exit - // FALLTROUGH + ; FALLTROUGH wedge_dos_command_confirmed: -#endif // !HAS_SMALL_BASIC +} ; !HAS_SMALL_BASIC - // Provide command name + ; Provide command name jsr wedge_dos_setnam jsr JSETNAM jsr JOPEN - bcs_16 wedge_dos_basic_error + +bcs wedge_dos_basic_error - // Retrieve status, print it if not OK + ; Retrieve status, print it if not OK jsr JCLALL jsr wedge_dos_status_get_no_new_line lda BUF+0 - cmp #$30 // '0' + cmp #$30 ; '0' bne wedge_dos_status_print eor BUF+1 bne wedge_dos_status_print - // Clean-up and exit + ; Clean-up and exit jmp wedge_dos_clean_exit wedge_dos_change_drive: - // Fetch new drive number, make sure this is the last part of the command + ; Fetch new drive number, make sure this is the last part of the command jsr fetch_uint8 pha jsr fetch_character_skip_spaces cmp #$00 - bne_16 do_SYNTAX_error + +bne do_SYNTAX_error pla - // Check if device number is valid for IEC drive + ; Check if device number is valid for IEC drive cmp #$08 - bcc_16 do_ILLEGAL_DEVICE_NUMBER_error + +bcc do_ILLEGAL_DEVICE_NUMBER_error - // Store new device number and return to shell + ; Store new device number and return to shell sta FA jmp shell_main_loop wedge_dos_status_get: - // New line - separate status from current display + ; New line - separate status from current display jsr print_return - // FALLTROUGH + ; FALLTROUGH wedge_dos_status_get_no_new_line: - // Here the flow is mostly the same as in the example from - // https://codebase64.org/doku.php?id=base:reading_the_error_channel_of_a_disk_drive + ; Here the flow is mostly the same as in the example from + ; https://codebase64.org/doku.php?id=base:reading_the_error_channel_of_a_disk_drive - // Set remaining file parameters, open the channel + ; Set remaining file parameters, open the channel - lda #$00 // empty file name + lda #$00 ; empty file name jsr JSETNAM jsr JOPEN - bcs_16 wedge_dos_basic_error + +bcs wedge_dos_basic_error - // Set channel for input + ; Set channel for input ldx #$0F jsr JCHKIN - bcs_16 wedge_dos_basic_error + +bcs wedge_dos_basic_error - // Fetch the drive status + ; Fetch the drive status ldy #$00 - // FALLTROUGH + ; FALLTROUGH wedge_dos_status_get_loop: - // Check for buffer overflow + ; Check for buffer overflow cpy #$50 - beq_16 do_OVERFLOW_error + +beq do_OVERFLOW_error - // Check for EOF + ; Check for EOF jsr JREADST - // XXX check for transfer errors + ; XXX check for transfer errors bne wedge_dos_status_get_done - // Retrieve a byte and put it into the buffer + ; Retrieve a byte and put it into the buffer jsr JCHRIN - bcs_16 wedge_dos_basic_error + +bcs wedge_dos_basic_error sta BUF, y iny - bne wedge_dos_status_get_loop // branch always + bne wedge_dos_status_get_loop ; branch always wedge_dos_status_get_done: - // Strip ending RETURN + ; Strip ending RETURN dey rts @@ -220,45 +220,45 @@ wedge_dos_status_get_done: wedge_dos_status: jsr wedge_dos_status_get - jmp_8 wedge_dos_status_print_no_new_line + +bra wedge_dos_status_print_no_new_line wedge_dos_status_print: jsr print_return - // FALLTROUGH + ; FALLTROUGH wedge_dos_status_print_no_new_line: - // Print buffered status + ; Print buffered status ldx #$00 -!: +@3: dey - bmi !+ + bmi @4 lda BUF, x jsr JCHROUT inx - bne !- -!: - // Clean-up and exit + bne @3 +@4: + ; Clean-up and exit - jmp_8 wedge_dos_clean_exit + +bra wedge_dos_clean_exit wedge_dos_directory: - // First change the secondary address to the one suitable for directory loading + ; First change the secondary address to the one suitable for directory loading - lda #$00 // logical device number + lda #$00 ; logical device number ldx FA ldy #$60 jsr JSETFLS - // Provide file name + ; Provide file name jsr wedge_dos_setnam - // Open the file, set channel for reading + ; Open the file, set channel for reading jsr JOPEN bcs wedge_dos_basic_error @@ -267,52 +267,52 @@ wedge_dos_directory: jsr JCHKIN bcs wedge_dos_basic_error - // Ignore start address (2 first bytes) - XXX check for errors + ; Ignore start address (2 first bytes) - XXX check for errors jsr JCHRIN bcs wedge_dos_basic_error jsr JCHRIN bcs wedge_dos_basic_error - // FALLTROUGH + ; FALLTROUGH wedge_dos_directory_line: - // Load a single line, reuse BASIC input buffer + ; Load a single line, reuse BASIC input buffer ldy #$FF -!: +@5: iny jsr JCHRIN bcs wedge_dos_basic_error sta BUF, y cpy #$50 - beq_16 do_OVERFLOW_error // branch if line too long + +beq do_OVERFLOW_error ; branch if line too long jsr JREADST - bne !+ // end of file - cpy #$04 // 2 bytes (pointer to next line) + 2 bytes (line number) - bcc !- + bne @6 ; end of file + cpy #$04 ; 2 bytes (pointer to next line) + 2 bytes (line number) + bcc @5 lda BUF, y - bne !- + bne @5 - // End of line, but not end of file + ; End of line, but not end of file beq wedge_dos_directory_display -!: +@6: lda #K_STS_END_OF_FILE - sta IOSTATUS // make sure end of file is marked + sta IOSTATUS ; make sure end of file is marked - // FALLTROUGH + ; FALLTROUGH wedge_dos_directory_display: - cpy #$05 // protection against malformed directory + cpy #$05 ; protection against malformed directory bcc wedge_dos_clean_exit - lda #$00 // extra protection agains buffer overflow + lda #$00 ; extra protection agains buffer overflow sta BUF, y - // Display line + ; Display line ldx #16380 +; +; Values for IRQ generation timer - original idea was: +; +; (This value was calculated by running a custom IRQ handler on a C64 +; with original KERNAL, and writing the values of $DC04/5 to the screen +; in the IRQ handler to see roughly what value the timers must be set to) +; ldy #<16380 +; ldx #>16380 -// Current values selected on the following assumptions: -// -// PAL C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), -// is clocked at 0.985248 MHz, so that 1/60s is 16421 ($4025) CPU cycles -// -// NTSC C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), -// is clocked at 1.022727 MHz, so that 1/60s is 17045 ($4295) CPU cycles +; Current values selected on the following assumptions: +; +; PAL C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), +; is clocked at 0.985248 MHz, so that 1/60s is 16421 ($4025) CPU cycles +; +; NTSC C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), +; is clocked at 1.022727 MHz, so that 1/60s is 17045 ($4295) CPU cycles -irq_timing_hi: // high bytes +irq_timing_hi: ; high bytes -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { - .byte >17045 // NTSC - .byte >16421 // PAL + !byte >17045 ; NTSC + !byte >16421 ; PAL -#else +} else { -// -// Timer values needed by UP9600 -// -// Original driver code by Daniel Dallman with Bo Zimmerman adaptations, -// these causes the tick to be generated 64 times per second -// +; +; Timer values needed by UP9600 +; +; Original driver code by Daniel Dallman with Bo Zimmerman adaptations, +; these causes the tick to be generated 64 times per second +; - .byte $42 // NTSC - .byte $40 // PAL - -#endif \ No newline at end of file + !byte $42 ; NTSC + !byte $40 ; PAL +} diff --git a/src/kernal/assets/irq_timing_lo.s b/src/kernal/assets/irq_timing_lo.s index 3760f444..c7663df6 100644 --- a/src/kernal/assets/irq_timing_lo.s +++ b/src/kernal/assets/irq_timing_lo.s @@ -1,42 +1,41 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Values for IRQ generation timer - original idea was: -// -// (This value was calculated by running a custom IRQ handler on a C64 -// with original KERNAL, and writing the values of $DC04/5 to the screen -// in the IRQ handler to see roughly what value the timers must be set to) -// ldy #<16380 -// ldx #>16380 +; +; Values for IRQ generation timer - original idea was: +; +; (This value was calculated by running a custom IRQ handler on a C64 +; with original KERNAL, and writing the values of $DC04/5 to the screen +; in the IRQ handler to see roughly what value the timers must be set to) +; ldy #<16380 +; ldx #>16380 -// Current values selected on the following assumptions: -// -// PAL C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), -// is clocked at 0.985248 MHz, so that 1/60s is 16421 ($4025) CPU cycles -// -// NTSC C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), -// is clocked at 1.022727 MHz, so that 1/60s is 17045 ($4295) CPU cycles +; Current values selected on the following assumptions: +; +; PAL C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), +; is clocked at 0.985248 MHz, so that 1/60s is 16421 ($4025) CPU cycles +; +; NTSC C64 (https://codebase64.org/doku.php?id=base:cpu_clocking), +; is clocked at 1.022727 MHz, so that 1/60s is 17045 ($4295) CPU cycles -irq_timing_lo: // low bytes +irq_timing_lo: ; low bytes -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { - .byte <17045 // NTSC - .byte <16421 // PAL + !byte <17045 ; NTSC + !byte <16421 ; PAL -#else +} else { -// -// Timer values needed by UP9600 -// -// Original driver code by Daniel Dallman with Bo Zimmerman adaptations, -// these causes the tick to be generated 64 times per second -// +; +; Timer values needed by UP9600 +; +; Original driver code by Daniel Dallman with Bo Zimmerman adaptations, +; these causes the tick to be generated 64 times per second +; - .byte $95 // NTSC - .byte $25 // PAL - -#endif \ No newline at end of file + !byte $95 ; NTSC + !byte $25 ; PAL +} diff --git a/src/kernal/assets/kernal_messages.s b/src/kernal/assets/kernal_messages.s index 16129aa8..5c816750 100644 --- a/src/kernal/assets/kernal_messages.s +++ b/src/kernal/assets/kernal_messages.s @@ -1,98 +1,91 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Messages to be prined out by Kernal -// - -.encoding "petscii_upper" +; +; Messages to be prined out by Kernal +; -// Double underscore prevents labels from being passed to VICE (would confuse monitor) +; Double underscore prevents labels from being passed to VICE (would confuse monitor) -.label __MSG_KERNAL_SEARCHING_FOR = __msg_kernalsearching_for - __msg_kernal_first -.label __MSG_KERNAL_LOADING = __msg_kernalloading - __msg_kernal_first -.label __MSG_KERNAL_VERIFYING = __msg_kernalverifying - __msg_kernal_first -.label __MSG_KERNAL_SAVING = __msg_kernalsaving - __msg_kernal_first -.label __MSG_KERNAL_FROM_HEX = __msg_kernalfrom_hex - __msg_kernal_first -.label __MSG_KERNAL_TO_HEX = __msg_kernalto_hex - __msg_kernal_first +!addr __MSG_KERNAL_SEARCHING_FOR = __msg_kernalsearching_for - __msg_kernal_first +!addr __MSG_KERNAL_LOADING = __msg_kernalloading - __msg_kernal_first +!addr __MSG_KERNAL_VERIFYING = __msg_kernalverifying - __msg_kernal_first +!addr __MSG_KERNAL_SAVING = __msg_kernalsaving - __msg_kernal_first +!addr __MSG_KERNAL_FROM_HEX = __msg_kernalfrom_hex - __msg_kernal_first +!addr __MSG_KERNAL_TO_HEX = __msg_kernalto_hex - __msg_kernal_first -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO -.label __MSG_KERNAL_PRESS_PLAY = __msg_kernalplay - __msg_kernal_first -.label __MSG_KERNAL_FOUND = __msg_kernalfound - __msg_kernal_first -#if CONFIG_MB_MEGA_65 -.label __MSG_KERNAL_OK_SEARCHING = __msg_kernaloksearching - __msg_kernal_first -#endif -#endif +!ifdef HAS_TAPE { +!addr __MSG_KERNAL_PRESS_PLAY = __msg_kernalplay - __msg_kernal_first +!addr __MSG_KERNAL_FOUND = __msg_kernalfound - __msg_kernal_first +!ifdef CONFIG_MB_M65 { +!addr __MSG_KERNAL_OK_SEARCHING = __msg_kernaloksearching - __msg_kernal_first +} } -#if CONFIG_PANIC_SCREEN -.label __MSG_KERNAL_PANIC = __msg_kernalpanic - __msg_kernal_first -.label __MSG_KERNAL_PANIC_ROM_MISMATCH = __msg_kernalpanic_rom_mismatch - __msg_kernal_first -#endif +!ifdef CONFIG_PANIC_SCREEN { +!addr __MSG_KERNAL_PANIC = __msg_kernalpanic - __msg_kernal_first +!addr __MSG_KERNAL_PANIC_ROM_MISMATCH = __msg_kernalpanic_rom_mismatch - __msg_kernal_first +} __msg_kernal_first: __msg_kernalsearching_for: - .byte $0D - .text "SEARCHING FOR" - .byte $80 + $20 // end of string mark + space + !byte $0D + !pet "searching for" + !byte $80 + $20 ; end of string mark + space __msg_kernalloading: - .byte $0D - .text "LOADIN" - .byte $80 + $47 // end of string mark + 'G' + !byte $0D + !pet "loadin" + !byte $80 + $47 ; end of string mark + 'G' __msg_kernalverifying: - .byte $0D - .text "VERIFYIN" - .byte $80 + $47 // end of string mark + 'G' + !byte $0D + !pet "verifyin" + !byte $80 + $47 ; end of string mark + 'G' __msg_kernalsaving: - .byte $0D - .text "SAVING" - .byte $80 + $20 // end of string mark + space + !byte $0D + !pet "saving" + !byte $80 + $20 ; end of string mark + space __msg_kernalfrom_hex: - .text " FROM " - .byte $80 + $24 // end of string mark + '$' + !pet " from " + !byte $80 + $24 ; end of string mark + '$' __msg_kernalto_hex: - .text " TO " - .byte $80 + $24 // end of string mark + '$' + !pet " to " + !byte $80 + $24 ; end of string mark + '$' -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { __msg_kernalplay: - .byte $0D - .text "PRESS PLAY ON TAPE" - .byte $80 + $0D // end of string mark + return + !byte $0D + !pet "press play on tape" + !byte $80 + $0D ; end of string mark + return __msg_kernalfound: - .text "FOUND" - .byte $80 + $20 // end of string mark + space + !pet "found" + !byte $80 + $20 ; end of string mark + space -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { __msg_kernaloksearching: - .text "OK" - .byte $0D, $0D - .text "SEARCHIN" - .byte $80 + $47 // end of string mark + 'G' + !pet "ok" + !byte $0D, $0D + !pet "searchin" + !byte $80 + $47 ; end of string mark + 'G' +} } -#endif - -#endif - -#if CONFIG_PANIC_SCREEN +!ifdef CONFIG_PANIC_SCREEN { __msg_kernalpanic: - .text "KERNAL PANI" - .byte $80 + $43 // end of string mark + 'C' + !pet "kernal pani" + !byte $80 + $43 ; end of string mark + 'C' __msg_kernalpanic_rom_mismatch: - .text " - ROM MISMATC" - .byte $80 + $48 // end of string mark + 'H' - -#endif // CONFIG_PANIC_SCREEN + !pet " - rom mismatc" + !byte $80 + $48 ; end of string mark + 'H' +} diff --git a/src/kernal/assets/programmable_keys.s b/src/kernal/assets/programmable_keys.s index 181914e0..4a0f88a4 100644 --- a/src/kernal/assets/programmable_keys.s +++ b/src/kernal/assets/programmable_keys.s @@ -1,128 +1,139 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Command string definitions for programmable keys -// +; +; Command string definitions for programmable keys +; -#if CONFIG_PROGRAMMABLE_KEYS - - -.macro PROGRAMMABLE_KEY_CODE(STR, CODE) -{ - .if (STR.size() > 0) - { - .byte CODE - } -} - -.macro PROGRAMMABLE_KEY_STRING(STR) -{ - .if (STR.size() > 0) - { - .text STR - .byte $00 - } -} - -.macro PROGRAMMABLE_KEY_OFFSET(STR, LABEL) -{ - .if (STR.size() > 0) - { - .byte LABEL - programmable_keys_strings - } -} +!ifdef CONFIG_PROGRAMMABLE_KEYS { programmable_keys_codes: - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_RUN, KEY_RUN) + !ifdef CONFIG_KEYCMD_RUN { !byte KEY_RUN } - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F1, KEY_F1) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F2, KEY_F2) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F3, KEY_F3) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F4, KEY_F4) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F5, KEY_F5) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F6, KEY_F6) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F7, KEY_F7) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F8, KEY_F8) + !ifdef CONFIG_KEYCMD_F1 { !byte KEY_F1 } + !ifdef CONFIG_KEYCMD_F2 { !byte KEY_F2 } + !ifdef CONFIG_KEYCMD_F3 { !byte KEY_F3 } + !ifdef CONFIG_KEYCMD_F4 { !byte KEY_F4 } + !ifdef CONFIG_KEYCMD_F5 { !byte KEY_F5 } + !ifdef CONFIG_KEYCMD_F6 { !byte KEY_F6 } + !ifdef CONFIG_KEYCMD_F7 { !byte KEY_F7 } + !ifdef CONFIG_KEYCMD_F8 { !byte KEY_F8 } -#if !CONFIG_LEGACY_SCNKEY && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_HELP, KEY_HELP) -#endif +!ifndef CONFIG_LEGACY_SCNKEY { + +!ifdef CONFIG_KEYBOARD_C128 { + + !ifdef CONFIG_KEYCMD_HELP { !byte KEY_HELP } + +} else ifdef CONFIG_KEYBOARD_C65 { + + !ifdef CONFIG_KEYCMD_HELP { !byte KEY_HELP } + + !ifdef CONFIG_KEYCMD_F9 { !byte KEY_F9 } + !ifdef CONFIG_KEYCMD_F10 { !byte KEY_F10 } + !ifdef CONFIG_KEYCMD_F11 { !byte KEY_F11 } + !ifdef CONFIG_KEYCMD_F12 { !byte KEY_F12 } + !ifdef CONFIG_KEYCMD_F13 { !byte KEY_F13 } + !ifdef CONFIG_KEYCMD_F14 { !byte KEY_F14 } + + +} } -#if !CONFIG_LEGACY_SCNKEY && CONFIG_KEYBOARD_C65 - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F9, KEY_F9) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F10, KEY_F10) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F11, KEY_F11) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F12, KEY_F12) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F13, KEY_F13) - PROGRAMMABLE_KEY_CODE(CONFIG_KEYCMD_F14, KEY_F14) -#endif __programmable_keys_codes_end: programmable_keys_strings: -__str_offset_RUN: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_RUN) +__str_offset_RUN: !ifdef CONFIG_KEYCMD_RUN { +CONFIG_KEYCMD_RUN + !byte $00 } -__str_offset_F1: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F1) -__str_offset_F2: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F2) -__str_offset_F3: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F3) -__str_offset_F4: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F4) -__str_offset_F5: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F5) -__str_offset_F6: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F6) -__str_offset_F7: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F7) -__str_offset_F8: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F8) +__str_offset_F1: !ifdef CONFIG_KEYCMD_F1 { +CONFIG_KEYCMD_F1 + !byte $00 } +__str_offset_F2: !ifdef CONFIG_KEYCMD_F2 { +CONFIG_KEYCMD_F2 + !byte $00 } +__str_offset_F3: !ifdef CONFIG_KEYCMD_F3 { +CONFIG_KEYCMD_F3 + !byte $00 } +__str_offset_F4: !ifdef CONFIG_KEYCMD_F4 { +CONFIG_KEYCMD_F4 + !byte $00 } +__str_offset_F5: !ifdef CONFIG_KEYCMD_F5 { +CONFIG_KEYCMD_F5 + !byte $00 } +__str_offset_F6: !ifdef CONFIG_KEYCMD_F6 { +CONFIG_KEYCMD_F6 + !byte $00 } +__str_offset_F7: !ifdef CONFIG_KEYCMD_F7 { +CONFIG_KEYCMD_F7 + !byte $00 } +__str_offset_F8: !ifdef CONFIG_KEYCMD_F8 { +CONFIG_KEYCMD_F8 + !byte $00 } -#if !CONFIG_LEGACY_SCNKEY && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65) -__str_offset_HELP: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_HELP) -#endif +!ifndef CONFIG_LEGACY_SCNKEY { + +!ifdef CONFIG_KEYBOARD_C128 { + +__str_offset_HELP: !ifdef CONFIG_KEYCMD_HELP { +CONFIG_KEYCMD_HELP + !byte $00 } + +} else ifdef CONFIG_KEYBOARD_C65 { + +__str_offset_HELP: !ifdef CONFIG_KEYCMD_HELP { +CONFIG_KEYCMD_HELP + !byte $00 } + +__str_offset_F9: !ifdef CONFIG_KEYCMD_F9 { +CONFIG_KEYCMD_F9 + !byte $00 } +__str_offset_F10: !ifdef CONFIG_KEYCMD_F10 { +CONFIG_KEYCMD_F10 + !byte $00 } +__str_offset_F11: !ifdef CONFIG_KEYCMD_F11 { +CONFIG_KEYCMD_F11 + !byte $00 } +__str_offset_F12: !ifdef CONFIG_KEYCMD_F12 { +CONFIG_KEYCMD_F12 + !byte $00 } +__str_offset_F13: !ifdef CONFIG_KEYCMD_F13 { +CONFIG_KEYCMD_F13 + !byte $00 } +__str_offset_F14: !ifdef CONFIG_KEYCMD_F14 { +CONFIG_KEYCMD_F14 + !byte $00 } + +} } -#if !CONFIG_LEGACY_SCNKEY && CONFIG_KEYBOARD_C65 -__str_offset_F9: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F9) -__str_offset_F10: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F10) -__str_offset_F11: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F11) -__str_offset_F12: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F12) -__str_offset_F13: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F13) -__str_offset_F14: PROGRAMMABLE_KEY_STRING(CONFIG_KEYCMD_F14) -#endif __programmable_keys_strings_end: -{ - .var offset = __programmable_keys_strings_end - programmable_keys_strings - .if (offset >= 255) .error "Programmable keys took too much space" -} + + !if (__programmable_keys_strings_end - programmable_keys_strings > 255) { + !error "Programmable keys took too much space" + } programmable_keys_offsets: - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_RUN, __str_offset_RUN) + !ifdef CONFIG_KEYCMD_RUN { !byte __str_offset_RUN - programmable_keys_strings } - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F1, __str_offset_F1) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F2, __str_offset_F2) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F3, __str_offset_F3) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F4, __str_offset_F4) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F5, __str_offset_F5) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F6, __str_offset_F6) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F7, __str_offset_F7) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F8, __str_offset_F8) + !ifdef CONFIG_KEYCMD_F1 { !byte __str_offset_F1 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F2 { !byte __str_offset_F2 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F3 { !byte __str_offset_F3 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F4 { !byte __str_offset_F4 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F5 { !byte __str_offset_F5 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F6 { !byte __str_offset_F6 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F7 { !byte __str_offset_F7 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F8 { !byte __str_offset_F8 - programmable_keys_strings } -#if !CONFIG_LEGACY_SCNKEY && (CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_HELP, __str_offset_HELP) -#endif +!ifndef CONFIG_LEGACY_SCNKEY { -#if !CONFIG_LEGACY_SCNKEY && CONFIG_KEYBOARD_C65 - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F9, __str_offset_F9) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F10, __str_offset_F10) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F11, __str_offset_F11) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F12, __str_offset_F12) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F13, __str_offset_F13) - PROGRAMMABLE_KEY_OFFSET(CONFIG_KEYCMD_F14, __str_offset_F14) -#endif +!ifdef CONFIG_KEYBOARD_C128 { + !ifdef CONFIG_KEYCMD_HELP { !byte __str_offset_HELP - programmable_keys_strings } -#endif // CONFIG_PROGRAMMABLE_KEYS +} else ifdef CONFIG_KEYBOARD_C65 { + + !ifdef CONFIG_KEYCMD_HELP { !byte __str_offset_HELP - programmable_keys_strings } + + !ifdef CONFIG_KEYCMD_F9 { !byte __str_offset_F9 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F10 { !byte __str_offset_F10 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F11 { !byte __str_offset_F11 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F12 { !byte __str_offset_F12 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F13 { !byte __str_offset_F13 - programmable_keys_strings } + !ifdef CONFIG_KEYCMD_F14 { !byte __str_offset_F14 - programmable_keys_strings } + +} } + +} diff --git a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s index 9b337da2..38f47421 100644 --- a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s +++ b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s @@ -1,72 +1,64 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Definitions for communication with MEGA65 segment KERNAL_1 from KERNAL_0 -// +; +; Definitions for communication with MEGA65 segment KERNAL_1 from KERNAL_0 +; -#if SEGMENT_KERNAL_0 +!ifdef SEGMENT_KERNAL_0 { - // Label definitions + ; Label definitions - .label VK1__IOINIT = $4000 + 2 * 0 - .label VK1__RAMTAS = $4000 + 2 * 1 - .label VK1__vicii_init = $4000 + 2 * 2 - .label VK1__load_tape_normal = $4000 + 2 * 3 - .label VK1__load_tape_turbo = $4000 + 2 * 4 - .label VK1__load_tape_auto = $4000 + 2 * 5 - .label VK1__tape_head_align = $4000 + 2 * 6 - .label VK1__m65_chrout_screen = $4000 + 2 * 7 - .label VK1__m65_chrin_keyboard = $4000 + 2 * 8 - .label VK1__M65_MODESET = $4000 + 2 * 9 - .label VK1__M65_SCRMODEGET = $4000 + 2 * 10 - .label VK1__M65_SCRMODESET = $4000 + 2 * 11 - .label VK1__M65_CLRSCR = $4000 + 2 * 12 - .label VK1__M65_CLRWIN = $4000 + 2 * 13 - .label VK1__m65_screen_upd_txtrow_off = $4000 + 2 * 14 + !addr VK1__IOINIT = $4000 + 2 * 0 + !addr VK1__RAMTAS = $4000 + 2 * 1 + !addr VK1__vicii_init = $4000 + 2 * 2 + !addr VK1__load_tape_normal = $4000 + 2 * 3 + !addr VK1__load_tape_turbo = $4000 + 2 * 4 + !addr VK1__load_tape_auto = $4000 + 2 * 5 + !addr VK1__tape_head_align = $4000 + 2 * 6 + !addr VK1__m65_chrout_screen = $4000 + 2 * 7 + !addr VK1__m65_chrin_keyboard = $4000 + 2 * 8 + !addr VK1__M65_MODESET = $4000 + 2 * 9 + !addr VK1__M65_SCRMODEGET = $4000 + 2 * 10 + !addr VK1__M65_SCRMODESET = $4000 + 2 * 11 + !addr VK1__M65_CLRSCR = $4000 + 2 * 12 + !addr VK1__M65_CLRWIN = $4000 + 2 * 13 + !addr VK1__m65_screen_upd_txtrow_off = $4000 + 2 * 14 -#else +} else { - // Vector table (Open ROMs private!) + ; Vector table (Open ROMs private!) - .word IOINIT - .word RAMTAS - .word vicii_init + !word IOINIT + !word RAMTAS + !word vicii_init -#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_AUTODETECT - .word load_tape_normal -#else - .word $0000 -#endif +!ifdef CONFIG_TAPE_NORMAL { !ifndef CONFIG_TAPE_AUTODETECT { + !word load_tape_normal +} else { !word $0000 } } else { !word $0000 } -#if CONFIG_TAPE_TURBO && !CONFIG_TAPE_AUTODETECT - .word load_tape_turbo -#else - .word $0000 -#endif +!ifdef CONFIG_TAPE_TURBO { !ifndef CONFIG_TAPE_AUTODETECT { + !word load_tape_turbo +} else { !word $0000 } } else { !word $0000 } -#if CONFIG_TAPE_AUTODETECT - .word load_tape_auto -#else - .word $0000 -#endif -#if CONFIG_TAPE_HEAD_ALIGN - .word tape_head_align -#else - .word $0000 -#endif +!ifdef CONFIG_TAPE_AUTODETECT { + !word load_tape_auto +} else { !word $0000 } - .word m65_chrout_screen - .word m65_chrin_keyboard +!ifdef CONFIG_TAPE_HEAD_ALIGN { + !word tape_head_align +} else { !word $0000 } - .word M65_MODESET - .word M65_SCRMODEGET - .word M65_SCRMODESET - .word M65_CLRSCR - .word M65_CLRWIN - .word m65_screen_upd_txtrow_off + !word m65_chrout_screen + !word m65_chrin_keyboard -#endif + !word M65_MODESET + !word M65_SCRMODEGET + !word M65_SCRMODESET + !word M65_CLRSCR + !word M65_CLRWIN + !word m65_screen_upd_txtrow_off +} diff --git a/src/kernal/board_m65/mega65_dmagic.s b/src/kernal/board_m65/mega65_dmagic.s index 22cb5ad8..c68ac527 100644 --- a/src/kernal/board_m65/mega65_dmagic.s +++ b/src/kernal/board_m65/mega65_dmagic.s @@ -1,79 +1,81 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// Helper routines for DMAgic usage +; Helper routines for DMAgic usage -// See: -// - https://c65gs.blogspot.com/2019/03/auto-detecting-required-revision-of.html -// - https://c65gs.blogspot.com/2018/01/improving-dmagic-controller-interface.html +; See: +; - https://c65gs.blogspot.com/2019/03/auto-detecting-required-revision-of.html +; - https://c65gs.blogspot.com/2018/01/improving-dmagic-controller-interface.html m65_dmagic_oper_fill: - // To configure job parameters, use: - // - M65_DMAJOB_SIZE_* - // - M65_DMAJOB_DST_* - // - .A - byte for filling - // Afterwards, consider M65_DMAJOB_*_2 and M65_DMAJOB_*_3 destroyed. + ; To configure job parameters, use: + ; - M65_DMAJOB_SIZE_* + ; - M65_DMAJOB_DST_* + ; - .A - byte for filling + ; Afterwards, consider M65_DMAJOB_DST_2 and M65_DMAJOB_*_3 destroyed. - // Set fill address + ; Set fill address sta M65_DMAJOB_SRC_0 - // Set operation type + ; Set operation type - lda #($03 + $08) // operation: FILL + allow interrupts + lda #($03 + $08) ; operation: FILL + allow interrupts sta M65_DMAGIC_LIST+6 - // Adapt the addresses, launch the job + ; XXX! put 0 into M65_DMAJOB_SRC_3 to clear the flags + + ; Adapt the addresses, launch the job jsr m65_dmagic_adapt_dst - jmp_8 m65_dmagic_launch + bra m65_dmagic_launch m65_dmagic_oper_copy: - // To configure job parameters, use: - // - M65_DMAJOB_SIZE_* - // - M65_DMAJOB_SRC_* - // - M65_DMAJOB_DST_* - // Afterwards, consider M65_DMAJOB_DST_2 and M65_DMAJOB_DST_3 destroyed. + ; To configure job parameters, use: + ; - M65_DMAJOB_SIZE_* + ; - M65_DMAJOB_SRC_* + ; - M65_DMAJOB_DST_* + ; Afterwards, consider M65_DMAJOB_*_2 and M65_DMAJOB_*_3 destroyed. - // Set operation type + ; Set operation type - lda #($00 + $08) // operation: COPY + allow interrupts + lda #($00 + $08) ; operation: COPY + allow interrupts sta M65_DMAGIC_LIST+6 - // Adapt the addresses, launch the job + ; Adapt the addresses, launch the job jsr m65_dmagic_adapt_src jsr m65_dmagic_adapt_dst - // XXX prepare separate version for the opposite direction - change direction - // by setting bit 6 of M65_DMAJOB_*_2 + ; XXX possibly prepare separate version for the opposite direction - change direction + ; by setting bit 6 of M65_DMAJOB_*_2 - // FALLTROUGH + ; FALLTROUGH m65_dmagic_launch: - // Launch the DMA list + ; Launch the DMA list lda #$00 - sta DMA_ADDRBANK // $D702 - sta DMA_ADDRMB // $D704 + sta DMA_ADDRBANK ; $D702 + sta DMA_ADDRMB ; $D704 lda #>M65_DMAGIC_LIST - sta DMA_ADDRMSB // $D701 + sta DMA_ADDRMSB ; $D701 lda #scnkey_set_keytab sta KEYLOG+1 - // Initialise cursor blink flags (Computes Mapping the 64 p215) + ; Initialise cursor blink flags (Computes Mapping the 64 p215) lda #$01 sta BLNCT sta BLNSW - // Enable cursor repeat - XXX make it configurable + ; Enable cursor repeat - XXX make it configurable -#if CONFIG_KEY_REPEAT_DEFAULT && !CONFIG_KEY_REPEAT_ALWAYS +!ifdef CONFIG_KEY_REPEAT_DEFAULT { !ifndef CONFIG_KEY_REPEAT_ALWAYS { lda #$80 sta RPTFLG +} } -#endif + ; Set keyboard decode vector (Computes Mapping the 64 p215) - // Set keyboard decode vector (Computes Mapping the 64 p215) +!ifdef CONFIG_LEGACY_SCNKEY { -#if CONFIG_LEGACY_SCNKEY - - // Set initial variables for our improved keyboard scan routine + ; Set initial variables for our improved keyboard scan routine lda #$FF ldx #6 -!: sta BufferOld,x +@1: + sta BufferOld,x dex - bpl !- + bpl @1 sta BufferQuantity - // Set key repeat delay (Computes Mapping the 64 p215) - // Making some numbers up here: Repeat every ~1/10th sec - // But require key to be held for ~1/3sec before - // repeating (Computes Mapping the 64 p58) + ; Set key repeat delay (Computes Mapping the 64 p215) + ; Making some numbers up here: Repeat every ~1/10th sec + ; But require key to be held for ~1/3sec before + ; repeating (Computes Mapping the 64 p58) - // Not needed for default keyboard scanning code + ; Not needed for default keyboard scanning code - ldx #22-2 // Fudge factor to match speed + ldx #22-2 ; Fudge factor to match speed stx DELAY - -#endif +} - // Set current colour for text (Computes Mapping the 64 p215) + ; Set current colour for text (Computes Mapping the 64 p215) ldx #CONFIG_COLOR_TXT stx COLOR - // Set maximum keyboard buffer size (Computes Mapping the 64 p215) + ; Set maximum keyboard buffer size (Computes Mapping the 64 p215) ldx #10 stx XMAX - // Put non-zero value in MODE to enable case switch + ; Put non-zero value in MODE to enable case switch ldx #$00 stx MODE - // Fallthrough/jump to screen clear routine (Computes Mapping the 64 p215) + ; Fallthrough/jump to screen clear routine (Computes Mapping the 64 p215) jmp clear_screen diff --git a/src/kernal/init/e518.cint_legacy.s b/src/kernal/init/e518.cint_legacy.s index 23ef60ec..b986e07b 100644 --- a/src/kernal/init/e518.cint_legacy.s +++ b/src/kernal/init/e518.cint_legacy.s @@ -1,40 +1,39 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Part of the official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 280 -// - [CM64] Computes Mapping the Commodore 64 - page 242 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Part of the official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 280 +; - [CM64] Computes Mapping the Commodore 64 - page 242 +; +; CPU registers that has to be preserved (see [RG64]): none +; -cint_legacy: // $E518 +cint_legacy: ; $E518 -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcs !+ + bcs @1 jsr M65_MODESET bra cint_legacy_end -!: -#endif - - // Setup video and I/O - // See here: https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=22 +@1: +} + ; Setup video and I/O + ; See here: https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=22 jsr vicii_init - // FALLTROUGH + ; FALLTROUGH cint_legacy_end: - // Code below must be placed under $E51B, or some code will break - see here: - // - https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=2 - // Game 'Operacja Proboszcz' is one example. + ; Code below must be placed under $E51B, or some code will break - see here: + ; - https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=2 + ; Game 'Operacja Proboszcz' is one example. - jmp cint_screen_keyboard // XXX try to fit the code here + jmp cint_screen_keyboard ; XXX try to fit the code here diff --git a/src/kernal/init/e5a0.vicii_init.s b/src/kernal/init/e5a0.vicii_init.s index 5cb3d59c..1657e714 100644 --- a/src/kernal/init/e5a0.vicii_init.s +++ b/src/kernal/init/e5a0.vicii_init.s @@ -1,71 +1,74 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * * #IGNORE -// -// Well-known Kernal routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 215 -// +; +; Well-known Kernal routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 215 +; vicii_init: -#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +!ifdef SEGMENT_M65_KERNAL_0 { - jsr map_KERNAL_1 - jsr_ind VK1__vicii_init - jmp map_NORMAL + jsr map_KERNAL_1 + jsr (VK1__vicii_init) + jmp map_NORMAL -#else +} else { - // Clear everything - turn off sprites (observed hanging around after - // running programs and resetting), etc. + ; Clear everything - turn off sprites (observed hanging around after + ; running programs and resetting), etc. lda #$00 ldx #$2E - !: +@1: sta __VIC_BASE, x dex - bpl !- + bpl @1 -#if !CONFIG_MB_MEGA_65 && !CONFIG_MB_ULTIMATE_64 +!ifndef CONFIG_MB_M65 { !ifndef CONFIG_MB_U64 { - // Disable C128 extra keys - just to be sure they will not interfere with anything + ; Disable C128 extra keys - just to be sure they will not interfere with anything stx VIC_XSCAN - // Disable the C128 2MHz mode, it prevents VIC-II display from working correctly + ; Disable the C128 2MHz mode, it prevents VIC-II display from working correctly stx VIC_CLKRATE +} } -#endif + ; Set up default IO values + ; - [CM64] page 129 - VIC_SCROLY + ; - [CM64] pages 140-144 - VIC_SCROLX + ; - [CM64] pages 145-146 - VIC_YMCSB - // Set up default IO values - // - [CM64] page 129 - VIC_SCROLY - // - [CM64] pages 140-144 - VIC_SCROLX - // - [CM64] pages 145-146 - VIC_YMCSB - - lda #$1B // according to [CM64] page 137 some software assumes oldest bit is 0 + lda #$1B ; according to [CM64] page 137 some software assumes oldest bit is 0 sta VIC_SCROLY lda #$C8 - sta VIC_SCROLX // 40 column, etc. + sta VIC_SCROLX ; 40 column, etc. lda #$14 sta VIC_YMCSB lda #$0F - sta VIC_IRQ // clear all interrupts + sta VIC_IRQ ; clear all interrupts - // We use a different colour scheme of white text on all blue by default, - // but brand-specific color scheme can also be enabled + ; We use a different colour scheme of white text on all blue by default, + ; but brand-specific color scheme can also be enabled lda #CONFIG_COLOR_BG sta VIC_EXTCOL sta VIC_BGCOL0 - // Setup default I/O devices + ; Setup default I/O devices +!ifdef CONFIG_IEC { jmp clrchn_reset +} else { + jmp CLRCHN +} -#endif // ROM layout +} ; ROM layout diff --git a/src/kernal/init/fce2.hw_entry_reset.s b/src/kernal/init/fce2.hw_entry_reset.s index 754ccff8..41c21683 100644 --- a/src/kernal/init/fce2.hw_entry_reset.s +++ b/src/kernal/init/fce2.hw_entry_reset.s @@ -1,78 +1,72 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Resources describing the C64 reset sequence: -// https://www.c64-wiki.com/wiki/Reset_(Process) +; Resources describing the C64 reset sequence: +; https://www.c64-wiki.com/wiki/Reset_(Process) hw_entry_reset: - // The GPL program at https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/6502_functional_test.a65 - // uses the similar initial reset sequence, affirmed by c64 PRG p269 + ; The GPL program at https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/6502_functional_test.a65 + ; uses the similar initial reset sequence, affirmed by c64 PRG p269 - sei // disable the interrupts, as fast as possible - they are disabled in case of HW reset, - // but this routine can be also called manually + sei ; disable the interrupts, as fast as possible - they are disabled in case of HW reset, + ; but this routine can be also called manually - cld // required for all CPUs - due to possibility of manual call + cld ; required for all CPUs - due to possibility of manual call -#if HAS_OPCODES_65CE02 +!ifdef HAS_OPCODES_65CE02 { - see // disable extended stack - -#endif + see ; disable extended stack +} ldx #$FF txs -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr m65_reset_part +} -#endif +!ifdef CONFIG_PLATFORM_COMMODORE_64 { -#if CONFIG_PLATFORM_COMMODORE_64 + ; The following routine is based on reading the public KERNAL jumptable routine + ; list, and making unimaginative assumptions about what should be done on reset. + ; Also, https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image was used + ; as it shows example startup sequence, to be followe by cartridge creators - // The following routine is based on reading the public KERNAL jumptable routine - // list, and making unimaginative assumptions about what should be done on reset. - // Also, https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image was used - // as it shows example startup sequence, to be followe by cartridge creators - - // C64 PRG p269 + ; C64 PRG p269 jsr cartridge_check - bne !+ + bne @1 jmp (ICART_COLD_START) -!: +@1: - // Disable the screen (and set 40 columns) to prevent visual glitches later + ; Disable the screen (and set 40 columns) to prevent visual glitches later ldx #$28 stx VIC_SCROLX - -#endif - - // Initialising IO is obviously required. Also indicated by c64 prg p269. +} + ; Initialising IO is obviously required. Also indicated by c64 prg p269. jsr JIOINIT - // Setting up the screen and testing ram is obviously required - // also affirmed by p269 of c64 prg - jsr JRAMTAS // called RANTAM on Codebase64 wiki + ; Setting up the screen and testing ram is obviously required + ; also affirmed by p269 of c64 prg + jsr JRAMTAS ; called RANTAM on Codebase64 wiki - // Resetting IO vectors is obviously required, if we want interrupts to run - // also affirmed by c64 prg p269 + ; Resetting IO vectors is obviously required, if we want interrupts to run + ; also affirmed by c64 prg p269 jsr JRESTOR - // "Compute's Mapping the 64" p236 + ; "Compute's Mapping the 64" p236 jsr JCINT -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { clc - jsr M65_MODESET // on MEGA65 go to native mode by default + jsr M65_MODESET ; on MEGA65 go to native mode by default +} + ; What do we do when finished? A C64 jumps into the BASIC ROM + cli ; allow interrupts to happen -#endif - - // What do we do when finished? A C64 jumps into the BASIC ROM - cli // allow interrupts to happen - - // c64 prg p269 + ; c64 prg p269 jmp (IBASIC_COLD_START) diff --git a/src/kernal/init/fd50.ramtas.s b/src/kernal/init/fd50.ramtas.s index 70a4abc2..d68d3f16 100644 --- a/src/kernal/init/fd50.ramtas.s +++ b/src/kernal/init/fd50.ramtas.s @@ -1,71 +1,71 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT -// #LAYOUT# X16 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +;; #LAYOUT# X16 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 291 -// - [CM64] Computes Mapping the Commodore 64 - page 237 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 291 +; - [CM64] Computes Mapping the Commodore 64 - page 237 +; +; CPU registers that has to be preserved (see [RG64]): none +; RAMTAS: -#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +!ifdef SEGMENT_M65_KERNAL_0 { - jsr map_KERNAL_1 - jsr_ind VK1__RAMTAS - jmp map_NORMAL + jsr map_KERNAL_1 + jsr (VK1__RAMTAS) + jmp map_NORMAL -#else +} else { - // C64 Programmers Reference guide p291: - // Clear $0000-$0101, $0200-$03ff - // PGS: $0000, $0001 are CPU IO ports, so should not get written to + ; C64 Programmers Reference guide p291: + ; Clear $0000-$0101, $0200-$03ff + ; PGS: $0000, $0001 are CPU IO ports, so should not get written to - // How many ways are there to efficiently erase these two pages - // of RAM? We would like to avoid any unnecessary byte similarity - // with the C64 KERNAL. Thus we do $0300 before $0200, even though - // with the longer sequence of identicale bytes we see no basis for - // it being copyrightable. Again, we just want to redue the attack - // surface for any misguided suit. + ; How many ways are there to efficiently erase these two pages + ; of RAM? We would like to avoid any unnecessary byte similarity + ; with the C64 KERNAL. Thus we do $0300 before $0200, even though + ; with the longer sequence of identicale bytes we see no basis for + ; it being copyrightable. Again, we just want to redue the attack + ; surface for any misguided suit. ldy #$00 lda #$00 -!: +@1: sta $0300,Y sta $0200,Y - sta $0002,Y // that is why we do not use .X for index, we do not want zeropage addressing here! + sta $0002,Y ; that is why we do not use .X for index, we do not want zeropage addressing here! iny - bne !- + bne @1 - // Allocate cassette buffer + ; Allocate cassette buffer ldx #<$033C stx TAPE1+0 ldx #>$033C stx TAPE1+1 -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { - // Set screen address pointer ("Compute's Mapping the 64" p238) - // This is obvious boiler plate containing no creative input, but to avoid - // unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this, - // and several following + ; Set screen address pointer ("Compute's Mapping the 64" p238) + ; This is obvious boiler plate containing no creative input, but to avoid + ; unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this, + ; and several following ldx #>$0400 stx HIBASE - // Set BASIC start text pointer - // (remember, that low memory is 0 initialized at this moment) + ; Set BASIC start text pointer + ; (remember, that low memory is 0 initialized at this moment) ldx #>$0800 stx MEMSTR+1 - // Work out RAM size and put in MEMSIZK - // Try to modify $8000, if it fails then RAM ends at $7FFF, else $9FFF + ; Work out RAM size and put in MEMSIZK + ; Try to modify $8000, if it fails then RAM ends at $7FFF, else $9FFF ldx $8000 inx @@ -73,17 +73,21 @@ RAMTAS: cpx $8000 bne ramtas_32k - // FALLTROUGH + ; FALLTROUGH ramtas_40k: - // 40K RAM - restore memory content, set MEMSIZK + ; 40K RAM - restore memory content, set MEMSIZK ldy #$A0 -!: + + ; FALLTROUGH + +ramtas_xxk: + sty MEMSIZK+1 - // Always restore memory, cartridge might have RAM under ROM + ; Always restore memory, cartridge might have RAM under ROM dex stx $8000 @@ -92,12 +96,12 @@ ramtas_40k: ramtas_32k: - // 32K RAM - restore memory content, set MEMSIZK + ; 32K RAM - restore memory content, set MEMSIZK ldy #$80 - bne !- // branch always + bne ramtas_xxk ; branch always -#elif CONFIG_PLATFORM_COMMANDER_X16 +} else ifdef CONFIG_PLATFORM_COMMANDER_X16 { ldx #>$0800 stx MEMSTR+1 @@ -105,11 +109,11 @@ ramtas_32k: ldy #$9F sty MEMSIZK+1 -#else +} else { - .error "Please fill-in RAMTAS" + !error "Please fill-in RAMTAS" -#endif // platform +} ; platform -#endif // ROM layout +} ; ROM layout diff --git a/src/kernal/init/fda3.ioinit.s b/src/kernal/init/fda3.ioinit.s index b3973e07..98f2cd8b 100644 --- a/src/kernal/init/fda3.ioinit.s +++ b/src/kernal/init/fda3.ioinit.s @@ -1,175 +1,170 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 285 -// - [CM64] Computes Mapping the Commodore 64 - page 238 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 285 +; - [CM64] Computes Mapping the Commodore 64 - page 238 +; +; CPU registers that has to be preserved (see [RG64]): none +; IOINIT: -#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +!ifdef SEGMENT_M65_KERNAL_0 { - jsr map_KERNAL_1 - jsr_ind VK1__IOINIT - // End by initializing the MEGA65 internal DOS - jmp m65dos_init + jsr map_KERNAL_1 + jsr (VK1__IOINIT) + jmp m65dos_init ; end by initializing the MEGA65 internal DOS -#else +} else { - // - // First initialize the CPU port, to make sure we have correct memory map - // + ; + ; First initialize the CPU port, to make sure we have correct memory map + ; - // We want BASIC and KERNAL ROMs mapped, and datasette motor off - // (https://www.c64-wiki.com/wiki/Zeropage) - // Work around for VICE bug: Writing $00 before $01 results in rubbish in $01 - // after. https://sourceforge.net/p/vice-emu/bugs/1057/ + ; We want BASIC and KERNAL ROMs mapped, and datasette motor off + ; (https://www.c64-wiki.com/wiki/Zeropage) + ; Work around for VICE bug: Writing $00 before $01 results in rubbish in $01 + ; after. https://sourceforge.net/p/vice-emu/bugs/1057/ ldx #$27 stx CPU_R6510 - ldx #$2F // checked real ROM value + ldx #$2F ; checked real ROM value stx CPU_D6510 - // - // Now prevent the CIAs from generating interrupts, who knows what damage they can do - // + ; + ; Now prevent the CIAs from generating interrupts, who knows what damage they can do + ; - // Disable IRQ generation for both CIAs - see [CM64], page 149 + ; Disable IRQ generation for both CIAs - see [CM64], page 149 ldx #$7F - stx CIA1_ICR // $DC0D - stx CIA2_ICR // $DD0D + stx CIA1_ICR ; $DC0D + stx CIA2_ICR ; $DD0D - // See discussion here: - // https://www.lemon64.com/forum/viewtopic.php?t=41744&sid=e294c254db2ba671cde643f100aae341 - // It seems that initializing this register to $7F is the best idea - UDTIM key scanning - // also leaves this at $7F + ; See discussion here: + ; https://www.lemon64.com/forum/viewtopic.php?t=41744&sid=e294c254db2ba671cde643f100aae341 + ; It seems that initializing this register to $7F is the best idea - UDTIM key scanning + ; also leaves this at $7F - stx CIA1_PRA // $DC00 + stx CIA1_PRA ; $DC00 - // - // Now silence the SID chip(s), depending on the configuration - we want them silent ASAP - // + ; + ; Now silence the SID chip(s), depending on the configuration - we want them silent ASAP + ; lda #$00 -#if !CONFIG_MB_MEGA_65 +!ifndef CONFIG_MB_M65 { - // First the standard chip (skip if it is covered by whole $D4XX range) + ; First the standard chip (skip if it is covered by whole $D4XX range) -#if !CONFIG_SID_D4XX +!ifndef CONFIG_SID_D4XX { sta SID_SIGVOL -#endif // !CONFIG_SID_D4XX +} - // Silence manually configured 2nd and 3rd SIDs + ; Silence manually configured 2nd and 3rd SIDs -#if CONFIG_SID_2ND +!ifdef CONFIG_SID_2ND_ADDRESS { sta SID_SIGVOL - __SID_BASE + CONFIG_SID_2ND_ADDRESS -#endif // CONFIG_SID_2ND +} -#if CONFIG_SID_3RD +!ifdef CONFIG_SID_3RD_ADDRESS { sta SID_SIGVOL - __SID_BASE + CONFIG_SID_3RD_ADDRESS -#endif // CONFIG_SID_3RD +} + ; Silence whole D4XX and D5XX ranges (if configured) - // Silence whole D4XX and D5XX ranges (if configured) - -#if CONFIG_SID_D4XX || CONFIG_SID_D5XX +!ifdef CONFIG_SID_D4XX_OR_D5XX { ldy #$00 -!: +@1: -#if CONFIG_SID_D4XX +!ifdef CONFIG_SID_D4XX { sta SID_SIGVOL + $000, Y -#endif // CONFIG_SID_D4XX - -#if CONFIG_SID_D5XX +} +!ifdef CONFIG_SID_D5XX { sta SID_SIGVOL + $100, Y -#endif // CONFIG_SID_D4XX +} tya clc adc #$20 tay - bne !- + bne @1 -#endif // CONFIG_SID_D4XX || CONFIG_SID_D5XX +} ; CONFIG_SID_D4XX_OR_D5XX -#else +} else { ; CONFIG_MB_M65 - // MEGA65 specific handling - it contains 4 SIDs + ; MEGA65 specific handling - it contains 4 SIDs sta SID_SIGVOL + __SID_R1_OFFSET sta SID_SIGVOL + __SID_R2_OFFSET sta SID_SIGVOL + __SID_L1_OFFSET sta SID_SIGVOL + __SID_L2_OFFSET -#endif // CONFIG_MB_MEGA_65 +} - // - // Now continue the CIAs initialization - // + ; + ; Now continue the CIAs initialization + ; - // For CIA #1 we need port A as output and port B as input to scan the keyboard + ; For CIA #1 we need port A as output and port B as input to scan the keyboard ldx #$FF - stx CIA1_DDRA // $DC02 + stx CIA1_DDRA ; $DC02 inx - stx CIA1_DDRB // $DC03 - stx CIA2_DDRB // $DD03 // XXX this port is used for RS-232, value here is most likely wrong! + stx CIA1_DDRB ; $DC03 + stx CIA2_DDRB ; $DD03 ; XXX this port is used for RS-232, value here is most likely wrong! -#if CONFIG_KEYBOARD_C65 || CONFIG_KEYBOARD_C65_CAPS_LOCK +!ifdef CONFIG_KEYBOARD_C65_OR_CAPS_LOCK { lda #$02 - sta C65_EXTKEYS_DDR // output for most keys, input for CAPS LOCK bit + sta C65_EXTKEYS_DDR ; output for most keys, input for CAPS LOCK bit +} -#endif - - // Set DDR on CIA2 for IEC bus, VIC-II banking (see [CM64], $DDOO description on page 193) + ; Set DDR on CIA2 for IEC bus, VIC-II banking (see [CM64], $DDOO description on page 193) lda #$3F - sta CIA2_DDRA // $DD02 + sta CIA2_DDRA ; $DD02 - // Checked using VICE that original ROM initializes timers this way + ; Checked using VICE that original ROM initializes timers this way ldx #$08 - stx CIA1_CRB // $DC0F - stx CIA2_CRA // $DD0E - stx CIA2_CRB // $DD0F + stx CIA1_CRB ; $DC0F + stx CIA2_CRA ; $DD0E + stx CIA2_CRB ; $DD0F - // Set VIC-II bank - at least the 'Operacja Proboszcz' game needs this within IOINIT - // Checked on original ROMs, that it sets bit #2 (RS-232 output) high + ; Set VIC-II bank - at least the 'Operacja Proboszcz' game needs this within IOINIT + ; Checked on original ROMs, that it sets bit #2 (RS-232 output) high - ldx #%00000111 // XXX adapt this to IEC idle state, JMP at the end won't be needed - stx CIA2_PRA // $DD00 + ldx #%00000111 ; XXX adapt this to IEC idle state, JMP at the end won't be needed + stx CIA2_PRA ; $DD00 - // Put something sane in the IRQ timer + ; Put something sane in the IRQ timer jsr setup_irq_timer - // Enable timer A to run continuously (http://codebase64.org/doku.php?id=base:timerinterrupts) + ; Enable timer A to run continuously (http://codebase64.org/doku.php?id=base:timerinterrupts) ldx #$11 - stx CIA1_CRA // $DC0E + stx CIA1_CRA ; $DC0E - // Enable timer interrupt + ; Enable timer interrupt ldx #$81 - stx CIA1_ICR // $DC0D + stx CIA1_ICR ; $DC0D -#if CONFIG_IEC +!ifdef CONFIG_IEC { - // Set IEC bus to its initial idle state + ; Set IEC bus to its initial idle state jmp iec_set_idle -#else +} else { rts - -#endif +} -#endif // ROM layout +} ; ROM layout diff --git a/src/kernal/init/ff5b.cint.s b/src/kernal/init/ff5b.cint.s index 784bb73f..47f7eee9 100644 --- a/src/kernal/init/ff5b.cint.s +++ b/src/kernal/init/ff5b.cint.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 280 -// - [CM64] Computes Mapping the Commodore 64 - page 242 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 280 +; - [CM64] Computes Mapping the Commodore 64 - page 242 +; +; CPU registers that has to be preserved (see [RG64]): none +; CINT: diff --git a/src/kernal/init/fffc.vector_reset.s b/src/kernal/init/fffc.vector_reset.s index 32fb6c03..a6545674 100644 --- a/src/kernal/init/fffc.vector_reset.s +++ b/src/kernal/init/fffc.vector_reset.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// $FFFC - CPU Reset Vector -// Uncontrovertial, as it is a CPU requirement, and nothing else. +; $FFFC - CPU Reset Vector +; Uncontrovertial, as it is a CPU requirement, and nothing else. vector_reset: - .word hw_entry_reset + !word hw_entry_reset diff --git a/src/kernal/init/setup_pal_ntsc.s b/src/kernal/init/setup_pal_ntsc.s index 52845204..c887f904 100644 --- a/src/kernal/init/setup_pal_ntsc.s +++ b/src/kernal/init/setup_pal_ntsc.s @@ -1,65 +1,65 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Detect video system (PAL/NTSC), use method by Graham, as it is short and reliable -// see here: https://codebase64.org/doku.php?id=base:detect_pal_ntsc +; Detect video system (PAL/NTSC), use method by Graham, as it is short and reliable +; see here: https://codebase64.org/doku.php?id=base:detect_pal_ntsc setup_pal_ntsc: lda VIC_RASTER -!: +@1: cmp VIC_RASTER - beq !- + beq @1 bmi setup_pal_ntsc - // Result in A, if no interrupt happened during the test: - // #$37 -> 312 rasterlines, PAL, VIC 6569 - // #$06 -> 263 rasterlines, NTSC, VIC 6567R8 - // #$05 -> 262 rasterlines, NTSC, VIC 6567R56A + ; Result in A, if no interrupt happened during the test: + ; #$37 -> 312 rasterlines, PAL, VIC 6569 + ; #$06 -> 263 rasterlines, NTSC, VIC 6567R8 + ; #$05 -> 262 rasterlines, NTSC, VIC 6567R56A cmp #$07 bcc setup_ntsc - // FALLTROUGH + ; FALLTROUGH setup_pal: lda #$01 - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH setup_ntsc: lda #$00 - // FALLTROUGH + ; FALLTROUGH setup_pal_ntsc_end: sta TVSFLG - // FALLTROUGH + ; FALLTROUGH -setup_irq_timer: // entry point needed by UP9600 and CIA1 burst mod support +setup_irq_timer: ; entry point needed by UP9600 and CIA1 burst mod support - // Sets up IRQ timer in CIA1 to ~1/60th of a second, - // depending on the detected video system + ; Sets up IRQ timer in CIA1 to ~1/60th of a second, + ; depending on the detected video system - // Retrieve video system (0 - NTSC, 1 - PAL), assume PAL for unknown values + ; Retrieve video system (0 - NTSC, 1 - PAL), assume PAL for unknown values ldx TVSFLG - beq !+ + beq @2 ldx #$01 -!: - // Setup interval for timer A in CIA1 +@2: + ; Setup interval for timer A in CIA1 lda irq_timing_lo, x - sta CIA1_TIMALO // $DC04 + sta CIA1_TIMALO ; $DC04 lda irq_timing_hi, x - sta CIA1_TIMAHI // $DC05 + sta CIA1_TIMAHI ; $DC05 rts diff --git a/src/kernal/interrupts/ea31.default_irq_handler.s b/src/kernal/interrupts/ea31.default_irq_handler.s index 394b5c21..bd43b132 100644 --- a/src/kernal/interrupts/ea31.default_irq_handler.s +++ b/src/kernal/interrupts/ea31.default_irq_handler.s @@ -1,75 +1,71 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE default_irq_handler: -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { jsr rs232_count_channels cpx #$00 - beq !+ + beq @1 jsr up9600_irq -!: +@1: +} -#endif // CONFIG_RS232_UP9600 -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcs !+ + bcs @2 jsr m65_cursor_blink bra default_irq_handler_common -!: +@2: jsr cursor_blink default_irq_handler_common: jsr JSCNKEY - jsr JUDTIM // update jiffy clock + jsr JUDTIM ; update jiffy clock -#else +} else { jsr cursor_blink jsr JSCNKEY - jsr JUDTIM // update jiffy clock - -#endif + jsr JUDTIM ; update jiffy clock +} -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { - // Turn tape motor on/off depending on the button state - // For CAS1 (tape motor interlock) variable description, see Mapping the C64, page 7 + ; Turn tape motor on/off depending on the button state + ; For CAS1 (tape motor interlock) variable description, see Mapping the C64, page 7 lda CPU_R6510 and #$10 - beq !+ // branch if tape button pressed + beq @3 ; branch if tape button pressed jsr tape_motor_off lda #$00 sta CAS1 - beq default_irq_handler_end_tape // branch always -!: + beq @4 ; branch always +@3: lda CAS1 - bne default_irq_handler_end_tape + bne @4 jsr tape_motor_on - -default_irq_handler_end_tape: - -#endif // CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +@4: +} -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { - // Acknowledge CIA interrupt and return + ; Acknowledge CIA interrupt and return jmp clear_cia1_interrupt_flag_and_return_from_interrupt -#else + } else { jmp return_from_interrupt - -#endif +} diff --git a/src/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s b/src/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s index 6d72292d..298bef0c 100644 --- a/src/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s +++ b/src/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// https://csdb.dk/forums/index.php?roomid=11&topicid=5776 -// Clear the CIA1 interrupt flag, and then fall through to -// the return from interrupt routine +; https://csdb.dk/forums/index.php?roomid=11&topicid=5776 +; Clear the CIA1 interrupt flag, and then fall through to +; the return from interrupt routine clear_cia1_interrupt_flag_and_return_from_interrupt: - // We have free choice of LDA, LDX or LDY to achieve this goal - // in 3 bytes and minimum cycles. Thus we randomly choose LDY. + ; We have free choice of LDA, LDX or LDY to achieve this goal + ; in 3 bytes and minimum cycles. Thus we randomly choose LDY. ldy CIA1_ICR - // FALL THROUGH to $EA81 + ; FALLTHROUGH to $EA81 diff --git a/src/kernal/interrupts/ea81.return_from_interrupt.s b/src/kernal/interrupts/ea81.return_from_interrupt.s index 9372d84d..a3cfb174 100644 --- a/src/kernal/interrupts/ea81.return_from_interrupt.s +++ b/src/kernal/interrupts/ea81.return_from_interrupt.s @@ -1,26 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// The IRQ is a commonly messed with thing on the C64, -// so we need to handle entry points that are commonly -// relied upon, including: -// $EA31 - Standard IRQ routine -// $EA61 - Check keyboard, but do not update timer? https://github.com/cc65/cc65/issues/324 -// $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb -// Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) +; The IRQ is a commonly messed with thing on the C64, +; so we need to handle entry points that are commonly +; relied upon, including: +; $EA31 - Standard IRQ routine +; $EA61 - Check keyboard, but do not update timer? https://github.com/cc65/cc65/issues/324 +; $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb +; Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) return_from_interrupt: - // Restore registers and return - // Sequence according to Computes Mapping the 64 p73 + ; Restore registers and return + ; Sequence according to Computes Mapping the 64 p73 - ply_trash_a - plx_trash_a + +ply_trash_a + +plx_trash_a pla - // FALLTROUGH + ; FALLTROUGH return_from_interrupt_rti: diff --git a/src/kernal/interrupts/fe47.default_nmi_handler.s b/src/kernal/interrupts/fe47.default_nmi_handler.s index 5e86373f..eb6946ba 100644 --- a/src/kernal/interrupts/fe47.default_nmi_handler.s +++ b/src/kernal/interrupts/fe47.default_nmi_handler.s @@ -1,40 +1,39 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE default_nmi_handler: - // Implemented according to Computes Mapping the Commodore 64, page 74 - // and to https://www.c64-wiki.com/wiki/Interrupt + ; Implemented according to Computes Mapping the Commodore 64, page 74 + ; and to https://www.c64-wiki.com/wiki/Interrupt - // Save registers, sequence according to Computes Mapping the Commodore 64, page 73 + ; Save registers, sequence according to Computes Mapping the Commodore 64, page 73 pha - phx_trash_a - phy_trash_a + +phx_trash_a + +phy_trash_a - // XXX: RS-232 support is not implemented + ; XXX: RS-232 support is not implemented - // XXX confirm NMIs from CIA, or no other NMI will arrive! + ; XXX confirm NMIs from CIA, or no other NMI will arrive! -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { jsr cartridge_check - bne !+ + bne @1 jmp (ICART_WARM_START) -!: +@1: +} -#endif + ; According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request - // According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request - - // XXX is it right? how to check that IRQ was caused by RESTORE? + ; XXX is it right? how to check that IRQ was caused by RESTORE? jsr JSTOP - bcs !+ - jmp return_from_interrupt // no STOP pressed -!: - // STOP + RESTORE - clean the address of the BRK instruction (it is not BRK) first + bcs @2 + jmp return_from_interrupt ; no STOP pressed +@2: + ; STOP + RESTORE - clean the address of the BRK instruction (it is not BRK) first lda #$00 sta CMP0+0 sta CMP0+1 diff --git a/src/kernal/interrupts/fe66.default_brk_handler.s b/src/kernal/interrupts/fe66.default_brk_handler.s index eb7e2cec..258bd701 100644 --- a/src/kernal/interrupts/fe66.default_brk_handler.s +++ b/src/kernal/interrupts/fe66.default_brk_handler.s @@ -1,43 +1,40 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE default_brk_handler: - // Implemented according to Computes Mapping the Commodore 64, pages 73-74 + ; Implemented according to Computes Mapping the Commodore 64, pages 73-74 - sei // disable IRQs, to be sure they wont interfere + sei ; disable IRQs, to be sure they wont interfere -#if CONFIG_PLATFORM_COMMODORE_64 +!ifdef CONFIG_PLATFORM_COMMODORE_64 { ldx #$00 - sta VIC_SCROLX // turn the display off - we want as little screen artifacts as possible + sta VIC_SCROLX ; turn the display off - we want as little screen artifacts as possible +} -#endif + cld ; make sure this dangerous flag is disabled - cld // make sure this dangerous flag is disabled +!ifdef HAS_OPCODES_65CE02 { -#if HAS_OPCODES_65CE02 + see ; disable extended stack +} - see // disable extended stack +!ifdef CONFIG_MB_M65 { -#endif - -#if ROM_LAYOUT_M65 - - // Make sure we have normal memory mapping + ; Make sure we have normal memory mapping jsr map_NORMAL - -#endif +} jsr JRESTOR jsr JIOINIT - // Original routine calls just a part of CINT - but I am not sure which one. Most likely it - // skips the PAL/NTSC check by calling $E518. I suspect bug in the original ROM, lets - // call the whole CINT, just to be sure everything is initialized. + ; Original routine calls just a part of CINT - but I am not sure which one. Most likely it + ; skips the PAL/NTSC check by calling $E518. I suspect bug in the original ROM, lets + ; call the whole CINT, just to be sure everything is initialized. jsr CINT diff --git a/src/kernal/interrupts/fffa.vector_nmi.s b/src/kernal/interrupts/fffa.vector_nmi.s index 16089345..a5a81cd0 100644 --- a/src/kernal/interrupts/fffa.vector_nmi.s +++ b/src/kernal/interrupts/fffa.vector_nmi.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// $FFFA - CPU NMI Hanlder -// Uncontrovertial as this is also a CPU requirement. +; $FFFA - CPU NMI Hanlder +; Uncontrovertial as this is also a CPU requirement. vector_nmi: - .word hw_entry_nmi + !word hw_entry_nmi diff --git a/src/kernal/interrupts/fffe.vector_irq.s b/src/kernal/interrupts/fffe.vector_irq.s index ba5a1f6f..fe8eb827 100644 --- a/src/kernal/interrupts/fffe.vector_irq.s +++ b/src/kernal/interrupts/fffe.vector_irq.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// $FFFE - CPU IRQ Vector. -// This is non-controvertial, as it is a 6502 CPU requirement, and we just have to point -// it to whatever IRQ routine we make. +; $FFFE - CPU IRQ Vector. +; This is non-controvertial, as it is a 6502 CPU requirement, and we just have to point +; it to whatever IRQ routine we make. vector_irq: - .word hw_entry_irq + !word hw_entry_irq diff --git a/src/kernal/interrupts/hw_entry_irq.s b/src/kernal/interrupts/hw_entry_irq.s index 0424705a..bcfe6d57 100644 --- a/src/kernal/interrupts/hw_entry_irq.s +++ b/src/kernal/interrupts/hw_entry_irq.s @@ -1,45 +1,46 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE hw_entry_irq: - // The IRQ is a commonly messed with thing on the C64, - // so we need to handle entry points that are commonly - // relied upon, including: - // $EA31 - Standard IRQ routine - // $EA61 - Check keyboard, but do not update timer? https://github.com/cc65/cc65/issues/324 - // $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb - // Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) + ; The IRQ is a commonly messed with thing on the C64, + ; so we need to handle entry points that are commonly + ; relied upon, including: + ; $EA31 - Standard IRQ routine + ; $EA61 - Check keyboard, but do not update timer? https://github.com/cc65/cc65/issues/324 + ; $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb + ; Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) - // Save registers, sequence according to Computes Mapping the Commodore 64, page 73 + ; Save registers, sequence according to Computes Mapping the Commodore 64, page 73 pha - phx_trash_a - phy_trash_a + +phx_trash_a + +phy_trash_a -#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS - cld // clear decimal flag to allow using it without disabling interrupts -#endif +!ifndef HAS_OPCODES_65CE02 { !ifdef CONFIG_BCD_SAFE_INTERRUPTS { - // Check if caused by BRK + cld ; clear decimal flag to allow using it without disabling interrupts +} } + + ; Check if caused by BRK tsx - lda $0104, x // get the pre-interrupt processor state + lda $0104, x ; get the pre-interrupt processor state and #$10 bne irq_handler_brk - // Not caused by BRK - call interrupt routine (only if initialised) - // Routine on zeropage = assuming not initialized + ; Not caused by BRK - call interrupt routine (only if initialised) + ; Routine on zeropage = assuming not initialized lda CINV+1 - beq !+ + beq @1 jmp (CINV) -!: - // Vector not initialized - call default interrupt routine +@1: + ; Vector not initialized - call default interrupt routine jmp default_irq_handler irq_handler_brk: - // Store BRK adddress, to be displayed + ; Store BRK adddress, to be displayed sec lda $0105, x sbc #$02 @@ -48,5 +49,5 @@ irq_handler_brk: sbc #$00 sta CMP0+1 - // Interrupt caused by BRK + ; Interrupt caused by BRK jmp (CBINV) diff --git a/src/kernal/interrupts/hw_entry_nmi.s b/src/kernal/interrupts/hw_entry_nmi.s index 225f9397..68bd744f 100644 --- a/src/kernal/interrupts/hw_entry_nmi.s +++ b/src/kernal/interrupts/hw_entry_nmi.s @@ -1,23 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE hw_entry_nmi: - sei // do not allow IRQ to interfere, see https://www.c64-wiki.com/wiki/Interrupt + sei ; do not allow IRQ to interfere, see https://www.c64-wiki.com/wiki/Interrupt -#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS - cld // clear decimal flag to allow using it without disabling interrupts -#endif +!ifndef HAS_OPCODES_65CE02 { !ifdef CONFIG_BCD_SAFE_INTERRUPTS { - // Call interrupt routine (only if initialised) + cld ; clear decimal flag to allow using it without disabling interrupts +} } + + ; Call interrupt routine (only if initialised) pha - lda NMINV+1 // consider zeropage NMI address as uninitialized vector - beq !+ // this allows safer interrupt vector modifications + lda NMINV+1 ; consider zeropage NMI address as uninitialized vector + beq @1 ; this allows safer interrupt vector modifications pla jmp (NMINV) -!: - // Vector not initialized - call default interrupt routine +@1: + ; Vector not initialized - call default interrupt routine pla jmp default_nmi_handler diff --git a/src/kernal/interrupts/nmi_lock.s b/src/kernal/interrupts/nmi_lock.s index 0b1462ee..83a5b9eb 100644 --- a/src/kernal/interrupts/nmi_lock.s +++ b/src/kernal/interrupts/nmi_lock.s @@ -1,60 +1,58 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Routine to lock NMI interrupts, using a trick described here: -// - https://codebase64.org/doku.php?id=base:nmi_lock -// +; +; Routine to lock NMI interrupts, using a trick described here: +; - https://codebase64.org/doku.php?id=base:nmi_lock +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { -// XXX consider broader usage of this method to make IO safer +; XXX consider broader usage of this method to make IO safer nmi_lock: - // We will have to change NMI vector to point empty routine, - // which will not acknowledge the interrupt - thus preventing - // the NMI to be triggered again + ; We will have to change NMI vector to point empty routine, + ; which will not acknowledge the interrupt - thus preventing + ; the NMI to be triggered again - // Our code considers zeropage address invalid, so put - // it there as a preparation + ; Our code considers zeropage address invalid, so put + ; it there as a preparation ldx #$00 stx NMINV+1 - // We can now safelly replace the vector + ; We can now safelly replace the vector lda #return_from_interrupt_rti sta NMINV+1 - // Stop timer A + ; Stop timer A - stx CIA2_CRA // $DD0E + stx CIA2_CRA ; $DD0E - // Set timer A to 0, after starting NMI will occur immediately + ; Set timer A to 0, after starting NMI will occur immediately - stx CIA2_TIMALO // $DD04 - stx CIA2_TIMAHI // $DD05 + stx CIA2_TIMALO ; $DD04 + stx CIA2_TIMAHI ; $DD05 - // Set timer A as source for NMI + ; Set timer A as source for NMI lda #$81 - sta CIA2_ICR // $DD0D + sta CIA2_ICR ; $DD0D - // Start timer A to trigger the NMI + ; Start timer A to trigger the NMI lda #$01 - sta CIA2_CRA // $DD0E + sta CIA2_CRA ; $DD0E - // All done. Unmaskable interrupts are now masked. + ; All done. Unmaskable interrupts are now masked. rts - - -#endif +} diff --git a/src/kernal/iostack/chkinout.s b/src/kernal/iostack/chkinout.s index 1d7c2043..e4374cf8 100644 --- a/src/kernal/iostack/chkinout.s +++ b/src/kernal/iostack/chkinout.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Common part of CHKIN and CKOUT -// +; +; Common part of CHKIN and CKOUT +; chkinout_device_not_present: - ply_trash_a + +ply_trash_a pla jsr kernalstatus_DEVICE_NOT_FOUND jmp kernalerror_DEVICE_NOT_FOUND chkinout_file_not_open: - ply_trash_a + +ply_trash_a pla jmp kernalerror_FILE_NOT_OPEN diff --git a/src/kernal/iostack/clall_real.s b/src/kernal/iostack/clall_real.s index 7243d7d6..bd1a3450 100644 --- a/src/kernal/iostack/clall_real.s +++ b/src/kernal/iostack/clall_real.s @@ -1,38 +1,38 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 281 -// - [CM64] Computes Mapping the Commodore 64 - page 230 -// -// CPU registers that has to be preserved (see [RG64]): .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 281 +; - [CM64] Computes Mapping the Commodore 64 - page 230 +; +; CPU registers that has to be preserved (see [RG64]): .Y +; clall_real: - // Store .Y register - phy_trash_a + ; Store .Y register + +phy_trash_a - // Original routine probably just sets LDTND to 0, but this is not really safe, - // so we actually close all the channels; at least IDE64 does the same for - // its channels, see CLALL description in the IDE64 Users Guide -!: + ; Original routine probably just sets LDTND to 0, but this is not really safe, + ; so we actually close all the channels; at least IDE64 does the same for + ; its channels, see CLALL description in the IDE64 Users Guide +@1: ldy LDTND - beq !+ + beq @2 dey lda LAT, y jsr JCLOSE - jmp !- -!: - // Restore .Y register - ply_trash_a + jmp @1 +@2: + ; Restore .Y register + +ply_trash_a - // 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too + ; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too jsr CLRCHN - // Not sure whether original Kernal does so, but it seems sane to also clear possible errors + ; Not sure whether original Kernal does so, but it seems sane to also clear possible errors jmp kernalstatus_reset diff --git a/src/kernal/iostack/e50a.plot.s b/src/kernal/iostack/e50a.plot.s index e42d76c0..d060398e 100644 --- a/src/kernal/iostack/e50a.plot.s +++ b/src/kernal/iostack/e50a.plot.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 290 -// - [CM64] Computes Mapping the Commodore 64 - page 215 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 290 +; - [CM64] Computes Mapping the Commodore 64 - page 215 +; +; CPU registers that has to be preserved (see [RG64]): none +; PLOT: bcs plot_get - // Note: the 'set' part has to start from $E50C, as this is a known address - // - https://www.lemon64.com/forum/viewtopic.php?t=3296&%3Bstart=15 - // - https://sys64738.org/2019/05/c64-bedtime-coding-eng-printing-08/ - // - 'Duotris' game calls $E50C during startup screen initialization + ; Note: the 'set' part has to start from $E50C, as this is a known address + ; - https://www.lemon64.com/forum/viewtopic.php?t=3296&%3Bstart=15 + ; - https://sys64738.org/2019/05/c64-bedtime-coding-eng-printing-08/ + ; - 'Duotris' game calls $E50C during startup screen initialization plot_set: @@ -28,7 +28,7 @@ plot_set: jsr screen_calculate_pointers - // FALLTROUGH to save one byte on RTS + ; FALLTROUGH to save one byte on RTS plot_get: diff --git a/src/kernal/iostack/f13e.getin.s b/src/kernal/iostack/f13e.getin.s index c3017601..4950ace7 100644 --- a/src/kernal/iostack/f13e.getin.s +++ b/src/kernal/iostack/f13e.getin.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 283 -// - [CM64] Computes Mapping the Commodore 64 - page 227/228 -// -// CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 283 +; - [CM64] Computes Mapping the Commodore 64 - page 227/228 +; +; CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y +; GETIN: diff --git a/src/kernal/iostack/f157.chrin.s b/src/kernal/iostack/f157.chrin.s index b663cd93..018decc0 100644 --- a/src/kernal/iostack/f157.chrin.s +++ b/src/kernal/iostack/f157.chrin.s @@ -1,51 +1,51 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 277/278 -// - [CM64] Computes Mapping the Commodore 64 - page 228 -// -// CPU registers that has to be preserved (see [RG64]): .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 277/278 +; - [CM64] Computes Mapping the Commodore 64 - page 228 +; +; CPU registers that has to be preserved (see [RG64]): .Y +; -// Reads a byte of input, unless from keyboard. -// If from keyboard, then it gets a whole line of input, and returns the first char. -// Repeated calls after that read out the successive bytes of the line of input. +; Reads a byte of input, unless from keyboard. +; If from keyboard, then it gets a whole line of input, and returns the first char. +; Repeated calls after that read out the successive bytes of the line of input. CHRIN: - // Determine the device number + ; Determine the device number lda DFLTN - // Try $00 - keyboard - beq_16 chrin_keyboard + ; Try $00 - keyboard + +beq chrin_keyboard - // XXX Try $03 - screen - // cmp #$03 - // beq_16 chrin_screen + ; XXX Try $03 - screen + ; cmp #$03 + ; +beq chrin_screen -#if HAS_RS232 +!ifdef HAS_RS232 { - // Try $02 - RS-232 + ; Try $02 - RS-232 cmp #$02 - beq_16 chrin_rs232 + +beq chrin_rs232 -#endif // HAS_RS232 +} ; HAS_RS232 -chrin_getin: // jump entry for GETIN +chrin_getin: ; jump entry for GETIN -#if CONFIG_IEC +!ifdef CONFIG_IEC { - // Try IEC devices + ; Try IEC devices jsr iec_check_devnum_oc - bcc_16 chrin_iec + +bcc chrin_iec -#endif // CONFIG_IEC +} ; CONFIG_IEC - // Not a supported device + ; Not a supported device jmp lvs_device_not_found_error diff --git a/src/kernal/iostack/f1ca.chrout.s b/src/kernal/iostack/f1ca.chrout.s index b528a8bb..a9685588 100644 --- a/src/kernal/iostack/f1ca.chrout.s +++ b/src/kernal/iostack/f1ca.chrout.s @@ -1,80 +1,80 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 278/279 -// - [CM64] Computes Mapping the Commodore 64 - page 228 -// -// CPU registers that has to be preserved (see [RG64]): .Y -// Additionally we have to preserve .X for out CHRIN and implementation -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 278/279 +; - [CM64] Computes Mapping the Commodore 64 - page 228 +; +; CPU registers that has to be preserved (see [RG64]): .Y +; Additionally we have to preserve .X for out CHRIN and implementation +; CHROUT: sta SCHAR - // Save X and Y values - // (Confirmed by writing a test program that X and Y - // do not get modified, in agreement with C64 PRG - // description of CHROUT) + ; Save X and Y values + ; (Confirmed by writing a test program that X and Y + ; do not get modified, in agreement with C64 PRG + ; description of CHROUT) - phx_trash_a - phy_trash_a + +phx_trash_a + +phy_trash_a php - // Determine the device number + ; Determine the device number lda DFLTO - cmp #$03 // screen - beq_16 chrout_screen + cmp #$03 ; screen + +beq chrout_screen -#if HAS_RS232 +!ifdef HAS_RS232 { cmp #$02 - beq_16 chrout_rs232 -#endif + +beq chrout_rs232 +} -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_oc - bcc_16 chrout_iec -#endif + +bcc chrout_iec +} - // FALLTROUGH + ; FALLTROUGH chrout_done_fail: plp - // Restore X and Y - ply_trash_a - plx_trash_a + ; Restore X and Y + +ply_trash_a + +plx_trash_a - sec // indicate failure + sec ; indicate failure rts chrout_done_unknown_device: plp - // Restore X and Y - ply_trash_a - plx_trash_a + ; Restore X and Y + +ply_trash_a + +plx_trash_a - // End wioth error + ; End wioth error jmp lvs_device_not_found_error chrout_done_success: plp - cli // needed for screen (checked calling the routine on original ROMs), XXX what about other devices? + cli ; needed for screen (checked calling the routine on original ROMs), XXX what about other devices? - // Restore X and Y - ply_trash_a - plx_trash_a + ; Restore X and Y + +ply_trash_a + +plx_trash_a lda SCHAR - clc // indicate success + clc ; indicate success rts diff --git a/src/kernal/iostack/f20e.chkin.s b/src/kernal/iostack/f20e.chkin.s index e2eae99e..e417edbb 100644 --- a/src/kernal/iostack/f20e.chkin.s +++ b/src/kernal/iostack/f20e.chkin.s @@ -1,74 +1,73 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routines, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 275 -// - [CM64] Computes Mapping the Commodore 64 - page 229 -// -// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) -// +; +; Official Kernal routines, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 275 +; - [CM64] Computes Mapping the Commodore 64 - page 229 +; +; CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) +; CHKIN: - // Store registers for preservation + ; Store registers for preservation pha - phy_trash_a + +phy_trash_a - // Reset status + ; Reset status jsr kernalstatus_reset - // First retrieve the FAT/LAT/SAT table index (and check if file is open) + ; First retrieve the FAT/LAT/SAT table index (and check if file is open) txa jsr find_fls - bcs_16 chkinout_file_not_open + +bcs chkinout_file_not_open - // Now we have table index in Y + ; Now we have table index in Y lda FAT,Y - // Handle all the devices + ; Handle all the devices - beq chkin_set_device // 0 - keyboard + beq chkin_set_device ; 0 - keyboard - // Tape not supported here + ; Tape not supported here -#if HAS_RS232 +!ifdef HAS_RS232 { cmp #$02 - beq_16 chkin_rs232 + +beq chkin_rs232 +} -#endif // HAS_RS232 - -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_oc - bcc_16 chkin_iec + +bcc chkin_iec +} -#endif // CONFIG_IEC - - cmp #$03 // screen - only legal one left - bne_16 chkinout_device_not_present + cmp #$03 ; screen - only legal one left + +bne chkinout_device_not_present chkin_set_device: + lda FAT,Y sta DFLTN - // FALLTROUGH + ; FALLTROUGH chkinout_end: - ply_trash_a + +ply_trash_a pla - clc // indicate success + clc ; indicate success rts chkin_file_not_input: - ply_trash_a + +ply_trash_a pla jmp kernalerror_FILE_NOT_INPUT diff --git a/src/kernal/iostack/f250.ckout.s b/src/kernal/iostack/f250.ckout.s index a99f359e..d420fcc6 100644 --- a/src/kernal/iostack/f250.ckout.s +++ b/src/kernal/iostack/f250.ckout.s @@ -1,65 +1,65 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routines, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 276 -// - [CM64] Computes Mapping the Commodore 64 - page 229 -// -// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) -// +; +; Official Kernal routines, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 276 +; - [CM64] Computes Mapping the Commodore 64 - page 229 +; +; CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) +; CKOUT: - // Store registers for preservation + ; Store registers for preservation pha - phy_trash_a + +phy_trash_a - // Reset status + ; Reset status jsr kernalstatus_reset - // First retrieve the FAT/LAT/SAT table index (and check if file is open) + ; First retrieve the FAT/LAT/SAT table index (and check if file is open) txa jsr find_fls - bcs_16 chkinout_file_not_open + +bcs chkinout_file_not_open - // Now we have table index in Y + ; Now we have table index in Y lda FAT,Y - // Handle all the devices + ; Handle all the devices - beq ckout_file_not_output // 0 - keyboard + beq ckout_file_not_output ; 0 - keyboard - // Tape not supported here + ; Tape not supported here -#if HAS_RS232 +!ifdef HAS_RS232 { cmp #$02 - beq_16 ckout_rs232 + +beq ckout_rs232 +} -#endif // HAS_RS232 - -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_oc - bcc_16 ckout_iec + +bcc ckout_iec +} -#endif // CONFIG_IEC - - cmp #$03 // screen - only legal one left - bne_16 chkinout_device_not_present + cmp #$03 ; screen - only legal one left + +bne chkinout_device_not_present ckout_set_device: + lda FAT,Y sta DFLTO jmp chkinout_end ckout_file_not_output: - ply_trash_a + + +ply_trash_a pla jmp kernalerror_FILE_NOT_OUTPUT diff --git a/src/kernal/iostack/f291.close.s b/src/kernal/iostack/f291.close.s index 1a5b49a6..d3dd249d 100644 --- a/src/kernal/iostack/f291.close.s +++ b/src/kernal/iostack/f291.close.s @@ -1,48 +1,48 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 281/282 -// - [CM64] Computes Mapping the Commodore 64 - page 229/230 -// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc (IEC command) -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 281/282 +; - [CM64] Computes Mapping the Commodore 64 - page 229/230 +; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc (IEC command) +; +; CPU registers that has to be preserved (see [RG64]): none +; CLOSE: - // Find the LAT / SAT / FAT entry which LAT corresponds to A + ; Find the LAT / SAT / FAT entry which LAT corresponds to A jsr find_fls - bcs close_end // XXX can we report error in IOSTATUS here? + bcs close_end ; XXX can we report error in IOSTATUS here? - // We have the entry index in .Y + ; We have the entry index in .Y lda FAT, y - // Perform device-specific actions + ; Perform device-specific actions -#if HAS_RS232 +!ifdef HAS_RS232 { cmp #$02 - beq_16 close_rs232 -#endif + +beq close_rs232 +} -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_oc - bcc_16 close_iec -#endif + +bcc close_iec +} - // FALLTROUGH + ; FALLTROUGH close_remove_from_table: - // Remove channel from the table + ; Remove channel from the table iny cpy #$0A - bpl !+ + bpl @1 lda LAT, y sta LAT-1, y lda FAT, y @@ -50,11 +50,11 @@ close_remove_from_table: lda SAT, y sta SAT-1, y jmp close_remove_from_table -!: - // Decrement the list size variable +@1: + ; Decrement the list size variable dec LDTND - clc // report success - not sure if original CLOSE does this, but it is nevertheless a good practice + clc ; report success - not sure if original CLOSE does this, but it is nevertheless a good practice close_end: rts diff --git a/src/kernal/iostack/f32f.clall.jmp.s b/src/kernal/iostack/f32f.clall.jmp.s index 3305e94a..946eb160 100644 --- a/src/kernal/iostack/f32f.clall.jmp.s +++ b/src/kernal/iostack/f32f.clall.jmp.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Our implementation is longer than the original one, -// placing it here would cause a collision with CLRCHN +; Our implementation is longer than the original one, +; placing it here would cause a collision with CLRCHN CLALL: diff --git a/src/kernal/iostack/f333.clrchn.s b/src/kernal/iostack/f333.clrchn.s index b4829b11..be3a8e81 100644 --- a/src/kernal/iostack/f333.clrchn.s +++ b/src/kernal/iostack/f333.clrchn.s @@ -1,34 +1,32 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 282 -// - [CM64] Computes Mapping the Commodore 64 - page 230 -// -// CPU registers that has to be preserved (see [RG64]): .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 282 +; - [CM64] Computes Mapping the Commodore 64 - page 230 +; +; CPU registers that has to be preserved (see [RG64]): .Y +; CLRCHN: -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr clrchn_iec -#else - nop // just to prevent double label -#endif - // FALLTROUGH + ; FALLTROUGH -clrchn_reset: // entry needed by vicii_init +clrchn_reset: ; entry needed by vicii_init +} - // Set input device number to keyboard + ; Set input device number to keyboard lda #$00 sta DFLTN - // Set output device number to screen + ; Set output device number to screen lda #$03 sta DFLTO diff --git a/src/kernal/iostack/f34a.open.s b/src/kernal/iostack/f34a.open.s index 6387bdf1..19ab1b69 100644 --- a/src/kernal/iostack/f34a.open.s +++ b/src/kernal/iostack/f34a.open.s @@ -1,51 +1,52 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 289 -// - [CM64] Computes Mapping the Commodore 64 - page 230/231 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 289 +; - [CM64] Computes Mapping the Commodore 64 - page 230/231 +; +; CPU registers that has to be preserved (see [RG64]): none +; OPEN: - // Reset status + ; Reset status jsr kernalstatus_reset - // Check if the logical file number is unique + ; Check if the logical file number is unique ldy LDTND -!: - beq !+ +@1: + beq @3 dey lda LAT, y cmp LA - bne open_not_yet_open + bne @2 jmp kernalerror_FILE_ALREADY_OPEN -open_not_yet_open: +@2: ; not yet open + cpy #$00 - jmp !- -!: - // Check if we have space in tables + jmp @1 +@3: + ; Check if we have space in tables ldy LDTND cpy #$0A bcc open_has_space -!: - // Table is full + + ; Table is full jmp kernalerror_TOO_MANY_OPEN_FILES open_has_space: - // Update the tables + ; Update the tables - // LAT / FAT / SAT support implemented according to - // 'Computes Mapping the Commodore 64', page 52 + ; LAT / FAT / SAT support implemented according to + ; 'Computes Mapping the Commodore 64', page 52 lda LA sta LAT, y @@ -59,21 +60,18 @@ open_has_space: lda FA -#if HAS_RS232 +!ifdef HAS_RS232 { cmp #$02 - beq_16 open_rs232 + +beq open_rs232 +} -#endif - -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_oc - bcc_16 open_iec - -#endif - - // FALLTROUGH + +bcc open_iec +} + ; FALLTROUGH open_done_success: diff --git a/src/kernal/iostack/f49e.load_prep.s b/src/kernal/iostack/f49e.load_prep.s index 6d71806c..cb7e6401 100644 --- a/src/kernal/iostack/f49e.load_prep.s +++ b/src/kernal/iostack/f49e.load_prep.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// LOAD preparation routine -// +; +; LOAD preparation routine +; -// -// Input (according to http://sta.c64.org/cbm64krnfunc.html) -// .A - 0 for load, non-0 for verify -// .X and .Y - load address (if secondary address is 0) -// +; +; Input (according to http://sta.c64.org/cbm64krnfunc.html) +; .A - 0 for load, non-0 for verify +; .X and .Y - load address (if secondary address is 0) +; -// -// Note: Although the vector at $330 points to $F4A5, the Kernal jump table points to $F49E -// (see also Mapping the C64, page 76). By experimenting I have discovered that $F49E performs -// indirect jump via ($0330) vector, after setting MEMUSS. -// +; +; Note: Although the vector at $330 points to $F4A5, the Kernal jump table points to $F49E +; (see also Mapping the C64, page 76). By experimenting I have discovered that $F49E performs +; indirect jump via ($0330) vector, after setting MEMUSS. +; LOAD_PREP: diff --git a/src/kernal/iostack/f4a5.load.s b/src/kernal/iostack/f4a5.load.s index ac201c15..43b511a5 100644 --- a/src/kernal/iostack/f4a5.load.s +++ b/src/kernal/iostack/f4a5.load.s @@ -1,74 +1,72 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 286 -// - [CM64] Computes Mapping the Commodore 64 - page 231 -// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 286 +; - [CM64] Computes Mapping the Commodore 64 - page 231 +; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +; +; CPU registers that has to be preserved (see [RG64]): none +; - // Expects that SETLFS and SETNAM are called before hand. - // $YYXX = load address. - // (ignored if SETLFS channel = 1, i.e., like ,8,1) - // If A=1 then VERIFY instead of LOAD. - // On exit, $YYXX is the highest address into which data - // will have been placed. + ; Expects that SETLFS and SETNAM are called before hand. + ; $YYXX = load address. + ; (ignored if SETLFS channel = 1, i.e., like ,8,1) + ; If A=1 then VERIFY instead of LOAD. + ; On exit, $YYXX is the highest address into which data + ; will have been placed. LOAD: - // Are we loading or verifying? + ; Are we loading or verifying? sta VERCKK - // Store start address of LOAD + ; Store start address of LOAD lda MEMUSS+0 sta STAL+0 lda MEMUSS+1 sty STAL+1 - // Reset status + ; Reset status jsr kernalstatus_reset -#if CONFIG_MEMORY_MODEL_60K - // We need our helpers to get to filenames under ROMs or IO area +!ifdef CONFIG_MEMORY_MODEL_60K { + ; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines -#endif +} - // Check whether we support the requested device + ; Check whether we support the requested device lda FA -#if !CONFIG_TAPE_AUTODETECT +!ifndef CONFIG_TAPE_AUTODETECT { -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { cmp #$01 - beq_16 load_tape_normal -#endif -#if CONFIG_TAPE_TURBO + +beq load_tape_normal +} +!ifdef CONFIG_TAPE_TURBO { cmp #$07 - beq_16 load_tape_turbo -#endif + +beq load_tape_turbo +} -#else // CONFIG_TAPE_AUTODETECT +} else { ; CONFIG_TAPE_AUTODETECT cmp #$01 - beq_16 load_tape_auto + +beq load_tape_auto cmp #$07 - beq_16 load_tape_auto - -#endif + +beq load_tape_auto +} -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_lvs - bcc_16 load_iec -#endif - + +bcc load_iec +} jmp lvs_illegal_device_number diff --git a/src/kernal/iostack/f5dd.save_prep.s b/src/kernal/iostack/f5dd.save_prep.s index be34baea..b197e498 100644 --- a/src/kernal/iostack/f5dd.save_prep.s +++ b/src/kernal/iostack/f5dd.save_prep.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// SAVE preparation routine -// +; +; SAVE preparation routine +; -// -// Input (according to http://sta.c64.org/cbm64krnfunc.html) -// .A - address of zero page register holding start address of memory area to save -// .X and .Y - end address of memory area plus 1 -// +; +; Input (according to http://sta.c64.org/cbm64krnfunc.html) +; .A - address of zero page register holding start address of memory area to save +; .X and .Y - end address of memory area plus 1 +; -// -// Note: Experimenting can easily confirm that SAVE preparation routine does similar -// actions as LOAD preparation routine. -// +; +; Note: Experimenting can easily confirm that SAVE preparation routine does similar +; actions as LOAD preparation routine. +; SAVE_PREP: diff --git a/src/kernal/iostack/f5ed.save.s b/src/kernal/iostack/f5ed.save.s index caf08d01..f3f65b27 100644 --- a/src/kernal/iostack/f5ed.save.s +++ b/src/kernal/iostack/f5ed.save.s @@ -1,33 +1,33 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 293/294 -// - [CM64] Computes Mapping the Commodore 64 - page 231/232 -// - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 293/294 +; - [CM64] Computes Mapping the Commodore 64 - page 231/232 +; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +; +; CPU registers that has to be preserved (see [RG64]): none +; SAVE: - // Reset status + ; Reset status jsr kernalstatus_reset -#if CONFIG_MEMORY_MODEL_60K - // We need our helpers to get to filenames under ROMs or IO area +!ifdef CONFIG_MEMORY_MODEL_60K { + ; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines -#endif +} - // Check whether we support the requested device + ; Check whether we support the requested device lda FA -#if CONFIG_IEC +!ifdef CONFIG_IEC { jsr iec_check_devnum_lvs - bcc_16 save_iec -#endif + +bcc save_iec +} jmp lvs_illegal_device_number diff --git a/src/kernal/iostack/findfls.s b/src/kernal/iostack/findfls.s index 52c04c5a..5ee50aaa 100644 --- a/src/kernal/iostack/findfls.s +++ b/src/kernal/iostack/findfls.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Just a helper routine +; Just a helper routine -// Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y -// Carry flag set means not found +; Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y +; Carry flag set means not found find_fls: ldy LDTND -!: +@1: dey - bmi find_fls_not_found // no more entries + bmi find_fls_not_found ; no more entries cmp LAT, y - bne !- // does not match, try the next one + bne @1 ; does not match, try the next one clc rts diff --git a/src/kernal/iostack/getin_real.s b/src/kernal/iostack/getin_real.s index 335c0319..e1826b55 100644 --- a/src/kernal/iostack/getin_real.s +++ b/src/kernal/iostack/getin_real.s @@ -1,31 +1,30 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 283 -// - [CM64] Computes Mapping the Commodore 64 - page 227/228 -// -// CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 283 +; - [CM64] Computes Mapping the Commodore 64 - page 227/228 +; +; CPU registers that has to be preserved (see [RG64]): for RS-232: .X, .Y +; getin_real: - // Determine the device number + ; Determine the device number lda DFLTN - // Try $00 - keyboard - beq_16 getin_keyboard + ; Try $00 - keyboard + +beq getin_keyboard -#if HAS_RS232 +!ifdef HAS_RS232 { - // Try $02 - RS-232 + ; Try $02 - RS-232 cmp #$02 - beq_16 getin_rs232 - -#endif // HAS_RS232 + +beq getin_rs232 +} jmp chrin_getin diff --git a/src/kernal/iostack/load_save_common.s b/src/kernal/iostack/load_save_common.s index 6c5dc73e..d40039f9 100644 --- a/src/kernal/iostack/load_save_common.s +++ b/src/kernal/iostack/load_save_common.s @@ -1,10 +1,10 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper functions for various LOAD/VERIFY/SAVE routine variants (IEC / U64 / etc.) -// +; +; Helper functions for various LOAD/VERIFY/SAVE routine variants (IEC / U64 / etc.) +; lvs_handle_byte_load_verify: @@ -12,14 +12,14 @@ lvs_handle_byte_load_verify: ldy VERCKK bne lvs_handle_byte_verify - // As with our BASIC, we want to enable LOADing - // anywhere in memory, including over the IO space. - // Thus we have to use a helper routine in low memory - // to do the memory access + ; As with our BASIC, we want to enable LOADing + ; anywhere in memory, including over the IO space. + ; Thus we have to use a helper routine in low memory + ; to do the memory access -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // Save byte under ROMs and IO if required + ; Save byte under ROMs and IO if required php sei ldx #$33 @@ -30,14 +30,13 @@ lvs_handle_byte_load_verify: stx $01 plp -#else +} else { ldy #0 sta (EAL),y +} -#endif - - // FALLTROUGH + ; FALLTROUGH lvs_handle_byte_load_verify_end: @@ -47,12 +46,12 @@ lvs_handle_byte_load_verify_end: lvs_handle_byte_verify: -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { - // Store byte for comparing + ; Store byte for comparing sta TBTCNT - // Retrieve byte from under ROMs and IO if required + ; Retrieve byte from under ROMs and IO if required php sei ldx #$33 @@ -63,33 +62,32 @@ lvs_handle_byte_verify: stx $01 plp - // Compare with stored byte + ; Compare with stored byte cmp TBTCNT -#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K +} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K { - // Store byte for comparing + ; Store byte for comparing sta TBTCNT ldy #0 jsr peek_under_roms_via_EAL - // Compare with stored byte + ; Compare with stored byte cmp TBTCNT -#else // CONFIG_MEMORY_MODEL_38K +} else { ; CONFIG_MEMORY_MODEL_38K ldy #0 cmp (EAL),y - -#endif +} beq lvs_handle_byte_load_verify_end sec rts -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC +!ifdef HAS_TAPE_OR_IEC { lvs_STAL_to_MEMUSS: @@ -99,33 +97,28 @@ lvs_STAL_to_MEMUSS: sta MEMUSS+1 rts -#endif - -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC - -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { lvs_advance_MEMUSS: - // Advance pointer + ; Advance pointer inc MEMUSS+0 - bne !+ + bne @1 inc MEMUSS+1 -!: +@1: rts - -#endif +} lvs_check_EAL: lda MEMUSS+1 cmp EAL+1 - bne !+ + bne @2 lda MEMUSS+0 cmp EAL+0 -!: +@2: rts @@ -138,22 +131,22 @@ lvs_display_searching_for: jsr print_kernal_message ldy #$00 -!: +@3: cpy FNLEN beq lvs_display_end -#if CONFIG_MEMORY_MODEL_60K +!ifdef CONFIG_MEMORY_MODEL_60K { ldx #__kb_matrix_shift // up - .byte >__kb_matrix_normal // down - .byte >__kb_matrix_shift // left - .byte >__kb_matrix_normal // right + !byte >__kb_matrix_shift ; up + !byte >__kb_matrix_normal ; down + !byte >__kb_matrix_shift ; left + !byte >__kb_matrix_normal ; right -#endif +} } diff --git a/src/kernal/keyboard/kb_matrix_lookup.s b/src/kernal/keyboard/kb_matrix_lookup.s index bb82cf2c..b320f0ae 100644 --- a/src/kernal/keyboard/kb_matrix_lookup.s +++ b/src/kernal/keyboard/kb_matrix_lookup.s @@ -1,27 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper table for determining keyboard matrix decoding table on the C64 keyboard -// -// When more than one bucky keey is pressed, decoding keys is asking for trouble, -// so never allow this. -// +; +; Helper table for determining keyboard matrix decoding table on the C64 keyboard +; +; When more than one bucky keey is pressed, decoding keys is asking for trouble, +; so never allow this. +; -#if !CONFIG_LEGACY_SCNKEY +!ifndef CONFIG_LEGACY_SCNKEY { kb_matrix_lookup: - .byte (__kb_matrix_normal - kb_matrix) // %000 Normal - .byte (__kb_matrix_shift - kb_matrix) // %001 SHIFT - .byte (__kb_matrix_vendor - kb_matrix) // %010 VENDOR - .byte $FF // %011 SHIFT+VENDOR - .byte (__kb_matrix_ctrl - kb_matrix) // %100 CTRL - .byte $FF // %101 SHIFT+CTRL - .byte $FF // %110 VENDOR+CTRL - .byte $FF // %111 SHIFT+VENDOR+CTRL - -#endif + !byte (__kb_matrix_normal - kb_matrix) ; %000 Normal + !byte (__kb_matrix_shift - kb_matrix) ; %001 SHIFT + !byte (__kb_matrix_vendor - kb_matrix) ; %010 VENDOR + !byte $FF ; %011 SHIFT+VENDOR + !byte (__kb_matrix_ctrl - kb_matrix) ; %100 CTRL + !byte $FF ; %101 SHIFT+CTRL + !byte $FF ; %110 VENDOR+CTRL + !byte $FF ; %111 SHIFT+VENDOR+CTRL +} \ No newline at end of file diff --git a/src/kernal/keyboard/kb_matrix_lookup_legacy.s b/src/kernal/keyboard/kb_matrix_lookup_legacy.s index da4df653..1d1ddaa2 100644 --- a/src/kernal/keyboard/kb_matrix_lookup_legacy.s +++ b/src/kernal/keyboard/kb_matrix_lookup_legacy.s @@ -1,32 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Work out if normal, shifted, control or Vendor modified keyboard. -// Table contains the offsets into keyboard_matrixes that should be used -// for different values of the bottom 3 bits of key_bucky_state XXX -// Interaction is simple to work out when playing with a C64: -// CTRL trumps SHIFT or VENDOR -// VENDOR + SHIFT = DOES NOTHING -// All 3 does CONTROL -// +; +; Work out if normal, shifted, control or Vendor modified keyboard. +; Table contains the offsets into keyboard_matrixes that should be used +; for different values of the bottom 3 bits of key_bucky_state XXX +; Interaction is simple to work out when playing with a C64: +; CTRL trumps SHIFT or VENDOR +; VENDOR + SHIFT = DOES NOTHING +; All 3 does CONTROL +; -// This lookup table is used by TWW/CTR keyboard routine only! +; This lookup table is used by TWW/CTR keyboard routine only! -#if CONFIG_LEGACY_SCNKEY +!ifdef CONFIG_LEGACY_SCNKEY { kb_matrix_lookup: - .byte $00 // Normal - .byte $40 // Shifted - .byte $80 // Control - .byte $80 // Control + SHIFT - .byte $C0 // Vendor - .byte $C0 // Vendor + SHIFT - .byte $80 // Vendor + CTRL - .byte $80 // Vendor + CTRL + SHIFT - -#endif // CONFIG_LEGACY_SCNKEY + !byte $00 ; Normal + !byte $40 ; Shifted + !byte $80 ; Control + !byte $80 ; Control + SHIFT + !byte $C0 ; Vendor + !byte $C0 ; Vendor + SHIFT + !byte $80 ; Vendor + CTRL + !byte $80 ; Vendor + CTRL + SHIFT +} diff --git a/src/kernal/keyboard/kb_matrix_row_keys.s b/src/kernal/keyboard/kb_matrix_row_keys.s index ce225e80..e74f02db 100644 --- a/src/kernal/keyboard/kb_matrix_row_keys.s +++ b/src/kernal/keyboard/kb_matrix_row_keys.s @@ -1,33 +1,32 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Single row key codes for scanning the C64 keyboard -// -// Values based on: -// - [CM64] Computes Mapping the Commodore 64 - pags 58 (SHFLAG), 173 (matrix) -// +; +; Single row key codes for scanning the C64 keyboard +; +; Values based on: +; - [CM64] Computes Mapping the Commodore 64 - pags 58 (SHFLAG), 173 (matrix) +; -#if !CONFIG_LEGACY_SCNKEY +!ifndef CONFIG_LEGACY_SCNKEY { kb_matrix_row_keys: - // - values for CIA1_PRA to connect only the given row - // - first 3 values also meant for VIC_XSCAN for C128 keyboards - // - also used to scan a single row + ; - values for CIA1_PRA to connect only the given row + ; - first 3 values also meant for VIC_XSCAN for C128 keyboards + ; - also used to scan a single row - .byte %11111110 - .byte %11111101 - .byte %11111011 - .byte %11110111 - .byte %11101111 - .byte %11011111 - .byte %10111111 - .byte %01111111 + !byte %11111110 + !byte %11111101 + !byte %11111011 + !byte %11110111 + !byte %11101111 + !byte %11011111 + !byte %10111111 + !byte %01111111 - -#endif // no CONFIG_LEGACY_SCNKEY +} ; no CONFIG_LEGACY_SCNKEY diff --git a/src/kernal/keyboard/kb_matrix_row_offsets.s b/src/kernal/keyboard/kb_matrix_row_offsets.s index 314a0852..6a59df0d 100644 --- a/src/kernal/keyboard/kb_matrix_row_offsets.s +++ b/src/kernal/keyboard/kb_matrix_row_offsets.s @@ -1,27 +1,26 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper values to quickly determine row offset from the start of keyboard matrix -// +; +; Helper values to quickly determine row offset from the start of keyboard matrix +; -#if !CONFIG_LEGACY_SCNKEY +!ifndef CONFIG_LEGACY_SCNKEY { kb_matrix_row_offsets: - // - offsets (in bytes) to the first bytes of keyboard matrix rows + ; - offsets (in bytes) to the first bytes of keyboard matrix rows - .byte 0*8 - .byte 1*8 - .byte 2*8 - .byte 3*8 - .byte 4*8 - .byte 5*8 - .byte 6*8 - .byte 7*8 - -#endif // no CONFIG_LEGACY_SCNKEY + !byte 0*8 + !byte 1*8 + !byte 2*8 + !byte 3*8 + !byte 4*8 + !byte 5*8 + !byte 6*8 + !byte 7*8 +} diff --git a/src/kernal/keyboard/keyboard_disconnect.s b/src/kernal/keyboard/keyboard_disconnect.s index 98c0150b..416ed33a 100644 --- a/src/kernal/keyboard/keyboard_disconnect.s +++ b/src/kernal/keyboard/keyboard_disconnect.s @@ -1,26 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine - disconnects the keyboard from CIA1_PRB, -// leaves $FF in .X (behavior needed in some places) -// +; +; Helper routine - disconnects the keyboard from CIA1_PRB, +; leaves $FF in .X (behavior needed in some places) +; -#if !CONFIG_LEGACY_SCNKEY +!ifndef CONFIG_LEGACY_SCNKEY { keyboard_disconnect: ldx #$FF - stx CIA1_PRA // disconnect all the rows -#if CONFIG_KEYBOARD_C128 + stx CIA1_PRA ; disconnect all the rows +!ifdef CONFIG_KEYBOARD_C128 { stx VIC_XSCAN -#endif +} rts - - -#endif +} diff --git a/src/kernal/keyboard/scnkey.s b/src/kernal/keyboard/scnkey.s index 50965ea7..5560f22d 100644 --- a/src/kernal/keyboard/scnkey.s +++ b/src/kernal/keyboard/scnkey.s @@ -1,282 +1,276 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 295 -// - [CM64] Computes Mapping the Commodore 64 - page 220 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 295 +; - [CM64] Computes Mapping the Commodore 64 - page 220 +; +; CPU registers that has to be preserved (see [RG64]): none +; -// Variables used: -// - KEYTAB - keyboard matrix pointer -// - DELAY - counter for first delay between key repeats -// - KOUNT - counter for next delays between key repeats -// - SHFLAG - SHIFT / CTRL / VENDOR keypress status -// - NDX - number of characters in keyboard buffer -// - XMAX - maximum size of keyboard buffer -// - LSTX - matrix coordinate of last pressed key -// - LSTSHF - previous status of SHFLAG -// - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed -// - RPTFLG - whether key repeat is allowed +; Variables used: +; - KEYTAB - keyboard matrix pointer +; - DELAY - counter for first delay between key repeats +; - KOUNT - counter for next delays between key repeats +; - SHFLAG - SHIFT / CTRL / VENDOR keypress status +; - NDX - number of characters in keyboard buffer +; - XMAX - maximum size of keyboard buffer +; - LSTX - matrix coordinate of last pressed key +; - LSTSHF - previous status of SHFLAG +; - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed +; - RPTFLG - whether key repeat is allowed -#if !CONFIG_LEGACY_SCNKEY +!ifndef CONFIG_LEGACY_SCNKEY { -// Routine takes some ideas from TWW/CTR proposal, see here: -// - http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way +; Routine takes some ideas from TWW/CTR proposal, see here: +; - http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way SCNKEY: - // Prepare for SHFLAG update + ; Prepare for SHFLAG update lda SHFLAG sta LSTSHF lda #$00 sta SHFLAG -#if !CONFIG_JOY2_CURSOR && CONFIG_KEY_FAST_SCAN +!ifndef CONFIG_JOY2_CURSOR { !ifdef CONFIG_KEY_FAST_SCAN { - // Check for any activity - speed optimization, but cannot be done - // that early if we are to scan the joystick #2 + ; Check for any activity - speed optimization, but cannot be done + ; that early if we are to scan the joystick #2 ldx #$00 - stx CIA1_PRA // connect all the rows -#if CONFIG_KEYBOARD_C128 + stx CIA1_PRA ; connect all the rows +!ifdef CONFIG_KEYBOARD_C128 { stx VIC_XSCAN -#endif - dex // puts $FF +} + dex ; puts $FF cpx CIA1_PRB beq scnkey_no_keys -#endif +} } - // Retrieve SHIFT / VENDOR / CTRL / ALT / CAPS LOCK status + ; Retrieve SHIFT / VENDOR / CTRL / ALT / CAPS LOCK status -#if CONFIG_KEYBOARD_C128_CAPS_LOCK +!ifdef CONFIG_KEYBOARD_C128_CAPS_LOCK { - // First check if this is really a C128 - to avoid false positive + ; First check if this is really a C128 - to avoid false positive ldx #$00 stx VIC_XSCAN - dex // puts $FF + dex ; puts $FF cpx VIC_XSCAN - beq !+ // branch if C64, C128 will keep some bits cleared + beq @1 ; branch if C64, C128 will keep some bits cleared lda CPU_R6510 and #$40 - bne !+ // branch if no CAPS LOCK + bne @1 ; branch if no CAPS LOCK lda #KEY_CAPS_LOCK sta SHFLAG -!: +@1: -#if !CONFIG_KEYBOARD_C128 - stx VIC_XSCAN // disconnect C128 keys if no C128 keyboard is supported -#endif +!ifndef !CONFIG_KEYBOARD_C128 { + stx VIC_XSCAN ; disconnect C128 keys if no C128 keyboard is supported +} } -#endif - -#if CONFIG_KEYBOARD_C65_CAPS_LOCK +!ifdef CONFIG_KEYBOARD_C65_CAPS_LOCK { lda C65_EXTKEYS_PR and #$01 - bne !+ // branch if no CAPS LOCK + bne @2 ; branch if no CAPS LOCK lda #KEY_CAPS_LOCK sta SHFLAG -!: +@2: -#if !CONFIG_KEYBOARD_C65 +!ifndef CONFIG_KEYBOARD_C65 { ldx #$FF - stx C65_EXTKEYS_PR // disconnect C128 keys if no C128 keyboard is supported -#endif - -#endif + stx C65_EXTKEYS_PR ; disconnect C65 keys if no C65 keyboard is supported +} } ldy #(__kb_matrix_bucky_confmask_end - kb_matrix_bucky_confmask - 1) scnkey_bucky_loop: lda kb_matrix_bucky_confmask, y sta CIA1_PRA -#if CONFIG_KEYBOARD_C128 +!ifdef CONFIG_KEYBOARD_C128 { lda kb_matrix_bucky_confmask_c128, y sta VIC_XSCAN -#endif -#if CONFIG_KEYBOARD_C65 +} +!ifdef CONFIG_KEYBOARD_C65 { lda kb_matrix_bucky_confmask_c65, y sta C65_EXTKEYS_PR -#endif +} lda kb_matrix_bucky_testmask, y and CIA1_PRB - bne !+ // branch if not pressed + bne @3 ; branch if not pressed lda SHFLAG ora kb_matrix_bucky_shflag, y sta SHFLAG -!: +@3: dey bpl scnkey_bucky_loop - // Set KEYTAB vector + ; Set KEYTAB vector lda KEYLOG+1 - bne !+ - jsr scnkey_set_keytab // KEYLOG routine on zeropage? most likely vector not set - jmp_8 scnkey_keytab_set_done + bne @11 + jsr scnkey_set_keytab ; KEYLOG routine on zeropage? most likely vector not set + +bra scnkey_keytab_set_done -!: -#if HAS_OPCODES_65CE02 - jsr_ind KEYLOG -#else +@11: +!ifdef HAS_OPCODES_65CE02 { + jsr (KEYLOG) +} else { jsr scnkey_via_keylog -#endif +} scnkey_keytab_set_done: -#if CONFIG_JOY2_CURSOR +!ifdef CONFIG_JOY2_CURSOR { - // Check for control port 2 activity + ; Check for control port 2 activity ldx #$00 - stx CIA1_DDRA // set port to input to read joystick + stx CIA1_DDRA ; set port to input to read joystick - lda CIA1_PRA // read the joystick 2 status + lda CIA1_PRA ; read the joystick 2 status - dex // puts $FF - stx CIA1_DDRA // set port back to output + dex ; puts $FF + stx CIA1_DDRA ; set port back to output - and #%00001111 // filter out anything but joystick movement + and #%00001111 ; filter out anything but joystick movement cmp #%00001111 bne scnkey_joystick_filtered -#if CONFIG_KEY_FAST_SCAN +!ifdef CONFIG_KEY_FAST_SCAN { - inx // puts $00 - stx CIA1_PRA // connect all the rows -#if CONFIG_KEYBOARD_C128 + inx ; puts $00 + stx CIA1_PRA ; connect all the rows +!ifdef CONFIG_KEYBOARD_C128 { stx VIC_XSCAN -#endif -#if CONFIG_KEYBOARD_C65 +} +!ifdef CONFIG_KEYBOARD_C65 { stx C65_EXTKEYS_PR -#endif - dex // puts $FF +} + dex ; puts $FF cpx CIA1_PRB beq scnkey_no_keys -#endif // CONFIG_KEY_FAST_SCAN +} ; CONFIG_KEY_FAST_SCAN +} ; CONFIG_JOY2_CURSOR -#endif // CONFIG_JOY2_CURSOR + ; Check for control port 1 activity (can interfere with keyboard) - // Check for control port 1 activity (can interfere with keyboard) + jsr keyboard_disconnect ; disconnect all the rows, .X will be $FF + cpx CIA1_PRB ; only control port activity will be reported +!ifdef CONFIG_JOY1_CURSOR { + bne scnkey_joystick_1 ; use joystick for cursor keys +} else { + bne scnkey_no_keys ; if activity detected do not scan the keyboard +} - jsr keyboard_disconnect // disconnect all the rows, .X will be $FF - cpx CIA1_PRB // only control port activity will be reported -#if CONFIG_JOY1_CURSOR - bne scnkey_joystick_1 // use joystick for cursor keys -#else - bne scnkey_no_keys // if activity detected do not scan the keyboard -#endif - - // Check if KEYTAB is not 0 (happens if more than one bucky key is pressed) - // High byte equal to 0 = table considered invalid + ; Check if KEYTAB is not 0 (happens if more than one bucky key is pressed) + ; High byte equal to 0 = table considered invalid lda KEYTAB+1 beq scnkey_no_keys - // Scan the keyboard matrix + ; Scan the keyboard matrix - ldy #$FF // offset in key matrix table, $FF for not found yet -#if CONFIG_KEYBOARD_C128 + ldy #$FF ; offset in key matrix table, $FF for not found yet +!ifdef CONFIG_KEYBOARD_C128 { jsr scnkey_128 -#endif -#if CONFIG_KEYBOARD_C65 +} +!ifdef CONFIG_KEYBOARD_C65 { jsr scnkey_65 -#endif +} ldx #$07 scnkey_matrix_loop: lda kb_matrix_row_keys, x sta CIA1_PRA - lda kb_matrix_bucky_filter, x // filter out bucky keys + lda kb_matrix_bucky_filter, x ; filter out bucky keys ora CIA1_PRB cmp #$FF - beq scnkey_matrix_loop_next // skip if no key pressed from this row + beq scnkey_matrix_loop_next ; skip if no key pressed from this row cpy #$FF - bne scnkey_no_keys // jam, more than one key pressed - // We have at least one key pressed in this row, we need to find which one exactly + bne scnkey_no_keys ; jam, more than one key pressed + ; We have at least one key pressed in this row, we need to find which one exactly ldy #$07 scnkey_matrix_loop_inner: cmp kb_matrix_row_keys, y - bne !+ // not this particular key - tya // now .A contains key offset within a row + bne @4 ; not this particular key + tya ; now .A contains key offset within a row clc - adc kb_matrix_row_offsets, x // now .A contains key offset from the matrix start + adc kb_matrix_row_offsets, x ; now .A contains key offset from the matrix start tay jmp scnkey_matrix_loop_next -!: +@4: dey bpl scnkey_matrix_loop_inner - bmi scnkey_no_keys // branch always, multiple keys must have been pressed + bmi scnkey_no_keys ; branch always, multiple keys must have been pressed scnkey_matrix_loop_next: dex bpl scnkey_matrix_loop - // Scanning complete - check if we got a key + ; Scanning complete - check if we got a key cpy #$FF beq scnkey_no_keys - // To be extra sure, check for possible control port 1 interference once again + ; To be extra sure, check for possible control port 1 interference once again - jsr keyboard_disconnect // disconnect all the rows, .X will be $FF - cpx CIA1_PRB // only control port activity will be reported - beq scnkey_got_key // branch if joystick activity NOT detected + jsr keyboard_disconnect ; disconnect all the rows, .X will be $FF + cpx CIA1_PRB ; only control port activity will be reported + beq scnkey_got_key ; branch if joystick activity NOT detected - // FALLTROUGH + ; FALLTROUGH scnkey_no_keys: - // Mark no key press + ; Mark no key press lda #$40 sta LSTX rts -#if CONFIG_JOY1_CURSOR +!ifdef CONFIG_JOY1_CURSOR { scnkey_joystick_1: - // Prepare joystick 1 status + ; Prepare joystick 1 status lda CIA1_PRB - and #%00001111 // filter out anything but movement + and #%00001111 ; filter out anything but movement - // FALLTROUGH + ; FALLTROUGH +} -#endif - -#if CONFIG_JOY1_CURSOR || CONFIG_JOY2_CURSOR +!ifdef CONFIG_JOY1_OR_JOY2_CURSOR { scnkey_joystick_filtered: - // Set appropriate keyboard matrix and key code for joystick event + ; Set appropriate keyboard matrix and key code for joystick event ldy #$03 -!: +@5: cmp kb_matrix_joy_status, y - beq !+ + beq @6 dey - bpl !- + bpl @5 - // Not found + ; Not found rts -!: - // Found +@6: + ; Found lda kb_matrix_joy_keytab_lo, y sta KEYTAB+0 @@ -285,65 +279,64 @@ scnkey_joystick_filtered: lda kb_matrix_joy_keytab_idx, y tay - // FALLTROUGH + ; FALLTROUGH +} -#endif - -scnkey_got_key: // .Y should now contain the key offset in matrix pointed by KEYTAB +scnkey_got_key: ; .Y should now contain the key offset in matrix pointed by KEYTAB cpy LSTX - beq scnkey_try_repeat // branch if the same key as previously + beq scnkey_try_repeat ; branch if the same key as previously sty LSTX - // Reset key repeat counters - see [CM64] page 58 + ; Reset key repeat counters - see [CM64] page 58 - // Note: according to [CM64] it should be $10 for initializing DELAY, $06 for - // initializing KOUNT for the first time and $04 for subsequent ones - but replicating - // this would make our implementation longer, probably without improving the compatibility. - // - // Besides - since I am the one who writes the code, I will make the values exactly how I like them :D + ; Note: according to [CM64] it should be $10 for initializing DELAY, $06 for + ; initializing KOUNT for the first time and $04 for subsequent ones - but replicating + ; this would make our implementation longer, probably without improving the compatibility. + ; + ; Besides - since I am the one who writes the code, I will make the values exactly how I like them :D -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { lda #$16 -#else +} else { lda #$18 -#endif +} sta DELAY - // FALLTROUGH + ; FALLTROUGH scnkey_output_key: - // Check if we have free space in the keyboard buffer + ; Check if we have free space in the keyboard buffer lda NDX cmp XMAX - bcs scnkey_early_repeat // no space in buffer + bcs scnkey_early_repeat ; no space in buffer - // Reinitialize secondary counter + ; Reinitialize secondary counter lda #$03 sta KOUNT - // Retrieve the PETSCII code + ; Retrieve the PETSCII code -#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 +!ifdef CONFIG_KEYBOARD_C128_OR_C65 { cpy #$40 - bcc !+ + bcc scnkey_output_get_keycode -#if CONFIG_KEYBOARD_C128 - lda kb_matrix_128 - $41, y // retrieve key code from C128 extended matrix -#elif CONFIG_KEYBOARD_C65 +!ifdef CONFIG_KEYBOARD_C128 { + lda kb_matrix_128 - $41, y ; retrieve key code from C128 extended matrix +} else ifdef CONFIG_KEYBOARD_C65 { - // Select key matrix (normal or shifted) for extended C65 keys + ; Select key matrix (normal or shifted) for extended C65 keys lda SHFLAG - and #%00000111 // KEY_FLAG_SHIFT + KEY_FLAG_VENDOR + KEY_FLAG_CTRL + and #%00000111 ; KEY_FLAG_SHIFT + KEY_FLAG_VENDOR + KEY_FLAG_CTRL beq scnkey_output_65_no_shift cmp #KEY_FLAG_SHIFT - // XXX how to behave on VENDOR/CTRL key? Harmonize this with claasic keys behavior - bne scnkey_no_keys // no scanning for this bucky key combination + ; XXX how to behave on VENDOR/CTRL key? Harmonize this with clasic keys behavior + bne scnkey_no_keys ; no scanning for this bucky key combination lda kb_matrix_65_shifted - $41, y jmp scnkey_got_petscii @@ -351,76 +344,79 @@ scnkey_output_key: scnkey_output_65_no_shift: lda kb_matrix_65 - $41, y +} -#endif jmp scnkey_got_petscii -!: - lda (KEYTAB), y // retrieve key code from standard matrix -#endif // CONFIG_KEYBOARD_C128 or CONFIG_KEYBOARD_C65 + ; FALLTROUGH -#if CONFIG_KEYBOARD_C128_CAPS_LOCK || CONFIG_KEYBOARD_C65_CAPS_LOCK +scnkey_output_get_keycode: - // Check if we need special handling for a CAPS LOCK key - // This is shorter than a separate set of tables + lda (KEYTAB), y ; retrieve key code from standard matrix + +} ; CONFIG_KEYBOARD_C128 or CONFIG_KEYBOARD_C65 + +!ifdef CONFIG_KEYBOARD_CAPS_LOCK { + + ; Check if we need special handling for a CAPS LOCK key + ; This is shorter than a separate set of tables scnkey_handle_caps_lock: -#if !CONFIG_KEYBOARD_C128 && !CONFIG_KEYBOARD_C65 +!ifndef CONFIG_KEYBOARD_C128_OR_C65 { lda (KEYTAB), y -#endif +} tax lda SHFLAG and #(%00000111 + KEY_CAPS_LOCK) cmp #KEY_CAPS_LOCK - bne !+ // branch if no special CAPS LOCK handling needed + bne @7 ; branch if no special CAPS LOCK handling needed - cpx #$41 // 'A' - bcc !+ - cpx #$5B // 'Z' + 1 - bcs !+ + cpx #$41 ; 'A' + bcc @7 + cpx #$5B ; 'Z' + 1 + bcs @7 txa clc - adc #$20 // turn lowercase into uppercase + adc #$20 ; turn lowercase into uppercase tax -!: +@7: txa -#endif // CONFIG_KEYBOARD_C128_CAPS_LOCK or CONFIG_KEYBOARD_C65_CAPS_LOCK +} ; CONFIG_KEYBOARD_C128_CAPS_LOCK or CONFIG_KEYBOARD_C65_CAPS_LOCK -#if !CONFIG_KEYBOARD_C128 && !CONFIG_KEYBOARD_C128_CAPS_LOCK && !CONFIG_KEYBOARD_C65 && !CONFIG_KEYBOARD_C65_CAPS_LOCK +!ifndef CONFIG_KEYBOARD_C128_OR_C65 { !ifndef CONFIG_KEYBOARD_CAPS_LOCK { lda (KEYTAB), y +} } -#endif - - // Output PETSCII code to the keyboard buffer + ; Output PETSCII code to the keyboard buffer scnkey_got_petscii: -#if CONFIG_KEYBOARD_C128 && CONFIG_EDIT_TABULATORS +!ifdef CONFIG_KEYBOARD_C128 { !ifdef CONFIG_EDIT_TABULATORS { - // Special handling for SHIFT+TAB; it is easier than creating new matrix + ; Special handling for SHIFT+TAB; it is easier than creating new matrix tax cmp #KEY_C64_TAB_FW - bne !+ + bne @8 lda SHFLAG and #KEY_FLAG_SHIFT - beq !+ + beq @8 ldx #KEY_C64_TAB_BW -!: +@8: txa -#endif // CONFIG_KEYBOARD_C128 and CONFIG_EDIT_TABULATORS +} } ; CONFIG_KEYBOARD_C128 and CONFIG_EDIT_TABULATORS - beq scnkey_no_keys // branch if we have no PETSCII code for this key + beq scnkey_no_keys ; branch if we have no PETSCII code for this key ldy NDX sta KEYD, y inc NDX - // FALLTROUGH + ; FALLTROUGH scnkey_done: @@ -428,46 +424,46 @@ scnkey_done: scnkey_try_repeat: -#if !CONFIG_KEY_REPEAT_ALWAYS +!ifndef CONFIG_KEY_REPEAT_ALWAYS { - // Check whether we should repeat keys - first the flag, afterwards hardcoded list + ; Check whether we should repeat keys - first the flag, afterwards hardcoded list lda RPTFLG - bmi scnkey_handle_repeat // branch if we should repeat always + bmi scnkey_handle_repeat ; branch if we should repeat always tya ldx #(__kb_matrix_alwaysrepeat_end - kb_matrix_alwaysrepeat - 1) -!: +@9: cmp kb_matrix_alwaysrepeat, x beq scnkey_handle_repeat dex - bpl !- + bpl @9 bmi scnkey_done scnkey_handle_repeat: -#endif // no CONFIG_KEY_REPEAT_ALWAYS +} ; no CONFIG_KEY_REPEAT_ALWAYS - // Countdown before first repeat + ; Countdown before first repeat lda DELAY - beq !+ + beq @10 dec DELAY rts -!: - // Countdown before subsequent repeats +@10: + ; Countdown before subsequent repeats lda KOUNT - beq scnkey_output_key // if second counter is also 0, we can repeat the key + beq scnkey_output_key ; if second counter is also 0, we can repeat the key dec KOUNT rts scnkey_early_repeat: - // Keyboard buffer was full - at least make sure the key - // will be repeated as soon as possible + ; Keyboard buffer was full - at least make sure the key + ; will be repeated as soon as possible lda #$00 sta DELAY @@ -475,4 +471,4 @@ scnkey_early_repeat: rts -#endif // no CONFIG_LEGACY_SCNKEY +} ; no CONFIG_LEGACY_SCNKEY diff --git a/src/kernal/keyboard/scnkey_128.s b/src/kernal/keyboard/scnkey_128.s index fd00cddc..07b11b21 100644 --- a/src/kernal/keyboard/scnkey_128.s +++ b/src/kernal/keyboard/scnkey_128.s @@ -1,71 +1,71 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Keyboard scanning routine extension for C128 keyboards -// -// - [CM128] Computes Mapping the Commodore 128 - pages 212 (SHFLAG), 290 (matrix) -// +; +; Keyboard scanning routine extension for C128 keyboards +; +; - [CM128] Computes Mapping the Commodore 128 - pages 212 (SHFLAG), 290 (matrix) +; -#if CONFIG_KEYBOARD_C128 && !CONFIG_LEGACY_SCNKEY +!ifdef CONFIG_KEYBOARD_C128 { !ifndef CONFIG_LEGACY_SCNKEY { -// Inlining this within SCNKEY would both overcomplicate the implementation -// and disrupt a lot of branches (they would cross the 127 bytes distance limit) +; Inlining this within SCNKEY would both overcomplicate the implementation +; and disrupt a lot of branches (they would cross the 127 bytes distance limit) -// .Y is now $FF - try to put there a key code from extended keyboard +; .Y is now $FF - try to put there a key code from extended keyboard scnkey_128: - sty CIA1_PRA // disconnect all the classic keys first + sty CIA1_PRA ; disconnect all the classic keys first ldx #$02 scnkey_matrix_128_loop: lda kb_matrix_row_keys, x sta VIC_XSCAN - lda kb_matrix_128_bucky_filter, x // filter out bucky keys + lda kb_matrix_128_bucky_filter, x ; filter out bucky keys ora CIA1_PRB cmp #$FF - beq scnkey_matrix_128_loop_next // skip if no key pressed from this row + beq scnkey_matrix_128_loop_next ; skip if no key pressed from this row cpy #$FF - bne scnkey_128_no_keys // jam, more than one key pressed - // We have at least one key pressed in this row, we need to find which one exactly + bne scnkey_128_no_keys ; jam, more than one key pressed + ; We have at least one key pressed in this row, we need to find which one exactly ldy #$07 scnkey_matrix_128_loop_inner: cmp kb_matrix_row_keys, y - bne !+ // not this particular key - tya // now .A contains key offset within a row + bne @1 ; not this particular key + tya ; now .A contains key offset within a row clc - adc kb_matrix_row_offsets, x // now .A contains key offset from the matrix start - adc #$41 // now .A contains offset after the standard matrix + adc kb_matrix_row_offsets, x ; now .A contains key offset from the matrix start + adc #$41 ; now .A contains offset after the standard matrix tay jmp scnkey_matrix_128_loop_next -!: +@1: dey bpl scnkey_matrix_128_loop_inner - bmi scnkey_128_no_keys // branch always, multiple keys must have been pressed + bmi scnkey_128_no_keys ; branch always, multiple keys must have been pressed scnkey_matrix_128_loop_next: dex bpl scnkey_matrix_128_loop - // Scanning the C128 keyboard part complete + ; Scanning the C128 keyboard part complete scnkey_128_done: - stx VIC_XSCAN // $FF, disconnects C128 keys + stx VIC_XSCAN ; $FF, disconnects C128 keys rts scnkey_128_no_keys: - pla // get rid of return address from the stack + pla ; get rid of return address from the stack pla - jmp scnkey_no_keys // pass controll to original routine + jmp scnkey_no_keys ; pass controll to original routine -#endif // CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY +} } ; CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY diff --git a/src/kernal/keyboard/scnkey_65.s b/src/kernal/keyboard/scnkey_65.s index 8518c837..6d000c2e 100644 --- a/src/kernal/keyboard/scnkey_65.s +++ b/src/kernal/keyboard/scnkey_65.s @@ -1,68 +1,68 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Keyboard scanning routine extension for C65 keyboards -// -// - [CM128] Computes Mapping the Commodore 128 - pages 212 (SHFLAG) -// - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt (matrix) -// +; +; Keyboard scanning routine extension for C65 keyboards +; +; - [CM128] Computes Mapping the Commodore 128 - pages 212 (SHFLAG) +; - https://github.com/MEGA65/c65-specifications/blob/master/c65manualupdated.txt (matrix) +; -#if CONFIG_KEYBOARD_C65 && !CONFIG_LEGACY_SCNKEY +!ifdef CONFIG_KEYBOARD_C65 { !ifndef CONFIG_LEGACY_SCNKEY { -// Inlining this within SCNKEY would both overcomplicate the implementation -// and disrupt a lot of branches (they would cross the 127 bytes distance limit) +; Inlining this within SCNKEY would both overcomplicate the implementation +; and disrupt a lot of branches (they would cross the 127 bytes distance limit) -// .Y is now $FF - try to put there a key code from extended keyboard +; .Y is now $FF - try to put there a key code from extended keyboard scnkey_65: - sty CIA1_PRA // disconnect classic keys + sty CIA1_PRA ; disconnect classic keys lda #$00 - sta C65_EXTKEYS_PR // connect C65 keys + sta C65_EXTKEYS_PR ; connect C65 keys - lda #%00000101 // filter out bucky keys: ALT, NO_SCRL + lda #%00000101 ; filter out bucky keys: ALT, NO_SCRL ora CIA1_PRB cmp #$FF - beq scnkey_65_done // skip if no key pressed from this row + beq scnkey_65_done ; skip if no key pressed from this row - // At least one key is pressed - decode it + ; At least one key is pressed - decode it ldy #$07 scnkey_matrix_65_loop: cmp kb_matrix_row_keys, y - bne !+ // not this particular key - tya // now .A contains key offset within a row + bne @1 ; not this particular key + tya ; now .A contains key offset within a row clc - adc kb_matrix_row_offsets, x // now .A contains key offset from the matrix start - adc #$41 // now .A contains offset after the standard matrix + adc kb_matrix_row_offsets, x ; now .A contains key offset from the matrix start + adc #$41 ; now .A contains offset after the standard matrix tay jmp scnkey_65_done -!: +@1: dey bpl scnkey_matrix_65_loop - // FALLTROUGH, multiple keys must have been pressed + ; FALLTROUGH, multiple keys must have been pressed scnkey_65_no_keys: - pla // get rid of return address from the stack + pla ; get rid of return address from the stack pla - jmp scnkey_no_keys // pass controll to original routine + jmp scnkey_no_keys ; pass controll to original routine scnkey_65_done: ldx #$FF - stx C65_EXTKEYS_PR // connect C65 keys + stx C65_EXTKEYS_PR ; connect C65 keys rts -#endif // CONFIG_KEYBOARD_C65 and no CONFIG_LEGACY_SCNKEY +} } ; CONFIG_KEYBOARD_C65 and no CONFIG_LEGACY_SCNKEY diff --git a/src/kernal/keyboard/scnkey_legacy.s b/src/kernal/keyboard/scnkey_legacy.s index d5ab27d2..38feccd1 100644 --- a/src/kernal/keyboard/scnkey_legacy.s +++ b/src/kernal/keyboard/scnkey_legacy.s @@ -1,124 +1,124 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 295 -// - [CM64] Computes Mapping the Commodore 64 - page 220 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 295 +; - [CM64] Computes Mapping the Commodore 64 - page 220 +; +; CPU registers that has to be preserved (see [RG64]): none +; -// NOTE: The code here is described as legacy, because the algorithm (although working very well) -// requires much more RAM than the original Kernal routine uses; without any form of extended -// RAM available to Open ROMs it will always be a serious compatibility risk. +; NOTE: The code here is described as legacy, because the algorithm (although working very well) +; requires much more RAM than the original Kernal routine uses; without any form of extended +; RAM available to Open ROMs it will always be a serious compatibility risk. -#if CONFIG_LEGACY_SCNKEY +!ifdef CONFIG_LEGACY_SCNKEY { -// Scan the keyboard.. -// Here we don't use the horrible buggy original routine, -// not just because of copyright. Instead, we use the -// nice one with joystick interference removal and -// key roll-over support from -// http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way +; Scan the keyboard.. +; Here we don't use the horrible buggy original routine, +; not just because of copyright. Instead, we use the +; nice one with joystick interference removal and +; key roll-over support from +; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Keyboard IO Routine -// ~~~~~~~~~~~~~~~~~~~ -// By: TWW/CTR +; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +; Keyboard IO Routine +; ~~~~~~~~~~~~~~~~~~~ +; By: TWW/CTR -// Information -// ~~~~~~~~~~~ -// The routine uses "2 Key rollower" or up to 3 if the key-combination doesen't induce shadowing. -// If 2 or 3 keys are pressed simultaneously (within 1 scan) a "No Activity" state has to occur before new valid keys are returned. -// RESTORE is not detectable and must be handled by NMI IRQ. -// SHIFT LOCK is not detected due to unreliability. +; Information +; ~~~~~~~~~~~ +; The routine uses "2 Key rollower" or up to 3 if the key-combination doesen't induce shadowing. +; If 2 or 3 keys are pressed simultaneously (within 1 scan) a "No Activity" state has to occur before new valid keys are returned. +; RESTORE is not detectable and must be handled by NMI IRQ. +; SHIFT LOCK is not detected due to unreliability. -// History: -// ~~~~~~~~ -// V3.0 - Hacked to pieces by PGS to work as KERNAL keyboard scan routine -// V2.5 - New test tool. -// Added return of error codes. -// Fixed a bug causing Buffer Overflow. -// Fixed a bug in Non Alphanumerical Flags from 2.0. -// V2.1 - Shortened the source by adding .for loops & Updated the header and some comments. -// Added "simultaneous keypress" check. -// V2.0 - Added return of non-Alphanumeric keys into X & Y-Registers. -// Small optimizations here and there. -// V1.1 - Unrolled code to make it faster and optimized other parts of it. -// Removed SHIFT LOCK scanning. -// V1.0 - First Working Version along with test tool. +; History: +; ~~~~~~~~ +; V3.0 - Hacked to pieces by PGS to work as KERNAL keyboard scan routine +; V2.5 - New test tool. +; Added return of error codes. +; Fixed a bug causing Buffer Overflow. +; Fixed a bug in Non Alphanumerical Flags from 2.0. +; V2.1 - Shortened the source by adding .for loops & Updated the header and some comments. +; Added "simultaneous keypress" check. +; V2.0 - Added return of non-Alphanumeric keys into X & Y-Registers. +; Small optimizations here and there. +; V1.1 - Unrolled code to make it faster and optimized other parts of it. +; Removed SHIFT LOCK scanning. +; V1.0 - First Working Version along with test tool. -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ - // Low memory variables + ; Low memory variables - // Reuse RS232 variables, since they should not be used by other things. - // Carefully avoid $A7 which is used by 64NET - .label KeyQuantity = $A8 // 1 byte - .label BufferNew = $A9 // 3 bytes - .label TempZP = $B6 // 1 byte - // These should be initialized in CINT to $FF - .label BufferQuantity = $B4 // 1 byte - .label BufferOld = $293 // 3 bytes - .label Buffer = $297 // 4 bytes + ; Reuse RS232 variables, since they should not be used by other things. + ; Carefully avoid $A7 which is used by 64NET + !addr KeyQuantity = $A8 ; 1 byte + !addr BufferNew = $A9 ; 3 bytes + !addr TempZP = $B6 ; 1 byte + ; These should be initialized in CINT to $FF + !addr BufferQuantity = $B4 ; 1 byte + !addr BufferOld = $293 ; 3 bytes + !addr Buffer = $297 ; 4 bytes - // $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20 - // and not used on C64, so safe for us to use, probably. - .label ScanResult = $250 // 8 bytes + ; $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20 + ; and not used on C64, so safe for us to use, probably. + !addr ScanResult = $250 ; 8 bytes - // Operational Variables - .const MaxKeyRollover = 3 + ; Operational Variables + !addr MaxKeyRollover = 3 SCNKEY: lda #$00 sta BufferQuantity - // Decrement key repeat timeout if non-zero + ; Decrement key repeat timeout if non-zero ldx KOUNT beq sk_start dec KOUNT sk_start: - // Call main keyboard scanning routine + ; Call main keyboard scanning routine jsr Main lda BufferQuantity beq no_keys_waiting - // Stuff each key pressed into the keyboard buffer + ; Stuff each key pressed into the keyboard buffer ldy #$00 -!: +@1: lda Buffer,y jsr accept_key iny cpy BufferQuantity - bne !- + bne @1 no_keys_waiting: rts accept_key: - // Work out what is new and needs to be added - // to the input buffer. - // Also update the bucky key status flags etc + ; Work out what is new and needs to be added + ; to the input buffer. + ; Also update the bucky key status flags etc cmp #$ff beq sk_nokey - // Got a key, turn it from matrix position to key value, - // and stuff it in the keyboard buffer + ; Got a key, turn it from matrix position to key value, + ; and stuff it in the keyboard buffer - // Convert matrix position to key code - // XXX - Add offset of $40, $80 or $C0 if shift, CONTROL or C= are held down + ; Convert matrix position to key code + ; XXX - Add offset of $40, $80 or $C0 if shift, CONTROL or C= are held down pha lda SHFLAG and #$7 @@ -128,10 +128,10 @@ accept_key: ora kb_matrix_lookup,x tax lda kb_matrix,x - // But don't insert $00 characters + ; But don't insert $00 characters beq sk_nokey - // Stash key into keyboard buffer + ; Stash key into keyboard buffer ldx NDX cpx XMAX beq sk_nokey @@ -142,8 +142,8 @@ sk_nokey: rts - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Routine for Scanning a Matrix Row + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Routine for Scanning a Matrix Row KeyInRow: ldy #7 @@ -159,18 +159,18 @@ nokey: rts - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Routine for handling: Key Found + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Routine for handling: Key Found KeyFound: stx TempZP dec KeyQuantity bmi OverFlow - // Originally, we resolved the keys. - // Now we just return the matrix position, so that - // we can do C64-style bucky modifications as normal - // was: ldy KeyTable,x + ; Originally, we resolved the keys. + ; Now we just return the matrix position, so that + ; we can do C64-style bucky modifications as normal + ; was: ldy KeyTable,x pha txa @@ -180,15 +180,15 @@ KeyFound: ldx TempZP rts - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Routine for handling: Overflow + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Routine for handling: Overflow OverFlow: - pla // Dirty hack to handle 2 layers of JSR + pla ; Dirty hack to handle 2 layers of JSR pla pla pla - // Don't manipulate last legal buffer as the routine will fix itself once it gets valid input again. + ; Don't manipulate last legal buffer as the routine will fix itself once it gets valid input again. ReturnNoKeys: sec @@ -197,21 +197,21 @@ ReturnNoKeys: lda #$FF sta LSTX ldx #MaxKeyRollover-1 -!: +@2: sta Buffer,x sta BufferOld,x dex - bpl !- + bpl @2 rts - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Exit Routine for: No Activity + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Exit Routine for: No Activity NoActivityDetected: - // So cancel all bucky keys + ; So cancel all bucky keys lda SHFLAG sta LSTSHF lda #$00 @@ -219,22 +219,22 @@ NoActivityDetected: jmp ReturnNoKeys - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Configure Data Direction Registers + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Configure Data Direction Registers Main: - // Begin with no key events + ; Begin with no key events lda #$ff sta BufferNew+0 sta BufferNew+1 sta BufferNew+2 - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Check for Port Activity + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Check for Port Activity ldx #$FF ldy #$00 - sty CIA1_PRA // Connect all Keyboard Rows + sty CIA1_PRA ; Connect all Keyboard Rows cpx CIA1_PRB bne skip0 @@ -242,69 +242,69 @@ Main: JoystickActivity: - // Clear bucky key status + ; Clear bucky key status lda #$00 sta SHFLAG lda CIA1_PRB and #$03 cmp #$01 - bne !+ - // down - ldx #$07 // UP/DOWN + bne @3 + ; down + ldx #$07 ; UP/DOWN jsr KeyFound -!: +@3: cmp #$02 - bne !+ - // Up - // Mark shift as pressed + bne @4 + ; Up + ; Mark shift as pressed ldx #$01 stx SHFLAG - ldx #$07 // UP/DOWN + ldx #$07 ; UP/DOWN jsr KeyFound -!: - // Only allow up/down OR left/right, since - // else we have confusing situation with SHIFT required - // for one, but not the other. - // XXX - We could fix this by making the joystick activity - // feed the key input at a higher level, rather than - // simulating directly pressing the cursor keys. +@4: + ; Only allow up/down OR left/right, since + ; else we have confusing situation with SHIFT required + ; for one, but not the other. + ; XXX - We could fix this by making the joystick activity + ; feed the key input at a higher level, rather than + ; simulating directly pressing the cursor keys. cmp #$03 - beq !+ + beq @5 jmp skdone -!: +@5: lda CIA1_PRB and #$0c cmp #$04 - bne !+ + bne @6 ldx #$02 - jsr KeyFound // LEFT/RIGHT -!: + jsr KeyFound ; LEFT/RIGHT +@6: cmp #$08 - bne !+ + bne @7 ldx #$01 stx SHFLAG ldx #$02 - jsr KeyFound // LEFT/RIGHT -!: + jsr KeyFound ; LEFT/RIGHT +@7: jmp skdone skip0: - // // Set max keys allowed before ignoring result + ; ; Set max keys allowed before ignoring result lda #MaxKeyRollover sta KeyQuantity - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Check for Control Port #1 Activity + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Check for Control Port #1 Activity - stx CIA1_PRA // Disconnect all Keyboard Rows - cpx CIA1_PRB // Only Control Port activity will be detected + stx CIA1_PRA ; Disconnect all Keyboard Rows + cpx CIA1_PRB ; Only Control Port activity will be detected bne JoystickActivity - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Scan Keyboard Matrix + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Scan Keyboard Matrix ldx #7 lda #%11111110 @@ -319,40 +319,40 @@ next_row: dex bpl next_row - // X gets back to $FF here, which is assumed below + ; X gets back to $FF here, which is assumed below - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Check for Control Port #1 Activity (again) + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Check for Control Port #1 Activity (again) - stx CIA1_PRA // Disconnect all Keyboard Rows - cpx CIA1_PRB // Only Control Port activity will be detected - beq !+ + stx CIA1_PRA ; Disconnect all Keyboard Rows + cpx CIA1_PRB ; Only Control Port activity will be detected + beq @8 jmp ReturnNoKeys -!: - // Make X = $00, assumed below +@8: + ; Make X = $00, assumed below inx - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Check and flag Non Alphanumeric Keys + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Check and flag Non Alphanumeric Keys - // Store de-bounce data for bucky keys - // (Compute's Mapping the 64, p58-59) + ; Store de-bounce data for bucky keys + ; (Compute's Mapping the 64, p58-59) lda SHFLAG sta LSTSHF - // Build bucky state + ; Build bucky state lda #$00 sta SHFLAG lda ScanResult+6 eor #%10000000 - and #%10000000 // Left shift + and #%10000000 ; Left shift rol rol and #$01 ora SHFLAG sta SHFLAG - // Right shift + ; Right shift lda ScanResult+1 eor #$10 lsr @@ -363,14 +363,14 @@ next_row: ora SHFLAG sta SHFLAG - // Control + ; Control lda ScanResult+0 eor #$04 and #$04 ora SHFLAG sta SHFLAG - // Vendor key + ; Vendor key lda ScanResult+0 eor #$ff lsr @@ -381,13 +381,13 @@ next_row: ora SHFLAG sta SHFLAG - // Handle SHIFT + VENDOR + ; Handle SHIFT + VENDOR jsr scnkey_toggle_if_needed no_case_toggle: - // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // // Check for pressed key(s) + ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; ; Check for pressed key(s) lda ScanResult+7 cmp #$ff @@ -432,15 +432,15 @@ skdone: - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Key Scan Completed + ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ; Key Scan Completed - // Put any new key (not in old scan) into buffer + ; Put any new key (not in old scan) into buffer ldx #MaxKeyRollover-1 ProcessPressedKeys: - // Check if the currently pressed key is continuing to be held down + ; Check if the currently pressed key is continuing to be held down lda BufferNew,x cmp #$ff beq ConsiderNextKey @@ -453,12 +453,12 @@ ProcessPressedKeys: RecordKeypress: - // New Key Detected + ; New Key Detected ldy BufferQuantity cpy #MaxKeyRollover - bcc !+ - jmp ReturnNoKeys // too many new keys -!: + bcc @9 + jmp ReturnNoKeys ; too many new keys +@9: AcceptKeyEvent: sta Buffer,y iny @@ -468,26 +468,26 @@ ConsiderNextKey: dex bpl ProcessPressedKeys - // Copy new presses to old list + ; Copy new presses to old list ldx #MaxKeyRollover-1 -!: +@10: lda BufferNew,x sta BufferOld,x dex - bpl !- + bpl @10 - // Return success and set of pressed keys + ; Return success and set of pressed keys clc rts KeyHeld: - // The key in A is still held down. - // compare with key in LSTX - // (Compute's Mapping the 64 p36-37) - // if different, reset repeat count down. + ; The key in A is still held down. + ; compare with key in LSTX + ; (Compute's Mapping the 64 p36-37) + ; if different, reset repeat count down. - // Ignore bucky keys, so that repeat can work when a - // bucky is held down. + ; Ignore bucky keys, so that repeat can work when a + ; bucky is held down. cmp #15 beq BuckyHeld cmp #52 @@ -500,7 +500,7 @@ KeyHeld: cmp LSTX beq SameKeyHeld - // Different key held + ; Different key held sta LSTX pha lda DELAY @@ -514,12 +514,12 @@ SameKeyHeld: lda KOUNT bmi KeyCanRepeat bne KeyRepeatWait - // Count down ended, so repeat key now + ; Count down ended, so repeat key now KeyCanRepeat: - // (Compute's Mapping the 64 p58) + ; (Compute's Mapping the 64 p58) pha - lda #6-2 // Fudge factor to match speed + lda #6-2 ; Fudge factor to match speed sta KOUNT pla pla @@ -530,4 +530,4 @@ KeyRepeatWait: jmp ConsiderNextKey -#endif // CONFIG_LEGACY_SCNKEY +} ; CONFIG_LEGACY_SCNKEY diff --git a/src/kernal/keyboard/scnkey_set_keytab.s b/src/kernal/keyboard/scnkey_set_keytab.s index 0b2bf4ed..86aceb29 100644 --- a/src/kernal/keyboard/scnkey_set_keytab.s +++ b/src/kernal/keyboard/scnkey_set_keytab.s @@ -1,109 +1,113 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Well-known Kernal routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - pages 220, 221 -// +; +; Well-known Kernal routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - pages 220, 221 +; scnkey_set_keytab: -#if CONFIG_LEGACY_SCNKEY // routine not compatible with legacy SCNKEY +!ifdef CONFIG_LEGACY_SCNKEY { ; routine not compatible with legacy SCNKEY rts -#else +} else { - // Set initial KEYTAB value + ; Set initial KEYTAB value lda #kb_matrix sta KEYTAB+1 - // Calculate table index + ; Calculate table index lda SHFLAG - and #$07 // we are only interested in SHIFT / CTRL / VENDOR keys + and #$07 ; we are only interested in SHIFT / CTRL / VENDOR keys tax - // Retrieve table offset + ; Retrieve table offset lda kb_matrix_lookup, x cmp #$FF bne scnkey_valid_offset - // $FF means we should not decode anything, mark this by setting high byte - // of KEYTAB to 0 (I do not think anyone would put keyboard decoding table - // at zeropage) + ; $FF means we should not decode anything, mark this by setting high byte + ; of KEYTAB to 0 (I do not think anyone would put keyboard decoding table + ; at zeropage) lda #$00 - beq !+ // branch always + beq scnkey_valid_offset_cont ; branch always scnkey_valid_offset: - // Add offset to the vector + ; Add offset to the vector clc adc KEYTAB+0 sta KEYTAB+0 lda #$00 adc KEYTAB+1 -!: + + ; FALLTROUGH + +scnkey_valid_offset_cont: + sta KEYTAB+1 - // FALLTROUGH + ; FALLTROUGH -#endif // no CONFIG_LEGACY_SCNKEY +} ; no CONFIG_LEGACY_SCNKEY -scnkey_toggle_if_needed: // entry for SCNKEY (TWW/CTR version) +scnkey_toggle_if_needed: ; entry for SCNKEY (TWW/CTR version) - // Check if we should toggle the character set + ; Check if we should toggle the character set lda MODE - bne !+ // not allowed to toggle + bne @1 ; not allowed to toggle lda SHFLAG and #$03 cmp #$03 - bne !+ // no SHIFT + VENDOR pressed + bne @1 ; no SHIFT + VENDOR pressed lda LSTSHF and #$03 cmp #$03 - beq !+ // already toggled + beq @1 ; already toggled - // Toggle char set + ; Toggle char set -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcc !++ + bcc @2 - // Toggling charsets for C64 mode + ; Toggling charsets for C64 mode lda VIC_YMCSB eor #$02 sta VIC_YMCSB -!: +@1: rts - // Toggling charsets for M65 mode -!: + ; Toggling charsets for M65 mode +@2: lda VIC_CHARPTR+1 eor #%00001000 sta VIC_CHARPTR+1 rts -#else +} else { lda VIC_YMCSB eor #$02 sta VIC_YMCSB -!: +@1: rts -#endif +} diff --git a/src/kernal/keyboard/scnkey_via_keylog.s b/src/kernal/keyboard/scnkey_via_keylog.s index d23f27d1..3b141824 100644 --- a/src/kernal/keyboard/scnkey_via_keylog.s +++ b/src/kernal/keyboard/scnkey_via_keylog.s @@ -1,14 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// Short helper jump-via-vector routine, to set the keyboard matrix +; Short helper jump-via-vector routine, to set the keyboard matrix -#if !HAS_OPCODES_65CE02 +!ifndef HAS_OPCODES_65CE02 { scnkey_via_keylog: jmp (KEYLOG) - -#endif +} diff --git a/src/kernal/memory/fd15.restor.s b/src/kernal/memory/fd15.restor.s index a4a5b106..34167be5 100644 --- a/src/kernal/memory/fd15.restor.s +++ b/src/kernal/memory/fd15.restor.s @@ -1,27 +1,27 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 293 (RESTOR), 304 (VECTOR) -// - [CM64] Computes Mapping the Commodore 64 - page 237 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 293 (RESTOR), 304 (VECTOR) +; - [CM64] Computes Mapping the Commodore 64 - page 237 +; +; CPU registers that has to be preserved (see [RG64]): none +; RESTOR: - clc // clear carry - for writing to system table + clc ; clear carry - for writing to system table ldy #>vector_defaults ldx #tiny_nmi_handler @@ -35,7 +35,7 @@ tiny_nmi_handler_routine: rti peek_under_roms_routine: php - // Offset of arg of lda ($00),y + ; Offset of arg of lda ($00),y stx peek_under_roms+pa-peek_under_roms_routine+1 jsr memmap_allram pa: lda ($00),y @@ -45,7 +45,7 @@ pa: lda ($00),y poke_under_roms_routine: php - // Offset of arg of lda ($00),y + ; Offset of arg of lda ($00),y stx poke_under_roms+pb-poke_under_roms_routine+1 jsr memmap_allram pb: sta ($00),y @@ -70,5 +70,4 @@ memmap_allram_routine: __ram_routines_end: - -#endif +} diff --git a/src/kernal/memory/vector_real.s b/src/kernal/memory/vector_real.s index 9440fa34..4cfee796 100644 --- a/src/kernal/memory/vector_real.s +++ b/src/kernal/memory/vector_real.s @@ -1,45 +1,45 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE vector_real: - // Use MEMUSS as temporary storage location - checked on real C64 that this is the - // address originally used; after calling VECTOR and checking zero page - // area afterwards, the address could be found there + ; Use MEMUSS as temporary storage location - checked on real C64 that this is the + ; address originally used; after calling VECTOR and checking zero page + ; area afterwards, the address could be found there - // According to 'Computes Mapping the Commodore 64' page 237, - // the CBM implementation does not disable IRQs - yet, the - // 'C64 Programmers Reference Guide' does not contain such - // warning and does not mention any preparations needed. + ; According to 'Computes Mapping the Commodore 64' page 237, + ; the CBM implementation does not disable IRQs - yet, the + ; 'C64 Programmers Reference Guide' does not contain such + ; warning and does not mention any preparations needed. - // Initial idea was to do php, cli, ..., plp to make the routine safer, - // but it seems it might cause problem with initialization on XEMU emulator - // XXX find out, why + ; Initial idea was to do php, cli, ..., plp to make the routine safer, + ; but it seems it might cause problem with initialization on XEMU emulator + ; XXX find out, why - // Prepare the user data pointer - strange order to reduce risk - // of potential similarity to the original routine + ; Prepare the user data pointer - strange order to reduce risk + ; of potential similarity to the original routine sty MEMUSS + 1 stx MEMUSS + 0 lda #$00 - sta NMINV + 1 // our routine considers this a disabled interrupt + sta NMINV + 1 ; our routine considers this a disabled interrupt - // Select routine variant - store or restore vectors + ; Select routine variant - store or restore vectors ldy #$1F bcc vector_restore lda CINV, y sta (MEMUSS), y - bcs vector_end_loop // branch always + bcs vector_end_loop ; branch always vector_restore: lda (MEMUSS), y sta CINV, y - // FALLTROUGH + ; FALLTROUGH vector_end_loop: dey diff --git a/src/kernal/panic.s b/src/kernal/panic.s index 1dbbf993..0cb5a0bc 100644 --- a/src/kernal/panic.s +++ b/src/kernal/panic.s @@ -1,56 +1,54 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Something terrible happened - show the panic screen -// +; +; Something terrible happened - show the panic screen +; -#if CONFIG_PANIC_SCREEN +!ifdef CONFIG_PANIC_SCREEN { panic: - // Store error code on stack + ; Store error code on stack pha - // Reinitialize the hardware + ; Reinitialize the hardware sei jsr IOINIT -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { - // Make sure we are in legacy mode with normal memory mapping + ; Make sure we are in legacy mode with normal memory mapping jsr map_NORMAL sec - jsr M65_MODESET // switch to legacy C64 compatibility mode + jsr M65_MODESET ; switch to legacy C64 compatibility mode sei -#else +} else { jsr vicii_init - -#endif +} jsr clear_screen - // Disable NMIs + ; Disable NMIs -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { jsr nmi_lock -#else +} else { lda #$00 - sta NMINV + 1 // our routine does not allow zeropage vectors + sta NMINV + 1 ; our routine does not allow zeropage vectors +} -#endif - - // Display KERNAL PANIC message + ; Display KERNAL PANIC message ldx #$14 ldy #$0E @@ -59,7 +57,7 @@ panic: ldx #__MSG_KERNAL_PANIC jsr print_kernal_message - // Display error code and message (if known) + ; Display error code and message (if known) pla beq kernal_panic_infinite_loop @@ -80,20 +78,20 @@ panic: ldx #__MSG_KERNAL_PANIC_ROM_MISMATCH jsr print_kernal_message - // Display some raster effect in the infinitew loop + ; Display some raster effect in the infinitew loop kernal_panic_infinite_loop: + ldx #$00 stx VIC_EXTCOL -!: +@1: inx - bpl !- + bpl @1 ldx #$06 stx VIC_EXTCOL - nop + +nop - bne kernal_panic_infinite_loop // branch always - -#endif // CONFIG_PANIC_SCREEN + bne kernal_panic_infinite_loop ; branch always +} diff --git a/src/kernal/print/print_hex_byte.s b/src/kernal/print/print_hex_byte.s index 5bcbbd34..ee07b2f3 100644 --- a/src/kernal/print/print_hex_byte.s +++ b/src/kernal/print/print_hex_byte.s @@ -1,16 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Print the hex value in .A as two digits -// +; +; Print the hex value in .A as two digits +; print_hex_byte: -#if HAS_BCD_SAFE_INTERRUPTS +!ifdef HAS_BCD_SAFE_INTERRUPTS { - // Idea by Haubitze + ; Idea by Haubitze sed pha @@ -30,7 +30,7 @@ print_hex_byte: cld jmp JCHROUT -#else +} else { pha lsr @@ -39,15 +39,16 @@ print_hex_byte: lsr ora #$30 cmp #$3A - bcc !+ + bcc @1 adc #6 -!: jsr JCHROUT +@1: + jsr JCHROUT pla and #$0f ora #$30 cmp #$3A - bcc !+ + bcc @2 adc #6 -!: jmp JCHROUT - -#endif +@2: + jmp JCHROUT +} diff --git a/src/kernal/print/print_kernal_message.s b/src/kernal/print/print_kernal_message.s index 906ee939..01f15850 100644 --- a/src/kernal/print/print_kernal_message.s +++ b/src/kernal/print/print_kernal_message.s @@ -1,18 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Print one of the standard Kernal messages, index in .X -// +; +; Print one of the standard Kernal messages, index in .X +; + +print_kernal_message_loop: -!: jsr JCHROUT inx print_kernal_message: lda __msg_kernal_first, x - bpl !- // 0 marks end of string + bpl print_kernal_message_loop ; 0 marks end of string and #$7F jmp JCHROUT diff --git a/src/kernal/print/print_return.s b/src/kernal/print/print_return.s index f9926e7d..3966a0ec 100644 --- a/src/kernal/print/print_return.s +++ b/src/kernal/print/print_return.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Print the carriage return -// +; +; Print the carriage return +; print_return: - lda #$0D // carriage return code + lda #$0D ; carriage return code jmp JCHROUT diff --git a/src/kernal/print/print_space.s b/src/kernal/print/print_space.s index 374873f5..ea601d94 100644 --- a/src/kernal/print/print_space.s +++ b/src/kernal/print/print_space.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Print the space character -// +; +; Print the space character +; print_space: - lda #$20 // space code + lda #$20 ; space code jmp JCHROUT diff --git a/src/kernal/print/printf.s b/src/kernal/print/printf.s index 42934867..c134f1b3 100644 --- a/src/kernal/print/printf.s +++ b/src/kernal/print/printf.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// printf()-like routine for simplifying debugging +; printf()-like routine for simplifying debugging -// Prints the literal zero-terminated string that follows, -// which may also include special tokens that allow -// printing of hex byte and word values stored at the indicated -// addresses. +; Prints the literal zero-terminated string that follows, +; which may also include special tokens that allow +; printing of hex byte and word values stored at the indicated +; addresses. -// .byte 1,$byte = display byte as hex -// .byte 2,$low,$hi = display word as hex -// .byte $f0+n,$low,$hi = display byte at $hi$lo+n as hex +; .byte 1,$byte = display byte as hex +; .byte 2,$low,$hi = display word as hex +; .byte $f0+n,$low,$hi = display byte at $hi$lo+n as hex -#if CONFIG_DBG_PRINTF +!ifdef CONFIG_DBG_PRINTF { printf: - // Temporary storage is between end of screen at $0400 - // and the sprite pointers at $7f8 + ; Temporary storage is between end of screen at $0400 + ; and the sprite pointers at $7f8 sta $7f0 stx $7f1 sty $7f2 @@ -25,14 +25,14 @@ printf: pla sta $7f3 - // Set up read routine - lda #$ad // LDA $nnnn + ; Set up read routine + lda #$ad ; LDA $nnnn sta $7f4 lda #$60 - sta $7f7 // RTS + sta $7f7 ; RTS - // Get PC of caller from the stack, so that - // we can parse through it + ; Get PC of caller from the stack, so that + ; we can parse through it pla clc adc #$01 @@ -45,8 +45,8 @@ printf_loop: jsr $7f4 cmp #$00 bne printf_continues - // Put return address on stack and restore - // registers + ; Put return address on stack and restore + ; registers lda $7f6 pha lda $7f5 @@ -62,33 +62,33 @@ printf_loop: printf_continues: cmp #$01 bne not_hexbyte - // Print a hex byte + ; Print a hex byte - // Skip the token + ; Skip the token jsr printf_advance - // Read the low byte + ; Read the low byte jsr $7f4 - // Print as hex + ; Print as hex jsr print_hex_byte jmp printf_nextchar not_hexbyte: cmp #$02 bne not_hexword - // Print a hex word + ; Print a hex word - // Skip the token + ; Skip the token jsr printf_advance jsr printf_advance - // Read the high byte + ; Read the high byte jsr $7f4 - // Print as hex + ; Print as hex jsr print_hex_byte - // Skip the token + ; Skip the token jsr printf_retreat - // Read the low byte + ; Read the low byte jsr $7f4 - // Print as hex + ; Print as hex jsr print_hex_byte jsr printf_advance jmp printf_nextchar @@ -97,11 +97,11 @@ not_hexword: cmp #$f0 bcc not_pointer - // Treat two-byte arg as base address - // and lower 4 bits of token as offset from - // that location. + ; Treat two-byte arg as base address + ; and lower 4 bits of token as offset from + ; that location. - // Get offset + ; Get offset and #$0f tay @@ -117,7 +117,7 @@ not_hexword: jmp printf_nextchar not_pointer: - // Print character + ; Print character jsr JCHROUT printf_nextchar: @@ -125,15 +125,15 @@ printf_nextchar: jmp printf_loop printf_advance: - // Advance pointer to next character + ; Advance pointer to next character inc $7f5 - bne !+ + bne @1 inc $7f6 -!: +@1: rts printf_retreat: - // Retreat pointer to previous char + ; Retreat pointer to previous char lda $7f5 sec sbc #1 @@ -142,5 +142,4 @@ printf_retreat: sbc #0 sta $7f6 rts - -#endif // CONFIG_DBG_PRINTF +} diff --git a/src/kernal/rom_revision/ff80.kernal_revision.s b/src/kernal/rom_revision/ff80.kernal_revision.s index 74101501..dff88bb0 100644 --- a/src/kernal/rom_revision/ff80.kernal_revision.s +++ b/src/kernal/rom_revision/ff80.kernal_revision.s @@ -1,67 +1,68 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// This byte (hex $FF80, dec 65408) identifies Kernal revision on several machines. Although not all -// of the, used it for versioning purpose, here is the list of all the values I could find. Sources: -// - [CM64] Computes Mapping the Commodore 64 (page 242/243) -// - [MM] Marko Mäkelä article, http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/c64/revisions.txt -// - [VICE] Checked with ROMs included in VICE emulator -// - [XEMU] Checked with ROMs retrieved by XEMU emulator -// -// IDEA: put here a value, that is different from any version currently known, as -// a warning that this is not a Commodore Kernal or anything already known. -// -// C64 - values from the official ROMs: -// - $00 - [CM64] then current number [MM] 901227-02 [VICE] C64 Revision 2 -// - $03 - [CM64] (not mentionned) [MM] 901227-02, 901227-03 [VICE] C64 Revision 3 -// - $43 - [CM64] (not mentionned) [MM] 251104-04 [VICE] SX-64 -// - $64 - [CM64] PET64 ROM [MM] (not mentionned) [VICE] PET64 -// - $AA - [CM64] first version of ROM [MM] 901227-01 [VICE] C64 Revision 1 -// -// C64 - values from unofficial 3rd party ROMs: -// - $00 - Turbo Trans, Turbo Access, Turbo Process -// - $03 - SuperCPU ROM 1.40, 2.04, also unofficial 0.7 ROM from [VICE], -// DolphinDOS 2.0, JiffyDOS 6.01, EXOS V3/4, -// Datel Mercury V3 US, Datel DOS-ROM V1.2, Datel Turbo ROM II V3.2+, -// Turbo Process US, -// burst CIA 1/2 Kernal by Albert, SD2IEC Kernal 1.0/2.0/2.1/2.2 by Claus -// - $4A - S-JiffyDOS -// - $53 - Professional DOS V1, SpeedDOS Plus 2.7 -// - $C3 - Cockroach Turbo ROM V1 -// -// PET: -// - $40 - [VICE] PET 2001-8N -// - $A7 - [VICE] PET 30XX -// - $AA - [VICE] PET 40XX, PET 80XX, SuperPET -// -// CBM II: -// - $E0 - [VICE] 5x0, 6x0, 7x0 models -// -// VIC-20: -// - $16 - [VICE] all models, also VIC-20 JiffyDOS PAL/NTSC -// -// 264 family: -// - $01 - [VICE] 364 -// - $05 - [VICE] C16, C116, Plus/4 -// - $06 - (unofficial) JiffyDOS NTSC -// - $81 - [VICE] 232 -// - $86 - (unofficial) JiffyDOS PAL -// -// C128: -// - $01 - see https://www.pagetable.com/?p=1058 -// - $02 - unreleased updated ROM, see https://www.pagetable.com/?p=1058 -// -// Commodore prototypes: -// - $04 - [XEMU] 64 mode ROM of the C65 prototype, ROM 910111 -// - $FF - [XEMU] C65 native mode, ROM 910111 -// - $FF - [XEMU] Commodore LCD -// -// Non-Commodore machines: -// - $FF - Commander X16 (emulator r28) -// +; +; This byte (hex $FF80, dec 65408) identifies Kernal revision on several machines. Although not all +; of the, used it for versioning purpose, here is the list of all the values I could find. Sources: +; - [CM64] Computes Mapping the Commodore 64 (page 242/243) +; - [MM] Marko Mäkelä article, http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/c64/revisions.txt +; - [VICE] Checked with ROMs included in VICE emulator +; - [XEMU] Checked with ROMs retrieved by XEMU emulator +; +; IDEA: put here a value, that is different from any version currently known, as +; a warning that this is not a Commodore Kernal or anything already known. +; +; C64 - values from the official ROMs: +; - $00 - [CM64] then current number [MM] 901227-02 [VICE] C64 Revision 2 +; - $03 - [CM64] (not mentionned) [MM] 901227-02, 901227-03 [VICE] C64 Revision 3 +; - $43 - [CM64] (not mentionned) [MM] 251104-04 [VICE] SX-64 +; - $64 - [CM64] PET64 ROM [MM] (not mentionned) [VICE] PET64 +; - $AA - [CM64] first version of ROM [MM] 901227-01 [VICE] C64 Revision 1 +; +; C64 - values from unofficial 3rd party ROMs: +; - $00 - Turbo Trans, Turbo Access, Turbo Process +; - $03 - SuperCPU ROM 1.40, 2.04, also unofficial 0.7 ROM from [VICE], +; DolphinDOS 2.0, JiffyDOS 6.01, EXOS V3/4, +; Datel Mercury V3 US, Datel DOS-ROM V1.2, Datel Turbo ROM II V3.2+, +; Turbo Process US, +; burst CIA 1/2 Kernal by Albert, SD2IEC Kernal 1.0/2.0/2.1/2.2 by Claus +; - $4A - S-JiffyDOS +; - $53 - Professional DOS V1, SpeedDOS Plus 2.7 +; - $C3 - Cockroach Turbo ROM V1 +; +; PET: +; - $40 - [VICE] PET 2001-8N +; - $A7 - [VICE] PET 30XX +; - $AA - [VICE] PET 40XX, PET 80XX, SuperPET +; +; CBM II: +; - $E0 - [VICE] 5x0, 6x0, 7x0 models +; +; VIC-20: +; - $16 - [VICE] all models, also VIC-20 JiffyDOS PAL/NTSC +; +; 264 family: +; - $01 - [VICE] 364 +; - $05 - [VICE] C16, C116, Plus/4 +; - $06 - (unofficial) JiffyDOS NTSC +; - $81 - [VICE] 232 +; - $86 - (unofficial) JiffyDOS PAL +; +; C128: +; - $01 - see https://www.pagetable.com/?p=1058 +; - $02 - unreleased updated ROM, see https://www.pagetable.com/?p=1058 +; +; Commodore prototypes: +; - $04 - [XEMU] 64 mode ROM of the C65 prototype, ROM 910111 +; - $FF - [XEMU] C65 native mode, ROM 910111 +; - $FF - [XEMU] Commodore LCD +; +; Non-Commodore machines: +; - $FF - Commander X16 (emulator r28) +; kernal_revision: - .byte $F0 // chosen not to conflict with anything known so far + + !byte $F0 ; chosen not to conflict with anything known so far diff --git a/src/kernal/rs232/chkin_rs232_up2400.s b/src/kernal/rs232/chkin_rs232_up2400.s index ea8edff1..dc031040 100644 --- a/src/kernal/rs232/chkin_rs232_up2400.s +++ b/src/kernal/rs232/chkin_rs232_up2400.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CHKIN routine -// +; +; RS-232 part of the CHKIN routine +; -#if CONFIG_RS232_UP2400 +!ifdef CONFIG_RS232_UP2400 { chkin_rs232: - STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + +STUB_IMPLEMENTATION ; XXX provide implementation for both UP2400 and UP9600 -#endif // CONFIG_RS232_UP2400 +} ; CONFIG_RS232_UP2400 diff --git a/src/kernal/rs232/chkin_rs232_up9600.s b/src/kernal/rs232/chkin_rs232_up9600.s index c1ffd6cb..3bb4b141 100644 --- a/src/kernal/rs232/chkin_rs232_up9600.s +++ b/src/kernal/rs232/chkin_rs232_up9600.s @@ -1,51 +1,51 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CHKIN routine -// +; +; RS-232 part of the CHKIN routine +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { -// XXX get rid of the ENABLE/DISABLE mechanism +; XXX get rid of the ENABLE/DISABLE mechanism chkin_rs232: pha lda XXX_UPFLAG - bne !+ + bne @1 pla - jmp $F20E // XXX + jmp $F20E ; XXX -!: +@1: pla - jsr $F30F // XXX - beq !+ - jmp $F701 // XXX + jsr $F30F ; XXX + beq @2 + jmp $F701 ; XXX -!: - jsr $F31F // XXX +@2: + jsr $F31F ; XXX lda FA cmp #$02 - beq !+ + beq @3 cmp #$04 bcc chkin_rs232_nochkin jsr XXX_DISABLE jmp chkin_rs232_nochkin -!: +@3: sta $99 jsr XXX_ENABLE clc rts -chkin_rs232_nochkin - jmp $F219 // XXX +chkin_rs232_nochkin: + jmp $F219 ; XXX -#endif // CONFIG_RS232_UP9600 +} ; CONFIG_RS232_UP9600 diff --git a/src/kernal/rs232/chrin_rs232_up2400.s b/src/kernal/rs232/chrin_rs232_up2400.s index d11f6ca2..11c27bed 100644 --- a/src/kernal/rs232/chrin_rs232_up2400.s +++ b/src/kernal/rs232/chrin_rs232_up2400.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CHRIN routine -// +; +; RS-232 part of the CHRIN routine +; -#if CONFIG_RS232_UP2400 +!ifdef CONFIG_RS232_UP2400 { chrin_rs232: - STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + +STUB_IMPLEMENTATION ; XXX provide implementation for both UP2400 and UP9600 -#endif // CONFIG_RS232_UP2400 +} ; CONFIG_RS232_UP2400 diff --git a/src/kernal/rs232/chrin_rs232_up9600.s b/src/kernal/rs232/chrin_rs232_up9600.s index 8ada792c..93563fa3 100644 --- a/src/kernal/rs232/chrin_rs232_up9600.s +++ b/src/kernal/rs232/chrin_rs232_up9600.s @@ -1,46 +1,46 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CHRIN routine -// +; +; RS-232 part of the CHRIN routine +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { chrin_rs232: - phy_trash_a - phx_trash_a + +phy_trash_a + +phx_trash_a lda #$00 sta XXX_SAVBYTE sta RSSTAT jsr up9600_rsin - bcc !+ - plx_trash_a - ply_trash_a + bcc @1 + +plx_trash_a + +ply_trash_a - lda #$08 // XXX don't we have some routine for this? + lda #$08 ; XXX don't we have some routine for this? sta RSSTAT lda #$00 clc rts -!: +@1: sta XXX_SAVBYTE XXX_DOGET4: - plx_trash_a - ply_trash_a + +plx_trash_a + +ply_trash_a lda XXX_SAVBYTE clc rts -#endif // CONFIG_RS232_UP9600 +} ; CONFIG_RS232_UP9600 diff --git a/src/kernal/rs232/chrout_rs232.s b/src/kernal/rs232/chrout_rs232.s index 4ed361cf..0ed2b03c 100644 --- a/src/kernal/rs232/chrout_rs232.s +++ b/src/kernal/rs232/chrout_rs232.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CHROUT routine -// +; +; RS-232 part of the CHROUT routine +; -#if HAS_RS232 +!ifdef HAS_RS232 { chrout_rs232: - STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + +STUB_IMPLEMENTATION ; XXX provide implementation for both UP2400 and UP9600 -#endif // HAS_RS232 +} ; HAS_RS232 diff --git a/src/kernal/rs232/ckout_rs232_up2400.s b/src/kernal/rs232/ckout_rs232_up2400.s index 40d1c374..058991c5 100644 --- a/src/kernal/rs232/ckout_rs232_up2400.s +++ b/src/kernal/rs232/ckout_rs232_up2400.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CKOUT routine -// +; +; RS-232 part of the CKOUT routine +; -#if CONFIG_RS232_UP2400 +!ifdef CONFIG_RS232_UP2400 { ckout_rs232: - STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + +STUB_IMPLEMENTATION ; XXX provide implementation for both UP2400 and UP9600 -#endif // CONFIG_RS232_UP2400 +} ; CONFIG_RS232_UP2400 diff --git a/src/kernal/rs232/ckout_rs232_up9600.s b/src/kernal/rs232/ckout_rs232_up9600.s index 3e36affb..2592996d 100644 --- a/src/kernal/rs232/ckout_rs232_up9600.s +++ b/src/kernal/rs232/ckout_rs232_up9600.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CKOUT routine -// +; +; RS-232 part of the CKOUT routine +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { ckout_rs232: - // XXX adapt this + ; XXX adapt this lda #$02 sta DFLTO @@ -23,4 +23,4 @@ ckout_rs232: rts -#endif // CONFIG_RS232_UP9600 +} ; CONFIG_RS232_UP9600 diff --git a/src/kernal/rs232/close_rs232.s b/src/kernal/rs232/close_rs232.s index 7a254c8d..e57066cc 100644 --- a/src/kernal/rs232/close_rs232.s +++ b/src/kernal/rs232/close_rs232.s @@ -1,35 +1,35 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the CLOSE routine -// +; +; RS-232 part of the CLOSE routine +; -#if HAS_RS232 +!ifdef HAS_RS232 { -#if CONFIG_MEMORY_MODEL_60K - .error "CONFIG_MEMORY_MODEL_60K is not compatible with RS-232 memory allocation code" -#endif +!ifdef CONFIG_MEMORY_MODEL_60K { + !error "CONFIG_MEMORY_MODEL_60K is not compatible with RS-232 memory allocation code" +} close_rs232: - // First check how many RS-232 channels are currently allocated. - // If more than one, skip deallocation (other channels still uses the buffer). + ; First check how many RS-232 channels are currently allocated. + ; If more than one, skip deallocation (other channels still uses the buffer). jsr rs232_count_channels - cpx #$02 // set Carry if more than one is open + cpx #$02 ; set Carry if more than one is open bcs close_rs232_end - // Deallocate buffer + ; Deallocate buffer inc MEMSIZK+1 inc MEMSIZK+1 - // XXX is this needed? check with original ROM what it actually does + ; XXX is this needed? check with original ROM what it actually does lda #$00 sta ROBUF+0 @@ -37,9 +37,11 @@ close_rs232: sta RIBUF+0 sta RIBUF+1 + ; FALLTROUGH + close_rs232_end: jmp close_remove_from_table -#endif // HAS_RS232 +} ; HAS_RS232 diff --git a/src/kernal/rs232/getin_rs232.s b/src/kernal/rs232/getin_rs232.s index c1b01556..6c838231 100644 --- a/src/kernal/rs232/getin_rs232.s +++ b/src/kernal/rs232/getin_rs232.s @@ -1,17 +1,16 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the GETIN routine -// +; +; RS-232 part of the GETIN routine +; -#if HAS_RS232 +!ifdef HAS_RS232 { getin_rs232: - STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 - -#endif // HAS_RS232 + STUB_IMPLEMENTATION+ ; XXX provide implementation for both UP2400 and UP9600 +} diff --git a/src/kernal/rs232/open_rs232.s b/src/kernal/rs232/open_rs232.s index 06c08e65..3b410ccb 100644 --- a/src/kernal/rs232/open_rs232.s +++ b/src/kernal/rs232/open_rs232.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RS-232 part of the OPEN routine -// +; +; RS-232 part of the OPEN routine +; -#if HAS_RS232 +!ifdef HAS_RS232 { -#if CONFIG_MEMORY_MODEL_60K - .error "CONFIG_MEMORY_MODEL_60K is not compatible with RS-232 memory allocation code" -#endif +!ifdef CONFIG_MEMORY_MODEL_60K { + !error "CONFIG_MEMORY_MODEL_60K is not compatible with RS-232 memory allocation code" +} open_rs232: - // First check how many RS-232 channels are currently allocated. - // If more than one, skip allocation (already allocated). + ; First check how many RS-232 channels are currently allocated. + ; If more than one, skip allocation (already allocated). jsr rs232_count_channels - cpx #$02 // set Carry if more than one is open + cpx #$02 ; set Carry if more than one is open bcs open_rs232_end - // Allocate buffers - first RIBUF, afterwards ROBUF - // (checked addresses on original ROMs) + ; Allocate buffers - first RIBUF, afterwards ROBUF + ; (checked addresses on original ROMs) lda MEMSIZK+0 sta ROBUF+0 @@ -39,7 +39,7 @@ open_rs232: lda MEMSIZK+1 sta ROBUF+1 - // Initialize buffer indexes + ; Initialize buffer indexes lda #$00 sta RIDBE @@ -48,16 +48,13 @@ open_rs232: sta RODBE -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { jmp up9600_enable - -#endif // CONFIG_RS232_UP9600 - +} open_rs232_end: jmp open_done_success +} - -#endif // HAS_RS232 diff --git a/src/kernal/rs232/rs232_count_channels.s b/src/kernal/rs232/rs232_count_channels.s index c4f17976..9f7b6d3d 100644 --- a/src/kernal/rs232/rs232_count_channels.s +++ b/src/kernal/rs232/rs232_count_channels.s @@ -1,29 +1,28 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Sets .X to number of open RS-232 channels -// +; +; Sets .X to number of open RS-232 channels +; -#if HAS_RS232 +!ifdef HAS_RS232 { rs232_count_channels: ldx #$00 ldy LDTND -!: +@1: dey - bmi !+ + bmi @2 lda FAT, y cmp #$02 - bne !- + bne @1 inx - bpl !- // branch always -!: + bpl @1 ; branch always +@2: rts +} - -#endif diff --git a/src/kernal/rs232/up9600_disable.s b/src/kernal/rs232/up9600_disable.s index 44d6691f..87463876 100644 --- a/src/kernal/rs232/up9600_disable.s +++ b/src/kernal/rs232/up9600_disable.s @@ -1,32 +1,32 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Disable UP9600 interface -// +; +; Disable UP9600 interface +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { -up9600_disable: // XXX adapt +up9600_disable: ; XXX adapt - // XXX restore interrupt vectors and IRQ timer + ; XXX restore interrupt vectors and IRQ timer sei - lda CIA2_PRB // $DD01; DISABLE RTS + lda CIA2_PRB ; $DD01; DISABLE RTS and #$FD - sta CIA2_PRB // $DD01 + sta CIA2_PRB ; $DD01 lda #$7F - sta CIA2_ICR // $DD0D ; DISABLE ALL CIA INTERRUPTS - sta CIA1_ICR // $DC0D + sta CIA2_ICR ; $DD0D ; DISABLE ALL CIA INTERRUPTS + sta CIA1_ICR ; $DC0D lda #$41; QUICK (AND DIRTY) HACK TO SWITCH BACK - sta CIA1_TIMAHI // $DC05 ; TO THE DEFAULT CIA1 CONFIGURATION + sta CIA1_TIMAHI ; $DC05 ; TO THE DEFAULT CIA1 CONFIGURATION lda #$81 - sta CIA1_ICR // $DC0D ; ENABLE TIMER1 (THIS IS DEFAULT) + sta CIA1_ICR ; $DC0D ; ENABLE TIMER1 (THIS IS DEFAULT) lda #ORIGIRQ @@ -41,6 +41,4 @@ up9600_disable: // XXX adapt pla tax pla - - -#endif // CONFIG_RS232_UP9600 +} diff --git a/src/kernal/rs232/up9600_enable.s b/src/kernal/rs232/up9600_enable.s index 2f9be6db..ce451f7f 100644 --- a/src/kernal/rs232/up9600_enable.s +++ b/src/kernal/rs232/up9600_enable.s @@ -1,23 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Enable UP9600 interface support -// +; +; Enable UP9600 interface support +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { -up9600_enable: // XXX adapt +up9600_enable: ; XXX adapt sei - lda IRQVECT cmp #NMIBYTRY sta NMIVECT+1 -NMIDOBI2 +NMIDOBI2: pla; IGNORE, IF NMI WAS TRIGGERED BY RESTORE-KEY rti - ; -NMIBYTRY +NMIBYTRY: pha - bit CIA2_ICR // $DD0D; CHECK BIT 7 (SDR FULL PRINT) + bit CIA2_ICR ; $DD0D; CHECK BIT 7 (SDR FULL PRINT) bpl NMIDOBI2; SDR NOT FULL, THEN SKIP (EG. RESTORE-KEY) lda #$92 - sta CIA2_CRB // $DD0F; STOP TIMER B (KEEP SIGNALLING AT PB7!) - sta CIA2_ICR // $DD0D; ENABLE FLAG (AND TIMER) INTERRUPTS + sta CIA2_CRB ; $DD0F; STOP TIMER B (KEEP SIGNALLING AT PB7!) + sta CIA2_ICR ; $DD0D; ENABLE FLAG (AND TIMER) INTERRUPTS lda #NMIDOBIT sta NMIVECT+1 - phx_trash_a - phy_trash_a - lda CIA2_SDR // $DD0C; READ SDR (BIT0=DATABIT7,...,BIT7=DATABIT0) + +phx_trash_a + +phy_trash_a + lda CIA2_SDR ; $DD0C; READ SDR (BIT0=DATABIT7,...,BIT7=DATABIT0) cmp #128; MOVE BIT7 INTO CARRY-FLAG and #127 tax @@ -57,13 +56,12 @@ NMIBYTRY sbc RIDBS cmp #200 bcc NMIBYTR2 - lda CIA2_PRB // $DD01;; MORE THAN 200 BYTES IN THE RECEIVE BUFFER + lda CIA2_PRB ; $DD01;; MORE THAN 200 BYTES IN THE RECEIVE BUFFER and #$FD;; THEN DISABLE RTS - sta CIA2_PRB // $DD01 -NMIBYTR2 - ply_trash_a - plx_trash_a + sta CIA2_PRB ; $DD01 +NMIBYTR2: + +ply_trash_a + +plx_trash_a pla rti - -#endif // CONFIG_RS232_UP9600 +} diff --git a/src/kernal/rs232/up9600_rsin.s b/src/kernal/rs232/up9600_rsin.s index 67cb5f93..40767446 100644 --- a/src/kernal/rs232/up9600_rsin.s +++ b/src/kernal/rs232/up9600_rsin.s @@ -1,46 +1,44 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Get byte from serial interface -// +; +; Get byte from serial interface +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { up9600_rsin: ldy RIDBS cpy RIDBE - beq up9600_rsin_end; // skip (empty buffer, return with carry set) + beq up9600_rsin_end; ; skip (empty buffer, return with carry set) lda (RIBUF),Y iny sty RIDBS - pha // begin buffer emptying chk + pha ; begin buffer emptying chk tya sec sbc RIDBE - cmp #206 // 256-50 - bcc !+ + cmp #206 ; 256-50 + bcc @1 lda #$02 - ora CIA2_PR // $DD01 - sta CIA2_PR // enable RTS + ora CIA2_PR ; $DD01 + sta CIA2_PR ; enable RTS clc - // FALLTROUGH - -!: + ; FALLTROUGH +@1: pla - // FALLTROUGH + ; FALLTROUGH up9600_rsin_end: rts - -#endif // CONFIG_RS232_UP9600 +} diff --git a/src/kernal/rs232/up9600_rsout.s b/src/kernal/rs232/up9600_rsout.s index 0efed7f4..c1921252 100644 --- a/src/kernal/rs232/up9600_rsout.s +++ b/src/kernal/rs232/up9600_rsout.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Put byte to serial interface -// +; +; Put byte to serial interface +; -// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations +; Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations -#if CONFIG_RS232_UP9600 +!ifdef CONFIG_RS232_UP9600 { up9600_rsout: pha - sta $9E // XXX synchronize with aliases + sta $9E ; XXX synchronize with aliases cmp #$80 and #$7F - stx $A8 // XXX synchronize with aliases - sty $A7 // XXX synchronize with aliases + stx $A8 ; XXX synchronize with aliases + sty $A7 ; XXX synchronize with aliases tax jsr up9600_rsout_time @@ -27,15 +27,15 @@ up9600_rsout: adc #$00 lsr sei - sta CIA1_SDR // $DC0C + sta CIA1_SDR ; $DC0C lda #$02 - STA XXX_OUTSTAT + sta XXX_OUTSTAT ror ora #$7F - sta CIA1_SDR // $DC0C + sta CIA1_SDR ; $DC0C cli - ldx $A8 // XXX synchronize with aliases - ldy $A7 // XXX synchronize with aliases + ldx $A8 ; XXX synchronize with aliases + ldy $A7 ; XXX synchronize with aliases pla rts @@ -43,17 +43,15 @@ up9600_rsout_time: cli lda #$FD - sta TIME+2 // XXX check if this is the lowest byte + sta TIME+2 ; XXX check if this is the lowest byte rs232_rsout_wait: lda XXX_OUTSTAT - beq !+ + beq @1 bit TIME+2 bmi up9600_rsout_wait +@1: + jmp $F490 ; XXX +} -!: - jmp $F490 // XXX - - -#endif // CONFIG_RS232_UP9600 diff --git a/src/kernal/screen/chrin_keyboard.s b/src/kernal/screen/chrin_keyboard.s index 5cfe67e2..6fc937c9 100644 --- a/src/kernal/screen/chrin_keyboard.s +++ b/src/kernal/screen/chrin_keyboard.s @@ -1,54 +1,53 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Keyboard part of the CHRIN routine -// +; +; Keyboard part of the CHRIN routine +; chrin_keyboard: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcc_16 m65_chrin_keyboard + +bcc m65_chrin_keyboard +} -#endif - - // Preserve .X and .Y registers + ; Preserve .X and .Y registers stx XSAV - phy_trash_a + +phy_trash_a - // FALLTROUGH + ; FALLTROUGH 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. + ; 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 chrin_keyboard_read - // We have input waiting at (LSXP)+CRSW - // When CRSW = INDX, then we return a carriage return and clear the flag + ; We have input waiting at (LSXP)+CRSW + ; When CRSW = INDX, then we return a carriage return and clear the flag cmp INDX bne chrin_keyboard_not_end_of_input - // Clear pending input and quote flags + ; Clear pending input and quote flags lda #$00 sta CRSW sta QTSW - // FALLTROUGH + ; FALLTROUGH chrin_keyboard_empty_line: - // For an empty line, just return the carriage return + ; For an empty line, just return the carriage return - ply_trash_a + +ply_trash_a ldx XSAV clc lda #$0D @@ -56,19 +55,19 @@ chrin_keyboard_empty_line: chrin_keyboard_not_end_of_input: - // Advance index, return the next byte + ; Advance index, return the next byte inc CRSW tay - // FALLTROUGH + ; FALLTROUGH chrin_keyboard_return_byte: lda (LSXP),y jsr screen_check_toggle_quote tax - ply_trash_a + +ply_trash_a txa ldx XSAV jsr screen_code_to_petscii @@ -79,7 +78,7 @@ chrin_keyboard_read: jsr cursor_enable - // Wait for a key + ; Wait for a key lda NDX beq chrin_keyboard_repeat @@ -87,7 +86,7 @@ chrin_keyboard_read: cmp #$0D bne chrkn_keyboard_not_enter - // FALLTROUGH + ; FALLTROUGH chrin_keyboard_enter: @@ -95,38 +94,38 @@ chrin_keyboard_enter: jsr pop_keyboard_buffer jsr 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) + ; 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 line of input + ; Set pointer to line of input lda PNT+0 sta LSXP+0 lda PNT+1 sta LSXP+1 - // If the current line is a continuation of the previous one, decrease LSXP by 40 + ; If the current line is a continuation of the previous one, decrease LSXP by 40 ldy TBLX lda LDTB1, y - bmi chrin_enter_calc_length // branch if not continuation + bmi chrin_enter_calc_length ; branch if not continuation lda LSXP+0 sec sbc #40 sta LSXP+0 - bcs !+ + bcs @1 dec LSXP+1 -!: +@1: ldy #80 - bne chrin_enter_loop // branch always + bne chrin_enter_loop ; branch always chrin_enter_calc_length: - // Get the logical line length + ; Get the logical line length jsr screen_get_logical_line_end_ptr iny chrin_enter_loop: - // Skip spaces at the end of line + ; Skip spaces at the end of line dey bmi chrin_keyboard_empty_line lda (LSXP),y @@ -135,29 +134,28 @@ chrin_enter_loop: iny sty INDX - // Set mark informing that we are returning a line + ; Set mark informing that we are returning a line ldy #$01 sty CRSW - // Clear quote mode mark - dey // set .Y to 0 + ; Clear quote mode mark + dey ; set .Y to 0 sty QTSW - // Return first char of line - beq chrin_keyboard_return_byte // branch always + ; Return first char of line + beq chrin_keyboard_return_byte ; branch always chrkn_keyboard_not_enter: lda KEYD -#if CONFIG_PROGRAMMABLE_KEYS +!ifdef CONFIG_PROGRAMMABLE_KEYS { jsr chrin_programmable_keys bcc chrin_keyboard_enter +} -#endif // CONFIG_PROGRAMMABLE_KEYS - - // Print character, keep looking for input from keyboard until carriage return + ; Print character, keep looking for input from keyboard until carriage return jsr CHROUT jsr pop_keyboard_buffer jmp chrin_keyboard_repeat diff --git a/src/kernal/screen/chrin_programmable_keys.s b/src/kernal/screen/chrin_programmable_keys.s index c785543a..8f79d65a 100644 --- a/src/kernal/screen/chrin_programmable_keys.s +++ b/src/kernal/screen/chrin_programmable_keys.s @@ -1,46 +1,46 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Keyboard part of the CHRIN routine - programmable keys support -// Output: if Carry clear, programmable key was handled -// +; +; Keyboard part of the CHRIN routine - programmable keys support +; Output: if Carry clear, programmable key was handled +; -#if CONFIG_PROGRAMMABLE_KEYS +!ifdef CONFIG_PROGRAMMABLE_KEYS { chrin_programmable_keys: - // Check if the key is programmable + ; Check if the key is programmable ldx #(__programmable_keys_codes_end - programmable_keys_codes - 1) -!: +@1: cmp programmable_keys_codes, x - beq !+ + beq @2 dex - bpl !- + bpl @1 - // This is not a programmable key + ; This is not a programmable key sec rts -!: - // .X contains index of the key code, we need offset to key string instead +@2: + ; .X contains index of the key code, we need offset to key string instead lda programmable_keys_offsets, x tax - // Print all the characters assigned to key -!: + ; Print all the characters assigned to key +@3: lda programmable_keys_strings, x - beq !+ - jsr CHROUT // our implementation preserves .X too + beq @4 + jsr CHROUT ; our implementation preserves .X too inx - bne !- // jumps always -!: + bne @3 ; jumps always +@4: clc rts -#endif // CONFIG_PROGRAMMABLE_KEYS +} ; CONFIG_PROGRAMMABLE_KEYS diff --git a/src/kernal/screen/chrout_screen.s b/src/kernal/screen/chrout_screen.s index 153425d9..8aae371a 100644 --- a/src/kernal/screen/chrout_screen.s +++ b/src/kernal/screen/chrout_screen.s @@ -1,92 +1,91 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support (character output) -// +; +; CHROUT routine - screen support (character output) +; chrout_screen: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcc_16 m65_chrout_screen - -#endif + +bcc m65_chrout_screen +} jsr cursor_hide_if_visible lda SCHAR tax - // All the PETSCII control codes are within $0x, $1x, $8x, $9x, remaining - // ones are always printable characters; separate away control codes + ; 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 chrout_screen_control + +beq chrout_screen_control txa - // Literals - first convert PETSCII to screen code + ; Literals - first convert PETSCII to screen code jsr chrout_to_screen_code - // FALLTROUGH + ; FALLTROUGH -chrout_screen_literal: // entry point for chrout_screen_quote +chrout_screen_literal: ; entry point for chrout_screen_quote - // Write normal character on the screen + ; Write normal character on the screen - tax // store screen code, we need .A for calculations + tax ; store screen code, we need .A for calculations - // First we need offset from PNT in .Y, we can take it from PNTR + ; First we need offset from PNT in .Y, we can take it from PNTR jsr screen_get_clipped_PNTR - // Put the character on the screen + ; Put the character on the screen txa - ora RVS // Computes Mapping the 64, page 38 + ora RVS ; Computes Mapping the 64, page 38 sta (PNT),y - // Decrement number of chars waiting to be inserted + ; Decrement number of chars waiting to be inserted lda INSRT - beq !+ + beq @1 dec INSRT -!: - // Toggle quote flag if required +@1: + ; Toggle quote flag if required txa jsr screen_check_toggle_quote - // Set colour of the newly printed character + ; Set colour of the newly printed character lda COLOR sta (USER),y - // Advance the column + ; Advance the column ldy PNTR iny sty PNTR - // Scroll down (extend logical line) if needed + ; Scroll down (extend logical line) if needed cpy #40 - bne !+ + bne @2 jsr screen_grow_logical_line inc TBLX ldy PNTR -!: - // If not the 80th character of the logical row, we are done +@2: + ; If not the 80th character of the logical row, we are done cpy #80 bcc chrout_screen_calc_lptr_done - // Advance to the next line + ; Advance to the next line jmp screen_advance_to_next_line @@ -94,7 +93,7 @@ chrout_screen_calc_lptr_done: jsr screen_calculate_pointers - // FALLTROUGH + ; FALLTROUGH chrout_screen_done: diff --git a/src/kernal/screen/chrout_screen_clr.s b/src/kernal/screen/chrout_screen_clr.s index e2860ce5..21c15f7a 100644 --- a/src/kernal/screen/chrout_screen_clr.s +++ b/src/kernal/screen/chrout_screen_clr.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CLR key handling within CHROUT -// +; +; CLR key handling within CHROUT +; chrout_screen_CLR: diff --git a/src/kernal/screen/chrout_screen_control.s b/src/kernal/screen/chrout_screen_control.s index 8100db55..10355eb2 100644 --- a/src/kernal/screen/chrout_screen_control.s +++ b/src/kernal/screen/chrout_screen_control.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support, control codes -// +; +; CHROUT routine - screen support, control codes +; chrout_screen_control: @@ -20,37 +20,37 @@ chrout_try_jumptable_loop: cpx #(__chrout_screen_jumptable_quote_guard - chrout_screen_jumptable_codes - 1) bne chrout_try_jumptable_loop_noquote - // Is this insert/quote mode? + ; Is this insert/quote mode? tay lda QTSW ora INSRT - beq !+ + beq @1 tya jmp chrout_screen_quote -!: +@1: tya - // FALLTROUGH + ; FALLTROUGH chrout_try_jumptable_loop_noquote: cmp chrout_screen_jumptable_codes, x - bne !+ + bne @2 - // Found, perform a jump to subroutine -#if !HAS_OPCODES_65C02 + ; Found, perform a jump to subroutine +!ifndef HAS_OPCODES_65C02 { lda chrout_screen_jumptable_hi, x pha lda chrout_screen_jumptable_lo, x pha rts -#else +} else { txa asl tax jmp (chrout_screen_jumptable, x) -#endif -!: +} +@2: dex bpl chrout_try_jumptable_loop @@ -61,12 +61,12 @@ chrout_try_COLOR: chrout_try_color_loop: cmp colour_codes,x - bne !+ + bne @3 stx COLOR jmp chrout_screen_done -!: +@3: dex bpl chrout_try_color_loop - // Unknown code, or key not requiring any handling + ; Unknown code, or key not requiring any handling jmp chrout_screen_done diff --git a/src/kernal/screen/chrout_screen_crsr.s b/src/kernal/screen/chrout_screen_crsr.s index 819c8a9a..b9ae5308 100644 --- a/src/kernal/screen/chrout_screen_crsr.s +++ b/src/kernal/screen/chrout_screen_crsr.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Cursor keys handling within CHROUT -// +; +; Cursor keys handling within CHROUT +; chrout_screen_CRSR_UP: @@ -14,7 +14,7 @@ chrout_screen_CRSR_UP: beq chrout_screen_CRSR_done dec TBLX - // FALLTROUGH + ; FALLTROUGH chrout_screen_CRSR_done: @@ -25,9 +25,9 @@ chrout_screen_CRSR_DOWN: lda TBLX cmp #24 - bne !+ + bne @1 jsr screen_scroll_up -!: +@1: inc TBLX jmp chrout_screen_calc_lptr_done @@ -36,19 +36,23 @@ chrout_screen_CRSR_RIGHT: jsr screen_get_clipped_PNTR cpy #39 - beq_16 screen_advance_to_next_line + +beq screen_advance_to_next_line iny -!: + + ; FALLTROUGH + +chrout_screen_CRSR_LR_end: + sty PNTR - bpl chrout_screen_CRSR_done // branch always + bpl chrout_screen_CRSR_done ; branch always chrout_screen_CRSR_LEFT: jsr screen_get_clipped_PNTR dey - bpl !- + bpl chrout_screen_CRSR_LR_end lda TBLX beq chrout_screen_CRSR_done @@ -56,4 +60,4 @@ chrout_screen_CRSR_LEFT: dec TBLX lda #39 sta PNTR - bne chrout_screen_CRSR_done // branch always + bne chrout_screen_CRSR_done ; branch always diff --git a/src/kernal/screen/chrout_screen_del.s b/src/kernal/screen/chrout_screen_del.s index 807e4b79..0ca97edf 100644 --- a/src/kernal/screen/chrout_screen_del.s +++ b/src/kernal/screen/chrout_screen_del.s @@ -1,79 +1,79 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support, DEL key handling -// +; +; CHROUT routine - screen support, DEL key handling +; chrout_screen_DEL: - // In insert mode it embeds control character + ; In insert mode it embeds control character ldx INSRT - beq !+ + beq @1 lda #KEY_DEL jmp chrout_screen_quote -!: +@1: ldy PNTR beq chrout_screen_del_column_0 cpy #40 bne chrout_screen_del_column_normal - // FALLTROUGH + ; FALLTROUGH chrout_screen_del_column_40: - // First column of the extended line - decrement USER/PNT for copying + ; First column of the extended line - decrement USER/PNT for copying -#if HAS_OPCODES_65CE02 +!ifdef HAS_OPCODES_65CE02 { dew USER dew PNT -#else +} else { lda USER+0 - bne !+ + bne @2 dec USER+1 dec PNT+1 -!: +@2: dec USER+0 dec PNT+0 -#endif +} - // Copy characters + ; Copy characters ldx #39 ldy #0 jsr chrout_screen_del_copy_loop - // Finish by moving the cursor left + ; Finish by moving the cursor left jmp chrout_screen_CRSR_LEFT chrout_screen_del_column_normal: - // We need to scroll back the rest of the logical line + ; We need to scroll back the rest of the logical line - // First reduce PNTR to 0-39 range + ; First reduce PNTR to 0-39 range jsr screen_get_clipped_PNTR sty PNTR - // Now get the offset to the last logical line character + ; Now get the offset to the last logical line character jsr screen_get_logical_line_end_ptr tya - // Substract the PNTR value, this will tell us how many characters we need to move + ; Substract the PNTR value, this will tell us how many characters we need to move sec sbc PNTR tax - // Perform the character copy (scroll back) in a loop + ; Perform the character copy (scroll back) in a loop ldy PNTR dey jsr chrout_screen_del_copy_loop dec PNTR - // FALLTROUGH + ; FALLTROUGH chrout_screen_del_done: @@ -94,7 +94,7 @@ chrout_screen_del_copy_loop: dex bpl chrout_screen_del_copy_loop - // Clear char at end of line (just the character - not color!) + ; Clear char at end of line (just the character - not color!) lda #$20 sta (PNT),y @@ -103,20 +103,20 @@ chrout_screen_del_copy_loop: chrout_screen_del_column_0: ldy TBLX - beq chrout_screen_del_done // delete from row 0, col 0 does nothing + beq chrout_screen_del_done ; delete from row 0, col 0 does nothing - // Move cursor to end of previous line + ; Move cursor to end of previous line dec TBLX lda #39 sta PNTR - // Update PNT and USER pointers + ; Update PNT and USER pointers jsr screen_calculate_PNT_USER - // Put space character at the current cursor position (do not clear the color!) + ; Put space character at the current cursor position (do not clear the color!) ldy #39 lda #$20 sta (PNT),y - // Finish with recalculating all the variables + ; Finish with recalculating all the variables bne chrout_screen_del_done diff --git a/src/kernal/screen/chrout_screen_gfxtxt.s b/src/kernal/screen/chrout_screen_gfxtxt.s index 04d73c04..37cfbf4e 100644 --- a/src/kernal/screen/chrout_screen_gfxtxt.s +++ b/src/kernal/screen/chrout_screen_gfxtxt.s @@ -1,23 +1,27 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// GFX/TXT mode switch handling within CHROUT -// +; +; GFX/TXT mode switch handling within CHROUT +; chrout_screen_GFX: lda VIC_YMCSB - and #$02 // to upper case -!: + and #$02 ; to upper case + + ; FALLTROUGH + +chrout_screen_GFX_TXT_end: + sta VIC_YMCSB jmp chrout_screen_done chrout_screen_TXT: lda VIC_YMCSB - ora #$02 // to lower case - bne !- // branch always + ora #$02 ; to lower case + bne chrout_screen_GFX_TXT_end ; branch always diff --git a/src/kernal/screen/chrout_screen_home.s b/src/kernal/screen/chrout_screen_home.s index 353429f4..bd2a6712 100644 --- a/src/kernal/screen/chrout_screen_home.s +++ b/src/kernal/screen/chrout_screen_home.s @@ -1,11 +1,11 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// HOME key handling within CHROUT -// +; +; HOME key handling within CHROUT +; chrout_screen_HOME: diff --git a/src/kernal/screen/chrout_screen_ins.s b/src/kernal/screen/chrout_screen_ins.s index 0e3eed38..96c5ba4d 100644 --- a/src/kernal/screen/chrout_screen_ins.s +++ b/src/kernal/screen/chrout_screen_ins.s @@ -1,82 +1,82 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support, INS key handling -// +; +; CHROUT routine - screen support, INS key handling +; chrout_screen_INS: - // First check if last character of the logical line is space + ; First check if last character of the logical line is space jsr screen_check_space_ends_line beq chrout_screen_ins_possible - // Not space, we cannot insert anything + ; Not space, we cannot insert anything - bne_16 chrout_screen_done + +bne chrout_screen_done chrout_screen_ins_possible: - // Move chars towards end of the line + ; Move chars towards end of the line jsr screen_get_logical_line_end_ptr - // Special handling for cursor in second line + ; Special handling for cursor in second line ldx TBLX lda LDTB1+0, x bpl chrout_screen_ins_second_line - // Perform character copy + ; Perform character copy jsr chrout_screen_ins_copy_loop - // Put space in the inserted gap + ; Put space in the inserted gap lda #$20 sta (PNT), y - // If line does not end with space now, try to grow the logical line + ; If line does not end with space now, try to grow the logical line jsr screen_check_space_ends_line beq chrout_screen_ins_done jsr screen_grow_logical_line - // FALLTROUGH + ; FALLTROUGH chrout_screen_ins_done: - // End of processing + ; End of processing jmp chrout_screen_calc_lptr_done chrout_screen_ins_second_line: - // Adapt PNTR for copying + ; Adapt PNTR for copying lda PNTR sec sbc #40 sta PNTR - // Perform character copy + ; Perform character copy jsr chrout_screen_ins_copy_loop - // Put space in the inserted gap + ; Put space in the inserted gap lda #$20 sta (PNT), y - // End of processing - bne chrout_screen_ins_done // branch always + ; End of processing + bne chrout_screen_ins_done ; branch always chrout_screen_ins_copy_loop: - // Note: While the following routine is obvious to any skilled - // in the art as the most obvious simple and efficient solution, - // if the screen writes are before the colour writes, it results - // in a relatively long verbatim stretch of bytes when compared to - // the C64 KERNAL. Thus we have swapped the order, just to reduce - // the potential for any argument of copyright infringement, even - // though we really do not believe that the routine can be copyrighted - // due to the lack of creativity. + ; Note: While the following routine is obvious to any skilled + ; in the art as the most obvious simple and efficient solution, + ; if the screen writes are before the colour writes, it results + ; in a relatively long verbatim stretch of bytes when compared to + ; the C64 KERNAL. Thus we have swapped the order, just to reduce + ; the potential for any argument of copyright infringement, even + ; though we really do not believe that the routine can be copyrighted + ; due to the lack of creativity. dey lda (USER),y iny @@ -90,8 +90,8 @@ chrout_screen_ins_copy_loop: cpy PNTR bne chrout_screen_ins_copy_loop - // Increase insert mode count (which causes quote-mode like behaviour) + ; Increase insert mode count (which causes quote-mode like behaviour) inc INSRT - // Return from loop + ; Return from loop rts diff --git a/src/kernal/screen/chrout_screen_jumptable_codes.s b/src/kernal/screen/chrout_screen_jumptable_codes.s index 4299d42a..1777deba 100644 --- a/src/kernal/screen/chrout_screen_jumptable_codes.s +++ b/src/kernal/screen/chrout_screen_jumptable_codes.s @@ -1,91 +1,124 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Jumptable for screen control codes support. To improve performance, should be sorted -// starting from the least probable routine. -// +; +; Jumptable for screen control codes support. To improve performance, should be sorted +; starting from the least probable routine. +; chrout_screen_jumptable_codes: - .byte KEY_CLR - .byte KEY_HOME - .byte KEY_C64_SHIFT_OFF - .byte KEY_C64_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_INS + !byte KEY_CLR + !byte KEY_HOME + !byte KEY_C64_SHIFT_OFF + !byte KEY_C64_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_INS __chrout_screen_jumptable_quote_guard: -#if CONFIG_EDIT_STOPQUOTE - .byte KEY_STOP -#endif -#if CONFIG_EDIT_TABULATORS - .byte KEY_C64_TAB_BW - .byte KEY_C64_TAB_FW -#endif - .byte KEY_DEL - .byte KEY_RETURN +!ifdef CONFIG_EDIT_STOPQUOTE { + !byte KEY_STOP +} +!ifdef CONFIG_EDIT_TABULATORS { + !byte KEY_C64_TAB_BW + !byte KEY_C64_TAB_FW +} + !byte KEY_DEL + !byte KEY_RETURN __chrout_screen_jumptable_codes_end: -.const chrout_list = List().add( - - chrout_screen_CLR, - chrout_screen_HOME, - chrout_screen_SHIFT_OFF, - chrout_screen_SHIFT_ON, - chrout_screen_TXT, - chrout_screen_GFX, - chrout_screen_RVS_OFF, - chrout_screen_RVS_ON, - chrout_screen_CRSR_RIGHT, - chrout_screen_CRSR_LEFT, - chrout_screen_CRSR_DOWN, - chrout_screen_CRSR_UP, - chrout_screen_INS, -#if CONFIG_EDIT_STOPQUOTE - chrout_screen_STOP, -#endif -#if CONFIG_EDIT_TABULATORS - chrout_screen_TAB_BW, - chrout_screen_TAB_FW, -#endif - chrout_screen_DEL, - chrout_screen_RETURN -) - - -#if !HAS_OPCODES_65C02 - +!ifndef HAS_OPCODES_65C02 { chrout_screen_jumptable_lo: - put_jumptable_lo(chrout_list) - + !byte <(chrout_screen_CLR-1) + !byte <(chrout_screen_HOME-1) + !byte <(chrout_screen_SHIFT_OFF-1) + !byte <(chrout_screen_SHIFT_ON-1) + !byte <(chrout_screen_TXT-1) + !byte <(chrout_screen_GFX-1) + !byte <(chrout_screen_RVS_OFF-1) + !byte <(chrout_screen_RVS_ON-1) + !byte <(chrout_screen_CRSR_RIGHT-1) + !byte <(chrout_screen_CRSR_LEFT-1) + !byte <(chrout_screen_CRSR_DOWN-1) + !byte <(chrout_screen_CRSR_UP-1) + !byte <(chrout_screen_INS-1) +!ifdef CONFIG_EDIT_STOPQUOTE { + !byte <(chrout_screen_STOP-1) +} +!ifdef CONFIG_EDIT_TABULATORS { + !byte <(chrout_screen_TAB_BW-1) + !byte <(chrout_screen_TAB_FW-1) +} + !byte <(chrout_screen_DEL-1) + !byte <(chrout_screen_RETURN-1) chrout_screen_jumptable_hi: - put_jumptable_hi(chrout_list) + !byte >(chrout_screen_CLR-1) + !byte >(chrout_screen_HOME-1) + !byte >(chrout_screen_SHIFT_OFF-1) + !byte >(chrout_screen_SHIFT_ON-1) + !byte >(chrout_screen_TXT-1) + !byte >(chrout_screen_GFX-1) + !byte >(chrout_screen_RVS_OFF-1) + !byte >(chrout_screen_RVS_ON-1) + !byte >(chrout_screen_CRSR_RIGHT-1) + !byte >(chrout_screen_CRSR_LEFT-1) + !byte >(chrout_screen_CRSR_DOWN-1) + !byte >(chrout_screen_CRSR_UP-1) + !byte >(chrout_screen_INS-1) +!ifdef CONFIG_EDIT_STOPQUOTE { + !byte >(chrout_screen_STOP-1) +} +!ifdef CONFIG_EDIT_TABULATORS { + !byte >(chrout_screen_TAB_BW-1) + !byte >(chrout_screen_TAB_FW-1) +} + !byte >(chrout_screen_DEL-1) + !byte >(chrout_screen_RETURN-1) - -#else // HAS_OPCODES_65C02 +} else { ; HAS_OPCODES_65C02 chrout_screen_jumptable: - // Note: 65C02 has the page boundary vector bug fixed! - put_jumptable(chrout_list) + ; Note: 65C02 has the page boundary vector bug fixed! -#endif + !word chrout_screen_CLR + !word chrout_screen_HOME + !word chrout_screen_SHIFT_OFF + !word chrout_screen_SHIFT_ON + !word chrout_screen_TXT + !word chrout_screen_GFX + !word chrout_screen_RVS_OFF + !word chrout_screen_RVS_ON + !word chrout_screen_CRSR_RIGHT + !word chrout_screen_CRSR_LEFT + !word chrout_screen_CRSR_DOWN + !word chrout_screen_CRSR_UP + !word chrout_screen_INS +!ifdef CONFIG_EDIT_STOPQUOTE { + !word chrout_screen_STOP +} +!ifdef CONFIG_EDIT_TABULATORS { + !word chrout_screen_TAB_BW + !word chrout_screen_TAB_FW +} + !word chrout_screen_DEL + !word chrout_screen_RETURN +} diff --git a/src/kernal/screen/chrout_screen_quote.s b/src/kernal/screen/chrout_screen_quote.s index 245450ab..084c639d 100644 --- a/src/kernal/screen/chrout_screen_quote.s +++ b/src/kernal/screen/chrout_screen_quote.s @@ -1,24 +1,24 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support, control codes in quote mode -// +; +; CHROUT routine - screen support, control codes in quote mode +; chrout_screen_quote: - // Low control codes are just +$80 + ; 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 -!: + ; 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 @1 + adc #$BF ; C=1, so adding $BF + C = add $C0 +@1: jmp chrout_screen_literal diff --git a/src/kernal/screen/chrout_screen_return.s b/src/kernal/screen/chrout_screen_return.s index 93a28a19..ec9b2c57 100644 --- a/src/kernal/screen/chrout_screen_return.s +++ b/src/kernal/screen/chrout_screen_return.s @@ -1,33 +1,33 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RETURN key handling within CHROUT -// +; +; RETURN key handling within CHROUT +; chrout_screen_RETURN: - // RETURN clears quote and insert modes, it also clears reverse flag + ; RETURN clears quote and insert modes, it also clears reverse flag lda #$00 sta QTSW sta INSRT sta RVS - // RETURN key moves cursor two lines down in case - // of first line of the extended logical line + ; RETURN key moves cursor two lines down in case + ; of first line of the extended logical line ldy TBLX cpy #24 - beq !+ // last line on screen - no need for a double line skip + beq @1 ; last line on screen - no need for a double line skip lda LDTB1+1, y - bmi !+ // current line is not continued + bmi @1 ; current line is not continued inc TBLX jsr screen_calculate_PNT_USER -!: +@1: jmp screen_advance_to_next_line diff --git a/src/kernal/screen/chrout_screen_rvs.s b/src/kernal/screen/chrout_screen_rvs.s index 5703cacc..fed019ec 100644 --- a/src/kernal/screen/chrout_screen_rvs.s +++ b/src/kernal/screen/chrout_screen_rvs.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// RVS ON/OFF handling within CHROUT -// +; +; RVS ON/OFF handling within CHROUT +; chrout_screen_RVS_ON: lda #$80 - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH chrout_screen_RVS_OFF: diff --git a/src/kernal/screen/chrout_screen_shift_onoff.s b/src/kernal/screen/chrout_screen_shift_onoff.s index 0058e836..0104f812 100644 --- a/src/kernal/screen/chrout_screen_shift_onoff.s +++ b/src/kernal/screen/chrout_screen_shift_onoff.s @@ -1,23 +1,23 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// SHIFT ON/OFF handling within CHROUT -// +; +; SHIFT ON/OFF handling within CHROUT +; chrout_screen_SHIFT_ON: - lda #$00 // enable SHIFT+VENDOR combination - skip_2_bytes_trash_nvz + lda #$00 ; enable SHIFT+VENDOR combination + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH chrout_screen_SHIFT_OFF: - lda #$80 // disable SHIFT+VENDOR combination + lda #$80 ; disable SHIFT+VENDOR combination sta MODE jmp chrout_screen_done diff --git a/src/kernal/screen/chrout_screen_stop.s b/src/kernal/screen/chrout_screen_stop.s index d44654f6..243db941 100644 --- a/src/kernal/screen/chrout_screen_stop.s +++ b/src/kernal/screen/chrout_screen_stop.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// STOP key handling within CHROUT -// +; +; STOP key handling within CHROUT +; -#if CONFIG_EDIT_STOPQUOTE +!ifdef CONFIG_EDIT_STOPQUOTE { chrout_screen_STOP: @@ -17,6 +17,4 @@ chrout_screen_STOP: sta QTSW sta INSRT jmp chrout_screen_done - - -#endif +} diff --git a/src/kernal/screen/chrout_screen_tab.s b/src/kernal/screen/chrout_screen_tab.s index 6ca12662..390350de 100644 --- a/src/kernal/screen/chrout_screen_tab.s +++ b/src/kernal/screen/chrout_screen_tab.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tabulation keys handling within CHROUT -// +; +; Tabulation keys handling within CHROUT +; -#if CONFIG_EDIT_TABULATORS +!ifdef CONFIG_EDIT_TABULATORS { chrout_screen_TAB_FW: @@ -19,9 +19,9 @@ chrout_screen_TAB_FW: tay iny cpy #40 - bcc !+ + bcc @1 ldy #39 -!: +@1: sty PNTR jmp chrout_screen_calc_lptr_done @@ -30,14 +30,13 @@ chrout_screen_TAB_FW: chrout_screen_TAB_BW: jsr screen_get_clipped_PNTR - beq !+ // column 0, recalculating pointers is not necessary, but this is a rare case nevertheless + beq @2 ; column 0, recalculating pointers is not necessary, but this is a rare case nevertheless dey tya and #%11111000 sta PNTR -!: +@2: jmp chrout_screen_calc_lptr_done - -#endif // CONFIG_EDIT_TABULATORS +} ; CONFIG_EDIT_TABULATORS diff --git a/src/kernal/screen/chrout_to_screen_code.s b/src/kernal/screen/chrout_to_screen_code.s index 207c512d..f328829a 100644 --- a/src/kernal/screen/chrout_to_screen_code.s +++ b/src/kernal/screen/chrout_to_screen_code.s @@ -1,44 +1,48 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - convert PETSCII to screen code -// +; +; CHROUT routine - convert PETSCII to screen code +; chrout_to_screen_code: - // Codes $C0-$DF become $40-$5F + ; Codes $C0-$DF become $40-$5F cmp #$E0 - bcs !+ + bcs @1 cmp #$C0 - bcc !+ + bcc @1 and #$7F - rts // not high char -!: - // Range $20-$3F is unchanged + rts ; not high char +@1: + ; Range $20-$3F is unchanged cmp #$40 - bcc !+ // not high char + bcc @done ; not high char - // Unshifted letters and symbols from $40-$5F - // all end up being -$40 - // (C64 PRG p376) + ; 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 + ; 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 + ; Fix shifted chars by adding $20 again cmp #$20 - bcc !+ // not high char + bcc @done ; not high char cmp #$40 - bcs !+ // not high char + bcs @done ; not high char clc adc #$20 -!: + + ; FALLTROUGH + +@done: + rts diff --git a/src/kernal/screen/cursor.s b/src/kernal/screen/cursor.s index 4058778b..3e19d327 100644 --- a/src/kernal/screen/cursor.s +++ b/src/kernal/screen/cursor.s @@ -1,36 +1,36 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * 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) -// - USER (current screen line colour pointer) -// - PNT (current screen line pointer) -// - PNTR (current screen x position) -// +; +; Variables used: +; - BLNSW (cursor blink switch) +; - BLNCT (cursor blink countdown) +; - GDBLN (cursor saved character) +; - BLNON (if cursor is visible) +; - GDCOL (colour under cursor) +; - USER (current screen line colour pointer) +; - PNT (current screen line pointer) +; - PNTR (current screen x position) +; cursor_blink: - // Is the cursor enabled? + ; Is the cursor enabled? lda BLNSW bne cursor_blink_end - // Do we need to redraw things? + ; Do we need to redraw things? dec BLNCT bpl cursor_blink_end - // Check if cursor was visible or not, and toggle + ; Check if cursor was visible or not, and toggle lda BLNON bne cursor_undraw - // FALLTROUGH + ; FALLTROUGH cursor_draw: @@ -39,7 +39,7 @@ cursor_draw: sta GDBLN eor #$80 sta (PNT),y - // Also set cursor colour + ; Also set cursor colour lda (USER),y sta GDCOL lda COLOR @@ -48,29 +48,29 @@ cursor_draw: lda #1 sta BLNON - bne cursor_timer_reset // branches always + bne cursor_timer_reset ; branches always -// XXX code below is probably not 100% safe +; XXX code below is probably not 100% safe cursor_disable: lda #$80 sta BLNSW - // FALLTHROUGH + ; FALLTHROUGH cursor_hide_if_visible: - // Set countdown to high value, to prevent IRQ interference + ; Set countdown to high value, to prevent IRQ interference lda #$FF sta BLNCT - // If cursor is not visible, not much to do + ; If cursor is not visible, not much to do lda BLNON beq cursor_timer_reset - // FALLTROUGH + ; FALLTROUGH cursor_undraw: @@ -80,23 +80,23 @@ cursor_undraw: lda GDCOL sta (USER),y - // FALLTROUGH + ; FALLTROUGH -cursor_undraw_cont: // entry point used by MEGA65 screen editor +cursor_undraw_cont: ; entry point used by MEGA65 screen editor - // Mark cursor as not drawn + ; Mark cursor as not drawn lda #0 sta BLNON - // FALLTROUGH + ; FALLTROUGH cursor_timer_reset: - // Rest blink counter (Mapping the 64, p39-40) + ; Rest blink counter (Mapping the 64, p39-40) lda #20 sta BLNCT - // FALLTROUGH + ; FALLTROUGH cursor_blink_end: diff --git a/src/kernal/screen/cursor_enable.s b/src/kernal/screen/cursor_enable.s index 2208768b..88c22c21 100644 --- a/src/kernal/screen/cursor_enable.s +++ b/src/kernal/screen/cursor_enable.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Variables used: -// - BLNSW (cursor blink switch) -// +; +; Variables used: +; - BLNSW (cursor blink switch) +; cursor_enable: diff --git a/src/kernal/screen/cursor_show.s b/src/kernal/screen/cursor_show.s index 585ce97e..98a3c139 100644 --- a/src/kernal/screen/cursor_show.s +++ b/src/kernal/screen/cursor_show.s @@ -1,28 +1,28 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Variables used: -// - BLNSW (cursor blink switch) -// - BLNON (if cursor is visible) -// - BLNCT (cursor blink countdown) -// +; +; Variables used: +; - BLNSW (cursor blink switch) +; - BLNON (if cursor is visible) +; - BLNCT (cursor blink countdown) +; cursor_show_if_enabled: lda BLNSW - bne !+ + bne cursor_show_done lda BLNON - bne !+ + bne cursor_show_done - // FALLTROUGH + ; FALLTROUGH cursor_show: - // Set the cursor so that it is going to be repainted by the next IRQ + ; Set the cursor so that it is going to be repainted by the next IRQ lda #$01 sta BLNCT @@ -30,5 +30,8 @@ cursor_show: lda #$00 sta BLNON -!: + ; FALLTROUGH + +cursor_show_done: + rts diff --git a/src/kernal/screen/e544.clear_screen.s b/src/kernal/screen/e544.clear_screen.s index a153885e..e5ed73fe 100644 --- a/src/kernal/screen/e544.clear_screen.s +++ b/src/kernal/screen/e544.clear_screen.s @@ -1,42 +1,41 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Clear screen and initialise line link table, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - pages 215-216 -// +; +; Clear screen and initialise line link table, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - pages 215-216 +; clear_screen: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcc_16 M65_CLRSCR + +bcc 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 + ; 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 lda #$80 ldy #24 -!: +@1: sta LDTB1,y dey - bpl !- + bpl @1 - // Clear all the rows + ; Clear all the rows ldx #24 -!: +@2: jsr screen_clear_line dex - bpl !- + bpl @2 - // Fall to cursor home routine + ; Fall to cursor home routine jmp cursor_home diff --git a/src/kernal/screen/e566.cursor_home.s b/src/kernal/screen/e566.cursor_home.s index 782f5189..2b08ef7b 100644 --- a/src/kernal/screen/e566.cursor_home.s +++ b/src/kernal/screen/e566.cursor_home.s @@ -1,19 +1,19 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Home the cursor, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 216 -// +; +; Home the cursor, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 216 +; cursor_home: lda #$00 - sta PNTR // current column (logical) - sta TBLX // current row + sta PNTR ; current column (logical) + sta TBLX ; current row - // FALLTROUGH to the next routine + ; FALLTROUGH to the next routine diff --git a/src/kernal/screen/e56c.screen_calculate_pointers.s b/src/kernal/screen/e56c.screen_calculate_pointers.s index 3c30b0b4..2103d1fc 100644 --- a/src/kernal/screen/e56c.screen_calculate_pointers.s +++ b/src/kernal/screen/e56c.screen_calculate_pointers.s @@ -1,26 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Set pointer (PNT) to current screen line , described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 216 -// - http://sta.c64.org/cbm64scrfunc.html -// +; +; Set pointer (PNT) to current screen line , described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 216 +; - http://sta.c64.org/cbm64scrfunc.html +; -// XXX find out what the original ROM really recalculate +; XXX find out what the original ROM really recalculate screen_calculate_pointers: -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr M65_MODEGET - bcc_16 m65_screen_upd_txtrow_off - -#endif + +bcc m65_screen_upd_txtrow_off +} jsr screen_calculate_PNT_USER jmp screen_calculate_PNTR_LNMX diff --git a/src/kernal/screen/e8ea.screen_scroll_up.s b/src/kernal/screen/e8ea.screen_scroll_up.s index be3ab67d..73d1f5a7 100644 --- a/src/kernal/screen/e8ea.screen_scroll_up.s +++ b/src/kernal/screen/e8ea.screen_scroll_up.s @@ -1,66 +1,64 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Scroll the whole screen up by 1 logical line, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 218 -// +; +; Scroll the whole screen up by 1 logical line, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 218 +; screen_scroll_up: - // First handle CTRL and NO_SCRL keys + ; First handle CTRL and NO_SCRL keys -#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 +!ifdef CONFIG_KEYBOARD_C128_OR_C65 { - // Do not scroll if NO_SCRL is pressed and interrupts are enabled -!: + ; Do not scroll if NO_SCRL is pressed and interrupts are enabled +@1: php pla and #%00000010 - bne !+ // branch if IRQs disabled, we cannot detect NO_SCRL status + bne @2 ; branch if IRQs disabled, we cannot detect NO_SCRL status lda SHFLAG and #KEY_FLAG_NO_SCRL - bne !- -!: - -#endif - - // Check if CTRL key pressed - if so, perform a delay + bne @1 +@2: +} + ; Check if CTRL key pressed - if so, perform a delay lda SHFLAG and #KEY_FLAG_CTRL beq screen_scroll_up_delay_done ldy #$09 -!: +@3: ldx #$FF jsr wait_x_bars dey - bne !- + bne @3 - // FALLTROUGH + ; FALLTROUGH -screen_scroll_up_delay_done: // entry point for cursor move control codes +screen_scroll_up_delay_done: ; entry point for cursor move control codes - // Scroll the LDTB1 (line link table) + ; Scroll the LDTB1 (line link table) ldy #$00 -!: +@4: lda LDTB1+1, y sta LDTB1+0, y iny cpy #24 - bne !- + bne @4 lda #$80 sta LDTB1+24 - // Preserve SAL and EAL, prepare initial SAL/EAL/PNT/USER values + ; Preserve SAL and EAL, prepare initial SAL/EAL/PNT/USER values jsr screen_preserve_sal_eal @@ -79,7 +77,7 @@ screen_scroll_up_delay_done: // entry point for cursor move control codes sta SAL+0 sta PNT+0 - // Now copy, SAL->EAL, PNT->USER, in a loop + ; Now copy, SAL->EAL, PNT->USER, in a loop ldy #$00 @@ -90,15 +88,15 @@ screen_scroll_up_loop: lda (PNT), y sta (USER), y - // Check if this was the last byte (last destination byte for color copy is #DBBF) + ; Check if this was the last byte (last destination byte for color copy is #DBBF) cpy #$BF - bne !+ // definitely not the last byte + bne @5 ; definitely not the last byte lda USER+1 cmp #$DB beq screen_scroll_up_loop_done -!: - // Increment .Y, possibly advance pointers +@5: + ; Increment .Y, possibly advance pointers iny bne screen_scroll_up_loop @@ -107,28 +105,28 @@ screen_scroll_up_loop: inc EAL+1 inc USER+1 inc PNT+1 - bne screen_scroll_up_loop // branch alwayys + bne screen_scroll_up_loop ; branch alwayys screen_scroll_up_loop_done: - // Restore SAL and EAL + ; Restore SAL and EAL jsr screen_restore_sal_eal - // Clear the newly introduced line + ; Clear the newly introduced line ldx #24 jsr screen_clear_line - // Decrement the current physical line number + ; Decrement the current physical line number dec TBLX - // If the first line is linked, scroll once more + ; If the first line is linked, scroll once more bit LDTB1+0 bpl screen_scroll_up - // Recalculate PNT and USER + ; Recalculate PNT and USER jmp screen_calculate_PNT_USER diff --git a/src/kernal/screen/e9ff.screen_clear_line.s b/src/kernal/screen/e9ff.screen_clear_line.s index 4611a575..b969e618 100644 --- a/src/kernal/screen/e9ff.screen_clear_line.s +++ b/src/kernal/screen/e9ff.screen_clear_line.s @@ -1,38 +1,38 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Well-known routine, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - page 219 -// - http://sta.c64.org/cbm64scrfunc.html -// -// input: .X - screen line to clear -// -// Checked that original routine preserves X (convenient for loops), -// and leaves space screen code in .A, so duplicate this behaviour -// +; +; Well-known routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - page 219 +; - http://sta.c64.org/cbm64scrfunc.html +; +; input: .X - screen line to clear +; +; Checked that original routine preserves X (convenient for loops), +; and leaves space screen code in .A, so duplicate this behaviour +; screen_clear_line: - // First, calculate PNT and USER - phx_trash_a + ; First, calculate PNT and USER + +phx_trash_a jsr screen_calculate_PNT_USER_from_X - plx_trash_a + +plx_trash_a - // Now clear the line + ; Now clear the line ldy #39 -!: +@1: lda COLOR sta (USER), y - lda #$20 // space character screen code + lda #$20 ; space character screen code sta (PNT), y dey - bpl !- + bpl @1 - // Done + ; Done rts diff --git a/src/kernal/screen/screen.s b/src/kernal/screen/screen.s index f83b39b1..c84cc23c 100644 --- a/src/kernal/screen/screen.s +++ b/src/kernal/screen/screen.s @@ -1,44 +1,44 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmer's Reference Guide - page 295 -// - [CM64] Compute's Mapping the Commodore 64 - page 215 -// -// CPU registers that has to be preserved (see [RG64]): .A -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmer's Reference Guide - page 295 +; - [CM64] Compute's Mapping the Commodore 64 - page 215 +; +; CPU registers that has to be preserved (see [RG64]): .A +; SCREEN: -#if !ROM_LAYOUT_M65 +!ifndef CONFIG_MB_M65 { - // There are only 2 sane ways to implement this routine, - // I hope this one is different than what Commodore picked :) + ; There are only 2 sane ways to implement this routine, + ; I hope this one is different than what Commodore picked :) - ldy #25 // 25 columns - ldx #40 // 40 rows + ldy #25 ; 25 columns + ldx #40 ; 40 rows rts -#else +} else { php jsr M65_MODEGET - bcc !+ + bcc @1 plp - ldy #25 // 25 columns - ldx #40 // 40 rows + ldy #25 ; 25 columns + ldx #40 ; 40 rows rts -!: - // Screen dimensions depends on text mode +@1: + ; Screen dimensions depends on text mode plp pha @@ -50,5 +50,4 @@ SCREEN: pla rts - -#endif +} \ No newline at end of file diff --git a/src/kernal/screen/screen_advance_to_next_line.s b/src/kernal/screen/screen_advance_to_next_line.s index eb02bc8b..eb2e7c21 100644 --- a/src/kernal/screen/screen_advance_to_next_line.s +++ b/src/kernal/screen/screen_advance_to_next_line.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_advance_to_next_line: - // Check if we are at the bottom of the screen + ; Check if we are at the bottom of the screen ldy TBLX cpy #24 - bne !+ + bne @1 - // We need to scroll the screen up + ; We need to scroll the screen up jsr screen_scroll_up -!: +@1: inc TBLX - // Set PNTR to 0 (for continued line will be fixed later) + ; Set PNTR to 0 (for continued line will be fixed later) lda #$00 sta PNTR diff --git a/src/kernal/screen/screen_calculate_pnt_user.s b/src/kernal/screen/screen_calculate_pnt_user.s index 75603fc1..acea7d8e 100644 --- a/src/kernal/screen/screen_calculate_pnt_user.s +++ b/src/kernal/screen/screen_calculate_pnt_user.s @@ -1,48 +1,48 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Set pointers PNT and USER to current screen line -// +; +; Set pointers PNT and USER to current screen line +; screen_calculate_PNT_USER: ldx TBLX - // FALLTROUGH + ; FALLTROUGH -screen_calculate_PNT_USER_from_X: // entry point for screen_clear_line +screen_calculate_PNT_USER_from_X: ; entry point for screen_clear_line - // Reset pointer to start of screen + ; Reset pointer to start of screen lda HIBASE sta PNT+1 lda #$00 sta PNT+0 - // Add 40 to PNT for every line + ; Add 40 to PNT for every line cpx #$00 beq screen_calculate_USER -!: +@1: lda #40 clc adc PNT+0 sta PNT+0 - bcc !+ + bcc @2 inc PNT+1 -!: +@2: dex - bne !-- + bne @1 - // FALLTROUGH + ; FALLTROUGH screen_calculate_USER: - // Calculate USER (pointer to the current line in color RAM) + ; Calculate USER (pointer to the current line in color RAM) lda PNT+0 sta USER+0 diff --git a/src/kernal/screen/screen_calculate_pntr_lnmx.s b/src/kernal/screen/screen_calculate_pntr_lnmx.s index 75c31643..3ed7ccae 100644 --- a/src/kernal/screen/screen_calculate_pntr_lnmx.s +++ b/src/kernal/screen/screen_calculate_pntr_lnmx.s @@ -1,12 +1,12 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Sets PNTR in a proper range (0-39 or 40-79) -// Sets LNMX to 39 or 79 -// +; +; Sets PNTR in a proper range (0-39 or 40-79) +; Sets LNMX to 39 or 79 +; screen_calculate_PNTR_LNMX: @@ -18,7 +18,7 @@ screen_calculate_PNTR_LNMX: plp bmi screen_calculate_PNTR_0_39 - // FALLTROUGH + ; FALLTROUGH screen_calculate_PNTR_40_79: @@ -27,35 +27,35 @@ screen_calculate_PNTR_40_79: adc #40 tay - // FALLTROUGH + ; FALLTROUGH screen_calculate_PNTR_0_39: sty PNTR - // FALLTROUGH + ; FALLTROUGH screen_calculate_LNMX: ldy TBLX lda LDTB1, y - bpl screen_calculate_lnmx_79 // this line is a continuation + bpl screen_calculate_lnmx_79 ; this line is a continuation cpy #24 - beq screen_calculate_lnmx_39 // this is the last line, which is not a continuation + beq screen_calculate_lnmx_39 ; this is the last line, which is not a continuation iny lda LDTB1, y - bpl screen_calculate_lnmx_79 // line is continued + bpl screen_calculate_lnmx_79 ; line is continued - // FALLTROUGH + ; FALLTROUGH screen_calculate_lnmx_39: lda #39 - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH screen_calculate_lnmx_79: diff --git a/src/kernal/screen/screen_check_space_ends_line.s b/src/kernal/screen/screen_check_space_ends_line.s index 7c1243b5..b6ce85bb 100644 --- a/src/kernal/screen/screen_check_space_ends_line.s +++ b/src/kernal/screen/screen_check_space_ends_line.s @@ -1,7 +1,7 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_check_space_ends_line: diff --git a/src/kernal/screen/screen_check_toggle_quote.s b/src/kernal/screen/screen_check_toggle_quote.s index 255f1d19..73899019 100644 --- a/src/kernal/screen/screen_check_toggle_quote.s +++ b/src/kernal/screen/screen_check_toggle_quote.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine - check character in .A, toggles quote flag if needed -// +; +; Helper routine - check character in .A, toggles quote flag if needed +; screen_check_toggle_quote: cmp #$22 - bne !+ + bne @1 lda QTSW eor #$80 sta QTSW - lda #$22 // restore previous .A valuee -!: + lda #$22 ; restore previous .A valuee +@1: rts diff --git a/src/kernal/screen/screen_code_to_petscii.s b/src/kernal/screen/screen_code_to_petscii.s index e19aad58..e72c63ac 100644 --- a/src/kernal/screen/screen_code_to_petscii.s +++ b/src/kernal/screen/screen_code_to_petscii.s @@ -1,52 +1,52 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Screen code to PETSCII conversion - see: -// -// - https://www.lemon64.com/forum/viewtopic.php?t=66362 -// - https://sta.c64.org/cbm64scrtopetext.html -// +; +; Screen code to PETSCII conversion - see: +; +; - https://www.lemon64.com/forum/viewtopic.php?t=66362 +; - https://sta.c64.org/cbm64scrtopetext.html +; screen_code_to_petscii: cmp #$20 - bcc s2p_adc_40 // $00-$1F -> $40-$5F + bcc s2p_adc_40 ; $00-$1F -> $40-$5F cmp #$40 - bcc s2p_end // $20-$3F -> $20-$3F + bcc s2p_end ; $20-$3F -> $20-$3F cmp #$60 - bcc s2p_adc_80 // $40-$5F -> $C0-$DF + bcc s2p_adc_80 ; $40-$5F -> $C0-$DF cmp #$80 - bcc s2p_adc_40 // $60-$7F -> $A0-$BF + bcc s2p_adc_40 ; $60-$7F -> $A0-$BF - // Here we have to check for quote mode + ; Here we have to check for quote mode bit QTSW bmi screen_code_to_petscii_quote - // Not quote mode - continue + ; Not quote mode - continue cmp #$A0 - bcc s2p_adc_C0 // $80-$9F -> $40-$5F + bcc s2p_adc_C0 ; $80-$9F -> $40-$5F cmp #$C0 - bcc s2p_adc_80 // $A0-$BF -> $20-$3F + bcc s2p_adc_80 ; $A0-$BF -> $20-$3F cmp #$E0 - bcc s2p_end // $C0-$DF -> $C0-$DF + bcc s2p_end ; $C0-$DF -> $C0-$DF clc - bcc s2p_adc_C0 // $E0-$FF -> $A0-$BF + bcc s2p_adc_C0 ; $E0-$FF -> $A0-$BF s2p_adc_40: - adc #$40 // Carry already clear + adc #$40 ; Carry already clear s2p_end: @@ -54,19 +54,19 @@ s2p_end: s2p_adc_80: - adc #$80 // Carry already clear + adc #$80 ; Carry already clear rts screen_code_to_petscii_quote: cmp #$C0 - bcc s2p_adc_80 // $80-$BF -> $00-$3F + bcc s2p_adc_80 ; $80-$BF -> $00-$3F clc - // FALLTROUGH $C0-$FF -> $80-$BF + ; FALLTROUGH $C0-$FF -> $80-$BF s2p_adc_C0: - adc #$C0 // Carry already clear + adc #$C0 ; Carry already clear rts diff --git a/src/kernal/screen/screen_get_cliped_pntr.s b/src/kernal/screen/screen_get_cliped_pntr.s index 355499fb..6839ecf1 100644 --- a/src/kernal/screen/screen_get_cliped_pntr.s +++ b/src/kernal/screen/screen_get_cliped_pntr.s @@ -1,20 +1,20 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Get PNTR value clipped to 0-39 range in .Y, sets flags to compare with 0, can trash .A -// +; +; Get PNTR value clipped to 0-39 range in .Y, sets flags to compare with 0, can trash .A +; screen_get_clipped_PNTR: ldy PNTR cpy #40 - bcc !+ + bcc @1 tya sbc #40 tay -!: +@1: cpy #$00 rts diff --git a/src/kernal/screen/screen_get_logical_line_end_ptr.s b/src/kernal/screen/screen_get_logical_line_end_ptr.s index d52dbc75..63ef357d 100644 --- a/src/kernal/screen/screen_get_logical_line_end_ptr.s +++ b/src/kernal/screen/screen_get_logical_line_end_ptr.s @@ -1,22 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_get_logical_line_end_ptr: ldy TBLX cpy #24 - bcs screen_get_logical_line_end_39 // last line of the screen + bcs screen_get_logical_line_end_39 ; last line of the screen lda LDTB1+0, y - bpl screen_get_logical_line_end_39 // current line continues previous one + bpl screen_get_logical_line_end_39 ; current line continues previous one lda LDTB1+1, y - bmi screen_get_logical_line_end_39 // current line is not continued + bmi screen_get_logical_line_end_39 ; current line is not continued - // FALLTROUGH + ; FALLTROUGH screen_get_logical_line_end_79: diff --git a/src/kernal/screen/screen_grow_logical_line.s b/src/kernal/screen/screen_grow_logical_line.s index b7e5acc6..72552579 100644 --- a/src/kernal/screen/screen_grow_logical_line.s +++ b/src/kernal/screen/screen_grow_logical_line.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_grow_logical_line_done_scroll: inc TBLX - // FALLTROUGH + ; FALLTROUGH screen_grow_logical_line_done: @@ -19,59 +19,59 @@ screen_grow_logical_line_screen_up: jsr screen_scroll_up - // FALLTROUGH + ; FALLTROUGH screen_grow_logical_line: - // Do not grow line if previus one is grown + ; Do not grow line if previus one is grown ldy TBLX lda LDTB1+0, y bpl screen_grow_logical_line_done_scroll - // If last line, scroll the screen up + ; If last line, scroll the screen up cpy #24 beq screen_grow_logical_line_screen_up - // Do not grow line if already grown + ; Do not grow line if already grown lda LDTB1+1, y bpl screen_grow_logical_line_done - // Preserve SAL and EAL + ; Preserve SAL and EAL jsr screen_preserve_sal_eal - // Scroll LDTB1 down (start from the end) + ; Scroll LDTB1 down (start from the end) ldy #23 -!: +@1: cpy TBLX - beq !+ - bcc !+ + beq @2 + bcc @2 lda LDTB1+0, y sta LDTB1+1, y dey - bne !- -!: - // Mark current line as grown + bne @1 +@2: + ; Mark current line as grown ldy TBLX lda #$00 sta LDTB1+1, y - // Now we have to scroll lines downwards to make space. We start from the end, - // and work backwards. We cannot be as simple and efficient here as we are - // for scrolling up, because we do not know how much must be scrolled. + ; Now we have to scroll lines downwards to make space. We start from the end, + ; and work backwards. We cannot be as simple and efficient here as we are + ; for scrolling up, because we do not know how much must be scrolled. - // Work out how many physical lines to scroll down + ; Work out how many physical lines to scroll down lda #23 sec sbc TBLX - beq screen_grow_logical_line_copy_done // branch if no need to copyy + beq screen_grow_logical_line_copy_done ; branch if no need to copyy tax - // Prepare initial SAL/EAL/PNT/USER values + ; Prepare initial SAL/EAL/PNT/USER values lda HIBASE clc @@ -79,64 +79,64 @@ screen_grow_logical_line: sta SAL+1 sta EAL+1 - lda #>$DB00 // 3rd page of the color memory + lda #>$DB00 ; 3rd page of the color memory sta PNT+1 sta USER+1 - lda #<$03C0 // start of destination row + lda #<$03C0 ; start of destination row sta EAL+0 sta USER+0 - lda #<$0398 // start of source row + lda #<$0398 ; start of source row sta SAL+0 sta PNT+0 screen_grow_logical_line_loop: - // Scroll down one line each loop iteration + ; Scroll down one line each loop iteration ldy #39 -!: +@3: lda (SAL), y sta (EAL), y lda (PNT), y sta (USER), y dey - bpl !- + bpl @3 - // Decrement SAL/PNT pointers by 40 (optimized due to fact they share LSB) + ; Decrement SAL/PNT pointers by 40 (optimized due to fact they share LSB) lda SAL+0 sec sbc #40 sta SAL+0 sta PNT+0 - bcs !+ + bcs @4 dec SAL+1 dec PNT+1 -!: - // Decrement EAL/USER pointers by 40 (optimized due to fact they share LSB) +@4: + ; Decrement EAL/USER pointers by 40 (optimized due to fact they share LSB) lda EAL+0 sec sbc #40 sta EAL+0 sta USER+0 - bcs !+ + bcs @5 dec EAL+1 dec USER+1 -!: - // Next loop iteration +@5: + ; Next loop iteration dex bne screen_grow_logical_line_loop screen_grow_logical_line_copy_done: - // Restore SAL and EAL + ; Restore SAL and EAL jsr screen_restore_sal_eal - // Erase newly inserted line and quit + ; Erase newly inserted line and quit ldx TBLX inx diff --git a/src/kernal/screen/screen_off.s b/src/kernal/screen/screen_off.s index 21ee078e..7e285bbd 100644 --- a/src/kernal/screen/screen_off.s +++ b/src/kernal/screen/screen_off.s @@ -1,14 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to blank screen -// +; +; Helper routine to blank screen +; +!set NEEDED = 0 +!ifdef HAS_TAPE { !set NEEDED = 1 } +!ifdef CONFIG_IEC_JIFFYDOS { !ifndef CONFIG_MEMORY_MODEL_60K { !set NEEDED = 1 } } -#if ((CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO)) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K) +!if NEEDED { screen_off: @@ -17,16 +20,14 @@ screen_off: and #($FF - $10) sta VIC_SCROLY - // To be sure there are no badlines we have to wait till the next screen, - // as the bit is checked by VIC-II at the start of the frame only -!: - lda VIC_SCROLY // wait for higher part of screen - bpl !- -!: - lda VIC_SCROLY // wait for lower part of the screen - bmi !- + ; To be sure there are no badlines we have to wait till the next screen, + ; as the bit is checked by VIC-II at the start of the frame only +@1: + lda VIC_SCROLY ; wait for higher part of screen + bpl @1 +@2: + lda VIC_SCROLY ; wait for lower part of the screen + bmi @2 rts - - -#endif +} diff --git a/src/kernal/screen/screen_on.s b/src/kernal/screen/screen_on.s index 57e81c02..d05c5aba 100644 --- a/src/kernal/screen/screen_on.s +++ b/src/kernal/screen/screen_on.s @@ -1,14 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Helper routine to show screen -// +; +; Helper routine to show screen +; +!set NEEDED = 0 +!ifdef HAS_TAPE { !set NEEDED = 1 } +!ifdef CONFIG_IEC_JIFFYDOS { !ifndef CONFIG_MEMORY_MODEL_60K { !set NEEDED = 1 } } -#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K) +!if NEEDED { screen_on: @@ -18,6 +21,4 @@ screen_on: sta VIC_SCROLY rts - - -#endif +} diff --git a/src/kernal/screen/screen_preserve_sal_eal.s b/src/kernal/screen/screen_preserve_sal_eal.s index a576cbab..3f31ed29 100644 --- a/src/kernal/screen/screen_preserve_sal_eal.s +++ b/src/kernal/screen/screen_preserve_sal_eal.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_preserve_sal_eal: - plx_trash_a - ply_trash_a + +plx_trash_a + +ply_trash_a - // Note: While the following routine is obvious to any skilled - // in the art as the most obvious simple and efficient solution, - // it results in a relatively long verbatim stretch of bytes when - // compared to the C64 KERNAL. Thus we have swapped the order, - // just to reduce the potential for any argument of copyright - // infringement, even though we really do not believe that the - // routine can be copyrighted due to the lack of creativity. + ; Note: While the following routine is obvious to any skilled + ; in the art as the most obvious simple and efficient solution, + ; it results in a relatively long verbatim stretch of bytes when + ; compared to the C64 KERNAL. Thus we have swapped the order, + ; just to reduce the potential for any argument of copyright + ; infringement, even though we really do not believe that the + ; routine can be copyrighted due to the lack of creativity. lda SAL+0 pha @@ -26,10 +26,10 @@ screen_preserve_sal_eal: lda EAL+1 pha - // FALLTROUGH + ; FALLTROUGH screen_common_sal_eal: - phy_trash_a - phx_trash_a + +phy_trash_a + +phx_trash_a rts diff --git a/src/kernal/screen/screen_restore_sal_eal.s b/src/kernal/screen/screen_restore_sal_eal.s index 6f10b390..6e822740 100644 --- a/src/kernal/screen/screen_restore_sal_eal.s +++ b/src/kernal/screen/screen_restore_sal_eal.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# X16 * #IGNORE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# X16 * #IGNORE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE screen_restore_sal_eal: - plx_trash_a - ply_trash_a + +plx_trash_a + +ply_trash_a - // Note: While the following routine is obvious to any skilled - // in the art as the most obvious simple and efficient solution, - // it results in a relatively long verbatim stretch of bytes when - // compared to the C64 KERNAL. Thus we have swapped the order, - // just to reduce the potential for any argument of copyright - // infringement, even though we really do not believe that the - // routine can be copyrighted due to the lack of creativity. + ; Note: While the following routine is obvious to any skilled + ; in the art as the most obvious simple and efficient solution, + ; it results in a relatively long verbatim stretch of bytes when + ; compared to the C64 KERNAL. Thus we have swapped the order, + ; just to reduce the potential for any argument of copyright + ; infringement, even though we really do not believe that the + ; routine can be copyrighted due to the lack of creativity. pla sta EAL+1 diff --git a/src/kernal/screen_m65/mega65_chrin_keyboard.s b/src/kernal/screen_m65/mega65_chrin_keyboard.s index 9ed62009..76f02967 100644 --- a/src/kernal/screen_m65/mega65_chrin_keyboard.s +++ b/src/kernal/screen_m65/mega65_chrin_keyboard.s @@ -1,50 +1,50 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Keyboard part of the CHRIN routine, version for MEGA65 native mode -// +; +; Keyboard part of the CHRIN routine, version for MEGA65 native mode +; -m65_chrin_keyboard: // XXX connnect this function to Kernal +m65_chrin_keyboard: ; XXX connnect this function to Kernal - // Preserve .X, .Y and .Z register + ; Preserve .X, .Y and .Z register phx phy phz - // FALLTROUGH + ; 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. + ; 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 + ; 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 + ; Clear pending input and quote flags lda #$00 sta CRSW sta QTSW - // FALLTROUGH + ; FALLTROUGH m65_chrin_keyboard_empty_line: - // For an empty line, just return the carriage return + ; For an empty line, just return the carriage return lda #$0D - // FALLTROUGH + ; FALLTROUGH m65_chrin_keyboard_end: @@ -56,12 +56,12 @@ m65_chrin_keyboard_end: m65_chrin_keyboard_not_end_of_input: - // Advance index, return the next byte + ; Advance index, return the next byte inc CRSW tay - // FALLTROUGH + ; FALLTROUGH m65_chrin_keyboard_return_byte: @@ -69,38 +69,38 @@ m65_chrin_keyboard_return_byte: tya taz - lda_lp (M65_LPNT_SCR), z + lda [M65_LPNT_SCR], z jsr screen_check_toggle_quote jsr screen_code_to_petscii - jmp_8 m65_chrin_keyboard_end + bra m65_chrin_keyboard_end m65_chrin_keyboard_read: jsr cursor_enable - // Wait for a key + ; Wait for a key lda NDX beq m65_chrin_keyboard_repeat lda KEYD cmp #$0D bne m65_chrin_keyboard_not_enter - // FALLTROUGH + ; FALLTROUGH m65_chrin_keyboard_enter: - // Disable cursor, retrieve code from keyboard buffer + ; 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) + ; 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 + ; Set pointer to the input, start for the viewport offset + screen memory base clc lda M65_COLVIEW+0 adc M65_SCRBASE+0 @@ -108,7 +108,7 @@ m65_chrin_keyboard_enter: lda M65_COLVIEW+1 adc M65_SCRBASE+1 sta M65__SCRINPUT+1 - // Add current row offset + ; Add current row offset clc lda M65__SCRINPUT+0 adc M65_TXTROW_OFF+0 @@ -117,54 +117,53 @@ m65_chrin_keyboard_enter: adc M65_TXTROW_OFF+1 sta M65__SCRINPUT+1 - // Retrieve first byte which is not space + ; Retrieve first byte which is not space jsr m65_helper_scrlpnt_chrin - ldy M65_COLVIEWMAX // XXX add support for windowed mode here + ldy M65_COLVIEWMAX ; XXX add support for windowed mode here iny - // FALLTROUGH + ; FALLTROUGH m65_chrin_enter_loop: - // Skip spaces at the end of line + ; Skip spaces at the end of line dey bmi m65_chrin_keyboard_empty_line tya taz - lda_lp (M65_LPNT_SCR), z + lda [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 + ; XXX add windowed mode support here - correct INDX and M65__SCRINPUT - // Set mark informing that we are returning a line + ; Set mark informing that we are returning a line ldy #$01 sty CRSW - // Clear quote mode mark + ; Clear quote mode mark dey sty QTSW - // Return first char of line - jmp_8 m65_chrin_keyboard_return_byte // branch always + ; Return first char of line + bra m65_chrin_keyboard_return_byte ; branch always m65_chrin_keyboard_not_enter: lda KEYD -#if CONFIG_PROGRAMMABLE_KEYS +!ifdef 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 + ; 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 index c2533579..933062f8 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen.s +++ b/src/kernal/screen_m65/mega65_chrout_screen.s @@ -1,87 +1,87 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// CHROUT routine - screen support (character output), MEGA65 native mode version -// +; +; CHROUT routine - screen support (character output), MEGA65 native mode version +; m65_chrout_screen: jsr m65_cursor_hide_if_visible - // Retrieve the character to output + ; 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 + ; 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 + +beq m65_chrout_screen_control txa - // Literals - first convert PETSCII to screen code + ; Literals - first convert PETSCII to screen code jsr chrout_to_screen_code - // FALLTROUGH + ; FALLTROUGH -m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote +m65_chrout_screen_literal: ; entry point for m65_chrout_screen_quote - // Write normal character on the screen + ; Write normal character on the screen - tax // store screen code, we need .A for calculations + tax ; store screen code, we need .A for calculations - // Preserve .Z on stack + ; Preserve .Z on stack phz - // Prepare .Z and M65_LPNT_SCR for colour memory manipulation + ; 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 + ; Store the new color in screen memory lda COLOR - sta_lp (M65_LPNT_SCR),z + sta [M65_LPNT_SCR], z - // Now change M65_LPNT_SCR to point to screen memory + ; Now change M65_LPNT_SCR to point to screen memory jsr m65_helper_scrlpnt_to_screen - // Decrement number of chars waiting to be inserted + ; Decrement number of chars waiting to be inserted lda INSRT - beq !+ + beq @1 dec INSRT -!: - // Toggle quote flag if required +@1: + ; Toggle quote flag if required txa jsr screen_check_toggle_quote - // Store the new character in screen memory, restore .Z + ; 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 + bpl @2 + ora #$80 ; reverse the character XXX consider doing this within chrout_to_screen_code +@2: + sta [M65_LPNT_SCR], z - // Restore .Z + ; Restore .Z plz - // Increment screen column by 1 + ; Increment screen column by 1 inc M65__TXTCOL - // FALLTROUGH + ; FALLTROUGH m65_chrout_fix_column_row: @@ -90,158 +90,158 @@ m65_chrout_fix_column_row: bit M65_SCRWINMODE bmi m65_chrout_fix_column_row_win - // Non-windowed mode + ; Non-windowed mode - // Check for column below 0 + ; Check for column below 0 lda M65__TXTCOL - bpl !++ + bpl @4 lda M65_COLVIEW+0 ora M65_COLVIEW+1 ora M65__TXTROW - bne !+ + bne @3 lda #$00 sta M65__TXTCOL - jmp_8 !++ -!: + bra @4 +@3: dec M65__TXTROW lda m65_scrtab_txtwidth,y sta M65__TXTCOL dec M65__TXTCOL -!: - // Check for column above maximum +@4: + ; Check for column above maximum lda M65__TXTCOL cmp m65_scrtab_txtwidth,y - bcc !+ + bcc @5 inc M65__TXTROW lda #$00 sta M65__TXTCOL -!: - // Check for row below 0 +@5: + ; Check for row below 0 lda M65__TXTROW - bpl !+ + bpl @6 jsr m65_chrout_fix_scroll_down -!: - // Check for row above maximum +@6: + ; Check for row above maximum lda M65__TXTROW cmp m65_scrtab_txtheight,y - bcc !+ + bcc @7 jsr m65_chrout_fix_scroll_up -!: - jmp_8 m65_chrout_fix_txtrow_off +@7: + bra m65_chrout_fix_txtrow_off m65_chrout_fix_column_row_win: - // Windowed mode + ; Windowed mode - // XXX - // XXX provide implementation - // XXX + ; XXX + ; XXX provide implementation + ; XXX - nop + +nop - // FALLTROUGH + ; FALLTROUGH m65_chrout_fix_txtrow_off: jsr m65_screen_upd_txtrow_off - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_done: jsr cursor_show_if_enabled - // XXX make sure it return success + ; XXX make sure it return success rts -// Try to fix coordinates by scrolling the screen down +; 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 + ; 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 + ; Yes, we can simply adapt the viewport sec lda M65_COLVIEW+0 sbc #$50 sta M65_COLVIEW+0 sta VIC_COLPTR+0 - bcs !+ + bcs @8 dec M65_COLVIEW+1 dec VIC_COLPTR+1 -!: +@8: sec lda VIC_SCRNPTR+0 sbc #$50 sta VIC_SCRNPTR+0 - bcs !+ + bcs @9 dec VIC_SCRNPTR+1 -!: - // FALLTROUGH +@9: + ; FALLTROUGH m65_chrout_fix_scroll_down_end: rts -// Try to fix coordinates by scrolling the screen up +; 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 + ; Check if we can simply adapt the viewport lda M65_COLVIEW+1 cmp M65_COLVIEWMAX+1 - bne !+ + bne @10 lda M65_COLVIEW+0 cmp M65_COLVIEWMAX+0 beq m65_chrout_fix_scroll_up_scroll -!: - // Yes, we can simply adapt the viewport +@10: + ; Yes, we can simply adapt the viewport clc lda M65_COLVIEW+0 adc #$50 sta M65_COLVIEW+0 sta VIC_COLPTR+0 - bcc !+ + bcc @11 inc M65_COLVIEW+1 inc VIC_COLPTR+1 -!: +@11: clc lda VIC_SCRNPTR+0 adc #$50 sta VIC_SCRNPTR+0 - bcc !+ + bcc @12 inc VIC_SCRNPTR+1 -!: +@12: rts m65_chrout_fix_scroll_up_scroll: - // Virtual screen is too small - we will lose one row + ; Virtual screen is too small - we will lose one row - // Calculate size of data to copy + ; Calculate size of data to copy sec lda M65_COLGUARD+0 @@ -251,19 +251,19 @@ m65_chrout_fix_scroll_up_scroll: sbc #$00 sta M65_DMAJOB_SIZE_1 - // Scroll up screen memory + ; Scroll up screen memory jsr m65_screen_dmasrcdst_screen jsr m65_screen_dmasrc_add_row jsr m65_dmagic_oper_copy - // Scroll up color memory + ; 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 + ; Clear the last row - color and screen memory phz @@ -271,18 +271,18 @@ m65_chrout_fix_scroll_up_scroll: lda COLOR and #$0F ldz M65_SCRCOLMAX -!: - sta_lp (M65_LPNT_SCR), z +@13: + sta [M65_LPNT_SCR], z dez - bpl !- + bpl @13 jsr m65_helper_scrlpnt_to_screen lda #$20 ldz M65_SCRCOLMAX -!: - sta_lp (M65_LPNT_SCR), z +@14: + sta [M65_LPNT_SCR], z dez - bpl !- + bpl @14 plz diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s index 3ad9551a..d2bd24b0 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s @@ -1,5 +1,5 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE m65_chrout_screen_control: @@ -15,32 +15,32 @@ 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? + ; Is this insert/quote mode? tay lda QTSW ora INSRT - beq !+ + beq @1 tya jmp m65_chrout_screen_quote -!: +@1: tya - // FALLTROUGH + ; FALLTROUGH m65_chrout_try_jumptable_loop_noquote: cmp m65_chrout_screen_jumptable_codes, x - bne !+ + bne @2 - // Found, perform a jump to subroutine + ; Found, perform a jump to subroutine txa asl tax jmp (m65_chrout_screen_jumptable, x) -!: +@2: dex bpl m65_chrout_try_jumptable_loop @@ -51,7 +51,7 @@ m65_chrout_try_COLOR: m65_chrout_try_color_loop: cmp colour_codes,x - bne !+ + bne @3 lda COLOR and #$F0 @@ -62,35 +62,35 @@ m65_chrout_try_color_loop: sta COLOR jmp m65_chrout_screen_done -!: +@3: dex bpl m65_chrout_try_color_loop - // Unknown code, or key not requiring any handling + ; Unknown code, or key not requiring any handling jmp m65_chrout_screen_done -// XXX: implement screen routines below: +; XXX: implement screen routines below: m65_chrout_screen_TAB: - nop + +nop m65_chrout_screen_LINE_FEED: - nop + +nop m65_chrout_screen_UNDERLINE_ON: - nop + +nop m65_chrout_screen_UNDERLINE_OFF: - nop + +nop m65_chrout_screen_FLASHING_ON: - nop + +nop m65_chrout_screen_FLASHING_OFF: - nop + +nop m65_chrout_screen_TAB_SET_CLR: - nop + +nop m65_chrout_screen_ESC: - nop + +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 index 9264e959..4a3b62db 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_1.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_1.s @@ -1,62 +1,62 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// Cursor movement +; Cursor movement m65_chrout_screen_CRSR_RIGHT: inc M65__TXTCOL - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_CRSR_LEFT: dec M65__TXTCOL - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_CRSR_DOWN: inc M65__TXTROW - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_CRSR_UP: dec M65__TXTROW - jmp_8 m65_chrout_screen_ctrl1_end + bra m65_chrout_screen_ctrl1_end -// 'RETURN' key +; 'RETURN' key m65_chrout_screen_RETURN: - // RETURN clears quote and insert modes, it also clears reverse flag + ; 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 + ; Move cursor to the beginning of the next line bit M65_SCRWINMODE - bpl !+ + bpl @1 lda M65_TXTWIN_X0 - skip_2_bytes_trash_nvz -!: + +skip_2_bytes_trash_nvz +@1: lda #$00 sta M65__TXTCOL inc M65__TXTROW - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_ctrl1_end: - // Correct the column/row values + ; 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 index 606d7cb0..d935efab 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s @@ -1,15 +1,15 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// 'REVERSE' mode support +; 'REVERSE' mode support m65_chrout_screen_RVS_ON: lda #$80 - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_RVS_OFF: @@ -17,134 +17,138 @@ m65_chrout_screen_RVS_OFF: sta RVS - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_ctrl2_end: jmp m65_chrout_screen_done -// 'SHIFT ON/OFF' support +; 'SHIFT ON/OFF' support m65_chrout_screen_SHIFT_ON: - lda #$00 // enable SHIFT+VENDOR combination - skip_2_bytes_trash_nvz + lda #$00 ; enable SHIFT+VENDOR combination + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH m65_chrout_screen_SHIFT_OFF: - lda #$80 // disable SHIFT+VENDOR combination + lda #$80 ; disable SHIFT+VENDOR combination sta MODE - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end -// STOP key support +; STOP key support m65_chrout_screen_STOP: lda #$00 sta QTSW sta INSRT - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end -// CLR/HOME key support +; CLR/HOME key support m65_chrout_screen_CLR: jsr M65_CLRWIN - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end m65_chrout_screen_HOME: jsr M65_HOME - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end -// Character set switching +; Character set switching m65_chrout_screen_GFX: lda VIC_CHARPTR+1 ora #%00001000 -!: + + ; FALLTROUGH + +m65_chrout_screen_GFX_cont: + sta VIC_CHARPTR+1 - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end m65_chrout_screen_TXT: lda VIC_CHARPTR+1 and #%11110111 - jmp_8 !- + bra m65_chrout_screen_GFX_cont -// INS key +; INS key m65_chrout_screen_INS: - // First prepare the pointer to the current row + ; First prepare the pointer to the current row jsr m65_helper_scrlpnt_color jsr m65_helper_scrlpnt_to_screen - // Check for windowed mode + ; Check for windowed mode lda M65_SCRWINMODE - bmi_16 m65_chrout_screen_INS_winmode + +bmi m65_chrout_screen_INS_winmode - // Check if last character of the line is space + ; Check if last character of the line is space ldy M65_SCRMODE lda m65_scrtab_txtwidth,y - dec_a + dec taz - lda_lp (M65_LPNT_SCR), z + lda [M65_LPNT_SCR], z cmp #$20 - bne_16 m65_chrout_screen_ctrl2_end + +bne m65_chrout_screen_ctrl2_end phz - // Last character is space - move the characters + ; Last character is space - move the characters jsr m65_chrout_screen_INS_copy - // Store space in the current character cell + ; Store space in the current character cell lda #$20 - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z - // Move the color memory + ; Move the color memory jsr m65_helper_scrlpnt_color plz jsr m65_chrout_screen_INS_copy - // Store current colour in the current character cell + ; Store current colour in the current character cell lda COLOR and #$0F - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z - // Increase insert mode count (which causes quote-mode like behaviour) and quit + ; Increase insert mode count (which causes quote-mode like behaviour) and quit inc INSRT - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end m65_chrout_screen_INS_winmode: - // Check if last character of the line within window is space + ; Check if last character of the line within window is space - // XXX provide implementation + ; XXX provide implementation - jmp_8 m65_chrout_screen_ctrl2_end + bra m65_chrout_screen_ctrl2_end m65_chrout_screen_INS_copy: dez - lda_lp (M65_LPNT_SCR), z + lda [M65_LPNT_SCR], z inz - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z dez cpz M65__TXTCOL bne m65_chrout_screen_INS_copy diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control_del.s b/src/kernal/screen_m65/mega65_chrout_screen_control_del.s index 54462dd6..b1baaaa9 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_del.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_del.s @@ -1,23 +1,23 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// 'DEL' key support +; 'DEL' key support m65_chrout_screen_DEL: - // First check for window mode + ; 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 + ; 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 + ; Not a window mode, not a first column - we can safely + ; delete the character and sroll back the rest of the row phz @@ -27,18 +27,18 @@ m65_chrout_screen_DEL: ldz M65_SCRCOLMAX lda COLOR and #$0F - sta_lp (M65_LPNT_SCR), z + sta [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 + sta [M65_LPNT_SCR], z plz - // End by moving cursor one position left + ; End by moving cursor one position left jmp m65_chrout_screen_CRSR_LEFT @@ -46,33 +46,33 @@ m65_chrout_screen_DEL_copy: ldz M65__TXTCOL dez -!: +@1: cpz M65_SCRCOLMAX - beq !+ + beq @2 inz - lda_lp (M65_LPNT_SCR), z + lda [M65_LPNT_SCR], z dez - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z inz - jmp_8 !- -!: + bra @1 +@2: rts m65_chrout_screen_DEL_1stcol: - // Start by moving one position left + ; Start by moving one position left jsr m65_chrout_screen_CRSR_LEFT - // If we are still in the first column - nothing to do + ; If we are still in the first column - nothing to do lda M65__TXTCOL - beq !+ + beq @3 - // Deleta character under cursor + ; Deleta character under cursor phz @@ -81,22 +81,21 @@ m65_chrout_screen_DEL_1stcol: lda COLOR and #$0F - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z jsr m65_helper_scrlpnt_to_screen lda #$20 - sta_lp (M65_LPNT_SCR), z + sta [M65_LPNT_SCR], z plz - // End of character deletion -!: + ; End of character deletion +@3: jmp m65_chrout_screen_done m65_chrout_screen_DEL_winmode: - // XXX provide implementation for window mode + ; 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 index 41913d29..72d28b9f 100644 --- a/src/kernal/screen_m65/mega65_clrscr.s +++ b/src/kernal/screen_m65/mega65_clrscr.s @@ -1,51 +1,51 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE M65_CLRSCR: - // Clear additional attributes from the color code + ; Clear additional attributes from the color code jsr m65_screen_clear_colorattr - // Disable the window mode + ; Disable the window mode lda #$00 sta M65_SCRWINMODE - // FALLTROUGH + ; FALLTROUGH m65_clrscr_takeover: - // Clear the whole screen + colour memory + ; Clear the whole screen + colour memory - // Screen size + ; 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 + ; Fill screen memory with spaces jsr m65_screen_dmasrcdst_screen lda #$20 jsr m65_dmagic_oper_fill - // Fill color memory with the current color + ; 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 + ; 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 + ; Set screen+color base address in VIC IV + ; XXX deduplicate with mode setting routine sta VIC_COLPTR+0 sta VIC_COLPTR+1 @@ -57,11 +57,11 @@ m65_clrscr_takeover: lda M65_SCRBASE+1 sta VIC_SCRNPTR+1 - // Set logical row length + ; Set logical row length jsr m65_screen_set_indx - // FALLTROUGH + ; FALLTROUGH M65_HOME: @@ -78,6 +78,6 @@ M65_HOME: M65_HOME_winmode: - // XXX provide implementation + ; XXX provide implementation rts diff --git a/src/kernal/screen_m65/mega65_clrwin.s b/src/kernal/screen_m65/mega65_clrwin.s index c519f8b4..4323fa05 100644 --- a/src/kernal/screen_m65/mega65_clrwin.s +++ b/src/kernal/screen_m65/mega65_clrwin.s @@ -1,28 +1,28 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// XXX deduplicate pointer manipulation, see M65_CLRSCR -// XXX consider using DMAgic for this - FILL command +; XXX deduplicate pointer manipulation, see M65_CLRSCR +; XXX consider using DMAgic for this - FILL command M65_CLRWIN: - // Clear additional attributes from the color code + ; Clear additional attributes from the color code jsr m65_screen_clear_colorattr - // Check if windowed mode; if not, go to M65_CLRSCR + ; Check if windowed mode; if not, go to M65_CLRSCR lda M65_SCRWINMODE - bpl_16 m65_clrscr_takeover + +bpl 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 + ; 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 + ; First initialize both pointers - // XXX use m65_helper_scrlpnt_color and m65_helper_scrlpnt_to_screen instead + ; XXX use m65_helper_scrlpnt_color and m65_helper_scrlpnt_to_screen instead clc lda M65_COLVIEW+0 @@ -40,67 +40,67 @@ M65_CLRWIN: sta M65_LPNT_KERN+0 lda M65_COLVIEW+1 sta M65_LPNT_KERN+1 - // XXX deduplicate part below with M65_CLRSCR + ; 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 + ; Go trough all the rows phz ldy #$00 - // FALLTROUGH + ; FALLTROUGH m65_clrwin_loop: - // Check if .Y cordinate is not below the window + ; 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 + bcc m65_clrwin_loop_next ; branch if we should skip this row - // Clear the row + ; Clear the row ldz M65_TXTWIN_X0 -!: +@1: lda #$20 - sta_lp (M65_LPNT_SCR),z + sta [M65_LPNT_SCR],z lda COLOR - sta_lp (M65_LPNT_KERN),z + sta [M65_LPNT_KERN],z inz cpz M65_TXTWIN_X1 - bne !- + bne @1 - // FALLTROUGH + ; FALLTROUGH m65_clrwin_loop_next: - // Increment M65_LPNT_SCR and M65_LPNT_KERN by the logical row length (always 80 = $50) + ; 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 !+ + bcc @2 inc M65_LPNT_SCR+1 -!: +@2: clc lda #$50 adc M65_LPNT_KERN+0 sta M65_LPNT_KERN+0 - bcc !+ + bcc @3 inc M65_LPNT_KERN+1 -!: - // Increment row counter, check if new row is valid +@3: + ; Increment row counter, check if new row is valid iny cpy M65_TXTWIN_Y1 bne m65_clrwin_loop plz - // Set screen variables + ; Set screen variables - // XXX implement this + ; XXX implement this rts diff --git a/src/kernal/screen_m65/mega65_cursor.s b/src/kernal/screen_m65/mega65_cursor.s index 3df29bf2..c5d20628 100644 --- a/src/kernal/screen_m65/mega65_cursor.s +++ b/src/kernal/screen_m65/mega65_cursor.s @@ -1,54 +1,54 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #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) -// +; +; 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! +m65_cursor_disable: ; XXX utilize this! - // Disable cursor blinking + ; Disable cursor blinking lda #$80 sta BLNSW - // FALLTHROUGH + ; FALLTHROUGH m65_cursor_hide_if_visible: - // Set countdown to high value, to prevent IRQ interference + ; Set countdown to high value, to prevent IRQ interference lda #$FF sta BLNCT - // If cursor is not visible, not much to do + ; If cursor is not visible, not much to do lda BLNON - beq_16 cursor_timer_reset + +beq cursor_timer_reset - // FALLTROUGH + ; FALLTROUGH m65_cursor_undraw: - // Preserve .Z + ; Preserve .Z phz - // Cursor undraw - color + ; Cursor undraw - color jsr m65_helper_scrlpnt_color ldz M65__TXTCOL lda GDCOL - sta_lp (M65_LPNT_SCR),z + sta [M65_LPNT_SCR],z - // Cursor undraw - character + ; Cursor undraw - character jsr m65_helper_scrlpnt_to_screen lda GDBLN - sta_lp (M65_LPNT_SCR),z + sta [M65_LPNT_SCR],z - // Restore .Z and continue as with normal editor + ; 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 index 80fd31c8..e144b74a 100644 --- a/src/kernal/screen_m65/mega65_cursor_blink.s +++ b/src/kernal/screen_m65/mega65_cursor_blink.s @@ -1,33 +1,33 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #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) -// +; +; 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 + ; Preserve .Z phz - // Is the cursor enabled? + ; Is the cursor enabled? lda BLNSW bne m65_cursor_blink_end - // Do we need to redraw things? + ; Do we need to redraw things? dec BLNCT bpl m65_cursor_blink_end - // Prepare .Z for offset within row + ; Prepare .Z for offset within row ldz M65__TXTCOL - // Prepare long pointer to color memory + ; Prepare long pointer to color memory lda #$0F sta M65_LPNT_IRQ+3 lda #$F8 @@ -38,7 +38,7 @@ m65_cursor_blink: lda M65_COLVIEW+0 sta M65_LPNT_IRQ+0 - // Add screen row to the address + ; Add screen row to the address clc lda M65_TXTROW_OFF+0 adc M65_LPNT_IRQ+0 @@ -47,38 +47,38 @@ m65_cursor_blink: adc M65_LPNT_IRQ+1 sta M65_LPNT_IRQ+1 - // Check if cursor was visible or not, and toggle + ; Check if cursor was visible or not, and toggle lda BLNON bne m65_cursor_blink_undraw - // FALLTROUGH + ; FALLTROUGH m65_cursor_blink_draw: lda #1 sta BLNON - // Cursor draw - color - lda_lp (M65_LPNT_IRQ),z + ; Cursor draw - color + lda [M65_LPNT_IRQ],z sta GDCOL lda COLOR - and #$0F // take current colour, but not extended attributes - sta_lp (M65_LPNT_IRQ),z + and #$0F ; take current colour, but not extended attributes + sta [M65_LPNT_IRQ],z - // Cursor draw - character + ; Cursor draw - character jsr m65_cursor_blink_irqpnt_to_screen - lda_lp (M65_LPNT_IRQ),z + lda [M65_LPNT_IRQ],z sta GDBLN eor #$80 - sta_lp (M65_LPNT_IRQ),z + sta [M65_LPNT_IRQ],z m65_cursor_blink_timer_reset: - // Rest blink counter (Mapping the 64, p39-40) + ; Rest blink counter (Mapping the 64, p39-40) lda #20 sta BLNCT - // FALLTROUGH + ; FALLTROUGH m65_cursor_blink_end: @@ -87,17 +87,17 @@ m65_cursor_blink_end: m65_cursor_blink_undraw: - // Cursor undraw - color + ; Cursor undraw - color lda GDCOL - sta_lp (M65_LPNT_IRQ),z + sta [M65_LPNT_IRQ],z - // Cursor undraw - character + ; Cursor undraw - character jsr m65_cursor_blink_irqpnt_to_screen lda GDBLN - sta_lp (M65_LPNT_IRQ),z + sta [M65_LPNT_IRQ],z - // Mark cursor as not drawn + ; Mark cursor as not drawn lda #0 sta BLNON - jmp_8 m65_cursor_blink_timer_reset + bra 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 index a8192463..5baad989 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers.s +++ b/src/kernal/screen_m65/mega65_screen_helpers.s @@ -1,5 +1,5 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE m65_screen_clear_colorattr: @@ -24,7 +24,7 @@ m65_screen_upd_txtrow_off: m65_screen_dmasrcdst_screen: - // Set screen memory as start/end addresses + ; Set screen memory as start/end addresses lda M65_SCRBASE+0 sta M65_DMAJOB_SRC_0 @@ -36,7 +36,11 @@ m65_screen_dmasrcdst_screen: sta M65_DMAJOB_SRC_2 sta M65_DMAJOB_DST_2 lda M65_SCRSEG+1 -!: + + ; FALLTROUGH + +m65_screen_dmasrcdst_screen_cont: + sta M65_DMAJOB_SRC_3 sta M65_DMAJOB_DST_3 @@ -45,7 +49,7 @@ m65_screen_dmasrcdst_screen: m65_screen_dmasrcdst_color: - // Set color memory as start/end addresses + ; Set color memory as start/end addresses lda #$00 sta M65_DMAJOB_SRC_0 @@ -56,7 +60,7 @@ m65_screen_dmasrcdst_color: sta M65_DMAJOB_SRC_2 sta M65_DMAJOB_DST_2 lda #$0F - jmp_8 !- + bra m65_screen_dmasrcdst_screen_cont m65_screen_dmasrc_add_row: @@ -65,7 +69,7 @@ m65_screen_dmasrc_add_row: lda M65_DMAJOB_SRC_0 adc #$50 sta M65_DMAJOB_SRC_0 - bcc !+ + bcc @1 inc M65_DMAJOB_SRC_1 -!: +@1: rts diff --git a/src/kernal/screen_m65/mega65_screen_helpers_K0.s b/src/kernal/screen_m65/mega65_screen_helpers_K0.s index edcd9382..f6597b3c 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers_K0.s +++ b/src/kernal/screen_m65/mega65_screen_helpers_K0.s @@ -1,30 +1,30 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Set the INDX variable - logical row length -// +; +; Set the INDX variable - logical row length +; -m65_screen_set_indx: // leaves value in .A +m65_screen_set_indx: ; leaves value in .A lda M65_SCRWINMODE - bmi !+ + bmi @1 - // Non-windowed mode + ; Non-windowed mode phx ldx M65_SCRMODE lda m65_scrtab_txtwidth,x - dec_a + dec sta INDX plx rts -!: - // Windowed mode +@1: + ; Windowed mode sec lda M65_TXTWIN_X1 sbc M65_TXTWIN_X0 - dec_a + dec 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 index a5e851a2..75f6d674 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers_irq.s +++ b/src/kernal/screen_m65/mega65_screen_helpers_irq.s @@ -1,10 +1,10 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE m65_cursor_blink_irqpnt_to_screen: - // Adapt pointer to point to screen memory + ; Adapt pointer to point to screen memory lda M65_SCRSEG+1 sta M65_LPNT_IRQ+3 diff --git a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s index 31630d11..82f016bb 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s +++ b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s @@ -1,10 +1,10 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE m65_helper_scrlpnt_color: - // Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000) + ; Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000) lda #$0F sta M65_LPNT_SCR+3 @@ -16,7 +16,7 @@ m65_helper_scrlpnt_color: lda M65_COLVIEW+0 sta M65_LPNT_SCR+0 - // Add screen row to the address + ; Add screen row to the address clc lda M65_TXTROW_OFF+0 @@ -32,7 +32,7 @@ m65_helper_scrlpnt_color: m65_helper_scrlpnt_to_screen: - // Change M65_LPNT_SCR to point to screen memory (when it points to color memory) + ; Change M65_LPNT_SCR to point to screen memory (when it points to color memory) clc lda M65_SCRBASE+0 @@ -42,7 +42,7 @@ m65_helper_scrlpnt_to_screen: adc M65_LPNT_SCR+1 sta M65_LPNT_SCR+1 - // FALLTROUGH + ; FALLTROUGH m65_helper_scrlpnt_to_screen_hi: @@ -57,11 +57,11 @@ m65_helper_scrlpnt_to_screen_hi: m65_helper_scrlpnt_chrin: - // Prepare the pointer for 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 + bra 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 index 7e89455c..2ca64d13 100644 --- a/src/kernal/screen_m65/mega65_screen_quote.s +++ b/src/kernal/screen_m65/mega65_screen_quote.s @@ -1,23 +1,22 @@ +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE - -// -// CHROUT routine - screen support, control codes in quote mode, MEGA65 native mode version -// +; +; CHROUT routine - screen support, control codes in quote mode, MEGA65 native mode version +; m65_chrout_screen_quote: - // Low control codes are just +$80 + ; 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 -!: + ; 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 @1 + adc #$BF ; C=1, so adding $BF + C = add $C0 +@1: 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 index 7c531313..d7503930 100644 --- a/src/kernal/screen_m65/mega65_screen_table_height.s +++ b/src/kernal/screen_m65/mega65_screen_table_height.s @@ -1,9 +1,9 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -m65_scrtab_txtheight: // height of the text screen +m65_scrtab_txtheight: ; height of the text screen - .byte 25 - .byte 25 - .byte 50 + !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 index 1a9a5850..2ac37b62 100644 --- a/src/kernal/screen_m65/mega65_screen_table_width.s +++ b/src/kernal/screen_m65/mega65_screen_table_width.s @@ -1,9 +1,9 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -m65_scrtab_txtwidth: // width of the text screen (logical width is always set to 80) +m65_scrtab_txtwidth: ; width of the text screen (logical width is always set to 80) - .byte 40 - .byte 80 - .byte 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 index 10c14d36..f0f6b684 100644 --- a/src/kernal/screen_m65/mega65_screen_tables_misc.s +++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s @@ -1,114 +1,110 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -m65_scrtab_vic_ctrlb: // parameters for VIC control register B +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 + !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 +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) + !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 +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) + !byte >((MEMCONF_SCRROWS - 25) * 80) + !byte >((MEMCONF_SCRROWS - 25) * 80) + !byte >((MEMCONF_SCRROWS - 50) * 80) -m65_scrtab_scrolx: // values for VIC_SCROLX +m65_scrtab_scrolx: ; values for VIC_SCROLX - .byte $C8 - .byte $CA - .byte $CA + !byte $C8 + !byte $CA + !byte $CA -m65_scrtab_rowoffset_lo: // row offsets - low bytes +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) + !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 +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) + !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. +; 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 + !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 + !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) + ; Note: 65C02 has the page boundary vector bug fixed! + + !word m65_chrout_screen_CLR + !word m65_chrout_screen_HOME + !word m65_chrout_screen_SHIFT_OFF + !word m65_chrout_screen_SHIFT_ON + !word m65_chrout_screen_TXT + !word m65_chrout_screen_GFX + !word m65_chrout_screen_RVS_OFF + !word m65_chrout_screen_RVS_ON + !word m65_chrout_screen_CRSR_RIGHT + !word m65_chrout_screen_CRSR_LEFT + !word m65_chrout_screen_CRSR_DOWN + !word m65_chrout_screen_CRSR_UP + !word m65_chrout_screen_TAB + !word m65_chrout_screen_LINE_FEED + !word m65_chrout_screen_UNDERLINE_ON + !word m65_chrout_screen_UNDERLINE_OFF + !word m65_chrout_screen_FLASHING_ON + !word m65_chrout_screen_FLASHING_OFF + !word m65_chrout_screen_TAB_SET_CLR + !word m65_chrout_screen_ESC + !word m65_chrout_screen_BELL + !word m65_chrout_screen_INS + !word m65_chrout_screen_STOP + !word m65_chrout_screen_DEL + !word m65_chrout_screen_RETURN diff --git a/src/kernal/screen_m65/mega65_scrmodeget.s b/src/kernal/screen_m65/mega65_scrmodeget.s index b541aa37..39498701 100644 --- a/src/kernal/screen_m65/mega65_scrmodeget.s +++ b/src/kernal/screen_m65/mega65_scrmodeget.s @@ -1,10 +1,10 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Output: -// .A - current screen mode -// +; +; Output: +; .A - current screen mode +; M65_SCRMODEGET: diff --git a/src/kernal/screen_m65/mega65_scrmodeset.s b/src/kernal/screen_m65/mega65_scrmodeset.s index 51edf6cd..b060e736 100644 --- a/src/kernal/screen_m65/mega65_scrmodeset.s +++ b/src/kernal/screen_m65/mega65_scrmodeset.s @@ -1,48 +1,48 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Input: -// - .A - desired screen mode -// -// Output: -// - Carry set = unsupported screen mode -// - Carry clear = screen mode switched correctly -// +; +; 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 + bcs m65_scrmodeset_rts ; branch if unsupported screen mode - // Preserve .X, move desired mode to .X, disable interrupts + ; Preserve .X, move desired mode to .X, disable interrupts phx sei - // Perform the switch + ; Perform the switch jsr m65_scrmodeset_internal - // Re-enable interrupts, restore .X + ; Re-enable interrupts, restore .X cli plx - // FALLTROUGH + ; FALLTROUGH m65_scrmodeset_rts: rts -m65_scrmodeset_internal: // entry point for M65_MODE65 +m65_scrmodeset_internal: ; entry point for M65_MODE65 - // Store desired screen mode + ; Store desired screen mode sta M65_SCRMODE - // Set flags/variables for 40/80 columns and 25/50 rows + ; Set flags/variables for 40/80 columns and 25/50 rows tax @@ -55,28 +55,28 @@ m65_scrmodeset_internal: // entry point for M65_MODE65 jsr viciv_hotregs_off - // Set the logical row length to 80 + ; 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 + ; 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_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 + ; 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 @@ -91,8 +91,8 @@ m65_scrmodeset_internal: // entry point for M65_MODE65 stx VIC_COLPTR+0 stx VIC_COLPTR+1 - // Set the following location: - // - VIC_CHARPTR - for character generator location + ; Set the following location: + ; - VIC_CHARPTR - for character generator location lda #normal takeover - -#endif +load_tape_normal_takeover: ; entry point for turbo->normal takeover +} jsr load_MEMUSS_to_STAL - // Try to load header into tape buffer (we will restore MEMUSS later) + ; Try to load header into tape buffer (we will restore MEMUSS later) jsr tape_normal_get_pilot_header -#if CONFIG_TAPE_AUTODETECT - bcs load_tape_normal_switch_turbo // failed, try turbo -#endif +!ifdef CONFIG_TAPE_AUTODETECT { + bcs load_tape_normal_switch_turbo ; failed, try turbo +} jsr load_TAPE1_to_MEMUSS jsr tape_normal_get_data_1 -#if !CONFIG_TAPE_AUTODETECT - bcs load_tape_normal_header // unable to read block, try again -#else - bcc !+ +!ifndef CONFIG_TAPE_AUTODETECT { + bcs load_tape_normal_header ; unable to read block, try again +} else { + bcc load_tape_normal_switch_turbo_skip load_tape_normal_switch_turbo: jsr lvs_STAL_to_MEMUSS - jmp load_tape_turbo_takeover // unable to read block, try turbo instead -!: -#endif + jmp load_tape_turbo_takeover ; unable to read block, try turbo instead +load_tape_normal_switch_turbo_skip: +} jsr load_TAPE1_to_MEMUSS jsr tape_normal_get_data_2 -#if !CONFIG_TAPE_AUTODETECT - bcs load_tape_normal_header // block load error, try again -#else - bcs load_tape_normal_switch_turbo // block load error, try turbo instead -#endif +!ifndef CONFIG_TAPE_AUTODETECT { + bcs load_tape_normal_header ; block load error, try again +} else { + bcs load_tape_normal_switch_turbo ; block load error, try turbo instead +} - // Check header type + ; Check header type ldy #$00 lda (TAPE1),y cmp #$05 - beq_16 tape_load_error // end of tape mark, nothing to load + +beq tape_load_error ; end of tape mark, nothing to load cmp #$01 - beq !+ + beq @1 cmp #$03 -#if !CONFIG_TAPE_AUTODETECT - bne load_tape_normal_header // header types 1 and 3 are loadable, see Mapping the C64, page 77 -#else +!ifndef CONFIG_TAPE_AUTODETECT { + bne load_tape_normal_header ; header types 1 and 3 are loadable, see Mapping the C64, page 77 +} else { bne load_tape_normal_takeover -#endif +} lda #$01 - sta SA // this file is non-relocatable; override secondary address with 1 -!: - // Restore MEMUSS, handle header + sta SA ; this file is non-relocatable; override secondary address with 1 +@1: + ; Restore MEMUSS, handle header jsr lvs_STAL_to_MEMUSS jsr tape_handle_header -#if !CONFIG_TAPE_AUTODETECT - bcs load_tape_normal_header // if name does not match, look for other header -#else +!ifndef CONFIG_TAPE_AUTODETECT { + bcs load_tape_normal_header ; if name does not match, look for other header +} else { bcs load_tape_normal_takeover -#endif +} - // FALLTROUGH + ; FALLTROUGH load_tape_normal_payload: - // Retrieve data + ; Retrieve data jsr tape_normal_get_pilot_data - ldy #$00 // no data size limit + ldy #$00 ; no data size limit jsr tape_normal_get_data_1 - bcs_16 tape_load_error + +bcs tape_load_error jsr lvs_check_EAL - bne_16 tape_load_error // amount of data read does not match header info + +bne tape_load_error ; amount of data read does not match header info jsr lvs_STAL_to_MEMUSS jsr tape_normal_get_data_2 - bcs_16 tape_load_error + +bcs tape_load_error jmp tape_load_success -load_TAPE1_to_MEMUSS: // set MEMUSS (start address) as tape buffer +load_TAPE1_to_MEMUSS: ; set MEMUSS (start address) as tape buffer lda TAPE1+1 sta MEMUSS+1 @@ -151,7 +150,7 @@ load_TAPE1_to_MEMUSS: // set MEMUSS (start address) as tape bu rts -load_MEMUSS_to_STAL: // preserve MEMUSS +load_MEMUSS_to_STAL: ; preserve MEMUSS lda MEMUSS+1 sta STAL+1 @@ -159,6 +158,4 @@ load_MEMUSS_to_STAL: // preserve MEMUSS sta STAL+0 rts - - -#endif +} diff --git a/src/kernal/tape/load_tape_turbo.s b/src/kernal/tape/load_tape_turbo.s index fe20438e..c4f08877 100644 --- a/src/kernal/tape/load_tape_turbo.s +++ b/src/kernal/tape/load_tape_turbo.s @@ -1,75 +1,73 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) part of the LOAD routine -// +; +; Tape (turbo) part of the LOAD routine +; -// Initially based on routine by enthusi/Onslaught, found here: -// - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source -// but heavily reworked since then. Still, original authors deserve credits! +; Initially based on routine by enthusi/Onslaught, found here: +; - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source +; but heavily reworked since then. Still, original authors deserve credits! -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { -#if !CONFIG_TAPE_AUTODETECT +!ifndef CONFIG_TAPE_AUTODETECT { load_tape_turbo: -#else +} else { load_tape_auto: +} -#endif + jsr tape_ditch_verify ; only LOAD is supported, no VERIFY - jsr tape_ditch_verify // only LOAD is supported, no VERIFY - - // Prepare for sound effects + ; Prepare for sound effects jsr tape_clean_sid - // Start playing + ; Start playing jsr tape_common_prepare_cia jsr tape_ask_play -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { jsr tape_prepare_reading -#endif +} - // FALLTROUGH + ; FALLTROUGH -#if CONFIG_TAPE_AUTODETECT +!ifdef CONFIG_TAPE_AUTODETECT { -load_tape_turbo_takeover: // entry point for normal->turbo takeover +load_tape_turbo_takeover: ; entry point for normal->turbo takeover jsr tape_common_autodetect - bcc_16 load_tape_normal_takeover + +bcc load_tape_normal_takeover +} -#endif - - // FALLTROUGH + ; FALLTROUGH load_tape_turbo_header: - // Read file header; structure described here: - // - https://www.luigidifraia.com/c64/docs/tapeloaders.html#turbotape64 - // - // 1 byte - file type (0 = data, odd value = relocatable, even value = non-relocatable) - // 2 bytes - start address - // 2 bytes - end address + 1 - // 1 byte - if $B0 (tape timing) contained at the time of saving - // (we skip this one to match normal system header) - // 16 bytes - filename, padded with 0x20 + ; Read file header; structure described here: + ; - https://www.luigidifraia.com/c64/docs/tapeloaders.html#turbotape64 + ; + ; 1 byte - file type (0 = data, odd value = relocatable, even value = non-relocatable) + ; 2 bytes - start address + ; 2 bytes - end address + 1 + ; 1 byte - if $B0 (tape timing) contained at the time of saving + ; (we skip this one to match normal system header) + ; 16 bytes - filename, padded with 0x20 jsr tape_turbo_sync_header -#if CONFIG_TAPE_AUTODETECT - bcs_16 load_tape_normal_takeover // failure, probably not a turbo tape file -#endif +!ifdef CONFIG_TAPE_AUTODETECT { + +bcs load_tape_normal_takeover ; failure, probably not a turbo tape file +} ldy #$00 - sta (TAPE1), y // store header type + sta (TAPE1), y ; store header type iny - // FALLTROUGH + ; FALLTROUGH load_tape_turbo_header_loop: @@ -77,85 +75,83 @@ load_tape_turbo_header_loop: sta (TAPE1), y iny cpy #$05 - bne !+ - jsr tape_turbo_get_byte // tape timing - skip this one -!: - cpy #$C0 // header is 192 bytes long in total + bne @1 + jsr tape_turbo_get_byte ; tape timing - skip this one +@1: + cpy #$C0 ; header is 192 bytes long in total bne load_tape_turbo_header_loop - // For non-relocatable files, override secondary address - ldy #$00 // XXX optimize out for 65C02 + ; For non-relocatable files, override secondary address + ldy #$00 ; XXX optimize out for 65C02 lda (TAPE1), y - beq !+ + beq @2 and #$01 - bne !+ - lda #$01 // XXX for 65C02 just set the bit with one instruction + bne @2 + lda #$01 ; XXX for 65C02 just set the bit with one instruction sta SA -!: - // Handle the header +@2: + ; Handle the header jsr tape_clean_sid jsr tape_handle_header - bcs load_tape_turbo_header // if name does not match, look for other header + bcs load_tape_turbo_header ; if name does not match, look for other header - // FALLTROUGH + ; FALLTROUGH load_tape_turbo_payload: - // Copy helper byte store routine to RAM, provide default memory mapping + ; Copy helper byte store routine to RAM, provide default memory mapping ldx #(__tape_turbo_bytestore_size - 1) -!: +@3: lda tape_turbo_bytestore_source, x sta __tape_turbo_bytestore, x dex - bpl !- + bpl @3 lda CPU_R6510 sta __tape_turbo_bytestore_defmap - // Initial checksum value + ; Initial checksum value lda #$00 sta PRTY - // Read file payload -!: + ; Read file payload +@4: jsr tape_turbo_sync_payload -#if CONFIG_TAPE_AUTODETECT - bcs !- -#endif +!ifdef CONFIG_TAPE_AUTODETECT { + bcs @4 +} - // FALLTROUGH + ; FALLTROUGH load_tape_turbo_loop: jsr tape_turbo_get_byte - jsr __tape_turbo_bytestore // like 'sta (MEMUSS),y' - but under I/O + jsr __tape_turbo_bytestore ; like 'sta (MEMUSS),y' - but under I/O - eor PRTY // handle checksum + eor PRTY ; handle checksum sta PRTY - // Advance MEMUSS (see Mapping the C64, page 36) -#if !HAS_OPCODES_65CE02 + ; Advance MEMUSS (see Mapping the C64, page 36) +!ifndef HAS_OPCODES_65CE02 { jsr lvs_advance_MEMUSS -#else +} else { inw MEMUSS+0 -#endif +} jsr lvs_check_EAL bne load_tape_turbo_loop - // Get the checksum + ; Get the checksum jsr tape_turbo_get_byte tax - // Silence audio + ; Silence audio jsr tape_clean_sid - // Verify the checksum + ; Verify the checksum cpx PRTY - beq_16 tape_load_success + +beq tape_load_success jmp tape_load_error - - -#endif // CONFIG_TAPE_TURBO +} diff --git a/src/kernal/tape/tape_common.s b/src/kernal/tape/tape_common.s index 4b896671..761927e0 100644 --- a/src/kernal/tape/tape_common.s +++ b/src/kernal/tape/tape_common.s @@ -1,18 +1,18 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Common routines for tape support -// +; +; Common routines for tape support +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { -// -// Loading terminated by user -// +; +; Loading terminated by user +; tape_break_error: @@ -22,31 +22,30 @@ tape_break_error: jmp kernalerror_ROUTINE_TERMINATED -// -// Ask user to press PLAY on tape deck, -// Unless user cancelled loading, blank screen and start motor -// +; +; Ask user to press PLAY on tape deck, +; Unless user cancelled loading, blank screen and start motor +; tape_ask_play: -#if !CONFIG_TAPE_NO_KEY_SENSE +!ifndef CONFIG_TAPE_NO_KEY_SENSE { - // First check whether the button is already pressed + ; First check whether the button is already pressed lda CPU_R6510 and #$10 beq tape_wait_play_done +} -#endif - - // Display message + ; Display message ldx #__MSG_KERNAL_PRESS_PLAY jsr print_kernal_message - // FALLTROUGH + ; FALLTROUGH -#if !CONFIG_TAPE_NO_KEY_SENSE +!ifndef CONFIG_TAPE_NO_KEY_SENSE { tape_wait_play_loop: @@ -54,122 +53,118 @@ tape_wait_play_loop: bcs tape_break_error lda CPU_R6510 - and #$10 // check for pressed button + and #$10 ; check for pressed button bne tape_wait_play_loop - // FALLTROUGH + ; FALLTROUGH -#else +} else { - // The ROM is configured for tape adapter without the key sense - but it is still - // possible, that regular Datasette or Tapuino is connected + ; The ROM is configured for tape adapter without the key sense - but it is still + ; possible, that regular Datasette or Tapuino is connected lda CPU_R6510 and #$10 - beq tape_wait_first_pulse // branch if button reported pressed, most likely really no key sense + beq tape_wait_first_pulse ; branch if button reported pressed, most likely really no key sense - // We have key sense - perform regular waiting -!: + ; We have key sense - perform regular waiting +@1: jsr STOP bcs tape_break_error lda CPU_R6510 and #$10 - beq !- + beq @1 tape_wait_first_pulse: - // We have no key sense - so just turn the motor on and wait for the first pulse + ; We have no key sense - so just turn the motor on and wait for the first pulse jsr tape_motor_on -!: +@2: jsr STOP bcs tape_break_error lda #$10 - bit CIA1_ICR // $DC0D - bne !- -!: + bit CIA1_ICR ; $DC0D + bne @2 +@3: jsr STOP bcs tape_break_error lda #$10 - bit CIA1_ICR // $DC0D - beq !- + bit CIA1_ICR ; $DC0D + beq @3 +} -#endif - - // FALLTROUGH + ; FALLTROUGH tape_wait_play_done: lda #$01 - sta CAS1 // set the interlock + sta CAS1 ; set the interlock -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { rts tape_prepare_reading: -#endif // CONFIG_TAPE_HEAD_ALIGN +} ; CONFIG_TAPE_HEAD_ALIGN -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { - // Display confirmation + ; Display confirmation ldx #__MSG_KERNAL_OK_SEARCHING jsr print_kernal_message +} -#endif - - // Prepare for reading + ; Prepare for reading jsr print_return jmp tape_screen_off_motor_on -// -// Handle file header - display it, decide whether load the file or not, etc. -// +; +; Handle file header - display it, decide whether load the file or not, etc. +; tape_handle_header: -#if !CONFIG_TAPE_NO_MOTOR_CONTROL +!ifndef CONFIG_TAPE_NO_MOTOR_CONTROL { jsr tape_screen_on_motor_off +} -#endif - - // Print FOUND + file name + ; Print FOUND + file name ldx #__MSG_KERNAL_FOUND jsr print_kernal_message ldy #$05 -!: +@4: lda (TAPE1), y jsr JCHROUT iny cpy #$15 - bne !- + bne @4 -#if !CONFIG_TAPE_NO_MOTOR_CONTROL +!ifndef CONFIG_TAPE_NO_MOTOR_CONTROL { - // Header, wait for user decision + ; Header, wait for user decision jsr tape_header_get_decision bcs tape_break_error +} -#endif - - // Check if file name matches + ; Check if file name matches jsr tape_match_filename bcs tape_handle_header_skip - // Setup STAL and EAL + ; Setup STAL and EAL ldy #$01 lda (TAPE1), y @@ -187,12 +182,12 @@ tape_handle_header: lda (TAPE1), y sta EAL+1 - // Handle the secondary address, 0 means loading to location from MEMUSS + ; Handle the secondary address, 0 means loading to location from MEMUSS lda SA - bne !+ + bne @5 - // EAL = EAL - STAL + ; EAL = EAL - STAL sec lda EAL+0 @@ -202,14 +197,14 @@ tape_handle_header: sbc STAL+1 sta EAL+1 - // STAL = MEMUSS + ; STAL = MEMUSS lda MEMUSS+0 sta STAL+0 lda MEMUSS+1 sta STAL+1 - // EAL = EAL + STAL + ; EAL = EAL + STAL clc lda EAL+0 @@ -218,36 +213,34 @@ tape_handle_header: lda EAL+1 adc STAL+1 sta EAL+1 -!: - // Setup MEMUSS (see Mapping the C64, page 36) +@5: + ; Setup MEMUSS (see Mapping the C64, page 36) jsr lvs_STAL_to_MEMUSS -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { - // Switch to legacy mode if needed + ; Switch to legacy mode if needed jsr m65_load_autoswitch_tape +} -#endif - - // Print LOADING and start address + ; Print LOADING and start address jsr lvs_display_loading_verifying - // FALLTROUGH + ; FALLTROUGH -#if !CONFIG_TAPE_NO_MOTOR_CONTROL +!ifndef CONFIG_TAPE_NO_MOTOR_CONTROL { tape_handle_header_displayed: - // Load the file + ; Load the file jsr tape_screen_off_motor_on - // FALLTROUGH - -#endif + ; FALLTROUGH +} tape_return_ok: @@ -256,12 +249,12 @@ tape_return_ok: tape_handle_header_skip: - // Skip this file + ; Skip this file jsr print_return jsr tape_screen_off_motor_on - // FALLTROUGH + ; FALLTROUGH tape_return_not_ok: @@ -269,24 +262,24 @@ tape_return_not_ok: rts -// -// Check whether file name matches the pattern -// +; +; Check whether file name matches the pattern +; tape_match_filename: lda FNLEN - beq tape_return_ok // no pattern to match + beq tape_return_ok ; no pattern to match ldy #$00 tape_match_loop: - lda #$20 // default byte, for padding + lda #$20 ; default byte, for padding cpy FNLEN - bcs !+ // end of pattern - lda (FNADDR), y // byte from pattern -!: + bcs @6 ; end of pattern + lda (FNADDR), y ; byte from pattern +@6: cmp #KEY_ASTERISK beq tape_return_ok @@ -311,31 +304,31 @@ tape_match_loop: rts -#if !CONFIG_TAPE_NO_MOTOR_CONTROL +!ifndef CONFIG_TAPE_NO_MOTOR_CONTROL { -// -// Get user decision whether to load the file or not -// +; +; Get user decision whether to load the file or not +; tape_header_get_decision: ldy #$00 -!: +@7: jsr udtim_keyboard lda STKEY - bpl tape_header_wait_stop // STOP pressed + bpl tape_header_wait_stop ; STOP pressed and #$10 - beq tape_header_wait_space // SPACE pressed + beq tape_header_wait_space ; SPACE pressed ldx #$80 - jsr wait_x_bars // sets .X to 0 + jsr wait_x_bars ; sets .X to 0 dex jsr wait_x_bars dey - bne !- + bne @7 - // FALLTROUGH - timeout + ; FALLTROUGH - timeout tape_header_wait_space: @@ -346,13 +339,12 @@ tape_header_wait_stop: sec rts - -#endif +} -// -// Report that file loading succeeded (or not) -// +; +; Report that file loading succeeded (or not) +; tape_load_success: @@ -364,6 +356,4 @@ tape_load_error: jsr tape_screen_on_motor_off jmp lvs_load_verify_error - - -#endif +} \ No newline at end of file diff --git a/src/kernal/tape/tape_common_autodetect.s b/src/kernal/tape/tape_common_autodetect.s index bad0c45e..0a592b5e 100644 --- a/src/kernal/tape/tape_common_autodetect.s +++ b/src/kernal/tape/tape_common_autodetect.s @@ -1,92 +1,92 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tries to detect -// -// Carry clear - normal, Carry set - turbo -// +; +; Tries to detect +; +; Carry clear - normal, Carry set - turbo +; -#if CONFIG_TAPE_AUTODETECT +!ifdef CONFIG_TAPE_AUTODETECT { tape_common_autodetect: - // Set screen color to something neutral, silence the audio + ; Set screen color to something neutral, silence the audio lda #$0B sta VIC_EXTCOL lda #$00 -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { sta SID_SIGVOL + __SID_R1_OFFSET sta SID_SIGVOL + __SID_L1_OFFSET -#else +} else { sta SID_SIGVOL -#endif +} - // FALLTROUGH + ; FALLTROUGH tape_common_autodetect_retry: - // It is not trivial to distinguish between normal and turbo, - // as short pulses of normal (and sync uses only shorts) - // have similar lengths as long pulses of turbo + ; It is not trivial to distinguish between normal and turbo, + ; as short pulses of normal (and sync uses only shorts) + ; have similar lengths as long pulses of turbo - // Thus, the routine here reads certain amount of pulses - // looking for evidence for either normal or turbo system; - // in case of no evidence found, assume normal + ; Thus, the routine here reads certain amount of pulses + ; looking for evidence for either normal or turbo system; + ; in case of no evidence found, assume normal - lda #$00 // plus = probably normal, minus = turbo + lda #$00 ; plus = probably normal, minus = turbo sta XSAV - ldy #$60 // $60 pulses cover 12 bytes of turbo recording - jsr tape_common_get_pulse // first pulse might be a garbage, ignore it + ldy #$60 ; $60 pulses cover 12 bytes of turbo recording + jsr tape_common_get_pulse ; first pulse might be a garbage, ignore it - // FALLTROUGH + ; FALLTROUGH tape_common_autodetect_loop: - jsr tape_common_get_pulse // read pulse for detection attempt + jsr tape_common_get_pulse ; read pulse for detection attempt - // If garbage found, retry detection + ; If garbage found, retry detection cmp #$28 - bcc tape_common_autodetect_retry // this is a VERY long pulse + bcc tape_common_autodetect_retry ; this is a VERY long pulse cmp #$E8 - bcs tape_common_autodetect_retry // this is a VERY short pulse + bcs tape_common_autodetect_retry ; this is a VERY short pulse - // First try to distinguish turbo short signal (reference: $CD) - // from normal signals (reference: $A5 or lower), these values - // give us threshold of ($CD + $A5) / 2 = $B9 + ; First try to distinguish turbo short signal (reference: $CD) + ; from normal signals (reference: $A5 or lower), these values + ; give us threshold of ($CD + $A5) / 2 = $B9 cmp #$B9 - bcc !+ - dec XSAV // above $B9 (so signal is shorter), looks like turbo -!: - // Now try to distinguish turbo signals (reference: $B1 or higher) - // from normal medium/long signals (reference: $7D or below), these values - // give us threshold of ($B1 + $7D) / 2 = $97 + bcc @1 + dec XSAV ; above $B9 (so signal is shorter), looks like turbo +@1: + ; Now try to distinguish turbo signals (reference: $B1 or higher) + ; from normal medium/long signals (reference: $7D or below), these values + ; give us threshold of ($B1 + $7D) / 2 = $97 cmp #$97 - bcs !+ + bcs @2 inc XSAV -!: - // The sync for turbo is not too long - if we have enough evidence, - // assume turbo recording already +@2: + ; The sync for turbo is not too long - if we have enough evidence, + ; assume turbo recording already lda XSAV cmp #$FD beq tape_common_autodetect_turbo - // Next iteration + ; Next iteration dey bpl tape_common_autodetect_loop - // Last chance for turbo + ; Last chance for turbo lda XSAV bmi tape_common_autodetect_turbo - // FALLTROUGH + ; FALLTROUGH tape_common_autodetect_normal: @@ -97,6 +97,4 @@ tape_common_autodetect_turbo: sec rts - - -#endif +} diff --git a/src/kernal/tape/tape_common_clean_sid.s b/src/kernal/tape/tape_common_clean_sid.s index 41083007..0c44d2bd 100644 --- a/src/kernal/tape/tape_common_clean_sid.s +++ b/src/kernal/tape/tape_common_clean_sid.s @@ -1,40 +1,38 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Clear the SID settings - for sound effects during LOAD -// +; +; Clear the SID settings - for sound effects during LOAD +; -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { tape_clean_sid: lda #$00 ldy #$1C -!: +@1: -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { - // It should be safer than cleaning whole $D400-D47C range + ; It should be safer than cleaning whole $D400-D47C range sta __SID_BASE + __SID_R1_OFFSET, y sta __SID_BASE + __SID_R2_OFFSET, y sta __SID_BASE + __SID_L1_OFFSET, y sta __SID_BASE + __SID_L2_OFFSET, y -#else +} else { sta __SID_BASE, y -#endif +} dey - bpl !- + bpl @1 rts - - -#endif +} \ No newline at end of file diff --git a/src/kernal/tape/tape_common_ditch_verify.s b/src/kernal/tape/tape_common_ditch_verify.s index b7d21d8a..65514982 100644 --- a/src/kernal/tape/tape_common_ditch_verify.s +++ b/src/kernal/tape/tape_common_ditch_verify.s @@ -1,24 +1,22 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Check if VERIFY asked - if yes, terminate loading -// +; +; Check if VERIFY asked - if yes, terminate loading +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { tape_ditch_verify: lda VERCKK - bne !+ + bne @1 rts -!: +@1: pla pla jmp lvs_device_not_found_error - - -#endif +} diff --git a/src/kernal/tape/tape_common_get_pulse.s b/src/kernal/tape/tape_common_get_pulse.s index 3cfccf75..00591f0e 100644 --- a/src/kernal/tape/tape_common_get_pulse.s +++ b/src/kernal/tape/tape_common_get_pulse.s @@ -1,33 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape helper routine - pulse reading -// -// Returns pulse length (with a bias, see comments) in .A -// +; +; Tape helper routine - pulse reading +; +; Returns pulse length (with a bias, see comments) in .A +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { tape_common_get_pulse: - // Contrary to original ROM implementation we do not use interrupts - // (see http://unusedino.de/ec64/technical/formats/tap.html) - busy wait - // implementation is probably just shorter + ; Contrary to original ROM implementation we do not use interrupts + ; (see http://unusedino.de/ec64/technical/formats/tap.html) - busy wait + ; implementation is probably just shorter lda #$10 -!: - bit CIA1_ICR // $DC0D - beq !- // busy loop to detect signal, restart timer afterwards - lda CIA2_TIMBLO // $DD06 - ldx #%01010001 // start timer, force latch reload, count timer A underflows - stx CIA2_CRB // $DD0F +@1: + bit CIA1_ICR ; $DC0D + beq @1 ; busy loop to detect signal, restart timer afterwards + lda CIA2_TIMBLO ; $DD06 + ldx #%01010001 ; start timer, force latch reload, count timer A underflows + stx CIA2_CRB ; $DD0F - cmp __pulse_threshold // default pulse check + cmp __pulse_threshold ; default pulse check rts - - -#endif +} diff --git a/src/kernal/tape/tape_common_motor.s b/src/kernal/tape/tape_common_motor.s index f88934da..dc6c9171 100644 --- a/src/kernal/tape/tape_common_motor.s +++ b/src/kernal/tape/tape_common_motor.s @@ -1,28 +1,30 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Handle tape deck motor -// +; +; Handle tape deck motor +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { tape_motor_off: lda CPU_R6510 ora #$20 - bne !+ // branch always + bne tape_motor_common ; branch always tape_motor_on: lda CPU_R6510 and #($FF - $20) -!: + + ; FALLTROUGH + +tape_motor_common: + sta CPU_R6510 rts - - -#endif +} diff --git a/src/kernal/tape/tape_common_prepare_cia.s b/src/kernal/tape/tape_common_prepare_cia.s index dd9eb3c5..d6977c05 100644 --- a/src/kernal/tape/tape_common_prepare_cia.s +++ b/src/kernal/tape/tape_common_prepare_cia.s @@ -1,65 +1,64 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Prepare CIA timers for tape reading -// +; +; Prepare CIA timers for tape reading +; -// -// Checked under VICE, PAL, average of 256 pulses: -// -// normal - short - timer goes down to $A5 -// normal - medium - timer goes down to $7D -// normal - long - timer goes down to $52 -// -// turbo - short - timer goes down to $CD -// turbo - long - timer goes down to $B1 -// -// -// Measurement subroutine: .A should contain timer value, $C000-$C002 zeroed -// -// clc -// adc $C001 -// sta $C001 -// bcc !+ -// inc $C000 -// !: -// inc $C002 -// beq !+ -// rts -// !: -// lda $C000 -// .break // .A contains our average -// rts -// +; +; Checked under VICE, PAL, average of 256 pulses: +; +; normal - short - timer goes down to $A5 +; normal - medium - timer goes down to $7D +; normal - long - timer goes down to $52 +; +; turbo - short - timer goes down to $CD +; turbo - long - timer goes down to $B1 +; +; +; Measurement subroutine: .A should contain timer value, $C000-$C002 zeroed +; +; clc +; adc $C001 +; sta $C001 +; bcc !+ +; inc $C000 +; !: +; inc $C002 +; beq !+ +; rts +; !: +; lda $C000 +; .break ; .A contains our average +; rts +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { tape_common_prepare_cia: - // Setup CIA #2 timers + ; Setup CIA #2 timers - ldx #$03 // set timer A to 4 ticks + ldx #$03 ; set timer A to 4 ticks - // FALLTROUGH + ; FALLTROUGH -tape_common_prepare_cia_by_x: // entry point for head align tool +tape_common_prepare_cia_by_x: ; entry point for head align tool - stx CIA2_TIMALO // $DD04 + stx CIA2_TIMALO ; $DD04 ldx #$00 - stx CIA2_TIMAHI // $DD05 + stx CIA2_TIMAHI ; $DD05 - stx CIA2_TIMBHI // $DD07 - dex // puts $FF - for running timer B as long as possible - stx CIA2_TIMBLO // $DD06 + stx CIA2_TIMBHI ; $DD07 + dex ; puts $FF - for running timer B as long as possible + stx CIA2_TIMBLO ; $DD06 - // Let timer A run continuously + ; Let timer A run continuously - ldx #%00010001 // start timer, force latch reload - stx CIA2_CRA // $DD0E + ldx #%00010001 ; start timer, force latch reload + stx CIA2_CRA ; $DD0E rts - -#endif +} diff --git a/src/kernal/tape/tape_common_screen.s b/src/kernal/tape/tape_common_screen.s index 9aa968e8..a1636149 100644 --- a/src/kernal/tape/tape_common_screen.s +++ b/src/kernal/tape/tape_common_screen.s @@ -1,14 +1,14 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Handle screen (visible/blanked) + tape deck motor (on/off), -// store/restore screen color -// +; +; Handle screen (visible/blanked) + tape deck motor (on/off), +; store/restore screen color +; -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +!ifdef HAS_TAPE { @@ -19,46 +19,44 @@ tape_screen_on_motor_off: lda COLSTORE sta VIC_EXTCOL -#if !ROM_LAYOUT_M65 +!ifndef CONFIG_MB_M65 { jmp screen_on -#else +} else { jsr M65_MODEGET - bcs_16 screen_on // MEGA65 native mode does not have badlines, no need to enable/disable screen + +bcs screen_on ; MEGA65 native mode does not have badlines, no need to enable/disable screen rts - -#endif +} tape_screen_off_motor_on: - // We do not want interrupts and CHROUT reenables them + ; We do not want interrupts and CHROUT reenables them sei - // Clear keyboard buffer + ; Clear keyboard buffer lda #$00 sta NDX - // Set screen color + ; Set screen color lda VIC_EXTCOL sta COLSTORE -#if !ROM_LAYOUT_M65 +!ifndef CONFIG_MB_M65 { jsr screen_off -#else +} else { jsr M65_MODEGET - // XXX optimize this - bcs !+ // MEGA65 native mode does not have badlines, no need to enable/disable screen + ; XXX optimize this + bcs @1 ; MEGA65 native mode does not have badlines, no need to enable/disable screen jsr screen_off -!: +@1: -#endif +} jmp tape_motor_on - -#endif +} diff --git a/src/kernal/tape/tape_head_align.s b/src/kernal/tape/tape_head_align.s index 690c665b..12ce37ab 100644 --- a/src/kernal/tape/tape_head_align.s +++ b/src/kernal/tape/tape_head_align.s @@ -1,64 +1,64 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape head alignemnt tool -// +; +; Tape head alignemnt tool +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { -.label __ha_start = 12 // starting row of the chart -.label __ha_rows = 11 // number of rows for scrolling +!set __ha_start = 12 ; starting row of the chart +!set __ha_rows = 11 ; number of rows for scrolling -// Helper tables +; Helper tables -.label __ha_offsets = $1000; -.label __ha_masks = $1100; +!addr __ha_offsets = $1000; +!addr __ha_masks = $1100; -// Generated code location +; Generated code location -.label __ha_scroll = $1300; +!addr __ha_scroll = $1300; -// Flag for GFX effects - reuse BASIC numeric work area on zero page +; Flag for GFX effects - reuse BASIC numeric work area on zero page -.label __ha_gfxflag = TEMPF2; // 1 byte +!addr __ha_gfxflag = TEMPF2; ; 1 byte tape_head_align: - // Make sure user really wants to launch the tool + ; Make sure user really wants to launch the tool jsr tape_ask_play - // Disable interrupts, set proper I/O values + ; Disable interrupts, set proper I/O values jsr CLALL sei jsr IOINIT - // jsr CINT + ; jsr CINT jsr nmi_lock - // Prepare CIA timers + ; Prepare CIA timers - ldx #$02 // set timer A to 3 ticks + ldx #$02 ; set timer A to 3 ticks jsr tape_common_prepare_cia_by_x - ldx #$FF // timer to control scroll speed - stx CIA1_TIMBLO // $DC06 - stx CIA1_TIMBHI // $DC07 + ldx #$FF ; timer to control scroll speed + stx CIA1_TIMBLO ; $DC06 + stx CIA1_TIMBHI ; $DC07 jsr tape_motor_on - // Clear color data ($0800) + ; Clear color data ($0800) ldy #$00 -!: +@1: lda #(CONFIG_COLOR_TXT * $10 + CONFIG_COLOR_BG) sta $0800, y @@ -67,146 +67,146 @@ tape_head_align: sta $0B00, y iny - bne !- + bne @1 - // Clear bitmap data ($2000) + ; Clear bitmap data ($2000) lda #$20 sta SAL+1 - tya // put 0 to .A + tya ; put 0 to .A sta SAL+0 -!: +@2: sta (SAL), y iny - bne !- + bne @2 inc SAL+1 ldx SAL+1 cpx #$40 - bne !- + bne @2 - // Print help message + ; Print help message jsr tape_head_align_print_help - // Make sure the row where the chart is being created is not visible + ; Make sure the row where the chart is being created is not visible lda #(CONFIG_COLOR_TXT * $10 + CONFIG_COLOR_TXT) ldy #$24 -!: +@3: sta $0800 + __ha_start * 40 + 1, y sta $0800 + __ha_start * 40 + 1 + (__ha_rows + 1) * 40, y dey - bne !- + bne @3 - // Set graphics mode + ; Set graphics mode - lda #$28 // graphics start at $2000, color at $0800 + lda #$28 ; graphics start at $2000, color at $0800 sta VIC_YMCSB - lda #$3B // set bit 5 to enable graphic mode + lda #$3B ; set bit 5 to enable graphic mode sta VIC_SCROLY - // Prepare lookup tables - to speed drawing, we are going to use two of them: - // - byte offset table will tell us which byte in memory to alter - // - mask will allow us to quickly put the pixel + ; Prepare lookup tables - to speed drawing, we are going to use two of them: + ; - byte offset table will tell us which byte in memory to alter + ; - mask will allow us to quickly put the pixel - ldx #$00 // loop index - ldy #$00 // temporary value for mask calculation -!: - // Byte offset is simple, just zero the 3 least significant bits + ldx #$00 ; loop index + ldy #$00 ; temporary value for mask calculation +@4: + ; Byte offset is simple, just zero the 3 least significant bits txa and #%11111000 sta __ha_offsets, x - // Mask changes with each iteration, use our temporary value in .Y + ; Mask changes with each iteration, use our temporary value in .Y tya clc ror - bne !+ + bne @5 lda #%10000000 -!: +@5: tay sta __ha_masks, x - // Next iteration + ; Next iteration inx - bne !-- + bne @4 - // Initialize flag for additional GFX effects + ; Initialize flag for additional GFX effects - stx __ha_gfxflag // .X is 0 at this moment + stx __ha_gfxflag ; .X is 0 at this moment - // Generate helper code for screen scrolling + ; Generate helper code for screen scrolling jsr tape_head_align_gen_code - // Provide new IRQ routine address + ; Provide new IRQ routine address lda #tape_head_align_irq sta CINV+1 - // Setup raster interrupt routine - see https://www.c64-wiki.com/wiki/Raster_interrupt + ; Setup raster interrupt routine - see https://www.c64-wiki.com/wiki/Raster_interrupt - lda #%01111111 // prevent CIA from generating interrupts - sta CIA1_ICR // $DC0D + lda #%01111111 ; prevent CIA from generating interrupts + sta CIA1_ICR ; $DC0D - and VIC_SCROLY // clear the highest bit of RASTER - sta VIC_SCROLY // $D011 + and VIC_SCROLY ; clear the highest bit of RASTER + sta VIC_SCROLY ; $D011 - lda #$FB // we want no badlines during the interrupt, this raster is 100% safe + lda #$FB ; we want no badlines during the interrupt, this raster is 100% safe sta VIC_RASTER - lda #%00000001 // enable raster interrupts - sta VIC_IRQMSK // $D01A + lda #%00000001 ; enable raster interrupts + sta VIC_IRQMSK ; $D01A cli tape_head_align_loop_1: - // Check for STOP key + ; Check for STOP key jsr udtim_keyboard jsr STOP bcs tape_head_align_quit - // Launch the timer + ; Launch the timer - ldx #%00011001 // start timer, one-shot force latch reload, count system ticks - stx CIA1_CRB // $DC0F + ldx #%00011001 ; start timer, one-shot force latch reload, count system ticks + stx CIA1_CRB ; $DC0F - // Scroll the whole chart one line down + ; Scroll the whole chart one line down ldx #$00 -!: - jsr __ha_scroll // scroll one column down, using fast generated code +@6: + jsr __ha_scroll ; scroll one column down, using fast generated code txa clc adc #$08 tax - bne !- + bne @6 - // Draw decorations + ; Draw decorations lda __ha_gfxflag inc __ha_gfxflag clc adc #$08 and #%00001100 - bne !+ + bne @7 ldy #%11110001 lda #%10001111 - bne !++ -!: + bne @8 +@7: ldy #%00000001 lda #%10000000 -!: +@8: ora __ha_chart + 7 + 8 * 0 sta __ha_chart + 7 + 8 * 0 @@ -214,13 +214,13 @@ tape_head_align_loop_1: ora __ha_chart + 7 + 8 * 31 sta __ha_chart + 7 + 8 * 31 - // Draw helper lines + ; Draw helper lines lda __ha_gfxflag and #%00000010 - beq !+ + beq @9 - // For 'normal' + ; For 'normal' lda #%00000001 ora __ha_chart + 7 + 8 * 6 @@ -230,13 +230,13 @@ tape_head_align_loop_1: ora __ha_chart + 7 + 8 * 13 sta __ha_chart + 7 + 8 * 13 - // For 'turbo' + ; For 'turbo' lda #%00010000 ora __ha_chart + 7 + 8 * 21 sta __ha_chart + 7 + 8 * 21 -!: - // FALLTROUGH +@9: + ; FALLTROUGH tape_head_align_loop_2: @@ -250,18 +250,18 @@ tape_head_align_loop_2: tape_head_align_quit: - // It makes no sense to return to system, as we already destroyed - // a lot of memory; fust clear initial BASIC text area to prevent - // data recovery attempts, and reset + ; It makes no sense to return to system, as we already destroyed + ; a lot of memory; fust clear initial BASIC text area to prevent + ; data recovery attempts, and reset ldx #$00 txa -!: +@10: sta $0800, x inx - bne !- + bne @10 jmp hw_entry_reset -#endif // CONFIG_TAPE_HEAD_ALIGN +} ; CONFIG_TAPE_HEAD_ALIGN diff --git a/src/kernal/tape/tape_head_align_gen_code.s b/src/kernal/tape/tape_head_align_gen_code.s index f79b761a..30e4834a 100644 --- a/src/kernal/tape/tape_head_align_gen_code.s +++ b/src/kernal/tape/tape_head_align_gen_code.s @@ -1,31 +1,31 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape head alignemnt tool - helper code generator -// +; +; Tape head alignemnt tool - helper code generator +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { -// Helper variables - reuse BASIC numeric work area on zero page +; Helper variables - reuse BASIC numeric work area on zero page -.label __ha_lda_addr = TEMPF1 + 0; // 2 bytes, for code generator -.label __ha_sta_addr = TEMPF1 + 2; // 2 bytes, for code generator +!addr __ha_lda_addr = TEMPF1 + 0; ; 2 bytes, for code generator +!addr __ha_sta_addr = TEMPF1 + 2; ; 2 bytes, for code generator tape_head_align_gen_code: - // Setup generated code start address + ; Setup generated code start address lda #<__ha_scroll sta SAL+0 lda #>__ha_scroll sta SAL+1 - // Setup initial source and destination addresses + ; Setup initial source and destination addresses ldy #<(__ha_chart + __ha_rows * (8 * 40) + 6) sty __ha_lda_addr + 0 @@ -36,19 +36,19 @@ tape_head_align_gen_code: sty __ha_lda_addr + 1 sty __ha_sta_addr + 1 - // Emit code to move 7 rows of one 8x8 cell -!: + ; Emit code to move 7 rows of one 8x8 cell +@1: ldx #$07 -!: +@2: jsr tape_head_align_gen_code_emit_pair dec __ha_lda_addr + 0 dec __ha_sta_addr + 0 dex - bne !- + bne @2 - // Emit code to fetch a top row from the cell above + ; Emit code to fetch a top row from the cell above inc __ha_lda_addr + 0 sec @@ -62,7 +62,7 @@ tape_head_align_gen_code: jsr tape_head_align_gen_code_emit_pair - // Prepare addresses for the next iteration + ; Prepare addresses for the next iteration lda __ha_lda_addr + 0 sta __ha_sta_addr + 0 @@ -71,16 +71,16 @@ tape_head_align_gen_code: dec __ha_lda_addr + 0 - // Now, new iteration - if needed + ; Now, new iteration - if needed lda __ha_sta_addr + 0 cmp #<(__ha_chart + 7) - bne !-- + bne @1 lda __ha_sta_addr + 1 cmp #>(__ha_chart + 7) - bne !-- + bne @1 - // Last pair to be generated starts from LDA #$00 + ; Last pair to be generated starts from LDA #$00 lda #$A9 jsr tape_head_align_gen_code_emit_byte @@ -89,7 +89,7 @@ tape_head_align_gen_code: jsr tape_head_align_gen_code_emit_sta - // Emit RTS and quit + ; Emit RTS and quit lda #$60 jmp tape_head_align_gen_code_emit_byte @@ -98,7 +98,7 @@ tape_head_align_gen_code: tape_head_align_gen_code_emit_pair: - lda #$BD // LDA absolute, x + lda #$BD ; LDA absolute, x jsr tape_head_align_gen_code_emit_byte lda __ha_lda_addr + 0 @@ -106,33 +106,32 @@ tape_head_align_gen_code_emit_pair: lda __ha_lda_addr + 1 jsr tape_head_align_gen_code_emit_byte - // FALLTROUGH + ; FALLTROUGH tape_head_align_gen_code_emit_sta: - lda #$9D // STA absolute, x + lda #$9D ; STA absolute, x jsr tape_head_align_gen_code_emit_byte lda __ha_sta_addr + 0 jsr tape_head_align_gen_code_emit_byte lda __ha_sta_addr + 1 - // FALLTROUGH + ; FALLTROUGH tape_head_align_gen_code_emit_byte: ldy #$00 sta (SAL), y -#if HAS_OPCODES_65CE02 +!ifdef HAS_OPCODES_65CE02 { inw SAL -#else +} else { inc SAL+0 - bne !+ + bne @3 inc SAL+1 -!: -#endif - +@3: +} rts -#endif // CONFIG_TAPE_HEAD_ALIGN +} ; CONFIG_TAPE_HEAD_ALIGN diff --git a/src/kernal/tape/tape_head_align_get_pulse.s b/src/kernal/tape/tape_head_align_get_pulse.s index 71b22e8e..df1cacd4 100644 --- a/src/kernal/tape/tape_head_align_get_pulse.s +++ b/src/kernal/tape/tape_head_align_get_pulse.s @@ -1,45 +1,45 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape head alignemnt tool - reading pulses from tape -// +; +; Tape head alignemnt tool - reading pulses from tape +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { tape_head_align_get_pulse: - // This routine differs from the one used to read pulse during tape reading: - // - it is not as precise - // - it terminates when timer reaches $FF - // - it returns value in .Y + ; This routine differs from the one used to read pulse during tape reading: + ; - it is not as precise + ; - it terminates when timer reaches $FF + ; - it returns value in .Y lda #$10 -!: - // Loop to detect signal +@1: + ; Loop to detect signal - ldy CIA2_TIMBLO // $DD06 - bit CIA1_ICR // $DC0D - bne !+ + ldy CIA2_TIMBLO ; $DD06 + bit CIA1_ICR ; $DC0D + bne @2 cpy #$FF - bne !- -!: - // FALLTROUGH + bne @1 +@2: + ; FALLTROUGH tape_head_align_get_pulse_start_timer: - // Start timer again, force latch reload, count timer A underflows + ; Start timer again, force latch reload, count timer A underflows lda #%01010001 - sta CIA2_CRB // $DD0F + sta CIA2_CRB ; $DD0F - // Return with time elapsed in .Y + ; Return with time elapsed in .Y rts -#endif // CONFIG_TAPE_HEAD_ALIGN +} ; CONFIG_TAPE_HEAD_ALIGN diff --git a/src/kernal/tape/tape_head_align_help.s b/src/kernal/tape/tape_head_align_help.s index a7115363..243dab12 100644 --- a/src/kernal/tape/tape_head_align_help.s +++ b/src/kernal/tape/tape_head_align_help.s @@ -1,35 +1,35 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape head alignemnt tool - prints out a help message on screen -// +; +; Tape head alignemnt tool - prints out a help message on screen +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { -// Helper variable - reuse BASIC numeric work area on zero page +; Helper variable - reuse BASIC numeric work area on zero page -.label __ha_storage = TEMPF1; // 1 byte +!addr __ha_storage = TEMPF1; ; 1 byte tape_head_align_print_help: - // Make screen font visible + ; Make screen font visible lda CPU_R6510 pha and #%11111011 sta CPU_R6510 - // Print help message + ; Print help message ldy #$00 - // Retrieve address -!: + ; Retrieve address +@1: lda tape_head_align_help_text, y iny cmp #$FF @@ -39,24 +39,24 @@ tape_head_align_print_help: lda tape_head_align_help_text, y iny sta EAL+1 -!: - // Retrieve and print character +@2: + ; Retrieve and print character lda tape_head_align_help_text, y iny cmp #$FF - beq !-- + beq @1 sty __ha_storage jsr tape_head_align_print_char ldy __ha_storage - bne !- // branch alwats + bne @2 ; branch alwats tape_head_align_print_end: - // Restore normal memory configuration and quit + ; Restore normal memory configuration and quit pla sta CPU_R6510 @@ -68,7 +68,7 @@ tape_head_align_print_string: tape_head_align_print_char: - // Calculate start address of character in .A + ; Calculate start address of character in .A sta SAL+0 lda #$00 @@ -86,62 +86,57 @@ tape_head_align_print_char: adc #$D0 sta SAL+1 - // Print out the character + ; Print out the character ldy #$07 -!: +@3: lda (SAL), y sta (EAL), y dey - bpl !- + bpl @3 - // Prepare EAL for the next character + ; Prepare EAL for the next character lda EAL+0 clc adc #$08 sta EAL+0 - bne !+ + bne @4 inc EAL+1 -!: +@4: rts -// -// Strings to print -// - -.encoding "screencode_upper" - +; +; Strings to print +; tape_head_align_help_text: - // Each string consists of: - // - destination (start byte) address - // - text in screencodes - // - $FF to mark end + ; Each string consists of: + ; - destination (start byte) address + ; - text in screencodes + ; - $FF to mark end - .word $2000 + (40 * 8) * 0 + 8 * 1 - .text "COMPUTER HAS TO TELL THE SIGNALS APART" - .byte $FF + !word $2000 + (40 * 8) * 0 + 8 * 1 + !scr "computer has to tell the signals apart" + !byte $FF - .word $2000 + (40 * 8) * 3 + 8 * 6 - .text "ALIGN HEAD FOR MINIMUM NOISE" - .byte $FF + !word $2000 + (40 * 8) * 3 + 8 * 6 + !scr "align head for minimum noise" + !byte $FF - .word $2000 + (40 * 8) * 6 + 8 * 2 - .text "IF THE DECK HAS A PITCH (TAPE SPEED)" - .byte $FF + !word $2000 + (40 * 8) * 6 + 8 * 2 + !scr "if the deck has a pitch (tape speed)" + !byte $FF - .word $2000 + (40 * 8) * 7 + 8 * 1 - .text "CONTROL, TWEAK IT SO THAT DOTTED LINES" - .byte $FF + !word $2000 + (40 * 8) * 7 + 8 * 1 + !scr "control, tweak it so that dotted lines" + !byte $FF - .word $2000 + (40 * 8) * 8 + 8 * 5 - .text "ARE HALF A WAY BETWEEN SIGNALS" - .byte $FF + !word $2000 + (40 * 8) * 8 + 8 * 5 + !scr "are half a way between signals" + !byte $FF - .byte $FF // end of strings - - -#endif + !byte $FF ; end of strings +} diff --git a/src/kernal/tape/tape_head_align_irq.s b/src/kernal/tape/tape_head_align_irq.s index 878041c6..0ff660c3 100644 --- a/src/kernal/tape/tape_head_align_irq.s +++ b/src/kernal/tape/tape_head_align_irq.s @@ -1,55 +1,55 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape head alignemnt tool - interrupt routine -// +; +; Tape head alignemnt tool - interrupt routine +; -#if CONFIG_TAPE_HEAD_ALIGN +!ifdef CONFIG_TAPE_HEAD_ALIGN { tape_head_align_irq: - // Acknowledge interrupt + ; Acknowledge interrupt asl VIC_IRQ - // Ignore 2 first pulses, they can be garbage + ; Ignore 2 first pulses, they can be garbage jsr tape_head_align_get_pulse jsr tape_head_align_get_pulse - // Now, we can retrieve pulses for the chart + ; Now, we can retrieve pulses for the chart ldx #$00 - // FALLTROUGH + ; FALLTROUGH tape_head_align_irq_loop: jsr tape_head_align_get_pulse - // If we approached badlines again - we cannot use this measurement anymore + ; If we approached badlines again - we cannot use this measurement anymore lda VIC_SCROLY - bmi !+ // branch if lower border + bmi @1 ; branch if lower border lda VIC_RASTER - cmp #$33 // first line where badline can occur + cmp #$33 ; first line where badline can occur bcs tape_head_align_irq_end -!: - // Draw pulse on the screen +@1: + ; Draw pulse on the screen cpy #$FF - beq !+ + beq @2 - // Center the chart horizontaly, with some margin from top + ; Center the chart horizontaly, with some margin from top - .label __ha_chart = $2000 + 8 * (40 * __ha_start + 4) + !addr __ha_chart = $2000 + 8 * (40 * __ha_start + 4) - phx_trash_a + +phx_trash_a lda __ha_offsets, y tax @@ -57,19 +57,19 @@ tape_head_align_irq_loop: ora __ha_chart + 7, x sta __ha_chart + 7, x - plx_trash_a -!: - // Next iteration + +plx_trash_a +@2: + ; Next iteration inx cpx #$40 bne tape_head_align_irq_loop - // FALLTROUGH + ; FALLTROUGH tape_head_align_irq_end: jmp return_from_interrupt -#endif // CONFIG_TAPE_HEAD_ALIGN +} ; CONFIG_TAPE_HEAD_ALIGN diff --git a/src/kernal/tape/tape_normal_calibrate.s b/src/kernal/tape/tape_normal_calibrate.s index 71201c5c..6dca34dc 100644 --- a/src/kernal/tape/tape_normal_calibrate.s +++ b/src/kernal/tape/tape_normal_calibrate.s @@ -1,69 +1,69 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - reading speed calibration -// -// Needs pulse length in .A -// +; +; Tape (normal) helper routine - reading speed calibration +; +; Needs pulse length in .A +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { -tape_normal_calibrate_during_pilot: // reecalibration during the pilot +tape_normal_calibrate_during_pilot: ; reecalibration during the pilot sta __normal_time_S - // We do not have any recent medium pulse measurement, - // probably the only solution is to estimate it + ; We do not have any recent medium pulse measurement, + ; probably the only solution is to estimate it lda #$FF sec sbc __normal_time_S - // We now have a difference from the starting point ($FF) + ; We now have a difference from the starting point ($FF) clc ror - sta __normal_time_M // this is temporary only! + sta __normal_time_M ; this is temporary only! - // We now have half the difference, substract it from - // short pulse measurement result + ; We now have half the difference, substract it from + ; short pulse measurement result lda __normal_time_S sec sbc __normal_time_M - // Add a small correction to gain $7D if starting from $A5. Dirty, ugly, - // and imprecise hack - but in real life should be good enough + ; Add a small correction to gain $7D if starting from $A5. Dirty, ugly, + ; and imprecise hack - but in real life should be good enough clc adc #$05 - sta __normal_time_M // estimated medium pulse length + sta __normal_time_M ; estimated medium pulse length jmp tape_normal_calibrate_common -tape_normal_calibrate_after_S: // recalibration after short pulse +tape_normal_calibrate_after_S: ; recalibration after short pulse sta __normal_time_S rts - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH -tape_normal_calibrate_after_M: // recalibration after medium pulse +tape_normal_calibrate_after_M: ; recalibration after medium pulse sta __normal_time_M - // FALLTROUGH + ; FALLTROUGH tape_normal_calibrate_common: - // Now compare results with current threshold + ; Now compare results with current threshold lda __normal_time_S sec @@ -73,20 +73,20 @@ tape_normal_calibrate_common: cmp __pulse_threshold - beq tape_normal_calibrate_done // branch if no recalibration needed + beq tape_normal_calibrate_done ; branch if no recalibration needed - // Correct the thresholds (default is $91 for the S/M one) + ; Correct the thresholds (default is $91 for the S/M one) - bcs tape_normal_calibrate_threshold_inc // branch if .A >= memory + bcs tape_normal_calibrate_threshold_inc ; branch if .A >= memory - // FALLTROUGH + ; FALLTROUGH tape_normal_calibrate_threshold_dec: lda __pulse_threshold cmp #($91-10) - bcc tape_normal_calibrate_done // do not decrement thresholds too far + bcc tape_normal_calibrate_done ; do not decrement thresholds too far sec sbc #$02 @@ -97,14 +97,14 @@ tape_normal_calibrate_threshold_dec: sbc #$03 sta __pulse_threshold_ML - bne tape_normal_calibrate_done // branch always + bne tape_normal_calibrate_done ; branch always tape_normal_calibrate_threshold_inc: lda __pulse_threshold cmp #($91+11) - bcs tape_normal_calibrate_done // do not increment thresholds too far + bcs tape_normal_calibrate_done ; do not increment thresholds too far clc adc #$02 @@ -115,12 +115,10 @@ tape_normal_calibrate_threshold_inc: adc #$03 sta __pulse_threshold_ML - // FALLTROUGH + ; FALLTROUGH tape_normal_calibrate_done: rts - - -#endif +} diff --git a/src/kernal/tape/tape_normal_get_bit.s b/src/kernal/tape/tape_normal_get_bit.s index 96ab54d4..fd3b175d 100644 --- a/src/kernal/tape/tape_normal_get_bit.s +++ b/src/kernal/tape/tape_normal_get_bit.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - bit reading -// -// Returns bit in Zero flag, Carry set means error, on 0 bit .A is 0 too -// +; +; Tape (normal) helper routine - bit reading +; +; Returns bit in Zero flag, Carry set means error, on 0 bit .A is 0 too +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_get_bit: - // Fetch the first pulse + ; Fetch the first pulse jsr tape_common_get_pulse bcc tape_normal_get_bit_1 - // First impulse was short, second should be medium + ; First impulse was short, second should be medium jsr tape_normal_calibrate_after_S @@ -28,11 +28,11 @@ tape_normal_get_bit: jsr tape_normal_calibrate_after_M - // We have a bit '0' + ; We have a bit '0' lda #$00 - // FALLTROUGH + ; FALLTROUGH tape_normal_get_bit_done: @@ -43,7 +43,7 @@ tape_normal_get_bit_done: tape_normal_get_bit_1: - // First impulse was medium, second should be short + ; First impulse was medium, second should be short jsr tape_normal_calibrate_after_M @@ -52,11 +52,11 @@ tape_normal_get_bit_1: jsr tape_normal_calibrate_after_S - // We have a bit '1' + ; We have a bit '1' clc lda #$06 - bne tape_normal_get_bit_done // branch always + bne tape_normal_get_bit_done ; branch always tape_normal_get_bit_error: @@ -65,4 +65,4 @@ tape_normal_get_bit_error: rts -#endif // CONFIG_TAPE_NORMAL +} ; CONFIG_TAPE_NORMAL diff --git a/src/kernal/tape/tape_normal_get_byte.s b/src/kernal/tape/tape_normal_get_byte.s index 35e18bec..35558dee 100644 --- a/src/kernal/tape/tape_normal_get_byte.s +++ b/src/kernal/tape/tape_normal_get_byte.s @@ -1,60 +1,60 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - byte reading -// -// Returns byte in .A (also sotred in INBIT), Carry flag set = error -// +; +; Tape (normal) helper routine - byte reading +; +; Returns byte in .A (also sotred in INBIT), Carry flag set = error +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_get_byte: - // Init parity bit and canary bit + ; Init parity bit and canary bit lda #$01 sta PRTY - lda #%01111111 // canary bit is 0 + lda #%01111111 ; canary bit is 0 sta INBIT - // Now fetch individual bits + ; Now fetch individual bits tape_normal_get_byte_loop: jsr tape_normal_get_bit bcs tape_normal_get_byte_error - beq !+ + beq @1 - // Handle parity bit + ; Handle parity bit lda #$01 eor PRTY sta PRTY sec -!: // moved bit state from Zero to Carry flag +@1: ; moved bit state from Zero to Carry flag - ror INBIT // put the bit in - bcs tape_normal_get_byte_loop // loop if no canary bit reached + ror INBIT ; put the bit in + bcs tape_normal_get_byte_loop ; loop if no canary bit reached - // Byte retrieved (on stack), now we need to validate the parity + ; Byte retrieved (on stack), now we need to validate the parity jsr tape_normal_get_bit bcs tape_normal_get_byte_error - beq !+ + beq @2 lda #$01 -!: +@2: eor PRTY bne tape_normal_get_byte_error - // Checksum validated succesfully + ; Checksum validated succesfully ldx #$0B - // Carry already clear + ; Carry already clear - // FALLTROUGH + ; FALLTROUGH tape_normal_get_byte_done: @@ -66,8 +66,6 @@ tape_normal_get_byte_done: tape_normal_get_byte_error: ldx #$09 - sec // make sure Carry is set to indicate error + sec ; make sure Carry is set to indicate error bcs tape_normal_get_byte_done - - -#endif +} diff --git a/src/kernal/tape/tape_normal_get_data_1.s b/src/kernal/tape/tape_normal_get_data_1.s index 963fcea9..9d3e49fd 100644 --- a/src/kernal/tape/tape_normal_get_data_1.s +++ b/src/kernal/tape/tape_normal_get_data_1.s @@ -1,36 +1,36 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - data block (primary) reading -// -// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too -// .Y not equal to 0 - returns error if data block is longer (length includes checksum) +; +; Tape (normal) helper routine - data block (primary) reading +; +; Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too +; .Y not equal to 0 - returns error if data block is longer (length includes checksum) -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_get_data_1: - // Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) - // and pointers for error log and correction mechanism + ; Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) + ; and pointers for error log and correction mechanism lda #$00 sta RIPRTY sta PTR2 sta PTR1 - // FALLTROUGH + ; FALLTROUGH tape_normal_get_data_1_block: - // - // Read the 1st copy of the block - // + ; + ; Read the 1st copy of the block + ; - // Read sync of the block + ; Read sync of the block ldy #$89 jsr tape_normal_sync bcs tape_normal_get_data_1_fail @@ -41,11 +41,11 @@ tape_normal_get_data_1_loop: jsr tape_normal_get_byte bcc tape_normal_get_data_1_loop_byte_OK - // Problem reading a byte, try to add it to the error log + ; Problem reading a byte, try to add it to the error log tsx - cpx #$20 // just to be on a safe side - bcc tape_normal_get_data_1_fail // branch if no more space in error log + cpx #$20 ; just to be on a safe side + bcc tape_normal_get_data_1_fail ; branch if no more space in error log ldx PTR1 lda MEMUSS+0 @@ -56,7 +56,7 @@ tape_normal_get_data_1_loop: inx stx PTR1 - // Addres added to error log, check if this was a checksum + ; Addres added to error log, check if this was a checksum jsr tape_normal_get_marker bcc tape_normal_get_data_1_loop_advance bcs tape_normal_get_data_1_success @@ -64,33 +64,33 @@ tape_normal_get_data_1_loop: tape_normal_get_data_1_loop_byte_OK: jsr tape_normal_get_marker - bcc !+ + bcc @1 - // End of the block + ; End of the block jsr tape_normal_update_checksum jmp tape_normal_get_data_1_success -!: - // Store byte, calculate checksum +@1: + ; Store byte, calculate checksum lda INBIT ldy #$00 -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr tape_normal_byte_store -#else +} else { sta (MEMUSS), y -#endif +} jsr tape_normal_update_checksum - // FALLTROUGH + ; FALLTROUGH tape_normal_get_data_1_loop_advance: - // Advance pointer -#if !HAS_OPCODES_65CE02 + ; Advance pointer +!ifndef HAS_OPCODES_65CE02 { jsr lvs_advance_MEMUSS -#else +} else { inw MEMUSS+0 -#endif +} jmp tape_normal_get_data_1_loop @@ -104,6 +104,4 @@ tape_normal_get_data_1_fail: sec rts - - -#endif +} diff --git a/src/kernal/tape/tape_normal_get_data_2.s b/src/kernal/tape/tape_normal_get_data_2.s index 2b88c12c..9f5fffc1 100644 --- a/src/kernal/tape/tape_normal_get_data_2.s +++ b/src/kernal/tape/tape_normal_get_data_2.s @@ -1,77 +1,77 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - data block (backup) reading -// +; +; Tape (normal) helper routine - data block (backup) reading +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_get_data_2: - // NOTE: Always read all the bytes fro second copy, to taht we stop - // at the moment when it is safe to start recording! + ; 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 + ; Read sync of the block ldy #$09 jsr tape_normal_sync - bcs tape_normal_get_data_2_done // Carry already set, will indicate error + bcs tape_normal_get_data_2_done ; Carry already set, will indicate error jsr tape_normal_get_marker - // FALLTROUGH + ; FALLTROUGH tape_normal_get_data_2_loop: - // Read missing bytes + ; Read missing bytes jsr tape_normal_get_byte bcc tape_normal_get_data_2_loop_byte_OK - // Problem reading a byte - just skip it + ; Problem reading a byte - just skip it bcs tape_normal_get_data_2_loop_advance tape_normal_get_data_2_loop_byte_OK: jsr load_cmp_log_MEMUSS - beq tape_normal_get_data_2_loop_from_log // branch if byte from the log + beq tape_normal_get_data_2_loop_from_log ; branch if byte from the log jsr tape_normal_get_marker - bcs tape_normal_get_data_2_log_checksum // branch if end of blocks + bcs tape_normal_get_data_2_log_checksum ; branch if end of blocks bcc tape_normal_get_data_2_loop_advance tape_normal_get_data_2_loop_from_log: - // This is a byte from the log + ; This is a byte from the log jsr tape_normal_get_marker - bcs !+ + bcs @1 lda INBIT ldy #$00 -#if ROM_LAYOUT_M65 +!ifdef CONFIG_MB_M65 { jsr tape_normal_byte_store -#else +} else { sta (MEMUSS), y -#endif -!: +} +@1: jsr tape_normal_update_checksum - // FALLTROUGH + ; FALLTROUGH tape_normal_get_data_2_loop_advance: - // Advance pointer -#if !HAS_OPCODES_65CE02 + ; Advance pointer +!ifndef HAS_OPCODES_65CE02 { jsr lvs_advance_MEMUSS -#else +} else { inw MEMUSS+0 -#endif +} jmp tape_normal_get_data_2_loop @@ -80,14 +80,14 @@ tape_normal_get_data_2_log_checksum: lda PTR1 cmp PTR2 - bne tape_normal_get_data_2_done // Carry already set + bne tape_normal_get_data_2_done ; Carry already set - // Validate checksum + ; Validate checksum lda RIPRTY - cmp #$01 // sets Carry if checksum verification fails + cmp #$01 ; sets Carry if checksum verification fails - // FALLTROUGH + ; FALLTROUGH tape_normal_get_data_2_done: @@ -99,19 +99,17 @@ load_cmp_log_MEMUSS: ldx PTR2 lda STACK+0, x cmp MEMUSS+0 - bne !+ + bne @2 lda STACK+1, x cmp MEMUSS+1 - bne !+ + bne @2 - // MEMUSS matches address from the log + ; MEMUSS matches address from the log inc PTR2 inc PTR2 - lda #$00 // to set Zero flag -!: + lda #$00 ; to set Zero flag +@2: rts - - -#endif +} diff --git a/src/kernal/tape/tape_normal_get_marker.s b/src/kernal/tape/tape_normal_get_marker.s index 350e8c49..b3f62525 100644 --- a/src/kernal/tape/tape_normal_get_marker.s +++ b/src/kernal/tape/tape_normal_get_marker.s @@ -1,17 +1,17 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - marker reading -// -// Reeturns marker type in Carry flag, set = end of data (normal marker) or failure (marker while sync) -// +; +; Tape (normal) helper routine - marker reading +; +; Reeturns marker type in Carry flag, set = end of data (normal marker) or failure (marker while sync) +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { - // (L,M) - end of byte, (L,S) - end of data + ; (L,M) - end of byte, (L,S) - end of data tape_normal_get_marker: @@ -19,9 +19,9 @@ tape_normal_get_marker: jsr tape_common_get_pulse cmp __pulse_threshold_ML - bcs tape_normal_get_marker // too short for a long pulse + bcs tape_normal_get_marker ; too short for a long pulse - // FALLTROUGH + ; FALLTROUGH tape_normal_get_marker_type: @@ -29,21 +29,21 @@ tape_normal_get_marker_type: - // Not an entry point!!! -!: - jsr tape_normal_calibrate_during_pilot // while sync use short pulses for calibration + ; Not an entry point!!! - // FALLTROUGH +tape_normal_get_marker_while_sync_loop: + + jsr tape_normal_calibrate_during_pilot ; while sync use short pulses for calibration + + ; FALLTROUGH tape_normal_get_marker_while_sync: jsr tape_common_get_pulse - bcs !- // branch if short pulse + bcs tape_normal_get_marker_while_sync_loop ; branch if short pulse cmp __pulse_threshold_ML - bcs tape_normal_get_marker_while_sync // too short for a long pulse + bcs tape_normal_get_marker_while_sync ; too short for a long pulse - bcc tape_normal_get_marker_type // branch always - - -#endif + bcc tape_normal_get_marker_type ; branch always +} diff --git a/src/kernal/tape/tape_normal_get_pilot.s b/src/kernal/tape/tape_normal_get_pilot.s index fad10a1d..40be7e60 100644 --- a/src/kernal/tape/tape_normal_get_pilot.s +++ b/src/kernal/tape/tape_normal_get_pilot.s @@ -1,25 +1,25 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - handling the pilot -// +; +; Tape (turbo) helper routine - handling the pilot +; -// Injest the pilot - series of short pulses. According to http://sidpreservation.6581.org/tape-format/ -// it consist of the following number of pulses: -// - $6A00 for header -// - $1A00 for data and seq block header -// - $4F for repeated header/data +; Injest the pilot - series of short pulses. According to http://sidpreservation.6581.org/tape-format/ +; it consist of the following number of pulses: +; - $6A00 for header +; - $1A00 for data and seq block header +; - $4F for repeated header/data -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { -tape_normal_get_pilot_header: // entry point, reset calibration, require 128x $40 pulses +tape_normal_get_pilot_header: ; entry point, reset calibration, require 128x $40 pulses - // Reading the pilot header is the first action performed, - // thus start by setting default thresholds + ; Reading the pilot header is the first action performed, + ; thus start by setting default thresholds lda #$91 sta __pulse_threshold @@ -28,36 +28,36 @@ tape_normal_get_pilot_header: // entry point, reset calibration, requir lda #$80 -#if CONFIG_TAPE_AUTODETECT - ldy #$FF // marker: try to detect turbo +!ifdef CONFIG_TAPE_AUTODETECT { + ldy #$FF ; marker: try to detect turbo bmi tape_normal_get_pilot_header_cont -#else - skip_2_bytes_trash_nvz -#endif +} else { + +skip_2_bytes_trash_nvz +} - // FALLTROUGH + ; FALLTROUGH -tape_normal_get_pilot_data: // entry point, require 4x $40 pulses +tape_normal_get_pilot_data: ; entry point, require 4x $40 pulses lda #$04 - skip_2_bytes_trash_nvz + +skip_2_bytes_trash_nvz - // FALLTROUGH + ; FALLTROUGH -tape_normal_get_pilot_short: // entry point, require 1x $40 pulses +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 +!ifdef 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 +} else { + +skip_2_bytes_trash_nvz +} - // FALLTROUGH + ; FALLTROUGH tape_normal_get_pilot_common: @@ -66,34 +66,34 @@ tape_normal_get_pilot_common: lda #$0B sta VIC_EXTCOL - // FALLTROUGH + ; FALLTROUGH tape_normal_get_pilot_common_restart: lda FSBLK sta ROPRTY - // FALLTROUGH + ; FALLTROUGH tape_normal_get_pilot_common_loop_outer: ldy #$40 - // FALLTROUGH + ; FALLTROUGH tape_normal_get_pilot_common_loop_inner: jsr tape_common_get_pulse - bcc tape_normal_get_pilot_common_restart // not a pilot - try again + bcc tape_normal_get_pilot_common_restart ; not a pilot - try again -#if CONFIG_TAPE_AUTODETECT +!ifdef 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 !++ -!: -#endif + bpl @1 + ; Try to distinguish turbo by checking for short signals + cmp #$B9 ; see comment in tape_common_autodetect.s + bcs @2 +@1: +} jsr tape_normal_calibrate_during_pilot @@ -104,8 +104,6 @@ tape_normal_get_pilot_common_loop_inner: bne tape_normal_get_pilot_common_loop_outer clc -!: +@2: rts - - -#endif +} diff --git a/src/kernal/tape/tape_normal_sync.s b/src/kernal/tape/tape_normal_sync.s index 8a749e36..19cc3b83 100644 --- a/src/kernal/tape/tape_normal_sync.s +++ b/src/kernal/tape/tape_normal_sync.s @@ -1,15 +1,15 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - synchronization handling -// -// .Y should contain start value (either $89 or $09) -// Carry set = failed +; +; Tape (turbo) helper routine - synchronization handling +; +; .Y should contain start value (either $89 or $09) +; Carry set = failed -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_sync: @@ -17,20 +17,20 @@ tape_normal_sync: lda #$06 sta VIC_EXTCOL - // Injest bytes of decreasing values + ; Injest bytes of decreasing values jsr tape_normal_get_marker_while_sync - bcs tape_normal_sync_fail // branch if end of data marker + bcs tape_normal_sync_fail ; branch if end of data marker jsr tape_normal_get_byte bcs tape_normal_sync_fail - cpy INBIT // INBIT contains same value as .A + cpy INBIT ; INBIT contains same value as .A bne tape_normal_sync_fail dey and #%01111110 - bne tape_normal_sync // branch if not $80 and not $00 + bne tape_normal_sync ; branch if not $80 and not $00 clc rts @@ -40,6 +40,4 @@ tape_normal_sync_fail: sec rts - - -#endif +} diff --git a/src/kernal/tape/tape_normal_update_checksum.s b/src/kernal/tape/tape_normal_update_checksum.s index 8b60d534..8f5010ec 100644 --- a/src/kernal/tape/tape_normal_update_checksum.s +++ b/src/kernal/tape/tape_normal_update_checksum.s @@ -1,13 +1,13 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (normal) helper routine - checksum calculation -// +; +; Tape (normal) helper routine - checksum calculation +; -#if CONFIG_TAPE_NORMAL +!ifdef CONFIG_TAPE_NORMAL { tape_normal_update_checksum: @@ -17,6 +17,4 @@ tape_normal_update_checksum: sta RIPRTY rts - - -#endif +} diff --git a/src/kernal/tape/tape_turbo_bytestore.s b/src/kernal/tape/tape_turbo_bytestore.s index 03bd41f6..e178825f 100644 --- a/src/kernal/tape/tape_turbo_bytestore.s +++ b/src/kernal/tape/tape_turbo_bytestore.s @@ -1,57 +1,57 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - storing byte uder I/O -// -// Has to preserve .A and .Y -// +; +; Tape (turbo) helper routine - storing byte uder I/O +; +; Has to preserve .A and .Y +; -// This helper routine is meant to be copied to the start of CPU stack. -// Original ROM tape loading routines uses this area to store information -// about bytes that did not read properly for the first time -// (see Mapping the C64, page 47); this mechanism is useless for turbo tape, -// but it means we can safely use this area for our purposes +; This helper routine is meant to be copied to the start of CPU stack. +; Original ROM tape loading routines uses this area to store information +; about bytes that did not read properly for the first time +; (see Mapping the C64, page 47); this mechanism is useless for turbo tape, +; but it means we can safely use this area for our purposes -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { -#if ROM_LAYOUT_M65 -.label __tape_turbo_bytestore_defmap = __tape_turbo_bytestore + 10 -#else -.label __tape_turbo_bytestore_defmap = __tape_turbo_bytestore + 7 -#endif -.label __tape_turbo_bytestore_size = __tape_turbo_bytestore_source_end - tape_turbo_bytestore_source +!ifdef CONFIG_MB_M65 { +!addr __tape_turbo_bytestore_defmap = __tape_turbo_bytestore + 10 +} else { +!addr __tape_turbo_bytestore_defmap = __tape_turbo_bytestore + 7 +} +!addr __tape_turbo_bytestore_size = __tape_turbo_bytestore_source_end - tape_turbo_bytestore_source tape_turbo_bytestore_source: -#if ROM_LAYOUT_M65 - jsr KERNAL_0.map_NORMAL -#endif +!ifdef CONFIG_MB_M65 { + jsr map_NORMAL +} - // Set all memory as RAM, tape motor ON + ; Set all memory as RAM, tape motor ON ldx #$00 stx CPU_R6510 - // Store byte in memory + ; Store byte in memory sta (MEMUSS), y - // Restore default memory layout - ldx #$00 // value will be determined later, offset from start: 7 bytes + ; Restore default memory layout + ldx #$00 ; value will be determined later, offset from start: 7 bytes stx CPU_R6510 -#if ROM_LAYOUT_M65 - // Restore default map and quit - jmp KERNAL_0.map_KERNAL_1 -#else - // Go back +!ifdef CONFIG_MB_M65 { + ; Restore default map and quit + jmp map_KERNAL_1 +} else { + ; Go back rts -#endif +} __tape_turbo_bytestore_source_end: -#endif // CONFIG_TAPE_TURBO +} ; CONFIG_TAPE_TURBO diff --git a/src/kernal/tape/tape_turbo_get_bit.s b/src/kernal/tape/tape_turbo_get_bit.s index d2cf4f6a..52416132 100644 --- a/src/kernal/tape/tape_turbo_get_bit.s +++ b/src/kernal/tape/tape_turbo_get_bit.s @@ -1,53 +1,53 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - bit reading -// +; +; Tape (turbo) helper routine - bit reading +; -// Based on routine by enthusi/Onslaught, found here: -// - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source +; Based on routine by enthusi/Onslaught, found here: +; - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { tape_turbo_get_bit: jsr tape_common_get_pulse - bcs !+ + bcs @1 clc ror - sta __turbo_half_S // store half of the last measurement result for short pulse + sta __turbo_half_S ; store half of the last measurement result for short pulse lda #$01 -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { sta SID_SIGVOL + __SID_R1_OFFSET sta SID_SIGVOL + __SID_L1_OFFSET -#else +} else { sta SID_SIGVOL -#endif +} lda #$06 sta VIC_EXTCOL sec rts -!: +@1: clc ror - sta __turbo_half_L // store half of the last measurement result for long pulse + sta __turbo_half_L ; store half of the last measurement result for long pulse lda #$00 -#if CONFIG_MB_MEGA_65 +!ifdef CONFIG_MB_M65 { sta SID_SIGVOL + __SID_R1_OFFSET sta SID_SIGVOL + __SID_L1_OFFSET -#else +} else { sta SID_SIGVOL -#endif +} sta VIC_EXTCOL clc rts -#endif // CONFIG_TAPE_TURBO +} ; CONFIG_TAPE_TURBO diff --git a/src/kernal/tape/tape_turbo_get_byte.s b/src/kernal/tape/tape_turbo_get_byte.s index 6d4753b2..584bf9f9 100644 --- a/src/kernal/tape/tape_turbo_get_byte.s +++ b/src/kernal/tape/tape_turbo_get_byte.s @@ -1,53 +1,53 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - byte reading -// -// Returns byte in .A -// +; +; Tape (turbo) helper routine - byte reading +; +; Returns byte in .A +; -// Based on routine by enthusi/Onslaught, found here: -// - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source +; Based on routine by enthusi/Onslaught, found here: +; - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { tape_turbo_get_byte: - phx_trash_a + +phx_trash_a lda #$01 - sta INBIT // init the to-be-read byte with 1 (canary bit to mark loop end) -!: + sta INBIT ; init the to-be-read byte with 1 (canary bit to mark loop end) +@1: jsr tape_turbo_get_bit rol INBIT - bcc !- // is the initial 1 shifted into carry already? - plx_trash_a + bcc @1 ; is the initial 1 shifted into carry already? + +plx_trash_a - // Compensate for tape speed variations + ; Compensate for tape speed variations - lda __turbo_half_S // half of the last value for bit '0' + lda __turbo_half_S ; half of the last value for bit '0' clc - adc __turbo_half_L // half of the last value for bit '1' + adc __turbo_half_L ; half of the last value for bit '1' sec - sbc __pulse_threshold // now we have a diff between current threshold and calculated one - beq tape_turbo_get_byte_done // branch if threshold correction not needed + sbc __pulse_threshold ; now we have a diff between current threshold and calculated one + beq tape_turbo_get_byte_done ; branch if threshold correction not needed - bpl !+ + bpl @2 lda __pulse_threshold cmp #($BF - 10) - beq tape_turbo_get_byte_done // do not decrease threshold too far no matter what + beq tape_turbo_get_byte_done ; do not decrease threshold too far no matter what dec __pulse_threshold - bne tape_turbo_get_byte_done // branch always -!: + bne tape_turbo_get_byte_done ; branch always +@2: lda __pulse_threshold cmp #($BF + 10) - beq tape_turbo_get_byte_done // do not increase threshold too far no matter what + beq tape_turbo_get_byte_done ; do not increase threshold too far no matter what inc __pulse_threshold @@ -57,4 +57,4 @@ tape_turbo_get_byte_done: rts -#endif // CONFIG_TAPE_TURBO +} ; CONFIG_TAPE_TURBO diff --git a/src/kernal/tape/tape_turbo_sync.s b/src/kernal/tape/tape_turbo_sync.s index 81106fb0..788d3b1b 100644 --- a/src/kernal/tape/tape_turbo_sync.s +++ b/src/kernal/tape/tape_turbo_sync.s @@ -1,77 +1,76 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - synchronization handling -// +; +; Tape (turbo) helper routine - synchronization handling +; -// Based on routine by enthusi/Onslaught, found here: -// - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source +; Based on routine by enthusi/Onslaught, found here: +; - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { tape_turbo_sync_header: - // Initial pulse threshold - lda #$BF // measured 128 bits '0' and 128 bits '1' under VICE, calculated average + ; Initial pulse threshold + lda #$BF ; measured 128 bits '0' and 128 bits '1' under VICE, calculated average sta __pulse_threshold - // Synchronize with start of sync sequence + ; Synchronize with start of sync sequence jsr tape_turbo_sync_first -#if CONFIG_TAPE_AUTODETECT +!ifdef CONFIG_TAPE_AUTODETECT { bcs tape_turbo_sync_done -#endif +} - // Perform synchronization, double loop, total $C0 * $04 iterations + ; Perform synchronization, double loop, total $C0 * $04 iterations ldx #$C0 -!: +@1: ldy #$04 -!: +@2: stx XSAV jsr tape_turbo_get_byte cmp #$02 - bne tape_turbo_sync_header // branch if failure + bne tape_turbo_sync_header ; branch if failure dey - bne !- + bne @2 ldx XSAV dex - bne !-- + bne @1 - // FALLTROUGH + ; FALLTROUGH tape_turbo_sync_payload: jsr tape_turbo_sync_first -#if CONFIG_TAPE_AUTODETECT - bcs tape_turbo_sync_done // this shopuld not happen -#endif -!: - ldx #$09 // 9, 8, ... -!: +!ifdef CONFIG_TAPE_AUTODETECT { + bcs tape_turbo_sync_done ; this shopuld not happen +} + ldx #$09 ; 9, 8, ... +@3: jsr tape_turbo_get_byte cmp #$02 - beq !- + beq @3 ldy #$00 -!: +@4: cpx INBIT bne tape_turbo_sync_payload jsr tape_turbo_get_byte dex - bne !- + bne @4 -#if CONFIG_TAPE_AUTODETECT +!ifdef CONFIG_TAPE_AUTODETECT { clc -#endif +} - // FALLTROUGH + ; FALLTROUGH tape_turbo_sync_done: rts -#endif // CONFIG_TAPE_TURBO +} ; CONFIG_TAPE_TURBO diff --git a/src/kernal/tape/tape_turbo_sync_first.s b/src/kernal/tape/tape_turbo_sync_first.s index 4e200bb9..6ef93293 100644 --- a/src/kernal/tape/tape_turbo_sync_first.s +++ b/src/kernal/tape/tape_turbo_sync_first.s @@ -1,30 +1,30 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Tape (turbo) helper routine - syynchronize to first byte with value $02 -// +; +; Tape (turbo) helper routine - syynchronize to first byte with value $02 +; -#if CONFIG_TAPE_TURBO +!ifdef CONFIG_TAPE_TURBO { tape_turbo_sync_first: -#if CONFIG_TAPE_AUTODETECT +!ifdef CONFIG_TAPE_AUTODETECT { ldy #$00 -!: +@1: jsr tape_turbo_get_bit rol INBIT lda INBIT cmp #$FF - bne !+ + bne @2 iny - bpl !- - bmi tape_turbo_sync_first_fail // suspiciously many $FF bytes, probably not a turbo tape -!: + bpl @1 + bmi tape_turbo_sync_first_fail ; suspiciously many $FF bytes, probably not a turbo tape +@2: cmp #$02 bne tape_turbo_sync_first @@ -36,7 +36,7 @@ tape_turbo_sync_first_fail: sec rts -#else // no CONFIG_TAPE_AUTODETECT + } else { ; no CONFIG_TAPE_AUTODETECT jsr tape_turbo_get_bit rol INBIT @@ -46,8 +46,7 @@ tape_turbo_sync_first_fail: bne tape_turbo_sync_first rts - -#endif +} -#endif +} diff --git a/src/kernal/time/rdtim.s b/src/kernal/time/rdtim.s index 0271acb3..7b0fcbab 100644 --- a/src/kernal/time/rdtim.s +++ b/src/kernal/time/rdtim.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 291 -// - [CM64] Computes Mapping the Commodore 64 - page 232 -// -// CPU registers that has to be preserved (see [RG64]): none -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 291 +; - [CM64] Computes Mapping the Commodore 64 - page 232 +; +; CPU registers that has to be preserved (see [RG64]): none +; RDTIM: - // Disable interrupts for the duration of the routine, to prevent - // jiffy clock update while reeading its values + ; Disable interrupts for the duration of the routine, to prevent + ; jiffy clock update while reeading its values sei - // Store the jiffy clock state + ; Store the jiffy clock state ldy TIME+0 ldx TIME+1 lda TIME+2 - // Enable interrupts. More elegant solution would be pha + sei + ... + pla, - // but (checked by running a test program) original ROM routine always - // leaves IRQs enabled. + ; Enable interrupts. More elegant solution would be pha + sei + ... + pla, + ; but (checked by running a test program) original ROM routine always + ; leaves IRQs enabled. cli rts diff --git a/src/kernal/time/settim.s b/src/kernal/time/settim.s index 7c07eb5c..ab81678c 100644 --- a/src/kernal/time/settim.s +++ b/src/kernal/time/settim.s @@ -1,29 +1,29 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 299/300 -// - [CM64] Computes Mapping the Commodore 64 - page 232 -// -// CPU registers that has to be preserved (see [RG64]): .A, .X, .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 299/300 +; - [CM64] Computes Mapping the Commodore 64 - page 232 +; +; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +; SETTIM: - // Disable interrupts for the duration of the routine, to prevent - // jiffy clock update while changing its values + ; Disable interrupts for the duration of the routine, to prevent + ; jiffy clock update while changing its values sei - // Store the jiffy clock state + ; Store the jiffy clock state sty TIME + 0 stx TIME + 1 sta TIME + 2 - // Enable interrupts. More elegant solution would be pha + sei + ... + pla, - // but (checked by running a test program) original ROM routine always - // leaves IRQs enabled. + ; Enable interrupts. More elegant solution would be pha + sei + ... + pla, + ; but (checked by running a test program) original ROM routine always + ; leaves IRQs enabled. cli rts diff --git a/src/kernal/time/udtim.s b/src/kernal/time/udtim.s index 44913c57..f3438648 100644 --- a/src/kernal/time/udtim.s +++ b/src/kernal/time/udtim.s @@ -1,21 +1,21 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE -// -// Official Kernal routine, described in: -// -// - [RG64] C64 Programmers Reference Guide - page 303 -// - [CM64] Computes Mapping the Commodore 64 - pages 27, 232 -// -// CPU registers that has to be preserved (see [RG64]): .Y -// +; +; Official Kernal routine, described in: +; +; - [RG64] C64 Programmers Reference Guide - page 303 +; - [CM64] Computes Mapping the Commodore 64 - pages 27, 232 +; +; CPU registers that has to be preserved (see [RG64]): .Y +; UDTIM: - // Update jiffy clock. The whole day is $4F1A00 jiffies - // (24 hours * 60 minutes * 60 seconds * 60 jiffies), - // after this time we have to reset the clock. + ; Update jiffy clock. The whole day is $4F1A00 jiffies + ; (24 hours * 60 minutes * 60 seconds * 60 jiffies), + ; after this time we have to reset the clock. inc TIME+2 bne udtim_rollover_check @@ -23,26 +23,26 @@ UDTIM: bne udtim_rollover_check inc TIME+0 - // FALLTROUGH + ; FALLTROUGH udtim_rollover_check: lda TIME+0 -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { cmp #$4F -#else +} else { cmp #$54 -#endif +} bcc udtim_keyboard lda TIME+1 -#if !CONFIG_RS232_UP9600 +!ifndef CONFIG_RS232_UP9600 { cmp #$1A -#else +} else { cmp #$60 -#endif +} bcc udtim_keyboard - // FALLTROUGH + ; FALLTROUGH udtim_clock_reset: @@ -51,61 +51,60 @@ udtim_clock_reset: sta TIME+1 sta TIME+2 - // FALLTROUGH + ; FALLTROUGH -// -// Keyboard part of the UDTIM routine, has to preserve .Y -// +; +; Keyboard part of the UDTIM routine, has to preserve .Y +; udtim_keyboard: -#if CONFIG_PLATFORM_COMMANDER_X16 +!ifdef CONFIG_PLATFORM_COMMANDER_X16 { - STUB_IMPLEMENTATION() + +STUB_IMPLEMENTATION -#else +} else { - // According to [CM64], page 27, the action we have to perform is to copy - // the last row of keyboard to RAM, so that various routines can detect the STOP - // key press. But something as simple as this would have created warm restart - // with M+N+SPACE+RESTORE due to ghosting - so the original ROM has to provide - // some protection here. I do not know what the mechanism there exactly does, - // but I hope the mechanism below will be compatible enough. + ; According to [CM64], page 27, the action we have to perform is to copy + ; the last row of keyboard to RAM, so that various routines can detect the STOP + ; key press. But something as simple as this would have created warm restart + ; with M+N+SPACE+RESTORE due to ghosting - so the original ROM has to provide + ; some protection here. I do not know what the mechanism there exactly does, + ; but I hope the mechanism below will be compatible enough. lda #$80 - sta CIA1_PRA // select all the rows except the last one -#if CONFIG_KEYBOARD_C128 + sta CIA1_PRA ; select all the rows except the last one +!ifdef CONFIG_KEYBOARD_C128 { ldx #$00 - stx VIC_XSCAN // connect all the extra C128 keys -#endif -#if CONFIG_KEYBOARD_C65 + stx VIC_XSCAN ; connect all the extra C128 keys +} +!ifdef CONFIG_KEYBOARD_C65 { ldx #$00 - stx C65_EXTKEYS_PR // connect all the extra C65 keys -#endif + stx C65_EXTKEYS_PR ; connect all the extra C65 keys +} - lda CIA1_PRB // read the keys + lda CIA1_PRB ; read the keys eor #$FF - sta STKEY // store reversed state - to filter out anything vulnerable to ghosting + sta STKEY ; store reversed state - to filter out anything vulnerable to ghosting -#if CONFIG_KEYBOARD_C128 - dex // puts $FF - stx VIC_XSCAN // disconnect the extra C128 keys -#endif -#if CONFIG_KEYBOARD_C65 - dex // puts $FF - stx C65_EXTKEYS_PR // disconnect the extra C65 keys -#endif +!ifdef CONFIG_KEYBOARD_C128 { + dex ; puts $FF + stx VIC_XSCAN ; disconnect the extra C128 keys +} +!ifdef CONFIG_KEYBOARD_C65 { + dex ; puts $FF + stx C65_EXTKEYS_PR ; disconnect the extra C65 keys +} lda #$7F - sta CIA1_PRA // select the last row (bit to 0) + sta CIA1_PRA ; select the last row (bit to 0) - lda CIA1_PRB // read the row - ora STKEY // filter out what might be the reason of ghosting + lda CIA1_PRB ; read the row + ora STKEY ; filter out what might be the reason of ghosting sta STKEY - // Leave the CIA configured this way. It would be far better to disconnect - // the keyboard at this point, but certain software (mainly intros) is - // unable to, for example, read the space bar status. + ; Leave the CIA configured this way. It would be far better to disconnect + ; the keyboard at this point, but certain software (mainly intros) is + ; unable to, for example, read the space bar status. rts - -#endif +} \ No newline at end of file diff --git a/src/program_traces/BASIC2.trace b/testsuite/program_traces/BASIC2.trace similarity index 100% rename from src/program_traces/BASIC2.trace rename to testsuite/program_traces/BASIC2.trace diff --git a/src/program_traces/README.md b/testsuite/program_traces/README.md similarity index 100% rename from src/program_traces/README.md rename to testsuite/program_traces/README.md diff --git a/tools/build_segment.cc b/tools/build_segment.cc index ab6c41ed..68211c5e 100644 --- a/tools/build_segment.cc +++ b/tools/build_segment.cc @@ -20,18 +20,16 @@ #include #include -const std::string ASM_CMD = "java -jar "; - const std::string LAB_OUT_START = "__routine_START_"; const std::string LAB_OUT_END = "__routine_END_"; -const std::string LAB_IN_START = ".label __routine_START_"; -const std::string LAB_IN_END = ".label __routine_END_"; +const std::string LAB_IN_START = "\t" + LAB_OUT_START; +const std::string LAB_IN_END = "\t" + LAB_OUT_END; // // Command line settings // -std::string CMD_assFile = "KickAss.jar"; +std::string CMD_assembler = "./acme"; std::string CMD_outFile = "OUT.BIN"; std::string CMD_outDir = "./out"; std::string CMD_segName = "MAIN"; @@ -49,7 +47,7 @@ std::list CMD_inList; void printUsage() { std::cout << "\n" << - "usage: build_segment [-a ] [-o ] [-d ]" << "\n" << + "usage: build_segment [-a ] [-o ] [-d ]" << "\n" << " [-l ] [-h ]" << "\n" << " [-s ] [-i ]" << "\n" << " [-r ]" << "\n" << @@ -70,6 +68,16 @@ void printBannerBinCompile() printBannerLineBottom(); } +std::string toLabel(const std::string &fileName) +{ + std::string retVal = fileName; + + std::replace(retVal.begin(), retVal.end(), ',', '_'); + std::replace(retVal.begin(), retVal.end(), '.', '_'); + + return retVal; +} + // // Class definitions // @@ -80,15 +88,24 @@ public: SourceFile(const std::string &fileName, const std::string &dirName); void preprocess(); - bool preprocessLine(const std::string &line); + void preprocessLine(const std::string &line, uint32_t lineNum); + void preprocessLine_Alias(const std::list &tokens, std::list::iterator &iter, uint32_t lineNum); + void preprocessLine_Import(const std::list &tokens, std::list::iterator &iter); + void preprocessLine_Layout(const std::list &tokens, std::list::iterator &iter); + bool nameMatch(const std::string &token, const std::string &name); std::string fileName; std::string dirName; + bool layoutProcessingDone; bool ignore; bool floating; bool high; + + std::map>> symbolImports; + std::map> symbolAliases; + std::vector content; std::string label; @@ -166,7 +183,7 @@ void parseCommandLine(int argc, char **argv) { switch(opt) { - case 'a': CMD_assFile = optarg; break; + case 'a': CMD_assembler = optarg; break; case 'o': CMD_outFile = optarg; break; case 'd': CMD_outDir = optarg; break; case 's': CMD_segName = optarg; break; @@ -291,15 +308,15 @@ void calcRoutineSizes() // Start at $100, so that no local data gets accesses using ZP addressing modes // during this pass, which would otherwise upset things later - outFile << "\n" << ".segment " << CMD_segName << " [start=$100, min=$100, max=$FFFF]" << "\n"; - outFile << "#define SEGMENT_" << CMD_segName << "\n"; - outFile << "#define ROM_LAYOUT_" << CMD_romLayout << "\n"; + outFile << "\n" << "*=$100" << "\n"; + outFile << "!set SEGMENT_" << CMD_segName << " = 1\n"; + outFile << "!set ROM_LAYOUT_" << CMD_romLayout << " = 1\n"; for (const auto &sourceFile : GLOBAL_sourceFiles) { outFile << "\n\n\n\n"; - outFile << "/* Source file: " << sourceFile.fileName << " */" << "\n\n"; - outFile << ".memblock \"" << sourceFile.fileName << "\"" << "\n"; + outFile << ";--- Source file " << sourceFile.fileName << "\n\n"; + outFile << "!zone " << toLabel(sourceFile.fileName) << "\n\n"; outFile << LAB_OUT_START << sourceFile.label << ":" << "\n\n"; outFile << std::string(sourceFile.content.begin(), sourceFile.content.end()); @@ -313,8 +330,9 @@ void calcRoutineSizes() // All written - now launch the assembler - const std::string cmd = "cd " + filePath + " && " + ASM_CMD + CMD_assFile + " " + - outFileNameBare + " -symbolfile -o /dev/null"; + const std::string cmd = "cd " + filePath + " && " + CMD_assembler + + " --color --outfile /dev/null --symbollist " + CMD_segName + "_sizetest.sym " + + outFileNameBare; std::cout << "command: " << cmd << "\n" << std::flush; if (0 != system(cmd.c_str())) { @@ -348,8 +366,8 @@ void calcRoutineSizes() auto eqPos = line.rfind('='); - auto address = strtol(line.substr(eqPos + 2).c_str(), nullptr ,16); - std::string refLabel = line.substr(0, eqPos); + auto address = strtol(line.substr(eqPos + 3).c_str(), nullptr , 16); + std::string refLabel = line.substr(0, eqPos - 1); for (auto &sourceFile : GLOBAL_sourceFiles) { @@ -494,32 +512,32 @@ void compileSegment() // First combine everything into one assembler file const std::string outFileNameBare = CMD_segName + "_combined.s"; + const std::string vlfFileNamePath = CMD_segName + "_combined.vs"; + const std::string repFileNamePath = CMD_segName + "_combined.rep"; + const std::string symFileNamePath = CMD_segName + "_combined.sym"; const std::string filePath = CMD_outDir + DIR_SEPARATOR; const std::string outFileNamePath = filePath + outFileNameBare; unlink(outFileNamePath.c_str()); + unlink(vlfFileNamePath.c_str()); + unlink(repFileNamePath.c_str()); + unlink(symFileNamePath.c_str()); std::ofstream outFile(outFileNamePath, std::fstream::out | std::fstream::trunc); if (!outFile.good()) ERROR(std::string("can't open temporary file '") + outFileNamePath + "'"); // Write the header - outFile << "\n" << - ".segment " << CMD_segName << - " [start=$" << std::hex << CMD_loAddress << - ", min=$" << std::hex << CMD_loAddress << - ", max=$" << std::hex << CMD_hiAddress << - ", outBin=\"" << CMD_outFile << "\", fill]" << - "\n"; - outFile << "#define SEGMENT_" << CMD_segName << "\n"; - outFile << "#define ROM_LAYOUT_" << CMD_romLayout << "\n"; - outFile << ".namespace " << CMD_segName << " {" << "\n\n"; + outFile << "!set SEGMENT_" << CMD_segName << " = 1\n"; + outFile << "!set ROM_LAYOUT_" << CMD_romLayout << " = 1\n\n"; + outFile << "\t* = $" << std::hex << CMD_loAddress << ", INVISIBLE\n"; + outFile << "\t!fill $" << std::hex << (CMD_hiAddress + 1 - CMD_loAddress) << "\n\n"; // Write files which only contain definitions (no routines) for (const auto &sourceFile : GLOBAL_sourceFiles_noCode) { outFile << "\n\n\n\n"; - outFile << "/* Source file: " << sourceFile.fileName << " */" << "\n\n"; - outFile << ".memblock \"" << sourceFile.fileName << "\"" << "\n"; + outFile << ";--- Source file " << sourceFile.fileName << "\n\n"; + outFile << "!zone " << toLabel(sourceFile.fileName) << "\n\n"; outFile << std::string(sourceFile.content.begin(), sourceFile.content.end()); outFile << "\n"; } @@ -529,22 +547,27 @@ void compileSegment() for (const auto &routine : GLOBAL_binningProblem.fixedRoutines) { outFile << "\n\n\n\n"; - outFile << "/* Source file: " << routine.second->fileName << " */" << "\n\n"; - outFile << ".memblock \"" << routine.second->fileName << "\"" << "\n"; + outFile << ";--- Source file " << routine.second->fileName << "\n\n"; + outFile << "!zone " << toLabel(routine.second->fileName) << "\n\n"; outFile << "\t* = $" << std::hex << routine.first << "\n\n"; outFile << std::string(routine.second->content.begin(), routine.second->content.end()); outFile << "\n"; } - outFile << "\n\n" << "} // namespace" << "\n"; + outFile << "\n\n"; if (!outFile.good()) ERROR(std::string("error writing temporary file '") + outFileNamePath + "'"); outFile.close(); // All written - now launch the assembler - const std::string cmd = "cd " + filePath + " && " + ASM_CMD + CMD_assFile + " " + - outFileNameBare + " -symbolfile -vicesymbols -o " + CMD_outFile; + const std::string cmd = "cd " + filePath + " && " + CMD_assembler + + " --strict-segments --color" + + " --outfile " + CMD_outFile + + " --symbollist " + symFileNamePath + + " --vicelabels " + vlfFileNamePath + + " --report " + repFileNamePath + + " " + outFileNameBare; std::cout << "command: " << cmd << "\n" << std::flush; if (0 != system(cmd.c_str())) { @@ -582,6 +605,7 @@ int main(int argc, char **argv) SourceFile::SourceFile(const std::string &fileName, const std::string &dirName) : fileName(fileName), dirName(dirName), + layoutProcessingDone(false), ignore(false), floating(false), high(false), @@ -638,30 +662,65 @@ SourceFile::SourceFile(const std::string &fileName, const std::string &dirName) preprocess(); - // Generate KickAss compatible label from the file name + // Generate assembler compatible label from the file name - label = fileName.substr(0, fileName.length() - 2); - - std::replace(label.begin(), label.end(), '.', '_'); - std::replace(label.begin(), label.end(), ',', '_'); + label = toLabel(fileName); } void SourceFile::preprocess() { std::string contentStr(content.begin(), content.end()); - std::istringstream stream(contentStr); + std::istringstream stream1(contentStr); + std::istringstream stream2(contentStr); std::string line; + uint32_t lineNum = 0; - while (std::getline(stream, line)) + // Preprocess all the lines + + while (std::getline(stream1, line)) { + lineNum++; + if (line.empty()) continue; std::replace(line.begin(), line.end(), '\t', ' '); line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); - if (!preprocessLine(line)) break; + preprocessLine(line, lineNum - 1); } + + // Replace content with preprocessed one + + std::string spacing; + content.clear(); + lineNum = 0; + + size_t maxSymLen = 0; + for (const auto &symbolAlias : symbolAliases) maxSymLen = std::max(maxSymLen, symbolAlias.second.first.length()); + + while (std::getline(stream2, line)) + { + if (symbolAliases.find(lineNum) != symbolAliases.end()) + { + std::ostringstream alias; + spacing.resize(maxSymLen + 2 - symbolAliases[lineNum].first.length(), ' '); + alias << "!addr " << symbolAliases[lineNum].first << spacing << "= $" << + std::hex << symbolAliases[lineNum].second << " " << line; + const std::string aliasStr = alias.str(); + content.insert(content.end(), aliasStr.begin(), aliasStr.end()); + } + else + { + content.insert(content.end(), line.begin(), line.end()); + } + + content.push_back('\n'); + lineNum++; + } + + symbolAliases.clear(); + symbolImports.clear(); } -bool SourceFile::preprocessLine(const std::string &line) +void SourceFile::preprocessLine(const std::string &line, uint32_t lineNum) { // Split the line into tokens @@ -674,7 +733,7 @@ bool SourceFile::preprocessLine(const std::string &line) if (token.empty()) continue; tokens.push_back(token); } - if (tokens.empty()) return true; + if (tokens.empty()) return; // Now preprocess line using the token list @@ -682,19 +741,94 @@ bool SourceFile::preprocessLine(const std::string &line) // Injest the comment token - if ((iter++)->compare("//") != 0 || iter == tokens.end()) return true; + if ((iter++)->compare(";;") != 0 || iter == tokens.end()) return; // Check if supported directive - if ((iter++)->compare("#LAYOUT#") != 0) return true; + if (iter->compare("#ALIAS#") == 0) preprocessLine_Alias(tokens, ++iter, lineNum); + else if (iter->compare("#IMPORT#") == 0) preprocessLine_Import(tokens, ++iter); + else if (iter->compare("#LAYOUT#") == 0) preprocessLine_Layout(tokens, ++iter); +} + +void SourceFile::preprocessLine_Alias(const std::list &tokens, std::list::iterator &iter, uint32_t lineNum) +{ + if (ignore) return; + + // Extract symbol, namespace, and target + + if (iter == tokens.end()) ERROR("syntax error, missing symbol in '#ALIAS#'"); + std::string symbol = *(iter++); + + if (iter == tokens.end() || (iter++)->compare("=") != 0) ERROR("syntax error, expected assignment in '#ALIAS#'"); + if (iter == tokens.end()) ERROR("syntax error, missing namespace/target in '#ALIAS#'"); + + auto dotPos = iter->rfind('.'); + std::string symNameSpace = iter->substr(0, dotPos); + std::string symTarget = iter->substr(dotPos + 1, std::string::npos); + + if (symNameSpace.empty()) ERROR("syntax error, missing namespace in '#ALIAS#'"); + if (symTarget.empty()) ERROR("syntax error, missing target in '#ALIAS#'"); + + // Put the alias - if address found + + for (const auto &alias : symbolImports[symNameSpace]) + { + if (alias.first.compare(symTarget) != 0) continue; + + symbolAliases[lineNum] = std::pair(symbol, alias.second); + break; + } +} + +void SourceFile::preprocessLine_Import(const std::list &tokens, std::list::iterator &iter) +{ + if (ignore) return; + + if (iter == tokens.end()) ERROR("syntax error, missing namespace in '#IMPORT#'"); + std::string symNameSpace = *(iter++); + + if (iter == tokens.end() || iter->compare("=") != 0) ERROR("syntax error, expected assignment in '#IMPORT#'"); + + while (++iter != tokens.end()) + { + // Try to import sumbols for the file + + std::ifstream impFile; + impFile.open(CMD_outDir + DIR_SEPARATOR + *iter); + if (!impFile.good()) + { + impFile.close(); + continue; + } + + std::string line; + while (std::getline(impFile, line)) + { + // Import label and address + + auto eqPos = line.rfind('='); + + auto address = strtol(line.substr(eqPos + 3).c_str(), nullptr , 16); + std::string label = line.substr(1, eqPos - 2); + + symbolImports[symNameSpace].push_back(std::pair(label, address)); + } + + impFile.close(); + } +} + +void SourceFile::preprocessLine_Layout(const std::list &tokens, std::list::iterator &iter) +{ + if (layoutProcessingDone) return; // Check if segment name and rom layout match if (iter == tokens.end()) ERROR("syntax error, missing rom layout in '#LAYOUT#'"); - if (!nameMatch(*(iter++), CMD_romLayout)) return true; + if (!nameMatch(*(iter++), CMD_romLayout)) return; if (iter == tokens.end()) ERROR("syntax error, missing segment name in '#LAYOUT#'"); - if (!nameMatch(*(iter++), CMD_segName)) return true; + if (!nameMatch(*(iter++), CMD_segName)) return; // Retrieve and apply action @@ -720,14 +854,15 @@ bool SourceFile::preprocessLine(const std::string &line) } else if (iter->compare("#TAKE") != 0) { - ERROR(std::string("syntax error, unsupported action '") + token + "' in '#LAYOUT#'"); + ERROR(std::string("syntax error, unsupported action '") + *iter + "' in '#LAYOUT#'"); } - // Tell the caller to finish processing the file + // Mark the file - to tell that layout processing is finished - return false; + layoutProcessingDone = true; } + bool SourceFile::nameMatch(const std::string &token, const std::string &name) { return (token.compare("*") == 0) || (token.compare(name) == 0); diff --git a/tools/generate_constants.cc b/tools/generate_constants.cc index 9e45e591..a13866fd 100644 --- a/tools/generate_constants.cc +++ b/tools/generate_constants.cc @@ -202,7 +202,7 @@ std::string toAssemblerString(const std::string &constName, double constValue) outFloat[4], constValue); - std::string outDef = std::string("\n.macro put_const_") + constName + "()\n{\n\t.byte " + buf + "\n}\n"; + std::string outDef = std::string("\n!macro PUT_CONST_") + constName + " {\n\t!byte " + buf + "\n}\n"; return outDef; } diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc index 4a021996..3779c015 100644 --- a/tools/generate_strings.cc +++ b/tools/generate_strings.cc @@ -1229,7 +1229,7 @@ void DataSet::generateConfigDepStrings() // List found - if (GLOBAL_ConfigOptions["CONFIG_SHOW_FEATURES"] || GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"]) + if (GLOBAL_ConfigOptions["CONFIG_SHOW_FEATURES"] || GLOBAL_ConfigOptions["CONFIG_MB_M65"]) { StringEntry newEntry1 = { true, true, true, true, "STR_PAL", "PAL\r" }; StringEntry newEntry2 = { true, true, true, true, "STR_NTSC", "NTSC\r" }; @@ -1244,13 +1244,13 @@ void DataSet::generateConfigDepStrings() stringEntryList.list.push_back(newEntry); } - if (GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"]) + if (GLOBAL_ConfigOptions["CONFIG_MB_M65"]) { 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"]) + if (!GLOBAL_ConfigOptions["CONFIG_BRAND_CUSTOM_BUILD"] || GLOBAL_ConfigOptions["CONFIG_MB_M65"]) { StringEntry newEntry = { true, true, true, true, "STR_PRE_REV", "RELEASE " }; stringEntryList.list.push_back(newEntry); @@ -1498,9 +1498,9 @@ void DataSet::encodeStringsFreq() void DataSet::putCharEncoding(std::ostringstream &stream, uint8_t idx, char character, bool is3n) { - stream << "\t.byte $" << std::uppercase << std::hex << + stream << "\t!byte $" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << +character << - " // " << std::setfill(is3n ? '0' : ' ') << std::setw(2) << +idx; + " ; " << std::setfill(is3n ? '0' : ' ') << std::setw(2) << +idx; std::string petscii; @@ -1530,7 +1530,7 @@ void DataSet::prepareOutput_1n_3n(std::ostringstream &stream) // Export all nibble-encoded characters - stream << std::endl << ".macro put_packed_as_1n() // characters encoded as 1 nibble" << std::endl << "{" << std::endl; + stream << std::endl << "!macro PUT_PACKED_AS_1N { ; characters encoded as 1 nibble" << std::endl << std::endl; idx = 0; for (const auto& encoding : as1n) @@ -1542,13 +1542,13 @@ void DataSet::prepareOutput_1n_3n(std::ostringstream &stream) // Export all byte-encoded characters - stream << std::endl << ".macro put_packed_as_3n() // characters encoded as 3 nibbles" << std::endl << "{" << std::endl; + stream << std::endl << "!macro PUT_PACKED_AS_3N { ; characters encoded as 3 nibbles" << std::endl << std::endl; idx = 0; for (const auto& encoding : as3n) { if (idx == tk__packed_as_3n) stream << std::endl << - "\t// Characters below are not used by any BASIC keyword" << std::endl << std::endl; + "\t; Characters below are not used by any BASIC keyword" << std::endl << std::endl; putCharEncoding(stream, ++idx, encoding, true); } @@ -1571,7 +1571,7 @@ void DataSet::prepareOutput_labels(std::ostringstream &stream, if (!stringEncoded.empty()) { - stream << ".label IDX__" << stringEntry.alias << + stream << "!set IDX__" << stringEntry.alias << std::string(maxAliasLen - stringEntry.alias.length(), ' ') << " = $" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << +idx << std::endl; } @@ -1584,14 +1584,14 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, { if (isCompressionLvl2(stringEntryList)) { - stream << std::endl << ".macro put_packed_dict_"; + stream << std::endl << "!macro PUT_PACKED_DICT_"; } else { - stream << std::endl << ".macro put_packed_freq_"; + stream << std::endl << "!macro PUT_PACKED_FREQ_"; } - stream << stringEntryList.name << "()" << std::endl << "{" << std::endl; + stream << stringEntryList.name << " {" << std::endl << std::endl; enum LastStr { NONE, SKIPPED, WRITTEN } lastStr = LastStr::NONE; for (uint8_t idxString = 0; idxString < stringEncodedList.size(); idxString++) @@ -1603,7 +1603,7 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, if (stringEntryList.type == ListType::DICTIONARY) ERROR("internal error"); // should never happen if (lastStr == LastStr::WRITTEN) stream << std::endl; - stream << "\t.byte $00 // skipped " << stringEntryList.list[idxString].alias << std::endl; + stream << "\t!byte $00 ; skipped " << stringEntryList.list[idxString].alias << std::endl; lastStr = LastStr::SKIPPED; } else @@ -1614,12 +1614,12 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, if (stringEntryList.type != ListType::DICTIONARY) { - stream << "\t// IDX__" << stringEntryList.list[idxString].alias << std::endl; + stream << "\t; IDX__" << stringEntryList.list[idxString].alias << std::endl; } // Output the source string - as a comment - stream << "\t// '"; + stream << "\t; '"; for (auto &character : stringEntryList.list[idxString].string) { if (character >= 32 && character <= 132 && character != 39 && character != 34) @@ -1639,7 +1639,7 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, // Output the encoding - stream << "\t.byte "; + stream << "\t!byte "; bool first = true; for (const auto &charEncoded : stringEncoded) @@ -1665,8 +1665,8 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, if (stringEntryList.type == ListType::KEYWORDS) { - stream << std::endl << "\t// Marker - end of the keyword list" << std::endl; - stream << "\t.byte $FF, $FF" << std::endl; + stream << std::endl << "\t; Marker - end of the keyword list" << std::endl; + stream << "\t!byte $FF, $FF" << std::endl; } stream << "}" << std::endl; @@ -1677,7 +1677,7 @@ void DataSet::prepareOutput() // Convert our encoded strings to a KickAssembler source std::ostringstream stream; - stream << std::endl << "#if ROM_LAYOUT_" << layoutName() << std::endl; + stream << std::endl << "!ifdef ROM_LAYOUT_" << layoutName() << " {"<< std::endl; // Export 1-nibble and 3-nibble encoding data @@ -1685,8 +1685,8 @@ void DataSet::prepareOutput() // Export additional data for the tokenizer - stream << std::endl << ".label TK__PACKED_AS_3N = $" << std::hex << +tk__packed_as_3n << - std::endl << ".label TK__MAX_KEYWORD_LEN = " << std::dec << +tk__max_keyword_len << std::endl; + stream << std::endl << "!set TK__PACKED_AS_3N = $" << std::hex << +tk__packed_as_3n << + std::endl << "!set TK__MAX_KEYWORD_LEN = " << std::dec << +tk__max_keyword_len << std::endl; // Export encoded strings @@ -1705,7 +1705,7 @@ void DataSet::prepareOutput() if (stringEntryList.type == ListType::KEYWORDS) { - stream << std::endl << ".label TK__MAXTOKEN_" << stringEntryList.name << " = " << + stream << std::endl << "!set TK__MAXTOKEN_" << stringEntryList.name << " = " << std::dec << stringEncodedList.size() << std::endl; } @@ -1716,7 +1716,7 @@ void DataSet::prepareOutput() // Finalize the file stream - stream << std::endl << "#endif // ROM_LAYOUT_" << layoutName() << std::endl; + stream << std::endl << "} ; ROM_LAYOUT_" << layoutName() << std::endl; outFileContent = stream.str(); } @@ -1748,21 +1748,21 @@ void parseConfigFile() std::getline(cnfFile, workStr); if (cnfFile.bad()) ERROR("error reading configuration file"); workStr = std::regex_replace(workStr, std::regex("^[ \t]+"), ""); - + // Skip lines which are not preprocessor definitions - if (workStr.empty() || workStr[0] != '#') continue; + if (workStr.empty() || workStr[0] != '!') continue; - // Make sure this is '#define ' + // Make sure this is '!set ' - if (!std::regex_match(workStr, std::regex("^#define[ \t].*"))) + if (!std::regex_match(workStr, std::regex("^\\!set[ \t].*"))) { - ERROR(std::string("only '#define' preprocessor directives allowed in config files - line ") + std::to_string(lineNum)); + continue; } - // Get rid of the directive and trailing spaces/comments + // Get rid of the directive and trailing spaces/values/comments - workStr = std::regex_replace(workStr, std::regex("^#define[ \t]+"), ""); + workStr = std::regex_replace(workStr, std::regex("^\\!set[ \t]+"), ""); workStr = std::regex_replace(workStr, std::regex("[ \t]+.*"), ""); // Add definitin to config option map @@ -1784,7 +1784,7 @@ void printUsage() void printBanner() { printBannerLineTop(); - std::cout << "// Generating compressed messages and BASIC tokens\n"; + std::cout << "; Generating compressed messages and BASIC tokens\n"; printBannerLineBottom(); } @@ -1824,7 +1824,7 @@ void writeStrings() outputString = dataSetX16.getOutput(); } - else if (GLOBAL_ConfigOptions["CONFIG_PLATFORM_COMMODORE_64"] && GLOBAL_ConfigOptions["CONFIG_MB_MEGA_65"]) + else if (GLOBAL_ConfigOptions["CONFIG_PLATFORM_COMMODORE_64"] && GLOBAL_ConfigOptions["CONFIG_MB_M65"]) { DataSetM65 dataSetM65; @@ -1841,7 +1841,7 @@ void writeStrings() outputString = dataSetM65.getOutput(); } - else if (GLOBAL_ConfigOptions["CONFIG_PLATFORM_COMMODORE_64"] && GLOBAL_ConfigOptions["CONFIG_MB_ULTIMATE_64"]) + else if (GLOBAL_ConfigOptions["CONFIG_PLATFORM_COMMODORE_64"] && GLOBAL_ConfigOptions["CONFIG_MB_U64"]) { DataSetU64 dataSetU64; @@ -1887,7 +1887,7 @@ void writeStrings() // Write header - outFile << "//\n// Generated file - do not edit\n//"; + outFile << ";\n; Generated file - do not edit\n;"; // Write packed strings