Merge branch 'master' into coniopeek

This commit is contained in:
mrdudz
2025-05-24 17:52:58 +02:00
604 changed files with 32401 additions and 8345 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
guidelines = 80, 120
[*.{c,h}]
cpp_new_line_before_open_brace_block=same_line
cpp_new_line_before_open_brace_function=new_line
cpp_space_before_function_open_parenthesis=insert
cpp_new_line_before_else=false

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`

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

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

View File

@@ -19,7 +19,7 @@ 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
@@ -35,7 +35,7 @@ jobs:
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.
run: make -C samples platforms
- name: Test that the targettest programs can be built.
@@ -44,7 +44,7 @@ jobs:
shell: bash
run: make -j2 doc
- name: Upload a documents snapshot.
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs
path: ./html
@@ -54,7 +54,7 @@ jobs:
make -j2 bin 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 +62,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 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,7 +44,7 @@ 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
@@ -59,7 +59,7 @@ jobs:
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
@@ -86,18 +86,18 @@ jobs:
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 +120,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
@@ -135,6 +135,15 @@ jobs:
port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
- name: Upload 64-bit Windows snapshot to sourceforge
uses: nogsantos/scp-deploy@master
with:
src: cc65-snapshot-win64.zip
host: ${{ secrets.SSH_HOST }}
remote: ${{ secrets.SSH_DIR }}
port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
- name: Upload documents snapshot to sourceforge
uses: nogsantos/scp-deploy@master
with:

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'
@@ -70,7 +70,7 @@ jobs:
- 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
- name: Test that the samples can be built (make samples)
if: steps.check-sha.outputs.cache-hit != 'true'

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 ; return value is char
</pre>
or, if the value is 0, you can use:
<pre>
ldx #0 ; Promote char return value
; 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).
~~~
* Functions, that are intended for a platform's system
library, should be optimized as much as possible.
* Sometimes, there must be a trade-off between size and
speed. If you think that a library function won't be used
often, then you should make it small. Otherwise, you should
make it fast.
* Comments that are put on the right side of instructions
must be aligned (start in the same character columns).
* Assembly source fields (label, operation, operand,
comment) should start ''after'' character columns that are
multiples of eight (such as 1, 9, 17, 33, and 41).
## LinuxDoc Sources
## LinuxDoc sources
* TAB characters must be expanded to spaces.
* All text files must end with new-line characters. Don't leave the last line "dangling".
* All text files must end with new-line characters. Don't
leave the last line "dangling".
* 80 characters is the desired maximum width of files.
* You should avoid typing non-ASCII characters.
* You should put blank lines between LinuxDoc sections:
* Three blank lines between ```<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,62 @@
# 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 |
A generic configuration to adapt cc65 to new targets is also around.
## People
Core team members:
cc65 is originally based on the "Small C" compiler by Ron Cain and
enhanced by James E. Hendrix.
### Project founders
* 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
@@ -15,7 +64,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
@@ -24,29 +73,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 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)
* [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)

View File

@@ -25,6 +25,12 @@ BRKVec := $03F0 ; Break vector
SOFTEV := $03F2 ; Vector for warm start
PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
;-----------------------------------------------------------------------------
; 80 column firmware
OURCH := $057B ; Cursor horizontal position
OURCV := $05FB ; Cursor vertical position
;-----------------------------------------------------------------------------
; Hardware

View File

@@ -15,7 +15,7 @@ CPU_ISET_4510 = $0400
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_6502DTV = CPU_ISET_6502|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

View File

@@ -31,10 +31,8 @@
; bgt - jump if unsigned greater
.macro bgt Arg
.local L
beq L
beq *+4
bcs Arg
L:
.endmacro
; ble - jump if unsigned less or equal

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

98
asminc/rp6502.inc Normal file
View File

@@ -0,0 +1,98 @@
; Picocomputer 6502 general defines
; RIA UART
RIA_READY := $FFE0 ; TX=$80 RX=$40
RIA_TX := $FFE1
RIA_RX := $FFE2
; VSYNC from PIX VGA
RIA_VSYNC := $FFE3
; RIA XRAM portal 0
RIA_RW0 := $FFE4
RIA_STEP0 := $FFE5
RIA_ADDR0 := $FFE6
; RIA XRAM portal 1
RIA_RW1 := $FFE8
RIA_STEP1 := $FFE9
RIA_ADDR1 := $FFEA
; RIA OS fastcall
RIA_XSTACK := $FFEC
RIA_ERRNO := $FFED
RIA_OP := $FFEF
RIA_IRQ := $FFF0
RIA_SPIN := $FFF1
RIA_BUSY := $FFF2 ; Bit $80
RIA_A := $FFF4
RIA_X := $FFF6
RIA_SREG := $FFF8
; RIA OS operation numbers
RIA_OP_EXIT := $FF
RIA_OP_ZXSTACK := $00
RIA_OP_XREG := $01
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
RIA_OP_CLOCK_GETTIMEZONE := $13
RIA_OP_OPEN := $14
RIA_OP_CLOSE := $15
RIA_OP_READ_XSTACK := $16
RIA_OP_READ_XRAM := $17
RIA_OP_WRITE_XSTACK := $18
RIA_OP_WRITE_XRAM := $19
RIA_OP_LSEEK := $1A
RIA_OP_UNLINK := $1B
RIA_OP_RENAME := $1C
; 6522 VIA
VIA := $FFD0 ; VIA base address
VIA_PB := VIA+$0 ; Port register B
VIA_PA1 := VIA+$1 ; Port register A
VIA_PRB := VIA+$0 ; *** Deprecated ***
VIA_PRA := VIA+$1 ; *** Deprecated ***
VIA_DDRB := VIA+$2 ; Data direction register B
VIA_DDRA := VIA+$3 ; Data direction register A
VIA_T1CL := VIA+$4 ; Timer 1, low byte
VIA_T1CH := VIA+$5 ; Timer 1, high byte
VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte
VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte
VIA_T2CL := VIA+$8 ; Timer 2, low byte
VIA_T2CH := VIA+$9 ; Timer 2, high byte
VIA_SR := VIA+$A ; Shift register
VIA_CR := VIA+$B ; Auxiliary control register
VIA_PCR := VIA+$C ; Peripheral control register
VIA_IFR := VIA+$D ; Interrupt flag register
VIA_IER := VIA+$E ; Interrupt enable register
VIA_PA2 := VIA+$F ; Port register A w/o handshake
; Values in ___oserror are the union of these FatFs errors and errno.inc
.enum
FR_OK = 32 ; Succeeded
FR_DISK_ERR ; A hard error occurred in the low level disk I/O layer
FR_INT_ERR ; Assertion failed
FR_NOT_READY ; The physical drive cannot work
FR_NO_FILE ; Could not find the file
FR_NO_PATH ; Could not find the path
FR_INVALID_NAME ; The path name format is invalid
FR_DENIED ; Access denied due to prohibited access or directory full
FR_EXIST ; Access denied due to prohibited access
FR_INVALID_OBJECT ; The file/directory object is invalid
FR_WRITE_PROTECTED ; The physical drive is write protected
FR_INVALID_DRIVE ; The logical drive number is invalid
FR_NOT_ENABLED ; The volume has no work area
FR_NO_FILESYSTEM ; There is no valid FAT volume
FR_MKFS_ABORTED ; The f_mkfs() aborted due to any problem
FR_TIMEOUT ; Could not get a grant to access the volume within defined period
FR_LOCKED ; The operation is rejected according to the file sharing policy
FR_NOT_ENOUGH_CORE ; LFN working buffer could not be allocated
FR_TOO_MANY_OPEN_FILES ; Number of open files > FF_FS_LOCK
FR_INVALID_PARAMETER ; Given parameter is invalid
.endenum

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

@@ -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;
@@ -27,10 +28,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro start = $4000;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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__;
@@ -43,10 +44,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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;
@@ -22,10 +23,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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;
@@ -26,10 +27,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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;
@@ -27,10 +28,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro start = $4000;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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__;
@@ -43,10 +44,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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;
@@ -22,10 +23,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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;
@@ -26,10 +27,11 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
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 = rw, 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 = rw, 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 = rw, 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 = rw, 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 = rw, 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 = rw, 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 = rw, 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

@@ -23,7 +23,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
ONCE: load = MAIN, type = ro, define = yes;
BASTAIL: load = MAIN, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;

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

View File

@@ -44,7 +44,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: 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;
OVL1ADDR: load = OVL1ADDR, type = ro;

View File

@@ -23,7 +23,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: 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;
}

View File

@@ -11,10 +11,10 @@ SEGMENTS {
ZP: load = ZP, type = zp, optional = yes;
VECTORS: load = ROM, run = RAM, type = rw, define = yes;
DATA: load = ROM, run = RAM, type = rw, define = yes, start = $0204;
INIT: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ONCE: load = ROM, type = ro, optional = yes;
CODE: load = ROM, type = ro;
INIT: load = ROM, type = ro;
RODATA: load = ROM, type = ro;
AUDIO: load = ROM, type = ro, optional = yes, start = $BF00;
SETUP: load = ROM, type = ro, start = $BFE8;

View File

@@ -57,7 +57,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw, optional = yes;
INIT: load = MAIN, type = rw, optional = yes; # uninitialized, but reserves output space
ONCE: load = MAIN, type = ro, define = yes;
BSS: load = BSS, type = bss, define = yes;
BRAM01ADDR: load = BRAM01ADDR, type = ro, optional = yes;

View File

@@ -24,7 +24,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw, optional = yes;
INIT: load = MAIN, type = rw, optional = yes; # uninitialized, but reserves output space
ONCE: load = MAIN, type = ro, define = yes;
BSS: load = BSS, type = bss, define = yes;
}

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

34
cfg/rp6502.cfg Normal file
View File

