diff --git a/CONFIG.md b/CONFIG.md index 409511a4..fd47a97c 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -113,7 +113,7 @@ Uses RAM under BASIC, I/O and KERNAL, takes over `$C000`-`$CFFF` area requires s 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. -## I/O devices +## IEC devices ### `CONFIG_IEC` @@ -143,17 +143,27 @@ Needs about 430 bytes in KERNAL segment. If unsure - enable. Causes screen blanking during JiffyDOS file loading to increase performance. +## Tape support + +Note: for Mega65 most of the tape support code is placed in it's extended ROM; very little of the (tiny) KERNAL segment is used. + ### `CONFIG_TAPE_NORMAL` Adds a minimal normal (standard Commodore format) tape support - just LOAD command. -Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 900 bytes are needed, as they share some code). If unsure - enable. +Needs about 1050 bytes in KERNAL segment (if both normal and turbo are enabled, about 900 bytes are needed, as they share some code). If unsure - enable. ### `CONFIG_TAPE_TURBO` Adds a minimal turbo tape support - just LOAD command (device 7, like on _Action Replay_ and _Final_ cartridges), up to 250 blocks -Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 950 bytes are needed, as they share some code). If unsure - enable. +Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 1300 bytes are needed, as they share some code). If unsure - enable. + +### `CONFIG_TAPE_AUTODETECT` + +Tape format (normal/turbo) is always autodetected. + +Needs about 100 more bytes in KERNAL segment. ### `CONFIG_TAPE_NO_KEY_SENSE` @@ -163,6 +173,12 @@ Enable this option if you are using a tape interface adapter with some audio sig Enable this option if you are using a tape interface adapter lacking tape motor control (most likely every adapter currently being sold) - this will eliminate the need to quickly press space when the program header information gets displayed. Note: if you are using a cassette player with REM port, and your adapter is connected to this port too, than you do not need this option. +### `CONFIG_TAPE_NO_ERROR_CORRECTION` + +Normal tape format contains two copies of each data block - in case some bytes from the first one are damaged, they can be corrected by reading them from the second copy. Enabling this option omits the core to read the second block. + +If used with `CONFIG_TAPE_NORMAL`, saves about 125 bytes in KERNAL segment. Not recommended when using real magnetic tapes. + ## Multiple SID support The SID is a sound chip - original machine had one installed. However, mods exists to add more of them for improved sound capabilitiee. 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. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c2bcde66..902f47aa 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,3 +1,3 @@ -Although the project itself is LGPL3, I (FeralChild64 - Roman St********ski) allow to redistribute +Although the project itself is LGPL3, I (FeralChild64 - Roman Standzikowski) allow to redistribute my contributions to this project under any OSI (Open Source Initiative) approved open source license. diff --git a/CREDITS.md b/CREDITS.md new file mode 100644 index 00000000..72143f5f --- /dev/null +++ b/CREDITS.md @@ -0,0 +1,25 @@ + +# CREDITS to people whose work was of great help to us + +## for source code we reused + +* TWW/CTR - for his keyboard handling code +* Graham - for his PAL/NTSC detection routine +* enthusi/Onslaught - for his example Turbo Tape 64 compatible loader + +## for documentation + +* Frantic - for [Codebase 64](https://codebase64.org) +* Joe Forster/STA - for the official/unofficial ROM API description at [sta.c64.org](http://sta.c64.org) +* J. Derogee - for the IEC Disected document +* Michael Steil - for a great IEC protocol description and various other documentation at [his blog](https://www.pagetable.com) +* Jochen Adler - for the JiffyDOS protocol reverse engineering +* H2Obsession - for the JiffyDOS protocol description on [his page](https://sites.google.com/site/h2obsession/CBM/C128/JiffySoft128) +* SD2IEC team - the project [source code](https://github.com/rkrajnc/sd2iec) helped a lot when adding IEC and JiffyDOS support +* slark - for his screen codes / PETSCII description at [slark.me](https://slark.me) +* silverdr - for the floating point routines [description](https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics) +* the [C64 Wiki](https://www.c64-wiki.com) contributors + +
+ +* ... and all the others we forgot diff --git a/LICENSE b/LICENSE index d309cbde..310d50d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,9 @@ The following copyright notices apply to the entirety of this package, -including each source file, unless otherwise noted in each file. +including each source file, unless otherwise noted in each file or directory. - Copyright Paul Gardner-Stephen, 2019. + Copyright Paul Gardner-Stephen, 2019. + Copyright Roman Standzikowski (FeralChil64), 2019-2020. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by diff --git a/Makefile b/Makefile index c220d998..eecfb259 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,21 @@ SRCDIR_COMMON = c64/aliases SRCDIR_BASIC = $(SRCDIR_COMMON) \ c64/basic \ c64/basic/,stubs \ + c64/basic/,stubs_math \ + c64/basic/board_m65 \ + c64/basic/board_x16 \ c64/basic/commands \ c64/basic/init \ + c64/basic/math \ + c64/basic/math_consts \ c64/basic/rom_revision SRCDIR_KERNAL = $(SRCDIR_COMMON) \ c64/kernal \ c64/kernal/,stubs \ c64/kernal/assets \ - c64/kernal/banking \ + c64/kernal/board_m65 \ + c64/kernal/board_x16 \ c64/kernal/iec \ c64/kernal/iec_fast \ c64/kernal/init \ @@ -35,44 +41,90 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \ c64/kernal/tape \ c64/kernal/time - -SRC_TOOLS = $(wildcard src/tools/*.c,src/tools/*.cc) +SRC_BASIC = $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) +SRC_KERNAL = $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) +SRC_TOOLS = $(wildcard tools/*.c,tools/*.cc) # Generated files -GEN_BASIC = build/,generated/packed_messages.s +GEN_BASIC = build/,generated/packed_messages.s build/,generated/float_constants.s GEN_KERNAL = +# List of build directories + +DIR_CUS = build/target_custom +DIR_GEN = build/target_generic +DIR_TST = build/target_testing +DIR_M65 = build/target_mega65 +DIR_U64 = build/target_ultimate64 +DIR_X16 = build/target_cx16 + +# List of config files + +CFG_CUS = c64/,,config_custom.s +CFG_GEN = c64/,,config_generic.s +CFG_TST = c64/,,config_testing.s +CFG_M65 = c64/,,config_mega65.s +CFG_U64 = c64/,,config_ultimate64.s +CFG_X16 = c64/,,config_cx16.s + +# Dependencies - helper variables + +DEP_BASIC = $(SRC_BASIC) $(SRCDIR_BASIC) $(GEN_BASIC) +DEP_KERNAL = $(SRC_KERNAL) $(SRCDIR_KERNAL) $(GEN_KERNAL) + # List of tools -TOOL_COLLECT_DATA = build/tools/collect_data -TOOL_COMPRESS_TEXT = build/tools/compress_text -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_COLLECT_DATA = build/tools/collect_data +TOOL_COMPRESS_TEXT = build/tools/compress_text +TOOL_GENERATE_CONSTANTS = build/tools/generate_constants +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 -TOOLS_LIST = $(pathsubst src/tools/%,build/tools/%,$(basename $(SRC_TOOLS))) +TOOLS_LIST = $(pathsubst tools/%,build/tools/%,$(basename $(SRC_TOOLS))) # List of targets -STD_TARGET_LIST_CUSTOM = build/kernal_custom.rom build/basic_custom.rom -STD_TARGET_LIST_GENERIC = build/kernal_generic.rom build/basic_generic.rom -STD_TARGET_LIST_TESTING = build/kernal_testing.rom build/basic_testing.rom -STD_TARGET_LIST_ULTIMATE64 = build/kernal_ultimate64.rom build/basic_ultimate64.rom -STD_TARGET_LIST_MEGA65 = build/mega65.rom +TARGET_CUS_B = build/basic_custom.rom +TARGET_GEN_B = build/basic_generic.rom +TARGET_TST_B = build/basic_testing.rom +TARGET_U64_B = build/basic_ultimate64.rom -STD_TARGET_LIST = build/chargen.rom \ - $(STD_TARGET_LIST_CUSTOM) \ - $(STD_TARGET_LIST_GENERIC) \ - $(STD_TARGET_LIST_TESTING) \ - $(STD_TARGET_LIST_MEGA65) \ - $(STD_TARGET_LIST_ULTIMATE64) +TARGET_CUS_K = build/kernal_custom.rom +TARGET_GEN_K = build/kernal_generic.rom +TARGET_TST_K = build/kernal_testing.rom +TARGET_U64_K = build/kernal_ultimate64.rom -EXT_TARGET_LIST = build/mega65.rom +TARGET_M65_x = build/mega65.rom +TARGET_X16_x = build/cx16-dummy.rom -REL_TARGET_LIST = $(pathsubst build/%,bin/%, $(STD_TARGET_LIST)) +TARGET_LIST_CUS = $(TARGET_CUS_B) $(TARGET_CUS_K) +TARGET_LIST_GEN = $(TARGET_GEN_B) $(TARGET_GEN_K) +TARGET_LIST_TST = $(TARGET_TST_B) $(TARGET_TST_K) +TARGET_LIST_U64 = $(TARGET_U64_B) $(TARGET_U64_K) + +TARGET_LIST = build/chargen.rom \ + $(TARGET_LIST_CUS) \ + $(TARGET_LIST_GEN) \ + $(TARGET_LIST_TST) \ + $(TARGET_M65_x) \ + $(TARGET_LIST_U64) \ + $(TARGET_X16_x) + +SEG_LIST_M65 = $(DIR_M65)/basic.seg_0 \ + $(DIR_M65)/basic.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 + +REL_TARGET_LIST = $(TARGET_LIST_GEN) $(TARGET_LIST_TST) $(TARGET_M65_x) $(TARGET_LIST_U64) # Misc strings @@ -87,31 +139,31 @@ GIT_COMMIT:= $(shell git log -1 --pretty='%h' | tr '[:lower:]' '[:upper:]') .PHONY: all clean updatebin all: - $(MAKE) -j64 --output-sync=target $(STD_TARGET_LIST) $(EXT_TARGET_LIST) + $(MAKE) -j64 --output-sync=target $(TARGET_LIST) $(EXT_TARGET_LIST) clean: @rm -rf build c64/basic/combined.s c64/kernal/combined.s updatebin: - $(MAKE) -j64 --output-sync=target $(STD_TARGET_LIST) $(EXT_TARGET_LIST) $(TOOL_RELEASE) - $(TOOL_RELEASE) -i ./build -o ./bin basic_generic.rom kernal_generic.rom basic_testing.rom kernal_testing.rom basic_ultimate64.rom kernal_ultimate64.rom mega65.rom + $(MAKE) -j64 --output-sync=target $(TARGET_LIST) $(TOOL_RELEASE) + $(TOOL_RELEASE) -i ./build -o ./bin $(patsubst build/%,%,$(REL_TARGET_LIST)) cp build/chargen.rom bin/chargen.rom # Rules - tools -$(TOOL_PNGPREPARE): src/pngprepare.c +$(TOOL_PNGPREPARE): tools/pngprepare.c @mkdir -p build/tools $(CC) -O2 -Wall -I/usr/local/include -L/usr/local/lib -o $@ $< -lpng -$(TOOL_COMPRESS_TEXT): src/compress_text.c +$(TOOL_COMPRESS_TEXT): tools/compress_text.c @mkdir -p build/tools $(CC) -O2 -Wall -I/usr/local/include -L/usr/local/lib -o $@ $< -lm -build/tools/%: src/%.c +build/tools/%: tools/%.c @mkdir -p build/tools $(CC) -O2 -Wall -o $@ $< -build/tools/%: src/%.cc src/common.h +build/tools/%: tools/%.cc tools/common.h @mkdir -p build/tools $(CXX) -O2 -Wall -o $@ $< @@ -122,157 +174,208 @@ build/chargen.rom: $(TOOL_PNGPREPARE) assets/8x8font.png # Dependencies - BASIC and KERNAL -build/target_custom/OUTB.BIN build/target_custom/BASIC_combined.vs: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC) \ - c64/,,config_custom.s build/target_custom/KERNAL_combined.sym \ - $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) -build/target_generic/OUTB.BIN build/target_generic/BASIC_combined.vs: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC) \ - c64/,,config_generic.s build/target_generic/KERNAL_combined.sym \ - $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) -build/target_testing/OUTB.BIN build/target_testing/BASIC_combined.vs: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC) \ - c64/,,config_testing.s build/target_testing/KERNAL_combined.sym \ - $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) -build/target_mega65/OUTB_0.BIN build/target_mega65/BASIC_0_combined.vs: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC) \ - c64/,,config_mega65.s build/target_mega65/KERNAL_0_combined.sym \ - $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) -build/target_ultimate64/OUTB.BIN build/target_ultimate64/BASIC_combined.vs: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC) \ - c64/,,config_ultimate64.s build/target_ultimate64/KERNAL_combined.sym \ - $(foreach dir,$(SRCDIR_BASIC),$(wildcard $(dir)/*.s)) +$(DIR_CUS)/OUTB_x.BIN $(DIR_CUS)/BASIC_combined.vs: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_CUS) $(DIR_CUS)/KERNAL_combined.sym +$(DIR_GEN)/OUTB_x.BIN $(DIR_GEN)/BASIC_combined.vs: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_GEN) $(DIR_GEN)/KERNAL_combined.sym +$(DIR_TST)/OUTB_x.BIN $(DIR_TST)/BASIC_combined.vs: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_TST) $(DIR_TST)/KERNAL_combined.sym +$(DIR_U64)/OUTB_x.BIN $(DIR_U64)/BASIC_combined.vs: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_U64) $(DIR_U64)/KERNAL_combined.sym -build/target_custom/OUTK.BIN build/target_custom/KERNAL_combined.vs build/target_custom/KERNAL_combined.sym: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL) \ - c64/,,config_custom.s \ - $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) -build/target_generic/OUTK.BIN build/target_generic/KERNAL_combined.vs build/target_generic/KERNAL_combined.sym: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL) \ - c64/,,config_generic.s \ - $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) -build/target_testing/OUTK.BIN build/target_testing/KERNAL_combined.vs build/target_testing/KERNAL_combined.sym: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL) \ - c64/,,config_testing.s \ - $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) -build/target_mega65/OUTK_0.BIN build/target_mega65/KERNAL_0_combined.vs build/target_mega65/KERNAL_0_combined.sym: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL) \ - c64/,,config_mega65.s \ - $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) -build/target_ultimate64/OUTK.BIN build/target_ultimate64/KERNAL_combined.vs build/target_ultimate64/KERNAL_combined.sym: \ - $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL) \ - c64/,,config_ultimate64.s \ - $(foreach dir,$(SRCDIR_KERNAL),$(wildcard $(dir)/*.s)) +$(DIR_CUS)/OUTK_x.BIN $(DIR_CUS)/KERNAL_combined.vs $(DIR_CUS)/KERNAL_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_CUS) +$(DIR_GEN)/OUTK_x.BIN $(DIR_GEN)/KERNAL_combined.vs $(DIR_GEN)/KERNAL_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_GEN) +$(DIR_TST)/OUTK_x.BIN $(DIR_TST)/KERNAL_combined.vs $(DIR_TST)/KERNAL_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_TST) +$(DIR_U64)/OUTK_x.BIN $(DIR_U64)/KERNAL_combined.vs $(DIR_U64)/KERNAL_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_U64) -build/target_custom/newrom: build/target_custom/OUTB.BIN build/target_custom/OUTK.BIN -build/target_generic/newrom: build/target_generic/OUTB.BIN build/target_generic/OUTK.BIN -build/target_testing/newrom: build/target_testing/OUTB.BIN build/target_testing/OUTK.BIN -build/target_mega65/newrom_0: build/target_mega65/OUTB_0.BIN build/target_mega65/OUTK_0.BIN -build/target_ultimate64/newrom: build/target_ultimate64/OUTB.BIN build/target_ultimate64/OUTK.BIN +$(DIR_M65)/OUTB_0.BIN $(DIR_M65)/BASIC_0_combined.vs $(DIR_M65)/BASIC_0_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_M65) $(DIR_M65)/KERNAL_0_combined.sym +$(DIR_M65)/OUTK_0.BIN $(DIR_M65)/KERNAL_0_combined.vs $(DIR_M65)/KERNAL_0_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_M65) -build/kernal_custom.rom: build/target_custom/newrom -build/kernal_generic.rom: build/target_generic/newrom -build/kernal_testing.rom: build/target_testing/newrom -build/kernal_mega65.rom_0: build/target_mega65/newrom_0 -build/kernal_ultimate64.rom: build/target_ultimate64/newrom +$(DIR_X16)/OUTB_0.BIN $(DIR_X16)/BASIC_0_combined.vs $(DIR_X16)/BASIC_0_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_X16) $(DIR_X16)/KERNAL_0_combined.sym +$(DIR_X16)/OUTK_0.BIN $(DIR_X16)/KERNAL_0_combined.vs $(DIR_X16)/KERNAL_0_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_X16) -build/basic_custom.rom: build/target_custom/newrom -build/basic_generic.rom: build/target_generic/newrom -build/basic_testing.rom: build/target_testing/newrom -build/basic_mega65.rom_0: build/target_mega65/newrom_0 -build/basic_ultimate64.rom: build/target_ultimate64/newrom +$(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1_combined.vs $(DIR_M65)/BASIC_1_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_M65) $(DIR_M65)/KERNAL_0_combined.sym $(DIR_M65)/BASIC_0_combined.sym +$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_M65) $(DIR_M65)/KERNAL_0_combined.sym -build/symbols_custom.vs: build/target_custom/BASIC_combined.vs build/target_custom/KERNAL_combined.vs -build/symbols_generic.vs: build/target_generic/BASIC_combined.vs build/target_generic/KERNAL_combined.vs -build/symbols_testing.vs: build/target_testing/BASIC_combined.vs build/target_testing/KERNAL_combined.vs -build/symbols_mega65_0.vs: build/target_mega65/BASIC_0_combined.vs build/target_mega65/KERNAL_0_combined.vs -build/symbols_ultimate64.vs: build/target_ultimate64/BASIC_combined.vs build/target_ultimate64/KERNAL_combined.vs +$(DIR_X16)/basic.seg_1 $(DIR_X16)/BASIC_1_combined.vs $(DIR_X16)/BASIC_1_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_BASIC) $(CFG_X16) $(DIR_M65)/KERNAL_0_combined.sym $(DIR_X16)/BASIC_0_combined.sym +$(DIR_X16)/kernal.seg_1 $(DIR_X16)/KERNAL_1_combined.vs $(DIR_X16)/KERNAL_1_combined.sym: \ + $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(DEP_KERNAL) $(CFG_X16) $(DIR_X16)/KERNAL_0_combined.sym -# Rules - BASIC and KERNAL +$(DIR_CUS)/OUTx_x.BIN: $(DIR_CUS)/OUTB_x.BIN $(DIR_CUS)/OUTK_x.BIN +$(DIR_GEN)/OUTx_x.BIN: $(DIR_GEN)/OUTB_x.BIN $(DIR_GEN)/OUTK_x.BIN +$(DIR_TST)/OUTx_x.BIN: $(DIR_TST)/OUTB_x.BIN $(DIR_TST)/OUTK_x.BIN +$(DIR_M65)/OUTx_0.BIN: $(DIR_M65)/OUTB_0.BIN $(DIR_M65)/OUTK_0.BIN +$(DIR_U64)/OUTx_x.BIN: $(DIR_U64)/OUTB_x.BIN $(DIR_U64)/OUTK_x.BIN +$(DIR_X16)/OUTx_0.BIN: $(DIR_X16)/OUTB_0.BIN $(DIR_X16)/OUTK_0.BIN + +$(TARGET_CUS_B): $(DIR_CUS)/OUTx_x.BIN +$(TARGET_GEN_B): $(DIR_GEN)/OUTx_x.BIN +$(TARGET_TST_B): $(DIR_TST)/OUTx_x.BIN +$(TARGET_U64_B): $(DIR_U64)/OUTx_x.BIN + +$(TARGET_CUS_K): $(DIR_CUS)/OUTx_x.BIN +$(TARGET_GEN_K): $(DIR_GEN)/OUTx_x.BIN +$(TARGET_TST_K): $(DIR_TST)/OUTx_x.BIN +$(TARGET_U64_K): $(DIR_U64)/OUTx_x.BIN + +build/symbols_custom.vs: $(DIR_CUS)/BASIC_combined.vs $(DIR_CUS)/KERNAL_combined.vs +build/symbols_generic.vs: $(DIR_GEN)/BASIC_combined.vs $(DIR_GEN)/KERNAL_combined.vs +build/symbols_testing.vs: $(DIR_TST)/BASIC_combined.vs $(DIR_TST)/KERNAL_combined.vs +build/symbols_ultimate64.vs: $(DIR_U64)/BASIC_combined.vs $(DIR_U64)/KERNAL_combined.vs + +# Rules - BASIC and KERNAL intermediate files build/,generated/packed_messages.s: $(TOOL_COMPRESS_TEXT) @mkdir -p build/,generated $(TOOL_COMPRESS_TEXT) > build/,generated/packed_messages.s -.PRECIOUS: build/target_%/OUTB.BIN build/target_%/BASIC_combined.vs -build/target_%/OUTB.BIN build/target_%/BASIC_combined.vs: +build/,generated/float_constants.s: $(TOOL_GENERATE_CONSTANTS) + @mkdir -p build/,generated + $(TOOL_GENERATE_CONSTANTS) -o build/,generated/float_constants.s + +.PRECIOUS: build/target_%/OUTB_x.BIN build/target_%/BASIC_combined.vs +build/target_%/OUTB_x.BIN build/target_%/BASIC_combined.vs: @mkdir -p build/target_$* @rm -f $@* build/target_$*/BASIC* - @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r STD -s BASIC -i BASIC-$* -o OUTB.BIN -d build/target_$* -l a000 -h e4d2 c64/,,config_$*.s $(SRCDIR_BASIC) $(GEN_BASIC) + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r STD -s BASIC -i BASIC-$* -o OUTB_x.BIN -d build/target_$* -l a000 -h e4d2 c64/,,config_$*.s $(SRCDIR_BASIC) $(GEN_BASIC) -.PRECIOUS: build/target_%/OUTK.BIN build/target_%/KERNAL_combined.vs build/target_%/KERNAL_combined.sym -build/target_%/OUTK.BIN build/target_%/KERNAL_combined.vs build/target_%/KERNAL_combined.sym: +.PRECIOUS: build/target_%/OUTK_x.BIN build/target_%/KERNAL_combined.vs build/target_%/KERNAL_combined.sym +build/target_%/OUTK_x.BIN build/target_%/KERNAL_combined.vs build/target_%/KERNAL_combined.sym: @mkdir -p build/target_$* @rm -f $@* build/target_$*/KERNAL* - @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r STD -s KERNAL -i KERNAL-$* -o OUTK.BIN -d build/target_$* -l e4d3 -h ffff c64/,,config_$*.s $(SRCDIR_KERNAL) $(GEN_KERNAL) + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r STD -s KERNAL -i KERNAL-$* -o OUTK_x.BIN -d build/target_$* -l e4d3 -h ffff c64/,,config_$*.s $(SRCDIR_KERNAL) $(GEN_KERNAL) -build/target_mega65/OUTB_0.BIN build/target_mega65/BASIC_0_combined.vs: - @mkdir -p build/target_mega65 - @rm -f $@* build/target_mega65/BASIC_0* - @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s BASIC_0 -i BASIC_0-mega65 -o OUTB_0.BIN -d build/target_mega65 -l a000 -h e4d2 c64/,,config_mega65.s $(SRCDIR_BASIC) $(GEN_BASIC) +# Rules - BASIC and KERNAL intermediate files, for Mega65 -build/target_mega65/OUTK_0.BIN build/target_mega65/KERNAL_0_combined.vs build/target_mega65/KERNAL_0_combined.sym: - @mkdir -p build/target_mega65 - @rm -f $@* build/target_mega65/KERNAL_0* - @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s KERNAL_0 -i KERNAL_0-mega65 -o OUTK_0.BIN -d build/target_mega65 -l e4d3 -h ffff c64/,,config_mega65.s $(SRCDIR_KERNAL) $(GEN_KERNAL) +$(DIR_M65)/OUTB_0.BIN $(DIR_M65)/BASIC_0_combined.vs $(DIR_M65)/BASIC_0_combined.sym: + @mkdir -p $(DIR_M65) + @rm -f $@* $(DIR_M65)/BASIC_0* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s BASIC_0 -i BASIC_0-mega65 -o OUTB_0.BIN -d $(DIR_M65) -l a000 -h e4d2 $(CFG_M65) $(SRCDIR_BASIC) $(GEN_BASIC) -build/target_mega65/kernal.seg_1 build/target_mega65/KERNAL_1_combined.vs build/target_mega65/KERNAL_1_combined.sym: $(TOOL_BUILD_SEGMENT) - @mkdir -p build/target_mega65 - @rm -f $@* build/target_mega65/kernal.seg_1 build/target_mega65/KERNAL_1* - @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s KERNAL_1 -i KERNAL_1-mega65 -o kernal.seg_1 -d build/target_mega65 -l 4000 -h 5fff c64/,,config_mega65.s $(SRCDIR_KERNAL) $(GEN_KERNAL) +$(DIR_M65)/OUTK_0.BIN $(DIR_M65)/KERNAL_0_combined.vs $(DIR_M65)/KERNAL_0_combined.sym: + @mkdir -p $(DIR_M65) + @rm -f $@* $(DIR_M65)/KERNAL_0* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s KERNAL_0 -i KERNAL_0-mega65 -o OUTK_0.BIN -d $(DIR_M65) -l e4d3 -h ffff $(CFG_M65) $(SRCDIR_KERNAL) $(GEN_KERNAL) -.PRECIOUS: build/target_%/newrom -build/target_%/newrom: - cat build/target_$*/OUTB.BIN build/target_$*/OUTK.BIN > $@ +$(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1_combined.vs $(DIR_M65)/BASIC_1_combined.sym: + @mkdir -p $(DIR_M65) + @rm -f $@* $(DIR_M65)/basic.seg_1 $(DIR_M65)/BASIC_1* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s BASIC_1 -i BASIC_1-mega65 -o basic.seg_1 -d $(DIR_M65) -l 4000 -h 5fff $(CFG_M65) $(SRCDIR_BASIC) $(GEN_BASIC) + +$(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1_combined.vs $(DIR_M65)/KERNAL_1_combined.sym: + @mkdir -p $(DIR_M65) + @rm -f $@* $(DIR_M65)/kernal.seg_1 $(DIR_M65)/KERNAL_1* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r M65 -s KERNAL_1 -i KERNAL_1-mega65 -o kernal.seg_1 -d $(DIR_M65) -l 4000 -h 5fff $(CFG_M65) $(SRCDIR_KERNAL) $(GEN_KERNAL) + +# Rules - BASIC and KERNAL intermediate files, for Commander X16 + +$(DIR_X16)/OUTB_0.BIN $(DIR_X16)/BASIC_0_combined.vs $(DIR_X16)/BASIC_0_combined.sym: + @mkdir -p $(DIR_X16) + @rm -f $@* $(DIR_X16)/BASIC_0* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r X16 -s BASIC_0 -i BASIC_0-mega65 -o OUTB_0.BIN -d $(DIR_X16) -l c000 -h e4d2 $(CFG_X16) $(SRCDIR_BASIC) $(GEN_BASIC) + +$(DIR_X16)/OUTK_0.BIN $(DIR_X16)/KERNAL_0_combined.vs $(DIR_X16)/KERNAL_0_combined.sym: + @mkdir -p $(DIR_X16) + @rm -f $@* $(DIR_X16)/KERNAL_0* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r X16 -s KERNAL_0 -i KERNAL_0-mega65 -o OUTK_0.BIN -d $(DIR_X16) -l e4d3 -h ffff $(CFG_X16) $(SRCDIR_KERNAL) $(GEN_KERNAL) + +$(DIR_X16)/basic.seg_1 $(DIR_X16)/BASIC_1_combined.vs $(DIR_X16)/BASIC_1_combined.sym: + @mkdir -p $(DIR_X16) + @rm -f $@* $(DIR_X16)/basic.seg_1 $(DIR_X16)/BASIC_1* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r X16 -s BASIC_1 -i BASIC_1-mega65 -o basic.seg_1 -d $(DIR_X16) -l a000 -h bfff $(CFG_X16) $(SRCDIR_BASIC) $(GEN_BASIC) + +$(DIR_X16)/kernal.seg_1 $(DIR_X16)/KERNAL_1_combined.vs $(DIR_X16)/KERNAL_1_combined.sym: + @mkdir -p $(DIR_X16) + @rm -f $@* $(DIR_X16)/kernal.seg_1 $(DIR_X16)/KERNAL_1* + @$(TOOL_BUILD_SEGMENT) -a ../../$(TOOL_ASSEMBLER) -r X16 -s KERNAL_1 -i KERNAL_1-mega65 -o kernal.seg_1 -d $(DIR_X16) -l a000 -h bfff $(CFG_X16) $(SRCDIR_KERNAL) $(GEN_KERNAL) + +# Rules - BASIC and KERNAL + +.PRECIOUS: build/target_%/OUTx_x.BIN +build/target_%/OUTx_x.BIN: + cat build/target_$*/OUTB_x.BIN build/target_$*/OUTK_x.BIN > $@ .PRECIOUS: build/kernal_%.rom build/kernal_%.rom: - dd if=build/target_$*/newrom bs=8192 count=1 skip=2 of=$@ + dd if=build/target_$*/OUTx_x.BIN bs=8192 count=1 skip=2 of=$@ .PRECIOUS: build/basic_%.rom build/basic_%.rom: - dd if=build/target_$*/newrom bs=8192 count=1 skip=0 of=$@ + dd if=build/target_$*/OUTx_x.BIN bs=8192 count=1 skip=0 of=$@ .PRECIOUS: build/symbols_%.vs build/symbols_%.vs: sort build/target_$*/BASIC_combined.vs build/target_$*/KERNAL_combined.vs | uniq | grep -v "__" > $@ -build/target_mega65/newrom_0: - cat build/target_mega65/OUTB_0.BIN build/target_mega65/OUTK_0.BIN > $@ +$(DIR_M65)/OUTx_0.BIN: + cat $(DIR_M65)/OUTB_0.BIN $(DIR_M65)/OUTK_0.BIN > $@ -build/kernal_mega65.rom_0: - dd if=build/target_mega65/newrom_0 bs=8192 count=1 skip=2 of=$@ +$(DIR_M65)/kernal.seg_0: $(DIR_M65)/OUTx_0.BIN + dd if=$(DIR_M65)/OUTx_0.BIN bs=8192 count=1 skip=2 of=$@ -build/basic_mega65.rom_0: - dd if=build/target_mega65/newrom_0 bs=8192 count=1 skip=0 of=$@ +$(DIR_M65)/basic.seg_0: $(DIR_M65)/OUTx_0.BIN + dd if=$(DIR_M65)/OUTx_0.BIN bs=8192 count=1 skip=0 of=$@ -build/kernal_hybrid.rom: kernal build/target_generic/OUTK.BIN +$(DIR_X16)/OUTx_0.BIN: + cat $(DIR_X16)/OUTB_0.BIN $(DIR_X16)/OUTK_0.BIN > $@ + +$(DIR_X16)/kernal.seg_0: $(DIR_X16)/OUTx_0.BIN + dd if=$(DIR_X16)/OUTx_0.BIN bs=8192 count=1 skip=1 of=$@ + +$(DIR_X16)/basic.seg_0: $(DIR_X16)/OUTx_0.BIN + dd if=$(DIR_X16)/OUTx_0.BIN bs=8192 count=1 skip=0 of=$@ + +build/kernal_hybrid.rom: kernal $(DIR_GEN)/OUTK_x.BIN @echo @echo $(HYBRID_WARNING) @echo (dd if=kernal bs=1140 count=1 skip=0 ; \ echo " > HYBRID ROM, DON'T DISTRIBUTE <" ; \ dd if=kernal bs=1 count=58 skip=1176 ; \ - cat build/target_generic/OUTK.BIN) > $@ + cat $(DIR_GEN)/OUTK_x.BIN) > $@ -build/symbols_hybrid.vs: build/target_generic/KERNAL_combined.vs - sort build/target_generic/KERNAL_combined.vs | uniq | grep -v "__" > $@ +build/symbols_hybrid.vs: $(DIR_GEN)/KERNAL_combined.vs + sort $(DIR_GEN)/KERNAL_combined.vs | uniq | grep -v "__" > $@ -# Rules - platform 'Mega 65' specific +# Rules - platform 'Mega65' specific -build/mega65.rom: build/kernal_mega65.rom_0 build/target_mega65/kernal.seg_1 build/basic_mega65.rom_0 build/chargen.rom - dd if=/dev/zero bs=8192 count=1 of=build/padding_8k - dd if=/dev/zero bs=8192 count=8 of=build/padding_64k - cat build/padding_8k > build/mega65.rom - cat build/padding_8k >> build/mega65.rom - cat build/target_mega65/kernal.seg_1 >> build/mega65.rom - cat build/padding_8k >> build/mega65.rom - cat build/padding_8k >> build/mega65.rom - cat build/basic_mega65.rom_0 >> build/mega65.rom - cat build/chargen.rom build/chargen.rom >> build/mega65.rom - cat build/kernal_mega65.rom_0 >> build/mega65.rom - cat build/padding_64k >> build/mega65.rom - rm -f build/padding* +$(TARGET_M65_x): $(SEG_LIST_M65) build/chargen.rom + dd if=/dev/zero bs=8192 count=1 of=build/m65_padding_08_KB + dd if=/dev/zero bs=8192 count=8 of=build/m65_padding_64_KB + cat build/m65_padding_08_KB > $(TARGET_M65_x) + cat build/m65_padding_08_KB >> $(TARGET_M65_x) + cat $(DIR_M65)/kernal.seg_1 >> $(TARGET_M65_x) + cat $(DIR_M65)/basic.seg_1 >> $(TARGET_M65_x) + cat build/m65_padding_08_KB >> $(TARGET_M65_x) + cat $(DIR_M65)/basic.seg_0 >> $(TARGET_M65_x) + cat build/chargen.rom >> $(TARGET_M65_x) + cat build/chargen.rom >> $(TARGET_M65_x) + cat $(DIR_M65)/kernal.seg_0 >> $(TARGET_M65_x) + cat build/m65_padding_64_KB >> $(TARGET_M65_x) + rm -f build/m65_padding_* + +# Rules - platform 'Commander X16' specific + +$(TARGET_X16_x): $(SEG_LIST_X16) build/chargen.rom + dd if=/dev/zero bs=8192 count=1 of=build/x16_padding_08_KB + dd if=/dev/zero bs=8192 count=8 of=build/x16_padding_64_KB + cat $(DIR_X16)/basic.seg_0 > $(TARGET_X16_x) + cat $(DIR_X16)/kernal.seg_0 >> $(TARGET_X16_x) + cat build/chargen.rom >> $(TARGET_X16_x) + cat $(DIR_X16)/basic.seg_1 >> $(TARGET_X16_x) + cat $(DIR_X16)/kernal.seg_1 >> $(TARGET_X16_x) + rm -f build/x16_padding_* # Rules - tests @@ -295,12 +398,15 @@ test_generic_x128: build/kernal_generic.rom build/basic_generic.rom build/symbol test_testing: build/kernal_testing.rom build/basic_testing.rom build/symbols_testing.vs x64 -kernal build/kernal_testing.rom -basic build/basic_testing.rom -moncommands build/symbols_testing.vs -1 $(TESTTAPE) -8 $(TESTDISK) -test_mega65: build/mega65.rom - ../xemu/build/bin/xmega65.native -dmarev 2 -forcerom -loadrom build/mega65.rom - test_ultimate64: build/kernal_ultimate64.rom build/basic_ultimate64.rom build/symbols_ultimate64.vs x64 -kernal build/kernal_ultimate64.rom -basic build/basic_ultimate64.rom -moncommands build/symbols_ultimate64.vs -1 $(TESTTAPE) -8 $(TESTDISK) +test_mega65: $(TARGET_M65_x) + ../xemu/build/bin/xmega65.native -dmarev 2 -forcerom -loadrom $(TARGET_M65_x) + +test_cx16: $(TARGET_X16_x) + ../x16-emulator/x16emu -rom $(TARGET_X16_x) + test_hybrid: build/kernal_hybrid.rom build/symbols_hybrid.vs @echo @echo $(HYBRID_WARNING) @@ -316,6 +422,6 @@ test_m65: build/mega65.rom testremote: build/kernal_custom.rom build/basic_custom.rom build/symbols_custom.vs x64 -kernal build/kernal_custom.rom -basic build/basic_custom.rom -moncommands build/symbols_custom.vs -remotemonitor -testsimilarity: build/target_generic/newrom $(TOOL_SIMILARITY) kernal basic - $(TOOL_SIMILARITY) kernal build/target_generic/newrom - $(TOOL_SIMILARITY) basic build/target_generic/newrom +testsimilarity: $(TOOL_SIMILARITY) $(DIR_GEN)/OUTx_x.BIN kernal basic + $(TOOL_SIMILARITY) kernal $(DIR_GEN)/OUTx_x.BIN + $(TOOL_SIMILARITY) basic $(DIR_GEN)/OUTx_x.BIN diff --git a/README.md b/README.md index 9a966ccb..4f8186b0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ A project to create unencumbered open-source ROMs for use on selected retro comp * [implementation status](./STATUS.md) of various APIs and functionalities * [configuration options](./CONFIG.md) for those willing to compile their own, customized ROM set * [development guide](./doc/Development.md) for those interested in OpenROMs technical aspects +* [license](./LICENSE) information and list of major contributors +* [credits](./CREDITS.md) to people whose work was of great help to us # Problem Statement and Motivation diff --git a/STATUS.md b/STATUS.md index 80eed824..10c217d9 100644 --- a/STATUS.md +++ b/STATUS.md @@ -12,7 +12,9 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * DOS wedge (direct mode only) - `@`, `@`, `@$`, `@$`, `@` * turbo tape load support (as device 7, or using `←L`), quite sophisticated: up to 250 blocks (can store bytes under I/O), automatically adjusts for tape speed differences -* improved support for tape adapters (for using regular casette players and other audio devices instead of Datasette) +* normal tape load error log is limited by free stack space only (no artificial limitation like in original ROMs) +* tape format autodetection; normal vs turbo is mostly transparent to user +* improved support for tape adapters (for using regular casette players and other audio devices instead of Datasette) and emulators * extended `LOAD` command * start/end addresses are displayed, in the Final cartridge style @@ -48,29 +50,41 @@ The following ROM features are currently missing: ## Keyboard +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | | C64 | DONE | | | C128 | DONE | | | Mega65 | NOT DONE | code should be complete, but is not tested yet | +
+ ## Screen +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | | VIC-II | DONE | | | 80 columns, VDC | NOT DONE | | | 80 columns, Mega65 | NOT DONE | | +
+ ## Tape port (LOAD only!) * Tapuino * Datasette +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | -| normal | PARTIAL | no tape speed calibratrion, no error correction | -| turbo (250 blocks) | DONE | | +| normal | DONE | up to 202 blocks, like original ROM | +| turbo | DONE | up to 250 blocks, like the best implementations | + +
## IEC bus @@ -79,6 +93,8 @@ The following ROM features are currently missing: * most disk drives and printers * some hard drives +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | | standard | DONE | | @@ -87,27 +103,36 @@ The following ROM features are currently missing: | CIA burst mod | NOT DONE | | | Mega65 burst | NOT DONE | | +
+ ## IEEE-488 bus * petSD+ * PET era disk drives and printers * various scientific equipment +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | | CBM cartridge | NOT DONE | | +
+ ## RS-232 * modems (telephone, WiFi) * parallel port printers +
+ | Driver | Status | Remarks | | :----------------: | :------: | :------------------------------------------------: | | UP2400 | NOT DONE | | | UP9600 | NOT DONE | work started, not functional yet | | ACIA 6551 | NOT DONE | | +
# API status @@ -142,7 +167,107 @@ For the current status of the low memory location implementation andd usage chec
-### Unofficial BASIC routines/locations + +### Math package + +Floating point mathematical routines - not official, but well known and broadly used. Note: there is an awful mess regarding naming (sometimes same name references different routines in different sources), so a custom naming scheme was applied. + +
+ +| Address | Name | Status | Remarks | +| :-------: | :--------------------- | :------: | :------------------------------------------------: | +| `$A9C4` | `convert_FAC1_to_INT` | NOT DONE | | +| `$AABC` | `print_FAC1` | NOT DONE | | +| `$AF7B` | `compute_TI` | NOT DONE | | +| `$AF7E` | not named yet | NOT DONE | | +| `$AF87` | not named yet | NOT DONE | | +| `$AF9A` | `compute_ST` | NOT DONE | | +| `$B1AA` | `FACINX` | NOT DONE | convert FAC1 to 16-bit signed integer | +| `$B1BF` | `convert_FAC1_to_s16` | NOT DONE | | +| `$B391` | `GIVAYF` | NOT DONE | 16-bit signed integer to FAC1 | +| `$B3A2` | `convert_Y_to_FAC1` | NOT DONE | | +| `$B794` | `convert_A_to_FAC1` | NOT DONE | | +| `$B7B5` | `STRVAL` | NOT DONE | imports string to FAC1 | +| `$B7F7` | `convert_FAC1_to_ADDR` | NOT DONE | | +| `$B849` | `add_HALF_FAC1` | NOT DONE | | +| `$B850` | `sub_MEM_FAC1` | DONE | | +| `$B853` | `sub_FAC2_FAC1` | DONE | | +| `$B862` | `add_align_exponents` | DONE | | +| `$B867` | `add_MEM_FAC1` | DONE | | +| `$B86A` | `add_FAC2_FAC1` | DONE | | +| `$B8FE` | `normal_FAC1` | DONE | | +| `$B947` | `inv_FAC1_mantissa` | NOT DONE | | +| `$B983` | `MULSHF` | NOT DONE | | +| `$B9EA` | `log_FAC1` | NOT DONE | | +| `$BA28` | `mul_MEM_FAC1` | PARTIAL | needs `mul_FAC2_FAC1` | +| `$BA2B` | `mul_FAC2_FAC1` | NOT DONE | some work started | +| `$BA59` | `MLTPLY` | NOT DONE | | +| `$BA8C` | `mov_MEM_FAC2` | DONE | | +| `$BA90` | `get_FAC2_via_INDEX` | NOT DONE | | +| `$BAE2` | `mul10_FAC1` | NOT DONE | | +| `$BAFE` | `div10_FAC1_p` | NOT DONE | | +| `$BB0F` | `div_MEM_FAC1` | PARTIAL | needs `div_FAC2_FAC1` | +| `$BB12` | `div_FAC2_FAC1` | NOT DONE | | +| `$BBA2` | `mov_MEM_FAC1` | DONE | | +| `$BBA6` | `get_FAC2_via_INDEX` | NOT DONE | | +| `$BBC7` | `mov_r_FAC1_TMP2` | PARTIAL | not fully tested yet | +| `$BBCA` | `mov_r_FAC1_TMP1` | PARTIAL | not fully tested yet | +| `$BBD0` | `mov_r_FAC1_VAR` | PARTIAL | not fully tested yet | +| `$BBD4` | `mov_r_FAC1_MEM` | PARTIAL | not fully tested yet | +| `$BBFC` | `mov_FAC2_FAC1` | PARTIAL | not fully tested yet | +| `$BC0C` | `mov_r_FAC1_FAC2` | PARTIAL | not fully tested yet | +| `$BC0F` | `mov_FAC1_FAC2` | DONE | | +| `$BC1B` | `round_FAC1` | PARTIAL | not fully tested yet | +| `$BC2B` | `sgn_FAC1_A` | NOT DONE | | +| `$BC39` | `sgn_FAC1` | NOT DONE | | +| `$BC3C` | `convert_A_to_FAC1` | NOT DONE | | +| `$BC44` | `convert_i16_to_FAC1` | NOT DONE | | +| `$BC58` | `abs_FAC1` | NOT DONE | | +| `$BC5B` | `FCOMP` | NOT DONE | compare FAC1 with RAM location | +| `$BC9B` | `QINT` | NOT DONE | convert FAC1 to 32 bit signed integer | +| `$BCCC` | `int_FAC1` | NOT DONE | | +| `$BCF3` | `FIN` | NOT DONE | imports string to FAC1, ignores spaces | +| `$BD7E` | `FINLOG` | NOT DONE | | +| `$BDDD` | `FOUT` | NOT DONE | outputs FAC1 to string at $0100 | +| `$BF71` | `sqr_FAC1` | NOT DONE | | +| `$BF74` | `sqr_FAC2` | NOT DONE | | +| `$BF78` | `FPWR` | NOT DONE | set FAC1 as RAM raised to the power of FAC1 | +| `$BF7B` | `FPWRT` | NOT DONE | set FAC1 as FAC2 raised to the power of FAC1 | +| `$BFB4` | `toggle_sign_FAC1` | DONE | | +| `$BFED` | `exp_FAC1` | NOT DONE | | +| `$E043` | `poly1_FAC1` | NOT DONE | | +| `$E059` | `poly2_FAC1` | NOT DONE | | +| `$E097` | `rnd_FAC1` | PARTIAL | requires `sgn_FAC1_A` | +| `$E09A` | `rnd_A` | DONE | | +| `$E0BE` | `rnd_generate` | DONE | | +| `$E264` | `cos_FAC1` | NOT DONE | | +| `$E26B` | `sin_FAC1` | NOT DONE | | +| `$E2B4` | `tan_FAC1` | NOT DONE | | +| `$E30E` | `atn_FAC1` | NOT DONE | | + +
+ +In addition to the routines, the following floating-number constants are available at their original locations: + +| Address | Name | Status | Remarks | +| :-------: | :-------------------------- | :------: | :-------------------------------------------: | +| `$AEA8` | `const_PI` | DONE | π | +| `$B1A5` | `const_NEG_32768` | DONE | -32768 | +| `$B9BC` | `const_ONE` | DONE | 1.0 | +| `$B9D6` | `const_INV_SQR_2` | DONE | 1.0 / sqr(2.0) | +| `$B9DB` | `const_SQR_2` | DONE | sqr(2.0) | +| `$B9E0` | `const_NEG_HALF` | DONE | -0.5 | +| `$B9E5` | `const_LOG_2` | DONE | log_e(2.0) | +| `$BAF9` | `const_TEN` | DONE | 10.0 | +| `$BF11` | `const_HALF` | DONE | 0.5 | +| `$BFBF` | `const_INV_LOG_2` | DONE | 1.0 / log_e(2.0) | +| `$BFE8` | `const_ONE` duplicate | DONE | 1.0 | +| `$E2E0` | `const_HALF_PI` | DONE | PI / 2.0 | +| `$E2E5` | `const_DOUBLE_PI` | DONE | PI * 2.0 | +| `$E2EA` | `const_QUARTER` | DONE | 0.25 | +| `$E309` | `const_DOUBLE_PI` duplicate | DONE | PI * 2.0 | + +### Other unofficial BASIC routines/locations Not all of them - only these we want to have implemented. @@ -151,19 +276,19 @@ Not all of them - only these we want to have implemented. | Address | Name | Status | Remarks | | :-------: | :----------- | :------: | :------------------------------------------------: | | `$A004` | revision str | DONE | | -| `$A408` | REASON | NOT DONE | | +| `$A408` | `REASON` | NOT DONE | | | `$A453` | (unknown) | NOT DONE | | -| `$A533` | LINKPRG | DONE | | +| `$A533` | `LINKPRG` | DONE | | | `$A644` | new | NOT DONE | | | `$A659` | set txt ptr | NOT DONE | | -| `$A68E` | RUNC | DONE | | -| `$A7AE` | NEWSTT | PARTIAL | redirected to RUN command | -| `$AB1E` | STROUT | DONE | | -| `$AD9E` | FRMEVL | NOT DONE | | -| `$BDCD` | LINPRT | DONE | temporary implementation | -| `$E3BF` | INIT | NOT DONE | | -| `$E422` | INITMSG | DONE | | -| `$E453` | RVECT | NOT DONE | | +| `$A68E` | `RUNC` | DONE | | +| `$A7AE` | `NEWSTT` | PARTIAL | redirected to RUN command | +| `$AB1E` | `STROUT` | DONE | | +| `$AD9E` | `FRMEVL` | NOT DONE | | +| `$BDCD` | `LINPRT` | DONE | temporary implementation | +| `$E3BF` | `INIT` | NOT DONE | | +| `$E422` | `INITMSG` | DONE | | +| `$E453` | `RVECT` | NOT DONE | |
diff --git a/assembler/KickAss.jar b/assembler/KickAss.jar index 82560fa2..3adf7b5e 100644 Binary files a/assembler/KickAss.jar and b/assembler/KickAss.jar differ diff --git a/assembler/KickAssembler.pdf b/assembler/KickAssembler.pdf index 3a68ed58..43d11e73 100644 Binary files a/assembler/KickAssembler.pdf and b/assembler/KickAssembler.pdf differ diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index e3d073ac..7828da6c 100644 Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ diff --git a/bin/basic_testing.rom b/bin/basic_testing.rom index fb950a74..6d2c34fe 100644 Binary files a/bin/basic_testing.rom and b/bin/basic_testing.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom index 6bbbab86..1fed28bd 100644 Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom index 90a888be..0df4af2e 100644 Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_testing.rom b/bin/kernal_testing.rom index 74a71589..6684bfdb 100644 Binary files a/bin/kernal_testing.rom and b/bin/kernal_testing.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index 754f75c7..df018309 100644 Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ diff --git a/bin/mega65.rom b/bin/mega65.rom index 6f99bd91..ece821ce 100644 Binary files a/bin/mega65.rom and b/bin/mega65.rom differ diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index 60fa3d47..d5983fcb 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -50,18 +50,19 @@ #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_SOFT // please keep disabled for now +// #define CONFIG_IEC_BURST_CIA1 // please keep disabled for now +// #define CONFIG_IEC_BURST_CIA2 // please keep disabled for now +// #define CONFIG_IEC_BURST_SOFT // please keep disabled for now #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT // mostly works, but not fullyy done yet! +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL +// #define CONFIG_TAPE_NO_ERROR_CORRECTION -// #define CONFIG_RS232_UP2400 // please keep disabled for now -// #define CONFIG_RS232_UP9600 // please keep disabled for now +// #define CONFIG_RS232_UP2400 // please keep disabled for now +// #define CONFIG_RS232_UP9600 // please keep disabled for now // Multiple SID support @@ -115,7 +116,7 @@ // Screen editor #define CONFIG_EDIT_STOPQUOTE -#define CONFIG_EDIT_TABULATORS +// #define CONFIG_EDIT_TABULATORS // Software features diff --git a/c64/,,config_cx16.s b/c64/,,config_cx16.s new file mode 100644 index 00000000..828f0e73 --- /dev/null +++ b/c64/,,config_cx16.s @@ -0,0 +1,136 @@ + +.const CONFIG_ID = $04 // should be 1 byte, different for each config file! +.encoding "petscii_upper" + +// +// Please read CONFIG.md before modifying this file! +// + +// Idea: +// - settings file for the Commander X16 machine + + + +// 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_MEGA_65 +// #define CONFIG_BRAND_ULTIMATE_64 + +.const CONFIG_CUSTOM_BRAND = @"FOR COMMANDER X16" + + +// 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 + + +// Memory model + +#define CONFIG_MEMORY_MODEL_38K +// #define CONFIG_MEMORY_MODEL_60K + + +// I/O devices + +// #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 +// #define CONFIG_TAPE_NO_ERROR_CORRECTION + + +// Multiple SID support + +// #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 + + +// 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 + +// #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" + + +// Screen editor + +// #define CONFIG_EDIT_STOPQUOTE +// #define CONFIG_EDIT_TABULATORS + + +// Software features + +// #define CONFIG_PANIC_SCREEN +// #define CONFIG_DOS_WEDGE +// #define CONFIG_TAPE_WEDGE +#define CONFIG_BCD_SAFE_INTERRUPTS + + +// Eye candy + +// #define CONFIG_COLORS_BRAND +// #define CONFIG_BANNER_SIMPLE +#define CONFIG_BANNER_FANCY +// #define CONFIG_BANNER_BRAND +// #define CONFIG_SHOW_FEATURES +// #define CONFIG_SHOW_PAL_NTSC + + +// Debug options + +// #define CONFIG_DBG_STUBS_BRK +// #define CONFIG_DBG_PRINTF diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 4195ef46..b74339af 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -50,8 +50,10 @@ #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL +// #define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support @@ -69,8 +71,8 @@ // Keyboard settings // #define CONFIG_LEGACY_SCNKEY -#define CONFIG_KEYBOARD_C128 -#define CONFIG_KEYBOARD_C128_CAPS_LOCK +// #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 @@ -105,7 +107,7 @@ // Screen editor #define CONFIG_EDIT_STOPQUOTE -#define CONFIG_EDIT_TABULATORS +// #define CONFIG_EDIT_TABULATORS // Software features diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index add9c08e..6bd9ee5c 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -48,10 +48,12 @@ #define CONFIG_IEC_JIFFYDOS #define CONFIG_IEC_JIFFYDOS_BLANK -// #define CONFIG_TAPE_NORMAL -// #define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_NORMAL +#define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL +// #define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index 0f7a164f..d6743178 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -50,8 +50,10 @@ // #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +// #define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL +#define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index f2927c60..9cbd6819 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -50,8 +50,10 @@ #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL +// #define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support @@ -105,7 +107,7 @@ // Screen editor #define CONFIG_EDIT_STOPQUOTE -#define CONFIG_EDIT_TABULATORS +// #define CONFIG_EDIT_TABULATORS // Software features diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index 60bbddc6..57fb1c9f 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -14,6 +14,9 @@ #if CONFIG_PLATFORM_COMMODORE_64 .eval selected++ #endif +#if CONFIG_PLATFORM_COMMANDER_X16 + .eval selected++ +#endif .if (selected != 1) .error "Please select exactly one CONFIG_PLATFORM_* option" } diff --git a/c64/aliases/,aliases_cpu.s b/c64/aliases/,aliases_cpu.s index cf99d957..b45f73f3 100644 --- a/c64/aliases/,aliases_cpu.s +++ b/c64/aliases/,aliases_cpu.s @@ -34,7 +34,7 @@ .pseudocommand panic code { // If case no panic screen is used, we can skip providing error codes within Kernal -#if CONFIG_PANIC_SCREEN || !SEGMENT_KERNAL +#if CONFIG_PANIC_SCREEN lda code #endif jmp ($E4B7) @@ -99,10 +99,33 @@ .byte $E3, arg } +// additional addressing modes + +.pseudocommand jsr_ind addr +{ + .var arg = addr.getValue() + .byte $22, mod(arg, $100), floor(arg / $100) +} + #endif +// +// Calculation shortcuts +// + +.pseudocommand lda_zero // WARNING: do not use within interrupts +{ +#if HAS_OPCODES_65CE02 + tba +#else + lda #$00 +#endif +} + + + // // Stack manipulation - some CPUs will leave .A unchanged, some will use it as temporary storage, so consider .A trashed // diff --git a/c64/aliases/,aliases_hardware_cx16.s b/c64/aliases/,aliases_hardware_cx16.s new file mode 100644 index 00000000..79bfbb4a --- /dev/null +++ b/c64/aliases/,aliases_hardware_cx16.s @@ -0,0 +1,73 @@ + +// +// Names of hardware registers +// + + +#if CONFIG_PLATFORM_COMMANDER_X16 + + // VERA registers + + .label __VERA_BASE = $9F20 // base address of the chip + + .label VERA_ADDR_LO = $9F20 + .label VERA_ADDR_MID = $9F21 + .label VERA_ADDR_HI = $9F22 + + .label VERA_DATA0 = $9F23 + .label VERA_DATA1 = $9F24 + + .label VERA_CTRL = $9F25 + + .label VERA_IEN = $9F26 + .label VERA_ISR = $9F27 + + // VIA #1 registers + + .label __VIA1_BASE = $9F60 // base address of the chip + + .label VIA1_PRB = $9F60 + .label VIA1_PRA = $9F61 + .label VIA1_DDRB = $9F62 + .label 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 + + .label VIA1_SR = $9F6A + .label VIA1_ACR = $9F6B + .label VIA1_PCR = $9F6C + .label VIA1_IFR = $9F6D + .label VIA1_IER = $9F6E + + .label VIA1_PRA_NH = $9F6F + + // VIA #2 registers + + .label __VIA2_BASE = $9F70 // base address of the chip + + .label VIA2_PRB = $9F70 + .label VIA2_PRA = $9F71 + .label VIA2_DDRB = $9F72 + .label 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 + + .label VIA2_SR = $9F7A + .label VIA2_ACR = $9F7B + .label VIA2_PCR = $9F7C + .label VIA2_IFR = $9F7D + .label VIA2_IER = $9F7E + + .label VIA2_PRA_NH = $9F7F + +#endif diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 4e6d2593..f6f9e3ac 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -1,6 +1,6 @@ // // Names of ZP and low memory locations: -// - Compute's Mapping the Commodore 64 +// - Computes Mapping the Commodore 64 // - https://www.c64-wiki.com/wiki/Zeropage // - http://unusedino.de/ec64/technical/project64/memory_maps.html // @@ -31,7 +31,7 @@ .label TEMPPT = $16 // -- NOT IMPLEMENTED -- .label LASTPT = $17 // $17-$18 -- NOT IMPLEMENTED -- .label TEMPST = $19 // $19-$21 -- NOT IMPLEMENTED -- - .label INDEX = $22 // $22-$25 -- NOT IMPLEMENTED -- temporary variables + .label INDEX = $22 // $22-$25 temporary variables, [!] our usage might be different .label RESHO = $26 // $26-$2A -- NOT IMPLEMENTED -- .label TXTTAB = $2B // $2B-$2C start of BASIC code .label VARTAB = $2D // $2D-$2E end of BASIC code, start of variables @@ -76,15 +76,15 @@ .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 -- NOT IMPLEMENTED -- + .label RNDX = $8B // $8B-$8F random number seed // // 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 // -- NOT IMPLEMENTED -- + .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 @@ -100,8 +100,8 @@ .label COLSTORE = $9C // [!] screen border storage for tape routines #endif .label MSGFLG = $9D // bit 6 = error messages, bit 7 = control message - .label PTR1 = $9E // -- NOT IMPLEMENTED -- - .label PTR2 = $9F // -- NOT IMPLEMENTED -- + .label PTR1 = $9E // for tape support, counter of errorneous bytes + .label PTR2 = $9F // for tape support, counter for errorneous bytes correction .label TIME = $A0 // $A0-$A2 jiffy clock #if !CONFIG_IEC_JIFFYDOS && !CONFIG_IEC_DOLPHINDOS && !CONFIG_IEC_BURST_CIA1 && !CONFIG_IEC_BURST_CIA2 && !CONFIG_IEC_BURST_SOFT .label TSFCNT = $A3 // temporary variable for tape and IEC, [!] our usage differs @@ -118,8 +118,8 @@ .label RIDDATA = $AA // -- NOT IMPLEMENTED -- .label RIPRTY = $AB // -- WIP -- checksum while reading tape #endif - .label SAL = $AC // $AC-$AD -- NOT IMPLEMENTED -- (implemented screen part) - .label EAL = $AE // $AE-$AF -- NOT IMPLEMENTED -- [!] used also by screen editor, for temporary color storage when scrolling + .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 @@ -145,7 +145,7 @@ .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 LXSP = $C9 // $C9-$CA start of input, X/Y position + .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 @@ -159,7 +159,7 @@ .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 LDTBL = $D9 // $D9-$F2 screen line link table, [!] our usage is different XXX give more details + .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 @@ -227,7 +227,7 @@ #if 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 doesn't crash the machine, but can be captured. + // 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 @@ -288,3 +288,27 @@ #endif // $3FC $3FC-$3FF -- UNUSED -- free for user software + + +// +// Definitions for tape functionality +// + +#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO + + .label __normal_time_S = IRQTMP+0 // duration of the short pulse + .label __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 + + .label __pulse_threshold = SVXT // pulse classification threshold + .label __pulse_threshold_ML = SYNO // M/L pulse classification threshold, for normal only + +#endif + +#if CONFIG_TAPE_TURBO + + .label __tape_turbo_bytestore = STACK // location of byte storage helper routine + +#endif diff --git a/c64/aliases/,aliases_rom_basic.s b/c64/aliases/,aliases_rom_basic.s index 67aa954d..89963b51 100644 --- a/c64/aliases/,aliases_rom_basic.s +++ b/c64/aliases/,aliases_rom_basic.s @@ -1,4 +1,15 @@ // BASIC startup vectors + + +#if ROM_LAYOUT_X16 + + .label IBASIC_COLD_START = $C000 + .label IBASIC_WARM_START = $C002 + +#else + .label IBASIC_COLD_START = $A000 .label IBASIC_WARM_START = $A002 + +#endif diff --git a/c64/aliases/,aliases_rom_cart.s b/c64/aliases/,aliases_rom_cart.s index 50decc3f..620960a7 100644 --- a/c64/aliases/,aliases_rom_cart.s +++ b/c64/aliases/,aliases_rom_cart.s @@ -1,5 +1,10 @@ +#if CONFIG_PLATFORM_COMMODORE_64 + // 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 diff --git a/c64/basic/,stubs/a408.reason.s b/c64/basic/,stubs/a408.reason.s index 8bca5016..00e36030 100644 --- a/c64/basic/,stubs/a408.reason.s +++ b/c64/basic/,stubs/a408.reason.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a453.unknown.s b/c64/basic/,stubs/a453.unknown.s index 02ae9dac..7a54c8b2 100644 --- a/c64/basic/,stubs/a453.unknown.s +++ b/c64/basic/,stubs/a453.unknown.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a483.main.s b/c64/basic/,stubs/a483.main.s index f15fd4d2..9533f2cb 100644 --- a/c64/basic/,stubs/a483.main.s +++ b/c64/basic/,stubs/a483.main.s @@ -1,4 +1,7 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_BASIC_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE // // Official BASIC routine, described in: @@ -9,9 +12,5 @@ // CPU registers that has to be preserved (see [RG64]): XXX // - MAIN: STUB_IMPLEMENTATION() - - -#endif // ROM layout diff --git a/c64/basic/,stubs/a57c.chrnch.s b/c64/basic/,stubs/a57c.chrnch.s index b5e3df12..d320dd69 100644 --- a/c64/basic/,stubs/a57c.chrnch.s +++ b/c64/basic/,stubs/a57c.chrnch.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a644.new.s b/c64/basic/,stubs/a644.new.s index 73c8df60..306c8228 100644 --- a/c64/basic/,stubs/a644.new.s +++ b/c64/basic/,stubs/a644.new.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a659.setcharptr.s b/c64/basic/,stubs/a659.setcharptr.s index 64a573a3..17f8cef5 100644 --- a/c64/basic/,stubs/a659.setcharptr.s +++ b/c64/basic/,stubs/a659.setcharptr.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a71a.qplop.s b/c64/basic/,stubs/a71a.qplop.s index 921a807a..03f00cd3 100644 --- a/c64/basic/,stubs/a71a.qplop.s +++ b/c64/basic/,stubs/a71a.qplop.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/a7e4.gone.s b/c64/basic/,stubs/a7e4.gone.s index bfbc4435..33b6e87c 100644 --- a/c64/basic/,stubs/a7e4.gone.s +++ b/c64/basic/,stubs/a7e4.gone.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/ad9e.frmevl.s b/c64/basic/,stubs/ad9e.frmevl.s index 2a246f66..46f275ed 100644 --- a/c64/basic/,stubs/ad9e.frmevl.s +++ b/c64/basic/,stubs/ad9e.frmevl.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs/ae86.eval.s b/c64/basic/,stubs/ae86.eval.s index b8e06255..b790c094 100644 --- a/c64/basic/,stubs/ae86.eval.s +++ b/c64/basic/,stubs/ae86.eval.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s b/c64/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s new file mode 100644 index 00000000..55b66169 --- /dev/null +++ b/c64/basic/,stubs_math/a9c4.convert_FAC1_to_INT.s @@ -0,0 +1,22 @@ +// #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 +// + +// XXX implement, test + + +convert_FAC1_to_INT: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/a9c4.interop b/c64/basic/,stubs_math/a9c4.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/a9c4.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/aabc.interop b/c64/basic/,stubs_math/aabc.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/aabc.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/aabc.print_FAC1.s b/c64/basic/,stubs_math/aabc.print_FAC1.s new file mode 100644 index 00000000..163da77b --- /dev/null +++ b/c64/basic/,stubs_math/aabc.print_FAC1.s @@ -0,0 +1,18 @@ +// #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 +// + +// XXX implement, test + + +print_FAC1: + + STUB_IMPLEMENTATION() \ No newline at end of file diff --git a/c64/basic/,stubs_math/af7b.compute_TI.s b/c64/basic/,stubs_math/af7b.compute_TI.s new file mode 100644 index 00000000..0bd1acfc --- /dev/null +++ b/c64/basic/,stubs_math/af7b.compute_TI.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX implement, test + +compute_TI: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/af7b.interop b/c64/basic/,stubs_math/af7b.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/af7b.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/af7e.interop b/c64/basic/,stubs_math/af7e.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/af7e.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/af7e.math_stub.s b/c64/basic/,stubs_math/af7e.math_stub.s new file mode 100644 index 00000000..c5eacf46 --- /dev/null +++ b/c64/basic/,stubs_math/af7e.math_stub.s @@ -0,0 +1,15 @@ +// #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 +// + +// XXX add name, label, implement, test + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/af87.interop b/c64/basic/,stubs_math/af87.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/af87.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/af87.math_stub.s b/c64/basic/,stubs_math/af87.math_stub.s new file mode 100644 index 00000000..25746cdc --- /dev/null +++ b/c64/basic/,stubs_math/af87.math_stub.s @@ -0,0 +1,15 @@ +// #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 +// + +// XXX add name, label, implement, test + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/af9a.compute_ST.s b/c64/basic/,stubs_math/af9a.compute_ST.s new file mode 100644 index 00000000..801fa221 --- /dev/null +++ b/c64/basic/,stubs_math/af9a.compute_ST.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX implement, test + +compute_ST: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/af9a.interop b/c64/basic/,stubs_math/af9a.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/af9a.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/b1aa.FACINX.s b/c64/basic/,stubs_math/b1aa.FACINX.s new file mode 100644 index 00000000..11ab5ed0 --- /dev/null +++ b/c64/basic/,stubs_math/b1aa.FACINX.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +FACINX: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b1aa.interop b/c64/basic/,stubs_math/b1aa.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/b1aa.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s b/c64/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s new file mode 100644 index 00000000..601bf5d7 --- /dev/null +++ b/c64/basic/,stubs_math/b1bf.convert_FAC1_to_s16.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX implement, test + +convert_FAC1_to_s16: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b1bf.interop b/c64/basic/,stubs_math/b1bf.interop new file mode 100644 index 00000000..3de00adc --- /dev/null +++ b/c64/basic/,stubs_math/b1bf.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +It's a part oof the ACME assembler SDK, see: +- https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True diff --git a/c64/basic/,stubs_math/b391.GIVAYF.s b/c64/basic/,stubs_math/b391.GIVAYF.s new file mode 100644 index 00000000..982b2262 --- /dev/null +++ b/c64/basic/,stubs_math/b391.GIVAYF.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +GIVAYF: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b391.interop b/c64/basic/,stubs_math/b391.interop new file mode 100644 index 00000000..62124f9a --- /dev/null +++ b/c64/basic/,stubs_math/b391.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example codoe utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s b/c64/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s new file mode 100644 index 00000000..7ec3f99a --- /dev/null +++ b/c64/basic/,stubs_math/b3a2.convert_Y_to_FAC1.s @@ -0,0 +1,16 @@ +// #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 + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b3a2.interop b/c64/basic/,stubs_math/b3a2.interop new file mode 100644 index 00000000..8b4c9dc2 --- /dev/null +++ b/c64/basic/,stubs_math/b3a2.interop @@ -0,0 +1,5 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 + diff --git a/c64/basic/,stubs_math/b794.convert_A_to_FAC1.s b/c64/basic/,stubs_math/b794.convert_A_to_FAC1.s new file mode 100644 index 00000000..c79f363c --- /dev/null +++ b/c64/basic/,stubs_math/b794.convert_A_to_FAC1.s @@ -0,0 +1,13 @@ +// #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 + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b794.interop b/c64/basic/,stubs_math/b794.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/b794.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/b7b5.STRVAL.s b/c64/basic/,stubs_math/b7b5.STRVAL.s new file mode 100644 index 00000000..f754d8f6 --- /dev/null +++ b/c64/basic/,stubs_math/b7b5.STRVAL.s @@ -0,0 +1,20 @@ +// #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 +// + +// XXX provide implementation + +STRVAL: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b7b5.interop b/c64/basic/,stubs_math/b7b5.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/b7b5.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s b/c64/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s new file mode 100644 index 00000000..f38d5a98 --- /dev/null +++ b/c64/basic/,stubs_math/b7f7.convert_FAC1_to_ADDR.s @@ -0,0 +1,20 @@ +// #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 +// + +// XXX implement, test + + +convert_FAC1_to_ADDR: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b7f7.interop b/c64/basic/,stubs_math/b7f7.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/b7f7.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/b849.add_HALF_FAC1.s b/c64/basic/,stubs_math/b849.add_HALF_FAC1.s new file mode 100644 index 00000000..deac2795 --- /dev/null +++ b/c64/basic/,stubs_math/b849.add_HALF_FAC1.s @@ -0,0 +1,16 @@ +// #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 + +// XXX implement + +add_HALF_FAC1: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b849.interop b/c64/basic/,stubs_math/b849.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/b849.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/b947.interop b/c64/basic/,stubs_math/b947.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/b947.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/b947.inv_FAC1_mantissa.s b/c64/basic/,stubs_math/b947.inv_FAC1_mantissa.s new file mode 100644 index 00000000..ceadfe99 --- /dev/null +++ b/c64/basic/,stubs_math/b947.inv_FAC1_mantissa.s @@ -0,0 +1,20 @@ +// #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 +// + +// XXX implement, test + + +inv_FAC1_mantissa: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b983.MULSHF.s b/c64/basic/,stubs_math/b983.MULSHF.s new file mode 100644 index 00000000..b4389b13 --- /dev/null +++ b/c64/basic/,stubs_math/b983.MULSHF.s @@ -0,0 +1,18 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - SHIFT routine +// +// See also: +// - [CM64] Computes Mapping the Commodore 64 - page 113 +// + +// XXX implement, test + + +MULSHF: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/b983.interop b/c64/basic/,stubs_math/b983.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/b983.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/b9ea.interop b/c64/basic/,stubs_math/b9ea.interop new file mode 100644 index 00000000..8b4c9dc2 --- /dev/null +++ b/c64/basic/,stubs_math/b9ea.interop @@ -0,0 +1,5 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 + diff --git a/c64/basic/,stubs_math/b9ea.log_FAC1.s b/c64/basic/,stubs_math/b9ea.log_FAC1.s new file mode 100644 index 00000000..2bc2765c --- /dev/null +++ b/c64/basic/,stubs_math/b9ea.log_FAC1.s @@ -0,0 +1,19 @@ +// #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 +// + +// XXX provide implementation + +log_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/ba59.MLTPLY.s b/c64/basic/,stubs_math/ba59.MLTPLY.s new file mode 100644 index 00000000..294cd246 --- /dev/null +++ b/c64/basic/,stubs_math/ba59.MLTPLY.s @@ -0,0 +1,18 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - add a mantissa byte of FAC2 to FAC1, do it .A times +// +// See also: +// - [CM64] Computes Mapping the Commodore 64 - page 113 +// + +// XXX implement, test + + +MULTPLY: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/ba59.interop b/c64/basic/,stubs_math/ba59.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/ba59.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s b/c64/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s new file mode 100644 index 00000000..1e5b639a --- /dev/null +++ b/c64/basic/,stubs_math/ba90.get_FAC2_via_INDEX.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX implement, test + +get_FAC2_via_INDEX: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/ba90.interop b/c64/basic/,stubs_math/ba90.interop new file mode 100644 index 00000000..3de00adc --- /dev/null +++ b/c64/basic/,stubs_math/ba90.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +It's a part oof the ACME assembler SDK, see: +- https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True diff --git a/c64/basic/,stubs_math/bae2.interop b/c64/basic/,stubs_math/bae2.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bae2.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bae2.mul10_FAC1.s b/c64/basic/,stubs_math/bae2.mul10_FAC1.s new file mode 100644 index 00000000..4d6e570d --- /dev/null +++ b/c64/basic/,stubs_math/bae2.mul10_FAC1.s @@ -0,0 +1,18 @@ +// #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 +// + +// XXX provide implementation + +mul10_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bafe.div10_FAC1_p.s b/c64/basic/,stubs_math/bafe.div10_FAC1_p.s new file mode 100644 index 00000000..0be04ac9 --- /dev/null +++ b/c64/basic/,stubs_math/bafe.div10_FAC1_p.s @@ -0,0 +1,22 @@ +// #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 + +// +// 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 provide implementation + +div10_FAC1_p: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bafe.interop b/c64/basic/,stubs_math/bafe.interop new file mode 100644 index 00000000..8b4c9dc2 --- /dev/null +++ b/c64/basic/,stubs_math/bafe.interop @@ -0,0 +1,5 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 + diff --git a/c64/basic/,stubs_math/bb12.div_FAC2_FAC1.s b/c64/basic/,stubs_math/bb12.div_FAC2_FAC1.s new file mode 100644 index 00000000..03f5b8db --- /dev/null +++ b/c64/basic/,stubs_math/bb12.div_FAC2_FAC1.s @@ -0,0 +1,24 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - divide FAC2 by FAC1, ignores sign +// +// Input: +// - .A - must load FAC1 exponent ($61) beforehand to set the zero flag +// +// Output: +// - leaves the quotient FAC1 and the remainder in FAC2 +// +// 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 provide implementation + +div_FAC2_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bb12.interop b/c64/basic/,stubs_math/bb12.interop new file mode 100644 index 00000000..ba5a12d8 --- /dev/null +++ b/c64/basic/,stubs_math/bb12.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing the routine: +- https://www.lemon64.com/forum/viewtopic.php?t=67576&sid=d41e77cdddd28d6f9c9d52ce5b4e8dc3 diff --git a/c64/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s b/c64/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s new file mode 100644 index 00000000..fc6675f6 --- /dev/null +++ b/c64/basic/,stubs_math/bba6.get_FAC1_via_INDEX.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX implement, test + +get_FAC1_via_INDEX: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bba6.interop b/c64/basic/,stubs_math/bba6.interop new file mode 100644 index 00000000..3de00adc --- /dev/null +++ b/c64/basic/,stubs_math/bba6.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +It's a part oof the ACME assembler SDK, see: +- https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True diff --git a/c64/basic/,stubs_math/bc2b.interop b/c64/basic/,stubs_math/bc2b.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc2b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bc2b.sgn_FAC1_A.s b/c64/basic/,stubs_math/bc2b.sgn_FAC1_A.s new file mode 100644 index 00000000..866ac209 --- /dev/null +++ b/c64/basic/,stubs_math/bc2b.sgn_FAC1_A.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +sgn_FAC1_A: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc39.interop b/c64/basic/,stubs_math/bc39.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc39.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bc39.sgn_FAC1.s b/c64/basic/,stubs_math/bc39.sgn_FAC1.s new file mode 100644 index 00000000..47af6ee9 --- /dev/null +++ b/c64/basic/,stubs_math/bc39.sgn_FAC1.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +sgn_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc3c.convert_A_to_FAC1.s b/c64/basic/,stubs_math/bc3c.convert_A_to_FAC1.s new file mode 100644 index 00000000..9187103d --- /dev/null +++ b/c64/basic/,stubs_math/bc3c.convert_A_to_FAC1.s @@ -0,0 +1,14 @@ +// #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 + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc3c.interop b/c64/basic/,stubs_math/bc3c.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc3c.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bc44.convert_i16_to_FAC1.s b/c64/basic/,stubs_math/bc44.convert_i16_to_FAC1.s new file mode 100644 index 00000000..b0e1f2e7 --- /dev/null +++ b/c64/basic/,stubs_math/bc44.convert_i16_to_FAC1.s @@ -0,0 +1,13 @@ +// #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 + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc44.interop b/c64/basic/,stubs_math/bc44.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/bc44.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/bc58.abs_FAC1.s b/c64/basic/,stubs_math/bc58.abs_FAC1.s new file mode 100644 index 00000000..919f179a --- /dev/null +++ b/c64/basic/,stubs_math/bc58.abs_FAC1.s @@ -0,0 +1,18 @@ +// #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 +// + +// XXX provide implementation + +abs_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc58.interop b/c64/basic/,stubs_math/bc58.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc58.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bc5b.FCOMP.s b/c64/basic/,stubs_math/bc5b.FCOMP.s new file mode 100644 index 00000000..e0f00777 --- /dev/null +++ b/c64/basic/,stubs_math/bc5b.FCOMP.s @@ -0,0 +1,29 @@ +// #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 +// + +// XXX provide implementation + +FCOMP: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc5b.interop b/c64/basic/,stubs_math/bc5b.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc5b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bc9b.QINT.s b/c64/basic/,stubs_math/bc9b.QINT.s new file mode 100644 index 00000000..26ba5f71 --- /dev/null +++ b/c64/basic/,stubs_math/bc9b.QINT.s @@ -0,0 +1,20 @@ +// #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 +// + +// XXX provide implementation + +QINT: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bc9b.interop b/c64/basic/,stubs_math/bc9b.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bc9b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bccc.int_FAC1.s b/c64/basic/,stubs_math/bccc.int_FAC1.s new file mode 100644 index 00000000..4a7c6d47 --- /dev/null +++ b/c64/basic/,stubs_math/bccc.int_FAC1.s @@ -0,0 +1,18 @@ +// #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 +// + +// XXX provide implementation + +int_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bccc.interop b/c64/basic/,stubs_math/bccc.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bccc.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bcf3.FIN.s b/c64/basic/,stubs_math/bcf3.FIN.s new file mode 100644 index 00000000..f06e63eb --- /dev/null +++ b/c64/basic/,stubs_math/bcf3.FIN.s @@ -0,0 +1,24 @@ +// #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 +// + +// XXX provide implementation + +FIN: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bcf3.interop b/c64/basic/,stubs_math/bcf3.interop new file mode 100644 index 00000000..ba5a12d8 --- /dev/null +++ b/c64/basic/,stubs_math/bcf3.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing the routine: +- https://www.lemon64.com/forum/viewtopic.php?t=67576&sid=d41e77cdddd28d6f9c9d52ce5b4e8dc3 diff --git a/c64/basic/,stubs_math/bd7e.FINLOG.s b/c64/basic/,stubs_math/bd7e.FINLOG.s new file mode 100644 index 00000000..998ca32b --- /dev/null +++ b/c64/basic/,stubs_math/bd7e.FINLOG.s @@ -0,0 +1,18 @@ +// #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 +// + +// XXX implement, test + + +FINLOG: + + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bd7e.interop b/c64/basic/,stubs_math/bd7e.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/bd7e.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/bddd.FOUT.s b/c64/basic/,stubs_math/bddd.FOUT.s new file mode 100644 index 00000000..a9b3b2d8 --- /dev/null +++ b/c64/basic/,stubs_math/bddd.FOUT.s @@ -0,0 +1,22 @@ +// #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 +// + +// XXX provide implementation + +FOUT: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bddd.interop b/c64/basic/,stubs_math/bddd.interop new file mode 100644 index 00000000..ba5a12d8 --- /dev/null +++ b/c64/basic/,stubs_math/bddd.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing the routine: +- https://www.lemon64.com/forum/viewtopic.php?t=67576&sid=d41e77cdddd28d6f9c9d52ce5b4e8dc3 diff --git a/c64/basic/,stubs_math/bf71.interop b/c64/basic/,stubs_math/bf71.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bf71.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bf71.sqr_FAC1.s b/c64/basic/,stubs_math/bf71.sqr_FAC1.s new file mode 100644 index 00000000..ac9a07c3 --- /dev/null +++ b/c64/basic/,stubs_math/bf71.sqr_FAC1.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +sqr_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bf74.interop b/c64/basic/,stubs_math/bf74.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bf74.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bf74.sqr_FAC2.s b/c64/basic/,stubs_math/bf74.sqr_FAC2.s new file mode 100644 index 00000000..a0b8a412 --- /dev/null +++ b/c64/basic/,stubs_math/bf74.sqr_FAC2.s @@ -0,0 +1,21 @@ +// #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 +// + +// XXX provide implementation + +sqr_FAC2: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bf78.FPWR.s b/c64/basic/,stubs_math/bf78.FPWR.s new file mode 100644 index 00000000..3225ae9c --- /dev/null +++ b/c64/basic/,stubs_math/bf78.FPWR.s @@ -0,0 +1,22 @@ +// #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 FAC1 +// +// 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/Floating_point_arithmetic +// - https://codebase64.org/doku.php?id=base:kernal_floating_point_mathematics +// + +// XXX provide implementation + +FPWR: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bf78.interop b/c64/basic/,stubs_math/bf78.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bf78.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bf7b.FPWRT.s b/c64/basic/,stubs_math/bf7b.FPWRT.s new file mode 100644 index 00000000..1bc6264a --- /dev/null +++ b/c64/basic/,stubs_math/bf7b.FPWRT.s @@ -0,0 +1,25 @@ +// #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 +// + +// XXX provide implementation + +FPWRT: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bf7b.interop b/c64/basic/,stubs_math/bf7b.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bf7b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/bfed.exp_FAC1.s b/c64/basic/,stubs_math/bfed.exp_FAC1.s new file mode 100644 index 00000000..296a58a3 --- /dev/null +++ b/c64/basic/,stubs_math/bfed.exp_FAC1.s @@ -0,0 +1,19 @@ +// #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 +// + +// XXX provide implementation + +exp_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/bfed.interop b/c64/basic/,stubs_math/bfed.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/,stubs_math/bfed.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/,stubs_math/e043.interop b/c64/basic/,stubs_math/e043.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/e043.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/e043.poly1_FAC1.s b/c64/basic/,stubs_math/e043.poly1_FAC1.s new file mode 100644 index 00000000..94639620 --- /dev/null +++ b/c64/basic/,stubs_math/e043.poly1_FAC1.s @@ -0,0 +1,27 @@ +// #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 +// + +// XXX provide implementation + +poly1_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e059.interop b/c64/basic/,stubs_math/e059.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/e059.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/,stubs_math/e059.poly2_FAC1.s b/c64/basic/,stubs_math/e059.poly2_FAC1.s new file mode 100644 index 00000000..226c61b3 --- /dev/null +++ b/c64/basic/,stubs_math/e059.poly2_FAC1.s @@ -0,0 +1,27 @@ +// #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 +// + +// XXX provide implementation + +poly2_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e264.cos_FAC1.s b/c64/basic/,stubs_math/e264.cos_FAC1.s new file mode 100644 index 00000000..bdf0b761 --- /dev/null +++ b/c64/basic/,stubs_math/e264.cos_FAC1.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX provide implementation + +COS: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e264.interop b/c64/basic/,stubs_math/e264.interop new file mode 100644 index 00000000..8e0ca383 --- /dev/null +++ b/c64/basic/,stubs_math/e264.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Usage example: +- https://www.lemon64.com/forum/viewtopic.php?t=10492 diff --git a/c64/basic/,stubs_math/e26b.interop b/c64/basic/,stubs_math/e26b.interop new file mode 100644 index 00000000..8e0ca383 --- /dev/null +++ b/c64/basic/,stubs_math/e26b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Usage example: +- https://www.lemon64.com/forum/viewtopic.php?t=10492 diff --git a/c64/basic/,stubs_math/e26b.sin_FAC1.s b/c64/basic/,stubs_math/e26b.sin_FAC1.s new file mode 100644 index 00000000..99eb4569 --- /dev/null +++ b/c64/basic/,stubs_math/e26b.sin_FAC1.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX provide implementation + +sin_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e2b4.interop b/c64/basic/,stubs_math/e2b4.interop new file mode 100644 index 00000000..8e0ca383 --- /dev/null +++ b/c64/basic/,stubs_math/e2b4.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Usage example: +- https://www.lemon64.com/forum/viewtopic.php?t=10492 diff --git a/c64/basic/,stubs_math/e2b4.tan_FAC1.s b/c64/basic/,stubs_math/e2b4.tan_FAC1.s new file mode 100644 index 00000000..480991fc --- /dev/null +++ b/c64/basic/,stubs_math/e2b4.tan_FAC1.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX provide implementation + +tan_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e30e.atn_FAC1.s b/c64/basic/,stubs_math/e30e.atn_FAC1.s new file mode 100644 index 00000000..1fc04501 --- /dev/null +++ b/c64/basic/,stubs_math/e30e.atn_FAC1.s @@ -0,0 +1,17 @@ +// #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 +// + +// XXX provide implementation + +atn_FAC1: + STUB_IMPLEMENTATION() diff --git a/c64/basic/,stubs_math/e30e.interop b/c64/basic/,stubs_math/e30e.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/,stubs_math/e30e.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/a533.linkprg.s b/c64/basic/a533.linkprg.s index 4db59db1..f272bd30 100644 --- a/c64/basic/a533.linkprg.s +++ b/c64/basic/a533.linkprg.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/a68e.runc.s b/c64/basic/a68e.runc.s index f0a8aeb1..bda66edc 100644 --- a/c64/basic/a68e.runc.s +++ b/c64/basic/a68e.runc.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/a7ae.newstt.s b/c64/basic/a7ae.newstt.s index 79aed4d6..069a1276 100644 --- a/c64/basic/a7ae.newstt.s +++ b/c64/basic/a7ae.newstt.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/ab1e.strout.s b/c64/basic/ab1e.strout.s index 0317550a..d067e9e1 100644 --- a/c64/basic/ab1e.strout.s +++ b/c64/basic/ab1e.strout.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 8e880687..575a98e5 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -81,7 +81,7 @@ rsl_l1: beq_16 wedge_dos #endif #if CONFIG_TAPE_WEDGE - cmp #$1F // left arrow + cmp #$5F // left arrow beq_16 wedge_tape #endif diff --git a/c64/basic/bdcd.linprt.s b/c64/basic/bdcd.linprt.s index 284b626e..5ab2fd47 100644 --- a/c64/basic/bdcd.linprt.s +++ b/c64/basic/bdcd.linprt.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/board_m65/mega65_dummy.s b/c64/basic/board_m65/mega65_dummy.s new file mode 100644 index 00000000..338a1c16 --- /dev/null +++ b/c64/basic/board_m65/mega65_dummy.s @@ -0,0 +1,7 @@ +// #LAYOUT# M65 BASIC_1 #TAKE +// #LAYOUT# * * #IGNORE + + +// Dummy, just to have anything in segment 1 + + brk diff --git a/c64/basic/board_x16/cx16_dummy.s b/c64/basic/board_x16/cx16_dummy.s new file mode 100644 index 00000000..e1558df9 --- /dev/null +++ b/c64/basic/board_x16/cx16_dummy.s @@ -0,0 +1,7 @@ +// #LAYOUT# X16 BASIC_1 #TAKE +// #LAYOUT# * * #IGNORE + + +// Dummy, just to have anything in segment 1 + + brk diff --git a/c64/basic/board_x16/cx16_stubs.s b/c64/basic/board_x16/cx16_stubs.s new file mode 100644 index 00000000..5b64b03d --- /dev/null +++ b/c64/basic/board_x16/cx16_stubs.s @@ -0,0 +1,8 @@ +// #LAYOUT# X16 BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// Stubs for Commander X16 support + + +rnd_seed_init: + jmp rnd_generate diff --git a/c64/basic/c000.skip_gap.s b/c64/basic/c000.skip_gap.s index 9d256aeb..a8d678e6 100644 --- a/c64/basic/c000.skip_gap.s +++ b/c64/basic/c000.skip_gap.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/init/a000.cold_start_vector.s b/c64/basic/init/a000.cold_start_vector.s index 067b0f64..ef12f257 100644 --- a/c64/basic/init/a000.cold_start_vector.s +++ b/c64/basic/init/a000.cold_start_vector.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/init/a002.warm_start_vector.s b/c64/basic/init/a002.warm_start_vector.s index 411e17a5..717c4b2b 100644 --- a/c64/basic/init/a002.warm_start_vector.s +++ b/c64/basic/init/a002.warm_start_vector.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/init/e394.basic_cold_start.s b/c64/basic/init/e394.basic_cold_start.s index 76419f1c..a7ba4138 100644 --- a/c64/basic/init/e394.basic_cold_start.s +++ b/c64/basic/init/e394.basic_cold_start.s @@ -8,6 +8,8 @@ basic_cold_start: +#if 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 ldy #(__rom_revision_basic_end - rom_revision_basic - 1) @@ -22,6 +24,8 @@ basic_cold_start: dey bpl !-- +#endif + // Remaining part would not fit here jmp basic_cold_start_internal diff --git a/c64/basic/math/add_FAC2_FAC1_sub.s b/c64/basic/math/add_FAC2_FAC1_sub.s new file mode 100644 index 00000000..a045e1b8 --- /dev/null +++ b/c64/basic/math/add_FAC2_FAC1_sub.s @@ -0,0 +1,97 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Math package - add FAC2 to FAC1, subtraction part +// + +// 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 + + lda FAC1_mantissa+0 + cmp FAC2_mantissa+0 + bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch + bne !+ // 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 + + lda FAC1_mantissa+2 + cmp FAC2_mantissa+2 + bcc add_FAC2_FAC1_sub_rev // if FAC1 < FAC2, branch + bne !+ // 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 + + // 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 + + sec + lda FAC1_mantissa+3 + sbc FAC2_mantissa+3 + sta FAC1_mantissa+3 + + lda FAC1_mantissa+2 + sbc FAC2_mantissa+2 + sta FAC1_mantissa+2 + + lda FAC1_mantissa+1 + sbc FAC2_mantissa+1 + sta FAC1_mantissa+1 + + lda FAC1_mantissa+0 + sbc FAC2_mantissa+0 + sta FAC1_mantissa+0 + + // Exponent should never need adaptation here + + jmp normal_FAC1 + +add_FAC2_FAC1_sub_rev: + + // Since |FAC1| < |FAC2|, toggle FAC1 sign before subtraction + + jsr toggle_sign_FAC1_skipcheck + + // Perform the subtration, FAC1 = FAC2 - FAC1 + + sec + lda #$00 + sbc FACOV + sta FACOV + + lda FAC2_mantissa+3 + sbc FAC1_mantissa+3 + sta FAC1_mantissa+3 + + lda FAC2_mantissa+2 + sbc FAC1_mantissa+2 + sta FAC1_mantissa+2 + + lda FAC2_mantissa+1 + sbc FAC1_mantissa+1 + sta FAC1_mantissa+1 + + lda FAC2_mantissa+0 + sbc FAC1_mantissa+0 + sta FAC1_mantissa+0 + + // Exponent should never need adaptation here + + jmp normal_FAC1 diff --git a/c64/basic/math/add_align_exponents.s b/c64/basic/math/add_align_exponents.s new file mode 100644 index 00000000..3956ed9c --- /dev/null +++ b/c64/basic/math/add_align_exponents.s @@ -0,0 +1,169 @@ +// #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 + +// XXX finish and test this + +add_align_exponents: + + // 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 + bcs add_align_exponent_FAC2 + + // FALLTROUGH + +add_align_exponent_FAC1: + + // 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 + + cmp #$08 + bcc add_align_exponent_FAC1_bit + + // FALLTROUGH + +add_align_exponent_FAC1_byte: + + // Add 8 to exponent, divide mantissa by 256 + + lda FAC1_exponent + clc + adc #$08 + sta FAC1_exponent + + lda FAC1_mantissa+3 + sta FACOV + lda FAC1_mantissa+2 + sta FAC1_mantissa+3 + lda FAC1_mantissa+1 + sta FAC1_mantissa+2 + lda FAC1_mantissa+0 + sta FAC1_mantissa+1 + lda #$00 + sta FAC1_mantissa+0 + + beq add_align_exponent_FAC1 // branch always - next iteration + +add_align_exponent_FAC1_bit: + + // Increment exponent, divide mantissa by 2 + + inc FAC1_exponent + + clc + ror FAC1_mantissa+0 + ror FAC1_mantissa+1 + ror FAC1_mantissa+2 + ror FAC1_mantissa+3 + ror FACOV + + lda FAC1_exponent + cmp FAC2_exponent + bne add_align_exponent_FAC1_bit // branch if next iteration needed + + rts + +add_align_exponent_FAC1_zero: + + lda #$00 + + sta FAC1_mantissa+0 + sta FAC1_mantissa+1 + sta FAC1_mantissa+2 + sta FAC1_mantissa+3 + sta FACOV + + lda FAC2_exponent + sta FAC1_exponent + + // FALLTROUGH + +add_align_exponents_done: + + rts + + + +add_align_exponent_FAC2: + + // 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 + + cmp #$08 + bcc add_align_exponent_FAC2_bit + + // FALLTROUGH + +add_align_exponent_FAC2_byte: + + // Add 8 to exponent, divide mantissa by 256 + + lda FAC2_exponent + clc + adc #$08 + sta FAC2_exponent + + lda FAC2_mantissa+2 + sta FAC2_mantissa+3 + lda FAC2_mantissa+1 + sta FAC2_mantissa+2 + lda FAC2_mantissa+0 + sta FAC2_mantissa+1 + lda #$00 + sta FAC2_mantissa+0 + + beq add_align_exponent_FAC2 // branch always - next iteration + +add_align_exponent_FAC2_bit: + + // Increment exponent, divide mantissa by 2 + + inc FAC2_exponent + + clc + ror FAC2_mantissa+0 + ror FAC2_mantissa+1 + ror FAC2_mantissa+2 + ror FAC2_mantissa+3 + + lda FAC1_exponent + cmp FAC2_exponent + bne add_align_exponent_FAC2_bit // branch if next iteration needed + + rts + + +add_align_exponent_FAC2_zero: + + lda #$00 + + sta FAC2_mantissa+0 + sta FAC2_mantissa+1 + sta FAC2_mantissa+2 + sta FAC2_mantissa+3 + + lda FAC1_exponent + sta FAC2_exponent + + rts diff --git a/c64/basic/math/b850.interop b/c64/basic/math/b850.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/b850.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/b850.sub_MEM_FAC1.s b/c64/basic/math/b850.sub_MEM_FAC1.s new file mode 100644 index 00000000..72281c92 --- /dev/null +++ b/c64/basic/math/b850.sub_MEM_FAC1.s @@ -0,0 +1,23 @@ +// #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 +// + +sub_MEM_FAC1: + + jsr mov_MEM_FAC2 + + // FALLTROUGH to sub_FAC2_FAC1 diff --git a/c64/basic/math/b853.interop b/c64/basic/math/b853.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/math/b853.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/math/b853.sub_FAC2_FAC1.s b/c64/basic/math/b853.sub_FAC2_FAC1.s new file mode 100644 index 00000000..e54a85a9 --- /dev/null +++ b/c64/basic/math/b853.sub_FAC2_FAC1.s @@ -0,0 +1,25 @@ +// #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 +// + +// XXX test this + +sub_FAC2_FAC1: + + // Toggle FAC1 sign + lda FAC1_sign + eor #$FF + sta FAC1_sign + + // Perform addition + jmp add_FAC2_FAC1 diff --git a/c64/basic/math/b862.add_align_exponent.jmp.s b/c64/basic/math/b862.add_align_exponent.jmp.s new file mode 100644 index 00000000..03fef8c3 --- /dev/null +++ b/c64/basic/math/b862.add_align_exponent.jmp.s @@ -0,0 +1,9 @@ +// #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 + + + jmp add_align_exponents diff --git a/c64/basic/math/b862.interop b/c64/basic/math/b862.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/b862.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/b867.add_MEM_FAC1.s b/c64/basic/math/b867.add_MEM_FAC1.s new file mode 100644 index 00000000..1d948ee0 --- /dev/null +++ b/c64/basic/math/b867.add_MEM_FAC1.s @@ -0,0 +1,23 @@ +// #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 +// + +add_MEM_FAC1: + + jsr mov_MEM_FAC2 + + // FALLTROUGH to add_FAC2_FAC1 diff --git a/c64/basic/math/b867.interop b/c64/basic/math/b867.interop new file mode 100644 index 00000000..0975813a --- /dev/null +++ b/c64/basic/math/b867.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Routine probably used very often, it's call can be seen in a tutorial here: +- https://codebase64.org/doku.php?id=base:generating_sines_with_basic diff --git a/c64/basic/math/b86a.add_FAC2_FAC1.s b/c64/basic/math/b86a.add_FAC2_FAC1.s new file mode 100644 index 00000000..9ae04a29 --- /dev/null +++ b/c64/basic/math/b86a.add_FAC2_FAC1.s @@ -0,0 +1,96 @@ +// #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 +// + +// XXX test this + +add_FAC2_FAC1: + + // 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 + + lda FAC1_exponent + beq_16 mov_FAC2_FAC1 + + // Make sure the exponents are aligned + + jsr add_align_exponents + + // Check whether signs are the same + + lda FAC1_sign + eor FAC2_sign + + bmi_16 add_FAC2_FAC1_sub // branch if signs are opposite + + // Perform the addition + + clc + lda FAC2_mantissa+3 + adc FAC1_mantissa+3 + sta FAC1_mantissa+3 + + lda FAC2_mantissa+2 + adc FAC1_mantissa+2 + sta FAC1_mantissa+2 + + lda FAC2_mantissa+1 + adc FAC1_mantissa+1 + sta FAC1_mantissa+1 + + lda FAC2_mantissa+0 + adc FAC1_mantissa+0 + sta FAC1_mantissa+0 + + bcc_16 normal_FAC1 // end if no need to adapt the exponent + + inc FAC1_exponent + bne add_FAC2_FAC1_adapt_mantissa // end if no overflow + + // FALLTROUGH + +set_FAC1_max: // entry used by other routines too + + lda #$FF + sta FAC1_exponent + sta FAC1_mantissa+3 + sta FAC1_mantissa+2 + sta FAC1_mantissa+1 + sta FAC1_mantissa+0 + + // FALLTROUGH + +add_FAC2_FAC1_done: + + rts + +add_FAC2_FAC1_adapt_mantissa: + + sec + ror FAC1_mantissa+0 + ror FAC1_mantissa+1 + ror FAC1_mantissa+2 + ror FAC1_mantissa+3 + ror FACOV + + rts diff --git a/c64/basic/math/b86a.interop b/c64/basic/math/b86a.interop new file mode 100644 index 00000000..1b7d0105 --- /dev/null +++ b/c64/basic/math/b86a.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- http://cbm-hackers.2304266.n4.nabble.com/unsigned-to-float-td4668532.html#a4668556 diff --git a/c64/basic/math/b8fe.interop b/c64/basic/math/b8fe.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/b8fe.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/b8fe.normal_FAC1.jmp.s b/c64/basic/math/b8fe.normal_FAC1.jmp.s new file mode 100644 index 00000000..e40972f8 --- /dev/null +++ b/c64/basic/math/b8fe.normal_FAC1.jmp.s @@ -0,0 +1,8 @@ +// #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 + + jmp normal_FAC1 diff --git a/c64/basic/math/ba28.interop b/c64/basic/math/ba28.interop new file mode 100644 index 00000000..0a30d506 --- /dev/null +++ b/c64/basic/math/ba28.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://www.lemon64.com/forum/viewtopic.php?t=42934 diff --git a/c64/basic/math/ba28.mul_MEM_FAC1.jmp.s b/c64/basic/math/ba28.mul_MEM_FAC1.jmp.s new file mode 100644 index 00000000..02a35b91 --- /dev/null +++ b/c64/basic/math/ba28.mul_MEM_FAC1.jmp.s @@ -0,0 +1,26 @@ +// #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 +// + +mul_MEM_FAC1: + + jsr mov_MEM_FAC2 + + // FALLTROUGH to mul_FAC2_FAC1 diff --git a/c64/basic/math/ba2b.interop b/c64/basic/math/ba2b.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/math/ba2b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/math/ba2b.mul_FAC2_FAC1.s b/c64/basic/math/ba2b.mul_FAC2_FAC1.s new file mode 100644 index 00000000..1b918524 --- /dev/null +++ b/c64/basic/math/ba2b.mul_FAC2_FAC1.s @@ -0,0 +1,8 @@ +// #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 + + jmp mul_FAC2_FAC1 diff --git a/c64/basic/math/ba8c.interop b/c64/basic/math/ba8c.interop new file mode 100644 index 00000000..0a30d506 --- /dev/null +++ b/c64/basic/math/ba8c.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://www.lemon64.com/forum/viewtopic.php?t=42934 diff --git a/c64/basic/math/ba8c.mov_MEM_FAC2.jmp.s b/c64/basic/math/ba8c.mov_MEM_FAC2.jmp.s new file mode 100644 index 00000000..d556073a --- /dev/null +++ b/c64/basic/math/ba8c.mov_MEM_FAC2.jmp.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_MEM_FAC2 diff --git a/c64/basic/math/bb0f.div_MEM_FAC1.s b/c64/basic/math/bb0f.div_MEM_FAC1.s new file mode 100644 index 00000000..2863958a --- /dev/null +++ b/c64/basic/math/bb0f.div_MEM_FAC1.s @@ -0,0 +1,23 @@ +// #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 +// + +div_MEM_FAC1: + + jsr mov_MEM_FAC2 + + // FALLTROUGH to div_FAC2_FAC1 diff --git a/c64/basic/math/bb0f.interop b/c64/basic/math/bb0f.interop new file mode 100644 index 00000000..50ba7802 --- /dev/null +++ b/c64/basic/math/bb0f.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://codebase64.org/doku.php?id=base:mandelbrot diff --git a/c64/basic/math/bba2.interop b/c64/basic/math/bba2.interop new file mode 100644 index 00000000..0975813a --- /dev/null +++ b/c64/basic/math/bba2.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Routine probably used very often, it's call can be seen in a tutorial here: +- https://codebase64.org/doku.php?id=base:generating_sines_with_basic diff --git a/c64/basic/math/bba2.mov_MEM_FAC1.jmp.s b/c64/basic/math/bba2.mov_MEM_FAC1.jmp.s new file mode 100644 index 00000000..21e9f9ca --- /dev/null +++ b/c64/basic/math/bba2.mov_MEM_FAC1.jmp.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_MEM_FAC1 diff --git a/c64/basic/math/bbc7.interop b/c64/basic/math/bbc7.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/bbc7.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/bbc7.mov_r_FAC1_TMP2.s b/c64/basic/math/bbc7.mov_r_FAC1_TMP2.s new file mode 100644 index 00000000..a3651fd4 --- /dev/null +++ b/c64/basic/math/bbc7.mov_r_FAC1_TMP2.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_r_FAC1_TMP2 diff --git a/c64/basic/math/bbca.interop b/c64/basic/math/bbca.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/bbca.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/bbca.mov_r_FAC1_TMP1.s b/c64/basic/math/bbca.mov_r_FAC1_TMP1.s new file mode 100644 index 00000000..d9993d30 --- /dev/null +++ b/c64/basic/math/bbca.mov_r_FAC1_TMP1.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_r_FAC1_TMP1 diff --git a/c64/basic/math/bbd0.interop b/c64/basic/math/bbd0.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/bbd0.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/bbd0.mov_r_FAC1_VAR.s b/c64/basic/math/bbd0.mov_r_FAC1_VAR.s new file mode 100644 index 00000000..59ac4b18 --- /dev/null +++ b/c64/basic/math/bbd0.mov_r_FAC1_VAR.s @@ -0,0 +1,21 @@ +// #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 +// + +mov_r_FAC1_VAR: + + ldy #FORPNT+1 + ldx #FORPNT+0 + + // FALLTROUGH to mov_r_FAC1_MEM diff --git a/c64/basic/math/bbd4.interop b/c64/basic/math/bbd4.interop new file mode 100644 index 00000000..50ba7802 --- /dev/null +++ b/c64/basic/math/bbd4.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://codebase64.org/doku.php?id=base:mandelbrot diff --git a/c64/basic/math/bbd4.mov_r_FAC1_MEM.s b/c64/basic/math/bbd4.mov_r_FAC1_MEM.s new file mode 100644 index 00000000..8bf3182d --- /dev/null +++ b/c64/basic/math/bbd4.mov_r_FAC1_MEM.s @@ -0,0 +1,26 @@ +// #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 +// + +mov_r_FAC1_MEM: + + // Start by rounding FAC1 + + jsr round_FAC1 + jmp mov_FAC1_MEM diff --git a/c64/basic/math/bbfc.interop b/c64/basic/math/bbfc.interop new file mode 100644 index 00000000..0d18777c --- /dev/null +++ b/c64/basic/math/bbfc.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, documented in many places. + +XXX - try to find real-life example diff --git a/c64/basic/math/bbfc.mov_FAC2_FAC1.s b/c64/basic/math/bbfc.mov_FAC2_FAC1.s new file mode 100644 index 00000000..a59de960 --- /dev/null +++ b/c64/basic/math/bbfc.mov_FAC2_FAC1.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_FAC2_FAC1 diff --git a/c64/basic/math/bc0c.interop b/c64/basic/math/bc0c.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/math/bc0c.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/math/bc0c.mov_r_FAC1_FAC2.s b/c64/basic/math/bc0c.mov_r_FAC1_FAC2.s new file mode 100644 index 00000000..edf6e9cd --- /dev/null +++ b/c64/basic/math/bc0c.mov_r_FAC1_FAC2.s @@ -0,0 +1,23 @@ +// #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 +// + +mov_r_FAC1_FAC2: + + // First round FAC1 + jsr round_FAC1 + + // FALLTROUGH to mov_FAC1_FAC2 diff --git a/c64/basic/math/bc0f.interop b/c64/basic/math/bc0f.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/math/bc0f.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/math/bc0f.mov_FAC1_FAC2.jmp.s b/c64/basic/math/bc0f.mov_FAC1_FAC2.jmp.s new file mode 100644 index 00000000..6cb71a8d --- /dev/null +++ b/c64/basic/math/bc0f.mov_FAC1_FAC2.jmp.s @@ -0,0 +1,8 @@ +// #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 + + jmp mov_FAC1_FAC2 diff --git a/c64/basic/math/bc1b.interop b/c64/basic/math/bc1b.interop new file mode 100644 index 00000000..ba5a12d8 --- /dev/null +++ b/c64/basic/math/bc1b.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing the routine: +- https://www.lemon64.com/forum/viewtopic.php?t=67576&sid=d41e77cdddd28d6f9c9d52ce5b4e8dc3 diff --git a/c64/basic/math/bc1b.round_FAC1.jmp.s b/c64/basic/math/bc1b.round_FAC1.jmp.s new file mode 100644 index 00000000..6658d65e --- /dev/null +++ b/c64/basic/math/bc1b.round_FAC1.jmp.s @@ -0,0 +1,9 @@ +// #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 + + jmp round_FAC1 + diff --git a/c64/basic/math/bfb4.interop b/c64/basic/math/bfb4.interop new file mode 100644 index 00000000..c4ad4680 --- /dev/null +++ b/c64/basic/math/bfb4.interop @@ -0,0 +1,4 @@ +This is an important floating point math routine, documented in many places. + +Example code utilizing this routine: +- https://github.com/irmen/prog8/blob/master/compiler/res/prog8lib/c64flt.p8 diff --git a/c64/basic/math/bfb4.toggle_sign_FAC1.s b/c64/basic/math/bfb4.toggle_sign_FAC1.s new file mode 100644 index 00000000..d3fa428a --- /dev/null +++ b/c64/basic/math/bfb4.toggle_sign_FAC1.s @@ -0,0 +1,27 @@ +// #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 +// + +toggle_sign_FAC1: + + lda FAC1_exponent + beq !+ // do not toggle the sign if value is 0 + + // FALLTROUGH + +toggle_sign_FAC1_skipcheck: // entry for other routines + + lda FAC1_sign + eor #$FF + sta FAC1_sign +!: + rts diff --git a/c64/basic/math/e097.interop b/c64/basic/math/e097.interop new file mode 100644 index 00000000..6b2f206f --- /dev/null +++ b/c64/basic/math/e097.interop @@ -0,0 +1,3 @@ +This is an important floating point math routine, referenced by ACME SDK, see here: + +- https://sourceforge.net/p/acme-crossass/code-0/38/tree/trunk/ACME_Lib/cbm/c64/float.a?force=True diff --git a/c64/basic/math/e097.rnd_FAC1.s b/c64/basic/math/e097.rnd_FAC1.s new file mode 100644 index 00000000..0091fe7f --- /dev/null +++ b/c64/basic/math/e097.rnd_FAC1.s @@ -0,0 +1,20 @@ +// #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 +// + +rnd_FAC1: + + jsr sgn_FAC1_A + + // FALLTROUGH to rnd_A + diff --git a/c64/basic/math/e09a.interop b/c64/basic/math/e09a.interop new file mode 100644 index 00000000..c876324b --- /dev/null +++ b/c64/basic/math/e09a.interop @@ -0,0 +1,5 @@ +This is an important floating point math routine, see: +- https://www.atarimagazines.com/compute/issue72/random_numbers.php + +Example code utilizing the routine: +- https://stackoverflow.com/questions/44937759/getting-random-number-from-6502-assembler/44937995 diff --git a/c64/basic/math/e09a.rnd_A.s b/c64/basic/math/e09a.rnd_A.s new file mode 100644 index 00000000..1bb428f8 --- /dev/null +++ b/c64/basic/math/e09a.rnd_A.s @@ -0,0 +1,26 @@ +// #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 +// + +rnd_A: + + cmp #$00 + beq_16 rnd_seed_init + + cmp #$80 + bcc_16 rnd_generate + + jmp rnd_seed_from_FAC1 diff --git a/c64/basic/math/e0be.interop b/c64/basic/math/e0be.interop new file mode 100644 index 00000000..c42eaa6a --- /dev/null +++ b/c64/basic/math/e0be.interop @@ -0,0 +1,5 @@ +This is an important floating point math routine, see: +- https://www.atarimagazines.com/compute/issue72/random_numbers.php + +Example coode utilizing this routine: +- https://www.lemon64.com/forum/viewtopic.php?t=56934&sid=387926a3f1d6373a384c0f7328b00c30 diff --git a/c64/basic/math/e0be.rnd_generate.s b/c64/basic/math/e0be.rnd_generate.s new file mode 100644 index 00000000..f33e2921 --- /dev/null +++ b/c64/basic/math/e0be.rnd_generate.s @@ -0,0 +1,77 @@ +// #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 +// + +rnd_generate: + + asl RNDX+1 + rol RNDX+2 + rol RNDX+3 + rol RNDX+4 + + bcs rnd_generate_copy + + lda RNDX+1 + eor #$B7 + sta RNDX+1 + + lda RNDX+2 + eor #$1D + sta RNDX+2 + + lda RNDX+3 + eor #$C1 + sta RNDX+3 + + lda RNDX+4 + eor #$04 + sta RNDX+4 + + sec // make sure Carry is always set, for adc + + // FALLTROUGH + +rnd_generate_copy: + + // Copy the generated number to FAC1, mangle it a little + + lda RNDX+3 + adc #$C6 + sta FAC1_mantissa+0 + + lda RNDX+1 + eor #$4E + sta FAC1_mantissa+1 + + lda RNDX+4 + eor #$62 + sta FAC1_mantissa+2 + + lda RNDX+2 + bit RNDX+2 + rol + sta FAC1_mantissa+3 + + // FALLTROUGH + +rnd_generate_finalize: + + lda #$00 + sta FAC1_sign + + lda #$80 + sta FACOV // just to prevent 0 after normalization + sta FAC1_exponent + + jmp normal_FAC1 diff --git a/c64/basic/math/mov_FAC1_FAC2.s b/c64/basic/math/mov_FAC1_FAC2.s new file mode 100644 index 00000000..8ce497d5 --- /dev/null +++ b/c64/basic/math/mov_FAC1_FAC2.s @@ -0,0 +1,51 @@ +// #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 +// + +mov_FAC1_FAC2: + + // Copy the exponent + lda FAC1_exponent + sta FAC2_exponent + beq !+ // for 0 no need to copy mantissa and sign + + // Copy the mantissa + lda FAC1_mantissa+0 + sta FAC2_mantissa+0 + lda FAC1_mantissa+1 + sta FAC2_mantissa+1 + lda FAC1_mantissa+2 + sta FAC2_mantissa+2 + lda FAC1_mantissa+3 + sta FAC2_mantissa+3 + + // Copy the sign + lda FAC1_sign + sta FAC2_sign + + lda FAC1_exponent +!: + // Duplicate the original ROM behaviour + ldx #$00 + stx FACOV + + rts diff --git a/c64/basic/math/mov_FAC1_MEM.s b/c64/basic/math/mov_FAC1_MEM.s new file mode 100644 index 00000000..84d49903 --- /dev/null +++ b/c64/basic/math/mov_FAC1_MEM.s @@ -0,0 +1,74 @@ +// #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 +// + +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 + + sty INDEX+1 + stx INDEX+0 + + ldy #$00 + + // Copy exponent + + lda FAC1_exponent + sta (INDEX), y + beq mov_FAC1_MEM_end // for 0 no need to copy anything more + + // Copy first byte of mantissa + + iny + lda FAC2_mantissa+3 + sta (INDEX), y + + // Copy the sign XXX try to optimize this part + + lda FAC1_sign + bne !+ + + lda FAC2_mantissa+3 + and #$7F + sta (INDEX), y +!: + // Copy remaining parts of mantissa + + iny + lda FAC2_mantissa+2 + sta (INDEX), y + + iny + lda FAC2_mantissa+1 + sta (INDEX), y + + iny + 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) + + ldy #$00 + sty FACOV + +mov_FAC1_MEM_end: + + lda FAC1_exponent + rts diff --git a/c64/basic/math/mov_FAC2_FAC1.s b/c64/basic/math/mov_FAC2_FAC1.s new file mode 100644 index 00000000..231c0b91 --- /dev/null +++ b/c64/basic/math/mov_FAC2_FAC1.s @@ -0,0 +1,49 @@ +// #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 +// + +mov_FAC2_FAC1: + + // Copy the mantissa + + lda FAC2_mantissa+3 + sta FAC1_mantissa+3 + lda FAC2_mantissa+2 + sta FAC1_mantissa+2 + lda FAC2_mantissa+1 + sta FAC1_mantissa+1 + lda FAC2_mantissa+0 + sta FAC1_mantissa+0 + + // Copy the sign + + lda FAC2_sign + sta FAC1_sign + + // Copy the exponent + + lda FAC2_exponent + sta FAC1_exponent + + // Clear FACOV + + ldx #$00 + stx FACOV + + rts diff --git a/c64/basic/math/mov_MEM_FAC1.s b/c64/basic/math/mov_MEM_FAC1.s new file mode 100644 index 00000000..f99cb9ee --- /dev/null +++ b/c64/basic/math/mov_MEM_FAC1.s @@ -0,0 +1,79 @@ +// #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 + +// 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 + + 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 + + // Copy the mantissa + + ldy #$04 + lda (INDEX), y + sta FAC1_mantissa+3 + + dey + lda (INDEX), y + sta FAC1_mantissa+2 + + dey + lda (INDEX), y + sta FAC1_mantissa+1 + + dey + lda (INDEX), y + ora #$80 // clear the sign bit + sta FAC1_mantissa+0 + + // Copy the sign + + lda (INDEX), y + bpl !+ // assumption: non-negative numbers are more frequent + lda #$FF + skip_2_bytes_trash_nvz +!: + lda #$00 + + sta FAC1_sign + + // 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 + + sty FACOV + + // Return the FAC1 exponent + + lda FAC1_exponent + rts diff --git a/c64/basic/math/mov_MEM_FAC2.s b/c64/basic/math/mov_MEM_FAC2.s new file mode 100644 index 00000000..f461a667 --- /dev/null +++ b/c64/basic/math/mov_MEM_FAC2.s @@ -0,0 +1,77 @@ +// #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 +// + +// 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 + + 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 + + // Copy the mantissa + + ldy #$04 + lda (INDEX), y + sta FAC2_mantissa+3 + + dey + lda (INDEX), y + sta FAC2_mantissa+2 + + dey + lda (INDEX), y + sta FAC2_mantissa+1 + + dey + lda (INDEX), y + ora #$80 // clear the sign bit + sta FAC2_mantissa+0 + + // Copy the sign + + lda (INDEX), y + bpl !+ // assumption: non-negative numbers are more frequent + lda #$FF + skip_2_bytes_trash_nvz +!: + lda #$00 + + sta FAC2_sign + + // Copy the exponent + + dey + lda (INDEX), y + sta FAC2_exponent + + // Return the FAC1 exponent + + lda FAC1_exponent + rts diff --git a/c64/basic/math/mov_r_FAC1_TMP1.s b/c64/basic/math/mov_r_FAC1_TMP1.s new file mode 100644 index 00000000..7edcf115 --- /dev/null +++ b/c64/basic/math/mov_r_FAC1_TMP1.s @@ -0,0 +1,18 @@ +// #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 +// + +mov_r_FAC1_TMP1: + + ldy #$00 + ldx #$5C + + jmp mov_r_FAC1_MEM diff --git a/c64/basic/math/mov_r_FAC1_TMP2.s b/c64/basic/math/mov_r_FAC1_TMP2.s new file mode 100644 index 00000000..3897d02a --- /dev/null +++ b/c64/basic/math/mov_r_FAC1_TMP2.s @@ -0,0 +1,18 @@ +// #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 +// + +mov_r_FAC1_TMP2: + + ldy #$00 + ldx #$57 + + jmp mov_r_FAC1_MEM diff --git a/c64/basic/math/mul_FAC2_FAC1.s b/c64/basic/math/mul_FAC2_FAC1.s new file mode 100644 index 00000000..35b71b39 --- /dev/null +++ b/c64/basic/math/mul_FAC2_FAC1.s @@ -0,0 +1,90 @@ +// #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 +// + +// XXX provide implementation + +mul_FAC2_FAC1: + + // First handle special case of multiplying by 0 + + lda FAC1_exponent + beq mul_FAC2_FAC1_done + + lda FAC2_exponent + bne !+ + sta FAC1_exponent + beq mul_FAC2_FAC1_done +!: + // Multiply signs + + lda FAC1_sign + eor FAC2_sign + sta FAC1_sign + + // Check if exponents can be added without overflow/underflow + + lda FAC1_exponent + and #$80 + eor FAC2_exponent + + bmi mul_FAC2_FAC1_add_exponents // exponent signs are opposite, we can add them safely + + // Both exponents are either negative (below $80), or both are non-negative ($80 or above), + // try to add them + + lda FAC1_exponent + clc + adc FAC2_exponent + bpl mul_FAC2_FAC1_sub_exp_bias // branch if we can add values + + // We cannot add them, result would over/underflow; set result as + // either 0 or maximum possible float + + lda FAC1_exponent + bmi_16 set_FAC1_max + + lda #$00 + sta FAC1_exponent + rts + +mul_FAC2_FAC1_add_exponents: + + // Add the exponents + + lda FAC1_exponent + clc + adc FAC2_exponent + + // FALLTROUGH + +mul_FAC2_FAC1_sub_exp_bias: + + sec + sbc #$80 // bias + sta FAC1_exponent + + // Multiply the mantissas + + // XXX + + STUB_IMPLEMENTATION() + +mul_FAC2_FAC1_done: + + rts diff --git a/c64/basic/math/normal_FAC1.s b/c64/basic/math/normal_FAC1.s new file mode 100644 index 00000000..5dc96fa5 --- /dev/null +++ b/c64/basic/math/normal_FAC1.s @@ -0,0 +1,102 @@ +// #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 +// + +// XXX test this + +normal_FAC1: + + lda FAC1_exponent + beq normal_FAC1_end // branch if our float is 0 + + // FALLTROUGH + +normal_FAC1_check_mantissa_byte: + + lda FAC1_mantissa+0 + beq normal_FAC1_by_byte // branch if we can move the whole byte + + // FALLTROUGH + +normal_FAC1_check_mantissa_bit: + + lda FAC1_mantissa+0 // XXX optimize for 65CE02? + and #$80 + bne normal_FAC1_end // branch if already normalized + + // FALLTROUGH + +normal_FAC1_by_bit: + + // Decrement the exponent + + dec FAC1_exponent + beq normal_FAC1_end // exponent reached 0, nothing more to do + + // Multiply the mantissa by 2 + + clc + rol FACOV + rol FAC1_mantissa+3 + rol FAC1_mantissa+2 + rol FAC1_mantissa+1 + rol FAC1_mantissa+0 + + 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 + + lda FAC1_exponent + sec + sbc #$08 + bcs !+ + lda #$00 +!: + sta FAC1_exponent + beq normal_FAC1_end // branch if our float reached 0 + + // Now multiply the mantissa by 8 by moving the whole bytes + + lda FAC1_mantissa+1 + sta FAC1_mantissa+0 + lda FAC1_mantissa+2 + sta FAC1_mantissa+1 + lda FAC1_mantissa+3 + sta FAC1_mantissa+2 + + lda FACOV + sta FAC1_mantissa+3 + + lda #$00 + sta FACOV + + // 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 + + // Our mantissa reached 0 - mark exponent as 0 and finish + + sta FAC1_exponent + + // FALLTROUGH + +normal_FAC1_end: + + rts diff --git a/c64/basic/math/rnd_seed_from_FAC1.s b/c64/basic/math/rnd_seed_from_FAC1.s new file mode 100644 index 00000000..0a288ca2 --- /dev/null +++ b/c64/basic/math/rnd_seed_from_FAC1.s @@ -0,0 +1,27 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Initialize random seed using values from FAC1, +// afterwards generate random number in FAC1 +// + +rnd_seed_from_FAC1: + + lda FAC1_mantissa+0 + sta RNDX+4 + + eor FAC1_mantissa+1 + sta RNDX+3 + + eor FAC1_mantissa+2 + sta RNDX+2 + + eor FAC1_mantissa+3 + sta RNDX+1 + + eor FAC1_exponent + sta RNDX+0 + + jmp rnd_generate diff --git a/c64/basic/math/rnd_seed_init.s b/c64/basic/math/rnd_seed_init.s new file mode 100644 index 00000000..56f0a13c --- /dev/null +++ b/c64/basic/math/rnd_seed_init.s @@ -0,0 +1,33 @@ +// #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 +// + +rnd_seed_init: + + 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 + sta RNDX+1 + + tya // .Y might contain some entropy + eor CIA1_TIMAHI + sta RNDX+4 + + lda TIME+0 // 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 + sta RNDX+2 + + // RNDX+0 will be overwritten by generator + + jmp rnd_generate diff --git a/c64/basic/math/round_FAC1.s b/c64/basic/math/round_FAC1.s new file mode 100644 index 00000000..7cef4a05 --- /dev/null +++ b/c64/basic/math/round_FAC1.s @@ -0,0 +1,61 @@ +// #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 +// + +// XXX test this + +round_FAC1: + + // 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 + + // 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! + + inc FAC1_mantissa+3 + bne round_FAC1_zero_FACOV + inc FAC1_mantissa+2 + bne round_FAC1_zero_FACOV + inc FAC1_mantissa+1 + bne round_FAC1_zero_FACOV + 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 + + 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 + + dec FAC1_exponent + + // FALLTROUGH + +round_FAC1_zero_FACOV: + + lda #$00 + sta FACOV + + // FALLTROUGH + +round_FAC1_done: + + rts diff --git a/c64/basic/math_consts/aea8.const_PI.s b/c64/basic/math_consts/aea8.const_PI.s new file mode 100644 index 00000000..d86c1687 --- /dev/null +++ b/c64/basic/math_consts/aea8.const_PI.s @@ -0,0 +1,14 @@ +// #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 +// + +const_PI: + + put_const_PI() diff --git a/c64/basic/math_consts/aea8.interop b/c64/basic/math_consts/aea8.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/aea8.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b1a5.const_NEG_32768.s b/c64/basic/math_consts/b1a5.const_NEG_32768.s new file mode 100644 index 00000000..c45694fa --- /dev/null +++ b/c64/basic/math_consts/b1a5.const_NEG_32768.s @@ -0,0 +1,14 @@ +// #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 +// + +CONST_NEG_32768: + + put_const_NEG_32768() diff --git a/c64/basic/math_consts/b1a5.interop b/c64/basic/math_consts/b1a5.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b1a5.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b9bc.const_ONE.s b/c64/basic/math_consts/b9bc.const_ONE.s new file mode 100644 index 00000000..38997280 --- /dev/null +++ b/c64/basic/math_consts/b9bc.const_ONE.s @@ -0,0 +1,14 @@ +// #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 +// + +const_ONE: + + put_const_ONE() diff --git a/c64/basic/math_consts/b9bc.interop b/c64/basic/math_consts/b9bc.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b9bc.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b9d6.const_INV_SQR_2.s b/c64/basic/math_consts/b9d6.const_INV_SQR_2.s new file mode 100644 index 00000000..e3733683 --- /dev/null +++ b/c64/basic/math_consts/b9d6.const_INV_SQR_2.s @@ -0,0 +1,13 @@ +// #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 +// + +const_INV_SQR_2: + + put_const_INV_SQR_2() diff --git a/c64/basic/math_consts/b9d6.interop b/c64/basic/math_consts/b9d6.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b9d6.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b9db.const_SQR_2.s b/c64/basic/math_consts/b9db.const_SQR_2.s new file mode 100644 index 00000000..ab9d0a51 --- /dev/null +++ b/c64/basic/math_consts/b9db.const_SQR_2.s @@ -0,0 +1,13 @@ +// #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 +// + +const_SQR_2: + + put_const_SQR_2() diff --git a/c64/basic/math_consts/b9db.interop b/c64/basic/math_consts/b9db.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b9db.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b9e0.const_NEG_HALF.s b/c64/basic/math_consts/b9e0.const_NEG_HALF.s new file mode 100644 index 00000000..0227e546 --- /dev/null +++ b/c64/basic/math_consts/b9e0.const_NEG_HALF.s @@ -0,0 +1,13 @@ +// #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 +// + +const_NEG_HALF: + + put_const_NEG_HALF() diff --git a/c64/basic/math_consts/b9e0.interop b/c64/basic/math_consts/b9e0.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b9e0.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/b9e5.const_LOG_2.s b/c64/basic/math_consts/b9e5.const_LOG_2.s new file mode 100644 index 00000000..559d1861 --- /dev/null +++ b/c64/basic/math_consts/b9e5.const_LOG_2.s @@ -0,0 +1,13 @@ +// #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 +// + +const_LOG_2: + + put_const_LOG_2() diff --git a/c64/basic/math_consts/b9e5.interop b/c64/basic/math_consts/b9e5.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/b9e5.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/baf9.const_TEN.s b/c64/basic/math_consts/baf9.const_TEN.s new file mode 100644 index 00000000..e2610722 --- /dev/null +++ b/c64/basic/math_consts/baf9.const_TEN.s @@ -0,0 +1,14 @@ +// #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 +// + +const_TEN: + + put_const_TEN() diff --git a/c64/basic/math_consts/baf9.interop b/c64/basic/math_consts/baf9.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/baf9.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/bf11.const_HALF.s b/c64/basic/math_consts/bf11.const_HALF.s new file mode 100644 index 00000000..15e1f801 --- /dev/null +++ b/c64/basic/math_consts/bf11.const_HALF.s @@ -0,0 +1,14 @@ +// #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 +// + +const_HALF: + + put_const_HALF() diff --git a/c64/basic/math_consts/bf11.interop b/c64/basic/math_consts/bf11.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/bf11.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/bfbf.const_INV_LOG_2.s b/c64/basic/math_consts/bfbf.const_INV_LOG_2.s new file mode 100644 index 00000000..07d97253 --- /dev/null +++ b/c64/basic/math_consts/bfbf.const_INV_LOG_2.s @@ -0,0 +1,13 @@ +// #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 +// + +const_INV_LOG_2: + + put_const_INV_LOG_2() diff --git a/c64/basic/math_consts/bfbf.interop b/c64/basic/math_consts/bfbf.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/bfbf.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/bfe8.const_ONE.s b/c64/basic/math_consts/bfe8.const_ONE.s new file mode 100644 index 00000000..bea746ee --- /dev/null +++ b/c64/basic/math_consts/bfe8.const_ONE.s @@ -0,0 +1,11 @@ +// #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 +// + + put_const_ONE() // duplicated constant - no label diff --git a/c64/basic/math_consts/bfe8.interop b/c64/basic/math_consts/bfe8.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/bfe8.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e2e0.const_HALF_PI.s b/c64/basic/math_consts/e2e0.const_HALF_PI.s new file mode 100644 index 00000000..a75efb68 --- /dev/null +++ b/c64/basic/math_consts/e2e0.const_HALF_PI.s @@ -0,0 +1,12 @@ +// #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 +// + +const_HALF_PI: + + put_const_HALF_PI() diff --git a/c64/basic/math_consts/e2e0.interop b/c64/basic/math_consts/e2e0.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2e0.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s b/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s new file mode 100644 index 00000000..f8728ef7 --- /dev/null +++ b/c64/basic/math_consts/e2e5.const_DOUBLE_PI.s @@ -0,0 +1,12 @@ +// #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 +// + +const_DOUBLE_PI: + + put_const_DOUBLE_PI() diff --git a/c64/basic/math_consts/e2e5.interop b/c64/basic/math_consts/e2e5.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2e5.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e2ea.const_QUARTER.s b/c64/basic/math_consts/e2ea.const_QUARTER.s new file mode 100644 index 00000000..77962d8a --- /dev/null +++ b/c64/basic/math_consts/e2ea.const_QUARTER.s @@ -0,0 +1,12 @@ +// #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 +// + +const_QUARTER: + + put_const_QUARTER() \ No newline at end of file diff --git a/c64/basic/math_consts/e2ea.interop b/c64/basic/math_consts/e2ea.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e2ea.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/math_consts/e309.const_DOUBLE_PI.s b/c64/basic/math_consts/e309.const_DOUBLE_PI.s new file mode 100644 index 00000000..33a01f1b --- /dev/null +++ b/c64/basic/math_consts/e309.const_DOUBLE_PI.s @@ -0,0 +1,10 @@ +// #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 +// + + put_const_DOUBLE_PI() // duplicated constant - no label diff --git a/c64/basic/math_consts/e309.interop b/c64/basic/math_consts/e309.interop new file mode 100644 index 00000000..cdf8d0e7 --- /dev/null +++ b/c64/basic/math_consts/e309.interop @@ -0,0 +1 @@ +A well-known floating-point constant, has to be at the same place or we risk hard to debug improper calculation results. diff --git a/c64/basic/rom_revision/a004.identifier.s b/c64/basic/rom_revision/a004.identifier.s index 2edea486..5d780247 100644 --- a/c64/basic/rom_revision/a004.identifier.s +++ b/c64/basic/rom_revision/a004.identifier.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/basic/rom_revision/bf52.rom_revision_basic.s b/c64/basic/rom_revision/bf52.rom_revision_basic.s index 91438dac..c3920eea 100644 --- a/c64/basic/rom_revision/bf52.rom_revision_basic.s +++ b/c64/basic/rom_revision/bf52.rom_revision_basic.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000 // #LAYOUT# * BASIC_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/assets/cartridge_signature.s b/c64/kernal/assets/cartridge_signature.s index c6aabb98..92a3b776 100644 --- a/c64/kernal/assets/cartridge_signature.s +++ b/c64/kernal/assets/cartridge_signature.s @@ -1,9 +1,9 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE cartridge_signature: .byte $C3,$C2,$CD,$38,$30 - - -#endif // ROM layout diff --git a/c64/kernal/assets/e8da.colour_codes.s b/c64/kernal/assets/e8da.colour_codes.s index 89849a12..003171f3 100644 --- a/c64/kernal/assets/e8da.colour_codes.s +++ b/c64/kernal/assets/e8da.colour_codes.s @@ -1,10 +1,10 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + // CHR$ codes for the 16 colours colour_codes: .byte 144,5,28,159,156,30,31,158 .byte 129,149,150,151,152,153,154,155 - - -#endif // ROM layout diff --git a/c64/kernal/assets/fd30.vector_defaults.s b/c64/kernal/assets/fd30.vector_defaults.s index 13b01e78..5e008825 100644 --- a/c64/kernal/assets/fd30.vector_defaults.s +++ b/c64/kernal/assets/fd30.vector_defaults.s @@ -1,4 +1,6 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE // // Default values for Kernal vectors - described in: @@ -25,6 +27,3 @@ vector_defaults: .word default_brk_handler // USRCMD .word LOAD // ILOAD .word SAVE // ISAVE - - -#endif // ROM layout diff --git a/c64/kernal/assets/irq_timing_hi.s b/c64/kernal/assets/irq_timing_hi.s index 794dd5cb..b884d60b 100644 --- a/c64/kernal/assets/irq_timing_hi.s +++ b/c64/kernal/assets/irq_timing_hi.s @@ -1,4 +1,6 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE // // Values for IRQ generation timer - original idea was: @@ -22,6 +24,3 @@ irq_timing_hi: // high bytes .byte >17045 // NTSC .byte >16421 // PAL - - -#endif // ROM layout diff --git a/c64/kernal/assets/irq_timing_lo.s b/c64/kernal/assets/irq_timing_lo.s index 2d18d4ec..5043d2ba 100644 --- a/c64/kernal/assets/irq_timing_lo.s +++ b/c64/kernal/assets/irq_timing_lo.s @@ -1,4 +1,6 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE // // Values for IRQ generation timer - original idea was: @@ -22,6 +24,3 @@ irq_timing_lo: // low bytes .byte <17045 // NTSC .byte <16421 // PAL - - -#endif // ROM layout \ No newline at end of file diff --git a/c64/kernal/assets/kernal_messages.s b/c64/kernal/assets/kernal_messages.s index 5f7712b1..3808770d 100644 --- a/c64/kernal/assets/kernal_messages.s +++ b/c64/kernal/assets/kernal_messages.s @@ -1,4 +1,6 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE // // Messages to be prined out by Kernal @@ -111,6 +113,3 @@ __msg_kernalfeatures: .byte $80 + $0D // end of string mark + return #endif // CONFIG_SHOW_FEATURES - - -#endif // ROM layout diff --git a/c64/kernal/keyboard/programmable_keys.s b/c64/kernal/assets/programmable_keys.s similarity index 100% rename from c64/kernal/keyboard/programmable_keys.s rename to c64/kernal/assets/programmable_keys.s diff --git a/c64/kernal/banking/4000.mega65_jumptable_kernal_1.s b/c64/kernal/banking/4000.mega65_jumptable_kernal_1.s deleted file mode 100644 index 001d624e..00000000 --- a/c64/kernal/banking/4000.mega65_jumptable_kernal_1.s +++ /dev/null @@ -1,26 +0,0 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE - -// -// Definitions for communication with Mega65 segment KERNAL_1 -// - - -#if SEGMENT_KERNAL_0 - - // Labels for jumps - - - .label KERNAL_1__RAMTAS = $4000 - - -#else - - // Jumptable (OpenROMs private!) - - - jmp RAMTAS - - -#endif diff --git a/c64/kernal/banking/4000.interop b/c64/kernal/board_m65/4000.interop similarity index 100% rename from c64/kernal/banking/4000.interop rename to c64/kernal/board_m65/4000.interop diff --git a/c64/kernal/board_m65/4000.mega65_vectable_kernal_1.s b/c64/kernal/board_m65/4000.mega65_vectable_kernal_1.s new file mode 100644 index 00000000..6c865009 --- /dev/null +++ b/c64/kernal/board_m65/4000.mega65_vectable_kernal_1.s @@ -0,0 +1,48 @@ +// #LAYOUT# M65 KERNAL_0 #TAKE-FLOAT +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Definitions for communication with Mega65 segment KERNAL_1 from KERNAL_0 +// + + +#if SEGMENT_KERNAL_0 + + // Label definitions + + .label VK1__IOINIT = $4000 + 2 * 0 + .label VK1__RAMTAS = $4000 + 2 * 1 + .label VK1__setup_vicii = $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 + +#else + + // Vector table (OpenROMs private!) + + .word IOINIT + .word RAMTAS + .word setup_vicii + +#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_AUTODETECT + .word load_tape_normal +#else + .word $0000 +#endif + +#if CONFIG_TAPE_TURBO && !CONFIG_TAPE_AUTODETECT + .word load_tape_turbo +#else + .word $0000 +#endif + +#if CONFIG_TAPE_AUTODETECT + .word load_tape_auto +#else + .word $0000 +#endif + + +#endif diff --git a/c64/kernal/board_m65/mega65_imports.s b/c64/kernal/board_m65/mega65_imports.s new file mode 100644 index 00000000..d06b0bdb --- /dev/null +++ b/c64/kernal/board_m65/mega65_imports.s @@ -0,0 +1,57 @@ +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Definitions for calling Mega65 segment KERNAL_0 routines from KERNAL_1 +// + +#import "KERNAL_0_combined.sym" + + +.label STOP = KERNAL_0.STOP +.label clrchn_reset = KERNAL_0.clrchn_reset +.label udtim_keyboard = KERNAL_0.udtim_keyboard + +.label setup_irq_timer = KERNAL_0.setup_irq_timer +.label wait_x_bars = KERNAL_0.wait_x_bars + + +#if CONFIG_IEC + +.label iec_set_idle = KERNAL_0.iec_set_idle + +#endif + + +#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO + +.label screen_on = KERNAL_0.screen_on +.label screen_off = KERNAL_0.screen_off +.label tape_motor_on = KERNAL_0.tape_motor_on +.label tape_motor_off = KERNAL_0.tape_motor_off + +.label lvs_display_loading_verifying = KERNAL_0.proxy_K1_lvs_display_loading_verifying +.label lvs_display_done = KERNAL_0.proxy_K1_lvs_display_done +.label lvs_return_last_address = KERNAL_0.proxy_K1_lvs_return_last_address +.label lvs_device_not_found_error = KERNAL_0.proxy_K1_lvs_device_not_found_error +.label lvs_load_verify_error = KERNAL_0.proxy_K1_lvs_load_verify_error + +.label lvs_check_EAL = KERNAL_0.lvs_check_EAL +.label lvs_STAL_to_MEMUSS = KERNAL_0.lvs_STAL_to_MEMUSS + +.label kernalerror_ROUTINE_TERMINATED = KERNAL_0.proxy_K1_kernalerror_ROUTINE_TERMINATED + +.label print_kernal_message = KERNAL_0.proxy_K1_print_kernal_message +.label print_return = KERNAL_0.proxy_K1_print_return + +.label __MSG_KERNAL_PRESS_PLAY = KERNAL_0.__MSG_KERNAL_PRESS_PLAY +.label __MSG_KERNAL_FOUND = KERNAL_0.__MSG_KERNAL_FOUND + +#endif + + +#if CONFIG_TAPE_NORMAL + +.label tape_normal_byte_store = KERNAL_0.tape_normal_byte_store + +#endif diff --git a/c64/kernal/banking/mega65_map_helpers.s b/c64/kernal/board_m65/mega65_map_helpers.s similarity index 100% rename from c64/kernal/banking/mega65_map_helpers.s rename to c64/kernal/board_m65/mega65_map_helpers.s diff --git a/c64/kernal/board_m65/mega65_proxies.s b/c64/kernal/board_m65/mega65_proxies.s new file mode 100644 index 00000000..94026367 --- /dev/null +++ b/c64/kernal/board_m65/mega65_proxies.s @@ -0,0 +1,59 @@ +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Proxies for calling Mega65 segment KERNAL_0 routines from KERNAL_1 +// + + +#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO + + +proxy_K1_kernalerror_ROUTINE_TERMINATED: + + jsr map_NORMAL + jmp kernalerror_ROUTINE_TERMINATED + + +proxy_K1_lvs_display_loading_verifying: + + jsr map_NORMAL + jsr lvs_display_loading_verifying + jmp map_KERNAL_1 + +proxy_K1_lvs_display_done: + + jsr map_NORMAL + jsr lvs_display_done + jmp map_KERNAL_1 + +proxy_K1_lvs_return_last_address: + + jsr map_NORMAL + jmp lvs_return_last_address + +proxy_K1_lvs_device_not_found_error: + + jsr map_NORMAL + jmp lvs_device_not_found_error + +proxy_K1_lvs_load_verify_error: + + jsr map_NORMAL + jmp lvs_load_verify_error + + +proxy_K1_print_kernal_message: + + jsr map_NORMAL + jsr print_kernal_message + jmp map_KERNAL_1 + +proxy_K1_print_return: + + jsr map_NORMAL + jsr print_return + jmp map_KERNAL_1 + + +#endif diff --git a/c64/kernal/board_m65/mega65_redirect_load_tape.s b/c64/kernal/board_m65/mega65_redirect_load_tape.s new file mode 100644 index 00000000..56061aca --- /dev/null +++ b/c64/kernal/board_m65/mega65_redirect_load_tape.s @@ -0,0 +1,39 @@ +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// ROM routine call redirect for tape loading +// + + +#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_AUTODETECT + +load_tape_normal: + + jsr map_KERNAL_1 + jsr_ind VK1__load_tape_normal + jmp map_NORMAL + +#endif + + +#if CONFIG_TAPE_TURBO && !CONFIG_TAPE_AUTODETECT + +load_tape_turbo: + + jsr map_KERNAL_1 + jsr_ind VK1__load_tape_turbo + jmp map_NORMAL + +#endif + + +#if CONFIG_TAPE_AUTODETECT + +load_tape_auto: + + jsr map_KERNAL_1 + jsr_ind VK1__load_tape_auto + jmp map_NORMAL + +#endif diff --git a/c64/kernal/board_m65/mega65_tape_normal_byte_store.s b/c64/kernal/board_m65/mega65_tape_normal_byte_store.s new file mode 100644 index 00000000..4c8cc13f --- /dev/null +++ b/c64/kernal/board_m65/mega65_tape_normal_byte_store.s @@ -0,0 +1,19 @@ +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Tape (normal) helper routine - byte storage when ban changing is needed +// + + +#if CONFIG_TAPE_NORMAL + + +tape_normal_byte_store: + + jsr map_NORMAL + sta (MEMUSS), y + jmp map_KERNAL_1 + + +#endif diff --git a/c64/kernal/board_x16/cx16_dummy.s b/c64/kernal/board_x16/cx16_dummy.s new file mode 100644 index 00000000..b25fa5cd --- /dev/null +++ b/c64/kernal/board_x16/cx16_dummy.s @@ -0,0 +1,7 @@ +// #LAYOUT# X16 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + + +// Dummy, just to have anything in segment 1 + + brk diff --git a/c64/kernal/board_x16/cx16_stubs.s b/c64/kernal/board_x16/cx16_stubs.s new file mode 100644 index 00000000..da530dd6 --- /dev/null +++ b/c64/kernal/board_x16/cx16_stubs.s @@ -0,0 +1,44 @@ +// #LAYOUT# X16 KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + +// Stubs for Commander X16 support + + +scnkey_set_keytab: + STUB_IMPLEMENTATION() + +clear_screen: + STUB_IMPLEMENTATION() + +setup_vicii: + STUB_IMPLEMENTATION() + +cursor_blink: + STUB_IMPLEMENTATION() + +chrin_keyboard: + STUB_IMPLEMENTATION() + +chrout_screen: + STUB_IMPLEMENTATION() + +IOINIT: + STUB_IMPLEMENTATION() + +SCNKEY: + STUB_IMPLEMENTATION() + +SCREEN: + STUB_IMPLEMENTATION() + +screen_calculate_pointers: + STUB_IMPLEMENTATION() + +setup_pal_ntsc: + STUB_IMPLEMENTATION() + +wait_x_bars: + STUB_IMPLEMENTATION() + +udtim_keyboard: + STUB_IMPLEMENTATION() diff --git a/c64/kernal/errors.s b/c64/kernal/errors.s index 91a85fe0..e1642238 100644 --- a/c64/kernal/errors.s +++ b/c64/kernal/errors.s @@ -6,90 +6,78 @@ // Kernal error codes are described in 'Commodore 64 Programmers Reference Guide', page 306 kernalerror_ROUTINE_TERMINATED: // by a STOP key + lda #K_ERR_ROUTINE_TERMINATED - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_TOO_MANY_OPEN_FILES: + lda #K_ERR_TOO_MANY_OPEN_FILES - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_ALREADY_OPEN: + lda #K_ERR_FILE_ALREADY_OPEN - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_NOT_OPEN: + lda #K_ERR_FILE_NOT_OPEN - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_NOT_FOUND: + lda #K_ERR_FILE_NOT_FOUND - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_DEVICE_NOT_FOUND: + lda #K_ERR_DEVICE_NOT_FOUND - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_NOT_INPUT: + lda #K_ERR_FILE_NOT_INPUT - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_NOT_OUTPUT: + lda #K_ERR_FILE_NOT_OUTPUT - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_FILE_NAME_MISSING: + lda #K_ERR_FILE_NAME_MISSING - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_ILLEGAL_DEVICE_NUMBER: + lda #K_ERR_ILLEGAL_DEVICE_NUMBER - sec - rts + skip_2_bytes_trash_nvz + + // FALLTROUGH kernalerror_TOP_MEM_RS232: + lda #K_ERR_TOP_MEM_RS232 + sec rts - - -// Kernal status codes are described in 'Commodore 64 Programmers Reference Guide', page 292 - -kernalstatus_reset: - lda #$00 - sta IOSTATUS - rts - -// The following two statuses are currently not implemented - and most likely not really needed - -// kernalstatus_TIMEOUT_WRITE: -// lda IOSTATUS -// ora #K_STS_TIMEOUT_WRITE -// sta IOSTATUS -// rts - -// kernalstatus_TIMEOUT_READ: -// lda IOSTATUS -// ora #K_STS_TIMEOUT_READ -// sta IOSTATUS -// rts - -kernalstatus_EOI: - lda IOSTATUS - ora #K_STS_EOI - sta IOSTATUS - rts - -kernalstatus_DEVICE_NOT_FOUND: - lda IOSTATUS - ora #K_STS_DEVICE_NOT_FOUND - sta IOSTATUS - rts diff --git a/c64/kernal/iec/iec_wait1ms.s b/c64/kernal/iec/iec_wait1ms.s index 2b1452fd..f011c292 100644 --- a/c64/kernal/iec/iec_wait1ms.s +++ b/c64/kernal/iec/iec_wait1ms.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/iec/save_iec.s b/c64/kernal/iec/save_iec.s index a90827a7..83dff28b 100644 --- a/c64/kernal/iec/save_iec.s +++ b/c64/kernal/iec/save_iec.s @@ -74,7 +74,7 @@ save_iec: jsr iec_tx_byte #endif - jsr lvs_setup_MEMUSS + jsr lvs_STAL_to_MEMUSS ldy #$00 iec_save_loop: diff --git a/c64/kernal/init/cartridge_check.s b/c64/kernal/init/cartridge_check.s index b47c61e7..3686a7f8 100644 --- a/c64/kernal/init/cartridge_check.s +++ b/c64/kernal/init/cartridge_check.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/init/e5a0.setup_vicii.s b/c64/kernal/init/e5a0.setup_vicii.s index a7a3e4f4..93b54949 100644 --- a/c64/kernal/init/e5a0.setup_vicii.s +++ b/c64/kernal/init/e5a0.setup_vicii.s @@ -1,5 +1,7 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * * #IGNORE // @@ -11,6 +13,14 @@ setup_vicii: +#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) + + jsr map_KERNAL_1 + jsr_ind VK1__setup_vicii + jmp map_NORMAL + +#else + // Clear everything - turn off sprites (observed hanging around after // running programs and resetting), etc. @@ -67,3 +77,5 @@ setup_vicii: // Setup default I/O devices jmp clrchn_reset + +#endif // ROM layout diff --git a/c64/kernal/init/fce2.hw_entry_reset.s b/c64/kernal/init/fce2.hw_entry_reset.s index dbe2c942..0d36a2d6 100644 --- a/c64/kernal/init/fce2.hw_entry_reset.s +++ b/c64/kernal/init/fce2.hw_entry_reset.s @@ -19,6 +19,8 @@ hw_entry_reset: ldx #$FF txs +#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 @@ -29,10 +31,13 @@ hw_entry_reset: bne !+ jmp (ICART_COLD_START) !: + // 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. jsr JIOINIT diff --git a/c64/kernal/init/fd50.ramtas.s b/c64/kernal/init/fd50.ramtas.s index cb135a4a..70a4abc2 100644 --- a/c64/kernal/init/fd50.ramtas.s +++ b/c64/kernal/init/fd50.ramtas.s @@ -1,6 +1,7 @@ // #LAYOUT# STD * #TAKE // #LAYOUT# M65 KERNAL_0 #TAKE // #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +// #LAYOUT# X16 KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE // @@ -16,9 +17,9 @@ RAMTAS: #if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) - jsr map_KERNAL_1 - jsr KERNAL_1__RAMTAS - jmp map_NORMAL + jsr map_KERNAL_1 + jsr_ind VK1__RAMTAS + jmp map_NORMAL #else @@ -48,6 +49,8 @@ RAMTAS: ldx #>$033C stx TAPE1+1 +#if 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, @@ -94,4 +97,19 @@ ramtas_32k: ldy #$80 bne !- // branch always +#elif CONFIG_PLATFORM_COMMANDER_X16 + + ldx #>$0800 + stx MEMSTR+1 + + ldy #$9F + sty MEMSIZK+1 + +#else + + .error "Please fill-in RAMTAS" + +#endif // platform + + #endif // ROM layout diff --git a/c64/kernal/init/fda3.ioinit.s b/c64/kernal/init/fda3.ioinit.s index e0fa1ecd..35d07223 100644 --- a/c64/kernal/init/fda3.ioinit.s +++ b/c64/kernal/init/fda3.ioinit.s @@ -1,5 +1,7 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE-FLOAT +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * * #IGNORE // @@ -14,6 +16,14 @@ IOINIT: +#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) + + jsr map_KERNAL_1 + jsr_ind VK1__IOINIT + jmp map_NORMAL + +#else + // // First initialize the CPU port, to make sure we have correct memory map // @@ -146,3 +156,6 @@ IOINIT: rts #endif + + +#endif // ROM layout diff --git a/c64/kernal/init/setup_pal_ntsc.s b/c64/kernal/init/setup_pal_ntsc.s index ebc22052..52845204 100644 --- a/c64/kernal/init/setup_pal_ntsc.s +++ b/c64/kernal/init/setup_pal_ntsc.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/interrupts/ea31.default_irq_handler.s b/c64/kernal/interrupts/ea31.default_irq_handler.s index 671839a3..6793302b 100644 --- a/c64/kernal/interrupts/ea31.default_irq_handler.s +++ b/c64/kernal/interrupts/ea31.default_irq_handler.s @@ -44,5 +44,13 @@ default_irq_handler_end_tape: #endif // CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO +#if CONFIG_PLATFORM_COMMODORE_64 + // Acknowledge CIA interrupt and return jmp clear_cia1_interrupt_flag_and_return_from_interrupt + +#else + + jmp return_from_interrupt + +#endif diff --git a/c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s b/c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s index 6ba7c968..6d72292d 100644 --- a/c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s +++ b/c64/kernal/interrupts/ea7e.ack_cia1_return_from_interrupt.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/interrupts/fe47.default_nmi_handler.s b/c64/kernal/interrupts/fe47.default_nmi_handler.s index 96a2bccb..5e86373f 100644 --- a/c64/kernal/interrupts/fe47.default_nmi_handler.s +++ b/c64/kernal/interrupts/fe47.default_nmi_handler.s @@ -17,10 +17,15 @@ default_nmi_handler: // XXX confirm NMIs from CIA, or no other NMI will arrive! +#if CONFIG_PLATFORM_COMMODORE_64 + jsr cartridge_check bne !+ jmp (ICART_WARM_START) !: + +#endif + // 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? diff --git a/c64/kernal/interrupts/fe66.default_brk_handler.s b/c64/kernal/interrupts/fe66.default_brk_handler.s index bcec92a5..668462f3 100644 --- a/c64/kernal/interrupts/fe66.default_brk_handler.s +++ b/c64/kernal/interrupts/fe66.default_brk_handler.s @@ -9,9 +9,13 @@ default_brk_handler: sei // disable IRQs, to be sure they wont interfere +#if CONFIG_PLATFORM_COMMODORE_64 + ldx #$00 sta VIC_SCROLX // turn the display off - we want as little screen artifacts as possible +#endif + cld // make sure this dangerous flag is disabled jsr JRESTOR diff --git a/c64/kernal/screen/e50a.interop b/c64/kernal/iostack/e50a.interop similarity index 100% rename from c64/kernal/screen/e50a.interop rename to c64/kernal/iostack/e50a.interop diff --git a/c64/kernal/screen/e50a.plot.s b/c64/kernal/iostack/e50a.plot.s similarity index 100% rename from c64/kernal/screen/e50a.plot.s rename to c64/kernal/iostack/e50a.plot.s diff --git a/c64/kernal/iostack/f4a5.load.s b/c64/kernal/iostack/f4a5.load.s index 7c39a23e..ac201c15 100644 --- a/c64/kernal/iostack/f4a5.load.s +++ b/c64/kernal/iostack/f4a5.load.s @@ -43,19 +43,32 @@ LOAD: // Check whether we support the requested device lda FA + +#if !CONFIG_TAPE_AUTODETECT + #if CONFIG_TAPE_NORMAL cmp #$01 beq_16 load_tape_normal #endif - #if CONFIG_TAPE_TURBO cmp #$07 beq_16 load_tape_turbo #endif +#else // CONFIG_TAPE_AUTODETECT + + cmp #$01 + beq_16 load_tape_auto + cmp #$07 + beq_16 load_tape_auto + +#endif + + #if CONFIG_IEC jsr iec_check_devnum_lvs bcc_16 load_iec #endif + jmp lvs_illegal_device_number diff --git a/c64/kernal/iostack/load_save_common.s b/c64/kernal/iostack/load_save_common.s index 7e6e0fb2..000e88f8 100644 --- a/c64/kernal/iostack/load_save_common.s +++ b/c64/kernal/iostack/load_save_common.s @@ -80,7 +80,7 @@ lvs_handle_byte_verify: #if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC -lvs_setup_MEMUSS: +lvs_STAL_to_MEMUSS: lda STAL+0 sta MEMUSS+0 diff --git a/c64/kernal/keyboard/pop_keyboard_buffer.s b/c64/kernal/iostack/pop_keyboard_buffer.s similarity index 100% rename from c64/kernal/keyboard/pop_keyboard_buffer.s rename to c64/kernal/iostack/pop_keyboard_buffer.s diff --git a/c64/kernal/jumptable/fff3.jiobase.s b/c64/kernal/jumptable/fff3.jiobase.s index 8f0b756b..0af3c7a1 100644 --- a/c64/kernal/jumptable/fff3.jiobase.s +++ b/c64/kernal/jumptable/fff3.jiobase.s @@ -16,6 +16,21 @@ // As there is nothing between here and $FFFA, we can just hard code this in place. // iobase: - commented out to prevent label naming conflict + +#if CONFIG_PLATFORM_COMMODORE_64 + ldy #$DC ldx #$00 + +#elif CONFIG_PLATFORM_COMMANDER_X16 + + ldy #$9F + ldx #$60 + +#else + + .error "Please fill-in IOBASE" + +#endif + rts diff --git a/c64/kernal/keyboard/chrin_keyboard.s b/c64/kernal/keyboard/chrin_keyboard.s index afdf4515..a7ab5e83 100644 --- a/c64/kernal/keyboard/chrin_keyboard.s +++ b/c64/kernal/keyboard/chrin_keyboard.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -24,15 +25,16 @@ chrin_repeat: lda CRSW beq read_from_keyboard - // Yes, we have input waiting at (LXSP)+CRSW + // Yes, we have input waiting at (LSXP)+CRSW // When CRSW = INDX, then we return a carriage return // and clear the flag cmp INDX bne not_end_of_input - // Return carriage return and clear pending input flag + // Return carriage return and clear pending input and quote flags lda #$00 sta CRSW + sta QTSW // FALLTROUGH @@ -53,8 +55,10 @@ not_end_of_input: // Return next byte of waiting tay + chrin_keyboard_return_byte: - lda (LXSP),y + lda (LSXP),y + jsr screen_check_toggle_quote tax ply_trash_a txa @@ -88,20 +92,20 @@ chrin_enter: // Set pointer to line of input lda PNT+0 - sta LXSP+0 + sta LSXP+0 lda PNT+1 - sta LXSP+1 + sta LSXP+1 - // If the current line is a continuation of the previous one, decrease LXSP by 40 + // If the current line is a continuation of the previous one, decrease LSXP by 40 ldy TBLX - lda LDTBL, y + lda LDTB1, y bmi chrin_enter_calc_length // branch if not continuation - lda LXSP+0 + lda LSXP+0 sec sbc #40 - sta LXSP+0 + sta LSXP+0 bcs !+ - dec LXSP+1 + dec LSXP+1 !: ldy #80 bne chrin_enter_loop // branch always @@ -111,23 +115,28 @@ chrin_enter_calc_length: // Calculate length jsr screen_get_logical_line_end_ptr iny - + chrin_enter_loop: // Retrieve bytes dey bmi empty_line - lda (LXSP),y + lda (LSXP),y cmp #$20 beq chrin_enter_loop iny sty INDX - lda #$01 - sta CRSW + + // Set mark informing that we are returning a line + ldy #$01 + sty CRSW + + // Clear quote mode mark + dey // set .Y to 0 + sty QTSW // Return first char of line - ldy #$00 - beq chrin_keyboard_return_byte // branch always + beq chrin_keyboard_return_byte // branch always not_enter: diff --git a/c64/kernal/keyboard/kb_matrix.s b/c64/kernal/keyboard/kb_matrix.s index 57458aae..e194bd95 100644 --- a/c64/kernal/keyboard/kb_matrix.s +++ b/c64/kernal/keyboard/kb_matrix.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_128.s b/c64/kernal/keyboard/kb_matrix_128.s index 9009f8b9..d6323ba6 100644 --- a/c64/kernal/keyboard/kb_matrix_128.s +++ b/c64/kernal/keyboard/kb_matrix_128.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_65.s b/c64/kernal/keyboard/kb_matrix_65.s index eb50d79b..a7cd89f5 100644 --- a/c64/kernal/keyboard/kb_matrix_65.s +++ b/c64/kernal/keyboard/kb_matrix_65.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s b/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s index b49d4943..9ccf1b16 100644 --- a/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s +++ b/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_bucky.s b/c64/kernal/keyboard/kb_matrix_bucky.s index 089ffaef..028721b0 100644 --- a/c64/kernal/keyboard/kb_matrix_bucky.s +++ b/c64/kernal/keyboard/kb_matrix_bucky.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_bucky_filter.s b/c64/kernal/keyboard/kb_matrix_bucky_filter.s index 0c693c5d..70d7251f 100644 --- a/c64/kernal/keyboard/kb_matrix_bucky_filter.s +++ b/c64/kernal/keyboard/kb_matrix_bucky_filter.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_joy.s b/c64/kernal/keyboard/kb_matrix_joy.s index d19644f1..754c341f 100644 --- a/c64/kernal/keyboard/kb_matrix_joy.s +++ b/c64/kernal/keyboard/kb_matrix_joy.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_lookup.s b/c64/kernal/keyboard/kb_matrix_lookup.s index 1d9715fc..bb82cf2c 100644 --- a/c64/kernal/keyboard/kb_matrix_lookup.s +++ b/c64/kernal/keyboard/kb_matrix_lookup.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_lookup_legacy.s b/c64/kernal/keyboard/kb_matrix_lookup_legacy.s index b628921f..da4df653 100644 --- a/c64/kernal/keyboard/kb_matrix_lookup_legacy.s +++ b/c64/kernal/keyboard/kb_matrix_lookup_legacy.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_row_keys.s b/c64/kernal/keyboard/kb_matrix_row_keys.s index 21bab4f5..ce225e80 100644 --- a/c64/kernal/keyboard/kb_matrix_row_keys.s +++ b/c64/kernal/keyboard/kb_matrix_row_keys.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/kb_matrix_row_offsets.s b/c64/kernal/keyboard/kb_matrix_row_offsets.s index 8b0b7d5a..314a0852 100644 --- a/c64/kernal/keyboard/kb_matrix_row_offsets.s +++ b/c64/kernal/keyboard/kb_matrix_row_offsets.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/keyboard_disconnect.s b/c64/kernal/keyboard/keyboard_disconnect.s index 5fb2bf73..98c0150b 100644 --- a/c64/kernal/keyboard/keyboard_disconnect.s +++ b/c64/kernal/keyboard/keyboard_disconnect.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 003b38e5..12161598 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/scnkey_128.s b/c64/kernal/keyboard/scnkey_128.s index 48945214..fd00cddc 100644 --- a/c64/kernal/keyboard/scnkey_128.s +++ b/c64/kernal/keyboard/scnkey_128.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/scnkey_65.s b/c64/kernal/keyboard/scnkey_65.s index 34584b72..8518c837 100644 --- a/c64/kernal/keyboard/scnkey_65.s +++ b/c64/kernal/keyboard/scnkey_65.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/scnkey_legacy.s b/c64/kernal/keyboard/scnkey_legacy.s index 42dae86f..d5ab27d2 100644 --- a/c64/kernal/keyboard/scnkey_legacy.s +++ b/c64/kernal/keyboard/scnkey_legacy.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/scnkey_set_keytab.s b/c64/kernal/keyboard/scnkey_set_keytab.s index c1da0a66..77ad45aa 100644 --- a/c64/kernal/keyboard/scnkey_set_keytab.s +++ b/c64/kernal/keyboard/scnkey_set_keytab.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/keyboard/udtim_keyboard.s b/c64/kernal/keyboard/udtim_keyboard.s index 35d6724a..d1c8c74e 100644 --- a/c64/kernal/keyboard/udtim_keyboard.s +++ b/c64/kernal/keyboard/udtim_keyboard.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/memory/membot.s b/c64/kernal/memory/membot.s index 0da97fdc..0a9987ea 100644 --- a/c64/kernal/memory/membot.s +++ b/c64/kernal/memory/membot.s @@ -1,4 +1,6 @@ -#if ROM_LAYOUT_STD || (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE // // Official Kernal routine, described in: @@ -24,6 +26,3 @@ membot_set: stx MEMSTR+0 rts - - -#endif // ROM layout diff --git a/c64/kernal/screen/chrout_screen.s b/c64/kernal/screen/chrout_screen.s index 356816d0..5118c854 100644 --- a/c64/kernal/screen/chrout_screen.s +++ b/c64/kernal/screen/chrout_screen.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -85,13 +86,8 @@ chrout_screen_literal: // Toggle quote flag if required txa - cmp #$22 - bne !+ + jsr screen_check_toggle_quote - lda QTSW - eor #$80 - sta QTSW -!: // Set colour of the newly printed character lda COLOR diff --git a/c64/kernal/screen/chrout_screen_clr.s b/c64/kernal/screen/chrout_screen_clr.s index 7da09ca6..e2860ce5 100644 --- a/c64/kernal/screen/chrout_screen_clr.s +++ b/c64/kernal/screen/chrout_screen_clr.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_control.s b/c64/kernal/screen/chrout_screen_control.s index 7f93c521..8100db55 100644 --- a/c64/kernal/screen/chrout_screen_control.s +++ b/c64/kernal/screen/chrout_screen_control.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_crsr.s b/c64/kernal/screen/chrout_screen_crsr.s index cb276f41..819c8a9a 100644 --- a/c64/kernal/screen/chrout_screen_crsr.s +++ b/c64/kernal/screen/chrout_screen_crsr.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_del.s b/c64/kernal/screen/chrout_screen_del.s index 5cfaaa07..807e4b79 100644 --- a/c64/kernal/screen/chrout_screen_del.s +++ b/c64/kernal/screen/chrout_screen_del.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -12,6 +13,7 @@ chrout_screen_DEL: // In insert mode it embeds control character ldx INSRT beq !+ + lda #KEY_DEL jmp chrout_screen_quote !: ldy PNTR diff --git a/c64/kernal/screen/chrout_screen_gfxtxt.s b/c64/kernal/screen/chrout_screen_gfxtxt.s index 9f326e43..04d73c04 100644 --- a/c64/kernal/screen/chrout_screen_gfxtxt.s +++ b/c64/kernal/screen/chrout_screen_gfxtxt.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_home.s b/c64/kernal/screen/chrout_screen_home.s index 4f0e3d05..353429f4 100644 --- a/c64/kernal/screen/chrout_screen_home.s +++ b/c64/kernal/screen/chrout_screen_home.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_ins.s b/c64/kernal/screen/chrout_screen_ins.s index 74be6b2a..0e3eed38 100644 --- a/c64/kernal/screen/chrout_screen_ins.s +++ b/c64/kernal/screen/chrout_screen_ins.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -25,7 +26,7 @@ chrout_screen_ins_possible: // Special handling for cursor in second line ldx TBLX - lda LDTBL+0, x + lda LDTB1+0, x bpl chrout_screen_ins_second_line // Perform character copy diff --git a/c64/kernal/screen/chrout_screen_jumptable_codes.s b/c64/kernal/screen/chrout_screen_jumptable_codes.s index 4e494b4d..66e56e74 100644 --- a/c64/kernal/screen/chrout_screen_jumptable_codes.s +++ b/c64/kernal/screen/chrout_screen_jumptable_codes.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -22,6 +23,7 @@ chrout_screen_jumptable_codes: .byte KEY_CRSR_LEFT .byte KEY_CRSR_DOWN .byte KEY_CRSR_UP + .byte KEY_INS __chrout_screen_jumptable_quote_guard: @@ -32,7 +34,6 @@ __chrout_screen_jumptable_quote_guard: .byte KEY_TAB_BW .byte KEY_TAB_FW #endif - .byte KEY_INS .byte KEY_DEL .byte KEY_RETURN @@ -55,6 +56,7 @@ chrout_screen_jumptable_lo: .byte <(chrout_screen_CRSR_LEFT - 1) .byte <(chrout_screen_CRSR_DOWN - 1) .byte <(chrout_screen_CRSR_UP - 1) + .byte <(chrout_screen_INS - 1) #if CONFIG_EDIT_STOPQUOTE .byte <(chrout_screen_STOP - 1) #endif @@ -62,7 +64,6 @@ chrout_screen_jumptable_lo: .byte <(chrout_screen_TAB_BW - 1) .byte <(chrout_screen_TAB_FW - 1) #endif - .byte <(chrout_screen_INS - 1) .byte <(chrout_screen_DEL - 1) .byte <(chrout_screen_RETURN - 1) @@ -80,6 +81,7 @@ chrout_screen_jumptable_hi: .byte >(chrout_screen_CRSR_LEFT - 1) .byte >(chrout_screen_CRSR_DOWN - 1) .byte >(chrout_screen_CRSR_UP - 1) + .byte >(chrout_screen_INS - 1) #if CONFIG_EDIT_STOPQUOTE .byte >(chrout_screen_STOP - 1) #endif @@ -87,13 +89,14 @@ chrout_screen_jumptable_hi: .byte >(chrout_screen_TAB_BW - 1) .byte >(chrout_screen_TAB_FW - 1) #endif - .byte >(chrout_screen_INS - 1) .byte >(chrout_screen_DEL - 1) .byte >(chrout_screen_RETURN - 1) #else -.if (mod(*, $2) == 1) { nop } // align code so that vector never crosses page boundary +__before_chrout_screen_jumptable: + +.if (mod(*, $2) == 1) { brk } // align code so that vector never crosses page boundary chrout_screen_jumptable: @@ -109,6 +112,7 @@ chrout_screen_jumptable: .word chrout_screen_CRSR_LEFT .word chrout_screen_CRSR_DOWN .word chrout_screen_CRSR_UP + .word chrout_screen_INS #if CONFIG_EDIT_STOPQUOTE .word chrout_screen_STOP #endif @@ -116,10 +120,11 @@ chrout_screen_jumptable: .word chrout_screen_TAB_BW .word chrout_screen_TAB_FW #endif - .word chrout_screen_INS .word chrout_screen_DEL .word chrout_screen_RETURN -.if (mod(*, $2) == 0) { nop } // make sure routine size is always the same, needed by build system + // Make sure routine size is always the same - build system limitation + +.if (__before_chrout_screen_jumptable == chrout_screen_jumptable) { brk } #endif diff --git a/c64/kernal/screen/chrout_screen_quote.s b/c64/kernal/screen/chrout_screen_quote.s index 8bbe2440..245450ab 100644 --- a/c64/kernal/screen/chrout_screen_quote.s +++ b/c64/kernal/screen/chrout_screen_quote.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_return.s b/c64/kernal/screen/chrout_screen_return.s index 4148dda6..93a28a19 100644 --- a/c64/kernal/screen/chrout_screen_return.s +++ b/c64/kernal/screen/chrout_screen_return.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -23,7 +24,7 @@ chrout_screen_RETURN: cpy #24 beq !+ // last line on screen - no need for a double line skip - lda LDTBL+1, y + lda LDTB1+1, y bmi !+ // current line is not continued inc TBLX diff --git a/c64/kernal/screen/chrout_screen_rvs.s b/c64/kernal/screen/chrout_screen_rvs.s index 3cb679ae..47dce95f 100644 --- a/c64/kernal/screen/chrout_screen_rvs.s +++ b/c64/kernal/screen/chrout_screen_rvs.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_shift_onoff.s b/c64/kernal/screen/chrout_screen_shift_onoff.s index 7ecbbe2a..24369ada 100644 --- a/c64/kernal/screen/chrout_screen_shift_onoff.s +++ b/c64/kernal/screen/chrout_screen_shift_onoff.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_stop.s b/c64/kernal/screen/chrout_screen_stop.s index 3c638032..d44654f6 100644 --- a/c64/kernal/screen/chrout_screen_stop.s +++ b/c64/kernal/screen/chrout_screen_stop.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/chrout_screen_tab.s b/c64/kernal/screen/chrout_screen_tab.s index 13634dc9..6ca12662 100644 --- a/c64/kernal/screen/chrout_screen_tab.s +++ b/c64/kernal/screen/chrout_screen_tab.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/cursor.s b/c64/kernal/screen/cursor.s index 15b460d2..7021133a 100644 --- a/c64/kernal/screen/cursor.s +++ b/c64/kernal/screen/cursor.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/cursor_enable.s b/c64/kernal/screen/cursor_enable.s index 155f28b4..d5322360 100644 --- a/c64/kernal/screen/cursor_enable.s +++ b/c64/kernal/screen/cursor_enable.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/cursor_show.s b/c64/kernal/screen/cursor_show.s index e96987aa..d700679f 100644 --- a/c64/kernal/screen/cursor_show.s +++ b/c64/kernal/screen/cursor_show.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/e544.clear_screen.s b/c64/kernal/screen/e544.clear_screen.s index e80029ca..8c3abe1d 100644 --- a/c64/kernal/screen/e544.clear_screen.s +++ b/c64/kernal/screen/e544.clear_screen.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -16,9 +17,9 @@ clear_screen: // continuation of the previous one lda #$80 - ldy #24 + ldy #24 !: - sta LDTBL,y + sta LDTB1,y dey bpl !- diff --git a/c64/kernal/screen/e566.cursor_home.s b/c64/kernal/screen/e566.cursor_home.s index 0e22fe78..782f5189 100644 --- a/c64/kernal/screen/e566.cursor_home.s +++ b/c64/kernal/screen/e566.cursor_home.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/e56c.screen_calculate_pointers.s b/c64/kernal/screen/e56c.screen_calculate_pointers.s index 591862c6..cb4194b9 100644 --- a/c64/kernal/screen/e56c.screen_calculate_pointers.s +++ b/c64/kernal/screen/e56c.screen_calculate_pointers.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/e8ea.screen_scroll_up.s b/c64/kernal/screen/e8ea.screen_scroll_up.s index fb3f262e..7d4712d4 100644 --- a/c64/kernal/screen/e8ea.screen_scroll_up.s +++ b/c64/kernal/screen/e8ea.screen_scroll_up.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -46,18 +47,18 @@ screen_scroll_up: screen_scroll_up_delay_done: // entry point for cursor move control codes - // Scroll the LDTBL (line link table) + // Scroll the LDTB1 (line link table) ldy #$00 !: - lda LDTBL+1, y - sta LDTBL+0, y + lda LDTB1+1, y + sta LDTB1+0, y iny cpy #24 bne !- lda #$80 - sta LDTBL+24 + sta LDTB1+24 // Preserve SAL and EAL, prepare initial SAL/EAL/PNT/USER values @@ -125,7 +126,7 @@ screen_scroll_up_loop_done: // If the first line is linked, scroll once more - bit LDTBL+0 + bit LDTB1+0 bpl screen_scroll_up // Recalculate PNT and USER diff --git a/c64/kernal/screen/e9ff.screen_clear_line.s b/c64/kernal/screen/e9ff.screen_clear_line.s index 6dc1f915..4611a575 100644 --- a/c64/kernal/screen/e9ff.screen_clear_line.s +++ b/c64/kernal/screen/e9ff.screen_clear_line.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen.s b/c64/kernal/screen/screen.s index 2d3611df..6b98bdb3 100644 --- a/c64/kernal/screen/screen.s +++ b/c64/kernal/screen/screen.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_advance_to_next_line.s b/c64/kernal/screen/screen_advance_to_next_line.s index c711e292..eb02bc8b 100644 --- a/c64/kernal/screen/screen_advance_to_next_line.s +++ b/c64/kernal/screen/screen_advance_to_next_line.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_calculate_pnt_user.s b/c64/kernal/screen/screen_calculate_pnt_user.s index ce477aa3..4fc409fa 100644 --- a/c64/kernal/screen/screen_calculate_pnt_user.s +++ b/c64/kernal/screen/screen_calculate_pnt_user.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_calculate_pntr_lnmx.s b/c64/kernal/screen/screen_calculate_pntr_lnmx.s index 7b4e7f5f..75c31643 100644 --- a/c64/kernal/screen/screen_calculate_pntr_lnmx.s +++ b/c64/kernal/screen/screen_calculate_pntr_lnmx.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -11,7 +12,7 @@ screen_calculate_PNTR_LNMX: ldy TBLX - lda LDTBL, y + lda LDTB1, y php jsr screen_get_clipped_PNTR plp @@ -37,14 +38,14 @@ screen_calculate_PNTR_0_39: screen_calculate_LNMX: ldy TBLX - lda LDTBL, y + lda LDTB1, y 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 iny - lda LDTBL, y + lda LDTB1, y bpl screen_calculate_lnmx_79 // line is continued // FALLTROUGH diff --git a/c64/kernal/screen/screen_check_space_ends_line.s b/c64/kernal/screen/screen_check_space_ends_line.s index a482dc9e..7c1243b5 100644 --- a/c64/kernal/screen/screen_check_space_ends_line.s +++ b/c64/kernal/screen/screen_check_space_ends_line.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_check_toggle_quote.s b/c64/kernal/screen/screen_check_toggle_quote.s new file mode 100644 index 00000000..255f1d19 --- /dev/null +++ b/c64/kernal/screen/screen_check_toggle_quote.s @@ -0,0 +1,21 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Helper routine - check character in .A, toggles quote flag if needed +// + +screen_check_toggle_quote: + + cmp #$22 + bne !+ + + lda QTSW + eor #$80 + sta QTSW + + lda #$22 // restore previous .A valuee +!: + rts diff --git a/c64/kernal/screen/screen_code_to_petscii.s b/c64/kernal/screen/screen_code_to_petscii.s index 7a76aae3..e19aad58 100644 --- a/c64/kernal/screen/screen_code_to_petscii.s +++ b/c64/kernal/screen/screen_code_to_petscii.s @@ -1,40 +1,72 @@ // #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: - cmp #$1B - bcc s2p_adc_40 - -s2p_not_alpha: + + cmp #$20 + bcc s2p_adc_40 // $00-$1F -> $40-$5F + cmp #$40 - bcc s2p_end + bcc s2p_end // $20-$3F -> $20-$3F - // FALLTROUGH - -s2p_not_punctuation: - cmp #$5B - bcs s2p_not_shifted - - // carry already clear here - adc #$80 - - rts - -s2p_not_shifted: + cmp #$60 + bcc s2p_adc_80 // $40-$5F -> $C0-$DF cmp #$80 - bcs s2p_end // not vendor + bcc s2p_adc_40 // $60-$7F -> $A0-$BF - // $60-$7F -> $A0-$BF + // Here we have to check for quote mode + + bit QTSW + bmi screen_code_to_petscii_quote + + // Not quote mode - continue + + cmp #$A0 + bcc s2p_adc_C0 // $80-$9F -> $40-$5F + + cmp #$C0 + bcc s2p_adc_80 // $A0-$BF -> $20-$3F + + cmp #$E0 + bcc s2p_end // $C0-$DF -> $C0-$DF + + clc + bcc s2p_adc_C0 // $E0-$FF -> $A0-$BF s2p_adc_40: - clc - adc #$40 - - // FALLTROUGH + adc #$40 // Carry already clear s2p_end: + + rts + +s2p_adc_80: + + adc #$80 // Carry already clear + rts + +screen_code_to_petscii_quote: + + cmp #$C0 + bcc s2p_adc_80 // $80-$BF -> $00-$3F + + clc + + // FALLTROUGH $C0-$FF -> $80-$BF + +s2p_adc_C0: + + adc #$C0 // Carry already clear rts diff --git a/c64/kernal/screen/screen_get_cliped_pntr.s b/c64/kernal/screen/screen_get_cliped_pntr.s index 761ffd92..355499fb 100644 --- a/c64/kernal/screen/screen_get_cliped_pntr.s +++ b/c64/kernal/screen/screen_get_cliped_pntr.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_get_logical_line_end_ptr.s b/c64/kernal/screen/screen_get_logical_line_end_ptr.s index e54bdd3d..d52dbc75 100644 --- a/c64/kernal/screen/screen_get_logical_line_end_ptr.s +++ b/c64/kernal/screen/screen_get_logical_line_end_ptr.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -9,10 +10,10 @@ screen_get_logical_line_end_ptr: cpy #24 bcs screen_get_logical_line_end_39 // last line of the screen - lda LDTBL+0, y + lda LDTB1+0, y bpl screen_get_logical_line_end_39 // current line continues previous one - lda LDTBL+1, y + lda LDTB1+1, y bmi screen_get_logical_line_end_39 // current line is not continued // FALLTROUGH diff --git a/c64/kernal/screen/screen_grow_logical_line.s b/c64/kernal/screen/screen_grow_logical_line.s index 92654151..b7e5acc6 100644 --- a/c64/kernal/screen/screen_grow_logical_line.s +++ b/c64/kernal/screen/screen_grow_logical_line.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE @@ -25,7 +26,7 @@ screen_grow_logical_line: // Do not grow line if previus one is grown ldy TBLX - lda LDTBL+0, y + lda LDTB1+0, y bpl screen_grow_logical_line_done_scroll // If last line, scroll the screen up @@ -33,22 +34,22 @@ screen_grow_logical_line: beq screen_grow_logical_line_screen_up // Do not grow line if already grown - lda LDTBL+1, y + lda LDTB1+1, y bpl screen_grow_logical_line_done // Preserve SAL and EAL jsr screen_preserve_sal_eal - // Scroll LDTBL down (start from the end) + // Scroll LDTB1 down (start from the end) ldy #23 !: cpy TBLX beq !+ bcc !+ - lda LDTBL+0, y - sta LDTBL+1, y + lda LDTB1+0, y + sta LDTB1+1, y dey bne !- @@ -56,7 +57,7 @@ screen_grow_logical_line: // Mark current line as grown ldy TBLX lda #$00 - sta LDTBL+1, y + 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 diff --git a/c64/kernal/screen/screen_off.s b/c64/kernal/screen/screen_off.s index 154ce86f..f7ef6d62 100644 --- a/c64/kernal/screen/screen_off.s +++ b/c64/kernal/screen/screen_off.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_on.s b/c64/kernal/screen/screen_on.s index 24e70a1b..6d49d4a4 100644 --- a/c64/kernal/screen/screen_on.s +++ b/c64/kernal/screen/screen_on.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_preserve_sal_eal.s b/c64/kernal/screen/screen_preserve_sal_eal.s index e4f7f55f..a576cbab 100644 --- a/c64/kernal/screen/screen_preserve_sal_eal.s +++ b/c64/kernal/screen/screen_preserve_sal_eal.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/screen/screen_restore_sal_eal.s b/c64/kernal/screen/screen_restore_sal_eal.s index fd8648c5..6f10b390 100644 --- a/c64/kernal/screen/screen_restore_sal_eal.s +++ b/c64/kernal/screen/screen_restore_sal_eal.s @@ -1,4 +1,5 @@ // #LAYOUT# STD * #TAKE +// #LAYOUT# X16 * #IGNORE // #LAYOUT# * KERNAL_0 #TAKE // #LAYOUT# * * #IGNORE diff --git a/c64/kernal/status.s b/c64/kernal/status.s new file mode 100644 index 00000000..39747d00 --- /dev/null +++ b/c64/kernal/status.s @@ -0,0 +1,42 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + + +// Kernal status codes are described in 'Commodore 64 Programmers Reference Guide', page 292 + +kernalstatus_reset: + lda #$00 + beq kernalstatus_end // branch always + +// The following two statuses are currently not implemented - and most likely not really needed + +// kernalstatus_TIMEOUT_WRITE: +// +// lda IOSTATUS +// ora #K_STS_TIMEOUT_WRITE +// bne kernalstatus_end // branch always + +// kernalstatus_TIMEOUT_READ: +// +// lda IOSTATUS +// ora #K_STS_TIMEOUT_READ +// bne kernalstatus_end // branch always + +kernalstatus_EOI: + + lda IOSTATUS + ora #K_STS_EOI + bne kernalstatus_end // branch always + +kernalstatus_DEVICE_NOT_FOUND: + + lda IOSTATUS + ora #K_STS_DEVICE_NOT_FOUND + + // FALLTROUGH + +kernalstatus_end: + + sta IOSTATUS + rts diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index f1ae13fa..c53dabdb 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -33,67 +33,66 @@ // (L,S) = end-of-data marker -// XXX use pilot to calibrate reading speed -// XXX add error correction - - #if CONFIG_TAPE_NORMAL +#if !CONFIG_TAPE_AUTODETECT + load_tape_normal: jsr tape_ditch_verify // only LOAD is supported, no VERIFY -#if CONFIG_TAPE_AUTODETECT - - // Prepare for sound effects in case of turbo takeover - jsr tape_clean_sid - -#endif - // Start playing jsr tape_common_prepare_cia jsr tape_ask_play -#if CONFIG_TAPE_AUTODETECT - - // FALLTROUGH - -load_tape_normal_takeover: // entry point for turbo->normal takeover - - jsr tape_common_autodetect - bcs_16 load_tape_turbo_takeover - -#endif - - // Temporarily store MEMUSS in EAL - - lda MEMUSS+1 - sta EAL+1 - lda MEMUSS+0 - sta EAL+0 - // FALLTROUGH load_tape_normal_header: - // Try to load header into tape buffer +#else - lda TAPE1+1 - sta MEMUSS+1 - lda TAPE1+0 - sta MEMUSS+0 +load_tape_normal_takeover: // entry point for turbo->normal takeover - // Retrieve the header +#endif - jsr tape_normal_pilot_header - ldy #$C1 // size limit (including checksum) - jsr tape_normal_get_data + jsr load_MEMUSS_to_STAL + + // 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 + + 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 !+ +load_tape_normal_switch_turbo: + jsr lvs_STAL_to_MEMUSS + jmp load_tape_turbo_takeover // unable to read block, try turbo instead +!: +#endif + +#if CONFIG_TAPE_NO_ERROR_CORRECTION + lda RIPRTY + cmp #$01 // sets Carry if checksum verification fails +#else + jsr load_TAPE1_to_MEMUSS + jsr tape_normal_get_data_2 +#endif +#if !CONFIG_TAPE_AUTODETECT + bcs load_tape_normal_header // block load error, try again +#else + bcs load_tape_normal_switch_turbo // block load error, try turbo instead +#endif // Check header type - ldy #$00 // XXX probably can be optimized for 65C02 + ldy #$00 lda (TAPE1),y cmp #$05 @@ -102,24 +101,24 @@ load_tape_normal_header: cmp #$01 beq !+ 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 + bne load_tape_normal_takeover +#endif lda #$01 sta SA // this file is non-relocatable; override secondary address with 1 !: - // Handle the header - - // Restore MEMUSS - - lda EAL+1 - sta MEMUSS+1 - lda EAL+0 - sta MEMUSS+0 - - // Handle the header + // 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 + bcs load_tape_normal_takeover +#endif // FALLTROUGH @@ -127,15 +126,44 @@ load_tape_normal_payload: // Retrieve data - jsr tape_normal_pilot_data + jsr tape_normal_get_pilot_data ldy #$00 // no data size limit - jsr tape_normal_get_data + jsr tape_normal_get_data_1 bcs_16 tape_load_error jsr lvs_check_EAL bne_16 tape_load_error // amount of data read does not match header info +#if CONFIG_TAPE_NO_ERROR_CORRECTION + lda RIPRTY + cmp #$01 // sets Carry if checksum verification fails +#else + jsr lvs_STAL_to_MEMUSS + jsr tape_normal_get_data_2 +#endif + bcs_16 tape_load_error + jmp tape_load_success + +load_TAPE1_to_MEMUSS: // set MEMUSS (start address) as tape buffer + + lda TAPE1+1 + sta MEMUSS+1 + lda TAPE1+0 + sta MEMUSS+0 + + rts + +load_MEMUSS_to_STAL: // preserve MEMUSS + + lda MEMUSS+1 + sta STAL+1 + lda MEMUSS+0 + sta STAL+0 + + rts + + #endif diff --git a/c64/kernal/tape/load_tape_turbo.s b/c64/kernal/tape/load_tape_turbo.s index fa470180..7c421e90 100644 --- a/c64/kernal/tape/load_tape_turbo.s +++ b/c64/kernal/tape/load_tape_turbo.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -14,8 +14,16 @@ #if CONFIG_TAPE_TURBO +#if !CONFIG_TAPE_AUTODETECT + load_tape_turbo: +#else + +load_tape_auto: + +#endif + jsr tape_ditch_verify // only LOAD is supported, no VERIFY // Prepare for sound effects @@ -29,7 +37,7 @@ load_tape_turbo: #if CONFIG_TAPE_AUTODETECT -load_tape_turbo_takeover: // entry point for turbo->normal takeover +load_tape_turbo_takeover: // entry point for normal->turbo takeover jsr tape_common_autodetect bcc_16 load_tape_normal_takeover diff --git a/c64/kernal/tape/tape_common.s b/c64/kernal/tape/tape_common.s index e2461a05..94d125b0 100644 --- a/c64/kernal/tape/tape_common.s +++ b/c64/kernal/tape/tape_common.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -179,7 +179,7 @@ tape_handle_header: !: // Setup MEMUSS (see Mapping the C64, page 36) - jsr lvs_setup_MEMUSS + jsr lvs_STAL_to_MEMUSS // Print LOADING and start address diff --git a/c64/kernal/tape/tape_common_autodetect.s b/c64/kernal/tape/tape_common_autodetect.s index 86fefe92..5ea9aebe 100644 --- a/c64/kernal/tape/tape_common_autodetect.s +++ b/c64/kernal/tape/tape_common_autodetect.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -8,9 +8,6 @@ // Carry clear - normal, Carry set - turbo // -// XXX implement fallback to autodetection in normal - - #if CONFIG_TAPE_AUTODETECT @@ -38,13 +35,13 @@ tape_common_autodetect_retry: sta XSAV ldy #$60 // $60 pulses cover 12 bytes of turbo recording - jsr tape_normal_get_pulse // first pulse might be a garbage, ignore it + jsr tape_common_get_pulse // first pulse might be a garbage, ignore it // FALLTROUGH tape_common_autodetect_loop: - jsr tape_normal_get_pulse // read pulse for detection attempt + jsr tape_common_get_pulse // read pulse for detection attempt // If garbage found, retry detection cmp #$28 diff --git a/c64/kernal/tape/tape_common_clean_sid.s b/c64/kernal/tape/tape_common_clean_sid.s index 80b4bbee..a320faef 100644 --- a/c64/kernal/tape/tape_common_clean_sid.s +++ b/c64/kernal/tape/tape_common_clean_sid.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // diff --git a/c64/kernal/tape/tape_common_ditch_verify.s b/c64/kernal/tape/tape_common_ditch_verify.s index 3fa1fcbb..b7d21d8a 100644 --- a/c64/kernal/tape/tape_common_ditch_verify.s +++ b/c64/kernal/tape/tape_common_ditch_verify.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // diff --git a/c64/kernal/tape/tape_common_get_pulse.s b/c64/kernal/tape/tape_common_get_pulse.s new file mode 100644 index 00000000..b194ccd7 --- /dev/null +++ b/c64/kernal/tape/tape_common_get_pulse.s @@ -0,0 +1,33 @@ +// #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 +// + + +#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO + + +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 + + 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 + + cmp __pulse_threshold // sdefault pulse check + rts + + +#endif diff --git a/c64/kernal/tape/tape_common_prepare_cia.s b/c64/kernal/tape/tape_common_prepare_cia.s index 0fda0555..d4d6302c 100644 --- a/c64/kernal/tape/tape_common_prepare_cia.s +++ b/c64/kernal/tape/tape_common_prepare_cia.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -7,7 +7,7 @@ // // -// Checked under VICE, PAL, average of 256 pulses: XXX retry measurements for NORMAL, something is probably wrong +// Checked under VICE, PAL, average of 256 pulses: // // normal - short - timer goes down to $A5 // normal - medium - timer goes down to $7D diff --git a/c64/kernal/tape/tape_common_screen.s b/c64/kernal/tape/tape_common_screen.s index fe2742ac..aaf7a150 100644 --- a/c64/kernal/tape/tape_common_screen.s +++ b/c64/kernal/tape/tape_common_screen.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // diff --git a/c64/kernal/tape/tape_normal_calibrate.s b/c64/kernal/tape/tape_normal_calibrate.s new file mode 100644 index 00000000..71201c5c --- /dev/null +++ b/c64/kernal/tape/tape_normal_calibrate.s @@ -0,0 +1,126 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Tape (normal) helper routine - reading speed calibration +// +// Needs pulse length in .A +// + + +#if CONFIG_TAPE_NORMAL + + +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 + + lda #$FF + sec + sbc __normal_time_S + + // We now have a difference from the starting point ($FF) + + clc + ror + sta __normal_time_M // this is temporary only! + + // 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 + + clc + adc #$05 + sta __normal_time_M // estimated medium pulse length + + jmp tape_normal_calibrate_common + + + +tape_normal_calibrate_after_S: // recalibration after short pulse + + sta __normal_time_S + rts + skip_2_bytes_trash_nvz + + // FALLTROUGH + +tape_normal_calibrate_after_M: // recalibration after medium pulse + + sta __normal_time_M + + // FALLTROUGH + +tape_normal_calibrate_common: + + // Now compare results with current threshold + + lda __normal_time_S + sec + sbc __pulse_threshold + clc + adc __normal_time_M + + cmp __pulse_threshold + + beq tape_normal_calibrate_done // branch if no recalibration needed + + // Correct the thresholds (default is $91 for the S/M one) + + bcs tape_normal_calibrate_threshold_inc // branch if .A >= memory + + // FALLTROUGH + + +tape_normal_calibrate_threshold_dec: + + lda __pulse_threshold + cmp #($91-10) + bcc tape_normal_calibrate_done // do not decrement thresholds too far + + sec + sbc #$02 + sta __pulse_threshold + + lda __pulse_threshold_ML + sec + sbc #$03 + sta __pulse_threshold_ML + + 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 + + clc + adc #$02 + sta __pulse_threshold + + lda __pulse_threshold_ML + clc + adc #$03 + sta __pulse_threshold_ML + + // FALLTROUGH + + +tape_normal_calibrate_done: + + rts + + +#endif diff --git a/c64/kernal/tape/tape_normal_get_bit.s b/c64/kernal/tape/tape_normal_get_bit.s index a092daa1..96ab54d4 100644 --- a/c64/kernal/tape/tape_normal_get_bit.s +++ b/c64/kernal/tape/tape_normal_get_bit.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -16,17 +16,20 @@ tape_normal_get_bit: // Fetch the first pulse - jsr tape_normal_get_pulse + jsr tape_common_get_pulse bcc tape_normal_get_bit_1 // First impulse was short, second should be medium - jsr tape_normal_get_pulse + jsr tape_normal_calibrate_after_S + + jsr tape_common_get_pulse bcs tape_normal_get_bit_error + jsr tape_normal_calibrate_after_M + // We have a bit '0' - // Carry flag already clear lda #$00 // FALLTROUGH @@ -34,6 +37,7 @@ tape_normal_get_bit: tape_normal_get_bit_done: sta VIC_EXTCOL + clc rts @@ -41,9 +45,13 @@ tape_normal_get_bit_1: // First impulse was medium, second should be short - jsr tape_normal_get_pulse + jsr tape_normal_calibrate_after_M + + jsr tape_common_get_pulse bcc tape_normal_get_bit_error + jsr tape_normal_calibrate_after_S + // We have a bit '1' clc diff --git a/c64/kernal/tape/tape_normal_get_byte.s b/c64/kernal/tape/tape_normal_get_byte.s index 98c98ee1..35e18bec 100644 --- a/c64/kernal/tape/tape_normal_get_byte.s +++ b/c64/kernal/tape/tape_normal_get_byte.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // diff --git a/c64/kernal/tape/tape_normal_get_data.s b/c64/kernal/tape/tape_normal_get_data.s deleted file mode 100644 index 780c85ac..00000000 --- a/c64/kernal/tape/tape_normal_get_data.s +++ /dev/null @@ -1,76 +0,0 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE - -// -// Tape (normal) helper routine - data block 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) - - -// XXX improve error handling - do not ignore second copy, handle damaged sync part - - -#if CONFIG_TAPE_NORMAL - - -tape_normal_get_data: - - // Store block size limit - sty XSAV - - // Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) - lda #$00 - sta RIPRTY - - // Read sync of the block - ldy #$89 - jsr tape_normal_sync - bcs tape_normal_get_block_done - jsr tape_normal_get_marker - -tape_normal_get_data_loop: - - jsr tape_normal_get_byte - bcs tape_normal_get_block_done // error reading byte - fatal for now - jsr tape_normal_get_marker - bcs tape_normal_get_checksum // end of data for the block - - // Store byte, calculate checksum - lda INBIT - ldy #$00 - sta (MEMUSS), y - eor RIPRTY - sta RIPRTY - - // Advance pointer -#if !HAS_OPCODES_65CE02 - jsr lvs_advance_MEMUSS -#else - inw MEMUSS+0 -#endif - - // Check block length limit - lda XSAV - beq tape_normal_get_data_loop // no limit requested - dec XSAV - bne tape_normal_get_data_loop - - sec - rts - -tape_normal_get_checksum: // XXX handle second copy, with pilot starting from $09 - - lda INBIT - eor RIPRTY - cmp #$01 // sets Carry if checksum verification fails - - // FALLTROUGH - -tape_normal_get_block_done: - - rts - - -#endif diff --git a/c64/kernal/tape/tape_normal_get_data_1.s b/c64/kernal/tape/tape_normal_get_data_1.s new file mode 100644 index 00000000..fd1242c6 --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_data_1.s @@ -0,0 +1,121 @@ +// #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) + + +// XXX improve error handling - do not ignore second copy, handle damaged sync part + + +#if 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 + lda #$00 + sta RIPRTY +#if !CONFIG_TAPE_NO_ERROR_CORRECTION + sta PTR2 + sta PTR1 +#endif + + // FALLTROUGH + +tape_normal_get_data_1_block: + + // + // Read the 1st copy of the block + // + + // Read sync of the block + ldy #$89 + jsr tape_normal_sync + bcs tape_normal_get_data_1_fail + jsr tape_normal_get_marker + +tape_normal_get_data_1_loop: + + jsr tape_normal_get_byte + bcc tape_normal_get_data_1_loop_byte_OK + +#if CONFIG_TAPE_NO_ERROR_CORRECTION + + bcs tape_normal_get_data_1_fail + +#else + + // Problem reading a byte, try to add it to the error log + + 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 + + ldx PTR1 + lda MEMUSS+0 + sta STACK, x + inx + lda MEMUSS+1 + sta STACK, x + inx + stx PTR1 + + // 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 + +#endif + +tape_normal_get_data_1_loop_byte_OK: + + jsr tape_normal_get_marker + bcc !+ + + // End of the block + jsr tape_normal_update_checksum + jmp tape_normal_get_data_1_success + +!: + // Store byte, calculate checksum + lda INBIT + ldy #$00 +#if ROM_LAYOUT_M65 + jsr tape_normal_byte_store +#else + sta (MEMUSS), y +#endif + jsr tape_normal_update_checksum + + // FALLTROUGH + +tape_normal_get_data_1_loop_advance: + + // Advance pointer +#if !HAS_OPCODES_65CE02 + jsr lvs_advance_MEMUSS +#else + inw MEMUSS+0 +#endif + + jmp tape_normal_get_data_1_loop + + +tape_normal_get_data_1_success: + + clc + rts + +tape_normal_get_data_1_fail: + + sec + rts + + +#endif diff --git a/c64/kernal/tape/tape_normal_get_data_2.s b/c64/kernal/tape/tape_normal_get_data_2.s new file mode 100644 index 00000000..cf2a3763 --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_data_2.s @@ -0,0 +1,124 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Tape (normal) helper routine - data block (backup) reading +// + + +#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_NO_ERROR_CORRECTION + + +tape_normal_get_data_2: + + // First check if there is a need to read anything + + lda PTR1 + beq tape_normal_get_data_2_log_checksum + + // Read sync of the block + + ldy #$09 + jsr tape_normal_sync + bcs tape_normal_get_data_2_done // Carry already set, will indicate error + jsr tape_normal_get_marker + + // FALLTROUGH + +tape_normal_get_data_2_loop: + + // Check if there are missing bytes to read + lda PTR1 + cmp PTR2 + beq tape_normal_get_data_2_log_checksum // branch if no more errors to correct + + // Read missing bytes + + jsr tape_normal_get_byte + bcc tape_normal_get_data_2_loop_byte_OK + + // 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 + + jsr tape_normal_get_marker + 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 + + jsr tape_normal_get_marker + bcs !+ + + lda INBIT + ldy #$00 +#if ROM_LAYOUT_M65 + jsr tape_normal_byte_store +#else + sta (MEMUSS), y +#endif +!: + jsr tape_normal_update_checksum + + // FALLTROUGH + +tape_normal_get_data_2_loop_advance: + + // Advance pointer +#if !HAS_OPCODES_65CE02 + jsr lvs_advance_MEMUSS +#else + inw MEMUSS+0 +#endif + + jmp tape_normal_get_data_2_loop + + +tape_normal_get_data_2_log_checksum: + + lda PTR1 + cmp PTR2 + bne tape_normal_get_data_2_done // Carry already set + + // Validate checksum + + lda RIPRTY + cmp #$01 // sets Carry if checksum verification fails + + // FALLTROUGH + +tape_normal_get_data_2_done: + + rts + + +load_cmp_log_MEMUSS: + + ldx PTR2 + lda STACK+0, x + cmp MEMUSS+0 + bne !+ + + lda STACK+1, x + cmp MEMUSS+1 + bne !+ + + // MEMUSS matches address from the log + + inc PTR2 + inc PTR2 + lda #$00 // to set Zero flag +!: + rts + + +#endif diff --git a/c64/kernal/tape/tape_normal_get_marker.s b/c64/kernal/tape/tape_normal_get_marker.s index 4106214c..2055c581 100644 --- a/c64/kernal/tape/tape_normal_get_marker.s +++ b/c64/kernal/tape/tape_normal_get_marker.s @@ -1,26 +1,53 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // // Tape (normal) helper routine - marker reading // -// Reeturns marker type in Carry flag, set = end of data +// Reeturns marker type in Carry flag, set = end of data (normal marker) or failure (marker while sync) // #if CONFIG_TAPE_NORMAL + // (L,M) - end of byte, (L,S) - end of data -tape_normal_get_marker: + +tape_normal_get_marker: + + + jsr tape_common_get_pulse + cmp __pulse_threshold_ML + bcs tape_normal_get_marker // too short for a long pulse + + // FALLTROUGH + +tape_normal_get_marker_type: + + jmp tape_common_get_pulse + + + +!: // Not an entry point!!! + + // XXX check for short pulses of turbo here + + jsr tape_normal_calibrate_during_pilot // while sync use short pulses for calibration + + // FALLTROUGH + +tape_normal_get_marker_while_sync: // (L,M) - end of byte, (L,S) - end of data - jsr tape_normal_get_pulse - cmp #($FF - $98 - $04) - bcs tape_normal_get_marker // too short for a long pulse + jsr tape_common_get_pulse + bcs !- // branch if short pulse - jmp tape_normal_get_pulse + cmp __pulse_threshold_ML + bcs tape_normal_get_marker_while_sync // too short for a long pulse + + bcc tape_normal_get_marker_type // branch always #endif diff --git a/c64/kernal/tape/tape_normal_get_pilot.s b/c64/kernal/tape/tape_normal_get_pilot.s new file mode 100644 index 00000000..214a7e1f --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_pilot.s @@ -0,0 +1,93 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// 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 + + +#if CONFIG_TAPE_NORMAL + + +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 + + lda #$91 + sta __pulse_threshold + lda #$67 + sta __pulse_threshold_ML + + lda #$80 + skip_2_bytes_trash_nvz + + // FALLTROUGH + +tape_normal_get_pilot_data: // entry point, require 4x $40 pulses + + lda #$04 + skip_2_bytes_trash_nvz + + // FALLTROUGH + +tape_normal_get_pilot_short: // entry point, require 1x $40 pulses + + lda #$01 + + // FALLTROUGH + +tape_normal_get_pilot_common: + + sta FSBLK + + lda #$0B + sta VIC_EXTCOL + + // FALLTROUGH + +tape_normal_get_pilot_common_restart: + + lda FSBLK + sta ROPRTY + + // FALLTROUGH + +tape_normal_get_pilot_common_loop_outer: + + ldy #$40 + + // 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 + +#if CONFIG_TAPE_AUTODETECT + // Try to distinguish turbo by cheecking for short signals + cmp #$B9 // see comment in tape_common_autodetect.s + bcs !+ +#endif + + jsr tape_normal_calibrate_during_pilot + + dey + bne tape_normal_get_pilot_common_loop_inner + + dec ROPRTY + bne tape_normal_get_pilot_common_loop_outer + + clc +!: + rts + + +#endif diff --git a/c64/kernal/tape/tape_normal_get_pulse.s b/c64/kernal/tape/tape_normal_get_pulse.s deleted file mode 100644 index ac4a1f02..00000000 --- a/c64/kernal/tape/tape_normal_get_pulse.s +++ /dev/null @@ -1,44 +0,0 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE - -// -// Tape (normal) helper routine - pulse reading -// -// Returns pulse length (with a bias, see comments) in .A -// - - -#if CONFIG_TAPE_NORMAL - - -tape_normal_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 - - 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 - - // Since the signal appeared to the point of timer restart we used: - // bit - 4 cycles - // beq - 2 cycles - // lda - 4 cycles - // ldx - 2 cycles - // stx - 4 cycles - // plus average 3 cycles (bit + beq time divided by 2) from value change to 'bit' instruction - // minus average 2 cycles due to timer A running continouslyy (might start before the pulse) - // this is total 17 cycles, or $4 periods of 4 ticks (timer A) each - we need to take it into account - // every time we check the pulse length - - cmp #($FF - $72 - $04) // short vs medium is the default check - rts - - -#endif diff --git a/c64/kernal/tape/tape_normal_pilot.s b/c64/kernal/tape/tape_normal_pilot.s deleted file mode 100644 index 0ea7dff7..00000000 --- a/c64/kernal/tape/tape_normal_pilot.s +++ /dev/null @@ -1,78 +0,0 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE - -// -// 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 - - -#if CONFIG_TAPE_NORMAL - - - -tape_normal_pilot_short: // require 1x $40 pulses - - lda #$01 - - // FALLTROUGH - -tape_normal_pilot_common: - - sta FSBLK - - // FALLTROUGH - -tape_normal_pilot_common_restart: - - lda #$0B - sta VIC_EXTCOL - - lda FSBLK - sta ROPRTY - - // FALLTROUGH - -tape_normal_pilot_common_loop_outer: - - ldy #$40 - - // FALLTROUGH - -tape_normal_pilot_common_loop_inner: - - jsr tape_normal_get_pulse - bcc tape_normal_pilot_common_restart // not a pilot - try again - - dey - bne tape_normal_pilot_common_loop_inner - - dec ROPRTY - bne tape_normal_pilot_common_loop_outer - - rts - - - -tape_normal_pilot_data: // require 4x $40 pulses - - lda #$04 - - skip_2_bytes_trash_nvz - - // FALLTROUGH - -tape_normal_pilot_header: // require 128x $40 pulses - - lda #$80 - - jmp tape_normal_pilot_common // XXX calibrate tape speed afterwards - - -#endif diff --git a/c64/kernal/tape/tape_normal_sync.s b/c64/kernal/tape/tape_normal_sync.s index 65310ab8..e7ba9eb9 100644 --- a/c64/kernal/tape/tape_normal_sync.s +++ b/c64/kernal/tape/tape_normal_sync.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -19,7 +19,7 @@ tape_normal_sync: // Injest bytes of decreasing values - jsr tape_normal_get_marker + jsr tape_normal_get_marker_while_sync bcs tape_normal_sync_fail // branch if end of data marker jsr tape_normal_get_byte diff --git a/c64/kernal/tape/tape_normal_update_checksum.s b/c64/kernal/tape/tape_normal_update_checksum.s new file mode 100644 index 00000000..8b60d534 --- /dev/null +++ b/c64/kernal/tape/tape_normal_update_checksum.s @@ -0,0 +1,22 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Tape (normal) helper routine - checksum calculation +// + + +#if CONFIG_TAPE_NORMAL + + +tape_normal_update_checksum: + + lda INBIT + eor RIPRTY + sta RIPRTY + + rts + + +#endif diff --git a/c64/kernal/tape/tape_turbo_bytestore.s b/c64/kernal/tape/tape_turbo_bytestore.s index aa70358c..03bd41f6 100644 --- a/c64/kernal/tape/tape_turbo_bytestore.s +++ b/c64/kernal/tape/tape_turbo_bytestore.s @@ -1,12 +1,14 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // // Tape (turbo) helper routine - storing byte uder I/O // +// Has to preserve .A and .Y +// -// This helper routine is meant to be copiet to the start of CPU stack. +// 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, @@ -16,13 +18,20 @@ #if CONFIG_TAPE_TURBO -.label __tape_turbo_bytestore = STACK +#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 tape_turbo_bytestore_source: +#if ROM_LAYOUT_M65 + jsr KERNAL_0.map_NORMAL +#endif + // Set all memory as RAM, tape motor ON ldx #$00 stx CPU_R6510 @@ -34,8 +43,13 @@ tape_turbo_bytestore_source: 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 rts +#endif __tape_turbo_bytestore_source_end: diff --git a/c64/kernal/tape/tape_turbo_get_bit.s b/c64/kernal/tape/tape_turbo_get_bit.s index e636772a..a903a4d5 100644 --- a/c64/kernal/tape/tape_turbo_get_bit.s +++ b/c64/kernal/tape/tape_turbo_get_bit.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -14,29 +14,13 @@ tape_turbo_get_bit: - -#if CONFIG_TAPE_NORMAL - jsr tape_normal_get_pulse // reuse routine from NORMAL system - -#else - - 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 - -#endif - - cmp SYNO // threshold + jsr tape_common_get_pulse bcs !+ clc ror - sta IRQTMP+0 // 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 sta SID_SIGVOL @@ -47,7 +31,7 @@ tape_turbo_get_bit: !: clc ror - sta IRQTMP+1 // 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 sta SID_SIGVOL diff --git a/c64/kernal/tape/tape_turbo_get_byte.s b/c64/kernal/tape/tape_turbo_get_byte.s index 7dfe6d66..6d4753b2 100644 --- a/c64/kernal/tape/tape_turbo_get_byte.s +++ b/c64/kernal/tape/tape_turbo_get_byte.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -28,28 +28,28 @@ tape_turbo_get_byte: // Compensate for tape speed variations - lda IRQTMP+0 // half of the last value for bit '0' + lda __turbo_half_S // half of the last value for bit '0' clc - adc IRQTMP+1 // half of the last value for bit '1' + adc __turbo_half_L // half of the last value for bit '1' sec - sbc SYNO // now we have a diff between current threshold and calculated one + 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 !+ - lda SYNO + lda __pulse_threshold cmp #($BF - 10) beq tape_turbo_get_byte_done // do not decrease threshold too far no matter what - dec SYNO + dec __pulse_threshold bne tape_turbo_get_byte_done // branch always !: - lda SYNO + lda __pulse_threshold cmp #($BF + 10) beq tape_turbo_get_byte_done // do not increase threshold too far no matter what - inc SYNO + inc __pulse_threshold tape_turbo_get_byte_done: diff --git a/c64/kernal/tape/tape_turbo_sync.s b/c64/kernal/tape/tape_turbo_sync.s index d283c733..81106fb0 100644 --- a/c64/kernal/tape/tape_turbo_sync.s +++ b/c64/kernal/tape/tape_turbo_sync.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // @@ -17,7 +17,7 @@ tape_turbo_sync_header: // Initial pulse threshold lda #$BF // measured 128 bits '0' and 128 bits '1' under VICE, calculated average - sta SYNO + sta __pulse_threshold // Synchronize with start of sync sequence jsr tape_turbo_sync_first diff --git a/c64/kernal/tape/tape_turbo_sync_first.s b/c64/kernal/tape/tape_turbo_sync_first.s index caa4bff2..4e200bb9 100644 --- a/c64/kernal/tape/tape_turbo_sync_first.s +++ b/c64/kernal/tape/tape_turbo_sync_first.s @@ -1,5 +1,5 @@ // #LAYOUT# STD * #TAKE -// #LAYOUT# * KERNAL_0 #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# * * #IGNORE // diff --git a/doc/Development.md b/doc/Development.md index 24760240..68cd49c6 100644 --- a/doc/Development.md +++ b/doc/Development.md @@ -85,10 +85,11 @@ List of the most important make targets: ### Code segments and ROM layouts -Currently there are 2 ROM layouts defined: +Currently there are 3 ROM layouts defined: - `STD` - with 2 code segments: `BASIC` (`$A000-$E4D2`, where `$C000-$DFFF` is a skip-gap for RAM and I/O area) and `KERNAL` (`$E4D3 - $FFFF`) -- `M65` - where `BASIC` becames `BASIC_0` and `KERNAL` becames `KERNAL_0`, additional segments might be added to the build system in the future; at the moment of writing this document additional 8KB of ROM is defined as `KERNAL_1` segment +- `M65` - where `BASIC` becames `BASIC_0` and `KERNAL` becames `KERNAL_0`, additional segments might be added to the build system in the future; at the moment of writing this document additional 8KB of ROM is defined as `BASIC_1` segment and additional 8KB of ROM is defined as `KERNAL_1` segment +- `X16` - memory layout for the Commander X16 machine To check for current ROM layout or code segment use KickAssembler preprocessor defines, like `ROM_LAYOUT_STD`, `ROM_LAYOUT_M65`, `SEGMENT_BASIC`, `SEGMENT_KERNAL_1`. @@ -107,7 +108,7 @@ File name of the fixed location routine adheres to the scheme: `addr.name.s`, wh For handling different ROM layouts, our build tool provides support for pragma-like comments, in the form: ``` -// #LAYOUT# +// #LAYOUT# ``` where: @@ -117,11 +118,12 @@ where: - `` - `KERNAL`, `BASIC`, `KERNAL_0`, `KERNAL_1`, etc., asterisk symbol can be used to match any segment - `` - what to do when layout and segment match: -| action | description | -| :------------ | :-------------------------------------------- | -| `#IGNORE` | ignore the file completely | -| `#TAKE` | compile the file normally | -| `#TAKE-FLOAT` | compile the file, but force it to be floating | +| action | description | +| :------------- | :----------------------------------------------------------------- | +| `#IGNORE` | ignore the file completely | +| `#TAKE` | compile the file normally | +| `#TAKE-FLOAT` | compile the file, but force it to be floating | +| `#TAKE-OFFSET` | shifts the fixed-location address by hex offset given as parameter | The first match counts, all the remaining ones are dropped. Examples: @@ -139,7 +141,7 @@ This is a very common one. For standard ROM layout just take the file. For non-s // #LAYOUT# * * #IGNORE ``` -This can be found in a private (internal) jumptable of `KERNAL_1` segmment of `M65` layout. For standard ROM part (`KERNAL_0` segment) take it as floating routine (for `KERNAL_0` segment the file provides only labels for the jumptable). For `KERNAL_1` segment of `M65` layout, take it as a fixed location-routine; in such case the file will provide a jumptable itself. For memory layout other than `M65`, just ignore the file. Yet another example: +This can be found in a private (internal) vector table of `KERNAL_1` segment of `M65` layout. For standard ROM part (`KERNAL_0` segment) take it as floating routine (for `KERNAL_0` segment the file provides only labels for the vector table). For `KERNAL_1` segment of `M65` layout, take it as a fixed location-routine; in such case the file will provide a vector table itself. For memory layout other than `M65`, just ignore the file. Yet another example: ``` // #LAYOUT# M65 KERNAL_0 #TAKE @@ -155,16 +157,16 @@ This is used for memory mapping helper routines, which are only needed for Mega6 // #LAYOUT# * * #IGNORE ``` -This is for the routine, that on Mega65 goes to `KERNAL_1` segment, but can still be transparently called using fixed location in `KERNAL_0` segement. The code might, for example, look this way: +This is for the routine, that on Mega65 goes to `KERNAL_1` segment, but can still be transparently called using fixed location in `KERNAL_0` segment. The code might, for example, look this way: ``` ROUTINE_NAME: #if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) - jsr map_KERNAL_1 - jsr KERNAL_1__ROUTINE_NAME // execute routine from KERNAL_1 segment - jmp map_NORMAL + jsr map_KERNAL_1 + jsr_ind VK1__ROUTINE_NAME // execute routine from KERNAL_1 segment + jmp map_NORMAL #else diff --git a/strings/00000080 b/strings/00000080 new file mode 100644 index 00000000..74f02616 --- /dev/null +++ b/strings/00000080 @@ -0,0 +1,3 @@ +some 0's + $80 + +Not creative - not copyrightable. diff --git a/strings/000020 b/strings/000020 new file mode 100644 index 00000000..daa82e1f --- /dev/null +++ b/strings/000020 @@ -0,0 +1,3 @@ +some 0's + $20 + +Not creative - not copyrightable. diff --git a/strings/00202BBC b/strings/00202BBC new file mode 100644 index 00000000..179489eb --- /dev/null +++ b/strings/00202BBC @@ -0,0 +1,3 @@ +$00 + JSR $BC2B + +Instruction (call of well-known subroutine) + some part. Trivial, not copyrightable. diff --git a/strings/00602017 b/strings/00602017 new file mode 100644 index 00000000..6dcd48ba --- /dev/null +++ b/strings/00602017 @@ -0,0 +1,3 @@ +$00 + RTS + JSR $xx17 + +Instruction and some parts. Trivial - not copyrightable. diff --git a/strings/0060A5 b/strings/0060A5 new file mode 100644 index 00000000..5acfc780 --- /dev/null +++ b/strings/0060A5 @@ -0,0 +1,3 @@ +$00 + RTS + LDA (zeropage address does not match) + +Instruction + some parts. Trivial - not copyrightable. diff --git a/strings/008D8D02A0 b/strings/008D8D02A0 new file mode 100644 index 00000000..9b7ba485 --- /dev/null +++ b/strings/008D8D02A0 @@ -0,0 +1,3 @@ +$00 + STA $028D + LDY (immediate value does not match) + +Instruction + some parts. Trivial - not copyrightable. diff --git a/strings/00B17AD0 b/strings/00B17AD0 new file mode 100644 index 00000000..8d207f6a --- /dev/null +++ b/strings/00B17AD0 @@ -0,0 +1,3 @@ +$00 + LDA ($7A),Y + BNE (offset does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/00DC60AD b/strings/00DC60AD new file mode 100644 index 00000000..d5c28289 --- /dev/null +++ b/strings/00DC60AD @@ -0,0 +1,3 @@ +$DC00 + RTS + LDA (address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/012CA900 b/strings/012CA900 new file mode 100644 index 00000000..900f8140 --- /dev/null +++ b/strings/012CA900 @@ -0,0 +1,3 @@ +$01 + $2C (BIT) + LDA #$00 + +Instruction + part of the common BIT trick to save some memory. Trivial - not copyrightable. diff --git a/strings/04B12285 b/strings/04B12285 new file mode 100644 index 00000000..9661fafd --- /dev/null +++ b/strings/04B12285 @@ -0,0 +1,3 @@ +$04 + LDA ($22),Y + STA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/04B122856588B122856488B122856388B122 b/strings/04B122856588B122856488B122856388B122 new file mode 100644 index 00000000..b00b8058 --- /dev/null +++ b/strings/04B122856588B122856488B122856388B122 @@ -0,0 +1,3 @@ +$04 + LDA ($22),Y + STA $65 + DEY + LDA ($22),Y + STA $64 + DEY + LDA ($22),Y + STA $64 + DEY + LDA ($22),Y + +Unrolled loop to copy values from memory location to a fixed zeropage location. Trivial - not copyrightable. diff --git a/strings/04B122856D88B122856C88B122856B88B122 b/strings/04B122856D88B122856C88B122856B88B122 new file mode 100644 index 00000000..7bd466c8 --- /dev/null +++ b/strings/04B122856D88B122856C88B122856B88B122 @@ -0,0 +1,3 @@ +$04 + LDA ($22),Y + STA $6D + DEY + LDA ($22),Y + STA $6C + DEY + LDA ($22),Y + STA $6B + DEY + LDA ($22),Y + +Unrolled loop to copy values from memory location to a fixed zeropage location. Trivial - not copyrightable. diff --git a/strings/09808562 b/strings/09808562 new file mode 100644 index 00000000..e220392b --- /dev/null +++ b/strings/09808562 @@ -0,0 +1,3 @@ +ORA #$80 + STA $62 + +Store .A with highest bit enforced in a memoryy location (small piece of code manipulating floating point value) - trivial, not copyrightable. diff --git a/strings/122067F8 b/strings/122067F8 new file mode 100644 index 00000000..e7563bbe --- /dev/null +++ b/strings/122067F8 @@ -0,0 +1,3 @@ +$12 + JSR $F867 + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/18690285 b/strings/18690285 new file mode 100644 index 00000000..e8e426eb --- /dev/null +++ b/strings/18690285 @@ -0,0 +1,3 @@ +CLC + ADC #$02 + STA (address does not match) + +Adding 2 to .A regardless of Carry flag state, storing result in memoryy (address does not match) - trivial, not copyrightable. diff --git a/strings/2285618470 b/strings/2285618470 new file mode 100644 index 00000000..b587160f --- /dev/null +++ b/strings/2285618470 @@ -0,0 +1,3 @@ +$22 + STA $61 + STY $70 + +Small piece of floating point values manipulation code. Trivial - not copyrightable. diff --git a/strings/228569A56160 b/strings/228569A56160 new file mode 100644 index 00000000..97d81fe6 --- /dev/null +++ b/strings/228569A56160 @@ -0,0 +1,3 @@ +$22 + STA $69 + LDA $61 + RTS + +Small part of code manipulating bytes of a well-known floating point pseudo-register. Trivial - not copyrightable. diff --git a/strings/22856D88B122856C88B122856B88B122 b/strings/22856D88B122856C88B122856B88B122 new file mode 100644 index 00000000..8421e963 --- /dev/null +++ b/strings/22856D88B122856C88B122856B88B122 @@ -0,0 +1,3 @@ +$22 + STA $6D + DEY + LDA ($22),Y + STA $6C + DEY + LDA ($22),Y + STA $6B + DEY + LDA ($22),Y + +Part of unrolled loop to copy value from memor location to a floating point accumulator. Trivial - not copyrightable. diff --git a/strings/22D008A5D449 b/strings/22D008A5D449 new file mode 100644 index 00000000..92a47fb7 --- /dev/null +++ b/strings/22D008A5D449 @@ -0,0 +1,3 @@ +$22 + BNE (offset matches) + LDA $D4 + EOR (immediate value does not match) + +Small piece of code manipulating screen-related variable. Since EOR argument does not match, it's clear that the code does something different. The similar part is trivial - not copyrightable. diff --git a/strings/2CA90085 b/strings/2CA90085 new file mode 100644 index 00000000..2c911e18 --- /dev/null +++ b/strings/2CA90085 @@ -0,0 +1,3 @@ +$2C (BIT) + LDA #$00 + STA (zeropage address does not match) + +A common trick using BIT opcode to load (or not) value into to .A and continue execution. Trivial - not copyrightable. diff --git a/strings/2CA9042CA9 b/strings/2CA9042CA9 new file mode 100644 index 00000000..8ba049f5 --- /dev/null +++ b/strings/2CA9042CA9 @@ -0,0 +1,3 @@ +$2C (BIT) + LDA #$04 + $2C (BIT) + LDA (value does not match) + +A common trick using BIT opcode to load different values (depending on a condition) to .A and continue execution. Here the values does not even fully match. Trivial - not copyrghtable. diff --git a/strings/3504F334 b/strings/3504F334 new file mode 100644 index 00000000..9d6da7fe --- /dev/null +++ b/strings/3504F334 @@ -0,0 +1,3 @@ +1.0 / sqr(2.0) (partial similarity only, does not include exponent) + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/38E90285 b/strings/38E90285 new file mode 100644 index 00000000..9b4cfbac --- /dev/null +++ b/strings/38E90285 @@ -0,0 +1,3 @@ +SEC + SBC #$02 + STA (zeropage address does not match) + +Subtract 2 from accumulator, store result somewhere (location does not match) - trivial, not copyrightable. diff --git a/strings/490FDAA2 b/strings/490FDAA2 new file mode 100644 index 00000000..9d7affdb --- /dev/null +++ b/strings/490FDAA2 @@ -0,0 +1,3 @@ +PI / 2.0 (partial similarity only, does not include exponent) + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/4C0CED4C b/strings/4C0CED4C new file mode 100644 index 00000000..f59817ae --- /dev/null +++ b/strings/4C0CED4C @@ -0,0 +1,3 @@ +JMP $ED0C + JMP (address does not match) + +Instruction and some part. Trivial - not copyrightable. diff --git a/strings/608100000000 b/strings/608100000000 new file mode 100644 index 00000000..4ce43696 --- /dev/null +++ b/strings/608100000000 @@ -0,0 +1,3 @@ +RTS (end of previous routine) + floating point constant 1.0 + +Basically a fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/61D0034C b/strings/61D0034C new file mode 100644 index 00000000..d0520aa8 --- /dev/null +++ b/strings/61D0034C @@ -0,0 +1,3 @@ +$61 + BNE (skip next instruction) + JMP (address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/61F006A56649FF8566608138AA3B29 b/strings/61F006A56649FF8566608138AA3B29 new file mode 100644 index 00000000..372fdb96 --- /dev/null +++ b/strings/61F006A56649FF8566608138AA3B29 @@ -0,0 +1,8 @@ +$61 + BEQ (offset matches) + LDA $66 + EOR #$FF + STA $66 + RTS + floating point constant 1.0 / log_e(2.0) (last byte differs, probablyy due to rounding) + +A part of trivial routine, reversing the sign of floating point accumulator, if it is not 0. Afterwards a floating point constant - a fact (generated by a specially written tool), not creative work. +Locations of the routine/constant are not creative work either - we have to preserve them to keep the compatiibility. + +Not copyrightable. + + diff --git a/strings/62666366646665667060 b/strings/62666366646665667060 new file mode 100644 index 00000000..ca4930bf --- /dev/null +++ b/strings/62666366646665667060 @@ -0,0 +1,3 @@ +$62 + ROR $63 + ROR $64 + ROR $65 + ROR $70 + RTS + +Code for dividing multi-byte integer by 2 (this time a floating point mantissa), common technique for 6502 assembler. Not creative - not copyrightable. diff --git a/strings/63856BA5 b/strings/63856BA5 new file mode 100644 index 00000000..a4d47655 --- /dev/null +++ b/strings/63856BA5 @@ -0,0 +1,3 @@ +$63 + STA $6B + LDA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/64856CA5 b/strings/64856CA5 new file mode 100644 index 00000000..1e2c0e39 --- /dev/null +++ b/strings/64856CA5 @@ -0,0 +1,3 @@ +$64 + STA $6C + LDA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/65856DA5 b/strings/65856DA5 new file mode 100644 index 00000000..648ad890 --- /dev/null +++ b/strings/65856DA5 @@ -0,0 +1,3 @@ +$65 + STA $6D + LDA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/66456E85 b/strings/66456E85 new file mode 100644 index 00000000..9c596392 --- /dev/null +++ b/strings/66456E85 @@ -0,0 +1,3 @@ +$66 + EOR $6E + STA (zeropage address does not match) + +Small piece of floating point values manipulation code (single instruction and some parts). Trivial - not copyrightable. diff --git a/strings/6649FF8566 b/strings/6649FF8566 new file mode 100644 index 00000000..e08d4fe3 --- /dev/null +++ b/strings/6649FF8566 @@ -0,0 +1,3 @@ +$66 + EOR #$FF + STA $66 + +Part of ccode reversing sign oof floating point variable. Trivial - not copyrightable. diff --git a/strings/66626663666466656670 b/strings/66626663666466656670 new file mode 100644 index 00000000..45be6917 --- /dev/null +++ b/strings/66626663666466656670 @@ -0,0 +1,3 @@ +ROR $62 + ROR $63 + ROR $64 + ROR $65 + ROR $70 + +Code for dividing multi-byte integer by 2 (this time a floating point mantissa), common technique for 6502 assembler. Not creative - not copyrightable. diff --git a/strings/6662666366646665667060 b/strings/6662666366646665667060 new file mode 100644 index 00000000..753cc7a2 --- /dev/null +++ b/strings/6662666366646665667060 @@ -0,0 +1,3 @@ +ROR $62 + ROR $63 + ROR $64 + ROR $65 + ROR $70 + RTS + +Code for dividing multi-byte integer by 2 (this time a floating point mantissa), common technique for 6502 assembler. Not creative - not copyrightable. diff --git a/strings/6A85624C b/strings/6A85624C new file mode 100644 index 00000000..c76e8180 --- /dev/null +++ b/strings/6A85624C @@ -0,0 +1,3 @@ +$6A + STA $62 + JMP (addres does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/6AE56285 b/strings/6AE56285 new file mode 100644 index 00000000..1aa15687 --- /dev/null +++ b/strings/6AE56285 @@ -0,0 +1,3 @@ +$6A + SBC $62 + STA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/6B8563A5 b/strings/6B8563A5 new file mode 100644 index 00000000..7a1b8e3a --- /dev/null +++ b/strings/6B8563A5 @@ -0,0 +1,3 @@ +$6B + STA $63 + LDA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/6B8563A562 b/strings/6B8563A562 new file mode 100644 index 00000000..d254cb6a --- /dev/null +++ b/strings/6B8563A562 @@ -0,0 +1,3 @@ +$6B + STA $63 + LDA $62 + +Small piece of code manipulating copying bytes of a well-known location (floating point accumulator) - trivial, not copyrightable. diff --git a/strings/6C8564A5 b/strings/6C8564A5 new file mode 100644 index 00000000..c6866eb3 --- /dev/null +++ b/strings/6C8564A5 @@ -0,0 +1,3 @@ +$6C + STA $64 + LDA (zeropage address does not match) + +Single instruction + some parts. Trivial - not copyrightable. diff --git a/strings/6CE56485 b/strings/6CE56485 new file mode 100644 index 00000000..8f6f6459 --- /dev/null +++ b/strings/6CE56485 @@ -0,0 +1,3 @@ +$6C + SBC $64 + STA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/6D8565A5 b/strings/6D8565A5 new file mode 100644 index 00000000..f822248f --- /dev/null +++ b/strings/6D8565A5 @@ -0,0 +1,3 @@ +$6D + STA $65 + LDA (zeropage address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/6D8565A564 b/strings/6D8565A564 new file mode 100644 index 00000000..f5704def --- /dev/null +++ b/strings/6D8565A564 @@ -0,0 +1,3 @@ +$6D + STA $65 + LDA $64 + +Small piece of code manipulating copying bytes of a well-known location (floating point accumulator) - trivial, not copyrightable. diff --git a/strings/702665266426632662 b/strings/702665266426632662 new file mode 100644 index 00000000..82e40274 --- /dev/null +++ b/strings/702665266426632662 @@ -0,0 +1,3 @@ +$70 + ROL $65 + ROL $64 + ROL $63 + ROL $62 + +Code for multiplaying multi-byte integer by 2 (this time a floating point mantissa), common technique for 6502 assembler. Not creative - not copyrightable. diff --git a/strings/803504F334813504F334808000000080317217F8 b/strings/803504F334813504F334808000000080317217F8 new file mode 100644 index 00000000..97a9130b --- /dev/null +++ b/strings/803504F334813504F334808000000080317217F8 @@ -0,0 +1,3 @@ +floating point constants: 1.0 / sqr(2.0) , sqr(2.0), -0.5, log_e(2.0) + +List of facts (generated by a specially written tool) in a well-known memory location, not a creative work. Not copyrightable. diff --git a/strings/8100000000 b/strings/8100000000 new file mode 100644 index 00000000..00e855aa --- /dev/null +++ b/strings/8100000000 @@ -0,0 +1,3 @@ +floating point constant 1.0 + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/81490FDAA283490FDAA27F00000000 b/strings/81490FDAA283490FDAA27F00000000 new file mode 100644 index 00000000..0f1bb8a9 --- /dev/null +++ b/strings/81490FDAA283490FDAA27F00000000 @@ -0,0 +1,3 @@ +floating point constants: PI / 2.0, PI * 2.0, 0.25 + +List of facts (generated by a specially written tool) in a well-known memory location, not a creative work. Not copyrightable. diff --git a/strings/82490FDA b/strings/82490FDA new file mode 100644 index 00000000..76d39a83 --- /dev/null +++ b/strings/82490FDA @@ -0,0 +1,3 @@ +floating point constant PI, last byte (lowest byte of mantissa) differs, probably due to rounding + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/83490FDAA2 b/strings/83490FDAA2 new file mode 100644 index 00000000..20cdb268 --- /dev/null +++ b/strings/83490FDAA2 @@ -0,0 +1,3 @@ +floating point constant PI * 2.0 + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/8420000000 b/strings/8420000000 new file mode 100644 index 00000000..a0fd48f2 --- /dev/null +++ b/strings/8420000000 @@ -0,0 +1,3 @@ +floating point constant 10.0 + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/8561A56585 b/strings/8561A56585 new file mode 100644 index 00000000..040db5b9 --- /dev/null +++ b/strings/8561A56585 @@ -0,0 +1,3 @@ +STA $61 + LDA $65 + STA (zeropage address does not match) + +Small piece of code manipulating copying bytes of a well-known location (floating point accumulator) - trivial, not copyrightable. diff --git a/strings/8562856385648565 b/strings/8562856385648565 new file mode 100644 index 00000000..9f626ee9 --- /dev/null +++ b/strings/8562856385648565 @@ -0,0 +1,3 @@ +STA $62 + STA $63 + STA $64 + STA $65 + +Piece of code filling the floating point mantissa bytes with constant variable - trivial, not copyrightable. diff --git a/strings/8562B003 b/strings/8562B003 new file mode 100644 index 00000000..5cd99bfa --- /dev/null +++ b/strings/8562B003 @@ -0,0 +1,3 @@ +STA $62 + BCS (offset matches) + +Small piece of floating point values manipulation code. Trivial - not copyrightable. diff --git a/strings/8563A562 b/strings/8563A562 new file mode 100644 index 00000000..d7e64cb6 --- /dev/null +++ b/strings/8563A562 @@ -0,0 +1,3 @@ +STA $63 + LDA $62 + +Small piece of code manipulating copying bytes of a well-known location (floating point accumulator) - trivial, not copyrightable. diff --git a/strings/8566A561 b/strings/8566A561 new file mode 100644 index 00000000..abfd6ab4 --- /dev/null +++ b/strings/8566A561 @@ -0,0 +1,3 @@ +STA $66 + LDA $61 + +Small piece of code manipulating copying bytes of a well-known location (floating point accumulator) - trivial, not copyrightable. diff --git a/strings/867060 b/strings/867060 new file mode 100644 index 00000000..9b5ee0ab --- /dev/null +++ b/strings/867060 @@ -0,0 +1,3 @@ +STX $70 (FACOV) + RTS + +Storing .X register in a welll-known memory location, followed by end of subroutine. Trivial - not copyrightable. diff --git a/strings/88B122 b/strings/88B122 new file mode 100644 index 00000000..cb432334 --- /dev/null +++ b/strings/88B122 @@ -0,0 +1,3 @@ +DEY + LDA ($22),Y + +Part of the loop reading data via general purpose vector variable. Not creative and fairy trivial- not copyrightable. diff --git a/strings/88B12285 b/strings/88B12285 new file mode 100644 index 00000000..b74ab76c --- /dev/null +++ b/strings/88B12285 @@ -0,0 +1,3 @@ +DEY + LDA ($22),Y + STA (zeropage address does not match) + +Part of the loop reading data via general purpose vector variable. Not creative and fairy trivial- not copyrightable. diff --git a/strings/8D00DCAD01DC b/strings/8D00DCAD01DC new file mode 100644 index 00000000..2168599f --- /dev/null +++ b/strings/8D00DCAD01DC @@ -0,0 +1,3 @@ +STA $DC00 + LDA $DC01 + +Small part of the routine manipulating I/O registers (store value in one register, fetch from another). Trivial - not copyrightable. diff --git a/strings/9080000000 b/strings/9080000000 new file mode 100644 index 00000000..ac8bd96c --- /dev/null +++ b/strings/9080000000 @@ -0,0 +1,3 @@ +floating point constant -32768.0 + +A fact (generated by a specially written tool), not creative work. Not copyrightable. diff --git a/strings/A0008470 b/strings/A0008470 new file mode 100644 index 00000000..93b1e3d6 --- /dev/null +++ b/strings/A0008470 @@ -0,0 +1,3 @@ +LDY #$00 + STY $70 + +Store 0 in a zeropage location, using .Y register. Trivial - not copyrightable. diff --git a/strings/A5619122 b/strings/A5619122 new file mode 100644 index 00000000..72e9637f --- /dev/null +++ b/strings/A5619122 @@ -0,0 +1,3 @@ +LDA $61 + STA ($22),Y + +Copy value from zeropage to some memory location pointed by a general-purpose vector. Trivial - noot copyrightable. diff --git a/strings/A56649FF b/strings/A56649FF new file mode 100644 index 00000000..45d482ce --- /dev/null +++ b/strings/A56649FF @@ -0,0 +1,3 @@ +LDA $66 + EOR #$FF + +Load a floating point value sign and reverse it - trivial, not copyrightable. diff --git a/strings/A56649FF8566 b/strings/A56649FF8566 new file mode 100644 index 00000000..25494374 --- /dev/null +++ b/strings/A56649FF8566 @@ -0,0 +1,3 @@ +LDA $66 + EOR #$FF + STA $66 + +Reversal of all the bits in a register (where 0 means positive floating point value, $FF - negative). Trivial - not copyrightable. diff --git a/strings/A56AE56285 b/strings/A56AE56285 new file mode 100644 index 00000000..88a3f800 --- /dev/null +++ b/strings/A56AE56285 @@ -0,0 +1,3 @@ +LDA $6A + SBC $62 + STA (zeropage address does not match) + +Small piece of code subtracting one floating point mantissa from another - this is a common technique to subtract numbers over 8 bits size on 6502. Not creative - not copyrightable. diff --git a/strings/A56DE56585 b/strings/A56DE56585 new file mode 100644 index 00000000..681b0e56 --- /dev/null +++ b/strings/A56DE56585 @@ -0,0 +1,3 @@ +LDA $6D + SBC $65 + STA (address does not match) + +Calculate diiff between two zeropage values, store result in another location - trivial, not copyrightable. diff --git a/strings/A56E8566 b/strings/A56E8566 new file mode 100644 index 00000000..43958604 --- /dev/null +++ b/strings/A56E8566 @@ -0,0 +1,3 @@ +LDA $6E + STA $66 + +Copy value from one zeropage location to another - trivial, not copyrightable. diff --git a/strings/A5A745AB85AB b/strings/A5A745AB85AB new file mode 100644 index 00000000..e69d8cbd --- /dev/null +++ b/strings/A5A745AB85AB @@ -0,0 +1,3 @@ +LDA $A7 + EOR $AB + STA $AB + +Small part of a routine reading from tape, calculates XOR checksum of the stream. Trivial - not copyrightable. diff --git a/strings/A5C485C2 b/strings/A5C485C2 new file mode 100644 index 00000000..f5a12df3 --- /dev/null +++ b/strings/A5C485C2 @@ -0,0 +1,3 @@ +LDA $C4 + STA $C2 + +Copy value from one zeropage location to another. Trivial - not copyrightable. diff --git a/strings/A6D8F005 b/strings/A6D8F005 new file mode 100644 index 00000000..2d6cac22 --- /dev/null +++ b/strings/A6D8F005 @@ -0,0 +1,3 @@ +LDX $D8 + BEQ (offset matches) + +Decision based whether well-known zeropage loacation is 0 or not. Trivial - not copyrightable. diff --git a/strings/A9012CA9022CA9032CA9042CA9052CA9062CA9072CA9082CA909 b/strings/A9012CA9022CA9032CA9042CA9052CA9062CA9072CA9082CA909 new file mode 100644 index 00000000..be85a90c --- /dev/null +++ b/strings/A9012CA9022CA9032CA9042CA9052CA9062CA9072CA9082CA909 @@ -0,0 +1,3 @@ +LDA #$01 + $2C + LDA #$02 + $2C + LDA #$03 + ... + +Common size optimization to set different values to a variable depending on a jump address, using BIT instruction ($2C) to skip unnecessary instruction, this time a relatively long one. Well-known technique, not creative - thus not copyrightable. diff --git a/strings/A9802CA9 b/strings/A9802CA9 new file mode 100644 index 00000000..9f95a605 --- /dev/null +++ b/strings/A9802CA9 @@ -0,0 +1,3 @@ +LDA #$80 + $2C (BIT) + LDA (value does not match) + +A common trick using BIT opcode to load different values (depending on a condition) to .A and continue execution. Here the values does not even fully match. Trivial - not copyrghtable. diff --git a/strings/B12285 b/strings/B12285 new file mode 100644 index 00000000..77d4f8a4 --- /dev/null +++ b/strings/B12285 @@ -0,0 +1,4 @@ +LDA ($22),Y + STA (zeropage address does not match) + +Instruction (accessing data via general purpose vector) + some part. Trivial, not copyyrightable. + diff --git a/strings/B1228565 b/strings/B1228565 new file mode 100644 index 00000000..85096ecf --- /dev/null +++ b/strings/B1228565 @@ -0,0 +1,3 @@ +LDA ($22),Y + STA $65 + +Small part of a routine copying memory variable to floating point accumulator (copies 1 byte) - trivial, not copyrightable. diff --git a/strings/BA200CED b/strings/BA200CED new file mode 100644 index 00000000..3ce6f608 --- /dev/null +++ b/strings/BA200CED @@ -0,0 +1,3 @@ +$BA + JSR $ED0C + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/BAC902D0 b/strings/BAC902D0 new file mode 100644 index 00000000..e135fb06 --- /dev/null +++ b/strings/BAC902D0 @@ -0,0 +1,3 @@ +$BA + CMP #$02 + BNE (offset does not match) + +Instruction + some parts. Trivial - not copyrightable. diff --git a/strings/D885F46020 b/strings/D885F46020 new file mode 100644 index 00000000..64c665fa --- /dev/null +++ b/strings/D885F46020 @@ -0,0 +1,3 @@ +$D8 + STA $F4 + RTS + JSR (address does not match) + +End of the routine (store data in a well-known zeropage location) + some parts. Trivial - not copyrightable. diff --git a/strings/E69FE69F b/strings/E69FE69F new file mode 100644 index 00000000..c28b9b68 --- /dev/null +++ b/strings/E69FE69F @@ -0,0 +1,4 @@ +INC $9F + INC $9F + +Increase value of zeropage variable (which counts the number of vectors) by 2. Trivial - not copyrightable. + diff --git a/strings/F38810F5 b/strings/F38810F5 new file mode 100644 index 00000000..d8b917cf --- /dev/null +++ b/strings/F38810F5 @@ -0,0 +1,3 @@ +$F3 + DEY + BPL (offset matches) + +Small part of the loop indexeed by .Y, counting down. Trivial - not copyrightable. diff --git a/strings/F7B0034C b/strings/F7B0034C new file mode 100644 index 00000000..ee5ded44 --- /dev/null +++ b/strings/F7B0034C @@ -0,0 +1,3 @@ +$F7 + BCS (skip the JMP) + JMP (address does not match) + +Instruction + some parts. Trivial, not copyrightable. diff --git a/strings/F7C884C8A0 b/strings/F7C884C8A0 new file mode 100644 index 00000000..bfed6dc9 --- /dev/null +++ b/strings/F7C884C8A0 @@ -0,0 +1,3 @@ +$F7 + INY + STY $C8 + LDY (immediate value does not match) + +Small piece of code manipulating screen-related variable. Similarity is very limited, there is nothing creative here - not copyrightable. diff --git a/testsuite/testtape-c64-pal-normal-errors.tap b/testsuite/testtape-c64-pal-normal-errors.tap new file mode 100644 index 00000000..0e103e44 Binary files /dev/null and b/testsuite/testtape-c64-pal-normal-errors.tap differ diff --git a/src/build_segment.cc b/tools/build_segment.cc similarity index 98% rename from src/build_segment.cc rename to tools/build_segment.cc index 643da112..422819ef 100644 --- a/src/build_segment.cc +++ b/tools/build_segment.cc @@ -91,8 +91,8 @@ public: std::vector content; std::string label; - int startAddr; // for fixed (non-floating) routines only - int codeLength; // for both fixed and floating routines + int startAddr; // for fixed (non-floating) routines only + int codeLength; // for both fixed and floating routines int testAddrStart; // start address during test run int testAddrEnd; // end address during test run @@ -170,8 +170,8 @@ void parseCommandLine(int argc, char **argv) case 's': CMD_segName = optarg; break; case 'i': CMD_segInfo = optarg; break; case 'r': CMD_romLayout = optarg; break; - case 'l': CMD_loAddress = strtol(optarg, nullptr ,16); break; - case 'h': CMD_hiAddress = strtol(optarg, nullptr ,16); break; + case 'l': CMD_loAddress = strtol(optarg, nullptr, 16); break; + case 'h': CMD_hiAddress = strtol(optarg, nullptr, 16); break; default: printUsage(); ERROR(); } } @@ -692,6 +692,11 @@ bool SourceFile::preprocessLine(const std::string &line) { floating = true; } + else if (iter->compare("#TAKE-OFFSET") == 0) + { + if (++iter == tokens.end()) ERROR("syntax error, missing parameter for '#TAKE-OFFSET'"); + startAddr += strtol(iter->c_str(), nullptr, 16); + } else if (iter->compare("#TAKE") != 0) { ERROR(std::string("syntax error, unsupported action '") + token + "' in '#LAYOUT#'"); @@ -791,8 +796,9 @@ void BinningProblem::addToProblem(SourceFile *routine) if (!gapFound) { - ERROR(std::string("start address of fixed address file '") + \ - routine->fileName + "' already occupied or out of range"); + ERROR(std::string("start address of fixed address file '") + + routine->fileName + "' (" + std::to_string(routine->startAddr) + + ") already occupied or out of range"); } } } diff --git a/src/collect_data.c b/tools/collect_data.c similarity index 100% rename from src/collect_data.c rename to tools/collect_data.c diff --git a/src/common.h b/tools/common.h similarity index 100% rename from src/common.h rename to tools/common.h diff --git a/src/compress_text.c b/tools/compress_text.c similarity index 100% rename from src/compress_text.c rename to tools/compress_text.c diff --git a/tools/generate_constants.cc b/tools/generate_constants.cc new file mode 100644 index 00000000..6d27caed --- /dev/null +++ b/tools/generate_constants.cc @@ -0,0 +1,257 @@ +// +// Utility to generate various floating points constants +// in a Commodore-specific variable format +// + +#include "common.h" + +#include + +#include +#include +#include +#include +#include + +// +// Basic types definition +// + +typedef struct ConstEntry +{ + ConstEntry(const std::string &constName, double constValue) : + constName(constName), + constValue(constValue), + outString(".error \"not generated\"") + { + }; + + const std::string constName; + const double constValue; + + std::string outString; + +} ConstEntry; + +// +// Constants to output +// + +std::vector GLOBAL_constants = +{ + // Constants from: + // - https://www.c64-wiki.com/wiki/BASIC-ROM + // Computes Mapping the Commodore 64, pages 103, 105, 113, 114, 116 + + ConstEntry( "QUARTER", 0.25 ), + ConstEntry( "HALF", 0.5 ), + ConstEntry( "NEG_HALF", -0.5 ), + ConstEntry( "ONE", 1.0 ), + ConstEntry( "TEN", 10.0 ), + ConstEntry( "NEG_32768", -32768.0 ), + + ConstEntry( "HALF_PI", M_PI / 2.0 ), + ConstEntry( "PI", M_PI ), + ConstEntry( "DOUBLE_PI", M_PI * 2.0 ), + ConstEntry( "SQR_2", std::sqrt(2.0) ), + ConstEntry( "INV_SQR_2", 1.0 / std::sqrt(2.0) ), + ConstEntry( "LOG_2", std::log(2.0) ), + ConstEntry( "INV_LOG_2", 1.0 / std::log(2.0) ), +}; + +// +// Command line settings +// + +std::string CMD_outFile = "out.s"; + +// +// Common helper functions +// + +void printUsage() +{ + std::cout << "\n" << + "usage: generate_constants [-o ]" << "\n\n"; +} + +void printBanner() +{ + printBannerLineTop(); + std::cout << "// Generating floating point constants" << "\n"; + printBannerLineBottom(); +} + +// +// Top-level functions +// + +void parseCommandLine(int argc, char **argv) +{ + int opt; + + // Retrieve command line options + + while ((opt = getopt(argc, argv, "o:")) != -1) + { + switch(opt) + { + case 'o': CMD_outFile = optarg; break; + default: printUsage(); ERROR(); + } + } +} + +// +// Constants generation +// + +std::string toAssemblerString(const std::string &constName, double constValue) +{ + uint8_t outFloat[5] = { 0 }; + + // Retrieve mantissa nad exponent + + int exponent = -0x80; + double mantissa = frexp(std::abs(constValue), &exponent); + + // Round the mantissa to output format precission + + const double coeff = 256.0 * 256.0 * 256.0 * 256.0; + + double intPart; + if (modf(mantissa * coeff, &intPart) >= 0.5) + { + mantissa = (intPart + 1.0) / coeff; + } + else + { + mantissa = intPart / coeff; + } + + if (mantissa >= 1.0) + { + mantissa = 0.5; + exponent++; + } + + // Add a bias to exponent + + exponent += 0x80; + + // Check if output format can contain such a number + + if (exponent > 0xFF) + { + ERROR(std::string("const '") + constName + "' abs value too large"); + } + else if (exponent <= 0) + { + ERROR(std::string("const '") + constName + "' abs value too small"); + } + + // Set output constant exponent + + outFloat[0] = exponent; + + // Set output constant mantissa + + for (uint8_t idxByte = 1; idxByte <= 4; idxByte++) + { + for (uint8_t idxBit = 0; idxBit <= 7; idxBit++) + { + outFloat[idxByte] = outFloat[idxByte] << 1; + if (mantissa >= 0.5) + { + outFloat[idxByte]++; + mantissa -= 0.5; + } + + mantissa *= 2; + } + } + + if (mantissa > 0.0) ERROR(std::string("const '") + constName + "' export error"); + if (outFloat[1] < 0x80) ERROR(std::string("const '") + constName + "' not normalized"); + + // Set output constant sign + + if (constValue >= 0.0) + { + outFloat[1] = outFloat[1] & 0x7F; + } + + // Return the output constant as string for assembler + + char buf[256] = { 0 }; + snprintf(buf, sizeof(buf), "$%02X, $%02X, $%02X, $%02X, $%02X // %22.10f", + outFloat[0], + outFloat[1], + outFloat[2], + outFloat[3], + outFloat[4], + constValue); + + std::string outDef = std::string("\n.macro put_const_") + constName + "()\n{\n\t.byte " + buf + "\n}\n"; + + return outDef; +} + + +void writeConstants() +{ + // Convert constants to assembler strings + + for (auto &entry : GLOBAL_constants) + { + entry.outString = toAssemblerString(entry.constName, entry.constValue); + } + + // Remove old file + + unlink(CMD_outFile.c_str()); + + // Open output file for writing + + std::ofstream outFile(CMD_outFile, std::fstream::out | std::fstream::trunc); + if (!outFile.good()) ERROR(std::string("can't open oputput file '") + CMD_outFile + "'"); + + // Write header + + outFile << "//\n// Generated file - do not edit\n//\n\n"; + + // Write constants + + for (auto &entry : GLOBAL_constants) + { + outFile << entry.outString; + } + + if (!outFile.good()) + { + outFile.close(); + unlink(CMD_outFile.c_str()); + ERROR(std::string("can't write oputput file '") + CMD_outFile + "'"); + } + + // Close the file + + outFile.close(); + + std::cout << std::string("Constants written to: ") + CMD_outFile + "\n\n"; +} + + +// +// Main function +// + +int main(int argc, char **argv) +{ + parseCommandLine(argc, argv); + + printBanner(); + writeConstants(); + + return 0; +} diff --git a/src/outdated/basic005.c b/tools/outdated/basic005.c similarity index 100% rename from src/outdated/basic005.c rename to tools/outdated/basic005.c diff --git a/src/outdated/prepare_startup.c b/tools/outdated/prepare_startup.c similarity index 100% rename from src/outdated/prepare_startup.c rename to tools/outdated/prepare_startup.c diff --git a/src/outdated/preprocess.c b/tools/outdated/preprocess.c similarity index 100% rename from src/outdated/preprocess.c rename to tools/outdated/preprocess.c diff --git a/src/pngprepare.c b/tools/pngprepare.c similarity index 100% rename from src/pngprepare.c rename to tools/pngprepare.c diff --git a/src/release.cc b/tools/release.cc similarity index 100% rename from src/release.cc rename to tools/release.cc diff --git a/src/similarity.c b/tools/similarity.c similarity index 100% rename from src/similarity.c rename to tools/similarity.c