diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000..75d9b00d3
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,16 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+**Compiler and OS**
+It is important to know what version of the compiler/assembler you used (call it with --version to get this info). Sometimes we also need to know what OS you are using.
+
+**Describe the bug**
+Please tell us what you did, what happened, and what you expected to happen instead.
+
+**To Reproduce**
+If it isnt obvious how to reproduce the problem, please give use some detailed instructions on how to reproduce it. Ideally provide a testcase (program) that we can put into the testbench later.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 000000000..09cadc0ba
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,14 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: feature request
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..5215c557d
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,9 @@
+## Summary
+
+Provide description of the bug (if an issue exists, link to it) and the fix.
+
+## Checklist
+
+- [ ] The fix meets the codestyle requirements
+- [ ] New unit tests have been added to prevent future regressions
+- [ ] The documentation has been updated if necessary
diff --git a/.github/checks/Makefile b/.github/checks/Makefile
index 93eeddd19..7fc51d8d4 100644
--- a/.github/checks/Makefile
+++ b/.github/checks/Makefile
@@ -5,14 +5,18 @@ endif
ifdef CMD_EXE
-.PHONY: checkstyle
+.PHONY: checkstyle sorted
checkstyle:
$(info INFO: style checks require bash.)
+sorted:
+ $(info INFO: table checks require bash.)
else
-.PHONY: checkstyle lineendings tabs lastline spaces noexec
+.PHONY: checkstyle lineendings tabs lastline spaces noexec sorted
+
+all: checkstyle sorted
checkstyle: lineendings tabs lastline spaces noexec
@@ -31,4 +35,12 @@ spaces: spaces.sh
noexec: noexec.sh
@./noexec.sh
+sorted: sorted.sh sorted_codeopt.sh sorted_opcodes.sh
+ @./sorted.sh
+ @./sorted_codeopt.sh
+ @./sorted_opcodes.sh
+
+checksp: checksp.sh
+ @./checksp.sh
+
endif
diff --git a/.github/checks/checksp.sh b/.github/checks/checksp.sh
new file mode 100755
index 000000000..f70d92e25
--- /dev/null
+++ b/.github/checks/checksp.sh
@@ -0,0 +1,22 @@
+#! /bin/bash
+OD65_EXE=../bin/od65
+CHECK_PATH=../../libwrk
+
+cd "${CHECK_PATH}" || {
+ echo "error: Directory ${CHECK_PATH} doesn't seem to exist" >&2
+ exit 1
+}
+
+[ -x "${OD65_EXE}" ] || {
+ echo "error: This check requires the od65 executable to be built" >&2
+ exit 1
+}
+
+EXITCODE=0
+find . -name \*.o -print | while read OBJ; do
+ "${OD65_EXE}" --dump-imports "${OBJ}" | grep -q "\"sp\"" && {
+ echo "error: Usage of symbol 'sp' found in module ${OBJ}" >&2
+ EXITCODE=1
+ }
+done
+exit ${EXITCODE}
diff --git a/.github/checks/lastline.sh b/.github/checks/lastline.sh
index d80d2fb57..6bb6e0dc5 100755
--- a/.github/checks/lastline.sh
+++ b/.github/checks/lastline.sh
@@ -9,7 +9,7 @@ nl='
'
nl=$'\n'
r1="${nl}$"
-FILES=`find $CHECK_PATH -type f \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | while read f; do
+FILES=`find $CHECK_PATH -type f -size +0 \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | while read f; do
t=$(tail -c2 $f; printf x)
[[ ${t%x} =~ $r1 ]] || echo "$f"
done`
@@ -23,3 +23,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
+exit 0
diff --git a/.github/checks/lineendings.sh b/.github/checks/lineendings.sh
index 5b445522f..5baac514e 100755
--- a/.github/checks/lineendings.sh
+++ b/.github/checks/lineendings.sh
@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
+exit 0
diff --git a/.github/checks/noexec.sh b/.github/checks/noexec.sh
index c76ae481d..5e53fe869 100755
--- a/.github/checks/noexec.sh
+++ b/.github/checks/noexec.sh
@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
+exit 0
diff --git a/.github/checks/sorted.sh b/.github/checks/sorted.sh
new file mode 100755
index 000000000..e15c04475
--- /dev/null
+++ b/.github/checks/sorted.sh
@@ -0,0 +1,39 @@
+#! /bin/bash
+OLDCWD=`pwd`
+SCRIPT_PATH=`dirname $0`
+
+CHECK_DIR=../../src
+
+SORT_OPT="-u -c"
+
+# $1: filename
+function checkarray_quoted_name
+{
+ CHECK_FILE="$1"
+ START="\\/\\* BEGIN SORTED.SH \\*\\/"
+ END="\\/\\* END SORTED.SH \\*\\/"
+
+ awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {printf("%04d##%s\n", count, $0)}' "$CHECK_FILE" | \
+ sed -e 's:\(.*\)##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp
+
+ if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
+ echo "error: "$1" table is empty"
+ rm -rf .a.tmp
+ exit -1
+ fi
+
+ if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then
+ echo ""$1" tables OK"
+ else
+ echo "error: "$1" tables are not sorted."
+ rm -rf .a.tmp
+ exit -1
+ fi
+ rm -rf .a.tmp
+}
+
+
+find "$CHECK_DIR" -name \*.\[ch\] -print | while read N; do
+ grep -q "BEGIN SORTED.SH" "$N" && checkarray_quoted_name "$N"
+done
+exit 0
diff --git a/.github/checks/sorted_codeopt.sh b/.github/checks/sorted_codeopt.sh
new file mode 100755
index 000000000..370bbfc9f
--- /dev/null
+++ b/.github/checks/sorted_codeopt.sh
@@ -0,0 +1,69 @@
+#! /bin/bash
+OLDCWD=`pwd`
+SCRIPT_PATH=`dirname $0`
+
+CHECK_DIR=../../src
+
+SORT_OPT="-u -c"
+
+# $1: filename
+function checkarray
+{
+ CHECK_FILE="$1"
+ START="\\/\\* BEGIN DECL SORTED_CODEOPT.SH \\*\\/"
+ END="\\/\\* END DECL SORTED_CODEOPT.SH \\*\\/"
+
+ awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {printf("%04d##%s\n", count, $0)}' "$CHECK_FILE" | \
+ sed -e 's:\(.*##\).*"\(.*\)",.*:\1\2:g' > .a.tmp
+
+ if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
+ echo "error: "$1" table is empty"
+ rm -rf .a.tmp
+ exit -1
+ fi
+
+ if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then
+ echo ""$1" decls sorted."
+ else
+ echo "error: "$1" decls are not sorted."
+ rm -rf .a.tmp
+ exit -1
+ fi
+
+ START="\\/\\* BEGIN SORTED_CODEOPT.SH \\*\\/"
+ END="\\/\\* END SORTED_CODEOPT.SH \\*\\/"
+
+ awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {printf("%04d##%s\n", count, $0)}' "$CHECK_FILE" | \
+ sed -e 's:\(.*##\).*&D\(.*\),.*:\1\2:g' > .b.tmp
+
+ if [[ -z $(grep '[^[:space:]]' .b.tmp) ]] ; then
+ echo "error: "$1" table is empty"
+ rm -rf .a.tmp .b.tmp
+ exit -1
+ fi
+
+ if `LC_COLLATE=C sort $SORT_OPT .b.tmp`; then
+ echo ""$1" tables sorted."
+ else
+ echo "error: "$1" tables are not sorted."
+ rm -rf .a.tmp .b.tmp
+ exit -1
+ fi
+
+ if cmp --silent -- .a.tmp .b.tmp; then
+ echo ""$1" tables OK"
+ else
+ echo "error: "$1" tables are different."
+ diff -y .a.tmp .b.tmp
+ rm -rf .a.tmp .b.tmp
+ exit -1
+ fi
+
+ rm -rf .a.tmp .b.tmp
+}
+
+
+find "$CHECK_DIR" -name \*.\[ch\] -print | while read N; do
+ grep -q "BEGIN DECL SORTED_CODEOPT.SH" "$N" && checkarray "$N"
+done
+exit 0
diff --git a/.github/checks/sorted_opcodes.sh b/.github/checks/sorted_opcodes.sh
new file mode 100755
index 000000000..8f8764c6a
--- /dev/null
+++ b/.github/checks/sorted_opcodes.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+OLDCWD=`pwd`
+SCRIPT_PATH=`dirname $0`
+
+CHECK_DIR=../../src
+
+SORT_OPT="-u -c"
+
+# $1: filename
+function checkarray_quoted_name
+{
+ CHECK_FILE="$1"
+ START="\\/\\* BEGIN SORTED_OPCODES.SH \\*\\/"
+ END="\\/\\* END SORTED_OPCODES.SH \\*\\/"
+
+ awk '/'"$START"'/{flag=1; count++; next} /'"$END"'/{flag=0;} flag {printf("%04d##%s\n", count, $0)}' "$CHECK_FILE" | \
+ sed 's:/\*.*::g' | \
+ grep '".*",' | \
+ sed -e 's:\(.*\)##.*\"\(.*\)\".*:\1##\2:g' > .a.tmp
+
+ if [[ -z $(grep '[^[:space:]]' .a.tmp) ]] ; then
+ echo "error: "$1" table is empty"
+ rm -rf .a.tmp
+ exit -1
+ fi
+
+ if `LC_COLLATE=C sort $SORT_OPT .a.tmp`; then
+ echo ""$1" tables OK"
+ else
+ echo "error: "$1" tables are not sorted."
+ rm -rf .a.tmp
+ exit -1
+ fi
+ rm -rf .a.tmp
+}
+
+find "$CHECK_DIR" -name \*.\[ch\] -print | while read N; do
+ grep -q "BEGIN SORTED_OPCODES.SH" "$N" && checkarray_quoted_name "$N"
+done
+exit 0
diff --git a/.github/checks/spaces.sh b/.github/checks/spaces.sh
index 945e9acc3..f2eea6f3f 100755
--- a/.github/checks/spaces.sh
+++ b/.github/checks/spaces.sh
@@ -5,7 +5,7 @@ CHECK_PATH=.
cd $SCRIPT_PATH/../../
-FILES=`find $CHECK_PATH -type f \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l ' $'`
+FILES=`find $CHECK_PATH -type f \( -name \*.inc -o -name Makefile -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "test/" | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l ' $'`
cd $OLDCWD
@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
+exit 0
diff --git a/.github/checks/tabs.sh b/.github/checks/tabs.sh
index 1c32def17..ed8d45bac 100755
--- a/.github/checks/tabs.sh
+++ b/.github/checks/tabs.sh
@@ -5,7 +5,7 @@ CHECK_PATH=.
cd $SCRIPT_PATH/../../
-FILES=`find $CHECK_PATH -type f \( \( -name \*.inc -a \! -name Makefile.inc \) -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l $'\t'`
+FILES=`find $CHECK_PATH -type f \( \( -name \*.inc -a \! -name Makefile.inc \) -o -name \*.cfg -o -name \*.\[chs\] -o -name \*.mac -o -name \*.asm -o -name \*.sgml \) -print | grep -v "test/" | grep -v "libwrk/" | grep -v "testwrk/" | xargs grep -l $'\t'`
cd $OLDCWD
@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
+exit 0
diff --git a/.github/workflows/build-on-pull-request.yml b/.github/workflows/build-on-pull-request.yml
index 55be5db1e..f5aacca31 100644
--- a/.github/workflows/build-on-pull-request.yml
+++ b/.github/workflows/build-on-pull-request.yml
@@ -19,42 +19,51 @@ jobs:
- shell: bash
run: git config --global core.autocrlf input
- name: Checkout Source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Do some simple style checks
shell: bash
run: make -j2 checkstyle
+ - name: Check bsearch tables
+ shell: bash
+ run: make -j2 sorted
- name: Build the tools.
shell: bash
- run: make -j2 bin USER_CFLAGS=-Werror
+ run: make -j2 bin USER_CFLAGS=-Werror QUIET=1
+ - name: Build the dbginfo example
+ shell: bash
+ run: make -j2 -C src test QUIET=1
- name: Build the utilities.
shell: bash
- run: make -j2 util
+ run: make -j2 util QUIET=1
- name: Build the platform libraries.
shell: bash
run: make -j2 lib QUIET=1
+ - name: check test that no modules use sp
+ shell: bash
+ run: make -j2 checksp QUIET=1
- name: Run the regression tests.
shell: bash
- run: make test QUIET=1
+ run: make -j2 test QUIET=1
- name: Test that the samples can be built.
- run: make -C samples platforms
+ run: make -C samples platforms QUIET=1
- name: Test that the targettest programs can be built.
- run: make -C targettest platforms
+ run: make -C targettest platforms QUIET=1
- name: Build the document files.
shell: bash
- run: make -j2 doc
+ run: make -j2 doc QUIET=1
- name: Upload a documents snapshot.
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: docs
path: ./html
- name: Build 64-bit Windows versions of the tools.
run: |
- make -C src clean
- make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32-
+ make -C src clean QUIET=1
+ make -j2 bin QUIET=1 USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32-
build_windows:
- name: Build (Windows)
+ name: Build and Test (Windows)
runs-on: windows-latest
steps:
@@ -62,13 +71,31 @@ jobs:
run: git config --global core.autocrlf input
- name: Checkout Source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Add msbuild to PATH
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
- - name: Build app (debug)
- run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug
+ - name: Build app (x86 debug)
+ run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug -property:Platform=Win32
- - name: Build app (release)
- run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release
+ - name: Build app (x86 release)
+ run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release -property:Platform=Win32
+
+ - name: Build app (x64 release)
+ run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug -property:Platform=x64
+
+ - name: Build app (x64 release)
+ run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Release -property:Platform=x64
+
+ - name: Build utils (MinGW)
+ shell: cmd
+ run: make -j2 util QUIET=1 SHELL=cmd
+
+ - name: Build the platform libraries (make lib)
+ shell: cmd
+ run: make -j2 lib QUIET=1 SHELL=cmd
+
+ - name: Run the regression tests (make test)
+ shell: cmd
+ run: make -j2 test QUIET=1 SHELL=cmd
diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml
index 571947c9b..591b221be 100644
--- a/.github/workflows/snapshot-on-push-master.yml
+++ b/.github/workflows/snapshot-on-push-master.yml
@@ -18,10 +18,10 @@ jobs:
run: git config --global core.autocrlf input
- name: Checkout Source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Add msbuild to PATH
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
- name: Build app (debug)
run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug
@@ -44,60 +44,63 @@ jobs:
- shell: bash
run: git config --global core.autocrlf input
- name: Checkout Source
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Do some simple style checks
shell: bash
run: make -j2 checkstyle
+ - name: Check bsearch tables
+ shell: bash
+ run: make -j2 sorted
- name: Build the tools.
shell: bash
run: |
- make -j2 bin USER_CFLAGS=-Werror
- make -j2 util
+ make -j2 bin USER_CFLAGS=-Werror QUIET=1
+ make -j2 util QUIET=1
- name: Build the platform libraries.
shell: bash
run: make -j2 lib QUIET=1
- name: Run the regression tests.
shell: bash
- run: make test QUIET=1
+ run: make -j2 test QUIET=1
- name: Test that the samples can be built.
shell: bash
- run: make -j2 samples
+ run: make -j2 samples QUIET=1
- name: Remove the output from the samples tests.
shell: bash
- run: make -C samples clean
+ run: make -C samples clean QUIET=1
- name: Remove programs in util directory
shell: bash
- run: make -C util clean
+ run: make -C util clean QUIET=1
- name: Build the document files.
shell: bash
- run: make -j2 doc
+ run: make -j2 doc QUIET=1
- name: Build and package 64-bit Windows versions of the tools.
run: |
- make -C src clean
- make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32-
+ make -C src clean QUIET=1
+ make -j2 bin QUIET=1 USER_CFLAGS=-Werror CROSS_COMPILE=x86_64-w64-mingw32-
make zip
mv cc65.zip cc65-snapshot-win64.zip
- name: Build and package 32-bit Windows versions of the tools.
run: |
- make -C src clean
- make -j2 bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
+ make -C src clean QUIET=1
+ make -j2 bin USER_CFLAGS=-Werror QUIET=1 CROSS_COMPILE=i686-w64-mingw32-
make zip
mv cc65.zip cc65-snapshot-win32.zip
- name: Upload a 32-bit Snapshot Zip
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: cc65-snapshot-win32
path: cc65-snapshot-win32.zip
- name: Upload a 64-bit Snapshot Zip
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: cc65-snapshot-win64
path: cc65-snapshot-win64.zip
- name: Get the online documents repo.
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
repository: cc65/doc
# this token will expire, if it does, generate a new one as decribed in https://github.com/cc65/cc65/issues/2065
@@ -120,7 +123,7 @@ jobs:
- name: Package offline documents.
run: 7z a cc65-snapshot-docs.zip ./html/*.*
- name: Upload a Documents Snapshot Zip
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
name: cc65-snapshot-docs
path: cc65-snapshot-docs.zip
diff --git a/.github/workflows/windows-test-scheduled.yml b/.github/workflows/windows-test-scheduled.yml
index 451b37f79..2e24e1d01 100644
--- a/.github/workflows/windows-test-scheduled.yml
+++ b/.github/workflows/windows-test-scheduled.yml
@@ -30,7 +30,7 @@ jobs:
run: mkdir ~/.cache-sha
- name: Cache SHA
- uses: actions/cache@v3
+ uses: actions/cache@v4
id: check-sha
with:
path: ~/.cache-sha
@@ -43,11 +43,11 @@ jobs:
- name: Checkout source
if: steps.check-sha.outputs.cache-hit != 'true'
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Add msbuild to PATH
if: steps.check-sha.outputs.cache-hit != 'true'
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
- name: Build app (MSVC debug)
if: steps.check-sha.outputs.cache-hit != 'true'
@@ -60,19 +60,19 @@ jobs:
- name: Build utils (MinGW)
if: steps.check-sha.outputs.cache-hit != 'true'
shell: cmd
- run: make -j2 util SHELL=cmd
+ run: make -j2 util SHELL=cmd QUIET=1
- name: Build the platform libraries (make lib)
if: steps.check-sha.outputs.cache-hit != 'true'
shell: cmd
- run: make -j2 lib QUIET=1 SHELL=cmd
+ run: make -j2 lib QUIET=1 SHELL=cmd QUIET=1
- name: Run the regression tests (make test)
if: steps.check-sha.outputs.cache-hit != 'true'
shell: cmd
- run: make test QUIET=1 SHELL=cmd
+ run: make -j2 test QUIET=1 SHELL=cmd QUIET=1
- name: Test that the samples can be built (make samples)
if: steps.check-sha.outputs.cache-hit != 'true'
shell: cmd
- run: make -j2 samples SHELL=cmd
+ run: make -j2 samples SHELL=cmd QUIET=1
diff --git a/Contributing.md b/Contributing.md
index 25c6217aa..10d687424 100644
--- a/Contributing.md
+++ b/Contributing.md
@@ -1,186 +1,321 @@
-This document contains all kinds of information that you should know if you want to contribute to the cc65 project. Before you start, please read all of it. If something is not clear to you, please ask - this document is an ongoing effort and may well be incomplete.
+Contributing to cc65
+====================
-(''Note:'' The word "must" indicates a requirement. The word "should" indicates a recomendation.)
+This document contains all kinds of information that you
+should know if you want to contribute to the cc65 project.
+Before you start, please read all of it. If something is not
+clear to you, please ask - this document is an ongoing effort
+and may well be incomplete.
-*this is work in progress and is constantly updated - if in doubt, please ask*
+Also, before you put a lot of work into implementing
+something you want to contribute, please get in touch with
+one of the developers and ask if what you are going to do is
+actually wanted and has a chance of being merged. Perhaps
+someone else is already working on it, or perhaps what you
+have in mind is not how we'd expect it to be - talking to us
+before you start might save you a lot of work in those cases.
-# generally
+(''Note:'' The word "must" indicates a requirement. The word
+ "should" indicates a recomendation.)
-* You must obey these rules when contributing new code or documentation to cc65. We are well aware that not all existing code may respect all rules outlined here - but this is no reason for you not to respect them.
-* One commit/patch/PR per issue. Do not mix several things unless they are very closely related.
-* Sometimes when you make a PR, it may break completely unrelated tests. However, any PR is expected to merge cleanly with no failures. That means in practise that you are expected to fix/update the failing tests if required - for example this might be needed if you make changes to the compiler that changes the format of error- or warning messages. In that case you might have to update some reference files in the testbench. Obviously still check if that is actually the right thing to do ;)
+*this is work in progress and is constantly updated - if in
+doubt, please ask*
+
+# Generally
+
+* You must obey these rules when contributing new code or
+ documentation to cc65. We are well aware that not all
+ existing code may respect all rules outlined here - but this
+ is no reason for you not to respect them.
+* One commit/patch/PR per issue. Do not mix several things
+ unless they are very closely related.
+* Sometimes when you make a PR, it may break completely
+ unrelated tests. However, any PR is expected to merge
+ cleanly with no failures. That means in practise that you
+ are expected to fix/update the failing tests if required -
+ for example this might be needed if you make changes to the
+ compiler that changes the format of error- or warning
+ messages. In that case you might have to update some
+ reference files in the testbench. Obviously still check if
+ that is actually the right thing to do. ;)
# Codestyle rules
-## All Sources
+## All sources
### Line endings
-All files must only contain Unix style 'LF' line endings. Please configure your editors accordingly.
+All files must only contain Unix style 'LF' line endings.
+Please configure your editors accordingly.
### TABs and spaces
-This is an ongoing controversial topic - everyone knows that. However, the following is how we do it :)
+This is an ongoing controversial topic - everyone knows
+that. However, the following is how we do it :)
* TAB characters must be expanded to spaces.
-* 4 spaces per indention level (rather than 8) are preferred, especially if there are many different levels.
+* 4 spaces per indention level (rather than 8) are
+ preferred, especially if there are many different levels.
* No extra spaces at the end of lines.
-* All text files must end with new-line characters. Don't leave the last line "dangling".
+* All text files must end with new-line characters. Don't
+ leave the last line "dangling".
-The (bash) scripts used to check the above rules can be found in ```.github/check```. You can also run all checks using ```make check```.
+The (bash) scripts used to check the above rules can be
+found in ```.github/check```. You can also run all checks
+using ```make check```.
-### Identifiers and Symbol names
+### Identifiers and symbol names
-The C Standard defines certain identifiers and symbol names, which we can not use
-in our code. Since it is not always obvious which parts of the library code will
-actually end up in a linked program, the following applies to ALL of the library.
+The C Standard defines certain identifiers and symbol names,
+which we can not use in our code. Since it is not always
+obvious which parts of the library code will actually end up
+in a linked program, the following applies to ALL of the
+library.
-Any non standard identifier/symbol/function that is exported from source files,
-or appears in header files:
+Any non standard identifier/symbol/function that is exported
+from source files, or appears in header files:
-* must not be in the "_symbol" form in C, or "__symbol" form in assembly.
-* must start with (at least) two (C Code) or three (assembly code) underscores, unless the symbol appears in a non standard header file.
+* must not be in the "_symbol" form in C, or "__symbol" form
+ in assembly,
+* must start with (at least) two (C Code) or three (assembly
+ code) underscores, unless the symbol appears in a non
+ standard header file.
-This is likely more than the standard dictates us to do - but it is certainly
-standard compliant - and easy to remember.
+This is likely more than the standard dictates us to do -
+but it is certainly standard compliant - and easy to
+remember.
-Also see the discussion in https://github.com/cc65/cc65/issues/1796
+Also see the discussion in
+https://github.com/cc65/cc65/issues/1796
-### misc
+### Miscellaneous
-* 80 characters is the desired maximum width of files. But, it isn't a "strong" rule; sometimes, you will want to type longer lines, in order to keep the parts of expressions or comments together on the same line.
+* 80 characters is the desired maximum width of files. But,
+ it isn't a "strong" rule; sometimes, you will want to type
+ longer lines, in order to keep the parts of expressions or
+ comments together on the same line.
* You should avoid typing non-ASCII characters.
-* If you change "normal" source code into comments, then you must add a comment about why that code is a comment.
-* When you want to create a comment from several lines of code, you should use preprocessor lines, instead of ```/* */``` or "```;```". Example:
-
+* If you change "normal" source code into comments, then you
+ must add a comment about why that code is a comment.
+* When you want to create a comment from several lines of
+ code, you should use preprocessor lines, instead of ```/*
+ */``` or "```;```". Example:
+
+~~~C
#if 0
- one ();
- two ();
- three = two () + one ();
+ one (); two ();
+ three = two () + one ();
#endif
-
+~~~
+
* You should type upper case characters for hex values.
-* When you type zero-page addresses in hexadecimal, you should type two hex characters (after the hex prefix). When you type non-zero-page addresses in hex, you should type four hex characters.
-* When you type lists of addresses, it is a good idea to sort them in ascending numerical order. That makes it easier for readers to build mental pictures of where things are in an address space. And, it is easier to see how big the variables and buffers are. Example:
-
+* When you type zero-page addresses in hexadecimal, you
+ should type two hex characters (after the hex prefix).
+ When you type non-zero-page addresses in hex, you should
+ type four hex characters.
+* When you type lists of addresses, it is a good idea to
+ sort them in ascending numerical order. That makes it
+ easier for readers to build mental pictures of where things
+ are in an address space. And, it is easier to see how big
+ the variables and buffers are. Example:
+
+~~~asm
xCoord := $0703
-yCoord := $0705 ; (this address implies that xCoord is 16 bits)
-cmdbuf := $0706 ; (this address implies that yCoord is 8 bits)
-cmdlen := $0786 ; (this address implies that cmdbuf is 128 bytes)
+yCoord := $0705 ; (this address implies that xCoord is 16 bits)
+cmdbuf := $0706 ; (this address implies that yCoord is 8 bits)
+cmdlen := $0786 ; (this address implies that cmdbuf is 128 bytes)
color := $0787
-
+~~~
-## C Sources
+## C sources
-The following is still very incomplete - if in doubt please look at existing sourcefiles and adapt to the existing style
+The following is still very incomplete - if in doubt please
+look at existing sourcefiles and adapt to the existing style.
-* Your files should generally obey the C89 standard, with a few C99 things (this is a bit similar to what cc65 itself supports). The exceptions are:
- * use stdint.h for variables that require a certain bit size
- * In printf-style functions use the PRIX64 (and similar) macros to deal with 64bit values (from inttypes.h)
-This list is not necessarily complete - if in doubt, please ask.
+Your files should generally obey the C89 standard, with a
+few C99 things (this is a bit similar to what cc65 itself
+supports). The exceptions are:
+
+* Use stdint.h for variables that require a certain bit size
+* In printf-style functions use the PRIX64 (and similar)
+ macros to deal with 64bit values (from inttypes.h) This
+ list is not necessarily complete - if in doubt, please ask.
* We generally have a "no warnings" policy
- * Warnings must not be hidden by using typecasts - fix the code instead
+* Warnings must not be hidden by using typecasts - fix the
+ code instead
* The normal indentation width should be four spaces.
-* You must use ANSI C comments (```/* */```); you must not use C++ comments (```//```).
-* When you add functions to an existing file, you should separate them by the same number of blank lines that separate the functions that already are in that file.
-* All function declarations must be followed by a comment block that tells at least briefly what the function does, what the parameters are, and what is returned. This comment must sit between the declaration and the function body, like this:
-
+* You must use ANSI C comments (```/* */```); you must not
+ use C++ comments (```//```).
+* When you add functions to an existing file, you should
+ separate them by the same number of blank lines that
+ separate the functions that already are in that file.
+* All function declarations must be followed by a comment
+ block that tells at least briefly what the function does,
+ what the parameters are, and what is returned. This comment
+ must sit between the declaration and the function body, like
+ this:
+
+~~~C
int foo(int bar)
/* Add 1 to bar, takes bar and returns the result */
{
return bar + 1;
}
-
-* When a function's argument list wraps around to a next line, you should indent that next line by either the normal width or enough spaces to align it with the arguments on the previous line.
-* All declarations in a block must be at the beginning of that block.
-* You should put a blank line between a list of local variable declarations and the first line of code.
-* Always use curly braces even for single statements after ```if```, and the single statement should go into a new line.
-* Use "cuddling" braces, ie the opening brace goes in the same line as the ```if```:
-
+~~~
+
+* When a function's argument list wraps around to a next
+ line, you should indent that next line by either the
+ normal width or enough spaces to align it with the arguments
+ on the previous line.
+* All declarations in a block must be at the beginning of
+ that block.
+* You should put a blank line between a list of local
+ variable declarations and the first line of code.
+* Always use curly braces even for single statements after
+ ```if```, and the single statement should go into a new
+ line.
+* Use "cuddling" braces, ie the opening brace goes in the
+ same line as the ```if```:
+
+~~~C
if (foo > 42) {
bar = 23;
}
-
-* Should the ```if``` statement be followed by an empty conditional block, there should be a comment telling why this is the case
-
-* You must separate function names and parameter/argument lists by one space.
-* When declaring/defining pointers, you must put the asterisk (```*```) next to the data type, with a space between it and the variable's name. Examples:
-
- int* namedPtr[5];
- char* nextLine (FILE* f);
-
+~~~
+
+* Should the ```if``` statement be followed by an empty
+ conditional block, there should be a comment telling why
+ this is the case:
+
+~~~C
+if (check()) { /* nothing happened, do nothing */ }
+~~~
+
+* You must separate function names and parameter/argument
+ lists by one space.
+* When declaring/defining pointers, you must put the
+ asterisk (```*```) next to the data type, with a space
+ between it and the variable's name. Examples:
+
+~~~C
+int* namedPtr[5];
+char* nextLine (FILE* f);
+~~~
### Header files
-Headers that belong to the standard library (libc) must conform with the C standard. That means:
-* all non standard functions, or functions that only exist in a certain standard, should be in #ifdefs
- * the same is true for macros or typedefs
-
-#if __CC65_STD__ == __CC65_STD_C99__
-/* stuff that only exists in C99 here */
-#endif
-#if __CC65_STD__ == __CC65_STD_CC65__
-/* non standard stuff here */
-#endif
-
-You can refer to Annex B of the ISO C99 standard ([here](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) is the draft).
+* All Headers should start with a copyright/license banner
+* Function prototypes must be a single line, not contain the redundant
+ "extern" keyword, and followed by a brief comment that explains what
+ the function does, and separated from the next prototype by a blank
+ line:
-## Assembly Sources
+~~~C
+void __fastcall__ cclear (unsigned char length);
+/* Clear part of a line (write length spaces). */
-* Op-code mnemonics must have lower-case letters. The names of instruction macroes may have upper-case letters.
-* Op-codes must use their official and commonly used mnemonics, ie bcc and bcs and not bgt and blt
-* Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context.
+~~~
+
+Headers that belong to the standard library (libc) must
+conform with the C standard. That means:
+
+* All non standard functions, or functions that only exist
+ in a certain standard, should be in #ifdefs
+* The same is true for macros or typedefs.
+ You can refer to Annex B of the ISO C99 standard
+ ([here](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf)
+ is the draft). Example:
+
+~~~C
+#if __CC65_STD__ == __CC65_STD_C99__ /* stuff that only exists in C99 here */
+#endif
+#if __CC65_STD__ == __CC65_STD_CC65__ /* non standard stuff here */
+#endif
+~~~
+
+## Assembly sources
+
+* Opcode mnemonics must have lower-case letters. The names
+ of instruction macroes may have upper-case letters.
+* Opcodes must use their official and commonly used
+ mnemonics, ie 'bcc' and 'bcs' and not 'bgt' and 'blt'.
+* Hexadecimal number constants should be used except where
+ decimal or binary numbers make much more sense in that
+ constant's context.
* Hexadecimal letters should be upper-case.
-* When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes).
-* If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) This must be done in one of the following ways:
-
+* When you set two registers or two memory locations to an
+ immediate 16-bit zero, you should use the expressions
+ ```#<$0000``` and ```#>$0000``` (they make it obvious where
+ you are putting the lower and upper bytes).
+* If a function is declared to return a char-sized value, it
+ actually must return an integer-sized value. (When cc65
+ promotes a returned value, it sometimes assumes that the value
+ already is an integer.)
+ This must be done in one of the following ways:
+
+~~~asm
lda #RETURN_VALUE
ldx #0 ; Promote char return value
-
-or, if the value is 0, you can use:
-
+
+ ; If the value is 0, you can use:
lda #RETURN_VALUE
.assert RETURN_VALUE = 0
tax
-
-sometimes jumping to return0 could save a byte:
-
+
+ ; Sometimes jumping to 'return 0' could save a byte:
.assert RETURN_VALUE = 0
jmp return 0
-
-* Functions, that are intended for a platform's system library, should be optimized as much as possible.
-* Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast.
-* Comments that are put on the right side of instructions must be aligned (start in the same character columns).
-* Assembly source fields (label, operation, operand, comment) should start ''after'' character columns that are multiples of eight (such as 1, 9, 17, 33, and 41).
+~~~
+
+* Functions, that are intended for a platform's system
+ library, should be optimized as much as possible.
+* Sometimes, there must be a trade-off between size and
+ speed. If you think that a library function won't be used
+ often, then you should make it small. Otherwise, you should
+ make it fast.
+* Comments that are put on the right side of instructions
+ must be aligned (start in the same character columns).
+* Assembly source fields (label, operation, operand,
+ comment) should start ''after'' character columns that are
+ multiples of eight (such as 1, 9, 17, 33, and 41).
-## LinuxDoc Sources
+## LinuxDoc sources
* TAB characters must be expanded to spaces.
-* All text files must end with new-line characters. Don't leave the last line "dangling".
+* All text files must end with new-line characters. Don't
+ leave the last line "dangling".
* 80 characters is the desired maximum width of files.
* You should avoid typing non-ASCII characters.
* You should put blank lines between LinuxDoc sections:
- * Three blank lines between `````` sections.
- * Two blank lines between `````` sections.
- * One blank line between other sections.
+* Three blank lines between `````` sections.
+* Two blank lines between `````` sections.
+* One blank line between other sections.
# Library implementation rules
-* By default the toolchain must output a "standard" binary for the platform, no emulator formats, no extra headers used by tools. If the resulting binaries can not be run as is on emulators or eg flash cartridges, the process of converting them to something that can be used with these should be documented in the user manual.
-* Generally every function should live in a seperate source file - unless the functions are so closely related that splitting makes no sense.
-* Source files should not contain commented out code - if they do, there should be a comment that explains why that commented out code exists.
+* By default the toolchain must output a "standard" binary
+ for the platform, no emulator formats, no extra headers
+ used by tools. If the resulting binaries can not be run as
+ is on emulators or eg flash cartridges, the process of
+ converting them to something that can be used with these
+ should be documented in the user manual.
+* Generally every function should live in a seperate source
+ file - unless the functions are so closely related that
+ splitting makes no sense.
+* Source files should not contain commented out code - if
+ they do, there should be a comment that explains why that
+ commented out code exists.
# Makefile rules
-* Makefiles must generally work on both *nix (ba)sh and windows cmd.exe.
-* Makefiles must not use external tools that are not provided by the cc65 toolchain itself.
+* Makefiles must generally work on both *nix (ba)sh and
+ windows cmd.exe.
+* Makefiles must not use external tools that are not
+ provided by the cc65 toolchain itself.
-The only exception to the above are actions that are exclusive to the github actions - those may rely on bash and/or linux tools.
+The only exception to the above are actions that are exclusive
+to the github actions - those may rely on bash and/or linux tools.
# Documentation rules
@@ -190,107 +325,42 @@ The only exception to the above are actions that are exclusive to the github act
## Wiki
-* The Wiki is strictly for additional information that does not fit into the regular user manual (LinuxDoc). The wiki must not duplicate any information that is present in the user manual
+* The Wiki is strictly for additional information that does
+ not fit into the regular user manual (LinuxDoc). The wiki
+ must not duplicate any information that is present in the
+ user manual.
-# Roadmap / TODOs / open Ends
+# Roadmap / TODOs / open ends
## Documentation
-* the printf family of function does not completely implement all printf modifiers and does not behave as expected in some cases - all this should be documented in detail
+* The printf() family of functions does not completely
+ implement all printf() modifiers and does not behave as
+ expected in some cases - all this should be documented in
+ detail.
## Compiler
-* We need a way that makes it possible to feed arbitrary assembler code into the optimzer, so we can have proper tests for it
+* We need a way that makes it possible to feed arbitrary
+ assembler code into the optimzer, so we can have proper
+ tests for it.
### Floating point support
-The first step is implementing the datatype "float" as IEEE 754 floats. Help welcomed!
+The first step is implementing the datatype "float" as IEEE
+754 floats. Help welcomed!
-* WIP compiler/library changes are here: https://github.com/cc65/cc65/pull/1777
+* WIP compiler/library changes are here:
+ https://github.com/cc65/cc65/pull/1777
## Library
-### name clashes in the library
-
-see "Identifiers and Symbol names" above - not all identifiers have been checked
-and renamed yet. The following is a list of those that still might need to be
-fixed:
-
-```
-common
-
-__argc libsrc/runtime/callmain.s libsrc/cbm610/mainargs.s libsrc/cx16/mainargs.s libsrc/plus4/mainargs.s libsrc/lynx/mainargs.s libsrc/c16/mainargs.s libsrc/geos-common/system/mainargs.s libsrc/sim6502/mainargs.s libsrc/c128/mainargs.s libsrc/vic20/mainargs.s libsrc/nes/mainargs.s libsrc/atari/getargs.s libsrc/apple2/mainargs.s libsrc/cbm510/mainargs.s libsrc/telestrat/mainargs.s libsrc/c64/mainargs.s libsrc/pet/mainargs.s libsrc/atmos/mainargs.s
-__argv libsrc/runtime/callmain.s libsrc/cbm610/mainargs.s libsrc/cx16/mainargs.s libsrc/plus4/mainargs.s libsrc/lynx/mainargs.s libsrc/c16/mainargs.s libsrc/geos-common/system/mainargs.s libsrc/sim6502/mainargs.s libsrc/c128/mainargs.s libsrc/vic20/mainargs.s libsrc/nes/mainargs.s libsrc/atari/getargs.s libsrc/apple2/mainargs.s libsrc/cbm510/mainargs.s libsrc/telestrat/mainargs.s libsrc/c64/mainargs.s libsrc/pet/mainargs.s libsrc/atmos/mainargs.s
-__cos libsrc/common/sincos.s
-__ctypeidx libsrc/common/ctype.s libsrc/common/ctypemask.s libsrc/geos-common/system/ctype.s libsrc/atari/ctype.s libsrc/cbm/ctype.s libsrc/atmos/ctype.s asminc/ctype_common.inc
-__cwd libsrc/common/getcwd.s libsrc/common/_cwd.s libsrc/atari/initcwd.s libsrc/apple2/initcwd.s libsrc/apple2/initcwd.s libsrc/telestrat/initcwd.s libsrc/cbm/initcwd.s
-__cwd_buf_size libsrc/common/_cwd.s
-__envcount libsrc/common/searchenv.s libsrc/common/_environ.s libsrc/common/putenv.s libsrc/common/getenv.s
-__environ libsrc/common/searchenv.s libsrc/common/_environ.s libsrc/common/putenv.s libsrc/common/getenv.s
-__envsize libsrc/common/_environ.s libsrc/common/putenv.s
-__fdesc libsrc/common/_fdesc.s libsrc/common/fopen.s
-__filetab libsrc/common/_fdesc.s libsrc/common/_file.s asminc/_file.inc
-__fopen libsrc/common/fopen.s libsrc/common/_fopen.s
-__printf libsrc/common/vsnprintf.s libsrc/common/_printf.s libsrc/common/vfprintf.s libsrc/conio/vcprintf.s libsrc/pce/_printf.s
-__scanf libsrc/common/_scanf.inc libsrc/common/vsscanf.s libsrc/conio/vcscanf.s
-__sin libsrc/common/sincos.s
-__sys libsrc/common/_sys.s libsrc/apple2/_sys.s
-__sys_oserrlist libsrc/common/stroserr.s libsrc/geos-common/system/oserrlist.s libsrc/atari/oserrlist.s libsrc/apple2/oserrlist.s libsrc/cbm/oserrlist.s libsrc/atmos/oserrlist.s
-__syschdir libsrc/common/chdir.s libsrc/atari/syschdir.s libsrc/apple2/syschdir.s libsrc/telestrat/syschdir.s libsrc/cbm/syschdir.s
-__sysmkdir libsrc/common/mkdir.s libsrc/atari/sysmkdir.s libsrc/apple2/sysmkdir.s libsrc/telestrat/sysmkdir.s
-__sysremove libsrc/common/remove.s libsrc/geos-common/file/sysremove.s libsrc/atari/sysremove.s libsrc/atari/sysrmdir.s libsrc/apple2/sysremove.s libsrc/apple2/sysrmdir.s libsrc/telestrat/sysremove.s libsrc/cbm/sysremove.s
-__sysrename libsrc/common/rename.s libsrc/geos-common/file/sysrename.s libsrc/atari/sysrename.s libsrc/apple2/sysrename.s libsrc/cbm/sysrename.s
-__sysrmdir libsrc/common/rmdir.s libsrc/atari/sysrmdir.s libsrc/apple2/sysrmdir.s
-__sysuname libsrc/common/uname.s libsrc/cbm610/sysuname.s libsrc/cx16/sysuname.s libsrc/plus4/sysuname.s libsrc/lynx/sysuname.s libsrc/c16/sysuname.s libsrc/geos-common/system/sysuname.s libsrc/c128/sysuname.s libsrc/creativision/sysuname.s libsrc/vic20/sysuname.s libsrc/nes/sysuname.s libsrc/atari/sysuname.s libsrc/apple2/sysuname.s libsrc/cbm510/sysuname.s libsrc/telestrat/sysuname.s libsrc/c64/sysuname.s libsrc/pet/sysuname.s libsrc/atari5200/sysuname.s libsrc/atmos/sysuname.s
-
-apple2
-
-__auxtype libsrc/apple2/open.s
-__datetime libsrc/apple2/open.s
-__dos_type libsrc/apple2/dioopen.s libsrc/apple2/curdevice.s libsrc/apple2/mainargs.s libsrc/apple2/settime.s libsrc/apple2/getdevice.s libsrc/apple2/dosdetect.s libsrc/apple2/irq.s libsrc/apple2/open.s libsrc/apple2/mli.s libsrc/apple2/getres.s
-__filetype libsrc/apple2/open.s libsrc/apple2/exehdr.s
-
-
-atari
-
-__defdev libsrc/atari/posixdirent.s libsrc/atari/ucase_fn.s libsrc/atari/getdefdev.s
-__dos_type libsrc/atari/getargs.s libsrc/atari/exec.s libsrc/atari/settime.s libsrc/atari/syschdir.s libsrc/atari/dosdetect.s libsrc/atari/is_cmdline_dos.s libsrc/atari/sysrmdir.s libsrc/atari/gettime.s libsrc/atari/lseek.s libsrc/atari/getres.s libsrc/atari/getdefdev.s
-__do_oserror libsrc/atari/posixdirent.s libsrc/atari/do_oserr.s libsrc/atari/serref.s libsrc/atari/read.s libsrc/atari/write.s libsrc/atari/close.s
-__getcolor libsrc/atari/setcolor.s
-__getdefdev libsrc/atari/getdefdev.s
-__graphics libsrc/atari/graphics.s
-__inviocb libsrc/atari/serref.s libsrc/atari/ser/atrrdev.s libsrc/atari/inviocb.s libsrc/atari/read.s libsrc/atari/write.s libsrc/atari/lseek.s libsrc/atari/close.s
-__is_cmdline_dos libsrc/atari/is_cmdline_dos.s libsrc/atari/doesclrscr.s
-__rest_vecs libsrc/atari/savevec.s
-__rwsetup libsrc/atari/rwcommon.s libsrc/atari/read.s libsrc/atari/write.s
-__save_vecs libsrc/atari/savevec.s
-__scroll libsrc/atari/scroll.s
-__setcolor libsrc/atari/setcolor.s
-__setcolor_low libsrc/atari/setcolor.s
-__sio_call libsrc/atari/diowritev.s libsrc/atari/diopncls.s libsrc/atari/siocall.s libsrc/atari/diowrite.s libsrc/atari/dioread.s
-
-
-cbm
-
-__cbm_filetype libsrc/cbm/cbm_filetype.s asminc/cbm_filetype.in
-__dirread libsrc/cbm/dir.inc libsrc/cbm/dir.s
-__dirread1 libsrc/cbm/dir.inc libsrc/cbm/dir.s
-
-
-lynx
-
-__iodat libsrc/lynx/lynx-cart.s libsrc/lynx/bootldr.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc
-__iodir libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc
-__sprsys libsrc/lynx/tgi/lynx-160-102-16.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc
-__viddma libsrc/lynx/tgi/lynx-160-102-16.s libsrc/lynx/extzp.s libsrc/lynx/crt0.s libsrc/lynx/extzp.inc
-
-
-pce
-
-__nmi libsrc/pce/irq.s libsrc/pce/crt0.s
-```
+Some name clashes need to be resolved. Please see the
+[detailed list of name clashes](libsrc/NameClashes.md).
## Test suite
-* specific tests to check the optimizer (rather than the codegenerator) are needed.
-* we need more specific tests to check standard conformance of the library headers
+* Specific tests to check the optimizer (rather than the code
+ generator) are needed.
+* We need more specific tests to check standard conformance
+ of the library headers.
diff --git a/Makefile b/Makefile
index 29fcbbf96..222fea5ac 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,39 @@
-.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples test util checkstyle check
+# ---- Display info during parsing phase ----
+SILENT:=$(findstring s,$(word 1, $(MAKEFLAGS)))
+ifneq ($(SILENT),s)
+ $(info Using Makefile: $(realpath $(firstword $(MAKEFILE_LIST))) $(MAKECMDGOALS))
+endif
+
+.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples test util checkstyle check checkprefix
.SUFFIXES:
-all install zip:
- @$(MAKE) -C src --no-print-directory $@
- @$(MAKE) -C libsrc --no-print-directory $@
- @$(MAKE) -C doc --no-print-directory $@
- @$(MAKE) -C util --no-print-directory $@
- @$(MAKE) -C samples --no-print-directory $@
+all:
+ @$(MAKE) -C src --no-print-directory $@
+ @$(MAKE) -C libsrc --no-print-directory $@
+ @$(MAKE) -C doc --no-print-directory $@
+ @$(MAKE) -C util --no-print-directory $@
+ @$(MAKE) -C samples --no-print-directory $@
+ @$(MAKE) checkprefix --no-print-directory
+
+zip:
+ @$(MAKE) -C src --no-print-directory $@
+ @$(MAKE) -C libsrc --no-print-directory $@
+ @$(MAKE) -C doc --no-print-directory $@
+ @$(MAKE) -C util --no-print-directory $@
+ @$(MAKE) -C samples --no-print-directory $@
+
+install:
+ifndef PREFIX
+ifndef DESTDIR
+ $(error Error: PREFIX or DESTDIR must be set for install to work)
+endif
+endif
+ @$(MAKE) -C src --no-print-directory $@
+ @$(MAKE) -C libsrc --no-print-directory $@
+ @$(MAKE) -C doc --no-print-directory $@
+ @$(MAKE) -C util --no-print-directory $@
+ @$(MAKE) -C samples --no-print-directory $@
mostlyclean clean:
@$(MAKE) -C src --no-print-directory $@
@@ -18,30 +44,53 @@ mostlyclean clean:
@$(MAKE) -C test --no-print-directory $@
@$(MAKE) -C targettest --no-print-directory $@
-avail unavail bin:
- @$(MAKE) -C src --no-print-directory $@
+avail unavail:
+# FIXME: actually not true, PREFIX is ignored?
+#ifndef PREFIX
+# $(error Error: PREFIX must be set for avail/unavail to work)
+#endif
+ @$(MAKE) -C src --no-print-directory $@
+
+bin:
+ @$(MAKE) -C src --no-print-directory $@
+ @$(MAKE) checkprefix --no-print-directory
lib libtest:
- @$(MAKE) -C libsrc --no-print-directory $@
+ @$(MAKE) -C libsrc --no-print-directory $@
doc html info:
- @$(MAKE) -C doc --no-print-directory $@
+ @$(MAKE) -C doc --no-print-directory $@
samples:
- @$(MAKE) -C samples --no-print-directory $@
+ @$(MAKE) -C samples --no-print-directory $@
util:
- @$(MAKE) -C util --no-print-directory $@
+ @$(MAKE) -C util --no-print-directory $@
%65:
- @$(MAKE) -C src --no-print-directory $@
+ @$(MAKE) -C src --no-print-directory $@
%:
- @$(MAKE) -C libsrc --no-print-directory $@
+ @$(MAKE) -C libsrc --no-print-directory $@
+
+checkprefix:
+ifndef PREFIX
+ifndef DESTDIR
+ $(warning Warning: PREFIX and DESTDIR are empty - make install will not work)
+endif
+endif
# check the code style
checkstyle:
- @$(MAKE) -C .github/checks --no-print-directory $@
+ @$(MAKE) -C .github/checks --no-print-directory $@
+
+# check bsearch tables
+sorted:
+ @$(MAKE) -C .github/checks --no-print-directory $@
+
+# check that no modules use "sp", requires the binaries to be built first
+checksp:
+ @$(MAKE) -C .github/checks --no-print-directory $@
# runs regression tests, requires libtest target libraries
test:
@@ -50,6 +99,8 @@ test:
# GNU "check" target, which runs all tests
check:
@$(MAKE) -C .github/checks checkstyle --no-print-directory
+ @$(MAKE) -C .github/checks sorted --no-print-directory
+ @$(MAKE) -C src test --no-print-directory
@$(MAKE) test
@$(MAKE) -C targettest platforms --no-print-directory
@$(MAKE) -C samples platforms --no-print-directory
diff --git a/README.md b/README.md
index f8a0d4ff2..891c31e86 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,63 @@
-# About cc65
+The cc65 cross-compiler suite
+=============================
-cc65 is a complete cross development package for 65(C)02 systems, including
-a powerful macro assembler, a C compiler, linker, archiver and several
-other tools. cc65 has C and runtime library support for many of the old 6502 machines.
-For details look at the [Website](https://cc65.github.io).
+cc65 is a complete cross-development package for 65(C)02 systems,
+including a powerful macro assembler, a C compiler, linker, archiver,
+simulator and several other tools. cc65 has C and runtime library
+support for many of the old 6502 machines. For details look at
+the [cc65 web site](https://cc65.github.io):
+
+| Company / People | Machine / Environment |
+|-------------------------|-------------------------------------|
+| Apple | Apple II |
+| | Apple IIe enhanced |
+| Atari | Atari 400/800 |
+| | Atari 2600 |
+| | Atari 5200 |
+| | Atari 7800 |
+| | Atari XL |
+| | Lynx |
+| Tangerine | Oric Atmos |
+| Eureka | Oric Telestrat |
+| Acorn | BBC series |
+| Commodore | C128 |
+| | C16 |
+| | C64 |
+| | CBM 510/610 |
+| | PET |
+| | Plus/4 |
+| | VIC-20 |
+| VTech | CreatiVision |
+| Commander X16 Community | Commander X16 |
+| Bit Corporation | Gamate |
+| Berkeley Softworks | GEOS (Apple/CBM) |
+| LUnix Team | LUnix (C64) |
+| Nintendo | Nintendo Entertainment System (NES) |
+| Ohio Scientific | OSI C1P |
+| MOS Technology, Inc. | KIM-1 |
+| NEC | PC Engine (PCE) |
+| Dr. Jozo Dujmović | Picocomputer (RP6502) |
+| Watara | Watura/QuickShot Supervision |
+| Synertek | SYM-1 |
+| USSR | Agat-7/9 |
+
+A generic configuration to adapt cc65 to new targets is also around.
## People
-Project founder:
+cc65 is originally based on the "Small C" compiler by Ron Cain and
+enhanced by James E. Hendrix.
-* Ullrich von Bassewitz
+### Project founders
-Core team members:
+* John R. Dunning: [original implementation](https://public.websites.umich.edu/~archive/atari/8bit/Languages/Cc65/)
+ of the C compiler and runtime library, Atari hosted.
+* Ullrich von Bassewitz:
+ * moved Dunning's code to modern systems,
+ * rewrote most parts of the compiler,
+ * rewrote all of the runtime library.
+
+### Core team members
* [Christian Groessler](https://github.com/groessler): Atari, Atari5200, and CreatiVision library Maintainer
* [dqh](https://github.com/dqh-au): GHA help
@@ -19,7 +65,7 @@ Core team members:
* [groepaz](https://github.com/mrdudz): CBM library, Project Maintainer
* [Oliver Schmidt](https://github.com/oliverschmidt): Apple II library Maintainer
-External contributors:
+### External contributors
* [acqn](https://github.com/acqn): various compiler fixes
* [jedeoric](https://github.com/jedeoric): Telestrat target
@@ -28,31 +74,35 @@ External contributors:
* [Stephan Mühlstrasser](https://github.com/smuehlst): osic1p target
* [Wayne Parham](https://github.com/WayneParham): Sym-1 target
* [Dave Plummer](https://github.com/davepl): KIM-1 target
+* [rumbledethumps](https://github.com/rumbledethumps): Picocomputer target
*(The above list is incomplete, if you feel left out - please speak up or add yourself in a PR)*
-For a complete list look at the [full team list](https://github.com/orgs/cc65/teams) or the list of [all contributors](https://github.com/cc65/cc65/graphs/contributors)
+For a complete list look at the [full team list](https://github.com/orgs/cc65/teams)
+or the list of [all contributors](https://github.com/cc65/cc65/graphs/contributors).
# Contact
-For general discussion, questions, etc subscribe to the [mailing list](https://cc65.github.io/mailing-lists.html) or use the [github discussions](https://github.com/cc65/cc65/discussions).
+For general discussion, questions, etc subscribe to the
+[mailing list](https://cc65.github.io/mailing-lists.html)
+or use the [github discussions](https://github.com/cc65/cc65/discussions).
-Some of us may also be around on IRC [#cc65](https://web.libera.chat/#cc65) on libera.chat
+Some of us may also be around on IRC [#cc65](https://web.libera.chat/#cc65) on libera.chat.
# Documentation
-* The main [Documentation](https://cc65.github.io/doc) for users and developers
-
-* Info on [Contributing](Contributing.md) to the CC65 project. Please read this before working on something you want to contribute, and before reporting bugs.
-
-* The [Wiki](https://github.com/cc65/wiki/wiki) contains some extra info that does not fit into the regular documentation.
+* The main [Documentation](https://cc65.github.io/doc) for users and
+ developers.
+* Info on [Contributing](Contributing.md) to the CC65 project. Please
+ read this before working on something you want to contribute, and
+ before reporting bugs.
+* The [Wiki](https://github.com/cc65/wiki/wiki) contains some extra info
+ that does not fit into the regular documentation.
# Downloads
* [Windows 64bit Snapshot](https://sourceforge.net/projects/cc65/files/cc65-snapshot-win64.zip)
-
* [Windows 32bit Snapshot](https://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip)
-
* [Linux Snapshot DEB and RPM](https://software.opensuse.org/download.html?project=home%3Astrik&package=cc65)
[](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml)
diff --git a/asminc/agat.inc b/asminc/agat.inc
new file mode 100644
index 000000000..b96d31834
--- /dev/null
+++ b/asminc/agat.inc
@@ -0,0 +1,39 @@
+
+;-----------------------------------------------------------------------------
+; Zero page stuff
+
+WNDLFT := $20 ; Text window left
+WNDWDTH := $21 ; Text window width
+WNDTOP := $22 ; Text window top
+WNDBTM := $23 ; Text window bottom+1
+CH := $24 ; Cursor horizontal position
+CV := $25 ; Cursor vertical position
+BASL := $28 ; Text base address low
+BASH := $29 ; Text base address high
+CURSOR := $2D ; Cursor character
+TATTR := $32 ; Text attributes
+PROMPT := $33 ; Used by GETLN
+VCOUT := $36 ; COUT Subroutine Vector
+VCIN := $38 ; CIN Subroutine Vector
+RNDL := $4E ; Random counter low
+RNDH := $4F ; Random counter high
+HIMEM := $73 ; Highest available memory address+1
+
+;-----------------------------------------------------------------------------
+; Vectors
+
+DOSWARM := $03D0 ; DOS warmstart vector
+BRKVec := $03F0 ; Break vector
+SOFTEV := $03F2 ; Vector for warm start
+PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
+
+;-----------------------------------------------------------------------------
+; Hardware
+
+; Keyboard input
+KBD := $C000 ; Read keyboard
+KBDSTRB := $C010 ; Clear keyboard strobe
+
+; Game controller
+BUTN0 := $C061 ; Open-Apple Key
+BUTN1 := $C062 ; Closed-Apple Key
diff --git a/asminc/apple2.inc b/asminc/apple2.inc
index 528c463a1..bde383882 100644
--- a/asminc/apple2.inc
+++ b/asminc/apple2.inc
@@ -24,6 +24,14 @@ DOSWARM := $03D0 ; DOS warmstart vector
BRKVec := $03F0 ; Break vector
SOFTEV := $03F2 ; Vector for warm start
PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
+ROM_RST := $FFFC ; 6502 reset vector
+ROM_IRQ := $FFFE ; 6502 IRQ vector
+
+;-----------------------------------------------------------------------------
+; 80 column firmware
+
+OURCH := $057B ; Cursor horizontal position
+OURCV := $05FB ; Cursor vertical position
;-----------------------------------------------------------------------------
; Hardware
diff --git a/asminc/apple2.mac b/asminc/apple2.mac
index b9860c092..c0c957102 100644
--- a/asminc/apple2.mac
+++ b/asminc/apple2.mac
@@ -36,6 +36,12 @@
; Just output the character
_scrcode arg1
+ ; Check for an identifier
+ .elseif .match (.left (1, {arg1}), identifier)
+
+ ; Just output the identifier
+ _scrcode arg1
+
; Anything else is an error
.else
diff --git a/asminc/atari.mac b/asminc/atari.mac
index 3916254d0..952af8732 100644
--- a/asminc/atari.mac
+++ b/asminc/atari.mac
@@ -46,6 +46,12 @@
; Just output the character
_scrcode arg1
+ ; Check for an identifier
+ .elseif .match (.left (1, {arg1}), identifier)
+
+ ; Just output the identifier
+ _scrcode arg1
+
; Anything else is an error
.else
diff --git a/asminc/c65.inc b/asminc/c65.inc
new file mode 100644
index 000000000..ff3572f1f
--- /dev/null
+++ b/asminc/c65.inc
@@ -0,0 +1,239 @@
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+TXTPTR := $3C ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+FNAM_LEN := $B7 ; Length of filename
+SECADR := $B9 ; Secondary address
+DEVNUM := $BA ; Device number
+FNAM := $BB ; Address of filename
+FNAM_BANK := $BE ; Bank for filename
+KEY_COUNT := $D0 ; Number of keys in input buffer
+FKEY_COUNT := $D1 ; Characters for function key
+MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns)
+GRAPHM := $D8 ; Graphics mode flags (bits 5-7)
+CHARDIS := $D9 ; Bit 2 shadow for location $01
+CURS_X := $EC ; Cursor column
+CURS_Y := $EB ; Cursor row
+SCREEN_PTR := $E0 ; Pointer to current char in text screen
+CRAM_PTR := $E2 ; Pointer to current char in color RAM
+CHARCOLOR := $F1
+RVS := $F3 ; Reverse output flag
+SCROLL := $F8 ; Disable scrolling flag
+
+BASIC_BUF := $0200 ; Location of command-line
+BASIC_BUF_LEN = 161 ; Maximum length of command-line
+
+FKEY_LEN := $1000 ; Function key lengths
+FKEY_TEXT := $100A ; Function key texts
+
+PALFLAG := $1103 ; $FF=PAL, $00=NTSC
+INIT_STATUS := $1104 ; Flags: Reset/Restore initiation status
+TIME := $110C ; 60HZ clock
+
+KBDREPEAT := $111a
+KBDREPEATRATE := $111b
+KBDREPEATDELAY := $111c
+
+; ---------------------------------------------------------------------------
+; Vectors
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; I/O: VIC
+
+VIC := $D000
+VIC_SPR0_X := $D000
+VIC_SPR0_Y := $D001
+VIC_SPR1_X := $D002
+VIC_SPR1_Y := $D003
+VIC_SPR2_X := $D004
+VIC_SPR2_Y := $D005
+VIC_SPR3_X := $D006
+VIC_SPR3_Y := $D007
+VIC_SPR4_X := $D008
+VIC_SPR4_Y := $D009
+VIC_SPR5_X := $D00A
+VIC_SPR5_Y := $D00B
+VIC_SPR6_X := $D00C
+VIC_SPR6_Y := $D00D
+VIC_SPR7_X := $D00E
+VIC_SPR7_Y := $D00F
+VIC_SPR_HI_X := $D010
+VIC_SPR_ENA := $D015
+VIC_SPR_EXP_Y := $D017
+VIC_SPR_EXP_X := $D01D
+VIC_SPR_MCOLOR := $D01C
+VIC_SPR_BG_PRIO := $D01B
+VIC_SPR_COLL := $D01E
+VIC_SPR_BG_COLL := $D01F
+
+VIC_SPR_MCOLOR0 := $D025
+VIC_SPR_MCOLOR1 := $D026
+
+VIC_SPR0_COLOR := $D027
+VIC_SPR1_COLOR := $D028
+VIC_SPR2_COLOR := $D029
+VIC_SPR3_COLOR := $D02A
+VIC_SPR4_COLOR := $D02B
+VIC_SPR5_COLOR := $D02C
+VIC_SPR6_COLOR := $D02D
+VIC_SPR7_COLOR := $D02E
+
+VIC_CTRL1 := $D011
+VIC_CTRL2 := $D016
+
+VIC_HLINE := $D012
+
+VIC_LPEN_X := $D013
+VIC_LPEN_Y := $D014
+
+VIC_VIDEO_ADR := $D018
+
+VIC_IRR := $D019 ; Interrupt request register
+VIC_IMR := $D01A ; Interrupt mask register
+
+VIC_BORDERCOLOR := $D020
+VIC_BG_COLOR0 := $D021
+VIC_BG_COLOR1 := $D022
+VIC_BG_COLOR2 := $D023
+VIC_BG_COLOR3 := $D024
+
+
+; ---------------------------------------------------------------------------
+; I/O: FDC
+
+FDC := $D080
+
+; ---------------------------------------------------------------------------
+; I/O: SID
+
+SID1 := $D400
+SID1_S1Lo := $D400
+SID1_S1Hi := $D401
+SID1_PB1Lo := $D402
+SID1_PB1Hi := $D403
+SID1_Ctl1 := $D404
+SID1_AD1 := $D405
+SID1_SUR1 := $D406
+
+SID1_S2Lo := $D407
+SID1_S2Hi := $D408
+SID1_PB2Lo := $D409
+SID1_PB2Hi := $D40A
+SID1_Ctl2 := $D40B
+SID1_AD2 := $D40C
+SID1_SUR2 := $D40D
+
+SID1_S3Lo := $D40E
+SID1_S3Hi := $D40F
+SID1_PB3Lo := $D410
+SID1_PB3Hi := $D411
+SID1_Ctl3 := $D412
+SID1_AD3 := $D413
+SID1_SUR3 := $D414
+
+SID1_FltLo := $D415
+SID1_FltHi := $D416
+SID1_FltCtl := $D417
+SID1_Amp := $D418
+SID1_ADConv1 := $D419
+SID1_ADConv2 := $D41A
+SID1_Noise := $D41B
+SID1_Read3 := $D41C
+
+SID2 := $D420
+SID2_S1Lo := $D420
+SID2_S1Hi := $D421
+SID2_PB1Lo := $D422
+SID2_PB1Hi := $D423
+SID2_Ctl1 := $D424
+SID2_AD1 := $D425
+SID2_SUR1 := $D426
+
+SID2_S2Lo := $D427
+SID2_S2Hi := $D428
+SID2_PB2Lo := $D429
+SID2_PB2Hi := $D42A
+SID2_Ctl2 := $D42B
+SID2_AD2 := $D42C
+SID2_SUR2 := $D42D
+
+SID2_S3Lo := $D42E
+SID2_S3Hi := $D42F
+SID2_PB3Lo := $D430
+SID2_PB3Hi := $D431
+SID2_Ctl3 := $D432
+SID2_AD3 := $D433
+SID2_SUR3 := $D434
+
+SID2_FltLo := $D435
+SID2_FltHi := $D436
+SID2_FltCtl := $D437
+SID2_Amp := $D438
+SID2_ADConv1 := $D439
+SID2_ADConv2 := $D43A
+SID2_Noise := $D43B
+SID2_Read3 := $D43C
+
+; ---------------------------------------------------------------------------
+; I/O: Complex Interface Adapters
+
+CIA1 := $DC00
+CIA1_PRA := $DC00 ; Port A
+CIA1_PRB := $DC01 ; Port B
+CIA1_DDRA := $DC02 ; Data direction register for port A
+CIA1_DDRB := $DC03 ; Data direction register for port B
+CIA1_TA := $DC04 ; 16-bit timer A
+CIA1_TB := $DC06 ; 16-bit timer B
+CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second
+CIA1_TODSEC := $DC09 ; Time-of-day seconds
+CIA1_TODMIN := $DC0A ; Time-of-day minutes
+CIA1_TODHR := $DC0B ; Time-of-day hours
+CIA1_SDR := $DC0C ; Serial data register
+CIA1_ICR := $DC0D ; Interrupt control register
+CIA1_CRA := $DC0E ; Control register for timer A
+CIA1_CRB := $DC0F ; Control register for timer B
+
+CIA2 := $DD00
+CIA2_PRA := $DD00
+CIA2_PRB := $DD01
+CIA2_DDRA := $DD02
+CIA2_DDRB := $DD03
+CIA2_TA := $DD04
+CIA2_TB := $DD06
+CIA2_TOD10 := $DD08
+CIA2_TODSEC := $DD09
+CIA2_TODMIN := $DD0A
+CIA2_TODHR := $DD0B
+CIA2_SDR := $DD0C
+CIA2_ICR := $DD0D
+CIA2_CRA := $DD0E
+CIA2_CRB := $DD0F
+
+; ---------------------------------------------------------------------------
+; I/O: DMA
+
+DMA := $D700
+
+
+; ---------------------------------------------------------------------------
+; Processor Port at $01
+
+LORAM = $01 ; Enable the basic rom
+HIRAM = $02 ; Enable the kernal rom
+IOEN = $04 ; Enable I/O
+CASSDATA = $08 ; Cassette data
+CASSPLAY = $10 ; Cassette: Play
+CASSMOT = $20 ; Cassette motor on
+TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
+
+RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
+
+; temporary, to get conio working
+XSIZE = 80
+YSIZE = 50
diff --git a/asminc/cbm.mac b/asminc/cbm.mac
index 6d7ac7e8d..5c542b228 100644
--- a/asminc/cbm.mac
+++ b/asminc/cbm.mac
@@ -40,6 +40,12 @@
; Just output the character
_scrcode arg1
+ ; Check for an identifier
+ .elseif .match (.left (1, {arg1}), identifier)
+
+ ; Just output the identifier
+ _scrcode arg1
+
; Anything else is an error
.else
.error "scrcode: invalid argument type"
diff --git a/asminc/cbm_kernal.inc b/asminc/cbm_kernal.inc
index 4d78cf93f..f06483a47 100644
--- a/asminc/cbm_kernal.inc
+++ b/asminc/cbm_kernal.inc
@@ -63,6 +63,43 @@
MOUSE_GET := $FF6B
.endif
+.if .def (__MEGA65__)
+ ; extended C65 jump table
+
+; memory before $ff3b is all $ff in mega65 ROM?
+; VERSIONQ := $FF2F
+; RESET_RUN := $FF32
+; CURSOR := $FF35
+
+ SAVEFL := $FF3B
+ GETIO := $FF41
+ GETLFS := $FF44
+ KEYLOCKS := $FF47
+ ADDKEY := $FF4A
+.endif
+
+.if .def(__C65__) || .def (__MEGA65__)
+ CURSOR := $E030 ; in editor ROM
+
+ SPIN_SPOUT := $FF4D
+ CLSALL := $FF50
+ C64MODE := $FF53
+ MonitorCall := $FF56
+ BOOT_SYS := $FF59
+ PHOENIX := $FF5C
+ LKUPLA := $FF5F
+ LKUPSA := $FF62
+ SWAPPER := $FF65
+ PFKEY := $FF68
+ SETBNK := $FF6B
+ JSRFAR := $FF6E
+ JMPFAR := $FF71
+ LDA_FAR := $FF74
+ STA_FAR := $FF77
+ CMP_FAR := $FF7A
+ PRIMM := $FF7D
+.endif
+
.if .def(__C128__)
; C128 extended jump table
C64MODE := $FF4D
@@ -83,7 +120,7 @@
PRIMM := $FF7D
.endif
-.if .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+.if .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def (__MEGA65__)
CINT := $FF81
IOINIT := $FF84
RAMTAS := $FF87
@@ -96,7 +133,7 @@
CINT := $FF7E
.endif
-.if .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+.if .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def (__MEGA65__)
RESTOR := $FF8A
VECTOR := $FF8D
.elseif .def(__CBM510__) || .def(__CBM610__)
@@ -112,6 +149,17 @@
MEMBOT := $FF9C
SCNKEY := $FF9F
SETTMO := $FFA2
+.elseif .def(__C65__) || .def (__MEGA65__)
+ SETMSG := $FF90
+ SECOND := $FF93
+ TKSA := $FF96
+ MEMTOP := $FF99
+ MEMBOT := $FF9C
+ SCNKEY := $FF9F
+ MONEXIT := $FFA2
+.endif
+
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__)
ACPTR := $FFA5
CIOUT := $FFA8
UNTLK := $FFAB
@@ -136,7 +184,7 @@ CHRIN := $FFCF
BSOUT := $FFD2
CHROUT := $FFD2
-.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__)
LOAD := $FFD5
SAVE := $FFD8
SETTIM := $FFDB
@@ -147,9 +195,14 @@ CHROUT := $FFD2
STOP := $FFE1
GETIN := $FFE4
CLALL := $FFE7
-UDTIM := $FFEA
-.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+.if .def(__C65__) || .def(__MEGA65__)
+ScanStopKey := $FFEA
+.else
+UDTIM := $FFEA
+.endif
+
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__)
SCREEN := $FFED
PLOT := $FFF0
IOBASE := $FFF3
@@ -173,10 +226,10 @@ UDTIM := $FFEA
KBDREAD := $E5CF
UPDCRAMPTR := $EAB2
.elseif .def(__C64__)
- CLRSCR := $E544
- KBDREAD := $E5B4
+ CLRSCR := $E544 ; Clear the screen
+ KBDREAD := $E5B4 ; Get Character From Keyboard Buffer
NMIEXIT := $FEBC
- UPDCRAMPTR := $EA24
+ UPDCRAMPTR := $EA24 ; Update color ram pointer
.elseif .def(__C128__)
CLRSCR := $C142
KBDREAD := $C006
@@ -189,4 +242,7 @@ UDTIM := $FFEA
.elseif .def(__C16__)
CLRSCR := $D88B
KBDREAD := $D8C1
+.elseif .def(__C65__) || .def(__MEGA65__)
+; CLRSCR := $E0EC ; ???
+ KBDREAD := $E006
.endif
diff --git a/asminc/cpu.mac b/asminc/cpu.mac
index 31170fbed..092519173 100644
--- a/asminc/cpu.mac
+++ b/asminc/cpu.mac
@@ -1,24 +1,4 @@
-; CPU bitmask constants
-CPU_ISET_NONE = $0001
-CPU_ISET_6502 = $0002
-CPU_ISET_6502X = $0004
-CPU_ISET_6502DTV = $0008
-CPU_ISET_65SC02 = $0010
-CPU_ISET_65C02 = $0020
-CPU_ISET_65816 = $0040
-CPU_ISET_SWEET16 = $0080
-CPU_ISET_HUC6280 = $0100
-;CPU_ISET_M740 = $0200 not actually implemented
-CPU_ISET_4510 = $0400
-
-; CPU capabilities
-CPU_NONE = CPU_ISET_NONE
-CPU_6502 = CPU_ISET_6502
-CPU_6502X = CPU_ISET_6502|CPU_ISET_6502X
-CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502X|CPU_ISET_6502DTV
-CPU_65SC02 = CPU_ISET_6502|CPU_ISET_65SC02
-CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02
-CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816
-CPU_SWEET16 = CPU_ISET_SWEET16
-CPU_HUC6280 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_HUC6280
-CPU_4510 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_4510
+; This file is no longer needed as the symbols that were defined here are now
+; internal symbols generated by the assembler. It is kept to avoid breaking
+; old sources.
+.warning "'.macpack cpu' is no longer required"
diff --git a/asminc/lynx.inc b/asminc/lynx.inc
index 403d15d07..150bee6d1 100644
--- a/asminc/lynx.inc
+++ b/asminc/lynx.inc
@@ -79,19 +79,91 @@ MATHL = $FC6D
MATHK = $FC6E
MATHJ = $FC6F
-; Suzy Misc
+; Suzy sprite engine
+
+SPRCTL0 = $FC80
+; Sprite bits-per-pixel definitions
+BPP_MASK = %11000000 ; Mask for settings bits per pixel
+BPP_1 = %00000000
+BPP_2 = %01000000
+BPP_3 = %10000000
+BPP_4 = %11000000
+; More sprite control 0 bit definitions
+HFLIP = %00100000
+VFLIP = %00010000
+; Sprite types - redefined to reflect the reality caused by the shadow error
+TYPE_SHADOW = %00000111
+TYPE_XOR = %00000110
+TYPE_NONCOLL = %00000101 ; Non-colliding
+TYPE_NORMAL = %00000100
+TYPE_BOUNDARY = %00000011
+TYPE_BSHADOW = %00000010 ; Background shadow
+TYPE_BACKNONCOLL = %00000001 ; Background non-colliding
+TYPE_BACKGROUND = %00000000
-SPRCTL0 = $FC80
SPRCTL1 = $FC81
-SPRCOLL = $FC82
-SPRINIT = $FC83
-SUZYHREV = $FC88
-SUZYSREV = $FC89
-SUZYBUSEN = $FC90
-SPRGO = $FC91
-SPRSYS = $FC92
-JOYSTICK = $FCB0
+LITERAL = %10000000
+PACKED = %00000000
+ALGO3 = %01000000 ; Broken, do not set this bit!
+; Sprite reload mask definitions
+RELOAD_MASK = %00110000
+RENONE = %00000000 ; Reload nothing
+REHV = %00010000 ; Reload hsize, vsize
+REHVS = %00100000 ; Reload hsize, vsize, stretch
+REHVST = %00110000 ; Reload hsize, vsize, stretch, tilt
+; More sprite control 1 bit definitions
+REUSEPAL = %00001000
+SKIP = %00000100
+DRAWUP = %00000010
+DRAWLEFT = %00000001
+
+SPRCOLL = $FC82
+SPRINIT = $FC83
+SUZYHREV = $FC88
+SUZYSREV = $FC89
+SUZYBUSEN = $FC90
+
+SPRGO = $FC91
+; SPRGO bit definitions
+SPRITE_GO = %00000001 ; sprite process start bit
+EVER_ON = %00000100 ; everon detector enable
+
+SPRSYS = $FC92
+; SPRSYS bit definitions for write operations
+SIGNMATH = %10000000 ; signed math
+ACCUMULATE = %01000000 ; accumulate multiplication results
+NO_COLLIDE = %00100000 ; do not collide with any sprites (also SPRCOLL bit definition)
+VSTRETCH = %00010000 ; stretch v
+LEFTHAND = %00001000
+CLR_UNSAFE = %00000100 ; unsafe access reset
+SPRITESTOP = %00000010 ; request to stop sprite process
+; SPRSYS bit definitions for read operations
+MATHWORKING = %10000000 ; math operation in progress
+MATHWARNING = %01000000 ; accumulator overflow on multiple or divide by zero
+MATHCARRY = %00100000 ; last carry bit
+VSTRETCHING = %00010000
+LEFTHANDED = %00001000
+UNSAFE_ACCESS = %00000100 ; unsafe access performed
+SPRITETOSTOP = %00000010 ; requested to stop
+SPRITEWORKING = %00000001 ; sprite process is active
+
+JOYSTICK = $FCB0
+; JOYSTICK bit definitions
+JOYPAD_UP = %10000000
+JOYPAD_DOWN = %01000000
+JOYPAD_LEFT = %00100000
+JOYPAD_RIGHT = %00010000
+BUTTON_OPTION1 = %00001000
+BUTTON_OPTION2 = %00000100
+BUTTON_INNER = %00000010
+BUTTON_OUTER = %00000001
+
SWITCHES = $FCB1
+; SWITCHES bit definitions
+CART1_IO_INACTIVE = %00000100
+CART0_IO_INACTIVE = %00000010
+BUTTON_PAUSE = %00000001
+
RCART0 = $FCB2
RCART1 = $FCB3
LEDS = $FCC0
@@ -99,181 +171,290 @@ PARSTATUS = $FCC2
PARDATA = $FCC3
HOWIE = $FCC4
-
-; ***
+;
; *** Mikey Addresses
; ***
-; Mikey Timers
+; Mikey timers
-TIMER0 = $FD00
-TIMER1 = $FD04
-TIMER2 = $FD08
-TIMER3 = $FD0C
-TIMER4 = $FD10
-TIMER5 = $FD14
-TIMER6 = $FD18
-TIMER7 = $FD1C
-HTIMER = $FD00 ; horizontal line timer (timer 0)
-VTIMER = $FD08 ; vertical blank timer (timer 2)
-STIMER = $FD1C ; sound timer (timer 7)
+; Logical timer names
+TIMER0 = $FD00
+TIMER1 = $FD04
+TIMER2 = $FD08
+TIMER3 = $FD0C
+TIMER4 = $FD10
+TIMER5 = $FD14
+TIMER6 = $FD18
+TIMER7 = $FD1C
+HTIMER = TIMER0 ; horizontal line timer (timer 0)
+VTIMER = TIMER2 ; vertical blank timer (timer 2)
+STIMER = TIMER7 ; sound timer (timer 7)
-HTIMBKUP = $FD00 ; horizontal line timer (timer 0)
-HTIMCTLA = $FD01
-HTIMCNT = $FD02
-HTIMCTLB = $FD03
-VTIMBKUP = $FD08 ; vertical blank timer (timer 2)
-VTIMCTLA = $FD09
-VTIMCNT = $FD0A
-VTIMCTLB = $FD0B
-BAUDBKUP = $FD10 ; serial timer (timer 4)
-STIMBKUP = $FD1C ; sound timer (timer 7)
-STIMCTLA = $FD1D
-STIMCNT = $FD1E
-STIMCTLB = $FD1F
+HTIMBKUP = $FD00 ; horizontal line timer (timer 0)
+HTIMCTLA = $FD01
+HTIMCNT = $FD02
+HTIMCTLB = $FD03
+VTIMBKUP = $FD08 ; vertical blank timer (timer 2)
+VTIMCTLA = $FD09
+VTIMCNT = $FD0A
+VTIMCTLB = $FD0B
+BAUDBKUP = $FD10 ; serial timer (timer 4)
+STIMBKUP = $FD1C ; sound timer (timer 7)
+STIMCTLA = $FD1D
+STIMCNT = $FD1E
+STIMCTLB = $FD1F
-TIM0BKUP = $FD00
-TIM0CTLA = $FD01
-TIM0CNT = $FD02
-TIM0CTLB = $FD03
-TIM1BKUP = $FD04
-TIM1CTLA = $FD05
-TIM1CNT = $FD06
-TIM1CTLB = $FD07
-TIM2BKUP = $FD08
-TIM2CTLA = $FD09
-TIM2CNT = $FD0A
-TIM2CTLB = $FD0B
-TIM3BKUP = $FD0C
-TIM3CTLA = $FD0D
-TIM3CNT = $FD0E
-TIM3CTLB = $FD0F
-TIM4BKUP = $FD10
-TIM4CTLA = $FD11
-TIM4CNT = $FD12
-TIM4CTLB = $FD13
-TIM5BKUP = $FD14
-TIM5CTLA = $FD15
-TIM5CNT = $FD16
-TIM5CTLB = $FD17
-TIM6BKUP = $FD18
-TIM6CTLA = $FD19
-TIM6CNT = $FD1A
-TIM6CTLB = $FD1B
-TIM7BKUP = $FD1C
-TIM7CTLA = $FD1D
-TIM7CNT = $FD1E
-TIM7CTLB = $FD1F
+TIM0BKUP = $FD00
+TIM0CTLA = $FD01
+TIM0CNT = $FD02
+TIM0CTLB = $FD03
+TIM1BKUP = $FD04
+TIM1CTLA = $FD05
+TIM1CNT = $FD06
+TIM1CTLB = $FD07
+TIM2BKUP = $FD08
+TIM2CTLA = $FD09
+TIM2CNT = $FD0A
+TIM2CTLB = $FD0B
+TIM3BKUP = $FD0C
+TIM3CTLA = $FD0D
+TIM3CNT = $FD0E
+TIM3CTLB = $FD0F
+TIM4BKUP = $FD10
+TIM4CTLA = $FD11
+TIM4CNT = $FD12
+TIM4CTLB = $FD13
+TIM5BKUP = $FD14
+TIM5CTLA = $FD15
+TIM5CNT = $FD16
+TIM5CTLB = $FD17
+TIM6BKUP = $FD18
+TIM6CTLA = $FD19
+TIM6CNT = $FD1A
+TIM6CTLB = $FD1B
+TIM7BKUP = $FD1C
+TIM7CTLA = $FD1D
+TIM7CNT = $FD1E
+TIM7CTLB = $FD1F
+
+; Timer offsets
+TIM_BACKUP = 0
+TIM_CONTROLA = 1
+TIM_COUNT = 2
+TIM_CONTROLB = 3
+
+; TIM_CONTROLA control bits
+ENABLE_INT = %10000000
+RESET_DONE = %01000000
+ENABLE_RELOAD = %00010000
+ENABLE_COUNT = %00001000
+AUD_CLOCK_MASK = %00000111
+; Clock settings
+AUD_LINKING = %00000111
+AUD_64 = %00000110
+AUD_32 = %00000101
+AUD_16 = %00000100
+AUD_8 = %00000011
+AUD_4 = %00000010
+AUD_2 = %00000001
+AUD_1 = %00000000
+
+; TIM_CONTROLB control bits
+TIMER_DONE = %00001000
+LAST_CLOCK = %00000100
+BORROW_IN = %00000010
+BORROW_OUT = %00000001
; Mikey Audio
-AUDIO0 = $FD20 ; audio channel 0
-AUDIO1 = $FD28 ; audio channel 1
-AUDIO2 = $FD30 ; audio channel 2
-AUDIO3 = $FD38 ; audio channel 3
+AUDIO0 = $FD20 ; audio channel 0
+AUDIO1 = $FD28 ; audio channel 1
+AUDIO2 = $FD30 ; audio channel 2
+AUDIO3 = $FD38 ; audio channel 3
-AUD0VOL = $FD20
-AUD0FEED = $FD21
-AUD0OUT = $FD22
-AUD0SHIFT = $FD23
-AUD0BKUP = $FD24
-AUD0CTLA = $FD25
-AUD0CNT = $FD26
-AUD0CTLB = $FD27
-AUD1VOL = $FD28
-AUD1FEED = $FD29
-AUD1OUT = $FD2A
-AUD1SHIFT = $FD2B
-AUD1BKUP = $FD2C
-AUD1CTLA = $FD2D
-AUD1CNT = $FD2E
-AUD1CTLB = $FD2F
-AUD2VOL = $FD30
-AUD2FEED = $FD31
-AUD2OUT = $FD32
-AUD2SHIFT = $FD33
-AUD2BKUP = $FD34
-AUD2CTLA = $FD35
-AUD2CNT = $FD36
-AUD2CTLB = $FD37
-AUD3VOL = $FD38
-AUD3FEED = $FD39
-AUD3OUT = $FD3A
-AUD3SHIFT = $FD3B
-AUD3BKUP = $FD3C
-AUD3CTLA = $FD3D
-AUD3CNT = $FD3E
-AUD3CTLB = $FD3F
-MSTEREO = $FD50
+AUD0VOL = $FD20
+AUD0FEED = $FD21
+AUD0OUT = $FD22
+AUD0SHIFT = $FD23
+AUD0BKUP = $FD24
+AUD0CTLA = $FD25
+AUD0CNT = $FD26
+AUD0CTLB = $FD27
+AUD1VOL = $FD28
+AUD1FEED = $FD29
+AUD1OUT = $FD2A
+AUD1SHIFT = $FD2B
+AUD1BKUP = $FD2C
+AUD1CTLA = $FD2D
+AUD1CNT = $FD2E
+AUD1CTLB = $FD2F
+AUD2VOL = $FD30
+AUD2FEED = $FD31
+AUD2OUT = $FD32
+AUD2SHIFT = $FD33
+AUD2BKUP = $FD34
+AUD2CTLA = $FD35
+AUD2CNT = $FD36
+AUD2CTLB = $FD37
+AUD3VOL = $FD38
+AUD3FEED = $FD39
+AUD3OUT = $FD3A
+AUD3SHIFT = $FD3B
+AUD3BKUP = $FD3C
+AUD3CTLA = $FD3D
+AUD3CNT = $FD3E
+AUD3CTLB = $FD3F
-; Mikey Misc
+; AUD_CONTROL bits are almost identical to TIM_CONTROLA bits.
+; See TIM_CONTROLA above for the other definitions
+FEEDBACK_7 = %10000000
+ENABLE_INTEGRATE = %00100000
+
+; Stereo control registers follow
+; Stereo capability does not exist in all Lynxes
+; Left and right may be reversed, and if so will be corrected in a later
+; release
+ATTENREG0 = $FD40 ; Stereo attenuation registers
+ATTENREG1 = $FD41
+ATTENREG2 = $FD42
+ATTENREG3 = $FD43
+
+MPAN = $FD44
+MSTEREO = $FD50
+; Bit definitions for MPAN and MSTEREO registers
+LEFT_ATTENMASK = %11110000
+RIGHT_ATTENMASK = %00001111
+LEFT3_SELECT = %10000000
+LEFT2_SELECT = %01000000
+LEFT1_SELECT = %00100000
+LEFT0_SELECT = %00010000
+RIGHT3_SELECT = %00001000
+RIGHT2_SELECT = %00000100
+RIGHT1_SELECT = %00000010
+RIGHT0_SELECT = %00000001
+
+; Mikey interrupts
+
+INTRST = $FD80
+INTSET = $FD81
; Interrupt bits in INTRST and INTSET
-TIMER0_INTERRUPT = $01
-TIMER1_INTERRUPT = $02
-TIMER2_INTERRUPT = $04
-TIMER3_INTERRUPT = $08
-TIMER4_INTERRUPT = $10
-TIMER5_INTERRUPT = $20
-TIMER6_INTERRUPT = $40
-TIMER7_INTERRUPT = $80
+TIMER0_INTERRUPT = %00000001
+TIMER1_INTERRUPT = %00000010
+TIMER2_INTERRUPT = %00000100
+TIMER3_INTERRUPT = %00001000
+TIMER4_INTERRUPT = %00010000
+TIMER5_INTERRUPT = %00100000
+TIMER6_INTERRUPT = %01000000
+TIMER7_INTERRUPT = %10000000
-HBL_INTERRUPT = TIMER0_INTERRUPT
-VBL_INTERRUPT = TIMER2_INTERRUPT
+HBL_INTERRUPT = TIMER0_INTERRUPT
+VBL_INTERRUPT = TIMER2_INTERRUPT
SERIAL_INTERRUPT = TIMER4_INTERRUPT
-SND_INTERRUPT = TIMER7_INTERRUPT
+SND_INTERRUPT = TIMER7_INTERRUPT
-INTRST = $FD80
-INTSET = $FD81
-MAGRDY0 = $FD84
-MAGRDY1 = $FD85
-AUDIN = $FD86
-SYSCTL1 = $FD87
-MIKEYHREV = $FD88
-MIKEYSREV = $FD89
-IODIR = $FD8A
-IODAT = $FD8B
-TxIntEnable = %10000000
-RxIntEnable = %01000000
-TxParEnable = %00010000
-ResetErr = %00001000
-TxOpenColl = %00000100
-TxBreak = %00000010
-ParEven = %00000001
-TxReady = %10000000
-RxReady = %01000000
-TxEmpty = %00100000
-RxParityErr = %00010000
-RxOverrun = %00001000
-RxFrameErr = %00000100
-RxBreak = %00000010
-ParityBit = %00000001
-SERCTL = $FD8C
-SERDAT = $FD8D
-SDONEACK = $FD90
-CPUSLEEP = $FD91
-DISPCTL = $FD92
-PBKUP = $FD93
-DISPADRL = $FD94
-DISPADRH = $FD95
-MTEST0 = $FD9C
-MTEST1 = $FD9D
-MTEST2 = $FD9E
-PALETTE = $FDA0 ; hardware rgb palette
-GCOLMAP = $FDA0 ; hardware rgb palette (green)
-RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue)
+MAGRDY0 = $FD84
+MAGRDY1 = $FD85
+AUDIN = $FD86
+SYSCTL1 = $FD87
+; SYSCTL1 bit definitions
+POWERON = %00000010
+CART_ADDR_STROBE = %00000001
+MIKEYHREV = $FD88
+MIKEYSREV = $FD89
-; ***
-; *** Misc Hardware + 6502 vectors
-; ***
+IODIR = $FD8A
+IODAT = $FD8B
+; IODIR and IODAT bit definitions
+AUDIN_BIT = %00010000 ; Note that there is also the address AUDIN
+READ_ENABLE = %00010000 ; Same bit for AUDIN_BIT
+RESTLESS = %00001000
+NOEXP = %00000100 ; If set, redeye is not connected
+CART_ADDR_DATA = %00000010
+CART_POWER_OFF = %00000010 ; Same bit for CART_ADDR_DATA
+EXTERNAL_POWER = %00000001
-MAPCTL = $FFF9
-VECTORS = $FFFB
-INTVECTL = $FFFE
-INTVECTH = $FFFF
-RSTVECTL = $FFFC
-RSTVECTH = $FFFD
-NMIVECTL = $FFFA
-NMIVECTH = $FFFB
+SERCTL = $FD8C
+; SERCTL bit definitions for write operations
+TXINTEN = %10000000
+RXINTEN = %01000000
+PAREN = %00010000
+RESETERR = %00001000
+TXOPEN = %00000100
+TXBRK = %00000010
+PAREVEN = %00000001
+; SERCTL bit definitions for read operations
+TXRDY = %10000000
+RXRDY = %01000000
+TXEMPTY = %00100000
+PARERR = %00010000
+OVERRUN = %00001000
+FRAMERR = %00000100
+RXBRK = %00000010
+PARBIT = %00000001
+SERDAT = $FD8D
+SDONEACK = $FD90
+CPUSLEEP = $FD91
+DISPCTL = $FD92
+; DISPCTL bit definitions
+DISP_COLOR = %10000000 ; must be set to 1
+DISP_FOURBIT = %01000000 ; must be set to 1
+DISP_FLIP = %00100000
+DMA_ENABLE = %00010000 ; must be set to 1
+
+PBKUP = $FD93
+DISPADRL = $FD94
+DISPADRH = $FD95
+
+MTEST0 = $FD9C
+; MTEST0 bit definitions
+AT_CNT16 = %10000000
+AT_TEST = %01000000
+XCLKEN = %00100000
+UART_TURBO = %00010000
+ROM_SEL = %00001000
+ROM_TEST = %00000100
+M_TEST = %00000010
+CPU_TEST = %00000001
+
+MTEST1 = $FD9D
+; MTEST1 bit definitions
+P_CNT16 = %01000000
+REF_CNT16 = %00100000
+VID_TRIG = %00010000
+REF_TRIG = %00001000
+VID_DMA_DIS = %00000100
+REF_FAST = %00000010
+REF_DIS = %00000001
+
+MTEST2 = $FD9E
+; MTEST2 bit definitions
+V_STROBE = %00010000
+V_ZERO = %00001000
+H_120 = %00000100
+H_ZERO = %00000010
+V_BLANKEF = %00000001
+
+PALETTE = $FDA0 ; hardware rgb palette
+GCOLMAP = $FDA0 ; hardware rgb palette (green)
+RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue)
+
+; Memory mapping control and 6502 vectors
+
+MAPCTL = $FFF9
+; MAPCTL bit definitions
+TURBO_DISABLE = %10000000
+VECTOR_SPACE = %00001000 ; 1 maps RAM into specified space
+ROM_SPACE = %00000100
+MIKEY_SPACE = %00000010
+SUZY_SPACE = %00000001
+
+VECTORS = $FFFB
+INTVECTL = $FFFE
+INTVECTH = $FFFF
+RSTVECTL = $FFFC
+RSTVECTH = $FFFD
+NMIVECTL = $FFFA
+NMIVECTH = $FFFB
diff --git a/asminc/mega65.inc b/asminc/mega65.inc
new file mode 100644
index 000000000..79a4e7b03
--- /dev/null
+++ b/asminc/mega65.inc
@@ -0,0 +1,239 @@
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+TXTPTR := $3C ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+FNAM_LEN := $B7 ; Length of filename
+SECADR := $B9 ; Secondary address
+DEVNUM := $BA ; Device number
+FNAM := $BB ; Address of filename
+FNAM_BANK := $BE ; Bank for filename
+KEY_COUNT := $D0 ; Number of keys in input buffer
+FKEY_COUNT := $D1 ; Characters for function key
+MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns)
+GRAPHM := $D8 ; Graphics mode flags (bits 5-7)
+CHARDIS := $D9 ; Bit 2 shadow for location $01
+CURS_X := $EC ; Cursor column
+CURS_Y := $EB ; Cursor row
+SCREEN_PTR := $E0 ; Pointer to current char in text screen
+CRAM_PTR := $E2 ; Pointer to current char in color RAM
+CHARCOLOR := $F1
+RVS := $F3 ; Reverse output flag
+SCROLL := $F8 ; Disable scrolling flag
+
+BASIC_BUF := $0200 ; Location of command-line
+BASIC_BUF_LEN = 161 ; Maximum length of command-line
+
+FKEY_LEN := $1000 ; Function key lengths
+FKEY_TEXT := $100A ; Function key texts
+
+PALFLAG := $1103 ; $FF=PAL, $00=NTSC
+INIT_STATUS := $1104 ; Flags: Reset/Restore initiation status
+TIME := $110C ; 60HZ clock
+
+KBDREPEAT := $111a
+KBDREPEATRATE := $111b
+KBDREPEATDELAY := $111c
+
+; ---------------------------------------------------------------------------
+; Vectors
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; I/O: VIC
+
+VIC := $D000
+VIC_SPR0_X := $D000
+VIC_SPR0_Y := $D001
+VIC_SPR1_X := $D002
+VIC_SPR1_Y := $D003
+VIC_SPR2_X := $D004
+VIC_SPR2_Y := $D005
+VIC_SPR3_X := $D006
+VIC_SPR3_Y := $D007
+VIC_SPR4_X := $D008
+VIC_SPR4_Y := $D009
+VIC_SPR5_X := $D00A
+VIC_SPR5_Y := $D00B
+VIC_SPR6_X := $D00C
+VIC_SPR6_Y := $D00D
+VIC_SPR7_X := $D00E
+VIC_SPR7_Y := $D00F
+VIC_SPR_HI_X := $D010
+VIC_SPR_ENA := $D015
+VIC_SPR_EXP_Y := $D017
+VIC_SPR_EXP_X := $D01D
+VIC_SPR_MCOLOR := $D01C
+VIC_SPR_BG_PRIO := $D01B
+VIC_SPR_COLL := $D01E
+VIC_SPR_BG_COLL := $D01F
+
+VIC_SPR_MCOLOR0 := $D025
+VIC_SPR_MCOLOR1 := $D026
+
+VIC_SPR0_COLOR := $D027
+VIC_SPR1_COLOR := $D028
+VIC_SPR2_COLOR := $D029
+VIC_SPR3_COLOR := $D02A
+VIC_SPR4_COLOR := $D02B
+VIC_SPR5_COLOR := $D02C
+VIC_SPR6_COLOR := $D02D
+VIC_SPR7_COLOR := $D02E
+
+VIC_CTRL1 := $D011
+VIC_CTRL2 := $D016
+
+VIC_HLINE := $D012
+
+VIC_LPEN_X := $D013
+VIC_LPEN_Y := $D014
+
+VIC_VIDEO_ADR := $D018
+
+VIC_IRR := $D019 ; Interrupt request register
+VIC_IMR := $D01A ; Interrupt mask register
+
+VIC_BORDERCOLOR := $D020
+VIC_BG_COLOR0 := $D021
+VIC_BG_COLOR1 := $D022
+VIC_BG_COLOR2 := $D023
+VIC_BG_COLOR3 := $D024
+
+
+; ---------------------------------------------------------------------------
+; I/O: FDC
+
+FDC := $D080
+
+; ---------------------------------------------------------------------------
+; I/O: SID
+
+SID0 := $D400
+SID0_S1Lo := $D400
+SID0_S1Hi := $D401
+SID0_PB1Lo := $D402
+SID0_PB1Hi := $D403
+SID0_Ctl1 := $D404
+SID0_AD1 := $D405
+SID0_SUR1 := $D406
+
+SID0_S2Lo := $D407
+SID0_S2Hi := $D408
+SID0_PB2Lo := $D409
+SID0_PB2Hi := $D40A
+SID0_Ctl2 := $D40B
+SID0_AD2 := $D40C
+SID0_SUR2 := $D40D
+
+SID0_S3Lo := $D40E
+SID0_S3Hi := $D40F
+SID0_PB3Lo := $D410
+SID0_PB3Hi := $D411
+SID0_Ctl3 := $D412
+SID0_AD3 := $D413
+SID0_SUR3 := $D414
+
+SID0_FltLo := $D415
+SID0_FltHi := $D416
+SID0_FltCtl := $D417
+SID0_Amp := $D418
+SID0_ADConv1 := $D419
+SID0_ADConv2 := $D41A
+SID0_Noise := $D41B
+SID0_Read3 := $D41C
+
+SID1 := $D420
+SID1_S1Lo := $D420
+SID1_S1Hi := $D421
+SID1_PB1Lo := $D422
+SID1_PB1Hi := $D423
+SID1_Ctl1 := $D424
+SID1_AD1 := $D425
+SID1_SUR1 := $D426
+
+SID1_S2Lo := $D427
+SID1_S2Hi := $D428
+SID1_PB2Lo := $D429
+SID1_PB2Hi := $D42A
+SID1_Ctl2 := $D42B
+SID1_AD2 := $D42C
+SID1_SUR2 := $D42D
+
+SID1_S3Lo := $D42E
+SID1_S3Hi := $D42F
+SID1_PB3Lo := $D430
+SID1_PB3Hi := $D431
+SID1_Ctl3 := $D432
+SID1_AD3 := $D433
+SID1_SUR3 := $D434
+
+SID1_FltLo := $D435
+SID1_FltHi := $D436
+SID1_FltCtl := $D437
+SID1_Amp := $D438
+SID1_ADConv1 := $D439
+SID1_ADConv2 := $D43A
+SID1_Noise := $D43B
+SID1_Read3 := $D43C
+
+; ---------------------------------------------------------------------------
+; I/O: Complex Interface Adapters
+
+CIA1 := $DC00
+CIA1_PRA := $DC00 ; Port A
+CIA1_PRB := $DC01 ; Port B
+CIA1_DDRA := $DC02 ; Data direction register for port A
+CIA1_DDRB := $DC03 ; Data direction register for port B
+CIA1_TA := $DC04 ; 16-bit timer A
+CIA1_TB := $DC06 ; 16-bit timer B
+CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second
+CIA1_TODSEC := $DC09 ; Time-of-day seconds
+CIA1_TODMIN := $DC0A ; Time-of-day minutes
+CIA1_TODHR := $DC0B ; Time-of-day hours
+CIA1_SDR := $DC0C ; Serial data register
+CIA1_ICR := $DC0D ; Interrupt control register
+CIA1_CRA := $DC0E ; Control register for timer A
+CIA1_CRB := $DC0F ; Control register for timer B
+
+CIA2 := $DD00
+CIA2_PRA := $DD00
+CIA2_PRB := $DD01
+CIA2_DDRA := $DD02
+CIA2_DDRB := $DD03
+CIA2_TA := $DD04
+CIA2_TB := $DD06
+CIA2_TOD10 := $DD08
+CIA2_TODSEC := $DD09
+CIA2_TODMIN := $DD0A
+CIA2_TODHR := $DD0B
+CIA2_SDR := $DD0C
+CIA2_ICR := $DD0D
+CIA2_CRA := $DD0E
+CIA2_CRB := $DD0F
+
+; ---------------------------------------------------------------------------
+; I/O: DMA
+
+DMA := $D700
+
+
+; ---------------------------------------------------------------------------
+; Processor Port at $01
+
+LORAM = $01 ; Enable the basic rom
+HIRAM = $02 ; Enable the kernal rom
+IOEN = $04 ; Enable I/O
+CASSDATA = $08 ; Cassette data
+CASSPLAY = $10 ; Cassette: Play
+CASSMOT = $20 ; Cassette motor on
+TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
+
+RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
+
+; temporary, to get conio working
+XSIZE = 80
+YSIZE = 50
diff --git a/asminc/rp6502.inc b/asminc/rp6502.inc
index 7dd1b8fcd..816712abb 100644
--- a/asminc/rp6502.inc
+++ b/asminc/rp6502.inc
@@ -37,6 +37,7 @@ RIA_OP_PHI2 := $02
RIA_OP_CODEPAGE := $03
RIA_OP_LRAND := $04
RIA_OP_STDIN_OPT := $05
+RIA_OP_CLOCK := $0F
RIA_OP_CLOCK_GETRES := $10
RIA_OP_CLOCK_GETTIME := $11
RIA_OP_CLOCK_SETTIME := $12
diff --git a/asminc/sim65.inc b/asminc/sim65.inc
new file mode 100644
index 000000000..b8ea264b7
--- /dev/null
+++ b/asminc/sim65.inc
@@ -0,0 +1,75 @@
+
+; *******************************************************************************
+; ** **
+; ** sim65.inc : assembler definitions for the sim6502 and sim65c02 targets. **
+; ** **
+; ** Sidney Cadot, January 2025 **
+; ** **
+; *******************************************************************************
+
+ ; The '_peripherals' symbol is defined in the linker configuration
+ ; file to correspond to the first address in the periperal memory
+ ; aparture.
+ ;
+ ; We use it here as a base address for all peripheral addresses.
+
+ .import _peripherals
+
+; **************************************************************
+; ** **
+; ** Define assembler symbols for the "counter" peripheral. **
+; ** **
+; **************************************************************
+
+peripheral_counter_base := _peripherals + 0
+
+peripheral_counter_latch := peripheral_counter_base + 0
+peripheral_counter_select := peripheral_counter_base + 1
+peripheral_counter_value := peripheral_counter_base + 2
+
+; Values for the peripheral_counter_select register.
+
+COUNTER_SELECT_CLOCKCYCLE_COUNTER = $00
+COUNTER_SELECT_INSTRUCTION_COUNTER = $01
+COUNTER_SELECT_IRQ_COUNTER = $02
+COUNTER_SELECT_NMI_COUNTER = $03
+COUNTER_SELECT_WALLCLOCK_TIME = $80
+COUNTER_SELECT_WALLCLOCK_TIME_SPLIT = $81
+
+; ********************************************************************
+; ** **
+; ** Define assembler symbols for the "sim65 control" peripheral. **
+; ** **
+; ********************************************************************
+
+peripheral_sim65_base := _peripherals + 10
+
+peripheral_sim65_cpu_mode := peripheral_sim65_base + 0
+peripheral_sim65_trace_mode := peripheral_sim65_base + 1
+
+; Values for the peripheral_sim65_cpu_mode register.
+
+SIM65_CPU_MODE_6502 = $00
+SIM65_CPU_MODE_65C02 = $01
+SIM65_CPU_MODE_6502X = $02
+
+; Bitfield values for the peripheral_sim65_trace_mode field.
+
+SIM65_TRACE_MODE_FIELD_INSTR_COUNTER = $40
+SIM65_TRACE_MODE_FIELD_CLOCK_COUNTER = $20
+SIM65_TRACE_MODE_FIELD_PC = $10
+SIM65_TRACE_MODE_FIELD_INSTR_BYTES = $08
+SIM65_TRACE_MODE_FIELD_INSTR_ASSEMBLY = $04
+SIM65_TRACE_MODE_FIELD_CPU_REGISTERS = $02
+SIM65_TRACE_MODE_FIELD_CC65_SP = $01
+
+; Values for the peripheral_sim65_trace_mode field that fully disable / enable tracing.
+
+SIM65_TRACE_MODE_DISABLE = $00
+SIM65_TRACE_MODE_ENABLE_FULL = $7F
+
+; ************************
+; ** **
+; ** End of sim65.inc **
+; ** **
+; ************************
diff --git a/asminc/stat.inc b/asminc/stat.inc
new file mode 100644
index 000000000..e5248f06d
--- /dev/null
+++ b/asminc/stat.inc
@@ -0,0 +1,64 @@
+;****************************************************************************
+;* *
+;* stat.inc *
+;* *
+;* Stat struct *
+;* *
+;* *
+;* *
+;*(C) 2023 Colin Leroy-Mira *
+;* *
+;* *
+;*This software is provided 'as-is', without any expressed or implied *
+;*warranty. In no event will the authors be held liable for any damages *
+;*arising from the use of this software. *
+;* *
+;*Permission is granted to anyone to use this software for any purpose, *
+;*including commercial applications, and to alter it and redistribute it *
+;*freely, subject to the following restrictions: *
+;* *
+;*1. The origin of this software must not be misrepresented; you must not *
+;* claim that you wrote the original software. If you use this software *
+;* in a product, an acknowledgment in the product documentation would be *
+;* appreciated but is not required. *
+;*2. Altered source versions must be plainly marked as such, and must not *
+;* be misrepresented as being the original software. *
+;*3. This notice may not be removed or altered from any source *
+;* distribution. *
+;* *
+;****************************************************************************
+
+ .include "time.inc"
+
+;------------------------------------------------------------------------------
+; st_mode values
+
+S_IFDIR = $01
+S_IFREG = $02
+
+;------------------------------------------------------------------------------
+; struct stat
+
+.struct stat
+ st_dev .dword
+ st_ino .dword
+ st_mode .byte
+ st_nlink .dword
+ st_uid .byte
+ st_gid .byte
+ st_size .dword
+ st_atim .tag timespec
+ st_ctim .tag timespec
+ st_mtim .tag timespec
+ .ifdef __APPLE2__
+ st_access .byte
+ st_type .byte
+ st_auxtype .word
+ st_storagetype .byte
+ st_blocks .word
+ st_mod_date .word
+ st_mod_time .word
+ st_create_date .word
+ st_create_time .word
+ .endif
+.endstruct
diff --git a/asminc/statvfs.inc b/asminc/statvfs.inc
new file mode 100644
index 000000000..8674b045d
--- /dev/null
+++ b/asminc/statvfs.inc
@@ -0,0 +1,46 @@
+;****************************************************************************
+;* *
+;* statvfs.inc *
+;* *
+;* Statvfs struct *
+;* *
+;* *
+;* *
+;*(C) 2023 Colin Leroy-Mira *
+;* *
+;* *
+;*This software is provided 'as-is', without any expressed or implied *
+;*warranty. In no event will the authors be held liable for any damages *
+;*arising from the use of this software. *
+;* *
+;*Permission is granted to anyone to use this software for any purpose, *
+;*including commercial applications, and to alter it and redistribute it *
+;*freely, subject to the following restrictions: *
+;* *
+;*1. The origin of this software must not be misrepresented; you must not *
+;* claim that you wrote the original software. If you use this software *
+;* in a product, an acknowledgment in the product documentation would be *
+;* appreciated but is not required. *
+;*2. Altered source versions must be plainly marked as such, and must not *
+;* be misrepresented as being the original software. *
+;*3. This notice may not be removed or altered from any source *
+;* distribution. *
+;* *
+;****************************************************************************
+
+;------------------------------------------------------------------------------
+; struct statvfs
+
+.struct statvfs
+ f_bsize .dword
+ f_frsize .dword
+ f_blocks .dword
+ f_bfree .dword
+ f_bavail .dword
+ f_files .dword
+ f_ffree .dword
+ f_favail .dword
+ f_fsid .dword
+ f_flag .dword
+ f_namemax .dword
+.endstruct
diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc
index c57bd3de8..bbfabdf40 100644
--- a/asminc/telestrat.inc
+++ b/asminc/telestrat.inc
@@ -257,8 +257,11 @@ XBINDX = $28 ; Convert a number into hex and displays on chan
XDECIM = $29
XHEXA = $2A ; Convert a number into hex
+XMAINARGS = $2C ; Only available for Orix
+
XEDT = $2D ; Launch editor
XINSER = $2E
+XGETARGV = $2E ; Only available for Orix
XSCELG = $2F ; Search a line in editor mode
XOPEN = $30 ; Only in Orix
diff --git a/asminc/time.inc b/asminc/time.inc
index 6064b4ba3..7c1ab3177 100644
--- a/asminc/time.inc
+++ b/asminc/time.inc
@@ -66,3 +66,9 @@
.global _clock_settime
.global _localtime
.global _mktime
+
+
+;------------------------------------------------------------------------------
+; Constants
+
+CLOCK_REALTIME = 0
diff --git a/asminc/zeropage.inc b/asminc/zeropage.inc
index 6627d86b6..8d508fc5a 100644
--- a/asminc/zeropage.inc
+++ b/asminc/zeropage.inc
@@ -8,11 +8,25 @@
; by the compiler, ready for usage in asm code.
- .globalzp sp, sreg, regsave
+ .globalzp c_sp, sreg, regsave
.globalzp ptr1, ptr2, ptr3, ptr4
.globalzp tmp1, tmp2, tmp3, tmp4
.globalzp regbank
+; FIXME: there must be a less ugly way to do this
+.ifp4510
+.else
+.ifp45GS02
+.else
+
+ ; The following symbol is supplied for compatibility reasons only, it
+ ; will get removed in future versions. Using it will cause a linker
+ ; warning.
+ .globalzp sp
+.endif
+.endif
+
+
; The size of the register bank
regbanksize = 6
diff --git a/cfg/agat.cfg b/cfg/agat.cfg
new file mode 100644
index 000000000..1a740cfc7
--- /dev/null
+++ b/cfg/agat.cfg
@@ -0,0 +1,44 @@
+# Default configuration
+
+FEATURES {
+ STARTADDRESS: default = $1903;
+}
+SYMBOLS {
+ __EXEHDR__: type = import;
+ __FILETYPE__: type = weak, value = $0006; # file type
+ __STACKSIZE__: type = weak, value = $0400; # 1k stack
+ __HIMEM__: type = weak, value = $C000; # Presumed RAM end
+}
+MEMORY {
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ HEADER: file = %O, start = %S - $003A, size = $003A;
+ MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ EXEHDR: load = HEADER, type = ro, optional = yes;
+ STARTUP: load = MAIN, type = ro, optional = yes;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw, optional = yes;
+ ONCE: load = MAIN, type = ro, define = yes;
+ BSS: load = BSS, type = bss, define = yes;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
diff --git a/cfg/apple2-hgr.cfg b/cfg/apple2-hgr.cfg
index 109fbe4f6..402e53b34 100644
--- a/cfg/apple2-hgr.cfg
+++ b/cfg/apple2-hgr.cfg
@@ -17,6 +17,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -31,6 +32,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/apple2-overlay.cfg b/cfg/apple2-overlay.cfg
index 754ece90f..512b19c16 100644
--- a/cfg/apple2-overlay.cfg
+++ b/cfg/apple2-overlay.cfg
@@ -25,6 +25,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__;
OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__;
OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__;
@@ -47,6 +48,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
diff --git a/cfg/apple2-system.cfg b/cfg/apple2-system.cfg
index 3dd94d793..8720ae800 100644
--- a/cfg/apple2-system.cfg
+++ b/cfg/apple2-system.cfg
@@ -13,6 +13,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = $2000, size = $BF00 - $2000;
BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = $2000 - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -26,6 +27,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/apple2.cfg b/cfg/apple2.cfg
index 19932b1f9..c33bdee2d 100644
--- a/cfg/apple2.cfg
+++ b/cfg/apple2.cfg
@@ -17,6 +17,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -30,6 +31,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/apple2enh-hgr.cfg b/cfg/apple2enh-hgr.cfg
index 109fbe4f6..402e53b34 100644
--- a/cfg/apple2enh-hgr.cfg
+++ b/cfg/apple2enh-hgr.cfg
@@ -17,6 +17,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -31,6 +32,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/apple2enh-overlay.cfg b/cfg/apple2enh-overlay.cfg
index 754ece90f..512b19c16 100644
--- a/cfg/apple2enh-overlay.cfg
+++ b/cfg/apple2enh-overlay.cfg
@@ -25,6 +25,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__;
OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__;
OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__;
@@ -47,6 +48,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
diff --git a/cfg/apple2enh-system.cfg b/cfg/apple2enh-system.cfg
index 3dd94d793..8720ae800 100644
--- a/cfg/apple2enh-system.cfg
+++ b/cfg/apple2enh-system.cfg
@@ -13,6 +13,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = $2000, size = $BF00 - $2000;
BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = $2000 - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -26,6 +27,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/apple2enh.cfg b/cfg/apple2enh.cfg
index 19932b1f9..c33bdee2d 100644
--- a/cfg/apple2enh.cfg
+++ b/cfg/apple2enh.cfg
@@ -17,6 +17,7 @@ MEMORY {
MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
+ LOW: file = "", define = yes, start = $0800, size = %S - $0800;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -30,6 +31,7 @@ SEGMENTS {
ONCE: load = MAIN, type = ro, define = yes;
LC: load = MAIN, run = LC, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;
+ LOWBSS: load = LOW, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/atari-asm-xex.cfg b/cfg/atari-asm-xex.cfg
index f0a6291db..fddf95dd4 100644
--- a/cfg/atari-asm-xex.cfg
+++ b/cfg/atari-asm-xex.cfg
@@ -20,5 +20,6 @@ SEGMENTS {
CODE: load = MAIN, type = rw, define = yes;
RODATA: load = MAIN, type = ro optional = yes;
DATA: load = MAIN, type = rw optional = yes;
+ INIT: load = MAIN, type = bss, optional = yes, define = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}
diff --git a/cfg/atari-asm.cfg b/cfg/atari-asm.cfg
index 6fc1c2caa..f824eb264 100644
--- a/cfg/atari-asm.cfg
+++ b/cfg/atari-asm.cfg
@@ -25,6 +25,7 @@ SEGMENTS {
CODE: load = MAIN, type = rw, define = yes;
RODATA: load = MAIN, type = ro optional = yes;
DATA: load = MAIN, type = rw optional = yes;
+ INIT: load = MAIN, type = bss, optional = yes, define = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
AUTOSTRT: load = TRAILER, type = ro, optional = yes;
}
diff --git a/cfg/atari-cassette.cfg b/cfg/atari-cassette.cfg
index 13b34cc73..1d7d02f93 100644
--- a/cfg/atari-cassette.cfg
+++ b/cfg/atari-cassette.cfg
@@ -22,8 +22,8 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes, optional = yes;
- INIT: load = MAIN, type = bss, optional = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/atari-overlay.cfg b/cfg/atari-overlay.cfg
index 60f98e453..1dde26331 100644
--- a/cfg/atari-overlay.cfg
+++ b/cfg/atari-overlay.cfg
@@ -52,7 +52,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
AUTOSTRT: load = TRAILER, type = ro;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
diff --git a/cfg/atari-xex.cfg b/cfg/atari-xex.cfg
index deab5c7a5..1ab60af2e 100644
--- a/cfg/atari-xex.cfg
+++ b/cfg/atari-xex.cfg
@@ -36,7 +36,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
}
FEATURES {
diff --git a/cfg/atari.cfg b/cfg/atari.cfg
index 37337ea53..0af121de3 100644
--- a/cfg/atari.cfg
+++ b/cfg/atari.cfg
@@ -40,7 +40,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
AUTOSTRT: load = TRAILER, type = ro;
}
diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg
index e8f6d44a5..a487bdcab 100644
--- a/cfg/atari5200.cfg
+++ b/cfg/atari5200.cfg
@@ -15,7 +15,7 @@ MEMORY {
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXTZP: load = ZP, type = zp, optional = yes;
- DLIST: load = ROM , type = ro, define = yes, optional = yes;
+ DLIST: load = ROM, type = ro, define = yes, optional = yes;
STARTUP: load = ROM, type = ro, define = yes, optional = yes;
LOWCODE: load = ROM, type = ro, define = yes, optional = yes;
ONCE: load = ROM, type = ro, optional = yes;
diff --git a/cfg/atarixl-largehimem.cfg b/cfg/atarixl-largehimem.cfg
index 8f70597aa..6df9b3f80 100644
--- a/cfg/atarixl-largehimem.cfg
+++ b/cfg/atarixl-largehimem.cfg
@@ -67,7 +67,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
AUTOSTRT: load = TRAILER, type = ro;
}
diff --git a/cfg/atarixl-overlay.cfg b/cfg/atarixl-overlay.cfg
index 3b8da4256..5cfdcdbc5 100644
--- a/cfg/atarixl-overlay.cfg
+++ b/cfg/atarixl-overlay.cfg
@@ -78,7 +78,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
AUTOSTRT: load = TRAILER, type = ro;
diff --git a/cfg/atarixl-xex.cfg b/cfg/atarixl-xex.cfg
index 853096c6f..a0a4a971d 100644
--- a/cfg/atarixl-xex.cfg
+++ b/cfg/atarixl-xex.cfg
@@ -58,7 +58,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
SRPREPHDR: load = UNUSED, type = ro;
SRPREPTRL: load = UNUSED, type = ro;
diff --git a/cfg/atarixl.cfg b/cfg/atarixl.cfg
index 1517afb5a..5e7199cd3 100644
--- a/cfg/atarixl.cfg
+++ b/cfg/atarixl.cfg
@@ -65,7 +65,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro, define = yes;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, optional = yes;
+ INIT: load = MAIN, type = bss, define = yes, optional = yes;
BSS: load = MAIN, type = bss, define = yes;
AUTOSTRT: load = TRAILER, type = ro;
}
diff --git a/cfg/c16-asm.cfg b/cfg/c16-asm.cfg
new file mode 100644
index 000000000..8cb839304
--- /dev/null
+++ b/cfg/c16-asm.cfg
@@ -0,0 +1,20 @@
+FEATURES {
+ STARTADDRESS: default = $1001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $3000 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro, optional = yes;
+ DATA: load = MAIN, type = rw, optional = yes;
+ BSS: load = MAIN, type = bss, define = yes;
+}
diff --git a/cfg/c65-asm.cfg b/cfg/c65-asm.cfg
new file mode 100644
index 000000000..40904ef70
--- /dev/null
+++ b/cfg/c65-asm.cfg
@@ -0,0 +1,20 @@
+FEATURES {
+ STARTADDRESS: default = $2001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $00FE, define = yes;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $D000 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = rw;
+ RODATA: load = MAIN, type = ro, optional = yes;
+ DATA: load = MAIN, type = rw, optional = yes;
+ BSS: load = MAIN, type = bss, optional = yes, define = yes;
+}
diff --git a/cfg/c65.cfg b/cfg/c65.cfg
new file mode 100644
index 000000000..2d78d26d2
--- /dev/null
+++ b/cfg/c65.cfg
@@ -0,0 +1,44 @@
+FEATURES {
+ STARTADDRESS: default = $2001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+ __EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
+ __HIMEM__: type = weak, value = $8000;
+}
+MEMORY {
+ ZP: file = "", define = yes, start = $0018, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ HEADER: file = %O, define = yes, start = %S, size = $0010;
+ MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
+ ONCE: load = MAIN, type = ro, define = yes;
+ BSS: load = BSS, type = bss, define = yes;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
diff --git a/cfg/kim1-mtu60k.cfg b/cfg/kim1-mtu60k.cfg
new file mode 100644
index 000000000..4f24a4bf4
--- /dev/null
+++ b/cfg/kim1-mtu60k.cfg
@@ -0,0 +1,41 @@
+# kim1-mtu60k.cfg (4k)
+#
+# for expanded KIM-1 w/ K-1008 Graphics and 60K RAM
+#
+# ld65 --config kim1-mtu60k.cfg -o .bin .o
+
+FEATURES {
+ STARTADDRESS: default = $2000;
+ CONDES: segment = STARTUP,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = STARTUP,
+ type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__;
+}
+
+SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack
+ __STARTADDRESS__: type = export, value = %S;
+}
+
+MEMORY {
+ ZP: file = %O, define = yes, start = $0000, size = $00EE;
+ CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
+ RAM: file = %O, define = yes, start = %S, size = $E000 - %S - __STACKSIZE__;
+ MAINROM: file = "", define = yes, start = $E000, size = $1000;
+ TOP: file = "", define = yes, start = $F000, size = $1000;
+}
+
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, define = yes;
+ STARTUP: load = RAM, type = ro, define = yes;
+ CODE: load = RAM, type = ro, define = yes;
+ RODATA: load = RAM, type = ro, define = yes;
+ ONCE: load = RAM, type = ro, define = yes;
+ DATA: load = RAM, type = rw, define = yes;
+ BSS: load = RAM, type = bss, define = yes;
+}
+
diff --git a/cfg/kim1-mtuE000.cfg b/cfg/kim1-mtuE000.cfg
new file mode 100644
index 000000000..5f93cc13f
--- /dev/null
+++ b/cfg/kim1-mtuE000.cfg
@@ -0,0 +1,41 @@
+# kim1-mtu60k.cfg (4k)
+#
+# for expanded KIM-1 w/ K-1008 Graphics and 60K RAM
+#
+# ld65 --config kim1-mtu60k.cfg -o .bin .o
+
+FEATURES {
+ STARTADDRESS: default = $E000;
+ CONDES: segment = STARTUP,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = STARTUP,
+ type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__;
+}
+
+SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0080; # 128 byte program stack
+ __STARTADDRESS__: type = export, value = %S;
+}
+
+MEMORY {
+ ZP: file = %O, define = yes, start = $0000, size = $00EE;
+ CPUSTACK: file = "", define = yes, start = $0100, size = $0100;
+ RAM: file = %O, define = yes, start = $2000, size = $E000 - $2000 - __STACKSIZE__;
+ MAINROM: file = "", define = yes, start = $E000, size = $1000;
+ TOP: file = "", define = yes, start = $F000, size = $1000;
+}
+
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, define = yes;
+ STARTUP: load = RAM, type = ro, define = yes;
+ CODE: load = RAM, type = ro, define = yes;
+ RODATA: load = RAM, type = ro, define = yes;
+ ONCE: load = RAM, type = ro, define = yes;
+ DATA: load = RAM, type = rw, define = yes;
+ BSS: load = RAM, type = bss, define = yes;
+}
+
diff --git a/cfg/lynx-uploader.cfg b/cfg/lynx-uploader.cfg
index 476b3c5de..62269de90 100644
--- a/cfg/lynx-uploader.cfg
+++ b/cfg/lynx-uploader.cfg
@@ -5,16 +5,17 @@ SYMBOLS {
__BANK1BLOCKSIZE__: type = weak, value = $0000; # bank 1 block size
__EXEHDR__: type = import;
__BOOTLDR__: type = import;
- __DEFDIR__: type = import;
__UPLOADER__: type = import;
+ __UPLOADERSIZE__: type = export, value = $61;
+ __HEADERSIZE__: type = export, value = 64;
}
MEMORY {
ZP: file = "", define = yes, start = $0000, size = $0100;
- HEADER: file = %O, start = $0000, size = $0040;
+ HEADER: file = %O, start = $0000, size = __HEADERSIZE__;
BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__;
- DIR: file = %O, start = $0000, size = 8;
- MAIN: file = %O, define = yes, start = $0200, size = $BD38 - __STACKSIZE__;
- UPLDR: file = %O, define = yes, start = $BFDC, size = $005C;
+ DIR: file = %O, start = $0000, size = 16;
+ MAIN: file = %O, define = yes, start = $0200, size = $C038 - __UPLOADERSIZE__ - $200 - __STACKSIZE__;
+ UPLOAD: file = %O, define = yes, start = $C038 - __UPLOADERSIZE__, size = $0061;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -30,8 +31,8 @@ SEGMENTS {
RODATA: load = MAIN, type = ro, define = yes;
DATA: load = MAIN, type = rw, define = yes;
BSS: load = MAIN, type = bss, define = yes;
- UPCODE: load = UPLDR, type = ro, define = yes;
- UPDATA: load = UPLDR, type = rw, define = yes;
+ UPCODE: load = UPLOAD, type = ro, define = yes;
+ UPDATA: load = UPLOAD, type = rw, define = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/cfg/mega65-asm.cfg b/cfg/mega65-asm.cfg
new file mode 100644
index 000000000..40904ef70
--- /dev/null
+++ b/cfg/mega65-asm.cfg
@@ -0,0 +1,20 @@
+FEATURES {
+ STARTADDRESS: default = $2001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $00FE, define = yes;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $D000 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = rw;
+ RODATA: load = MAIN, type = ro, optional = yes;
+ DATA: load = MAIN, type = rw, optional = yes;
+ BSS: load = MAIN, type = bss, optional = yes, define = yes;
+}
diff --git a/cfg/mega65.cfg b/cfg/mega65.cfg
new file mode 100644
index 000000000..2d78d26d2
--- /dev/null
+++ b/cfg/mega65.cfg
@@ -0,0 +1,44 @@
+FEATURES {
+ STARTADDRESS: default = $2001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+ __EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
+ __HIMEM__: type = weak, value = $8000;
+}
+MEMORY {
+ ZP: file = "", define = yes, start = $0018, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ HEADER: file = %O, define = yes, start = %S, size = $0010;
+ MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
+ ONCE: load = MAIN, type = ro, define = yes;
+ BSS: load = BSS, type = bss, define = yes;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
diff --git a/cfg/plus4-asm.cfg b/cfg/plus4-asm.cfg
new file mode 100644
index 000000000..df47ba06e
--- /dev/null
+++ b/cfg/plus4-asm.cfg
@@ -0,0 +1,20 @@
+FEATURES {
+ STARTADDRESS: default = $1001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $FD00 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro, optional = yes;
+ DATA: load = MAIN, type = rw, optional = yes;
+ BSS: load = MAIN, type = bss, define = yes;
+}
diff --git a/cfg/plus4-hires.cfg b/cfg/plus4-hires.cfg
new file mode 100644
index 000000000..0426c8d8c
--- /dev/null
+++ b/cfg/plus4-hires.cfg
@@ -0,0 +1,56 @@
+# Linker configuration that allows for a hi-res bitmap at $C000-$DF3F, but
+# puts the stack (and a "HIBSS" segment) in the remaining RAM at $DF40-$FD00.
+
+FEATURES {
+ STARTADDRESS: default = $1001;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+ __EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
+ __HIMEM__: type = weak, value = $FD00;
+}
+MEMORY {
+ # Reserve 8000 bytes at $C000 for 320x200 bitmap
+ RESERVED: file = "", define = yes, start = $C000, size = 8000;
+
+ ZP: file = "", define = yes, start = $0002, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ HEADER: file = %O, define = yes, start = %S, size = $000D;
+ MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __RESERVED_START__ - __MAIN_START__;
+
+ # Space between bitmap and top of memory
+ HIRAM: file = "", define = yes, start = __RESERVED_LAST__, size = __HIMEM__ - __HIRAM_START__ - __STACKSIZE__;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ ONCE: load = MAIN, type = ro, optional = yes;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = bss;
+ BSS: load = MAIN, type = bss, define = yes;
+
+ # Allow data between bitmap and top of memory to be used as a second BSS
+ # space. Define symbols for it so that it can be supplied to _heapadd().
+ HIBSS: load = HIRAM, type = bss, optional = yes, define = yes;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
diff --git a/cfg/sim6502.cfg b/cfg/sim6502.cfg
index 39c33581c..72098f750 100644
--- a/cfg/sim6502.cfg
+++ b/cfg/sim6502.cfg
@@ -1,12 +1,15 @@
SYMBOLS {
__EXEHDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
+ _peripherals: type = export, value = $FFC0;
}
+
MEMORY {
ZP: file = "", start = $0000, size = $0100;
HEADER: file = %O, start = $0000, size = $000C;
- MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
+ MAIN: file = %O, define = yes, start = $0200, size = $FFC0 - $0200 - __STACKSIZE__;
}
+
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
EXEHDR: load = HEADER, type = ro;
@@ -18,6 +21,7 @@ SEGMENTS {
DATA: load = MAIN, type = rw;
BSS: load = MAIN, type = bss, define = yes;
}
+
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
diff --git a/cfg/sim65c02.cfg b/cfg/sim65c02.cfg
index 39c33581c..72098f750 100644
--- a/cfg/sim65c02.cfg
+++ b/cfg/sim65c02.cfg
@@ -1,12 +1,15 @@
SYMBOLS {
__EXEHDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
+ _peripherals: type = export, value = $FFC0;
}
+
MEMORY {
ZP: file = "", start = $0000, size = $0100;
HEADER: file = %O, start = $0000, size = $000C;
- MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
+ MAIN: file = %O, define = yes, start = $0200, size = $FFC0 - $0200 - __STACKSIZE__;
}
+
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
EXEHDR: load = HEADER, type = ro;
@@ -18,6 +21,7 @@ SEGMENTS {
DATA: load = MAIN, type = rw;
BSS: load = MAIN, type = bss, define = yes;
}
+
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
diff --git a/cfg/vic20-asm-32k.cfg b/cfg/vic20-asm-32k.cfg
new file mode 100644
index 000000000..3d0341e71
--- /dev/null
+++ b/cfg/vic20-asm-32k.cfg
@@ -0,0 +1,22 @@
+# Assembly program configuration for expanded VICs (>= +8K).
+
+FEATURES {
+ STARTADDRESS: default = $1201;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $001A, define = yes;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $8000 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ BSS: load = MAIN, type = bss, optional = yes, define = yes;
+}
diff --git a/cfg/vic20-asm-3k.cfg b/cfg/vic20-asm-3k.cfg
new file mode 100644
index 000000000..6ef06957e
--- /dev/null
+++ b/cfg/vic20-asm-3k.cfg
@@ -0,0 +1,22 @@
+# Assembly program configuration for expanded VICs (+3K only).
+
+FEATURES {
+ STARTADDRESS: default = $0401;
+}
+SYMBOLS {
+ __LOADADDR__: type = import;
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $001A, define = yes;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ MAIN: file = %O, start = %S, size = $1E00 - %S;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ BSS: load = MAIN, type = bss, optional = yes, define = yes;
+}
diff --git a/cfg/vic20-asm.cfg b/cfg/vic20-asm.cfg
index 286a7f95c..531d3f010 100644
--- a/cfg/vic20-asm.cfg
+++ b/cfg/vic20-asm.cfg
@@ -1,3 +1,5 @@
+# Assembly program configuration for unexpanded VICs.
+
FEATURES {
STARTADDRESS: default = $1001;
}
@@ -7,11 +9,12 @@ SYMBOLS {
MEMORY {
ZP: file = "", start = $0002, size = $001A, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
- MAIN: file = %O, start = %S, size = $0DF3 - %S;
+ MAIN: file = %O, start = %S, size = $1E00 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
+ EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
diff --git a/doc/Makefile b/doc/Makefile
index bfdf0cce3..330f7b31c 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,3 +1,9 @@
+# ---- Display info during parsing phase ----
+SILENT:=$(findstring s,$(word 1, $(MAKEFLAGS)))
+ifneq ($(SILENT),s)
+ $(info Using Makefile: $(realpath $(firstword $(MAKEFILE_LIST))) $(MAKECMDGOALS))
+endif
+
ifneq ($(shell echo),)
CMD_EXE = 1
endif
diff --git a/doc/agat.sgml b/doc/agat.sgml
new file mode 100644
index 000000000..ca5338c5f
--- /dev/null
+++ b/doc/agat.sgml
@@ -0,0 +1,79 @@
+
+
+
+Agat-7/9 - specific information for cc65
+
+,
+
+
+
+An overview over the Agat-7 and Agat-9 and theirs interfaces to the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+
The Agat was a series of 8-bit computers produced in the Soviet Union from 1983 to 1993.
+It was based on Apple II architecture with all electronic components made in the Soviet Union except for 6502 microprocessors supplied by UMC (UM6502A).
+
If compared to Apple II, Agat had many improvements such as color text mode, additional graphic modes and flexible memory controller.
+Agat-7 had an Apple II compatibility card called "Module 121", while Agat-9 had a built-in Apple II+ mode activated by soft-switch.
+
All mass-produced Agat models were disk-based systems, 2K ROM contained only basic machine language monitor and disassembler.
+Agat-7 had 140K floppy-drive based on Apple DISK II, while Agat-9 was supplied with 840K drive having its own sector format and controller.
+
+Binary format
+
+The standard binary file format generated by the linker for the Agat target is
+an AppleSingle file to be compatible with AppleCommander .
+The default load address is $1903.
+
+
+
+Platform-specific header files
+
+Programs containing Agat-specific code may use the Usefull info
+
+ Most informative source on Agat (in russian) -
+ Wikipedia -
+ Controversial article on Agat from .
+The author reviewed custom-build mockup Agat bearing little relation to even the early Agat systems.
+
+
+
+License
+
+This software is provided "as-is", without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated, but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/apple2.sgml b/doc/apple2.sgml
index 97724c147..ec9598d04 100644
--- a/doc/apple2.sgml
+++ b/doc/apple2.sgml
@@ -62,7 +62,7 @@ Special locations:
While running LC address: $D000, LC size: $3000
+ LC address: $D000, LC size: $2FFC
For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all.