@@ -0,0 +1,34 @@
SYMBOLS {
__STARTUP__: type = import;
__STACKSIZE__: type = weak, value = $0800;
}
MEMORY {
ZP: file = "", define = yes, start = $0000, size = $0100;
CPUSTACK: file = "", start = $0100, size = $0100;
RAM: file = %O, define = yes, start = $0200, size = $FD00 - __STACKSIZE__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
ONCE: load = RAM, type = ro, optional = yes;
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw, define = yes;
BSS: load = RAM, 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

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

View File

@@ -22,7 +22,7 @@ SEGMENTS {
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
INIT: load = MAIN, type = rw; # uninitialized, but reserves output space
ONCE: load = MAIN, type = ro, define = yes;
BASTAIL: load = MAIN, type = ro, optional = yes;
BSS: load = BSS, type = bss, define = yes;

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

@@ -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
@@ -92,7 +92,28 @@ several useful settings:
</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,21 +342,42 @@ 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
</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
@@ -427,17 +469,47 @@ The names in the parentheses denote the symbols to be used for static linking of
<descrip>
<tag><tt/a2.ssc.ser (a2_ssc_ser)/</tag>
Driver for the Apple&nbsp;II Super Serial Card. Supports up to 19200 baud,
requires hardware flow control (RTS/CTS) and does interrupt driven receives.
Driver for the Apple&nbsp;II Super Serial Card.
The SSC is an extension card for the II, II+, IIe; the Apple //c and //c+ have
the same hardware and firmware integrated.
It supports up to 9600 baud, supports no flow control and hardware flow control
(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
<tt/SER_ERR_NO_DEVICE/ if there's no SSC firmware found in the selected slot.
In the Apple //c and //c+, slot 1 is the printer port, and slot 2 is the modem
port.
Never call <tt/ser_apple2_slot()/ after <tt/ser_open()/.
<tag><tt/a2.gs.ser (a2_gs_ser)/</tag>
Driver for the Apple&nbsp;IIgs serial ports (printer and modem).
It supports up to 9600 baud, supports no flow control and hardware flow control
(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 transmits are not interrupt driven, and the transceiver blocks if
the receiver asserts flow control because of a full buffer.
The driver defaults to opening the modem port. Calling <tt/ser_apple2_slot()/
prior to <tt/ser_open()/ allows to select the printer port (1) or the modem
port (0).
Never call <tt/ser_apple2_slot()/ after <tt/ser_open()/.
</descrip><p>
@@ -544,6 +616,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>
@@ -603,7 +697,17 @@ url="ca65.html" name="assembler manual">.
The header file <tt/apple2_filetype.h/ also defines many values
that can be used to set these variables. It is included in
<tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
<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>

View File

@@ -21,7 +21,8 @@ as it comes with the cc65 C compiler. It describes the memory layout,
enhanced&nbsp;Apple&nbsp;//e specific header files, available drivers, and any
pitfalls specific to that platform.
Please note that enhanced&nbsp;Apple&nbsp;//e specific functions are just mentioned
Please note that this target requires a 65C02 or 65816 CPU,
enhanced&nbsp;Apple&nbsp;//e specific functions are just mentioned
here, they are described in detail in the separate <url url="funcref.html"
name="function reference">. Even functions marked as "platform dependent" may
be available on more than one platform. Please see the function reference for
@@ -62,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
@@ -289,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
@@ -321,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
@@ -338,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
@@ -427,17 +448,47 @@ The names in the parentheses denote the symbols to be used for static linking of
<descrip>
<tag><tt/a2e.ssc.ser (a2e_ssc_ser)/</tag>
Driver for the Apple&nbsp;II Super Serial Card. Supports up to 19200 baud,
requires hardware flow control (RTS/CTS) and does interrupt driven receives.
Driver for the Apple&nbsp;II Super Serial Card.
The SSC is an extension card for the II, II+, IIe; the Apple //c and //c+ have
the same hardware and firmware integrated.
It supports up to 9600 baud, supports no flow control and hardware flow control
(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
<tt/SER_ERR_NO_DEVICE/ if there's no SSC firmware found in the selected slot.
In the Apple //c and //c+, slot 1 is the printer port, and slot 2 is the modem
port.
Never call <tt/ser_apple2_slot()/ after <tt/ser_open()/.
<tag><tt/a2e.gs.ser (a2e_gs_ser)/</tag>
Driver for the Apple&nbsp;IIgs serial ports (printer and modem).
It supports up to 9600 baud, supports no flow control and hardware flow control
(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 transmits are not interrupt driven, and the transceiver blocks if
the receiver asserts flow control because of a full buffer.
The driver defaults to opening the modem port. Calling <tt/ser_apple2_slot()/
prior to <tt/ser_open()/ allows to select the printer port (1) or the modem
port (0).
Never call <tt/ser_apple2_slot()/ after <tt/ser_open()/.
</descrip><p>
@@ -549,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>
@@ -593,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()/
@@ -610,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>

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

View File

@@ -120,7 +120,7 @@ Long options:
--list-bytes n Maximum number of bytes per listing line
--memory-model model Set the memory model
--pagelength n Set the page length for the listing
--relax-checks Relax some checks (see docs)
--relax-checks Disables some error checks
--smart Enable smart mode
--target sys Set the target system
--verbose Increase verbosity
@@ -265,14 +265,17 @@ Here is a description of all the command line options:
<label id="option--relax-checks">
<tag><tt>--relax-checks</tt></tag>
Relax some checks done by the assembler. This will allow code that is an
Disables some error checks done by the assembler. This will allow code that is an
error in most cases and flagged as such by the assembler, but can be valid
in special situations.
Examples are:
Disabled checks are:
<itemize>
<item>Short branches between two different segments.
<item>Byte sized address loads where the address is not a zeropage address.
<item>Address vs. fragment size: a byte sized load from an non-zeropage
address is truncated instead of producing an error.
<item>Indirect jump on page boundary: <tt>jmp (label)</tt> on a label that
resides on a page boundary (<tt>$xxFF</tt>) fetches the second byte from the
wrong address on 6502 CPUs, now allowed instead of producing an error.
</itemize>
@@ -826,49 +829,40 @@ names like "Loop". Here is an example:
bne @Loop ; ERROR: Unknown identifier!
</verb></tscreen>
<sect1>Unnamed labels<p>
If you really want to write messy code, there are also unnamed labels. These
labels do not have a name (you guessed that already, didn't you?). A colon is
used to mark the absence of the name.
If you really want to write messy code, there are also unnamed labels. To define
an unnamed label, use sole <tt>:</tt>.
Unnamed labels may be accessed by using the colon plus several minus or plus
characters as a label designator. Using the '-' characters will create a back
reference (use the n'th label backwards), using '+' will create a forward
reference (use the n'th label in forward direction). An example will help to
understand this:
To reference an unnamed label, use <tt>:</tt> with several <tt>-</tt> or <tt>+</tt> characters.
The <tt>-</tt> characters will create a back reference (n'th label backwards),
the <tt>+</tt> will create a forward reference (n'th label in forward direction).
As an alternative, angle brackets <tt>&lt;</tt> and <tt>&gt;</tt> may be used
instead of <tt>-</tt> and <tt>+</tt> with the same meaning.
Example:
<tscreen><verb>
: lda (ptr1),y ; #1
cmp (ptr2),y
bne :+ ; -> #2
tax
beq :+++ ; -> #4
iny
bne :- ; -> #1
inc ptr1+1
inc ptr2+1
bne :- ; -> #1
: bcs :+ ; #2 -> #3
ldx #$FF
rts
: ldx #$01 ; #3
: rts ; #4
cpy #0
beq :++
:
sta $2007
dey
bne :-
:
rts
</verb></tscreen>
As you can see from the example, unnamed labels will make even short
sections of code hard to understand, because you have to count labels
to find branch targets (this is the reason why I for my part do
prefer the "cheap" local labels). Nevertheless, unnamed labels are
convenient in some situations, so it's your decision.
Unnamed labels may make even short sections of code hard to understand, because
you have to count labels to find branch targets. It's better to prefer the
"cheap" local labels. Nevertheless, unnamed labels are convenient in some
situations, so it's up to your discretion.
<em/Note:/ <ref id="scopes" name="Scopes"> organize named symbols, not
unnamed ones, so scopes don't have an effect on unnamed labels.
<sect1>Using macros to define labels and constants<p>
While there are drawbacks with this approach, it may be handy in a few rare
@@ -1063,7 +1057,7 @@ The namespace token (<tt/::/) is used to access other scopes:
.endscope
...
lda foo::bar ; Access foo in scope bar
lda #foo::bar ; Access bar in scope foo
</verb></tscreen>
The only way to deny access to a scope from the outside is to declare a scope
@@ -1367,17 +1361,22 @@ writable.
Reading this pseudo variable will give the assembler version according to
the following formula:
VER_MAJOR*$100 + VER_MINOR*$10
<tt>(VER_MAJOR * 0x100) + VER_MINOR</tt>
It may be used to encode the assembler version or check the assembler for
special features not available with older versions.
The upper 8 bits are the major-, the lower 8 bits are the minor version.
Example:
Version 2.14 of the assembler will return $2E0 as numerical constant when
reading the pseudo variable <tt/.VERSION/.
For example, version 47.11 of the assembler would have this macro defined as
<tt/0x2f0b/.
Note: until 2.19 this pseudo variable was defined as <tt>(VER_MAJOR * 0x100) + VER_MINOR * 0x10</tt> -
which resulted in broken values starting at version 2.16 of the assembler. For
this reason the value of this pseudo variable is considered purely informal - you should
not use it to check for a specific assembler version and use different code
according to the detected version - please update your code to work with the
recent version of the assembler instead (There is very little reason to not use
the most recent version - and even less to support older versions in your code).
<sect>Pseudo functions<label id="pseudo-functions"><p>
@@ -2859,6 +2858,26 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
overridden. When using this feature, you may also get into trouble if
later versions of the assembler define new keywords starting with a dot.
<tag><tt>line_continuations</tt><label id="line_continuations"></tag>
Switch on or off line continuations using the backslash character
before a newline. The option is off by default.
Note: Line continuations do not work in a comment. A backslash at the
end of a comment is treated as part of the comment and does not trigger
line continuation.
Example:
<tscreen><verb>
.feature line_continuations + ; Allow line continuations
lda \
#$20 ; This is legal now
</verb></tscreen>
For backward compatibility reasons, the <tt>.LINECONT +</tt> control command
is also supported and enables the same feature.
<tag><tt>long_jsr_jmp_rts</tt><label id="long_jsr_jmp_rts"></tag>
Affects 65816 mode only.
@@ -3363,26 +3382,6 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
the feature in more detail.
<sect1><tt>.LINECONT</tt><label id=".LINECONT"><p>
Switch on or off line continuations using the backslash character
before a newline. The option is off by default.
Note: Line continuations do not work in a comment. A backslash at the
end of a comment is treated as part of the comment and does not trigger
line continuation.
The command can be followed by a '+' or '-' character to switch the
option on or off respectively.
Example:
<tscreen><verb>
.linecont + ; Allow line continuations
lda \
#$20 ; This is legal now
</verb></tscreen>
<sect1><tt>.LIST</tt><label id=".LIST"><p>
Enable output to the listing. The command can be followed by a boolean
@@ -3896,7 +3895,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
Reserve storage. The command is followed by one or two constant
expressions. The first one is mandatory and defines, how many bytes of
storage should be defined. The second, optional expression must by a
storage should be defined. The second, optional expression must be a
constant byte value that will be used as value of the data. If there
is no fill value given, the linker will use the value defined in the
linker configuration file (default: zero).
@@ -4078,7 +4077,9 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
<sect1><tt>.TAG</tt><label id=".TAG"><p>
Allocate space for a struct or union.
Allocate space for a struct or union. This is equivalent to
<tt><ref id=".RES" name=".RES"></tt> with the
<tt><ref id=".SIZEOF" name=".SIZEOF"></tt> of a struct.
Example:
@@ -4092,6 +4093,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
.tag Point ; Allocate 4 bytes
</verb></tscreen>
See: <ref id="structs" name="&quot;Structs and unions&quot;">
<sect1><tt>.UNDEF, .UNDEFINE</tt><label id=".UNDEFINE"><p>
@@ -4481,9 +4483,9 @@ different:
<item> Macros defined with <tt><ref id=".DEFINE" name=".DEFINE"></tt> may not
span more than a line. You may use line continuation (see <tt><ref
id=".LINECONT" name=".LINECONT"></tt>) to spread the definition over
more than one line for increased readability, but the macro itself
may not contain an end-of-line token.
id="line_continuations" name="line_continuations"></tt>) to spread the
definition over more than one line for increased readability, but the
macro itself may not contain an end-of-line token.
<item> Macros defined with <tt><ref id=".DEFINE" name=".DEFINE"></tt> share
the name space with classic macros, but they are detected and replaced
@@ -4857,10 +4859,15 @@ compiler, depending on the target system selected:
Structs and unions are special forms of <ref id="scopes" name="scopes">. They
are, to some degree, comparable to their C counterparts. Both have a list of
members. Each member allocates storage, and optionally may have a name whose
value, in the case of a struct, usually is the storage offset from the
beginning, and in the case of a union, doesn't change, and usually is zero.
members. Each member allocates storage, and optionally may have a name.
Each named member has a constant value equal to the storage offset from the
beginning of the structure. In the case of a union, all members are placed at
the same offset, typically 0.
Each named member also has a storage size which can be accessed with the
<tt><ref id=".SIZEOF" name=".SIZEOF"></tt> operator. The struct or union itself
also has a <tt/.SIZEOF/ indicating its total storage size.
<sect1>Declaration<p>
@@ -4887,8 +4894,9 @@ A struct or union may not necessarily have a name. If it is anonymous, no
local scope is opened; the identifiers used to name the members are placed
into the current scope instead.
A struct may contain unnamed members and definitions of local structs/unions.
The storage allocators may contain a multiplier, as in the example below:
Storage allocators may contain a multiplier. A struct may also contain members
and definitions of local structs/unions. Example:
<tscreen><verb>
.struct Circle
.struct Point
@@ -4897,7 +4905,8 @@ The storage allocators may contain a multiplier, as in the example below:
Radius .word
.endstruct
</verb></tscreen>
The size of the Circle struct is 6 (three words).
In this example the size of the Circle struct is 6 (three words).
<sect1>The storage allocator keywords<p>
@@ -4907,7 +4916,7 @@ The size of the Circle struct is 6 (three words).
<tag/.BYTE, .RES/
Allocates multiples of 1 byte. <tt/.RES/ requires an operand.
<tag/.DBYTE, .WORD, .ADDR/
<tag/.DBYT, .WORD, .ADDR/
Allocates multiples of 2 bytes.
<tag/.FARADDR/
@@ -4916,6 +4925,15 @@ The size of the Circle struct is 6 (three words).
<tag/.DWORD/
Allocates multiples of 4 bytes.
<tag/.TAG/
Allocates a previously defined struct.
<tag/.STRUCT, .UNION/
Begins a nested .struct or .union definition, and allocates it.
Note that its member offset values will begin at 0, unless this nested
structure is anonymous, in which case they will instead become members of
the enclosing scope.
</descrip>
@@ -4960,13 +4978,54 @@ name=".TAG"> directive.
C: .tag Circle
</verb></tscreen>
Currently, members are just offsets from the start of the struct or union. To
Members are just offsets from the start of the struct or union. To
access a field of a struct, the member offset must be added to the address of
the struct variable itself:
<tscreen><verb>
lda C+Circle::Radius ; Load circle radius into A
lda C + Circle::Radius ; Load circle radius
lda C + Circle::Origin + Point::ycoord ; Load circle origin.ycoord
</verb></tscreen>
That may change in a future version of the assembler.
Nested structures or unions are treated differently depending on whether they
are anonymous. If named, a new structure definition is created within the
enclosing scope, with its offsets beginning at 0. If anonymous, the members of
the new structure are added to the enclosing scope instead, with offsets
continuing through that scope. Example:
<tscreen><verb>
.struct Object
id .byte ; Object::id = 0
target .struct Point ; Object::target = 1
xcoord .word ; Object::Point::xcoord = 0
ycoord .word ; Object::Point::ycoord = 2
.endstruct
cost .struct ; Object::cost = 5
price .word ; Object::price = 5
tax .word ; Object::tax = 7
.endstruct
.struct
radius .word ; Object::radius = 9
.endstruct
.endstruct
O: .tag Object
lda O + Object::target + Object::Point::ycoord ; Named struct
lda O + Object::tax ; Anonymous
lda O + Object::radius ; Anonymous
; Be careful not to use a named nested structure without also adding the
; offset to the nested structure itself.
lda O + Object::Point::ycoord ; Incorrect!
lda O + Object::target + Object::Point::ycoord ; Correct
</verb></tscreen>
In this example, the first nested structure is named "Point", and its member
offsets begin at 0. On the other hand, the two anonymous structures simply
continue to add members to the enclosing "Object" structure.
Note that an anonymous structure does not need a member name, since all of its
members become part of the enclosing structure. The "cost" member in the
example is redundantly the same offset as its first member "price".
<sect1>Limitations<p>

View File

@@ -61,7 +61,7 @@ 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
-g Add debug info to object file
-h Help (this text)
@@ -84,8 +84,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
@@ -807,6 +808,9 @@ and the one defined by the ISO standard:
<itemize>
<item> The datatypes "float" and "double" are not available.
Floating point constants may be used, though they will have to be
converted and stored into integer values.
Floating point arithmetic expressions are not supported.
<p>
<item> C Functions may pass and return structs (or unions) by value, but only
of 1, 2 or 4 byte sizes.
@@ -820,6 +824,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
@@ -834,21 +843,21 @@ This cc65 version has some extensions to the ISO C standard.
<itemize>
<item> The compiler allows to insert assembler statements into the output
file. The syntax is
<item> The compiler allows to insert inline assembler code in the form of the
<tt/asm/ expression into the output file. The syntax is
<tscreen><verb>
asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
asm [optional volatile] (&lt;string literal&gt;[, optional parameters])
</verb></tscreen>
or
<tscreen><verb>
__asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
__asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters])
</verb></tscreen>
The first form is in the user namespace; and, is disabled if the <tt/-A/
switch is given.
There is a whole section covering inline assembler statements,
There is a whole section covering the inline assembler,
<ref id="inline-asm" name="see there">.
<p>
@@ -1005,6 +1014,13 @@ This cc65 version has some extensions to the ISO C standard.
<tt/_Static_assert/ is also available as the macro <tt/static_assert/ in
<tt/assert.h/.
Note: The string literal as the message in the <tt/_Static_assert/
declaration is not subject to string literal translation (see
<tt/<ref id="pragma-charmap" name="#pragma&nbsp;charmap()">/) and will
always be in the host encoding. On the other hand, any character or
string literals present in the condition expression of the
<tt/_Static_assert/ declaration will be translated as usual.
<item> cc65 supports bit-fields of any integral type that is int-sized or
smaller, and enumerated types with those types as their underlying
type. (Only <tt/int/, <tt/signed int/, and <tt/unsigned int/ are
@@ -1037,6 +1053,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>
@@ -1263,6 +1289,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>
@@ -1314,7 +1346,9 @@ parameter with the <tt/#pragma/.
<sect1><tt>#pragma charmap (&lt;index&gt;, &lt;code&gt;)</tt><label id="pragma-charmap"><p>
Each literal string and each literal character in the source is translated
Each literal string and each literal character in the preprocessed source,
except when used in an <tt/asm/ expression as the inline assembler code or
in a <tt/_Static_assert/ declaration as the failure message, is translated
by use of a translation table. That translation table is preset when the
compiler is started, depending on the target system; for example, to map
ISO-8859-1 characters into PETSCII if the target is a Commodore machine.
@@ -1346,7 +1380,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>
@@ -1601,13 +1635,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
@@ -1617,6 +1651,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.
@@ -1711,23 +1750,23 @@ bloated code and a slowdown.
<sect>Inline assembler<label id="inline-asm"><p>
The compiler allows to insert assembler statements into the output file. The
syntax is
The compiler allows to insert inline assembler code in the form of the <tt/asm/
expression into the output file. The syntax is
<tscreen><verb>
asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
asm [optional volatile] (&lt;string literal&gt;[, optional parameters])
</verb></tscreen>
or
<tscreen><verb>
__asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
__asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters])
</verb></tscreen>
<p>
The first form is in the user namespace; and, is disabled by <tt><ref
id="option--standard" name="--standard"></tt> if the argument is not <tt/cc65/.
The <tt/asm/ statement can be used only inside a function. Please note that
the result of an inline assembler expression is always of type <tt/void/.
The <tt/asm/ expression can be used only inside a function. The result of an
<tt/asm/ expression is always of type <tt/void/.
The contents of the string literal are preparsed by the compiler; and, inserted
into the generated assembly output, so that it can be processed further by
@@ -1738,15 +1777,15 @@ even if the ca65 assembler (which is used to translate the generated assembler
code) would accept them. The built-in inline assembler is not a replacement for
the full-blown macro assembler which comes with the compiler.
Note: Inline assembler statements are subject to all optimizations done by the
compiler. There currently is no way to protect an inline assembler statement
Note: Inline assembler expressions are subject to all optimizations done by the
compiler. There currently is no way to protect an inline assembler expression
-- alone -- from being moved or removed completely by the optimizer. If in
doubt, check the generated assembler output; or, disable optimizations (for
that function).
As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/
statements. It will disable optimization for the functions in which those
<tt/asm volatile/ statements sit. The effect is the same as though you put
expressions. It will disable optimization for the functions in which those
<tt/asm volatile/ expressions sit. The effect is the same as though you put
<tt/#pragma optimize(push, off)/ above those functions, and <tt/#pragma
optimize(pop)/ below those functions.
@@ -1754,6 +1793,13 @@ The string literal may contain format specifiers from the following list. For
each format specifier, an argument is expected which is inserted instead of
the format specifier, before passing the assembly code line to the backend.
Note: The string literal as the inline assembler code itself in the <tt/asm/
expression is not subject to string literal translation (see
<tt/<ref id="pragma-charmap" name="#pragma&nbsp;charmap()">/) and will always
be in the host encoding. On the other hand, all character and string literals
as the arguments for replacing the format specifiers will be translated as
usual.
<itemize>
<item><tt/%b/ - Numerical 8-bit value
<item><tt/%w/ - Numerical 16-bit value
@@ -1841,7 +1887,7 @@ Arrays also can be accessed:
<p>
Note: Do not embed the assembler labels that are used as names of global
variables or functions into your <tt/asm/ statements. Code such as this:
variables or functions into your <tt/asm/ expressions. Code such as this:
<tscreen><verb>
int foo;

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>

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>

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

@@ -184,7 +184,7 @@ Here is a description of all the command line options:
<label id="option--mnemonic-column">
<tag><tt>--mnemonic-column n</tt></tag>
Specifies the column where a mnemonic or pseudo instrcuction is output.
Specifies the column where a mnemonic or pseudo instruction is output.
<label id="option--pagelength">
@@ -255,7 +255,7 @@ 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.
emulated CPU instructions of the C64DTV device.
When disassembling 4510 code, due to handling of 16-bit wide branches, da65
@@ -283,7 +283,7 @@ Some instructions may generate labels in the first pass, while most other
instructions do not generate labels, but use them if they are available. Among
others, the branch and jump instructions will generate labels for the target
of the branch in the first pass. External labels (taken from the info file)
have precedence over internally generated ones, They must be valid identifiers
have precedence over internally generated ones. They must be valid identifiers
as specified for the ca65 assembler. Internal labels (generated by the
disassembler) have the form <tt/Labcd/, where <tt/abcd/ is the hexadecimal
address of the label in upper case letters. You should probably avoid using
@@ -304,7 +304,7 @@ name="next section"> for more information.
The info file contains lists of specifications grouped together. Each group
directive has an identifying token and an attribute list enclosed in curly
braces. Attributes have a name followed by a value. The syntax of the value
depends on the type of the attribute. String attributes are places in double
depends on the type of the attribute. String attributes are placed in double
quotes, numeric attributes may be specified as decimal numbers or hexadecimal
with a leading dollar sign. There are also attributes where the attribute
value is a keyword; in this case, the keyword is given as-is (without quotes or
@@ -317,8 +317,8 @@ anything). Each attribute is terminated by a semicolon.
<sect1>Comments<p>
Comments start with a hash mark (<tt/#/) or a double slash (<tt>//</tt>);
and, extend from the position of the mark to the end of the current line.
Comments start with a hash mark (<tt/#/) or a double slash (<tt>//</tt>)
and extend from the position of the mark to the end of the current line.
Hash marks or double slashes inside of strings will <em/not/ start a comment,
of course.
@@ -359,20 +359,20 @@ following attributes are recognized:
<tag><tt/HEXOFFS/</tag>
The attribute is followed by a boolean value. If true, offsets to labels are
This attribute is followed by a boolean value. If true, offsets to labels are
output in hex, otherwise they're output in decimal notation. The default is
false. The attribute may be changed on the command line using the <tt><ref
id="option--hexoffs" name="--hexoffs"></tt> option.
<tag><tt/INPUTNAME/</tag>
The attribute is followed by a string value, which gives the name of the
This attribute is followed by a string value, which gives the name of the
input file to read. If it is present, the disassembler does not accept an
input file name on the command line.
<tag><tt/INPUTOFFS/</tag>
The attribute is followed by a numerical value that gives an offset into
This attribute is followed by a numerical value that gives an offset into
the input file which is skipped before reading data. The attribute may be
used to skip headers or unwanted code sections in the input file.
@@ -412,7 +412,7 @@ following attributes are recognized:
<label id="OUTPUTNAME">
<tag><tt/OUTPUTNAME/</tag>
The attribute is followed by string value, which gives the name of the
This attribute is followed by string value, which gives the name of the
output file to write. If it is present, specification of an output file on
the command line using the <tt><ref id="option-o" name="-o"></tt> option is
not allowed.
@@ -433,8 +433,8 @@ following attributes are recognized:
This attribute may be used instead of the <tt><ref id="option--start-addr"
name="--start-addr"></tt> option on the command line. It takes a numerical
parameter. The default for the start address is $10000 minus the size of
the input file (this assumes that the input file is a ROM that contains the
reset and irq vectors).
the input file. (This assumes that the input file is a ROM that contains the
reset and irq vectors.)
<tag><tt/TEXTCOLUMN/</tag>
@@ -468,7 +468,7 @@ following attributes are recognized:
<tag><tt>NAME</tt></tag>
This is a convenience attribute. It takes a string argument and will cause
the disassembler to define a label for the start of the range with the
given name. So a separate <tt><ref id="infofile-label" name="LABEL"></tt>
given name so a separate <tt><ref id="infofile-label" name="LABEL"></tt>
directive is not needed.
<tag><tt>START</tt></tag>
@@ -509,8 +509,8 @@ following attributes are recognized:
<tag><tt>SKIP</tt></tag>
The range is simply ignored when generating the output file. Please note
that this means that reassembling the output file will <em/not/ generate
the original file, not only because the missing piece in between, but also
because the following code will be located on wrong addresses. Output
the original file, not only because of the missing piece in between, but
also because the following code will be located on wrong addresses. Output
generated with <tt/SKIP/ ranges will need manual rework.
<tag><tt>TEXTTABLE</tt></tag>
@@ -529,7 +529,7 @@ following attributes are recognized:
<tag><tt>ADDRMODE</tt></tag>
When disassembling 65816 code, this specifies the M and X flag states
for this range. It's a string argument of the form "mx", capital letters
for this range. It's a string argument of the form "mx". Capital letters
mean the flag is enabled.
</descrip>
@@ -561,9 +561,9 @@ code. The following attributes are recognized:
<tag><tt>NAME</tt></tag>
The attribute is followed by a string value which gives the name of the
label. Empty names are allowed, in this case the disassembler will create
an unnamed label (see the assembler docs for more information about unnamed
labels).
label. Empty names are allowed; in this case the disassembler will create
an unnamed label. (See the assembler docs for more information about unnamed
labels.)
<tag><tt>SIZE</tt></tag>
This attribute is optional and may be used to specify the size of the data
@@ -595,15 +595,18 @@ disassembled code. The following attributes are recognized:
<descrip>
<tag><tt>START</tt></tag>
Followed by a numerical value. Specifies the start address of the segment.
This attribute is followed by a numerical value which specifies the start
address of the segment.
<tag><tt>END</tt></tag>
Followed by a numerical value. Specifies the end address of the segment. The
end address is the last address that is a part of the segment.
This attribute is followed by a numerical value which specifies the end
address of the segment. The end address is the last address that is a part of
the segment.
<tag><tt>NAME</tt></tag>
The attribute is followed by a string value which gives the name of the
This attribute is followed by a string value which gives the name of the
segment.
</descrip>
All attributes are mandatory. Segments must not overlap. The disassembler will
@@ -635,10 +638,11 @@ The following attributes are recognized:
<descrip>
<tag><tt>FILE</tt></tag>
Followed by a string value. Specifies the name of the file to read.
This attribute is followed by a string value. It specifies the name of the
file to read.
<tag><tt>COMMENTSTART</tt></tag>
The optional attribute is followed by a character constant. It specifies the
This optional attribute is followed by a character constant. It specifies the
character that starts a comment. The default value is a semicolon. This
value is ignored if <tt/IGNOREUNKNOWN/ is true.

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,7 +95,13 @@ 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
</itemize>
@@ -101,7 +110,12 @@ 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">
</itemize>
@@ -128,7 +142,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 +159,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 +229,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>
@@ -334,9 +349,11 @@ 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_ostype" name="get_ostype">
<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"> -->
<item><ref id="videomode" name="videomode">
<!-- <item><ref id="vpeek" name="vpeek"> -->
<!-- <item><ref id="vpoke" name="vpoke"> -->
@@ -428,7 +445,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>
@@ -440,6 +457,16 @@ see also <tt>testcode/lib/em-test.c</tt> and <tt>samples/multidemo.c</tt>.
<url url="geos.html" name="GEOS API">.
<sect1><tt/inet.h/<label id="inet.h"><p>
<itemize>
<item><ref id="htonl" name="htonl">
<item><ref id="htons" name="htons">
<item><ref id="ntohl" name="ntohl">
<item><ref id="ntohs" name="ntohs">
</itemize>
<sect1><tt/joystick.h/<label id="joystick.h"><p>
<itemize>
@@ -452,6 +479,18 @@ see also <tt>testcode/lib/em-test.c</tt> and <tt>samples/multidemo.c</tt>.
</itemize>
<sect1><tt/kim1.h/<label id="kim1.h"><p>
<itemize>
<!-- <item><ref id="getkey" name="getkey"> -->
<!-- <item><ref id="scandisplay" name="scandisplay"> -->
<item><ref id="loadt" name="loadt">
<item><ref id="dumpt" name="dumpt">
</itemize>
(incomplete)
<sect1><tt/locale.h/<label id="locale.h"><p>
<itemize>
@@ -482,6 +521,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>
@@ -513,7 +560,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>
@@ -531,7 +578,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>
@@ -701,7 +748,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">
@@ -747,6 +794,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">
@@ -822,6 +870,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)
@@ -839,6 +901,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>
@@ -1726,16 +1795,17 @@ 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/
<ref id="fdisp" name="fdisp">,
<ref id="loadt" name="loadt">,
<ref id="dumpt" name="dumpt">,
<ref id="dumpt" name="dumpt">
<tag/Example/None.
</descrip>
</quote>
@@ -1880,7 +1950,7 @@ be used in presence of a prototype.
<ref id="_swap" name="_swap">,
<ref id="memcpy" name="memcpy">,
<ref id="memmove" name="memmove">,
<ref id="memset" name="memset">,
<ref id="memset" name="memset">
<tag/Example/None.
</descrip>
</quote>
@@ -1953,7 +2023,7 @@ sent a command to TALK and a secondary address if it needs one.
</itemize>
<tag/Availability/cc65
<tag/See also/
<ref id="cbm_k_talk" name="cbm_k_talk">,
<ref id="cbm_k_talk" name="cbm_k_talk">
<tag/Example/None.
</descrip>
</quote>
@@ -2355,8 +2425,8 @@ function, in order to provide input from the keyboard.
<tag/See also/
<ref id="cbm_k_getin" name="cbm_k_getin">,
<ref id="cbm_k_udtim" name="cbm_k_udtim">,
<ref id="cgetc" name="cgetc">,
<!-- <ref id="getc" name="getc"> -->
<ref id="cgetc" name="cgetc">
<!-- <ref id="getc" name="getc">, -->
<!-- <ref id="getchar" name="getchar"> -->
<tag/Example/None.
</descrip>
@@ -2383,7 +2453,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>
@@ -2827,6 +2897,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>
@@ -3253,6 +3396,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.
@@ -3274,7 +3481,7 @@ used in presence of a prototype.
<tag/Availability/cc65 (not all platforms)
<tag/See also/
<ref id="get_c128_speed" name="get_c128_speed">,
<ref id="set_c128_speed" name="set_c128_speed">,
<ref id="set_c128_speed" name="set_c128_speed">
<tag/Example/None.
</descrip>
</quote>
@@ -3314,7 +3521,7 @@ used in presence of a prototype.
<tag/Availability/cc65 (not all platforms)
<tag/See also/
<ref id="get_c65_speed" name="get_c65_speed">,
<ref id="set_c65_speed" name="set_c65_speed">,
<ref id="set_c65_speed" name="set_c65_speed">
<tag/Example/None.
</descrip>
</quote>
@@ -3340,6 +3547,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>
@@ -3380,6 +3607,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>
@@ -3440,11 +3686,11 @@ int main(void)
<quote>
<descrip>
<tag/Function/Dump memory to tape.
<tag/Header/<tt/<ref id="sym1.h" name="sym1.h">/
<tag/Header/<tt/<ref id="sym1.h" name="sym1.h">/, <tt/<ref id="kim1.h" name="kim1.h">/
<tag/Declaration/<tt/int __fastcall__ dumpt (unsigned char id, const void* start, const void* end);/
<tag/Description/<tt/dumpt/ saves memory onto data tape.
<tag/Notes/<itemize>
<item>The function is specific to the Sym-1.
<item>The function is specific to the Sym-1 and KIM-1.
<item>The return value is status. Non-zero status indicates an error.
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
@@ -3453,7 +3699,7 @@ be used in presence of a prototype.
<tag/See also/
<ref id="beep" name="beep">,
<ref id="fdisp" name="fdisp">,
<ref id="loadt" name="loadt">,
<ref id="loadt" name="loadt">
<tag/Example/None.
</descrip>
</quote>
@@ -3833,7 +4079,7 @@ switching the CPU into double clock mode.
<tag/See also/
<ref id="beep" name="beep">,
<ref id="loadt" name="loadt">,
<ref id="dumpt" name="dumpt">,
<ref id="dumpt" name="dumpt">
<tag/Example/None.
</descrip>
</quote>
@@ -3943,13 +4189,39 @@ 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>
<descrip>
<tag/Function/The function returns the operating system, the program runs on.
<tag/Header/<tt/<ref id="apple2.h" name="apple2.h">,
<ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">/
<ref id="atari.h" name="atari.h">, <ref id="c64.h" name="c64.h">,
<ref id="cx16.h" name="cx16.h">/
<tag/Declaration/<tt/unsigned char get_ostype (void);/
<tag/Description/<tt/get_ostype/ is machine dependent and does not exist for
all supported targets. If it exists, it returns a number that identifies the
@@ -4053,6 +4325,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>
@@ -4388,6 +4681,45 @@ to undefined behaviour.
</descrip>
</quote>
<sect1>htonl<label id="htonl"><p>
<quote>
<descrip>
<tag/Function/Swaps byte order in a 32 bit word.
<tag/Header/<tt/<ref id="inet.h" name="arpa/inet.h">/
<tag/Declaration/<tt/int htonl(val)/
<tag/Description/Converts a 32 bit word from from network byte order
(big endian) to little endian (or vice-versa).
<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/See also/
<ref id="ntohl" name="ntohl">
<tag/Availability/cc65
</descrip>
</quote>
<sect1>htons<label id="htons"><p>
<quote>
<descrip>
<tag/Function/Swaps byte order in a 16 bit word.
<tag/Header/<tt/<ref id="inet.h" name="arpa/inet.h">/
<tag/Declaration/<tt/int htons(val)/
<tag/Description/Converts a 16 bit word from from network byte order
(big endian) to little endian (or vice-versa) by swapping both its bytes.
<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/See also/
<ref id="ntohs" name="ntohs">
<tag/Availability/cc65
</descrip>
</quote>
<sect1>isalnum<label id="isalnum"><p>
@@ -5084,11 +5416,11 @@ used in presence of a prototype.
<quote>
<descrip>
<tag/Function/Load memory from tape.
<tag/Header/<tt/<ref id="sym1.h" name="sym1.h">/
<tag/Header/<tt/<ref id="sym1.h" name="sym1.h">/, <tt/<ref id="kim1.h" name="kim1.h">/
<tag/Declaration/<tt/int __fastcall__ loadt (unsigned char id);/
<tag/Description/<tt/loadt/ loads memory from data tape.
<tag/Notes/<itemize>
<item>The function is specific to the Sym-1.
<item>The function is specific to the Sym-1 and KIM-1.
<item>The return value is status. Non-zero status indicates an error.
<item>The function is only available as fastcall function, so it may only
be used in presence of a prototype.
@@ -5097,7 +5429,7 @@ be used in presence of a prototype.
<tag/See also/
<ref id="beep" name="beep">,
<ref id="fdisp" name="fdisp">,
<ref id="dumpt" name="dumpt">,
<ref id="dumpt" name="dumpt">
<tag/Example/None.
</descrip>
</quote>
@@ -5757,6 +6089,44 @@ memory allocated for the driver.
</descrip>
</quote>
<sect1>ntohl<label id="ntohl"><p>
<quote>
<descrip>
<tag/Function/Swaps byte order in a 32 bit word.
<tag/Header/<tt/<ref id="inet.h" name="arpa/inet.h">/
<tag/Declaration/<tt/int __fastcall__ ntohl (int val);/
<tag/Description/Converts a 32 bit word from from host byte order (little endian)
to big endian (or vice-versa).
<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/See also/
<ref id="htonl" name="htonl">
<tag/Availability/cc65
</descrip>
</quote>
<sect1>ntohs<label id="ntohs"><p>
<quote>
<descrip>
<tag/Function/Swaps byte order in a 16 bit word.
<tag/Header/<tt/<ref id="inet.h" name="arpa/inet.h">/
<tag/Declaration/<tt/int __fastcall__ ntohs (int val);/
<tag/Description/Converts a 16 bit word from from host byte order (little endian)
to big endian (or vice-versa) by swapping both its bytes.
<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/See also/
<ref id="htons" name="htons">
<tag/Availability/cc65
</descrip>
</quote>
<sect1>offsetof<label id="offsetof"><p>
<quote>
@@ -5959,6 +6329,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>
@@ -6127,6 +6523,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
@@ -6606,7 +7005,8 @@ be used in presence of a prototype.
<tag/Function/Uninstall the currently loaded driver but do not unload it.
<tag/Header/<tt/<ref id="serial.h" name="serial.h">/
<tag/Declaration/<tt/unsigned char ser_uninstall (void);/
<tag/Description/Uninstall the currently loaded driver but do not unload it.
<tag/Description/Uninstall the currently loaded driver but do not unload it. This
function returns SER_ERR_NO_DRIVER if no driver was installed, 0 otherwise.
<tag/Availability/cc65
<tag/See also/Other serial functions.
<tag/Example/None.
@@ -6790,6 +7190,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>
@@ -6972,6 +7396,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>
@@ -7552,22 +8055,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.
@@ -7984,6 +8512,8 @@ only in the presence of a prototype.
<descrip>
<tag/Function/Wait until the start of the next video frame.
<tag/Header/<tt/
<ref id="apple2enh.h" name="apple2enh.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">,
@@ -7991,6 +8521,7 @@ only in the presence of a prototype.
<tag/Declaration/<tt/void waitvsync (void);/
<tag/Description/Wait for vertical sync, to reduce flickering.
<tag/Availability/Platforms served by the headers above
(Atmos requires the VSync hack)
<tag/Example/None.
</descrip>
</quote>

View File

@@ -270,7 +270,7 @@ required for the correct process of GEOS sequential application building.
<p>Large GEOS applications typically don't fit in one piece in their designated
memory area. They are therefore split into overlays which are loaded into memory
on demand. The individual overlays are stored as records of a VLIR (Variable
Length Index Record) file. When GEOS starts a VLIR overlay appliation it loads
Length Index Record) file. When GEOS starts a VLIR overlay application it loads
record number 0 which is supposed to contain the main program. The record numbers
starting with 1 are to be used for the actual overlays.

View File

@@ -175,6 +175,9 @@
<tag><htmlurl url="plus4.html" name="plus4.html"></tag>
Topics specific to the Commodore Plus/4.
<tag><htmlurl url="rp6502.html" name="rp6502.html"></tag>
Topics specific to the Picocomputer 6502.
<tag><htmlurl url="supervision.html" name="supervision.html"></tag>
Topics specific to the Watara Supervision Console.

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>

96
doc/rp6502.sgml Normal file
View File

@@ -0,0 +1,96 @@
<!doctype linuxdoc system>
<article>
<title>Picocomputer 6502 - specific information for cc65
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
<abstract>
An overview over the Picocomputer 6502 and its interfaces to the cc65 C
compiler.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
The Picocomputer 6502 is a modern W65C02S computer with a custom operating
system designed to be POSIX-like. The reference design includes a W65C02S,
W65C22S, RP6502-RIA, and optionally a RP6502-VGA. Peripheral devices like
keyboards, mice, and flash storage are connected by USB to the RP6502-RIA.
Audio is generated by the RP6502-RIA. Video is generated by the RP6502-VGA.
<sect>Binary format<p>
The standard binary output format generated by the linker for the RP6502 target
is a plain machine language program without any prefix or postfix.
The RP6502 Integrated Development Environment, based on Visual Studio Code,
will convert the cc65 binary output into RP6502 ROM files that can be loaded
directly from the RP6502 monitor or installed on the RIA to be loaded at boot.
<sect>Memory layout<p>
<descrip>
<tag/Stack/
The C run-time stack is located at &dollar;FEFF, and grows downward.
<tag/Heap/
The C heap is located at the end of the program, and grows toward the C
run-time stack.
<tag/RAM/
RAM is located at &dollar;0000 - &dollar;FEFF. Default binaries load and
start at &dollar;0200.
<tag/ROM/
The RP6502 is designed with no ROM in the 6502 address space.
<tag/VIA/
A Versatile Interface Adapter (6522) is 16 registers located
at &dollar;FFD0.
<tag/RIA/
The RP6502 Interface Adapter is 32 registers located at &dollar;FFE0.
<tag/User/
User I/O expansion is from &dollar;FF00 to &dollar;FFCF.
</descrip><p>
<sect>Platform-specific header files<p>
Programs containing RP6502-specific code may use the <tt/rp6502.h/ or
<tt/rp6502.inc/ include files.
<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

@@ -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>
@@ -49,7 +51,7 @@ which is limited to an 8-bit result 0-255.
An error in sim65, like bad arguments or an internal problem will exit with <tt/1/.
A timeout from <tt/-x/ will exist with <tt/2/.
A timeout from <tt/-x/ will exit with <tt/2/.
<sect1>Command line options in detail<p>
@@ -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>
@@ -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

@@ -104,7 +104,7 @@ placeholder has two advantages:
<item> The code is better documented. It is clearly visible that the given
value is about to be changed.
<item> When examining an (initial) disassembly (e.g. in a debugger), these
placegolders can be better identified: They are fixed and, you may
placeholders can be better identified: They are fixed and, you may
notice that below, quite eye catching defined.
</enum>

View File

@@ -477,10 +477,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.

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

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

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>
@@ -121,6 +122,11 @@
#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
extern unsigned char _dos_type;
/* Valid _dos_type values:
**
@@ -142,6 +148,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 +178,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__)
@@ -172,6 +189,7 @@ extern void a2_auxmem_emd[];
extern void a2_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void a2_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
extern void a2_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
extern void a2_gs_ser[]; /* IIgs serial driver */
extern void a2_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void a2_lo_tgi[];
#endif
@@ -184,6 +202,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. */
@@ -210,6 +234,27 @@ 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
/* End of apple2.h */

View File

@@ -82,8 +82,8 @@
#define CH_F10 0xB0
/* Video modes */
#define VIDEOMODE_40x24 0x0011
#define VIDEOMODE_80x24 0x0012
#define VIDEOMODE_40x24 0x15
#define VIDEOMODE_80x24 0x00
#define VIDEOMODE_40COL VIDEOMODE_40x24
#define VIDEOMODE_80COL VIDEOMODE_80x24
@@ -100,6 +100,7 @@ extern void a2e_auxmem_emd[];
extern void a2e_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void a2e_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
extern void a2e_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
extern void a2e_gs_ser[]; /* IIgs serial driver */
extern void a2e_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void a2e_lo_tgi[];

View File

@@ -1,12 +1,12 @@
/*****************************************************************************/
/* */
/* closedir.c */
/* arpa/inet.h */
/* */
/* Close a directory */
/* Endianness utilities for cc65 */
/* */
/* */
/* */
/* (C) 2005 Oliver Schmidt, <ol.sc@web.de> */
/* (C) 2023 Colin Leroy-Mira, <colin@colino.net> */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -30,10 +30,8 @@
#include <stdlib.h>
#include <fcntl.h>
#include <dirent.h>
#include "dir.h"
#ifndef _ARPA_INET_H
#define _ARPA_INET_H
@@ -43,15 +41,27 @@
int __fastcall__ closedir (DIR* dir)
{
int result;
#if (__OPT_i__ < 200)
int __fastcall__ ntohs (int val);
int __fastcall__ htons (int val);
#else
/* Cleanup directory file */
result = close (dir->fd);
#define ntohs(x) \
( \
__AX__=(x), \
asm("sta tmp1"), \
asm("txa"), \
asm("ldx tmp1"), \
__AX__ \
)
#define htons(x) ntohs(x)
/* Cleanup DIR */
free (dir);
#endif
return result;
}
long __fastcall__ ntohl (long val);
long __fastcall__ htonl (long val);
/* End of arpa/inet.h */
#endif

View File

@@ -220,17 +220,17 @@
/* Color register functions */
/*****************************************************************************/
extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminance);
extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
extern unsigned char __fastcall__ _getcolor (unsigned char color_reg);
void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminance);
void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
unsigned char __fastcall__ _getcolor (unsigned char color_reg);
/*****************************************************************************/
/* Other screen functions */
/*****************************************************************************/
extern void waitvsync (void); /* wait for start of next frame */
extern int __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
extern void __fastcall__ _scroll (signed char numlines);
void waitvsync (void); /* wait for start of next frame */
int __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
void __fastcall__ _scroll (signed char numlines);
/* numlines > 0 scrolls up */
/* numlines < 0 scrolls down */
@@ -239,18 +239,18 @@ extern void __fastcall__ _scroll (signed char numlines);
/* Sound function */
/*****************************************************************************/
extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
/*****************************************************************************/
/* Misc. functions */
/*****************************************************************************/
extern unsigned char get_ostype(void); /* get ROM version */
extern unsigned char get_tv(void); /* get TV system */
extern void _save_vecs(void); /* save system vectors */
extern void _rest_vecs(void); /* restore system vectors */
extern char *_getdefdev(void); /* get default floppy device */
extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */
unsigned char get_ostype(void); /* get ROM version */
unsigned char get_tv(void); /* get TV system */
void _save_vecs(void); /* save system vectors */
void _rest_vecs(void); /* restore system vectors */
char *_getdefdev(void); /* get default floppy device */
unsigned char _is_cmdline_dos(void); /* does DOS support command lines */
/*****************************************************************************/

View File

@@ -94,7 +94,7 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
#define _bordercolor(color) 0
/* wait for start of next frame */
extern void waitvsync (void);
void waitvsync (void);
/* end of atari5200.h */
#endif

View File

@@ -52,7 +52,7 @@
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
extern unsigned char get_tv(void); /* get TV system */
unsigned char get_tv(void); /* get TV system */
#include <_tia.h>
#define TIA (*(struct __tia*)0x0000)

View File

@@ -169,6 +169,9 @@ void atmos_tock (void);
void atmos_zap (void);
/* Raygun sound effect */
void waitvsync (void);
/* Wait for start of next frame */
/* End of atmos.h */

View File

@@ -97,7 +97,7 @@
#define COLOR_WHITE (BCOLOR_WHITE | CATTR_LUMA7)
#define COLOR_RED (BCOLOR_RED | CATTR_LUMA4)
#define COLOR_CYAN (BCOLOR_CYAN | CATTR_LUMA7)
#define COLOR_PURPLE (BCOLOR_VIOLET | CATTR_LUMA7)
#define COLOR_PURPLE (BCOLOR_LIGHTVIOLET | CATTR_LUMA7)
#define COLOR_GREEN (BCOLOR_GREEN | CATTR_LUMA7)
#define COLOR_BLUE (BCOLOR_BLUE | CATTR_LUMA7)
#define COLOR_YELLOW (BCOLOR_YELLOW | CATTR_LUMA7)

View File

@@ -3,7 +3,7 @@
/* cx16.h */
/* */
/* CX16 system-specific definitions */
/* For prerelease 39 */
/* For prerelease 43 */
/* */
/* */
/* This software is provided "as-is", without any expressed or implied */
@@ -176,6 +176,11 @@ enum {
#define VIDEOMODE_40x15 0x04
#define VIDEOMODE_20x30 0x05
#define VIDEOMODE_20x15 0x06
#define VIDEOMODE_22x23 0x07
#define VIDEOMODE_64x50 0x08
#define VIDEOMODE_64x25 0x09
#define VIDEOMODE_32x50 0x0A
#define VIDEOMODE_32x25 0x0B
#define VIDEOMODE_80COL VIDEOMODE_80x60
#define VIDEOMODE_40COL VIDEOMODE_40x30
#define VIDEOMODE_320x240 0x80
@@ -256,6 +261,42 @@ struct __vera {
unsigned char vstart; /* Vertical start position */
unsigned char vstop; /* Vertical stop position */
};
struct { /* Visible when DCSEL flag = 2 */
unsigned char fxctrl;
unsigned char fxtilebase;
unsigned char fxmapbase;
unsigned char fxmult;
};
struct { /* Visible when DCSEL flag = 3 */
unsigned char fxxincrl;
unsigned char fxxincrh;
unsigned char fxyincrl;
unsigned char fxyincrh;
};
struct { /* Visible when DCSEL flag = 4 */
unsigned char fxxposl;
unsigned char fxxposh;
unsigned char fxyposl;
unsigned char fxyposh;
};
struct { /* Visible when DCSEL flag = 5 */
unsigned char fxxposs;
unsigned char fxyposs;
unsigned char fxpolyfilll;
unsigned char fxpolyfillh;
};
struct { /* Visible when DCSEL flag = 6 */
unsigned char fxcachel;
unsigned char fxcachem;
unsigned char fxcacheh;
unsigned char fxcacheu;
};
struct { /* Visible when DCSEL flag = 63 */
unsigned char dcver0;
unsigned char dcver1;
unsigned char dcver2;
unsigned char dcver3;
};
} display;
struct {
unsigned char config; /* Layer map geometry */

View File

@@ -33,6 +33,8 @@
#ifndef _DIRENT_H
#define _DIRENT_H
#include <target.h>
/*****************************************************************************/
@@ -46,31 +48,15 @@ typedef struct DIR DIR;
#if defined(__APPLE2__)
struct dirent {
char d_name[16];
unsigned d_ino;
unsigned d_blocks;
unsigned long d_size;
unsigned char d_type;
struct {
unsigned day :5;
unsigned mon :4;
unsigned year :7;
} d_cdate;
struct {
unsigned char min;
unsigned char hour;
} d_ctime;
unsigned char d_access;
unsigned d_auxtype;
struct {
unsigned day :5;
unsigned mon :4;
unsigned year :7;
} d_mdate;
struct {
unsigned char min;
unsigned char hour;
} d_mtime;
char d_name[16];
unsigned d_ino;
unsigned d_blocks;
unsigned long d_size;
unsigned char d_type;
struct datetime d_ctime;
unsigned char d_access;
unsigned d_auxtype;
struct datetime d_mtime;
};
#define _DE_ISREG(t) ((t) != 0x0F)
@@ -161,7 +147,5 @@ void __fastcall__ seekdir (DIR* dir, long offs);
void __fastcall__ rewinddir (DIR* dir);
/* End of dirent.h */
#endif

View File

@@ -31,27 +31,15 @@
/* */
/*****************************************************************************/
#ifndef _LYNX_H
#define _LYNX_H
/* Check for errors */
#if !defined(__LYNX__)
# error This module may only be used when compiling for the Lynx game console!
#endif
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Color defines */
/* Color definitions */
#define COLOR_TRANSPARENT 0x00
#define COLOR_BLACK 0x01
#define COLOR_RED 0x02
@@ -88,6 +76,56 @@
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
#define TGI_COLOR_WHITE COLOR_WHITE
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
/* Addresses of static drivers */
extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */
extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
/* Sound support */
void lynx_snd_init (void); /* Initialize the sound driver */
void lynx_snd_pause (void); /* Pause sound */
void lynx_snd_continue (void); /* Continue sound after pause */
void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music); /* Play tune on channel */
void lynx_snd_stop (void); /* Stop sound on all channels */
void __fastcall__ lynx_snd_stop_channel (unsigned char channel); /* Stop sound on all channels */
unsigned char lynx_snd_active(void); /* Show which channels are active */
/* Cartridge access */
void __fastcall__ lynx_load (int file_number); /* Load a file into RAM using a zero-based index */
void __fastcall__ lynx_exec (int file_number); /* Load a file into ram and execute it */
/* EEPROM access */
unsigned __fastcall__ lynx_eeprom_read (unsigned char cell); /* Read a 16 bit word from the given address */
unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val); /* Write the word at the given address */
void __fastcall__ lynx_eeprom_erase (unsigned char cell); /* Clear the word at the given address */
unsigned __fastcall__ lynx_eeread (unsigned cell); /* Read a 16 bit word from the given address 93C46, 93C66 or 93C86 */
unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); /* Write the word at the given address 93C46, 93C66 or 93C86 */
/* TGI extras */
#define tgi_sprite(spr) tgi_ioctl(0, spr)
#define tgi_flip() tgi_ioctl(1, (void*)0)
#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
#define tgi_busy() tgi_ioctl(4, (void*)0)
#define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))
/* Hardware definitions */
#include <_mikey.h>
#define MIKEY (*(struct __mikey *)0xFD00)
#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) /* mikey_timers[8] */
#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) /* timer0 (HBL) */
#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) /* timer2 (VBL) */
#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) /* timer4 (UART) */
#define _VIDDMA (*(unsigned int *) 0xFD92) /* DISPCTL/VIDDMA */
#include <_suzy.h>
#define SUZY (*(volatile struct __suzy*)0xFC00)
/* Masks for joy_read */
#define JOY_UP_MASK 0x80
#define JOY_DOWN_MASK 0x40
@@ -102,118 +140,5 @@
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
/*****************************************************************************/
/* Variables */
/*****************************************************************************/
/* The addresses of the static drivers */
extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */
extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
/*****************************************************************************/
/* Sound support */
/*****************************************************************************/
void lynx_snd_init (void);
/* Initialize the sound driver */
void lynx_snd_pause (void);
/* Pause sound */
void lynx_snd_continue (void);
/* Continue sound after pause */
void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
/* Play tune on channel */
void lynx_snd_stop (void);
/* Stop sound on all channels */
void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
/* Stop sound on all channels */
unsigned char lynx_snd_active(void);
/* Show which channels are active */
/*****************************************************************************/
/* Accessing the cart */
/*****************************************************************************/
void __fastcall__ lynx_load (int fileno);
/* Load a file into ram. The first entry is fileno=0. */
void __fastcall__ lynx_exec (int fileno);
/* Load a file into ram and execute it. */
/*****************************************************************************/
/* Accessing the EEPROM */
/*****************************************************************************/
unsigned __fastcall__ lynx_eeprom_read (unsigned char cell);
/* Read a 16 bit word from the given address */
unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
/* Write the word at the given address */
void __fastcall__ lynx_eeprom_erase (unsigned char cell);
/* Clear the word at the given address */
unsigned __fastcall__ lynx_eeread (unsigned cell);
/* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/
unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val);
/* Write the word at the given address 93C46 93C66 or 93C86*/
/*****************************************************************************/
/* TGI extras */
/*****************************************************************************/
#define tgi_sprite(spr) tgi_ioctl(0, spr)
#define tgi_flip() tgi_ioctl(1, (void*)0)
#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
#define tgi_busy() tgi_ioctl(4, (void*)0)
#define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))
/* Define Hardware */
#include <_mikey.h>
#define MIKEY (*(struct __mikey *)0xFD00)
#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8]
#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL)
#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL)
#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART)
#define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma
#include <_suzy.h>
#define SUZY (*(struct __suzy*)0xFC00)
/* End of lynx.h */
#endif

56
include/lzsa.h Normal file
View File

@@ -0,0 +1,56 @@
/*****************************************************************************/
/* */
/* lzsa.h */
/* */
/* Decompression routine for the 'lzsa' format */
/* */
/* */
/* */
/* (C) 2022 John Brandwood */
/* */
/* */
/* Boost license: */
/* Distributed under the Boost Software License, Version 1.0. */
/* Boost Software License - Version 1.0 - August 17th, 2003 */
/* */
/* Permission is hereby granted, free of charge, to any person or */
/* organization */
/* obtaining a copy of the software and accompanying documentation covered by*/
/* this license (the "Software") to use, reproduce, display, distribute, */
/* execute, and transmit the Software, and to prepare derivative works of the*/
/* Software, and to permit third-parties to whom the Software is furnished to*/
/* do so, all subject to the following: */
/* */
/* The copyright notices in the Software and this entire statement, including*/
/* the above license grant, this restriction and the following disclaimer, */
/* must be included in all copies of the Software, in whole or in part, and */
/* all derivative works of the Software, unless such copies or derivative */
/* works are solely in the form of machine-executable object code generated */
/* by a source language processor. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*/
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT */
/* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE */
/* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR */
/* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE */
/* USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*****************************************************************************/
#ifndef _LZSA_H
#define _LZSA_H
void __fastcall__ decompress_lzsa1 (const unsigned char* src, unsigned char* const dst);
/* Decompresses the source buffer into the destination buffer.
** compress with lzsa -r -f 1 input.bin output.lzsa1
*/
void __fastcall__ decompress_lzsa2 (const unsigned char* src, unsigned char* const dst);
/* Decompresses the source buffer into the destination buffer.
** compress with lzsa -r -f 2 input.bin output.lzsa2
*/
/* end of lzsa.h */
#endif

266
include/rp6502.h Normal file
View File

@@ -0,0 +1,266 @@
/*****************************************************************************/
/* */
/* rp6502.h */
/* */
/* Picocomputer 6502 */
/* */
/* */
/* 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 _RP6502_H
#define _RP6502_H
/* RP6502 VIA $FFD0-$FFDF */
#include <_6522.h>
#define VIA (*(volatile struct __6522 *)0xFFD0)
/* RP6502 RIA $FFE0-$FFF9 */
struct __RP6502
{
const unsigned char ready;
unsigned char tx;
const unsigned char rx;
const unsigned char vsync;
unsigned char rw0;
unsigned char step0;
unsigned int addr0;
unsigned char rw1;
unsigned char step1;
unsigned int addr1;
unsigned char xstack;
unsigned int errno;
unsigned char op;
unsigned char irq;
const unsigned char spin;
const unsigned char busy;
const unsigned char lda;
unsigned char a;
const unsigned char ldx;
unsigned char x;
const unsigned char rts;
unsigned int sreg;
};
#define RIA (*(volatile struct __RP6502 *)0xFFE0)
#define RIA_READY_TX_BIT 0x80
#define RIA_READY_RX_BIT 0x40
#define RIA_BUSY_BIT 0x80
/* XSTACK helpers */
void __fastcall__ ria_push_long (unsigned long val);
void __fastcall__ ria_push_int (unsigned int val);
#define ria_push_char(v) RIA.xstack = v
long ria_pop_long (void);
int ria_pop_int (void);
#define ria_pop_char() RIA.xstack
/* Set the RIA fastcall register */
void __fastcall__ ria_set_axsreg (unsigned long axsreg);
void __fastcall__ ria_set_ax (unsigned int ax);
#define ria_set_a(v) RIA.a = v
/* Run an OS operation */
int __fastcall__ ria_call_int (unsigned char op);
long __fastcall__ ria_call_long (unsigned char op);
/* These run _mappederrno() on error */
int __fastcall__ ria_call_int_errno (unsigned char op);
long __fastcall__ ria_call_long_errno (unsigned char op);
/* OS operation numbers */
#define RIA_OP_EXIT 0xFF
#define RIA_OP_ZXSTACK 0x00
#define RIA_OP_XREG 0x01
#define RIA_OP_PHI2 0x02
#define RIA_OP_CODEPAGE 0x03
#define RIA_OP_LRAND 0x04
#define RIA_OP_STDIN_OPT 0x05
#define RIA_OP_CLOCK 0x0F
#define RIA_OP_CLOCK_GETRES 0x10
#define RIA_OP_CLOCK_GETTIME 0x11
#define RIA_OP_CLOCK_SETTIME 0x12
#define RIA_OP_CLOCK_GETTIMEZONE 0x13
#define RIA_OP_OPEN 0x14
#define RIA_OP_CLOSE 0x15
#define RIA_OP_READ_XSTACK 0x16
#define RIA_OP_READ_XRAM 0x17
#define RIA_OP_WRITE_XSTACK 0x18
#define RIA_OP_WRITE_XRAM 0x19
#define RIA_OP_LSEEK 0x1A
#define RIA_OP_UNLINK 0x1B
#define RIA_OP_RENAME 0x1C
/* C API for the operating system. */
int __cdecl__ xregn (char device, char channel, unsigned char address, unsigned count,
...);
int __cdecl__ xreg (char device, char channel, unsigned char address, ...);
int phi2 (void);
int codepage (void);
long lrand (void);
int __fastcall__ stdin_opt (unsigned long ctrl_bits, unsigned char str_length);
int __fastcall__ read_xstack (void* buf, unsigned count, int fildes);
int __fastcall__ read_xram (unsigned buf, unsigned count, int fildes);
int __fastcall__ write_xstack (const void* buf, unsigned count, int fildes);
int __fastcall__ write_xram (unsigned buf, unsigned count, int fildes);
/* XREG location helpers */
#define xreg_ria_keyboard(...) xreg(0, 0, 0, __VA_ARGS__)
#define xreg_ria_mouse(...) xreg(0, 0, 1, __VA_ARGS__)
#define xreg_vga_canvas(...) xreg(1, 0, 0, __VA_ARGS__)
#define xreg_vga_mode(...) xreg(1, 0, 1, __VA_ARGS__)
/* XRAM structure helpers */
#define xram0_struct_set(addr, type, member, val) \
RIA.addr0 = (unsigned)(&((type *)0)->member) + (unsigned)addr; \
switch (sizeof(((type *)0)->member)) \
{ \
case 1: \
RIA.rw0 = val; \
break; \
case 2: \
RIA.step0 = 1; \
RIA.rw0 = val & 0xff; \
RIA.rw0 = (val >> 8) & 0xff; \
break; \
case 4: \
RIA.step0 = 1; \
RIA.rw0 = (unsigned long)val & 0xff; \
RIA.rw0 = ((unsigned long)val >> 8) & 0xff; \
RIA.rw0 = ((unsigned long)val >> 16) & 0xff; \
RIA.rw0 = ((unsigned long)val >> 24) & 0xff; \
break; \
}
#define xram1_struct_set(addr, type, member, val) \
RIA.addr1 = (unsigned)(&((type *)0)->member) + (unsigned)addr; \
switch (sizeof(((type *)0)->member)) \
{ \
case 1: \
RIA.rw1 = val; \
break; \
case 2: \
RIA.step1 = 1; \
RIA.rw1 = val & 0xff; \
RIA.rw1 = (val >> 8) & 0xff; \
break; \
case 4: \
RIA.step1 = 1; \
RIA.rw1 = (unsigned long)val & 0xff; \
RIA.rw1 = ((unsigned long)val >> 8) & 0xff; \
RIA.rw1 = ((unsigned long)val >> 16) & 0xff; \
RIA.rw1 = ((unsigned long)val >> 24) & 0xff; \
break; \
}
typedef struct
{
unsigned char x_wrap; // bool
unsigned char y_wrap; // bool
int x_pos_px;
int y_pos_px;
int width_chars;
int height_chars;
unsigned xram_data_ptr;
unsigned xram_palette_ptr;
unsigned xram_font_ptr;
} vga_mode1_config_t;
typedef struct
{
unsigned char x_wrap; // bool
unsigned char y_wrap; // bool
int x_pos_px;
int y_pos_px;
int width_tiles;
int height_tiles;
unsigned xram_data_ptr;
unsigned xram_palette_ptr;
unsigned xram_tile_ptr;
} vga_mode2_config_t;
typedef struct
{
unsigned char x_wrap; // bool
unsigned char y_wrap; // bool
int x_pos_px;
int y_pos_px;
int width_px;
int height_px;
unsigned xram_data_ptr;
unsigned xram_palette_ptr;
} vga_mode3_config_t;
typedef struct
{
int x_pos_px;
int y_pos_px;
unsigned xram_sprite_ptr;
unsigned char log_size;
unsigned char has_opacity_metadata; // bool
} vga_mode4_sprite_t;
typedef struct
{
int transform[6];
int x_pos_px;
int y_pos_px;
unsigned xram_sprite_ptr;
unsigned char log_size;
unsigned char has_opacity_metadata; // bool
} vga_mode4_asprite_t;
/* Values in __oserror are the union of these FatFs errors and errno.h */
typedef enum
{
FR_OK = 32, /* Succeeded */
FR_DISK_ERR, /* A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* Assertion failed */
FR_NOT_READY, /* The physical drive cannot work */
FR_NO_FILE, /* Could not find the file */
FR_NO_PATH, /* Could not find the path */
FR_INVALID_NAME, /* The path name format is invalid */
FR_DENIED, /* Access denied due to prohibited access or directory full */
FR_EXIST, /* Access denied due to prohibited access */
FR_INVALID_OBJECT, /* The file/directory object is invalid */
FR_WRITE_PROTECTED, /* The physical drive is write protected */
FR_INVALID_DRIVE, /* The logical drive number is invalid */
FR_NOT_ENABLED, /* The volume has no work area */
FR_NO_FILESYSTEM, /* There is no valid FAT volume */
FR_MKFS_ABORTED, /* The f_mkfs() aborted due to any problem */
FR_TIMEOUT, /* Could not get a grant to access the volume within defined period */
FR_LOCKED, /* The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* Number of open files > FF_FS_LOCK */
FR_INVALID_PARAMETER /* Given parameter is invalid */
} FRESULT;
#endif /* _RP6502_H */

136
include/sim65.h Normal file
View File

@@ -0,0 +1,136 @@
/*****************************************************************************/
/* */
/* sim65.h */
/* */
/* Definitions for the sim6502 and sim65c02 targets */
/* */
/* */
/* */
/* (C) 2025 Sidney Cadot */
/* */
/* */
/* 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 _SIM65_H
#define _SIM65_H
/* Check that we include this file while compiling to a compatible target. */
#if !defined(__SIM6502__) && !defined(__SIM65C02__)
# error This module may only be used when compiling for the sim6502 or sim65c02 targets!
#endif
#include <stdint.h>
/* The sim65 targets (sim6502, sim65c02) have a peripheral memory aperture located at
* address range 0xFFC0 .. 0xFFDF. Currently, the following peripherals are located
* inside that memory apeture:
*
* $FFC0 .. $FFC9 "counter" peripheral
* $FFCA .. $FFCB "sim65 control" peripheral
* $FFCC .. $FFDF (currently unused)
*
* The "peripherals" structure below corresponds to the register layout of the currently
* defined peripherals in this memory range. Combined with the fact that the sim6502 and
* sim65c02 linker configuration files define the "peripherals" symbol to be fixed at
* address $FFC0, this provides easy-to-use and efficient access to the peripheral registers.
*
* After including "sim65.h", it is possible for a C program to do things like:
*
* {
* peripherals.counter.latch = 0;
* peripherals.sim65.cpu_mode = SIM65_CPU_MODE_6502X;
* peripherals.sim65.trace_mode = SIM65_TRACE_MODE_ENABLE_FULL;
* }
*
* Note that "peripherals" variable is declared volatile. This instructs a C compiler to
* forego optimizations on memory accesses to the variable. However, CC65 currently ignores
* the volatile attribute. Fortunately, it is not smart with respect to optimizing
* memory accesses, so accessing the "peripherals" fields works fine in practice.
*/
extern volatile struct {
struct {
uint8_t latch;
uint8_t select;
union {
uint8_t value [8]; /* Access value as eight separate bytes. */
uint16_t value16 [4]; /* Access value as four 16-bit words. */
uint32_t value32 [2]; /* Access value as two 32-bit long words. */
};
} counter;
struct {
uint8_t cpu_mode;
uint8_t trace_mode;
} sim65;
} peripherals;
/* Values for the peripherals.counter.select field. */
#define COUNTER_SELECT_CLOCKCYCLE_COUNTER 0x00
#define COUNTER_SELECT_INSTRUCTION_COUNTER 0x01
#define COUNTER_SELECT_IRQ_COUNTER 0x02
#define COUNTER_SELECT_NMI_COUNTER 0x03
#define COUNTER_SELECT_WALLCLOCK_TIME 0x80
#define COUNTER_SELECT_WALLCLOCK_TIME_SPLIT 0x81
/* Values for the peripherals.sim65.cpu_mode field. */
#define SIM65_CPU_MODE_6502 0x00
#define SIM65_CPU_MODE_65C02 0x01
#define SIM65_CPU_MODE_6502X 0x02
/* Bitfield values for the peripherals.sim65.trace_mode field. */
#define SIM65_TRACE_MODE_FIELD_INSTR_COUNTER 0x40
#define SIM65_TRACE_MODE_FIELD_CLOCK_COUNTER 0x20
#define SIM65_TRACE_MODE_FIELD_PC 0x10
#define SIM65_TRACE_MODE_FIELD_INSTR_BYTES 0x08
#define SIM65_TRACE_MODE_FIELD_INSTR_ASSEMBLY 0x04
#define SIM65_TRACE_MODE_FIELD_CPU_REGISTERS 0x02
#define SIM65_TRACE_MODE_FIELD_CC65_SP 0x01
/* Values for the peripherals.sim65.trace_mode field that fully disable / enable tracing. */
#define SIM65_TRACE_MODE_DISABLE 0x00
#define SIM65_TRACE_MODE_ENABLE_FULL 0x7F
/* Convenience macros to enable / disable tracing at runtime. */
#define TRACE_ON() do peripherals.sim65.trace_mode = SIM65_TRACE_MODE_ENABLE_FULL; while(0)
#define TRACE_OFF() do peripherals.sim65.trace_mode = SIM65_TRACE_MODE_DISABLE; while(0)
/* Convenience macro to query the CPU mode at runtime. */
#define GET_CPU_MODE() peripherals.sim65.cpu_mode
/* Convenience macro to set the CPU mode at runtime.
*
* Use SIM65_CPU_MODE_6502, SIM65_CPU_MODE_65C02, or SIM65_CPU_MODE_6502 as argument.
*
* Important Note:
*
* When running in a program compiled for the "sim6502" target, it is safe to switch to
* 65C02 or 6502X mode, since the runtime library will only use plain 6502 opcodes, and
* those work the same in 65C02 and 6502X mode.
*
* However, when running in a program compiled for the "sim65c02" target, it is NOT safe
* to switch to 6502 or 6502X mode, since many routines in the runtime library use
* 65C02-specific opcodes, and these will not work as expected when the CPU is switched
* to 6502 or 6502X mode. When such an instruction is encountered, the program will
* exhibit undefined behavior.
*/
#define SET_CPU_MODE(mode) do peripherals.sim65.cpu_mode = mode; while(0)
/* End of sim65.h */
#endif

View File

@@ -52,15 +52,15 @@ typedef unsigned char uint8_t;
typedef unsigned uint16_t;
typedef unsigned long uint32_t;
#define INT8_MIN ((int8_t) 0x80)
#define INT8_MAX ((int8_t) 0x7F)
#define INT16_MIN ((int16_t) 0x8000)
#define INT16_MAX ((int16_t) 0x7FFF)
#define INT32_MIN ((int32_t) 0x80000000)
#define INT32_MAX ((int32_t) 0x7FFFFFFF)
#define UINT8_MAX ((uint8_t) 0xFF)
#define UINT16_MAX ((uint16_t) 0xFFFF)
#define UINT32_MAX ((uint32_t) 0xFFFFFFFF)
#define INT8_MIN -128
#define INT8_MAX 127
#define INT16_MIN (-32767 - 1)
#define INT16_MAX 32767
#define INT32_MIN (-2147483647L - 1L)
#define INT32_MAX 2147483647L
#define UINT8_MAX 255
#define UINT16_MAX 65535U
#define UINT32_MAX 4294967295UL
/* Minimum-width integer types */
typedef signed char int_least8_t;
@@ -70,15 +70,15 @@ typedef unsigned char uint_least8_t;
typedef unsigned uint_least16_t;
typedef unsigned long uint_least32_t;
#define INT_LEAST8_MIN ((int_least8_t) 0x80)
#define INT_LEAST8_MAX ((int_least8_t) 0x7F)
#define INT_LEAST16_MIN ((int_least16_t) 0x8000)
#define INT_LEAST16_MAX ((int_least16_t) 0x7FFF)
#define INT_LEAST32_MIN ((int_least32_t) 0x80000000)
#define INT_LEAST32_MAX ((int_least32_t) 0x7FFFFFFF)
#define UINT_LEAST8_MAX ((uint_least8_t) 0xFF)
#define UINT_LEAST16_MAX ((uint_least16_t) 0xFFFF)
#define UINT_LEAST32_MAX ((uint_least32_t) 0xFFFFFFFF)
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST32_MAX INT32_MAX
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
/* Fastest minimum-width integer types */
typedef signed char int_fast8_t;
@@ -88,40 +88,40 @@ typedef unsigned char uint_fast8_t;
typedef unsigned uint_fast16_t;
typedef unsigned long uint_fast32_t;
#define INT_FAST8_MIN ((int_fast8_t) 0x80)
#define INT_FAST8_MAX ((int_fast8_t) 0x7F)
#define INT_FAST16_MIN ((int_fast16_t) 0x8000)
#define INT_FAST16_MAX ((int_fast16_t) 0x7FFF)
#define INT_FAST32_MIN ((int_fast32_t) 0x80000000)
#define INT_FAST32_MAX ((int_fast32_t) 0x7FFFFFFF)
#define UINT_FAST8_MAX ((uint_fast8_t) 0xFF)
#define UINT_FAST16_MAX ((uint_fast16_t) 0xFFFF)
#define UINT_FAST32_MAX ((uint_fast32_t) 0xFFFFFFFF)
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST32_MAX INT32_MAX
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
/* Integer types capable of holding object pointers */
typedef int intptr_t;
typedef unsigned uintptr_t;
#define INTPTR_MIN ((intptr_t)0x8000)
#define INTPTR_MAX ((intptr_t)0x7FFF)
#define UINTPTR_MAX ((uintptr_t) 0xFFFF)
#define INTPTR_MIN INT16_MIN
#define INTPTR_MAX INT16_MAX
#define UINTPTR_MAX UINT16_MAX
/* Greatest width integer types */
typedef long intmax_t;
typedef unsigned long uintmax_t;
#define INTMAX_MIN ((intmax_t) 0x80000000)
#define INTMAX_MAX ((intmax_t) 0x7FFFFFFF)
#define UINTMAX_MAX ((uintmax_t) 0xFFFFFFFF)
#define INTMAX_MIN INT32_MIN
#define INTMAX_MAX INT32_MAX
#define UINTMAX_MAX UINT32_MAX
/* Limits of other integer types */
#define PTRDIFF_MIN ((int) 0x8000)
#define PTRDIFF_MAX ((int) 0x7FFF)
#define PTRDIFF_MIN INT16_MIN
#define PTRDIFF_MAX INT16_MAX
#define SIG_ATOMIC_MIN ((unsigned char) 0x00)
#define SIG_ATOMIC_MAX ((unsigned char) 0xFF)
#define SIG_ATOMIC_MIN 0
#define SIG_ATOMIC_MAX UINT8_MAX
#define SIZE_MAX 0xFFFF
#define SIZE_MAX UINT16_MAX
/* Macros for minimum width integer constants */
#define INT8_C(c) c

View File

@@ -86,6 +86,10 @@ extern FILE* stderr;
# define FILENAME_MAX (80+1)
#elif defined(__TELESTRAT__)
# define FILENAME_MAX (50+1)
#elif defined(__SIM6502__)
# define FILENAME_MAX (1024+1)
#elif defined(__SIM65C02__)
# define FILENAME_MAX (1024+1)
#else
# define FILENAME_MAX (16+1)
#endif

View File

@@ -81,6 +81,7 @@ void __fastcall__ bzero (void* ptr, size_t n); /* BSD */
char* __fastcall__ strdup (const char* s); /* SYSV/BSD */
int __fastcall__ stricmp (const char* s1, const char* s2); /* DOS/Windows */
int __fastcall__ strcasecmp (const char* s1, const char* s2); /* Same for Unix */
char* __fastcall__ strcasestr (const char* str, const char* substr);
int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count); /* DOS/Windows */
int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count); /* Same for Unix */
size_t __fastcall__ strnlen (const char* s, size_t maxlen); /* POSIX.1-2008 */
@@ -89,6 +90,7 @@ char* __fastcall__ strlower (char* s);
char* __fastcall__ strupr (char* s);
char* __fastcall__ strupper (char* s);
char* __fastcall__ strqtok (char* s1, const char* s2);
char* __fastcall__ stpcpy (char* dest, const char* src);
#endif
const char* __fastcall__ __stroserror (unsigned char errcode);

View File

@@ -2,7 +2,7 @@
/* */
/* stat.h */
/* */
/* Constants for the mode argument of open and creat */
/* stat(2) definition */
/* */
/* */
/* */
@@ -11,6 +11,9 @@
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* (C) 2023 Colin Leroy-Mira */
/* EMail: 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 */
@@ -36,6 +39,10 @@
#ifndef _STAT_H
#define _STAT_H
#include <time.h>
#include <target.h>
#include <sys/types.h>
/*****************************************************************************/
@@ -47,6 +54,30 @@
#define S_IREAD 0x01
#define S_IWRITE 0x02
#define S_IFMT 0x03
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
off_t st_size;
struct timespec st_atim;
struct timespec st_ctim;
struct timespec st_mtim;
#ifdef __APPLE2__
unsigned char st_access;
unsigned char st_type;
unsigned int st_auxtype;
unsigned char st_storagetype;
unsigned int st_blocks;
struct datetime st_mtime;
struct datetime st_ctime;
#endif
};
/*****************************************************************************/
@@ -55,5 +86,9 @@
int __fastcall__ stat (const char* pathname, struct stat* statbuf);
/* End of stat.h */
#endif

