Merge branch 'master' into seglist

This commit is contained in:
Bob Andrews
2025-07-03 23:16:51 +02:00
committed by GitHub
1009 changed files with 46517 additions and 9851 deletions

16
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -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.

View File

@@ -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.

9
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -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

View File

@@ -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

22
.github/checks/checksp.sh vendored Executable file
View File

@@ -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}

View File

@@ -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

View File

@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
exit 0

View File

@@ -16,3 +16,4 @@ if [ x"$FILES"x != xx ]; then
done
exit -1
fi
exit 0

39
.github/checks/sorted.sh vendored Executable file
View File

@@ -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

69
.github/checks/sorted_codeopt.sh vendored Executable file
View File

@@ -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

40
.github/checks/sorted_opcodes.sh vendored Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:
<pre>
* 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
</pre>
~~~
* 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:
<pre>
* 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
</pre>
~~~
## 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:
<pre>
* 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;
}
</pre>
* 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```:
<pre>
~~~
* 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;
}
</pre>
* Should the ```if``` statement be followed by an empty conditional block, there should be a comment telling why this is the case
<pre>
if (check()) {
/* nothing happened, do nothing */
}
</pre>
* 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:
<pre>
int* namedPtr[5];
char* nextLine (FILE* f);
</pre>
~~~
* 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
<pre>
#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
</pre>
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 </pre>
~~~
## 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:
<pre>
* 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
</pre>
or, if the value is 0, you can use:
<pre>
; If the value is 0, you can use:
lda #RETURN_VALUE
.assert RETURN_VALUE = 0
tax
</pre>
sometimes jumping to return0 could save a byte:
<pre>
; Sometimes jumping to 'return 0' could save a byte:
.assert RETURN_VALUE = 0
jmp return 0
</pre>
* 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
* 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
* 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 ```<sect>``` sections.
* Two blank lines between ```<sect1>``` sections.
* One blank line between other sections.
* Three blank lines between ```<sect>``` sections.
* Two blank lines between ```<sect1>``` 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.

View File

@@ -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

View File

@@ -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)
[![Snapshot Build](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml/badge.svg?branch=master)](https://github.com/cc65/cc65/actions/workflows/snapshot-on-push-master.yml)

39
asminc/agat.inc Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

239
asminc/c65.inc Normal file
View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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

239
asminc/mega65.inc Normal file
View File

@@ -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

View File

@@ -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

75
asminc/sim65.inc Normal file
View File

@@ -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 **
; ** **
; ************************

64
asminc/stat.inc Normal file
View File

@@ -0,0 +1,64 @@
;****************************************************************************
;* *
;* stat.inc *
;* *
;* Stat struct *
;* *
;* *
;* *
;*(C) 2023 Colin Leroy-Mira <colin@colino.net> *
;* *
;* *
;*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

46
asminc/statvfs.inc Normal file
View File

@@ -0,0 +1,46 @@
;****************************************************************************
;* *
;* statvfs.inc *
;* *
;* Statvfs struct *
;* *
;* *
;* *
;*(C) 2023 Colin Leroy-Mira <colin@colino.net> *
;* *
;* *
;*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

View File

@@ -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

View File

@@ -66,3 +66,9 @@
.global _clock_settime
.global _localtime
.global _mktime
;------------------------------------------------------------------------------
; Constants
CLOCK_REALTIME = 0

View File

@@ -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

44
cfg/agat.cfg Normal file
View File

@@ -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__;
}

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

20
cfg/c16-asm.cfg Normal file
View File

@@ -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;
}

20
cfg/c65-asm.cfg Normal file
View File

@@ -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;
}

44
cfg/c65.cfg Normal file
View File

@@ -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__;
}

41
cfg/kim1-mtu60k.cfg Normal file
View File

@@ -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 <prog>.bin <prog>.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;
}

41
cfg/kim1-mtuE000.cfg Normal file
View File

@@ -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 <prog>.bin <prog>.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;
}

View File

@@ -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,

20
cfg/mega65-asm.cfg Normal file
View File

@@ -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;
}

44
cfg/mega65.cfg Normal file
View File

@@ -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__;
}

20
cfg/plus4-asm.cfg Normal file
View File

@@ -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;
}

56
cfg/plus4-hires.cfg Normal file
View File

@@ -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__;
}

View File

@@ -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__,

View File

@@ -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__,

22
cfg/vic20-asm-32k.cfg Normal file
View File

@@ -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;
}

22
cfg/vic20-asm-3k.cfg Normal file
View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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

79
doc/agat.sgml Normal file
View File

@@ -0,0 +1,79 @@
<!doctype linuxdoc system>
<article>
<title>Agat-7/9 - specific information for cc65
<author><url url="https://sourceforge.net/u/olegodintsov/profile/" name="Oleg A. Odintsov">,<newline>
<url url="mailto:sintechs@gmail.com" name="Konstantin Fedorov">
<abstract>
An overview over the Agat-7 and Agat-9 and theirs interfaces to the cc65 C
compiler.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview
<p>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).
<p>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.
<p>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.
<sect>Binary format<p>
The standard binary file format generated by the linker for the Agat target is
an AppleSingle file to be compatible with AppleCommander <url url="https://applecommander.github.io/">.
The default load address is &dollar;1903.
<sect>Platform-specific header files<p>
Programs containing Agat-specific code may use the <tt/agat.h/ or
<tt/agat.inc/ include files.
<sect>Usefull info<p>
<sect1>Emulation<p>
<enum>
<item> Oleg Odintsov's Agat Emulator - <url url="https://agatemulator.sourceforge.net/english.html">
<item> MAME - <url url="https://www.mamedev.org/">
</enum>
<sect1>Links<p>
<enum>
<item> Most informative source on Agat (in russian) - <url url="https://agatcomp.ru">
<item> Wikipedia - <url url="https://en.wikipedia.org/wiki/Agat_(computer)">
<item> Controversial article on Agat from <url name="BYTE Magazine November 1984 Vol. 9, No. 12" url="https://archive.org/details/byte-magazine-1984-11/page/n135/mode/2up?view=theater">.
The author reviewed custom-build mockup Agat bearing little relation to even the early Agat systems.
</enum>
<sect>License<p>
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:
<enum>
<item> 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.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

View File

@@ -62,7 +62,7 @@ Special locations:
</descrip><p>
While running <tt/main()/ the Language Card bank 2 is enabled for read access.
However while running module constructors/destructors the Language Card is disabled.
However while running module constructors the Language Card is disabled.
Enabling the Language Card allows to use it as additional memory for cc65
generated code. However code is never automatically placed there. Rather code
@@ -87,12 +87,33 @@ several useful settings:
exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank
2 at all.
<tag>LC address: &dollar;D000, LC size: &dollar;3000</tag>
<tag>LC address: &dollar;D000, LC size: &dollar;2FFC</tag>
For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all.
</descrip><p>
<descrip>
<tag/Installing your code in the Language Card/
The code in the LC segment will automatically be copied from the end of the
binary into the Language Card at startup, even if the segment is empty (a
0-byte copy). This allows for tighter code. This code will be copied using the
Applesoft BLTU2 function that is available starting with the Apple ][+,
but not in the original Apple ][ with an Integer BASIC ROM. This shows as
a "RANGE ERROR. STOPPING AT ..." message on startup.
If you want to target the Integer BASIC original Apple ][, you can link in an
alternative implementation of the LC segment loading, at the cost of linking
in memcpy (60 bytes):
Using <tt/apple2-integer-basic-compat.o/ is as simple as placing it on the linker
command line like this:
<tscreen><verb>
cl65 -t apple2 myprog.c apple2-integer-basic-compat.o
</verb></tscreen>
</descrip>
<sect>Linker configurations<label id="link-configs"><p>
@@ -289,9 +310,9 @@ the memory from &dollar;800 to &dollar;1FFF can be added to the heap by calling
ProDOS 8 requires for every open file a page-aligned 1 KB I/O buffer. By default
these buffers are allocated by the cc65 runtime system on the heap using
<tt/posix_memalign()/. While this is generally the best solution it means quite
some overhead for (especially rather small) cc65 programs which do open files
but don't make use of the heap otherwise.
<url url="funcref.html#posix_memalign" name="posix_memalign()">. While this is
generally the best solution it means quite some overhead for (especially rather
small) cc65 programs which do open files but don't make use of the heap otherwise.
The apple2 package comes with the alternative ProDOS 8 I/O buffer allocation
module <tt/apple2-iobuf-0800.o/ which uses the memory between &dollar;800 and
@@ -321,18 +342,40 @@ Programs containing Apple&nbsp;&rsqb;&lsqb; specific code may use the
<sect1>Apple&nbsp;&rsqb;&lsqb; specific functions<p>
The functions listed below are special for the Apple&nbsp;&rsqb;&lsqb;. See
the <url url="funcref.html" name="function reference"> for declaration and
The functions and variables listed below are special for the Apple&nbsp;&rsqb;&lsqb;.
See the <url url="funcref.html" name="function reference"> for declaration and
usage.
<itemize>
<item>_auxtype
<item>_dos_type
<item>_filetype
<item>_datetime
<item>allow_lowercase
<item>beep
<item>dir_entry_count
<item>get_tv
<item>get_ostype
<item>gmtime_dt
<item>mktime_dt
<item>rebootafterexit
<item>ser_apple2_slot
<item>tgi_apple2_mix
<item>videomode
</itemize>
<sect1>Apple IIgs specific functions in accelerator.h<p>
In addition to those, the <tt/accelerator.h/ header file contains three functions
to help determine whether the program is running on a IIgs, and change the IIgs
CPU speed. See the <url url="funcref.html" name="function reference"> for declaration and
usage.
<itemize>
<item>detect_iigs
<item>get_iigs_speed
<item>set_iigs_speed
</itemize>
@@ -364,6 +407,10 @@ The names in the parentheses denote the symbols to be used for static linking of
with <tt/-S $4000/ to reserve the first hires page or with <tt/-S $6000/
to reserve both hires pages.
Note that the second hires page is only available if the text display is not in
80 column mode. This can be asserted by calling <tt/videomode (VIDEOMODE_40COL);/
before installing the driver.
The function <tt/tgi_apple2_mix()/ allows to activate 4 lines of text. The
function doesn't clear the corresponding area at the bottom of the screen.
@@ -434,10 +481,15 @@ The names in the parentheses denote the symbols to be used for static linking of
(RTS/CTS) and does interrupt driven receives. Speeds faster than 9600 baud
aren't reachable because the ROM and ProDOS IRQ handlers are too slow.
Software flow control (XON/XOFF) is not supported.
Note that because of the peculiarities of the 6551 chip transmits are not
interrupt driven, and the transceiver blocks if the receiver asserts
flow control because of a full buffer.
Note that using the driver at SER_BAUD_115200 will disable IRQs. It will be up
to the users to use the serial port, either by re-enabling IRQs themselves,
or by directly poll-reading the ACIA DATA register without the help of ser_get().
The driver defaults to slot 2. Call <tt/ser_apple2_slot()/ prior to
<tt/ser_open()/ in order to select a different slot. <tt/ser_apple2_slot()/
succeeds for all Apple&nbsp;II slots, but <tt/ser_open()/ fails with
@@ -569,6 +621,28 @@ program. See the discussion of the <tt/.CONDES/ feature in the <url
url="ca65.html" name="assembler manual">.
<sect1>ProDOS date/time manipulation<p>
<descrip>
The readdir and stat function return ProDOS timestamps in their file
creation/modification time attributes. You can convert them to more portable
time representations using either:
<tag/struct tm/
<tt/struct tm* __fastcall__ gmtime_dt (const struct datetime* dt);/
Converts a <tt/struct datetime/ into a <tt/struct tm/. Returns NULL in case
of error and sets errno.
<tag/time_t/
<tt/time_t __fastcall__ mktime_dt (const struct datetime* dt);/
Parses a <tt/struct datetime/ and returns a UNIX timestamp. Returns 0 on error and
sets errno.
</descrip>
<sect1>DIO<p>
<descrip>
@@ -630,6 +704,16 @@ url="ca65.html" name="assembler manual">.
that can be used to set these variables. It is included in
<tt/apple2.h/.
The global variable <tt/_datetime/ allows the file creation date/time
to be set before a call to <tt/fopen()/
or <tt/open()/ that creates the file. It is defined in <tt/apple2.h/:
<tscreen>
<verb>
extern struct datetime _datetime;
</verb>
</tscreen>
<tag>Example</tag>
A text file cannot be created with just the

View File

@@ -63,7 +63,7 @@ Special locations:
</descrip><p>
While running <tt/main()/ the Language Card bank 2 is enabled for read access.
However while running module constructors/destructors the Language Card is disabled.
However while running module constructors the Language Card is disabled.
Enabling the Language Card allows to use it as additional memory for cc65
generated code. However code is never automatically placed there. Rather code
@@ -88,7 +88,7 @@ several useful settings:
exit then a plain vanilla ProDOS 8 doesn't make use of the Language Card bank
2 at all.
<tag>LC address: &dollar;D000, LC size: &dollar;3000</tag>
<tag>LC address: &dollar;D000, LC size: &dollar;2FFC</tag>
For plain vanilla DOS 3.3 which doesn't make use of the Language Card at all.
</descrip><p>
@@ -290,9 +290,9 @@ the memory from &dollar;800 to &dollar;1FFF can be added to the heap by calling
ProDOS 8 requires for every open file a page-aligned 1 KB I/O buffer. By default
these buffers are allocated by the cc65 runtime system on the heap using
<tt/posix_memalign()/. While this is generally the best solution it means quite
some overhead for (especially rather small) cc65 programs which do open files
but don't make use of the heap otherwise.
<url url="funcref.html#posix_memalign" name="posix_memalign()">. While this is
generally the best solution it means quite some overhead for (especially rather
small) cc65 programs which do open files but don't make use of the heap otherwise.
The apple2enh package comes with the alternative ProDOS 8 I/O buffer allocation
module <tt/apple2enh-iobuf-0800.o/ which uses the memory between &dollar;800 and
@@ -322,15 +322,21 @@ Programs containing enhanced&nbsp;Apple&nbsp;//e specific code may use the
<sect1>Enhanced&nbsp;Apple&nbsp;//e specific functions<p>
The functions listed below are special for the enhanced&nbsp;Apple&nbsp;//e. See
the <url url="funcref.html" name="function reference"> for declaration and
The functions and variables listed below are special for the Apple&nbsp;&rsqb;&lsqb;.
See the <url url="funcref.html" name="function reference"> for declaration and
usage.
<itemize>
<item>_auxtype
<item>_dos_type
<item>_filetype
<item>_datetime
<item>beep
<item>dir_entry_count
<item>get_tv
<item>get_ostype
<item>gmtime_dt
<item>mktime_dt
<item>rebootafterexit
<item>ser_apple2_slot
<item>tgi_apple2_mix
@@ -339,6 +345,20 @@ usage.
</itemize>
<sect1>Apple IIgs specific functions in accelerator.h<p>
In addition to those, the <tt/accelerator.h/ header file contains three functions
to help determine whether the program is running on a IIgs, and change the IIgs
CPU speed. See the <url url="funcref.html" name="function reference"> for declaration and
usage.
<itemize>
<item>detect_iigs
<item>get_iigs_speed
<item>set_iigs_speed
</itemize>
<sect1>Hardware access<p>
There's currently no support for direct hardware access. This does not mean
@@ -435,10 +455,15 @@ The names in the parentheses denote the symbols to be used for static linking of
(RTS/CTS) and does interrupt driven receives. Speeds faster than 9600 baud
aren't reachable because the ROM and ProDOS IRQ handlers are too slow.
Software flow control (XON/XOFF) is not supported.
Note that because of the peculiarities of the 6551 chip transmits are not
interrupt driven, and the transceiver blocks if the receiver asserts
flow control because of a full buffer.
Note that using the driver at SER_BAUD_115200 will disable IRQs. It will be up
to the users to use the serial port, either by re-enabling IRQs themselves,
or by directly poll-reading the ACIA DATA register without the help of ser_get().
The driver defaults to slot 2. Call <tt/ser_apple2_slot()/ prior to
<tt/ser_open()/ in order to select a different slot. <tt/ser_apple2_slot()/
succeeds for all Apple&nbsp;II slots, but <tt/ser_open()/ fails with
@@ -575,6 +600,28 @@ program. See the discussion of the <tt/.CONDES/ feature in the <url
url="ca65.html" name="assembler manual">.
<sect1>ProDOS date/time manipulation<p>
<descrip>
The readdir and stat function return ProDOS timestamps in their file
creation/modification time attributes. You can convert them to more portable
time representations using either:
<tag/struct tm/
<tt/struct tm* __fastcall__ gmtime_dt (const struct datetime* dt);/
Converts a <tt/struct datetime/ into a <tt/struct tm/. Returns -1 in case
of error and sets errno, 0 on success.
<tag/time_t/
<tt/time_t __fastcall__ mktime_dt (const struct datetime* dt);/
Parses a <tt/struct datetime/ and returns a UNIX timestamp. Returns 0 on error and
sets errno.
</descrip>
<sect1>DIO<p>
<descrip>
@@ -619,7 +666,7 @@ url="ca65.html" name="assembler manual">.
auxiliary type. Therefore, some additional mechanism for specifying
the file types is needed.
<tag>Specifying the File Type and Auxiliary Type</tag>
<tag>Specifying the File Type, Auxiliary Type and creation date</tag>
There are two global variables provided that allow the file type
and auxiliary type to be specified before a call to <tt/fopen()/
@@ -636,6 +683,16 @@ url="ca65.html" name="assembler manual">.
that can be used to set these variables. It is included in
<tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
The global variable <tt/_datetime/ allows the file creation date/time
to be set before a call to <tt/fopen()/
or <tt/open()/ that creates the file. It is defined in <tt/apple2.h/:
<tscreen>
<verb>
extern struct datetime _datetime;
</verb>
</tscreen>
<tag>Example</tag>
A text file cannot be created with just the

View File

@@ -412,8 +412,9 @@ Please mind that ANTIC has memory alignment requirements for "player
missile graphics"-data, font data, display lists and screen memory. Creation
of a special linker configuration with appropriate aligned segments and
switching to that segment in the c-code is usually necessary. A more memory
hungry solution consists in using the "<tt/posix_memalign()/" function in
conjunction with copying your data to the allocated memory.
hungry solution consists in using the <url url="funcref.html#posix_memalign"
name="posix_memalign()"> function in conjunction with copying your data to the
allocated memory.
<sect1>Character mapping<p>
@@ -1120,7 +1121,7 @@ If BSS and/or the stack shouldn't stay at the end of the program,
some parts of the cc65 runtime lib need to be replaced/modified.
common/_heap.s defines the location of the heap and atari/crt0.s
defines the location of the stack by initializing sp.
defines the location of the stack by initializing c_sp.
<sect1>Upgrading from an older cc65 version<p>

View File

@@ -1,15 +1,15 @@
<!doctype linuxdoc system>
<article>
<title>Oric Atmos-specific information for cc65
<title>Tangerine Oric Atmos-specific information for cc65
<author>
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">,<newline>
<url url="mailto:polluks@sdf.org" name="Stefan A. Haubenthal">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<abstract>
An overview over the Atmos runtime system as it is implemented for the cc65 C
compiler.
An overview over the Oric Atmos runtime system as it is implemented for the cc65
C compiler. This target is not Oric-1 compatible.
</abstract>
<!-- Table of contents -->

File diff suppressed because it is too large Load Diff

View File

@@ -131,7 +131,7 @@ All other parameters will be pushed to the C-stack from left to right.
The rightmost parameter will have the lowest address on the stack,
and multi-byte parameters will have their least significant byte at the lower address.
The <tt/sp/ pseudo-register is a zeropage pointer to the base of the C-stack.
The <tt/c_sp/ pseudo-register is a zeropage pointer to the base of the C-stack.
If the function is variadic, the <tt/Y/ register will contain the number of
bytes pushed to the stack for this function.
@@ -153,10 +153,10 @@ void cdecl foo(unsigned bar, unsigned char baz);
; Example code for accessing bar. The variable is in A/X after this code snippet:
;
ldy #2 ; Offset of high byte of bar
lda (sp),y ; High byte now in A
lda (c_sp),y ; High byte now in A
tax ; High byte now in X
dey ; Offset of low byte of bar
lda (sp),y ; Low byte now in A
lda (c_sp),y ; Low byte now in A
</verb></tscreen>
<sect1>Epilogue, after the function call<p>
@@ -175,12 +175,12 @@ used if the return type is 32-bit.
If the function has a void return type, the compiler will not depend on the result
of <tt>A/X/sreg</tt>, so these may be clobbered by the function.
The C-stack pointer <tt/sp/ must be restored by the function to its value before the
The C-stack pointer <tt/c_sp/ must be restored by the function to its value before the
function call prologue. It may pop all of its parameters from the C-stack
(e.g. using the <tt/runtime/ function <tt/popa/),
or it could adjust <tt/sp/ directly.
or it could adjust <tt/c_sp/ directly.
If the function is variadic, the <tt/Y/ register contains the number of bytes
pushed to the stack on entry, which may be added to <tt/sp/ to restore its
pushed to the stack on entry, which may be added to <tt/c_sp/ to restore its
original state.
The internal pseudo-register <tt/regbank/ must not be changed by the function.

View File

@@ -61,8 +61,10 @@ Short options:
-Os Inline some standard functions
-T Include source as comment
-V Print the compiler version number
-W warning[,...] Suppress warnings
-W [-+]warning[,...] Control warnings ('-' disables, '+' enables)
-d Debug mode
-dM Output all user macros (needs -E)
-dP Output all predefined macros (needs -E)
-g Add debug info to object file
-h Help (this text)
-j Default characters are signed
@@ -84,8 +86,9 @@ Long options:
--create-full-dep name Create a full make dependency file
--data-name seg Set the name of the DATA segment
--debug Debug mode
--debug-tables name Write symbol table debug info to a file
--debug-info Add debug info to object file
--debug-opt name Configure optimizations with a file
--debug-opt name Debug optimization steps
--debug-opt-output Debug output of each optimization step
--dep-target target Use this dependency target
--disable-opt name Disable an optimization step
@@ -198,6 +201,28 @@ Here is a description of all the command line options:
Enables debug mode, for debugging the behavior of cc65.
<label id="option-dM">
<tag><tt>-dM</tt></tag>
When used with -E, will output <tt>#define</tt> directives for all the user
macros defined during execution of the preprocessor. This does not include
macros defined by the compiler.
Note: Can be combined with <tt/<ref id="option-dP" name="-dP">/ by using
<tt/-dMP/.
<label id="option-dP">
<tag><tt>-dP</tt></tag>
When used with -E, will output <tt>#define</tt> directives for all the macros
defined by the compiler itself. This does not include any user defined macros.
Note: Can be combined with <tt/<ref id="option-dM" name="-dM">/ by using
<tt/-dMP/.
<tag><tt>--debug-tables name</tt></tag>
Writes symbol table information to a file, which includes details on structs, unions
@@ -585,27 +610,42 @@ Here is a description of all the command line options:
<itemize>
<item>none
<item>agat (a russian apple2 like computer)
<item>apple2
<item>apple2enh
<item>atari
<item>atari2600
<item>atari5200
<item>atari7800
<item>atarixl
<item>atmos
<item>bbc
<item>c16 (works also for the c116 with memory up to 32K)
<item>c64
<item>c65
<item>c128
<item>cbm510 (CBM-II series with 40 column video)
<item>cbm610 (all CBM-II II computers with 80 column video)
<item>creativision
<item>cx16
<item>gamate
<item>geos-apple
<item>geos-cbm
<item>geos (alias for geos-cbm)
<item>kim1
<item>lunix
<item>lynx
<item>mega65
<item>nes
<item>osic1p
<item>pce (PC engine)
<item>pet (all CBM PET systems except the 2001)
<item>plus4
<item>p6502
<item>sim6502
<item>sim65c02
<item>supervision
<item>sym1
<item>telestrat
<item>vic20
</itemize>
@@ -823,6 +863,11 @@ and the one defined by the ISO standard:
as it sounds, since the 6502 has so few registers that it isn't
possible to keep values in registers anyway.
<p>
<item> In <tt/cc65/ mode, <tt/main()/ cannot be called recursively. If this
is necessary, the program must be compiled in <tt/c89/ or <tt/c99/ mode
using the <tt><ref id="option--standard" name="--standard"></tt>
command line option.
<p>
</itemize>
There may be some more minor differences I'm currently not aware of. The
@@ -1047,6 +1092,16 @@ This cc65 version has some extensions to the ISO C standard.
unsigned char foo = 0b101; // sets it to 5
</verb></tscreen>
<item> The character escape '\e', a GCC C extension, is accepted.
In ASCII this is the escape character 0x1B, which may be
remapped in other character sets via a #pragma charmap.
It can be disabled with the <tt><ref id="option--standard"
name="--standard"></tt> option.
<tscreen><verb>
unsigned char foo = '\e'; // sets it to 0x1B or equivalent
</verb></tscreen>
</itemize>
<p>
@@ -1138,6 +1193,134 @@ The compiler defines several macros at startup:
<item><tt/__CC65_STD_CC65__/
</itemize>
<label id="macro-CPU">
<tag><tt>__CPU__</tt></tag>
This macro contains a bitset that allows to check if a specific instruction
set is supported. For example, the 65C02 CPU supports all instructions of the
65SC02. So testing for the instruction set of the 65SC02 using the following
check will succeed for both CPUs (and also for the 65816 and HUC6280).
<tscreen><verb>
#if (__CPU__ & __CPU_ISET_65SC02__)
</verb></tscreen>
This is much simpler and more future proof than checking for specific CPUs.
The compiler defines a set of constants named <tt/__CPU_ISET_xxx/ to do the
checks. The <tt/__CPU__/ variable is usually derived from the target system
given, but can be changed using the <tt/<ref id="option--cpu" name="--cpu">/
command line option.
<tag><tt>__CPU_4510__</tt></tag>
This macro is defined if the code is compiled for a 4510 CPU.
<tag><tt>__CPU_45GS02__</tt></tag>
This macro is defined if the code is compiled for a 45GS02 CPU.
<tag><tt>__CPU_6502__</tt></tag>
This macro is defined if the code is compiled for a 6502 CPU.
<tag><tt>__CPU_6502X__</tt></tag>
This macro is defined if the code is compiled for a 6502 CPU with invalid
opcodes.
<tag><tt>__CPU_6502DTV__</tt></tag>
This macro is defined if the code is compiled for a DTV CPU.
<tag><tt>__CPU_65SC02__</tt></tag>
This macro is defined if the code is compiled for a 65SC02 CPU.
<tag><tt>__CPU_65C02__</tt></tag>
This macro is defined if the code is compiled for a 65C02 CPU.
<tag><tt>__CPU_65CE02__</tt></tag>
This macro is defined if the code is compiled for a 65CE02 CPU.
<tag><tt>__CPU_65816__</tt></tag>
This macro is defined if the code is compiled for a 65816 CPU.
<tag><tt>__CPU_HUC6280__</tt></tag>
This macro is defined if the code is compiled for a HUC6280 CPU.
<tag><tt>__CPU_M740__</tt></tag>
This macro is defined if the code is compiled for a M740 CPU.
<tag><tt>__CPU_W65C02__</tt></tag>
This macro is defined if the code is compiled for a W65C02 CPU.
<tag><tt>__CPU_ISET_6502__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 6502 CPU.
<tag><tt>__CPU_ISET_6502X__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 6502X CPU.
<tag><tt>__CPU_ISET_6502DTV__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 6502DTV CPU.
<tag><tt>__CPU_ISET_65SC02__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 65SC02 CPU.
<tag><tt>__CPU_ISET_65C02__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 65C02 CPU.
<tag><tt>__CPU_ISET_65CE02__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 65CE02 CPU.
<tag><tt>__CPU_ISET_65816__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the 65816 CPU.
<tag><tt>__CPU_ISET_HUC6280__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the HUC6280 CPU.
<tag><tt>__CPU_ISET_M740__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the M740 CPU.
<tag><tt>__CPU_ISET_W65C02__</tt></tag>
This macro expands to a numeric constant that can be used to check the
<tt/<ref id="macro-CPU" name="__CPU__">/ macro for the instruction set
of the W65C02 CPU.
<tag><tt>__CX16__</tt></tag>
This macro is defined if the target is the Commander X16 (-t cx16).
@@ -1273,6 +1456,12 @@ If the first parameter is <tt/push/, the old value is saved onto a stack
before changing it. The value may later be restored by using the <tt/pop/
parameter with the <tt/#pragma/.
For all pragma names that contain hyphens, the same name using underlines
instead of the hyphens is available as an alternative. While the former
resembles the corresponding command line option and is more orthogonal, the
latter may be more compatible with external tools that rewrite the token
sequences of the input.
<sect1><tt>#pragma allow-eager-inline ([push,] on|off)</tt><label id="pragma-allow-eager-inline"><p>
@@ -1358,7 +1547,7 @@ parameter with the <tt/#pragma/.
Example:
<tscreen><verb>
/* Use a space wherever an 'a' occurs in ISO-8859-1 source */
#pragma charmap (0x61, 0x20);
#pragma charmap (0x61, 0x20)
</verb></tscreen>
@@ -1613,13 +1802,13 @@ parameter with the <tt/#pragma/.
This pragma sets a wrapper for functions, often used for trampolines.
The name is a function returning <tt/void/, and taking no parameters.
The <tt/name/ is a wrapper function returning <tt/void/, and taking no parameters.
It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any
<tt/__fastcall__/ functions that have parameters. It must preserve
the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../"
in their prototypes).
The identifier is an 8-bit number that's set into <tt/tmp4/. If the identifier
The <tt/identifier/ is an 8-bit number that's set into <tt/tmp4/. If the <tt/identifier/
is "bank", then ca65's <tt><url url="ca65.html#.BANK" name=".bank"></tt> function will be used
to determine the number from the bank attribute defined in the linker config,
see <url url="ld65.html#MEMORY" name="Other MEMORY area attributes">. Note that
@@ -1629,6 +1818,11 @@ parameter with the <tt/#pragma/.
The address of a wrapped function is passed in <tt/ptr4/. The wrapper can
call that function by using "<tt/jsr callptr4/".
All functions ever declared or defined when this pragma is in effect will be wrapped
when they are called explicitly by their names later in the same translation unit.
Invocation of these functions in any other ways, for example, that via a function
pointer or in inline assembly code, will not be wrapped.
This feature is useful, for example, with banked memory, to switch banks
automatically to where a wrapped function resides, and then to restore the
previous bank when it returns.

View File

@@ -19,7 +19,7 @@ the native format.
chrcvt65 is a vector font converter. It is able to convert a "BGI Stroked
Font" to a compact TGI native vector font. See the function <url
url="funcref.html#tgi_load_vectorfont" name="tgi_load_vectorfont"> for usage.
url="tgi.html#tgi_load_vectorfont" name="tgi_load_vectorfont"> for usage.

View File

@@ -261,6 +261,9 @@ different options for different files on the command line. As an example.
translates main.c with full optimization and module.c with less optimization
and debug info enabled.
Note that the target system (-t , --target) must be specified before any file
unless using the default target of c64
The type of an input file is derived from its extension:
<itemize>

1082
doc/cpus.sgml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -140,7 +140,7 @@ FEATURES {
SYMBOLS {
# Define the stack size for the application
__STACKSIZE__: value = $0200, weak = yes;
__STACKSIZE__: value = $0200, type = weak;
}
</code></tscreen>
@@ -193,9 +193,9 @@ _init: LDX #$FF ; Initialize stack pointer to $01FF
; Set cc65 argument stack pointer
LDA #&lt;(__RAM_START__ + __RAM_SIZE__)
STA sp
STA c_sp
LDA #&gt;(__RAM_START__ + __RAM_SIZE__)
STA sp+1
STA c_sp+1
; ---------------------------------------------------------------------------
; Initialize memory storage

View File

@@ -243,6 +243,12 @@ point to <tt/cx320p1.tgi (cx320p1_tgi)/.
a way that's compatible with some of the other color drivers).
</descrip><p>
<descrip>
<tag><tt/cx640p1.tgi (cx640p1_tgi)/</tag>
This driver features a resolution of 640 across and 480 down with 2 colors,
black and white.
</descrip><p>
<sect1>Extended memory drivers<p>

View File

@@ -46,14 +46,16 @@ The assembler accepts the following options:
---------------------------------------------------------------------------
Usage: da65 [options] [inputfile]
Short options:
-d Debug mode
-g Add debug info to object file
-h Help (this text)
-i name Specify an info file
-m Run multiple passes to resolve labels
-o name Name the output file
-v Increase verbosity
-F Add formfeeds to the output
-s Accept line markers in the info file
-S addr Set the start/load address
-s Accept line markers in the info file
-V Print the disassembler version
Long options:
@@ -61,6 +63,7 @@ Long options:
--comment-column n Specify comment start column
--comments n Set the comment level for the output
--cpu type Set cpu type
--debug Debug mode
--debug-info Add debug info to object file
--formfeeds Add formfeeds to the output
--help Help (this text)
@@ -68,6 +71,7 @@ Long options:
--info name Specify an info file
--label-break n Add newline if label exceeds length n
--mnemonic-column n Specify mnemonic start column
--multi-pass Run multiple passes to resolve labels
--pagelength n Set the page length for the listing
--start-addr addr Set the start/load address
--sync-lines Accept line markers in the info file
@@ -110,19 +114,23 @@ Here is a description of all the command line options:
Set the CPU type. The option takes a parameter, which may be one of
<itemize>
<item>6502
<item>6502x
<item>6502dtv
<item>65sc02
<item>65c02
<item>65816
<item>huc6280
<item>4510
<item>6502 - NMOS 6502 (all legal instructions)
<item>6502X - NMOS 6502 with all undocumented instructions
<item>6502DTV - the emulated CPU of the C64DTV device
<item>65SC02 - first CMOS instruction set (no bit manipulation, no wai/stp)
<item>65C02 - full CMOS instruction set (has bit manipulation and wai/stp)
<item>65816 - the CPU of the SNES, and the SCPU
<item>HuC6280 - the CPU of the PC engine
<item>4510 - the CPU of the Commodore C65
<item>45GS02 - the CPU of the Commodore MEGA65
<item>M740 - a Microcontroller by Mitsubishi
</itemize>
6502x is for the NMOS 6502 with unofficial opcodes. 6502dtv is for the
emulated CPU of the C64DTV device. huc6280 is the CPU of the PC engine.
4510 is the CPU of the Commodore C65. 65816 is the CPU of the SNES.
<tag><tt>-d, --debug</tt></tag>
Enables debug mode, something that should not be needed for mere
mortals:-)
<label id="option--formfeeds">
@@ -181,6 +189,15 @@ Here is a description of all the command line options:
<tt><ref id="LABELBREAK" name="LABELBREAK"></tt>.
<tag><tt>-m, --multi-pass</tt></tag>
This option causes the disassembler to run multiple passes over the input
binary to find and create all necessary labels. Without this option the
disassembler may detect the necessity for a label in the final pass, when
output was already partially generated. It will output numerical addresses
or program counter relative expressions in this case.
<label id="option--mnemonic-column">
<tag><tt>--mnemonic-column n</tt></tag>
@@ -246,23 +263,85 @@ Here is a description of all the command line options:
<sect1>Supported CPUs<p>
With the command line option <tt><ref id="option--cpu" name="--cpu"></tt>, the
disassembler may be told which CPU to support:
<itemize>
<item>6502 - NMOS 6502 (all legal instructions)
<item>6502X - NMOS 6502 with all undocumented instructions
<item>6502DTV - the emulated CPU of the C64DTV device
<item>65SC02 - first CMOS instruction set (no bit manipulation, no wai/stp)
<item>65C02 - CMOS with Rockwell extensions
<item>W65C02 - full CMOS instruction set (has bit manipulation and wai/stp)
<item>65CE02 - CMOS with CSG extensions
<item>4510 - the CPU of the Commodore C65
<item>45GS02 - the CPU of the Commodore MEGA65
<item>HuC6280 - the CPU of the PC engine
<item>M740 - a Microcontroller by Mitsubishi
<item>65816 - the CPU of the SNES, and the SCPU
</itemize>
for more details on the various CPUs, see <tt><htmlurl url="cpus.html" name="here"></tt>.
<sect2>6502 mode<label id="6502-mode"><p>
The default (no CPU given on the command line or in the <tt/GLOBAL/ section of
the info file) is the 6502 CPU. The disassembler knows all "official" opcodes
for this CPU. Invalid opcodes are translated into <tt/.byte/ commands.
With the command line option <tt><ref id="option--cpu" name="--cpu"></tt>, the
disassembler may be told to recognize either the 65SC02 or 65C02 CPUs. The
latter understands the same opcodes as the former, plus 16 additional bit
manipulation and bit test-and-branch commands. Using 6502x as CPU the illegal
opcodes of 6502 CPU are detected and displayed. 6502dtv setting recognizes the
emulated CPU instructons of the C64DTV device.
<sect2>6502X mode<label id="6502X-mode"><p>
Using 6502X as CPU the illegal opcodes of 6502 CPU are detected and displayed.
<sect2>DTV mode<label id="DTV-mode"><p>
6502DTV setting recognizes the emulated CPU instructions of the C64DTV device.
<sect2>65SC02 mode<label id="65SC02-mode"><p>
The first CMOS instruction set, without bit manipulation or wai/stp.
<sect2>65C02 mode<label id="65C02-mode"><p>
The 65C02 understands the same opcodes as the 65SC02, plus 16 additional bit
manipulation and bit test-and-branch commands.
<sect2>W65C02 mode<label id="W65C02-mode"><p>
This mode also supports wai/stp.
<sect2>65CE02 mode<label id="65CE02-mode"><p>
<sect2>4510 mode<label id="4510-mode"><p>
When disassembling 4510 code, due to handling of 16-bit wide branches, da65
can produce output that can not be re-assembled, when one or more of those
branches point outside of the disassembled memory. This can happen when text
or binary data is processed.
<sect2>45GS02 mode<label id="45GS02-mode"><p>
All compound instructions are supported.
<sect2>HUC6280 mode<label id="HUC6280-mode"><p>
All special opcodes are supported.
<sect2>M740 mode<label id="M740-mode"><p>
All special opcodes are supported.
<sect2>65816 mode<label id="65816-mode"><p><p>
The 65816 support requires annotating ranges with the M and X flag states.
This can be recorded with an emulator that supports Code and Data Logging,
for example. Disassemble one bank at a time.

View File

@@ -71,18 +71,21 @@ function.
<item><ref id="detect_c64dtv" name="detect_c64dtv">
<item><ref id="detect_c65" name="detect_c65">
<item><ref id="detect_chameleon" name="detect_chameleon">
<item><ref id="detect_iigs" name="detect_iigs">
<item><ref id="detect_scpu" name="detect_scpu">
<item><ref id="detect_turbomaster" name="detect_turbomaster">
<item><ref id="get_c128_speed" name="get_c128_speed">
<item><ref id="get_c64dtv_speed" name="get_c64dtv_speed">
<item><ref id="get_c65_speed" name="get_c65_speed">
<item><ref id="get_chameleon_speed" name="get_chameleon_speed">
<item><ref id="get_iigs_speed" name="get_iigs_speed">
<item><ref id="get_scpu_speed" name="get_scpu_speed">
<item><ref id="get_turbomaster_speed" name="get_turbomaster_speed">
<item><ref id="set_c128_speed" name="set_c128_speed">
<item><ref id="set_c64dtv_speed" name="set_c64dtv_speed">
<item><ref id="set_c65_speed" name="set_c65_speed">
<item><ref id="set_chameleon_speed" name="set_chameleon_speed">
<item><ref id="set_iigs_speed" name="set_iigs_speed">
<item><ref id="set_scpu_speed" name="set_scpu_speed">
<item><ref id="set_turbomaster_speed" name="set_turbomaster_speed">
</itemize>
@@ -92,8 +95,16 @@ function.
<itemize>
<item>_dos_type
<item>allow_lowercase
<item><ref id="beep" name="beep">
<item><ref id="dir_entry_count" name="dir_entry_count">
<item><ref id="get_tv" name="get_tv">
<item><ref id="get_ostype" name="get_ostype">
<item><ref id="gmtime_dt" name="gmtime_dt">
<item><ref id="mktime_dt" name="mktime_dt">
<item>rebootafterexit
<item><ref id="videomode" name="videomode">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -101,9 +112,15 @@ function.
<itemize>
<item>_dos_type
<item><ref id="beep" name="beep">
<item><ref id="dir_entry_count" name="dir_entry_count">
<item><ref id="get_tv" name="get_tv">
<item><ref id="get_ostype" name="get_ostype">
<item><ref id="gmtime_dt" name="gmtime_dt">
<item><ref id="mktime_dt" name="mktime_dt">
<item>rebootafterexit
<item><ref id="videomode" name="videomode">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -128,7 +145,7 @@ function.
<!-- <item><ref id="_setcolor_low" name="_setcolor_low"> -->
<item><ref id="_sound" name="_sound">
<item><ref id="get_ostype" name="get_ostype">
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
</itemize>
(incomplete)
@@ -145,6 +162,7 @@ function.
<item><ref id="atmos_tick" name="atmos_tick">
<item><ref id="atmos_tock" name="atmos_tock">
<item><ref id="atmos_zap" name="atmos_zap">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -214,7 +232,7 @@ function.
<!-- <item><ref id="cbm_readdir" name="cbm_readdir"> -->
<!-- <item><ref id="cbm_save" name="cbm_save"> -->
<!-- <item><ref id="cbm_write" name="cbm_write"> -->
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
<item><ref id="kbrepeat" name="kbrepeat">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -271,6 +289,7 @@ function.
<item><ref id="cclear" name="cclear">
<item><ref id="cclearxy" name="cclearxy">
<item><ref id="cgetc" name="cgetc">
<item><ref id="cgets" name="cgets">
<item><ref id="chline" name="chline">
<item><ref id="chlinexy" name="chlinexy">
<item><ref id="clrscr" name="clrscr">
@@ -283,6 +302,7 @@ function.
<item><ref id="cputcxy" name="cputcxy">
<item><ref id="cputs" name="cputs">
<item><ref id="cputsxy" name="cputsxy">
<item><ref id="cscanf" name="cscanf">
<item><ref id="cursor" name="cursor">
<item><ref id="cvline" name="cvline">
<item><ref id="cvlinexy" name="cvlinexy">
@@ -335,7 +355,7 @@ function.
<itemize>
<!-- <item><ref id="get_numbanks" name="get_numbanks"> -->
<item><ref id="get_ostype" name="get_ostype">
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
<!-- <item><ref id="set_tv" name="set_tv"> -->
<!-- <item><ref id="vera_layer_enable" name="vera_layer_enable"> -->
<!-- <item><ref id="vera_sprites_enable" name="vera_sprites_enable"> -->
@@ -430,7 +450,7 @@ see also <tt>testcode/lib/em-test.c</tt> and <tt>samples/multidemo.c</tt>.
<sect1><tt/gamate.h/<label id="gamate.h"><p>
<itemize>
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -506,6 +526,14 @@ see also <tt>testcode/lib/em-test.c</tt> and <tt>samples/multidemo.c</tt>.
</itemize>
<sect1><tt/lzsa.h/<label id="lzsa.h"><p>
<itemize>
<item><ref id="decompress_lzsa1" name="decompress_lzsa1">
<item><ref id="decompress_lzsa2" name="decompress_lzsa2">
</itemize>
<sect1><tt/modload.h/<label id="modload.h"><p>
<itemize>
@@ -537,7 +565,7 @@ see also <tt>testcode/lib/em-test.c</tt> and <tt>samples/multidemo.c</tt>.
<sect1><tt/nes.h/<label id="nes.h"><p>
<itemize>
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -555,7 +583,7 @@ It does not declare any functions.
<sect1><tt/pce.h/<label id="pce.h"><p>
<itemize>
<!-- <item><ref id="get_tv" name="get_tv"> -->
<item><ref id="get_tv" name="get_tv">
<item><ref id="waitvsync" name="waitvsync">
</itemize>
@@ -725,7 +753,7 @@ communication, see also <tt>testcode/lib/ser-test.c</tt>.
<item><ref id="ltoa" name="ltoa">
<item><ref id="malloc" name="malloc">
<item><ref id="perror" name="perror">
<!-- <item><ref id="posix_memalign" name="posix_memalign"> -->
<item><ref id="posix_memalign" name="posix_memalign">
<!-- <item><ref id="putenv" name="putenv"> -->
<item><ref id="qsort" name="qsort">
<item><ref id="rand" name="rand">
@@ -771,6 +799,7 @@ communication, see also <tt>testcode/lib/ser-test.c</tt>.
<item><ref id="strqtok" name="strqtok">
<item><ref id="strrchr" name="strrchr">
<item><ref id="strspn" name="strspn">
<item><ref id="strcasestr" name="strcasestr">
<item><ref id="strstr" name="strstr">
<item><ref id="strtok" name="strtok">
<item><ref id="strxfrm" name="strxfrm">
@@ -846,6 +875,20 @@ communication, see also <tt>testcode/lib/ser-test.c</tt>.
(incomplete)
<sect1><tt/stat.h/<label id="sys/stat.h"><p>
<itemize>
<item><ref id="stat" name="stat">
</itemize>
<sect1><tt/statvfs.h/<label id="sys/statvfs.h"><p>
<itemize>
<item><ref id="statvfs" name="statvfs">
</itemize>
<sect1><tt/vic20.h/<label id="vic20.h"><p>
(incomplete)
@@ -863,6 +906,13 @@ communication, see also <tt>testcode/lib/ser-test.c</tt>.
(incomplete)
<sect1><tt/zx02.h/<label id="zx02.h"><p>
<itemize>
<item><ref id="decompress_zx02" name="decompress_zx02">
</itemize>
<sect>Alphabetical function reference<p>
<sect1>_DE_ISDIR<label id="_DE_ISDIR"><p>
@@ -1750,10 +1800,11 @@ used in presence of a prototype.
<descrip>
<tag/Function/Beep sound.
<tag/Header/<tt/<ref id="sym1.h" name="sym1.h">/
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">/
<tag/Declaration/<tt/void beep(void);/
<tag/Description/<tt/beep/ makes a brief tone.
<tag/Notes/<itemize>
<item>The function is specific to the Sym-1.
<item>The function is specific to the Sym-1 and Apple2 platforms.
</itemize>
<tag/Availability/cc65
<tag/See also/
@@ -2407,7 +2458,7 @@ the address must first be ORed with $60.
<tag/Availability/cc65
<tag/See also/
<ref id="cbm_k_listen" name="cbm_k_listen">
<tag/Exampe/None.
<tag/Example/None.
</descrip>
</quote>
@@ -2666,6 +2717,45 @@ see anything that you type. (See the description of <tt/cbm_k_scnkey()/.)
</quote>
<sect1>cgets<label id="cgets"><p>
<quote>
<descrip>
<tag/Function/Input a string directly from the console.
<tag/Header/<tt/<ref id="conio.h" name="conio.h">/
<tag/Declaration/<tt/char* __fastcall__ cgets (const char* buffer, int size);/
<tag/Description/The function inputs a string of at most <tt/size - 1/
characters from the console into <tt/buffer/. It returns when <tt/size - 1/
characters or either <tt/CR/ or <tt/LF/ are entered. It also handles both
multi-line input and backspacing.
<tag/Notes/<itemize>
<item>The function echoes <tt/CRLF/ when either <tt/CR/ or <tt/LF/ are read
but does NOT append either in <tt/buffer/.
<item>The function is only available as fastcall function, so it may only
be used in the presence of a prototype.
</itemize>
<tag/Availability/cc65
<tag/See also/
<ref id="cgetc" name="cgetc">,
<ref id="cscanf" name="cscanf">
<tag/Example/<verb>
#include &lt;conio.h&gt;
int main (void)
{
char buffer[200], *p;
cputs ("Type a lot and backspace a lot: ");
if (p = cgets (buffer, sizeof(buffer)))
cputs (p);
return 0;
}
</verb>
</descrip>
</quote>
<sect1>chline<label id="chline"><p>
<quote>
@@ -2851,6 +2941,79 @@ setting the time may not work. See also the platform-specific information.
</quote>
<sect1>gmtime_dt<label id="gmtime_dt"><p>
<quote>
<descrip>
<tag/Function/Converts a ProDOS date to a struct tm.
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">/
<tag/Declaration/<tt/struct tm* __fastcall__ gmtime_dt (const struct datetime* dt);/
<tag/Description/The <tt/gmtime_dt/ function converts the given
proDOS date/time to a struct tm. On error, NULL is returned and <tt/errno/ is set
to an error code describing the reason for the failure.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<item>This function is only available on Apple II.
<item>On Apple II, you can't stat() an opened file. stat() before opening.
</itemize>
<tag/Availability/cc65
<tag/Example/
<verb>
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
int main(void)
{
struct stat st;
struct tm* tm;
if (stat ("/disk/file", &amp;st) == 0) {
tm = gmtime_dt (&amp;st.st_ctime);
if (tm)
printf ("File created on %s\n", asctime(tm));
}
}
</verb>
</descrip>
</quote>
<sect1>mktime_dt<label id="mktime_dt"><p>
<quote>
<descrip>
<tag/Function/Converts a ProDOS date to a time_t.
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">/
<tag/Declaration/<tt/time_t __fastcall__ mktime_dt (const struct datetime* dt);/
<tag/Description/The <tt/mktime_dt/ function parses the given
proDOS date/time and returns a time_t timestamp. On error, 0 is returned,
and errno is set.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<item>This function is only available on Apple II.
</itemize>
<tag/Availability/cc65
<tag/Example/
<verb>
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
int main(void)
{
struct stat st;
if (stat ("/disk/file", &amp;st) == 0) {
printf ("File created on %s\n",
localtime (mktime_dt (&amp;st.st_ctime)));
}
}
</verb>
</descrip>
</quote>
<sect1>clrscr<label id="clrscr"><p>
<quote>
@@ -3192,6 +3355,47 @@ be used in presence of a prototype.
</quote>
<sect1>cscanf<label id="cscanf"><p>
<quote>
<descrip>
<tag/Function/Read formatted input from the console
<tag/Header/<tt/<ref id="conio.h" name="conio.h">/
<tag/Declaration/<tt/int cscanf (const char* format, ...);/
<tag/Description/The <tt/cscanf()/ function scans input from the console under
control of the argument <tt/format/. Following the format string is a list of
addresses to receive values. The format string is identical to that of the
<tt/scanf()/ function.
<tag/Notes/<itemize>
<item>A direct call to <tt/cursor()/ may be required to show the cursor.
<item>Some control characters like backspaces are not recognized.
<item>A better user experience can sometimes be provided by using <tt/cgets()/
to retrieve the input, and then using <tt/sscanf()/ to parse it.
</itemize>
<tag/Availability/cc65
<tag/See also/
<ref id="cgets" name="cgets">,
<ref id="cursor" name="cursor">
<tag/Example/<verb>
#include &lt;conio.h&gt;
int main (void)
{
int a, b, c;
cputs ("Type three integers that add to 100: ");
if (cscanf ("%d %d %d", &amp;a, &amp;b, &amp;c) == 3 && a + b + c == 100)
cputs ("\r\nYou passed!\r\n");
else
cputs ("\r\nYou failed!\r\n");
return 0;
}
</verb>
</descrip>
</quote>
<sect1>cursor<label id="cursor"><p>
<quote>
@@ -3277,6 +3481,70 @@ used in presence of a prototype.
<tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer.
<tag/Notes/<itemize>
<item>Use LZ4_compress_HC with compression level 16 for best compression.
<item>Your program will need to know the uncompressed size of the buffer as
there is no end-of-stream marker.
<item>LZ4 is the biggest and second-slowest decompressor shipped in cc65 runtime.
It is also the least efficient compression algorithm.
</itemize>
<tag/Availability/cc65
<tag/Example/None.
</descrip>
</quote>
<sect1>decompress_lzsa1<label id="decompress_lzsa1"><p>
<quote>
<descrip>
<tag/Function/Uncompress a LZSA buffer with format 1.
<tag/Header/<tt/<ref id="lzsa.h" name="lzsa.h">/
<tag/Declaration/<tt/void decompress_lzsa1 (const unsigned char* src, unsigned char* const dst);/
<tag/Description/<tt/decompress_lz4/ uncompresses a LZSA buffer with format 1.
<tag/Notes/<itemize>
<item>Use <tt/lzsa -f 1 -r input.bin output.lzsa1/ to compress your input.
<item>The project and compressor can be found at <url url="https://github.com/emmanuel-marty/lzsa">
<item>LZSA1 is the fastest decompressor shipped in cc65 runtime, but data is less
compressed than with LZSA2 and ZX02.
</itemize>
<tag/Availability/cc65
<tag/Example/None.
</descrip>
</quote>
<sect1>decompress_lzsa2<label id="decompress_lzsa2"><p>
<quote>
<descrip>
<tag/Function/Uncompress a LZSA buffer with format 2.
<tag/Header/<tt/<ref id="lzsa.h" name="lzsa.h">/
<tag/Declaration/<tt/void decompress_lzsa2 (const unsigned char* src, unsigned char* const dst);/
<tag/Description/<tt/decompress_lz4/ uncompresses a LZSA buffer with format 2.
<tag/Notes/<itemize>
<item>Use <tt/lzsa -f 2 -r input.bin output.lzsa2/ to compress your input.
<item>The project and compressor can be found at <url url="https://github.com/emmanuel-marty/lzsa">
<item>LZSA2 is the second fastest decompressor shipped in cc65 runtime, but data is less
compressed than with ZX02.
</itemize>
<tag/Availability/cc65
<tag/Example/None.
</descrip>
</quote>
<sect1>decompress_zx02<label id="decompress_zx02"><p>
<quote>
<descrip>
<tag/Function/Uncompress a ZX02 buffer.
<tag/Header/<tt/<ref id="zx02.h" name="zx02.h">/
<tag/Declaration/<tt/void decompress_zx02 (const unsigned char* src, unsigned char* const dst);/
<tag/Description/<tt/decompress_zx02/ uncompresses a ZX02 buffer with format 2.
<tag/Notes/<itemize>
<item>Use <tt/zx02 input.bin output.zx02/ to compress your input.
<item>The project and compressor can be found at <url url="https://github.com/dmsc/zx02">
<item>ZX02 is the slowest decompressor shipped with cc65 runtime, but is also the
smallest and has the best compression ratio.
</itemize>
<tag/Availability/cc65
<tag/Example/None.
@@ -3364,6 +3632,26 @@ used in presence of a prototype.
</quote>
<sect1>detect_iigs<label id="detect_iigs"><p>
<quote>
<descrip>
<tag/Function/Check whether we are running on an Apple IIgs..
<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
<tag/Declaration/<tt/unsigned char detect_iigs (void);/
<tag/Description/The function returns a 1 if running on an Apple IIgs.
<tag/Notes/<itemize>
<item>The function is specific to the Apple2 and Apple2enh platforms.
</itemize>
<tag/Availability/cc65 (not all platforms)
<tag/See also/
<ref id="get_iigs_speed" name="get_iigs_speed">,
<ref id="set_iigs_speed" name="set_iigs_speed">,
<tag/Example/None.
</descrip>
</quote>
<sect1>detect_scpu<label id="detect_scpu"><p>
<quote>
@@ -3404,6 +3692,25 @@ used in presence of a prototype.
</quote>
<sect1>dir_entry_count<label id="dir_entry_count"><p>
<quote>
<descrip>
<tag/Function/Returns the number of entries in the directory.
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">/
<tag/Declaration/<tt/unsigned int __fastcall__ dir_entry_count(DIR *dir);/
<tag/Description/<tt/dir_entry_count/ is machine dependent and does not exist for
all supported targets. If it exists, it returns the number of active
(non-deleted) files and directories in the directory.
<tag/Notes/<itemize>
<item>The function does not exist on all platforms.
</itemize>
<tag/Availability/cc65 (not all platforms)
<tag/Example/None.
</descrip>
</quote>
<sect1>div<label id="div"><p>
<quote>
@@ -3967,6 +4274,31 @@ be used in presence of a prototype.
</quote>
<sect1>get_tv<label id="get_tv"><p>
<quote>
<descrip>
<tag/Function/The function returns the system's vertical blank frequency.
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
<ref id="atari.h" name="atari.h">, <ref id="cbm.h" name="cbm.h">,
<ref id="cx16.h" name="cx16.h">, <ref id="gamate.h" name="gamate.h">,
<ref id="nes.h" name="nes.h">, <ref id="pce.h" name="pce.h">/
<tag/Declaration/<tt/unsigned char get_tv (void);/
<tag/Description/<tt/get_tv/ is machine dependent and does not exist for
all supported targets. If it exists, it returns a number that identifies the
frequency at which the screen vertical blank happens (either 50 or 60Hz),
if possible.
<tag/Notes/<itemize>
<item>The function does not exist on all platforms.
<item>Return TV_NTSC for 60Hz systems, TV_PAL for 50Hz systems, or
TV_OTHER if the scan frequency can not be determined.
</itemize>
<tag/Availability/cc65 (not all platforms)
<tag/Example/None.
</descrip>
</quote>
<sect1>get_ostype<label id="get_ostype"><p>
<quote>
@@ -4078,6 +4410,27 @@ header files define constants that can be used to check the return code.
</quote>
<sect1>get_iigs_speed<label id="get_iigs_speed"><p>
<quote>
<descrip>
<tag/Function/Get the current speed of the Apple IIgs.
<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
<tag/Declaration/<tt/unsigned char get_iigs_speed (void);/
<tag/Description/The function returns the current speed of the Apple IIgs.
<tag/Notes/<itemize>
<item>The function is specific to the Apple2 and Apple2enh platforms.
<item>See the accelerator.h header for the speed definitions.
</itemize>
<tag/Availability/cc65 (not all platforms)
<tag/See also/
<ref id="detect_iigs" name="detect_iigs">,
<ref id="set_iigs_speed" name="set_iigs_speed">,
<tag/Example/None.
</descrip>
</quote>
<sect1>get_scpu_speed<label id="get_scpu_speed"><p>
<quote>
@@ -6061,6 +6414,32 @@ be used in presence of a prototype.
</quote>
<sect1>posix_memalign<label id="posix_memalign"><p>
<quote>
<descrip>
<tag/Function/Allocate aligned dynamic memory.
<tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
<tag/Declaration/<tt/int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size);/
<tag/Description/Allocate a block of memory with the given "size", which is aligned to a
memory address that is a multiple of "alignment". "alignment" <em/must not/ be
zero, and <em/must/ be a power of two; otherwise, this function will return
EINVAL. The function returns ENOMEM if not enough memory is available
to satisfy the request. "memptr" must point to a variable; that variable
will return the address of the allocated memory. Use free() to release that
allocated block.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
</itemize>
<tag/Availability/POSIX 1003.1
<tag/See also/
<ref id="free" name="free">
<tag/Example/None.
</descrip>
</quote>
<sect1>psg_delay<label id="psg_delay"><p>
<quote>
@@ -6229,6 +6608,9 @@ be used in presence of a prototype.
<item>The returned pointer may point to a statically allocated instance of
<tt/struct dirent/, so it may get overwritten by subsequent calls to
<tt/readdir/.
<item>On the Apple II platform, the d_ctime and d_mtime returned are in the
ProDOS format. You can convert them to more portable time representations using
the ProDOS datetime conversion functions.
<item>On several platforms, namely the CBMs and the Atari, the disk drives get
confused when opening/closing files between directory reads. So for example a
program that reads the list of files on a disk, and after each call to
@@ -6893,6 +7275,30 @@ clean-up when exiting the program.
</quote>
<sect1>set_iigs_speed<label id="set_iigs_speed"><p>
<quote>
<descrip>
<tag/Function/Set the current speed of the Apple IIgs.
<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
<tag/Declaration/<tt/unsigned char __fastcall__ set_iigs_speed (unsigned char speed);/
<tag/Description/The function sets the speed of the Apple IIgs CPU (and returns
the new speed).
<tag/Notes/<itemize>
<item>The function is specific to the Apple2 and Apple2enh platforms.
<item>See the accelerator.h header for the speed definitions.
<item>Accepted parameters are SPEED_SLOW and SPEED_FAST (all other values are
considered SPEED_FAST).
</itemize>
<tag/Availability/cc65 (not all platforms)
<tag/See also/
<ref id="detect_iigs" name="detect_iigs">,
<ref id="get_iigs_speed" name="get_iigs_speed">,
<tag/Example/None.
</descrip>
</quote>
<sect1>set_scpu_speed<label id="set_scpu_speed"><p>
<quote>
@@ -7075,6 +7481,85 @@ be used in presence of a prototype.
</quote>
<sect1>stat<label id="stat"><p>
<quote>
<descrip>
<tag/Function/Get file status.
<tag/Header/<tt/<ref id="sys/stat.h" name="sys/stat.h">/
<tag/Declaration/<tt/int __fastcall__ stat (const char* pathname, struct stat* statbuf);/
<tag/Description/<tt/stat/ gets information for the file with the given name. On success,
zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
code describing the reason for the failure.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<item>On the Apple II platform, the st_ctim, st_mtim and st_atim members are left
to zero, for size and performance reasons. The ProDOS creation and modification dates
are returned in the ProDOS format in st_ctime and st_mtime. The access date does
not exist. You can convert them to POSIX-style time representations using
the <url url="apple2.html#ss9.3" name="ProDOS datetime conversion functions">.
</itemize>
<tag/Availability/POSIX 1003.1
<tag/See also/
<ref id="statvfs" name="statvfs">
<tag/Example/
<verb>
#include &lt;sys/stat.h&gt;
#define FILENAME "helloworld"
struct stat stbuf;
if (stat (FILENAME, &amp;stbuf) == 0) {
printf ("%s size is %lu bytes (created on %s)\n", FILENAME, stbuf.st_size,
#ifndef __APPLE2__
localtime (&amp;stbuf.st_ctim.tv_sec)
#else
localtime (mktime_dt (&amp;stbuf.st_ctime))
#endif
);
} else {
printf ("There was a problem stat'ing %s: %d\n", FILENAME, errno);
}
</verb>
</descrip>
</quote>
<sect1>statvfs<label id="statvfs"><p>
<quote>
<descrip>
<tag/Function/Get filesystem statistics.
<tag/Header/<tt/<ref id="sys/statvfs.h" name="sys/statvfs.h">/
<tag/Declaration/<tt/int __fastcall__ statvfs (const char* pathname, struct statvfs* buf);/
<tag/Description/<tt/statvfs/ gets information for the filesystem on which the given file
resides. On success,
zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
code describing the reason for the failure.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<item>The function requires an absolute pathname.
</itemize>
<tag/Availability/POSIX 1003.1
<tag/See also/
<ref id="stat" name="stat">
<tag/Example/
<verb>
#include &lt;sys/statvfs.h&gt;
#define FILENAME "/disk/helloworld"
struct statvfs stvbuf;
if (statvfs (FILENAME, &amp;stvbuf) == 0) {
printf ("%s filesystem has %u blocks of %u size, %u of them free.\n", FILENAME, stvbuf.f_blocks, stvbuf.f_bsize, stvbuf.f_bfree);
} else {
printf ("There was a problem statvfs'ing %s: %d\n", FILENAME, errno);
}
</verb>
</descrip>
</quote>
<sect1>strcasecmp<label id="strcasecmp"><p>
<quote>
@@ -7655,22 +8140,47 @@ be used in presence of a prototype.
</quote>
<sect1>strstr<label id="strstr"><p>
<sect1>strcasestr<label id="strcasestr"><p>
<quote>
<descrip>
<tag/Function/Find a substring.
<tag/Function/Find a substring, case-insensitive.
<tag/Header/<tt/<ref id="string.h" name="string.h">/
<tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
<tag/Description/<tt/strstr/ searches for the first occurrence of the string
<tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
otherwise it returns <tt/NULL/.
<tag/Declaration/<tt/char* __fastcall__ strcasestr (const char* str, const char* substr);/
<tag/Description/<tt/strcasestr/ searches for the first occurrence of the string
<tt/substr/ within <tt/str/. If found, it returns a pointer to the start of the
match in <tt/str/, otherwise it returns <tt/NULL/.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
</itemize>
<tag/Availability/ISO 9899
<tag/See also/
<ref id="strstr" name="strstr">,
<ref id="strcspn" name="strcspn">,
<ref id="strspn" name="strspn">
<tag/Example/None.
</descrip>
</quote>
<sect1>strstr<label id="strstr"><p>
<quote>
<descrip>
<tag/Function/Find a substring, case-sensitive.
<tag/Header/<tt/<ref id="string.h" name="string.h">/
<tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
<tag/Description/<tt/strstr/ searches for the first occurrence of the string
<tt/substr/ within <tt/str/. If found, it returns a pointer to the start of the
match in <tt/str/, otherwise it returns <tt/NULL/.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
</itemize>
<tag/Availability/ISO 9899
<tag/See also/
<ref id="strcasestr" name="strcasestr">,
<ref id="strcspn" name="strcspn">,
<ref id="strspn" name="strspn">
<tag/Example/None.
@@ -8052,24 +8562,27 @@ used in presence of a prototype.
<tag/Function/Switch to either 40- or 80-column text mode, or a standard
graphics mode.
<tag/Header/<tt/
<ref id="apple2.h" name="apple2.h">,
<ref id="apple2enh.h" name="apple2enh.h">,
<ref id="c128.h" name="c128.h">,
<ref id="cx16.h" name="cx16.h">/
<tag/Declaration/
<tt>unsigned __fastcall__ videomode (unsigned Mode); /* for apple2enh and c128 */</tt><newline>
<tt>signed char __fastcall__ videomode (signed char Mode); /* for cx16 */</tt>
<tt>unsigned __fastcall__ videomode (unsigned Mode); /* for c128 */</tt><newline>
<tt>signed char __fastcall__ videomode (signed char Mode); /* for apple2 and cx16 */</tt>
<tag/Description/Switch to a 40- or 80-column text or graphics mode, depending
on the argument. If the requested mode is already active, nothing happens. The
old mode is returned from the call.
<tag/Notes/<itemize>
<item>The function is specific to the Commodore 128, the enhanced Apple //e,
<item>The function is specific to the Commodore 128, the Apple II,
and the Commander X16.
<item>This function replaces <ref id="toggle_videomode"
name="toggle_videomode">.
<item>The function is available as only a fastcall function, so it may be used
only in the presence of a prototype.
<item>On Apple II, this functions returns the previously active video mode, or -1
if the mode is not supported due to lack of hardware.
</itemize>
<tag/Availability/C128, enhanced Apple //e, and CX16
<tag/Availability/C128, Apple II, and CX16
<tag/See also/
<ref id="fast" name="fast">,
<ref id="isfast" name="isfast">,
@@ -8087,13 +8600,21 @@ only in the presence of a prototype.
<descrip>
<tag/Function/Wait until the start of the next video frame.
<tag/Header/<tt/
<ref id="apple2.h" name="apple2.h">,
<ref id="atmos.h" name="atmos.h">,
<ref id="cbm.h" name="cbm.h">,
<ref id="gamate.h" name="gamate.h">,
<ref id="nes.h" name="nes.h">,
<ref id="pce.h" name="pce.h">/
<tag/Declaration/<tt/void waitvsync (void);/
<tag/Declaration/
<tt>void waitvsync (void);</tt><newline>
<tag/Description/Wait for vertical sync, to reduce flickering.
<tag/Notes/<itemize>
<item>The function will silently fail when the feature is not
supported, like on the Apple&nbsp;&rsqb;&lsqb;+.
</itemize>
<tag/Availability/Platforms served by the headers above
(Atmos requires the VSync hack)
<tag/Example/None.
</descrip>
</quote>

View File

@@ -109,6 +109,9 @@
<descrip>
<tag><htmlurl url="agat.html" name="agat.html"></tag>
Topics specific to the Agat machines.
<tag><htmlurl url="apple2.html" name="apple2.html"></tag>
Topics specific to the Apple&nbsp;&rsqb;&lsqb;.

View File

@@ -1180,6 +1180,202 @@ The ZPSAVE segment contains the original values of the zeropage locations used
by the ZEROPAGE segment. It is placed in its own segment because it must not be
initialized.
<sect>Debug Info<p>
The debug info and the API mirrors closely the items available in the sources
used to build an executable. To use the API efficiently, it is necessary to
understand from which blocks the information is built.
<itemize>
<item> Libraries
<item> Lines
<item> Modules
<item> Scopes
<item> Segments
<item> Source files
<item> Spans
<item> Symbols
<item> Types
</itemize>
Each item of each type has something like a primary index called an 'id'.
The ids can be thought of as array indices, so looking up something by its
id is fast. Invalid ids are marked with the special value CC65_INV_ID.
Data passed back for an item may contain ids of other objects. A scope for
example contains the id of the parent scope (or CC65_INV_ID if there is no
parent scope). Most API functions use ids to lookup related objects.
<sect1>Libraries<p>
This information comes from the linker and is currently used in only one
place:To mark the origin of a module. The information available for a library
is its name including the path.
<itemize>
<item> Library id
<item> Name and path of library
</itemize>
<sect1>Lines<p>
A line is a location in a source file. It is module dependent, which means
that if two modules use the same source file, each one has its own line
information for this file. While the assembler has also column information,
it is dropped early because it would generate much more data. A line may have
one or more spans attached if code or data is generated.
<itemize>
<item> Line id
<item> Id of the source file, the line is from
<item> The line number in the file (starting with 1)
<item> The type of the line: Assembler/C source or macro
<item> A count for recursive macros if the line comes from a macro
</itemize>
<sect1>Modules<p>
A module is actually an object file. It is generated from one or more source
files and may come from a library. The assembler generates a main scope for
symbols declared outside user generated scopes. The main scope has an empty name.
<itemize>
<item> Module id
<item> The name of the module including the path
<item> The id of the main source file (the one specified on the command line)
<item> The id of the library the module comes from, or CC65_INV_ID
<item> The id of the main scope for this module
</itemize>
<sect1>Scopes<p>
Each module has a main scope where all symbols live, that are specified outside
other scopes. Additional nested scopes may be specified in the sources. So scopes
have a one to many relation: Each scope (with the exception of the main scope) has
exactly one parent and may have several child scopes. Scopes may not cross modules.
<itemize>
<item> Scope id
<item> The name of the scope (may be empty)
<item> The type of the scope: Module, .SCOPE or .PROC, .STRUCT and .ENUM
<item> The size of the scope (the size of the span for the active segment)
<item> The id of the parent scope (CC65_INV_ID in case of the main scope)
<item> The id of the attached symbol for .PROC scopes
<item> The id of the module where the scope comes from
</itemize>
<sect1>Segment Info<p>
<itemize>
<item> Segment id
<item> The name of the segment
<item> The start address of the segment
<item> The size of the segment
<item> The name of the output file, this segment was written to (may be empty)
<item> The offset of the segment in the output file (only if name not empty)
<item> The bank number of the segment's memory area
</itemize>
It is also possible to retrieve the spans for sections (a section is the part of a
segment that comes from one module). Since the main scope covers a whole module, and
the main scope has spans assigned (if not empty), the spans for the main scope of a
module are also the spans for the sections in the segments.
<sect1>Source files<p>
Modules are generated from source files. Since some source files are used several times
when generating a list of modules (header files for example), the linker will merge
duplicates to reduce redundant information. Source files are considered identical if the
full name including the path is identical, and the size and time of last modification
matches. Please note that there may be still duplicates if files are accessed using
different paths.
<itemize>
<item> Source file id
<item> The name of the source file including the path
<item> The size of the file at the time when it was read
<item> The time of last modification at the time when the file was read
</itemize>
<sect1>Spans<p>
A span is a small part of a segment. It has a start address and a size. Spans are used
to record sizes of other objects. Line infos and scopes may have spans attached, so it
is possible to lookup which data was generated for these items.
<itemize>
<item> Span id
<item> The start address of the span. This is an absolute address
<item> The end address of the span. This is inclusive which means if start==end then => size==1
<item> The id of the segment were the span is located
<item> The type of the data in the span (optional, maybe NULL)
<item> The number of line infos available for this span
<item> The number of scope infos available for this span
</itemize>
The last two fields will save a call to cc65_line_byspan or cc65_scope_byspan by providing
information about the number of items that can be retrieved by these calls.
<sect1>Symbols<p>
<itemize>
<item> Symbol id
<item> The name of the symbol
<item> The type of the symbol, which may be label, equate or import
<item> The size of the symbol (size of attached code or data). Only for labels. Zero if unknown
<item> The value of the symbol. For an import, this is taken from the corresponding export
<item> The id of the corresponding export. Only valid for imports, CC65_INV_ID for other symbols
<item> The segment id if the symbol is segment based. For an import, taken from the export
<item> The id of the scope this symbols was defined in
<item> The id of the parent symbol. This is only set for cheap locals and CC65_INV_ID otherwise
</itemize>
Beware: Even for an import, the id of the corresponding export may be CC65_INV_ID.
This happens if the module with the export has no debug information. So make sure
that your application can handle it.
<sect1>Types<p>
A type is somewhat special. You cannot retrieve data about it in a similar way as with the other
items. Instead you have to call a special routine that parses the type data and returns it
in a set of data structures that can be processed by a C or C++ program.
The type information is language independent and doesn't encode things like 'const' or
'volatile'. Instead it defines a set of simple data types and a few ways to aggregate
them (arrays, structs and unions).
Type information is currently generated by the assembler for storage allocating commands
like .BYTE or .WORD. For example, the assembler code
<tscreen><verb>
foo: .byte $01, $02, $03
</verb></tscreen>
will assign the symbol foo a size of 3, but will also generate a span with a size of 3
bytes and a type ARRAY[3] OF BYTE.
Evaluating the type of a span allows a debugger to display the data in the same way as it
was defined in the assembler source.
<table>
<tabular ca="clc">
<bf/Assembler Command/| <bf/Generated Type Information/@<hline>
.ADDR| ARRAY OF LITTLE ENDIAN POINTER WITH SIZE 2 TO VOID@
.BYTE| ARRAY OF UNSIGNED WITH SIZE 1@
.DBYT| ARRAY OF BIG ENDIAN UNSIGNED WITH SIZE 2@
.DWORD| ARRAY OF LITTLE ENDIAN UNSIGNED WITH SIZE 4@
.FARADDR| ARRAY OF LITTLE ENDIAN POINTER WITH SIZE 3 TO VOID@
.WORD| ARRAY OF LITTLE ENDIAN UNSIGNED WITH SIZE 2
</tabular>
</table>
<sect>Copyright<p>

View File

@@ -165,8 +165,26 @@ The names in the parentheses denote the symbols to be used for static linking of
<sect1>Graphics drivers<p>
No graphics drivers are currently available for the Plus/4.
<descrip>
<tag><tt/ted-hi.tgi (ted_hi_tgi)/</tag>
This driver features a resolution of 320*200 with two colors and an
adjustable palette (that means that the two colors can be chosen out of a
palette of the 121 TED colors).
Note that the text-mode character matrix and color data are destroyed by this
driver. The driver calls the Kernal <tt/CLRSCR/ routine to return the text
screen to a usable (if empty) state on <tt/tgi_done()/.
This driver places the bitmap at &dollar;C000-&dollar;E000. Programs using
this driver must either be linked with the option <tt/-D
__HIMEM__=&dollar;C000/, or use the <tt/plus4-hires.cfg/ linker configuration.
The <tt/plus4-hires.cfg/ is preferable, as it allows the stack to remain at
&dollar;FCFF, and exposes the remaining high memory from the end of the bitmap
to the stack top as a <tt/HIBSS/ segment that can be used by the programmer,
or given to <tt/_heapadd()/ (using the symbols <tt/_HIBSS_START__/ and
<tt/_HIBSS_SIZE__/).
</descrip><p>
<sect1>Extended memory drivers<p>

View File

@@ -40,6 +40,8 @@ The simulator is called as follows:
Long options:
--help Help (this text)
--cycles Print amount of executed CPU cycles
--cpu <type> Override CPU type (6502, 65C02, 6502X)
--trace Enable CPU trace
--verbose Increase verbosity
--version Print the simulator version number
</verb></tscreen>
@@ -70,6 +72,17 @@ Here is a description of all the command line options:
count.
<tag><tt>--cpu &lt;type&gt;</tt></tag>
Specify the CPU type to use while executing the program. This CPU type
is normally determined from the program file header, but it can be useful
to override it.
<tag><tt>--trace</tt></tag>
Print a single line of information for each instruction or interrupt that
is executed by the CPU to stdout.
<tag><tt>-v, --verbose</tt></tag>
Increase the simulator verbosity.
@@ -115,37 +128,78 @@ PVExit ($01)
<sect>Creating a Test in C<p>
For a C test compiled and linked with <tt/--target sim6502/ the
For a C test linked with <tt/--target sim6502/ and the <tt/sim6502.lib/ library,
command line arguments to <tt/sim65/ will be passed to <tt/main/,
and the return value from <tt/main/ will become sim65's exit code.
The <tt/exit/ function may also be used to terminate with an exit code.
The <tt/stdlib.h/ <tt/exit/ function may also be used to terminate with an exit code.
Exit codes are limited to 8 bits.
Exit codes are limited to an unsigned 8 bit value. (E.g. returning -1 will give an exit code of 255.)
The standard C library high level file input and output is functional.
A sim65 application can be written like a command line application,
providing arguments to <tt/main/ and using the <tt/stdio.h/ interfaces.
providing command line arguments to <tt/main/ and using the <tt/stdio.h/ interfaces
to interact with the console or access files.
Internally, file input and output is provided at a lower level by
a set of built-in paravirtualization functions (<ref id="paravirt-internal" name="see below">).
a set of built-in paravirtualization functions (see <ref id="paravirt-internal" name="below">).
Example:
<tscreen><verb>
#include <stdio.h>
int main()
{
printf("Hello!\n");
return 5;
}
// Build and run:
// cl65 -t sim6502 -o example.prg example.c
// sim65 example.prg
// Build and run, separate steps:
// cc65 -t sim6502 -o example.s example.c
// ca65 -t sim6502 -o example.o example.s
// ld65 -t sim6502 -o example.prg example.o sim6502.lib
// sim65 example.prg
</verb></tscreen>
<sect>Creating a Test in Assembly<p>
Assembly tests may similarly be assembled and linked with
<tt/--target sim6502/ or <tt/--target sim65c02/.
Define and export <tt/_main/ as an entry point,
Though a C test may also link with assembly code,
a pure assembly test can also be created.
Link with <tt/--target sim6502/ or <tt/--target sim65c02/ and the corresponding library,
define and export <tt/_main/ as an entry point,
and the sim65 library provides two ways to return an 8-bit exit code:
<itemize>
<item>Return from <tt/_main/ with the exit code in <tt/A/.
<item><tt/jmp exit/ with the code in <tt/A/.
<item><tt/jmp exit/ with the code in <tt/A/. (<tt/.import exit/ from the sim65 library.)
</itemize>
The binary file has a 12 byte header:
Example:
<tscreen><verb>
.export _main
_main:
lda #5
rts
; Build and run:
; cl65 -t sim6502 -o example.prg example.s
; sim65 example.prg
; Build and run, separate steps:
; ca65 -t sim6502 -o example.o example.s
; ld65 -t sim6502 -o example.prg example.o sim6502.lib
; sim65 example.prg
</verb></tscreen>
Internally, the binary program file has a 12 byte header provided by the library:
<itemize>
@@ -155,7 +209,7 @@ The binary file has a 12 byte header:
<item>1 byte <bf/CPU type/: <tt/0/ = 6502, <tt/1/ = 65C02
<item>1 byte <bf/sp address/: the zero page address of the C parameter stack pointer <tt/sp/ used by the paravirtualization functions
<item>1 byte <bf/c_sp address/: the zero page address of the C parameter stack pointer <tt/c_sp/ used by the paravirtualization functions
<item>1 word <bf/load address/: where to load the data from the file into memory (default: <tt/$0200/)
@@ -182,8 +236,204 @@ These use cc65 calling conventions, and are intended for use with the sim65 targ
<item><tt/IRQ/ and <tt/NMI/ events will not be generated, though <tt/BRK/
can be used if the IRQ vector at <tt/$FFFE/ is manually prepared by the test code.
<item>The <tt/sim6502/ or <tt/sim65c02/ targets provide a default configuration,
but if customization is needed <tt/sim6502.cfg/ or <tt/sim65c02.cfg/ might be used as a template.
</itemize>
<sect>Counter peripheral
<p>The sim65 simulator supports a memory-mapped counter peripheral that manages
a number of 64-bit counters that are continuously updated as the simulator is
running. For each counter, it also provides a 64 bit "latching" register.
<p>The functionality of the counter peripheral is accessible through 3 registers:
<itemize>
<item><tt>PERIPHERALS_COUNTER_LATCH</tt> ($FFC0, write-only)
<item><tt>PERIPHERALS_COUNTER_SELECT</tt> ($FFC1, read/write)
<item><tt>PERIPHERALS_COUNTER_VALUE</tt> ($FFC2..$FFC9, read-only)
</itemize>
<p>These three registers are used as follows.
<p>When a program explicitly requests a "counter latch" operation by writing any value
to the <tt>PERIPHERALS_COUNTER_LATCH</tt> address ($FFC0), all live registers are simultaneously
copied to the latch registers. They will keep their newly latched values until another latch
operation is requested.
<p>The <tt>PERIPHERALS_COUNTER_SELECT</tt> address ($FFC1) register holds an 8-bit value that
specifies which 64-bit latch register is currently readable through the <tt>PERIPHERALS_COUNTER_VALUE</tt>
address range. Six values are currently defined:
<itemize>
<item>$00: latched clock cycle counter selected.
<item>$01: latched CPU instruction counter selected.
<item>$02: latched IRQ interrupt counter selected.
<item>$03: latched NMI interrupt counter selected.
<item>$80: latched wallclock time (nanoseconds) selected.
<item>$81: latched wallclock time (split: seconds, nanoseconds) selected.
</itemize>
<p>Values $00 to $03 provide access to the latched (frozen) value of their respective live
counters at the time of the last write to <tt>PERIPHERALS_COUNTER_LATCH</tt>.
<p>When <tt>PERIPHERALS_COUNTER_SELECT</tt> equals $80, the <tt>PERIPHERALS_COUNTER_VALUE</tt>
will be a 64-bit value corresponding to the number of nanoseconds elapsed since the Unix epoch
(Midnight, Jan 1st, 1970 UTC), at the time of the last latch operation.
<p>When <tt>PERIPHERALS_COUNTER_SELECT</tt> equals $81, the high 32 bits of <tt>PERIPHERALS_COUNTER_VALUE</tt>
will be a 32-bit value corresponding to the number of seconds elapsed since the Unix epoch (Midnight, Jan 1st,
1970 UTC), at the time of the last latch operation. The low 32 bits of
<tt>PERIPHERALS_COUNTER_VALUE</tt> will hold the nanoseconds since the start of that second.
<p>The two different wallclock-time latch registers will always refer to precisely the same time instant.
For some applications, the single 64-bit value measured in nanoseconds will be more convenient, while
for other applications, the split 32/32 bits representation with separate second and nanosecond
values will be more convenient.
<p>Note that the time elapsed since the Unix epoch is an approximation, as the implementation depends on the
way POSIX defines time-since-the-epoch. Unfortunately, POSIX incorrectly assumes that all days are precisely
86400 seconds long, which is not true in case of leap seconds. The way this inconsistency is resolved is
system dependent.
<p>On reset, <tt>PERIPHERALS_COUNTER_SELECT</tt> is initialized to zero. If the <tt>PERIPHERALS_COUNTER_SELECT</tt>
register holds a value other than one of the six values described above, all <tt>PERIPHERALS_COUNTER_VALUE</tt>
bytes will read as zero.
<p>The <tt>PERIPHERALS_COUNTER_VALUE</tt> addresses ($FFC2..$FFC9) are used to read to currently
selected 64-bit latch register value. Address $FFC2 holds the least significant byte (LSB),
while address $FFC9 holds the most significant byte (MSB).
<p>On reset, all latch registers are reset to zero. Reading any of the <tt>PERIPHERALS_COUNTER_VALUE</tt>
bytes before the first write to <tt>PERIPHERALS_COUNTER_LATCH</tt> will yield zero.
Example:
<tscreen><verb>
/* This example uses the peripheral support in sim65.h */
#include <stdio.h>
#include <sim65.h>
static void print_current_counters(void)
{
peripherals.counter.latch = 0; /* latch values */
peripherals.counter.select = COUNTER_SELECT_CLOCKCYCLE_COUNTER;
printf("clock cycles ............... : %08lx %08lx\n", peripherals.counter.value32[1], peripherals.counter.value32[0]);
peripherals.counter.select = COUNTER_SELECT_INSTRUCTION_COUNTER;
printf("instructions ............... : %08lx %08lx\n", peripherals.counter.value32[1], peripherals.counter.value32[0]);
peripherals.counter.select = COUNTER_SELECT_WALLCLOCK_TIME;
printf("wallclock time ............. : %08lx %08lx\n", peripherals.counter.value32[1], peripherals.counter.value32[0]);
peripherals.counter.select = COUNTER_SELECT_WALLCLOCK_TIME_SPLIT;
printf("wallclock time, split ...... : %08lx %08lx\n", peripherals.counter.value32[1], peripherals.counter.value32[0]);
printf("\n");
}
int main(void)
{
print_current_counters();
print_current_counters();
return 0;
}
</verb></tscreen>
<sect>SIM65 control peripheral
<p>The sim65 simulator supports a memory-mapped peripheral that allows control
of the simulator behavior itself.
<p>The sim65 control peripheral interface consists of 2 registers:
<itemize>
<item><tt>PERIPHERALS_SIMCONTROL_CPUMODE</tt> ($FFCA, read/write)
<item><tt>PERIPHERALS_SIMCONTROL_TRACEMODE</tt> ($FFCB, read/write)
</itemize>
<p>Address <tt>PERIPHERALS_SIMCONTROL_CPUMODE</tt> allows access to the currently active CPU mode.
<p>Possible values are CPU_6502 (0), CPU_65C02 (1), and CPU_6502X (2). For specialized applications,
it may be useful to switch CPU models at runtime; this is supported by writing 0, 1, or 2 to this address.
Writing any other value will be ignored.
<p>Address <tt>PERIPHERALS_SIMCONTROL_TRACEMODE</tt> allows inspection and control of the currently active
CPU tracing mode.
<p>A value of 0 means tracing is disabled; a value of $7F fully enables tracing. The 7
lower bits of the value actually provide control over which fields are printed; see below
for an explanation of the seven fields.
<p>Having the ability to enable/disable tracing on the fly can be a useful debugging aid. For example,
it can be used to enable tracing for short fragments of code. Consider the following example:
<tscreen><verb>
/* This example uses the TRACE_ON and TRACE_OFF macros defined in sim65.h */
#include <stdio.h>
#include <sim65.h>
unsigned x;
int main(void)
{
TRACE_ON();
x = 0x1234; /* We want to see what happens here. */
TRACE_OFF();
return 0;
}
</verb></tscreen>
<p>This small test program, when compiled with optimizations enabled (-O), produces the output trace below:
<tscreen><verb>
70 232 022E A2 12 ldx #$12 A=7F X=00 Y=04 S=FD Flags=nvdizC SP=FFBC
71 234 0230 A9 34 lda #$34 A=7F X=12 Y=04 S=FD Flags=nvdizC SP=FFBC
72 236 0232 8D C8 02 sta $02C8 A=34 X=12 Y=04 S=FD Flags=nvdizC SP=FFBC
73 240 0235 8E C9 02 stx $02C9 A=34 X=12 Y=04 S=FD Flags=nvdizC SP=FFBC
74 244 0238 A9 00 lda #$00 A=34 X=12 Y=04 S=FD Flags=nvdizC SP=FFBC
75 246 023A 8D CB FF sta $FFCB A=00 X=12 Y=04 S=FD Flags=nvdiZC SP=FFBC
</verb></tscreen>
<p>The example output shows the full trace format, consisting of the following seven fields:
<itemize>
<item>The first field is an instruction counter. We see here that the assignment '<tt>x = 0x1234;</tt>'
starts at the 70th CPU instruction since the start of the simulator, and takes four 6502 instructions.
The two instructions that follow correspond to the execution of the <tt>TRACE_OFF</tt>' macro
that disables tracing.
<item>The second field shows the clock cycles since the start of the program. Here we see that the
first four instructions take 12 clock cycles in total (262 - 250 = 12).
<item>The third field shows the program counter as a four-digit, i.e., the PC register. Its 16-bit
value is displayed as a 4-digit hecadecimal number.
<item>The fourth field shows one to three hexadecimal byte values that make up the instruction.
<item>The fifth field shows the instruction in human-readable assembly language.
<item>The sixth field shows the CPU registers before execution of the instruction. The A, X, Y, and
S registers are each shown as a single byte value. The six status bits of the CPU are shown in
the order NVDIZC (Negative, Overflow, Decimal, Interrupt, Zero, Carry). They are displayed as
a capital letter if the flag is set, or a small letter if the flag is unset.
<item>The seventh and last field shows the software stack pointer SP as used by CC65 programs that
conform to the CC65 conventions.
</itemize>
<p>Writing a specific value to <tt>PERIPHERALS_SIMCONTROL_TRACEMODE</tt> will control which of these
seven fields are displayed. The following values are defined to denote the seven fields:
<itemize>
<item>TRACE_FIELD_INSTR_COUNTER = 0x40
<item>TRACE_FIELD_CLOCK_COUNTER = 0x20
<item>TRACE_FIELD_PC = 0x10
<item>TRACE_FIELD_INSTR_BYTES = 0x08
<item>TRACE_FIELD_INSTR_ASSEMBLY = 0x04
<item>TRACE_FIELD_CPU_REGISTERS = 0x02
<item>TRACE_FIELD_CC65_SP = 0x01
</itemize>
<p>For example, writing the value $16 to <tt>PERIPHERALS_SIMCONTROL_TRACEMODE</tt> will only display
the program counter, instruction assembly, and CPU registers fields.
<sect>Copyright<p>

View File

@@ -43,7 +43,7 @@ of range.
<ref id="tgi_setcolor" name="tgi_setcolor">
<tag/Example/<tscreen><verb>
/* Draw the upper half of an ellipse */
tgi_setcolor(TGI_COLOR_BLUE);
tgi_setcolor(1);
tgi_arc (50, 50, 40, 20, 0, 180);
</verb></tscreen>
</descrip>
@@ -67,7 +67,7 @@ be used in presence of a prototype.
<tag/Availability/cc65
<tag/See also/Other tgi function
<tag/Example/<tscreen><verb>
tgi_setcolor(TGI_COLOR_GREEN);
tgi_setcolor(1);
tgi_bar(10, 10, 100, 60);
</verb></tscreen>
</descrip>
@@ -94,7 +94,7 @@ be used in presence of a prototype.
<ref id="tgi_pieslice" name="tgi_pieslice">,
<ref id="tgi_setcolor" name="tgi_setcolor">
<tag/Example/<tscreen><verb>
tgi_setcolor(TGI_COLOR_BLACK);
tgi_setcolor(1);
tgi_circle(50, 40, 40);
</verb></tscreen>
</descrip>
@@ -154,7 +154,7 @@ be used in presence of a prototype.
<ref id="tgi_pieslice" name="tgi_pieslice">,
<ref id="tgi_setcolor" name="tgi_setcolor">
<tag/Example/<tscreen><verb>
tgi_setcolor(TGI_COLOR_RED);
tgi_setcolor(1);
tgi_ellipse (50, 40, 40, 20);
</verb></tscreen>
</descrip>
@@ -216,17 +216,19 @@ original aspect ratio.
<quote>
<descrip>
<tag/Function/Return the current drawing color.
<tag/Function/Return the current drawing color (palette index).
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/unsigned char tgi_getcolor (void);/
<tag/Description/The actual color is an index to a palette. During tgi_init
you will get a default palette. The number of colors depend on the platform.
All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some
platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN
and then you change the green of the palette to blue using tgi_setpalette then
after this painting in TGI_COLOR_GREEN will actually be blue.
you will get a default palette.
A default palette has always two entries with values equal to TGI_COLOR_BLACK
and TGI_COLOR_WHITE. However, which default palette entries have those two
values is target specific.
Note that both the number of colors, and also the available colors, depend on
the target and/or driver.
<tag/Availability/cc65
<tag/See also/Other tgi functions
<tag/See also/<ref id="tgi_setcolor" name="tgi_setcolor">,
<ref id="tgi_setpalette" name="tgi_setpalette">
<tag/Example/<tscreen><verb>
color = tgi_getcolor();
</verb></tscreen>
@@ -238,7 +240,8 @@ color = tgi_getcolor();
<quote>
<descrip>
<tag/Function/Get the number of available colors.
<tag/Function/Get the number of available colors in the palette for the current
driver.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/
<tag/Description/TGI platforms use indexed color palettes. This function
@@ -287,8 +290,6 @@ if (num_colors == 0) {
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/
<tag/Description/The tgi driver has a default palette that is active at startup.
The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this
palette to work correctly.
<tag/Availability/cc65
<tag/See also/Other tgi functions
<tag/Example/None.
@@ -418,10 +419,10 @@ be used in presence of a prototype.
<quote>
<descrip>
<tag/Function/Get the color of a pixel from the viewpage.
<tag/Function/Get the color (palette index) of a pixel from the viewpage.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/
<tag/Description/Get the color of a pixel from the viewpage.
<tag/Description/Get the color (palette index) of a pixel from the viewpage.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
@@ -477,10 +478,10 @@ be used in presence of a prototype.
<quote>
<descrip>
<tag/Function/Get number of horisontal pixels on the screen.
<tag/Function/Get number of horizontal pixels on the screen.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/unsigned tgi_getxres (void);/
<tag/Description/Get number of horisontal pixels on the screen.
<tag/Description/Get number of horizontal pixels on the screen.
This is same as tgi_maxx()+1.
<tag/Availability/cc65
<tag/See also/Other tgi functions.
@@ -626,7 +627,7 @@ be used in presence of a prototype.
#define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
if (!tgi_busy()) {
tgi_sprite(&amp;background);
tgi_setcolor(TGI_COLOR_BLUE);
tgi_setcolor(1);
tgi_outttextxy(20,40,"Hello World");
tgi_updatedisplay();
}
@@ -791,7 +792,7 @@ of range.
<ref id="tgi_setcolor" name="tgi_setcolor">
<tag/Example/<tscreen><verb>
/* Draw the closed upper half of an ellipse */
tgi_setcolor(TGI_COLOR_BLUE);
tgi_setcolor(1);
tgi_pieslice (50, 50, 40, 20, 0, 180);
</verb></tscreen>
</descrip>
@@ -834,20 +835,21 @@ only in the presence of a prototype.
<quote>
<descrip>
<tag/Function/Set color to be used in future draw operations.
<tag/Function/Set color (palette index) to be used in future draw operations.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/
<tag/Description/Set color to be used in future draw operations.
<tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color_index);/
<tag/Description/Set color (palette index) to be used in future draw operations.
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
</itemize>
<tag/Availability/cc65
<tag/See also/Other tgi functions.
<tag/See also/<ref id="tgi_getcolor" name="tgi_getcolor">,
<ref id="tgi_setpalette" name="tgi_setpalette">
<tag/Example/<tscreen><verb>
tgi_setcolor(TGI_COLOR_BLACK);
tgi_setcolor(1);
tgi_bar(0,0,30,30);
tgi_setcolor(TGI_COLOR_WHITE);
tgi_setcolor(2);
tgi_bar(10,10,20,20);
</verb></tscreen>
</descrip>
@@ -893,13 +895,21 @@ Palette is a pointer to as many entries as there are colors.
<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/
<tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/
<tag/Description/Set the palette (not available with all drivers/hardware).
Palette is a pointer to as many entries as there are colors.
Palette is a pointer to as many entries as there are colors. The values in the
palette are target specific, some (hopefully, more or less) portable values are
defined in the TGI_COLOR_XY defines. Note that different platforms provide
different colors, only TGI_COLOR_BLACK and TGI_COLOR_WHITE are guaranteed to
exist (needed for the default palette).
<tag/Notes/<itemize>
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
<item>The palette is the (only) place where to use the TGI_COLOR_XY values. This
has been an ongoing and reoccurring misunderstanding in the past: At every other
place, the "color" values are indices into the current palette.
</itemize>
<tag/Availability/cc65
<tag/See also/Other tgi functions.
<tag/See also/<ref id="tgi_setcolor" name="tgi_setcolor">,
<ref id="tgi_getpalette" name="tgi_getpalette">
<tag/Example/None.
</descrip>
</quote>

View File

@@ -27,7 +27,7 @@
#ifndef __MIKEY_H
#define __MIKEY_H
/* timer structure */
/* Timer structure */
typedef struct _mikey_timer {
unsigned char reload;
unsigned char control;
@@ -39,7 +39,7 @@ typedef struct _mikey_all_timers {
struct _mikey_timer timer[8];
} _mikey_all_timers;
/* audio channel structure */
/* Audio channel structure */
typedef struct _mikey_audio {
unsigned char volume;
unsigned char feedback;
@@ -53,54 +53,212 @@ typedef struct _mikey_audio {
/* Define a structure with the mikey register offsets */
struct __mikey {
struct _mikey_timer timer0; // 0xFD00
struct _mikey_timer timer1; // 0xFD04
struct _mikey_timer timer2; // 0xFD08
struct _mikey_timer timer3; // 0xFD0C
struct _mikey_timer timer4; // 0xFD10
struct _mikey_timer timer5; // 0xFD14
struct _mikey_timer timer6; // 0xFD18
struct _mikey_timer timer7; // 0xFD1C
struct _mikey_audio channel_a; // 0xFD20
struct _mikey_audio channel_b; // 0xFD28
struct _mikey_audio channel_c; // 0xFD30
struct _mikey_audio channel_d; // 0xFD38
unsigned char attena; // 0xFD40 ?? not yet allocated?
unsigned char attenb; // 0xFD41 |
unsigned char attenc; // 0xFD42 |
unsigned char attend; // 0xFD43 |
unsigned char panning; // 0xFD44 |
unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used
unsigned char mstereo; // 0xFD50 stereo control bits
unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used
unsigned char intrst; // 0xFD80 interrupt poll 0
unsigned char intset; // 0xFD81 interrupt poll 1
unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used
unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit
unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit
unsigned char audin; // 0xFD86 audio in
unsigned char sysctl1; // 0xFD87 control bits
unsigned char mikeyrev; // 0xFD88 mikey hardware rev
unsigned char mikeysrev; // 0xFD89 mikey software rev
unsigned char iodir; // 0xFD8A parallel i/o data dir
unsigned char iodat; // 0xFD8B parallel data
unsigned char serctl; // 0xFD8C serial control register
unsigned char serdat; // 0xFD8D serial data
unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used
unsigned char sdoneack; // 0xFD90 suzy done acknowledge
unsigned char cpusleep; // 0xFD91 cpu bus request disable
unsigned char dispctl; // 0xFD92 video bus request enable, viddma
unsigned char pkbkup; // 0xFD93 magic 'P' count
unsigned char *scrbase; // 0xFD94 start address of video display
unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used
unsigned char mtest0; // 0xFD9C
unsigned char mtest1; // 0xFD9D
unsigned char mtest2; // 0xFD9E
unsigned char unused5; // 0xFD9F not used
unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes
// 0xFDC0 - 0xFDFF not used
struct _mikey_timer timer0; /* 0xFD00 */
struct _mikey_timer timer1; /* 0xFD04 */
struct _mikey_timer timer2; /* 0xFD08 */
struct _mikey_timer timer3; /* 0xFD0C */
struct _mikey_timer timer4; /* 0xFD10 */
struct _mikey_timer timer5; /* 0xFD14 */
struct _mikey_timer timer6; /* 0xFD18 */
struct _mikey_timer timer7; /* 0xFD1C */
struct _mikey_audio channel_a; /* 0xFD20 */
struct _mikey_audio channel_b; /* 0xFD28 */
struct _mikey_audio channel_c; /* 0xFD30 */
struct _mikey_audio channel_d; /* 0xFD38 */
unsigned char attena; /* 0xFD40 ?? not yet allocated? */
unsigned char attenb; /* 0xFD41 | */
unsigned char attenc; /* 0xFD42 | */
unsigned char attend; /* 0xFD43 | */
unsigned char panning; /* 0xFD44 | */
unsigned char unused0[11]; /* 0xFD45 - 0xFD4F not used */
unsigned char mstereo; /* 0xFD50 stereo control bits */
unsigned char unused1[47]; /* 0xFD51 - 0xFD7F not used */
unsigned char intrst; /* 0xFD80 interrupt poll 0 */
unsigned char intset; /* 0xFD81 interrupt poll 1 */
unsigned char unused2[2]; /* 0xFD82 - 0xFD83 not used */
unsigned char magrdy0; /* 0xFD84 mag tape channel0 ready bit */
unsigned char magrdy1; /* 0xFD85 mag tape channel1 ready bit */
unsigned char audin; /* 0xFD86 audio in */
unsigned char sysctl1; /* 0xFD87 control bits */
unsigned char mikeyrev; /* 0xFD88 mikey hardware rev */
unsigned char mikeysrev; /* 0xFD89 mikey software rev */
unsigned char iodir; /* 0xFD8A parallel i/o data dir */
unsigned char iodat; /* 0xFD8B parallel data */
unsigned char serctl; /* 0xFD8C serial control register */
unsigned char serdat; /* 0xFD8D serial data */
unsigned char unused3[2]; /* 0xFD8E - 0xFD8F not used */
unsigned char sdoneack; /* 0xFD90 suzy done acknowledge */
unsigned char cpusleep; /* 0xFD91 cpu bus request disable */
unsigned char dispctl; /* 0xFD92 video bus request enable, viddma */
unsigned char pkbkup; /* 0xFD93 magic 'P' count */
unsigned char *scrbase; /* 0xFD94 start address of video display */
unsigned char unused4[6]; /* 0xFD96 - 0xFD9B not used */
unsigned char mtest0; /* 0xFD9C */
unsigned char mtest1; /* 0xFD9D */
unsigned char mtest2; /* 0xFD9E */
unsigned char unused5; /* 0xFD9F not used */
unsigned char palette[32]; /* 0xFDA0 - 0xFDBF palette 32 bytes */
unsigned char unused6[64]; /* 0xFDC0 - 0xFDFF not used */
unsigned char bootrom[504]; /* 0xFE00 - 0xFFD8 boot rom */
unsigned char reserved; /* 0xFFD8 reserved for future hardware */
unsigned char mapctl; /* 0xFFF9 map control register */
struct {
unsigned char *nmi; /* 0xFFFA NMI vector */
unsigned char *reset; /* 0xFFFB reset vector */
unsigned char *irq; /* 0xFFFC IRQ vector */
} vectors;
};
/* TIM_CONTROLA control bit definitions */
enum {
ENABLE_INT = 0x80,
RESET_DONE = 0x40,
ENABLE_RELOAD = 0x10,
ENABLE_COUNT = 0x08
};
/* AUD_CONTROL control bit definitions */
enum {
FEEDBACK_7 = 0x80,
ENABLE_INTEGRATE = 0x20
};
/* Audio and timer clock settings for source period */
enum {
AUD_LINKING = 0x07,
AUD_64 = 0x06,
AUD_32 = 0x05,
AUD_16 = 0x04,
AUD_8 = 0x03,
AUD_4 = 0x02,
AUD_2 = 0x01,
AUD_1 = 0x00
};
/* TIM_CONTROLB control bit definitions */
enum {
TIMER_DONE = 0x08,
LAST_CLOCK = 0x04,
BORROW_IN = 0x02,
BORROW_OUT = 0x01
};
/* MPAN and MSTEREO registers bit definitions */
enum {
LEFT3_SELECT = 0x80,
LEFT2_SELECT = 0x40,
LEFT1_SELECT = 0x20,
LEFT0_SELECT = 0x10,
RIGHT3_SELECT = 0x08,
RIGHT2_SELECT = 0x04,
RIGHT1_SELECT = 0x02,
RIGHT0_SELECT = 0x01,
LEFT_ATTENMASK = 0xF0,
RIGHT_ATTENMASK = 0x0F
};
/* Interrupt Reset and Set bit definitions */
enum {
TIMER7_INT = 0x80,
TIMER6_INT = 0x40,
TIMER5_INT = 0x20,
TIMER4_INT = 0x10,
TIMER3_INT = 0x08,
TIMER2_INT = 0x04,
TIMER1_INT = 0x02,
TIMER0_INT = 0x01,
SERIAL_INT = TIMER4_INT,
VERTICAL_INT = TIMER2_INT,
HORIZONTAL_INT = TIMER0_INT
};
/* SYSCTL1 bit definitions */
enum {
POWERON = 0x02,
CART_ADDR_STROBE = 0x01
};
/* IODIR and IODAT bit definitions */
enum {
AUDIN_BIT = 0x10, /* different from AUDIN address */
READ_ENABLE = 0x10, /* same bit for AUDIN_BIT */
RESTLESS = 0x08,
NOEXP = 0x04, /* if set, redeye is not connected */
CART_ADDR_DATA = 0x02,
CART_POWER_OFF = 0x02, /* same bit for CART_ADDR_DATA */
EXTERNAL_POWER = 0x01
};
/* SERCTL bit definitions for write operations */
enum {
TXINTEN = 0x80,
RXINTEN = 0x40,
PAREN = 0x10,
RESETERR = 0x08,
TXOPEN = 0x04,
TXBRK = 0x02,
PAREVEN = 0x01
};
/* SERCTL bit definitions for read operations */
enum {
TXRDY = 0x80,
RXRDY = 0x40,
TXEMPTY = 0x20,
PARERR = 0x10,
OVERRUN = 0x08,
FRAMERR = 0x04,
RXBRK = 0x02,
PARBIT = 0x01
};
/* DISPCTL bit definitions */
enum {
DISP_COLOR = 0x08, /* must be set to 1 */
DISP_FOURBIT = 0x04, /* must be set to 1 */
DISP_FLIP = 0x02,
DMA_ENABLE = 0x01 /* must be set to 1 */
};
/* MTEST0 bit definitions */
enum {
AT_CNT16 = 0x80,
AT_TEST = 0x40,
XCLKEN = 0x20,
UART_TURBO = 0x10,
ROM_SEL = 0x08,
ROM_TEST = 0x04,
M_TEST = 0x02,
CPU_TEST = 0x01
};
/* MTEST1 bit definitions */
enum {
P_CNT16 = 0x40,
REF_CNT16 = 0x20,
VID_TRIG = 0x10,
REF_TRIG = 0x08,
VID_DMA_DIS = 0x04,
REF_FAST = 0x02,
REF_DIS = 0x01
};
/* MTEST2 bit definitions */
enum {
V_STROBE = 0x10,
V_ZERO = 0x08,
H_120 = 0x04,
H_ZERO = 0x02,
V_BLANKEF = 0x01
};
/* MAPCTL bit definitions */
enum {
TURBO_DISABLE = 0x80,
VECTOR_SPACE = 0x08,
ROM_SPACE = 0x04,
MIKEY_SPACE = 0x02,
SUZY_SPACE = 0x01
};
#endif

View File

@@ -24,75 +24,65 @@
/* */
/*****************************************************************************/
#ifndef __SUZY_H
#define __SUZY_H
/* Joypad $FCB0 */
#define JOYPAD_RIGHT 0x10
#define JOYPAD_LEFT 0x20
#define JOYPAD_DOWN 0x40
#define JOYPAD_UP 0x80
#define BUTTON_OPTION1 0x08
#define BUTTON_OPTION2 0x04
#define BUTTON_INNER 0x02
#define BUTTON_OUTER 0x01
/* JOYSTICK bit definitions */
enum {
JOYPAD_RIGHT = 0x10,
JOYPAD_LEFT = 0x20,
JOYPAD_DOWN = 0x40,
JOYPAD_UP = 0x80,
BUTTON_OPTION1 = 0x08,
BUTTON_OPTION2 = 0x04,
BUTTON_INNER = 0x02,
BUTTON_OUTER = 0x01
};
/* Switches $FCB1 */
#define BUTTON_PAUSE 0x01
/* SWITCHES bit definitions */
enum {
CART1_IO_INACTIVE = 0x04,
CART0_IO_INACTIVE = 0x02,
BUTTON_PAUSE = 0x01
};
/* SPRCTL0 bit definitions */
enum {
BPP_4 = 0xC0,
BPP_3 = 0x80,
BPP_2 = 0x40,
BPP_1 = 0x00,
HFLIP = 0x20,
VFLIP = 0x10,
TYPE_SHADOW = 0x07,
TYPE_XOR = 0x06,
TYPE_NONCOLL = 0x05,
TYPE_NORMAL = 0x04,
TYPE_BOUNDARY = 0x03,
TYPE_BSHADOW = 0x02,
TYPE_BACKNONCOLL = 0x01,
TYPE_BACKGROUND = 0x00
};
/* Hardware Math */
#define FACTOR_A *(unsigned int *) 0xFC54
#define FACTOR_B *(unsigned int *) 0xFC52
#define PRODUCT0 *(unsigned int *) 0xFC60
#define PRODUCT1 *(unsigned int *) 0xFC62
#define PRODUCT *(long *) 0xFC60
/* SPRCTL1 bit definitions */
enum {
LITERAL = 0x80,
PACKED = 0x00,
ALGO3 = 0x40,
RENONE = 0x00,
REHV = 0x10,
REHVS = 0x20,
REHVST = 0x30,
REUSEPAL = 0x08,
SKIP = 0x04,
DRAWUP = 0x02,
DRAWLEFT = 0x01
};
#define DIVIDEND0 *(unsigned int *) 0xFC60
#define DIVIDEND1 *(unsigned int *) 0xFC62
#define DIVIDEND *(long *) 0xFC60
#define DIVISOR *(unsigned int *) 0xFC56
#define QUOTIENT0 *(unsigned int *) 0xFC52
#define QUOTIENT1 *(unsigned int *) 0xFC54
#define QUOTIENT *(long *) 0xFC52
#define REMAINDER0 *(unsigned int *) 0xFC6C
#define REMAINDER1 *(unsigned int *) 0xFC6E
#define REMAINDER *(long *) 0xFC6C
/* Sprite control block (SCB) definitions */
/* Sprite control block (SCB) defines */
/* SPRCTL0 $FC80 */
#define BPP_4 0xC0
#define BPP_3 0x80
#define BPP_2 0x40
#define BPP_1 0x00
#define HFLIP 0x20
#define VFLIP 0x10
#define TYPE_SHADOW 0x07
#define TYPE_XOR 0x06
#define TYPE_NONCOLL 0x05
#define TYPE_NORMAL 0x04
#define TYPE_BOUNDARY 0x03
#define TYPE_BSHADOW 0x02
#define TYPE_BACKNONCOLL 0x01
#define TYPE_BACKGROUND 0x00
/* SPRCTL1 $FC81 */
#define LITERAL 0x80
#define PACKED 0x00
#define ALGO3 0x40
#define RENONE 0x00
#define REHV 0x10
#define REHVS 0x20
#define REHVST 0x30
#define REUSEPAL 0x08
#define SKIP 0x04
#define DRAWUP 0x02
#define DRAWLEFT 0x01
typedef struct SCB_REHVST_PAL { // SCB with all attributes
/* SCB with all attributes */
typedef struct SCB_REHVST_PAL {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -107,7 +97,8 @@ typedef struct SCB_REHVST_PAL { // SCB with all attributes
unsigned char penpal[8];
} SCB_REHVST_PAL;
typedef struct SCB_REHVST { // SCB without pallette
/* SCB without pallette */
typedef struct SCB_REHVST {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -121,7 +112,8 @@ typedef struct SCB_REHVST { // SCB without pallette
unsigned int tilt;
} SCB_REHVST;
typedef struct SCB_REHV { // SCB without stretch/tilt
/* SCB without stretch/tilt */
typedef struct SCB_REHV {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -133,7 +125,8 @@ typedef struct SCB_REHV { // SCB without stretch/tilt
unsigned int vsize;
} SCB_REHV;
typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal
/* SCB without stretch/tilt, with penpal */
typedef struct SCB_REHV_PAL {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -146,7 +139,8 @@ typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal
unsigned char penpal[8];
} SCB_REHV_PAL;
typedef struct SCB_REHVS { // SCB w/o tilt & penpal
/* SCB without tilt/penpal */
typedef struct SCB_REHVS {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -159,7 +153,8 @@ typedef struct SCB_REHVS { // SCB w/o tilt & penpal
unsigned int stretch;
} SCB_REHVS;
typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal
/* SCB without tilt, with penpal */
typedef struct SCB_REHVS_PAL {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -173,7 +168,8 @@ typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal
unsigned char penpal[8];
} SCB_REHVS_PAL;
typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal
/* SCB without size/stretch/tilt/penpal */
typedef struct SCB_RENONE {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -183,7 +179,8 @@ typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal
signed int vpos;
} SCB_RENONE;
typedef struct SCB_RENONE_PAL { // SCB w/o size/str/tilt w/penpal
/* SCB without size/str/tilt, with penpal */
typedef struct SCB_RENONE_PAL {
unsigned char sprctl0;
unsigned char sprctl1;
unsigned char sprcoll;
@@ -210,30 +207,124 @@ typedef struct PENPAL_1 {
unsigned char penpal[1];
} PENPAL_1;
/* Misc system defines */
/* SPRGO bit definitions */
enum {
SPRITE_GO = 0x01, /* sprite process start bit */
EVER_ON = 0x04 /* everon detector enable */
};
/* SPRGO $FC91 */
#define EVER_ON 0x04
#define SPRITE_GO 0x01
/* SPRSYS bit definitions for write operations */
enum {
SIGNMATH = 0x80, /* signed math */
ACCUMULATE = 0x40, /* accumulate multiplication results */
NO_COLLIDE = 0x20, /* do not collide with any sprites (also SPRCOLL bit definition) */
VSTRETCH = 0x10, /* stretch v */
LEFTHAND = 0x08,
CLR_UNSAFE = 0x04, /* unsafe access reset */
SPRITESTOP = 0x02 /* request to stop sprite process */
};
/* SPRSYS (write) $FC92 */
#define SIGNMATH 0x80
#define ACCUMULATE 0x40
#define NO_COLLIDE 0x20
#define VSTRETCH 0x10
#define LEFTHAND 0x08
#define CLR_UNSAFE 0x04
#define SPRITESTOP 0x02
/* SPRSYS bit definitions for read operations */
enum {
MATHWORKING = 0x80, /* math operation in progress */
MATHWARNING = 0x40, /* accumulator overflow on multiple or divide by zero */
MATHCARRY = 0x20, /* last carry bit */
VSTRETCHING = 0x10,
LEFTHANDED = 0x08,
UNSAFE_ACCESS = 0x04, /* unsafe access performed */
SPRITETOSTOP = 0x02, /* requested to stop */
SPRITEWORKING = 0x01 /* sprite process is active */
};
/* SPRSYS (read) $FC92 */
#define MATHWORKING 0x80
#define MATHWARNING 0x40
#define MATHCARRY 0x20
#define VSTRETCHING 0x10
#define LEFTHANDED 0x08
#define UNSAFE_ACCESS 0x04
#define SPRITETOSTOP 0x02
#define SPRITEWORKING 0x01
/* Suzy hardware registers */
struct __suzy {
unsigned char *tmpadr; /* 0xFC00 Temporary address */
unsigned int tiltacc; /* 0xFC02 Tilt accumulator */
unsigned int hoff; /* 0xFC04 Offset to H edge of screen */
unsigned int voff; /* 0xFC06 Offset to V edge of screen */
unsigned char *sprbase; /* 0xFC08 Base address of sprite */
unsigned char *colbase; /* 0xFC0A Base address of collision buffer */
unsigned char *vidadr; /* 0xFC0C Current vid buffer address */
unsigned char *coladr; /* 0xFC0E Current col buffer address */
unsigned char *scbnext; /* 0xFC10 Address of next SCB */
unsigned char *sprdline; /* 0xFC12 start of sprite data line address */
unsigned int hposstrt; /* 0xFC14 start hpos */
unsigned int vposstrt; /* 0xFC16 start vpos */
unsigned int sprhsize; /* 0xFC18 sprite h size */
unsigned int sprvsize; /* 0xFC1A sprite v size */
unsigned int stretchl; /* 0xFC1C H size adder */
unsigned int tilt; /* 0xFC1E H pos adder */
unsigned int sprdoff; /* 0xFC20 offset to next sprite data line */
unsigned int sprvpos; /* 0xFC22 current vpos */
unsigned int colloff; /* 0xFC24 offset to collision depository */
unsigned int vsizeacc; /* 0xFC26 vertical size accumulator */
unsigned int hsizeoff; /* 0xFC28 horizontal size offset */
unsigned int vsizeoff; /* 0xFC2A vertical size offset */
unsigned char *scbaddr; /* 0xFC2C address of current SCB */
unsigned char *procaddr; /* 0xFC2E address of current spr data proc */
unsigned char unused0[32]; /* 0xFC30 - 0xFC4F reserved/unused */
unsigned char unused1[2]; /* 0xFC50 - 0xFC51 do not use */
unsigned char mathd; /* 0xFC52 */
unsigned char mathc; /* 0xFC53 */
unsigned char mathb; /* 0xFC54 */
unsigned char matha; /* 0xFC55 write starts a multiply operation */
unsigned char mathp; /* 0xFC56 */
unsigned char mathn; /* 0xFC57 */
unsigned char unused2[8]; /* 0xFC58 - 0xFC5F do not use */
unsigned char mathh; /* 0xFC60 */
unsigned char mathg; /* 0xFC61 */
unsigned char mathf; /* 0xFC62 */
unsigned char mathe; /* 0xFC63 write starts a divide operation */
unsigned char unused3[8]; /* 0xFC64 - 0xFC6B do not use */
unsigned char mathm; /* 0xFC6C */
unsigned char mathl; /* 0xFC6D */
unsigned char mathk; /* 0xFC6E */
unsigned char mathj; /* 0xFC6F */
unsigned char unused4[16]; /* 0xFC70 - 0xFC7F do not use */
unsigned char sprctl0; /* 0xFC80 sprite control bits 0 */
unsigned char sprctl1; /* 0xFC81 sprite control bits 1 */
unsigned char sprcoll; /* 0xFC82 sprite collision number */
unsigned char sprinit; /* 0xFC83 sprite initialization bits */
unsigned char unused5[4]; /* 0xFC84 - 0xFC87 unused */
unsigned char suzyhrev; /* 0xFC88 suzy hardware rev */
unsigned char suzysrev; /* 0xFC89 suzy software rev */
unsigned char unused6[6]; /* 0xFC8A - 0xFC8F unused */
unsigned char suzybusen; /* 0xFC90 suzy bus enable */
unsigned char sprgo; /* 0xFC91 sprite process start bit */
unsigned char sprsys; /* 0xFC92 sprite system control bits */
unsigned char unused7[29]; /* 0xFC93 - 0xFCAF unused */
unsigned char joystick; /* 0xFCB0 joystick and buttons */
unsigned char switches; /* 0xFCB1 other switches */
unsigned char cart0; /* 0xFCB2 cart0 r/w */
unsigned char cart1; /* 0xFCB3 cart1 r/w */
unsigned char unused8[8]; /* 0xFCB4 - 0xFCBF unused */
unsigned char leds; /* 0xFCC0 leds */
unsigned char unused9; /* 0xFCC1 unused */
unsigned char parstat; /* 0xFCC2 parallel port status */
unsigned char pardata; /* 0xFCC3 parallel port data */
unsigned char howie; /* 0xFCC4 howie (?) */
/* 0xFCC5 - 0xFCFF unused */
};
/* Hardware math registers */
#define FACTOR_A *(unsigned int *) 0xFC54
#define FACTOR_B *(unsigned int *) 0xFC52
#define PRODUCT0 *(unsigned int *) 0xFC60
#define PRODUCT1 *(unsigned int *) 0xFC62
#define PRODUCT *(long *) 0xFC60
#define DIVIDEND0 *(unsigned int *) 0xFC60
#define DIVIDEND1 *(unsigned int *) 0xFC62
#define DIVIDEND *(long *) 0xFC60
#define DIVISOR *(unsigned int *) 0xFC56
#define QUOTIENT0 *(unsigned int *) 0xFC52
#define QUOTIENT1 *(unsigned int *) 0xFC54
#define QUOTIENT *(long *) 0xFC52
#define REMAINDER0 *(unsigned int *) 0xFC6C
#define REMAINDER1 *(unsigned int *) 0xFC6E
#define REMAINDER *(long *) 0xFC6C
/* Deprecated definitions */
/* MAPCTL $FFF9 */
#define HIGHSPEED 0x80
@@ -242,77 +333,4 @@ typedef struct PENPAL_1 {
#define MIKEYSPACE 0x02
#define SUZYSPACE 0x01
/* Suzy Hardware Registers */
struct __suzy {
unsigned int tmpadr; // 0xFC00 Temporary address
unsigned int tiltacc; // 0xFC02 Tilt accumulator
unsigned int hoff; // 0xFC04 Offset to H edge of screen
unsigned int voff; // 0xFC06 Offset to V edge of screen
unsigned char *sprbase; // 0xFC08 Base address of sprite
unsigned char *colbase; // 0xFC0A Base address of collision buffer
unsigned char *vidadr; // 0xFC0C Current vid buffer address
unsigned char *coladr; // 0xFC0E Current col buffer address
unsigned char *scbnext; // 0xFC10 Address of next SCB
unsigned char *sprdline; // 0xFC12 start of sprite data line address
unsigned char *hposstrt; // 0xFC14 start hpos
unsigned char *vposstrt; // 0xFC16 start vpos
unsigned char *sprhsize; // 0xFC18 sprite h size
unsigned char *sprvsize; // 0xFC1A sprite v size
unsigned int stretchl; // 0xFC1C H size adder
unsigned int tilt; // 0xFC1E H pos adder
unsigned int sprdoff; // 0xFC20 offset to next sprite data line
unsigned int sprvpos; // 0xFC22 current vpos
unsigned int colloff; // 0xFC24 offset to collision depository
unsigned int vsizeacc; // 0xFC26 vertical size accumulator
unsigned int hsizeoff; // 0xFC28 horizontal size offset
unsigned int vsizeoff; // 0xFC2A vertical size offset
unsigned char *scbaddr; // 0xFC2C address of current SCB
unsigned char *procaddr; // 0xFC2E address of current spr data proc
unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused
unsigned char unused1[2]; // 0xFC50 - 0xFC51 do not use
unsigned char mathd; // 0xFC52
unsigned char mathc; // 0xFC53
unsigned char mathb; // 0xFC54
unsigned char matha; // 0xFC55
unsigned char mathp; // 0xFC56
unsigned char mathn; // 0xFC57
unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use
unsigned char mathh; // 0xFC60
unsigned char mathg; // 0xFC61
unsigned char mathf; // 0xFC62
unsigned char mathe; // 0xFC63
unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use
unsigned char mathm; // 0xFC6C
unsigned char mathl; // 0xFC6D
unsigned char mathk; // 0xFC6E
unsigned char mathj; // 0xFC6F
unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use
unsigned char sprctl0; // 0xFC80 sprite control bits 0
unsigned char sprctl1; // 0xFC81 sprite control bits 1
unsigned char sprcoll; // 0xFC82 sprite collision number
unsigned char sprinit; // 0xFC83 sprite initialization bits
unsigned char unused5[4]; // 0xFC84 - 0xFC87 unused
unsigned char suzyhrev; // 0xFC88 suzy hardware rev
unsigned char suzysrev; // 0xFC89 suzy software rev
unsigned char unused6[6]; // 0xFC8A - 0xFC8F unused
unsigned char suzybusen; // 0xFC90 suzy bus enable
unsigned char sprgo; // 0xFC91 sprite process start bit
unsigned char sprsys; // 0xFC92 sprite system control bits
unsigned char unused7[29]; // 0xFC93 - 0xFCAF unused
unsigned char joystick; // 0xFCB0 joystick and buttons
unsigned char switches; // 0xFCB1 other switches
unsigned char cart0; // 0xFCB2 cart0 r/w
unsigned char cart1; // 0xFCB3 cart1 r/w
unsigned char unused8[8]; // 0xFCB4 - 0xFCBF unused
unsigned char leds; // 0xFCC0 leds
unsigned char unused9; // 0xFCC1 unused
unsigned char parstat; // 0xFCC2 parallel port status
unsigned char pardata; // 0xFCC3 parallel port data
unsigned char howie; // 0xFCC4 howie (?)
// 0xFCC5 - 0xFCFF unused
};
#endif

188
include/_vic3.h Normal file
View File

@@ -0,0 +1,188 @@
/*****************************************************************************/
/* */
/* _vic3.h */
/* */
/* Internal include file, do not use directly */
/* */
/* */
/* */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* 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. */
/* */
/*****************************************************************************/
#ifndef __VIC3_H
#define __VIC3_H
/* FIXME: only VIC2 registers right now */
/* Define a structure with the vic register offsets. In cc65 mode, there
** are aliases for the field accessible as arrays.
*/
#if __CC65_STD__ == __CC65_STD_CC65__
struct __vic3 {
union {
struct {
unsigned char spr0_x; /* Sprite 0, X coordinate */
unsigned char spr0_y; /* Sprite 0, Y coordinate */
unsigned char spr1_x; /* Sprite 1, X coordinate */
unsigned char spr1_y; /* Sprite 1, Y coordinate */
unsigned char spr2_x; /* Sprite 2, X coordinate */
unsigned char spr2_y; /* Sprite 2, Y coordinate */
unsigned char spr3_x; /* Sprite 3, X coordinate */
unsigned char spr3_y; /* Sprite 3, Y coordinate */
unsigned char spr4_x; /* Sprite 4, X coordinate */
unsigned char spr4_y; /* Sprite 4, Y coordinate */
unsigned char spr5_x; /* Sprite 5, X coordinate */
unsigned char spr5_y; /* Sprite 5, Y coordinate */
unsigned char spr6_x; /* Sprite 6, X coordinate */
unsigned char spr6_y; /* Sprite 6, Y coordinate */
unsigned char spr7_x; /* Sprite 7, X coordinate */
unsigned char spr7_y; /* Sprite 7, Y coordinate */
};
struct {
unsigned char x; /* X coordinate */
unsigned char y; /* Y coordinate */
} spr_pos[8];
};
unsigned char spr_hi_x; /* High bits of X coordinate */
unsigned char ctrl1; /* Control register 1 */
unsigned char rasterline; /* Current raster line */
union {
struct {
unsigned char strobe_x; /* Light pen, X position */
unsigned char strobe_y; /* Light pen, Y position */
};
struct {
unsigned char x; /* Light pen, X position */
unsigned char y; /* Light pen, Y position */
} strobe;
};
unsigned char spr_ena; /* Enable sprites */
unsigned char ctrl2; /* Control register 2 */
unsigned char spr_exp_y; /* Expand sprites in Y dir */
unsigned char addr; /* Address of chargen and video ram */
unsigned char irr; /* Interrupt request register */
unsigned char imr; /* Interrupt mask register */
unsigned char spr_bg_prio; /* Priority to background */
unsigned char spr_mcolor; /* Sprite multicolor bits */
unsigned char spr_exp_x; /* Expand sprites in X dir */
unsigned char spr_coll; /* Sprite/sprite collision reg */
unsigned char spr_bg_coll; /* Sprite/background collision reg */
unsigned char bordercolor; /* Border color */
union {
struct {
unsigned char bgcolor0; /* Background color 0 */
unsigned char bgcolor1; /* Background color 1 */
unsigned char bgcolor2; /* Background color 2 */
unsigned char bgcolor3; /* Background color 3 */
};
unsigned char bgcolor[4]; /* Background colors */
};
union {
struct {
unsigned char spr_mcolor0; /* Color 0 for multicolor sprites */
unsigned char spr_mcolor1; /* Color 1 for multicolor sprites */
};
/* spr_color is already used ... */
unsigned char spr_mcolors[2]; /* Color for multicolor sprites */
};
union {
struct {
unsigned char spr0_color; /* Color sprite 0 */
unsigned char spr1_color; /* Color sprite 1 */
unsigned char spr2_color; /* Color sprite 2 */
unsigned char spr3_color; /* Color sprite 3 */
unsigned char spr4_color; /* Color sprite 4 */
unsigned char spr5_color; /* Color sprite 5 */
unsigned char spr6_color; /* Color sprite 6 */
unsigned char spr7_color; /* Color sprite 7 */
};
unsigned char spr_color[8]; /* Colors for the sprites */
};
/* The following ones are only valid in the C128: */
unsigned char x_kbd; /* Additional keyboard lines */
unsigned char clock; /* Clock switch bit */
};
#else
struct __vic3 {
unsigned char spr0_x; /* Sprite 0, X coordinate */
unsigned char spr0_y; /* Sprite 0, Y coordinate */
unsigned char spr1_x; /* Sprite 1, X coordinate */
unsigned char spr1_y; /* Sprite 1, Y coordinate */
unsigned char spr2_x; /* Sprite 2, X coordinate */
unsigned char spr2_y; /* Sprite 2, Y coordinate */
unsigned char spr3_x; /* Sprite 3, X coordinate */
unsigned char spr3_y; /* Sprite 3, Y coordinate */
unsigned char spr4_x; /* Sprite 4, X coordinate */
unsigned char spr4_y; /* Sprite 4, Y coordinate */
unsigned char spr5_x; /* Sprite 5, X coordinate */
unsigned char spr5_y; /* Sprite 5, Y coordinate */
unsigned char spr6_x; /* Sprite 6, X coordinate */
unsigned char spr6_y; /* Sprite 6, Y coordinate */
unsigned char spr7_x; /* Sprite 7, X coordinate */
unsigned char spr7_y; /* Sprite 7, Y coordinate */
unsigned char spr_hi_x; /* High bits of X coordinate */
unsigned char ctrl1; /* Control register 1 */
unsigned char rasterline; /* Current raster line */
unsigned char strobe_x; /* Light pen, X position */
unsigned char strobe_y; /* Light pen, Y position */
unsigned char spr_ena; /* Enable sprites */
unsigned char ctrl2; /* Control register 2 */
unsigned char spr_exp_y; /* Expand sprites in Y dir */
unsigned char addr; /* Address of chargen and video ram */
unsigned char irr; /* Interrupt request register */
unsigned char imr; /* Interrupt mask register */
unsigned char spr_bg_prio; /* Priority to background */
unsigned char spr_mcolor; /* Sprite multicolor bits */
unsigned char spr_exp_x; /* Expand sprites in X dir */
unsigned char spr_coll; /* Sprite/sprite collision reg */
unsigned char spr_bg_coll; /* Sprite/background collision reg */
unsigned char bordercolor; /* Border color */
unsigned char bgcolor0; /* Background color 0 */
unsigned char bgcolor1; /* Background color 1 */
unsigned char bgcolor2; /* Background color 2 */
unsigned char bgcolor3; /* Background color 3 */
unsigned char spr_mcolor0; /* Color 0 for multicolor sprites */
unsigned char spr_mcolor1; /* Color 1 for multicolor sprites */
unsigned char spr0_color; /* Color sprite 0 */
unsigned char spr1_color; /* Color sprite 1 */
unsigned char spr2_color; /* Color sprite 2 */
unsigned char spr3_color; /* Color sprite 3 */
unsigned char spr4_color; /* Color sprite 4 */
unsigned char spr5_color; /* Color sprite 5 */
unsigned char spr6_color; /* Color sprite 6 */
unsigned char spr7_color; /* Color sprite 7 */
};
#endif
/* End of _vic3.h */
#endif

View File

@@ -304,6 +304,36 @@ unsigned char detect_turbomaster (void);
* 0x01 : C64 Turbo Master cartridge present
*/
unsigned char __fastcall__ set_iigs_speed (unsigned char speed);
/* Set the speed of the Apple IIgs CPU.
*
* Possible values:
* SPEED_SLOW : 1 Mhz mode
* SPEED_FAST : Fast mode (2.8MHz or more, depending on the presence of
* an accelerator)
*
* Any other value will be interpreted as SPEED_FAST.
*/
unsigned char get_iigs_speed (void);
/* Get the speed of the Apple IIgs CPU.
*
* Possible return values:
* SPEED_SLOW : 1 Mhz mode
* SPEED_FAST : Fast mode (2.8MHz or more, depending on the presence of
* an accelerator)
*/
unsigned char detect_iigs (void);
/* Check whether we are running on an Apple IIgs.
*
* Possible return values:
* 0x00 : No
* 0x01 : Yes
*/
/* End of accelerator.h */
#endif

76
include/agat.h Normal file
View File

@@ -0,0 +1,76 @@
#ifndef _AGAT_H
#define _AGAT_H
/* Check for errors */
#if !defined(__AGAT__)
# error This module may only be used when compiling for the Agat!
#endif
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Color defines */
#define COLOR_BLACK 0x00
#define COLOR_RED 0x01
#define COLOR_GREEN 0x02
#define COLOR_YELLOW 0x03
#define COLOR_BLUE 0x04
#define COLOR_MAGENTA 0x05
#define COLOR_CYAN 0x06
#define COLOR_WHITE 0x07
/* Characters codes */
#define CH_CTRL_C 0x03
#define CH_ENTER 0x0D
#define CH_ESC 0x1B
#define CH_CURS_LEFT 0x08
#define CH_CURS_RIGHT 0x15
#define CH_CURS_UP 0x19
#define CH_CURS_DOWN 0x1A
#define CH_ESC 0x1B
#define CH_HLINE 0x1B
#define CH_VLINE 0x5C
#define CH_ULCORNER 0x10
#define CH_URCORNER 0x12
#define CH_LLCORNER 0x1D
#define CH_LRCORNER 0x1F
/* Masks for joy_read */
#define JOY_UP_MASK 0x10
#define JOY_DOWN_MASK 0x20
#define JOY_LEFT_MASK 0x04
#define JOY_RIGHT_MASK 0x08
#define JOY_BTN_1_MASK 0x40
#define JOY_BTN_2_MASK 0x80
/* Return codes for get_ostype */
#define AGAT_UNKNOWN 0x00
#define AGAT_7 0x10 /* Agat 7 */
#define AGAT_9 0x20 /* Agat 9 */
/*****************************************************************************/
/* Code */
/*****************************************************************************/
unsigned char get_ostype (void);
/* Get the machine type. Returns one of the AGAT_xxx codes. */
void rebootafterexit (void);
/* Reboot machine after program termination has completed. */
/* The following #defines will cause the matching functions calls in conio.h
** to be overlaid by macros with the same names, saving the function call
** overhead.
*/
#define _bgcolor(color) COLOR_BLACK
#define _bordercolor(color) COLOR_BLACK
/* End of agat.h */
#endif

View File

@@ -41,6 +41,7 @@
# error This module may only be used when compiling for the Apple ][!
#endif
#include <time.h>
#include <apple2_filetype.h>
@@ -82,7 +83,77 @@
#define CH_CURS_LEFT 0x08
#define CH_CURS_RIGHT 0x15
#if !defined(__APPLE2ENH__)
/* These characters are not available on the ][+, but
* are on the //e. */
#if defined(__APPLE2ENH__) || defined(APPLE2_INCLUDE_IIE_CHARS)
#define CH_DEL 0x7F
#define CH_CURS_UP 0x0B
#define CH_CURS_DOWN 0x0A
/* These are defined to be OpenApple + NumberKey */
#define CH_F1 0xB1
#define CH_F2 0xB2
#define CH_F3 0xB3
#define CH_F4 0xB4
#define CH_F5 0xB5
#define CH_F6 0xB6
#define CH_F7 0xB7
#define CH_F8 0xB8
#define CH_F9 0xB9
#define CH_F10 0xB0
#endif
#if defined(__APPLE2ENH__)
/* MouseText-based functions for boxes and lines drawing */
void mt_chline (unsigned char length);
void mt_cvline (unsigned char length);
void mt_chlinexy (unsigned char x, unsigned char y, unsigned char length);
void mt_cvlinexy (unsigned char x, unsigned char y, unsigned char length);
#define CH_HLINE 0x5F
#define CH_VLINE 0xDF
#define CH_ULCORNER 0x5F
#define CH_URCORNER 0x20
#define CH_LLCORNER 0xD4
#define CH_LRCORNER 0xDF
#define CH_TTEE 0x5F
#define CH_BTEE 0xD4
#define CH_LTEE 0xD4
#define CH_RTEE 0xDF
#define CH_CROSS 0xD4
#define _chline(length) mt_chline(length)
#define _chlinexy(x,y,length) mt_chlinexy(x,y,length)
#define _cvline(length) mt_cvline(length)
#define _cvlinexy(x,y,length) mt_cvlinexy(x,y,length)
#else
/* Functions that don't depend on MouseText to draw boxes and lines */
void dyn_chline (unsigned char h, unsigned char length);
void dyn_cvline (unsigned char v, unsigned char length);
void dyn_chlinexy (unsigned char h, unsigned char x, unsigned char y, unsigned char length);
void dyn_cvlinexy (unsigned char v, unsigned char x, unsigned char y, unsigned char length);
#if defined(DYN_BOX_DRAW)
/* When the user defines DYN_BOX_DRAW, we'll adapt to the machine
** we run on.
*/
extern char CH_HLINE;
extern char CH_VLINE;
extern char CH_ULCORNER;
extern char CH_URCORNER;
extern char CH_LLCORNER;
extern char CH_LRCORNER;
extern char CH_TTEE;
extern char CH_BTEE;
extern char CH_LTEE;
extern char CH_RTEE;
extern char CH_CROSS;
#else
/* Otherwise, fallback to safety and don't use MouseText at all. */
#define CH_HLINE '-'
#define CH_VLINE '!'
#define CH_ULCORNER '+'
@@ -94,7 +165,14 @@
#define CH_LTEE '+'
#define CH_RTEE '+'
#define CH_CROSS '+'
#endif
#endif /* DYN_BOX_DRAW */
#define _chline(length) dyn_chline(CH_HLINE, length)
#define _chlinexy(x, y, length) dyn_chlinexy(CH_HLINE, x ,y, length)
#define _cvline(length) dyn_cvline(CH_VLINE, length)
#define _cvlinexy(x, y, length) dyn_cvlinexy(CH_VLINE, x, y, length)
#endif /* __APPLE2ENH__ */
/* Masks for joy_read */
#define JOY_UP_MASK 0x10
@@ -121,6 +199,17 @@
#define APPLE_IIGS1 0x81 /* Apple IIgs (ROM 1) */
#define APPLE_IIGS3 0x83 /* Apple IIgs (ROM 3) */
/* Return codes for get_tv() */
#define TV_NTSC 0
#define TV_PAL 1
#define TV_OTHER 2
/* Video modes */
#define VIDEOMODE_40x24 0x15
#define VIDEOMODE_80x24 0x00
#define VIDEOMODE_40COL VIDEOMODE_40x24
#define VIDEOMODE_80COL VIDEOMODE_80x24
extern unsigned char _dos_type;
/* Valid _dos_type values:
**
@@ -142,6 +231,27 @@ extern unsigned char _dos_type;
** ProDOS 8 2.4.x - 0x24
*/
/* struct stat.st_mode values */
#define S_IFDIR 0x01
#define S_IFREG 0x02
#define S_IFBLK 0xFF
#define S_IFCHR 0xFF
#define S_IFIFO 0xFF
#define S_IFLNK 0xFF
#define S_IFSOCK 0xFF
struct datetime {
struct {
unsigned day :5;
unsigned mon :4;
unsigned year :7;
} date;
struct {
unsigned char min;
unsigned char hour;
} time;
};
/*****************************************************************************/
@@ -151,20 +261,10 @@ extern unsigned char _dos_type;
/* The file stream implementation and the POSIX I/O functions will use the
** following struct to set the date and time stamp on files. This specificially
** following struct to set the date and time stamp on files. This specifically
** applies to the open and fopen functions.
*/
extern struct {
struct {
unsigned day :5;
unsigned mon :4;
unsigned year :7;
} createdate; /* Current date: 0 */
struct {
unsigned char min;
unsigned char hour;
} createtime; /* Current time: 0 */
} _datetime;
extern struct datetime _datetime;
/* The addresses of the static drivers */
#if !defined(__APPLE2ENH__)
@@ -185,6 +285,12 @@ extern void a2_lo_tgi[];
void beep (void);
/* Beep beep. */
unsigned char get_tv (void);
/* Get the machine vblank frequency. Returns one of the TV_xxx codes. */
unsigned char get_ostype (void);
/* Get the machine type. Returns one of the APPLE_xxx codes. */
@@ -211,6 +317,35 @@ void rebootafterexit (void);
#define _cpeekcolor() COLOR_WHITE
#define _cpeekrevers() 0
struct tm* __fastcall__ gmtime_dt (const struct datetime* dt);
/* Converts a ProDOS date/time structure to a struct tm */
time_t __fastcall__ mktime_dt (const struct datetime* dt);
/* Converts a ProDOS date/time structure to a time_t UNIX timestamp */
typedef struct DIR DIR;
unsigned int __fastcall__ dir_entry_count(DIR *dir);
/* Returns the number of active files in a ProDOS directory */
#if !defined(__APPLE2ENH__)
unsigned char __fastcall__ allow_lowercase (unsigned char onoff);
/* If onoff is 0, lowercase characters printed to the screen via STDIO and
** CONIO are forced to uppercase. If onoff is 1, lowercase characters are
** printed to the screen untouched. By default lowercase characters are
** forced to uppercase because a stock Apple ][+ doesn't support lowercase
** display. The function returns the old lowercase setting.
*/
#endif
signed char __fastcall__ videomode (unsigned mode);
/* Set the video mode, return the old mode, or -1 if 80-column hardware is not
** installed. Call with one of the VIDEOMODE_xx constants.
*/
void waitvsync (void);
/* Wait for start of next frame */
/* End of apple2.h */

View File

@@ -46,49 +46,6 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Characters codes */
#define CH_DEL 0x7F
#define CH_CURS_UP 0x0B
#define CH_CURS_DOWN 0x0A
#define CH_HLINE 0x5F
#define CH_VLINE 0xDF
#define CH_ULCORNER 0x5F
#define CH_URCORNER 0x20
#define CH_LLCORNER 0xD4
#define CH_LRCORNER 0xDF
#define CH_TTEE 0x5F
#define CH_BTEE 0xD4
#define CH_LTEE 0xD4
#define CH_RTEE 0xDF
#define CH_CROSS 0xD4
/* These are defined to be OpenApple + NumberKey */
#define CH_F1 0xB1
#define CH_F2 0xB2
#define CH_F3 0xB3
#define CH_F4 0xB4
#define CH_F5 0xB5
#define CH_F6 0xB6
#define CH_F7 0xB7
#define CH_F8 0xB8
#define CH_F9 0xB9
#define CH_F10 0xB0
/* Video modes */
#define VIDEOMODE_40x24 0x0011
#define VIDEOMODE_80x24 0x0012
#define VIDEOMODE_40COL VIDEOMODE_40x24
#define VIDEOMODE_80COL VIDEOMODE_80x24
/*****************************************************************************/
/* Variables */
/*****************************************************************************/
@@ -106,21 +63,5 @@ extern void a2e_lo_tgi[];
/*****************************************************************************/
/* Code */
/*****************************************************************************/
unsigned __fastcall__ videomode (unsigned mode);
/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
** constants.
*/
void waitvsync (void);
/* Wait for start of next frame */
/* End of apple2enh.h */
#endif

View File

@@ -40,6 +40,20 @@
/*****************************************************************************/
#if (__CPU__ & __CPU_ISET_65SC02__)
/* Always inline, three bytes is not more than a jsr */
#define ntohs(x) \
( \
__AX__=(x), \
asm("phx"), \
asm("tax"), \
asm("pla"), \
__AX__ \
)
#define htons(x) ntohs(x)
#else
#if (__OPT_i__ < 200)
int __fastcall__ ntohs (int val);
@@ -56,12 +70,12 @@ int __fastcall__ htons (int val);
)
#define htons(x) ntohs(x)
#endif
#endif /* __OPT_i__ < 200 */
#endif /* __CPU__ & __CPU_ISET_65SC02__ */
long __fastcall__ ntohl (long val);
long __fastcall__ htonl (long val);
/* End of arpa/inet.h */
#endif

Some files were not shown because too many files have changed in this diff Show More