View File

@@ -1,12 +1,13 @@
/*****************************************************************************/
/* */
/* dir.h */
/* statvfs.h */
/* */
/* Apple ][ system specific DIR */
/* statvfs(3) definition */
/* */
/* */
/* */
/* (C) 2005 Oliver Schmidt, <ol.sc@web.de> */
/* (C) 2023 Colin Leroy-Mira */
/* EMail: colin@colino.net */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -30,8 +31,10 @@
#ifndef _DIR_H
#define _DIR_H
#ifndef _STATVFS_H
#define _STATVFS_H
#include <sys/types.h>
@@ -41,22 +44,31 @@
struct DIR {
int fd;
unsigned char entry_length;
unsigned char entries_per_block;
unsigned char current_entry;
union {
unsigned char bytes[512];
struct {
unsigned prev_block;
unsigned next_block;
unsigned char entries[1];
} content;
} block;
struct statvfs {
unsigned long f_bsize;
unsigned long f_frsize;
fsblkcnt_t f_blocks;
fsblkcnt_t f_bfree;
fsblkcnt_t f_bavail;
fsfilcnt_t f_files;
fsfilcnt_t f_ffree;
fsfilcnt_t f_favail;
unsigned long f_fsid;
unsigned long f_flag;
unsigned long f_namemax;
};
/* End of dir.h */
/*****************************************************************************/
/* Code */
/*****************************************************************************/
int __fastcall__ statvfs (const char* pathname, struct statvfs* buf);
/* End of statvfs.h */
#endif

View File

@@ -50,6 +50,46 @@
typedef long int off_t;
#endif
#ifndef _HAVE_dev_t
#define _HAVE_dev_t
typedef unsigned long int dev_t;
#endif
#ifndef _HAVE_ino_t
#define _HAVE_ino_t
typedef unsigned long int ino_t;
#endif
#ifndef _HAVE_nlink_t
#define _HAVE_nlink_t
typedef unsigned long int nlink_t;
#endif
#ifndef _HAVE_uid_t
#define _HAVE_uid_t
typedef unsigned char uid_t;
#endif
#ifndef _HAVE_gid_t
#define _HAVE_gid_t
typedef unsigned char gid_t;
#endif
#ifndef _HAVE_mode_t
#define _HAVE_mode_t
typedef unsigned char mode_t;
#endif
#ifndef _HAVE_fsblkcnt_t
#define _HAVE_fsblkcnt_t
typedef unsigned long int fsblkcnt_t;
#endif
#ifndef _HAVE_fsfilcnt_t
#define _HAVE_fsfilcnt_t
typedef unsigned long int fsfilcnt_t;
#endif
/*****************************************************************************/
@@ -60,6 +100,3 @@ typedef long int off_t;
/* End of types.h */
#endif

View File

@@ -37,6 +37,11 @@
#define _TIME_H
/* Forward declaration for target.h */
typedef unsigned long time_t;
typedef unsigned long clock_t;
/* NULL pointer */
#ifndef NULL
@@ -49,9 +54,6 @@
typedef unsigned size_t;
#endif
typedef unsigned long time_t;
typedef unsigned long clock_t;
/* Structure for broken down time */
struct tm {
int tm_sec;
@@ -84,6 +86,8 @@ struct tm {
# define CLOCKS_PER_SEC 135 /* FIXME */
#elif defined(__GEOS__)
# define CLOCKS_PER_SEC 1
#elif defined (__RP6502__)
# define CLOCKS_PER_SEC 100
#elif defined(__TELESTRAT__)
# define CLOCKS_PER_SEC 10
#elif defined(__ATARI__) || defined (__LYNX__)

44
include/zx02.h Normal file
View File

@@ -0,0 +1,44 @@
/*****************************************************************************/
/* */
/* zx02.h */
/* */
/* Decompression routine for the 'zx02' format */
/* */
/* */
/* */
/* (C) 2022 DMSC */
/* */
/* */
/* MIT license: */
/* Permission is hereby granted, free of charge, to any person obtaining a */
/* copy of this software and associated documentation files (the “Software”),*/
/* to deal in the Software without restriction, including without limitation */
/* the rights to use, copy, modify, merge, publish, distribute, sublicense, */
/* and/or sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included */
/* in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN */
/* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, */
/* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR */
/* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE */
/* USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*****************************************************************************/
#ifndef _ZX02_H
#define _ZX02_H
void __fastcall__ decompress_zx02 (const unsigned char* src, unsigned char* const dst);
/* Decompresses the source buffer into the destination buffer.
** compress with zx02 input.bin output.zx02
*/
/* end of zx02.h */
#endif

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