diff --git a/.gitignore b/.gitignore
index 3e65003e4..1d5928af7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
/bin/
/emd/
/html/
+/info/
/joy/
/lib/
/libwrk/
diff --git a/README.md b/README.md
index 33101548b..39e4ef54c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
[documentation](http://cc65.github.io/cc65/doc)
+[wiki](https://github.com/cc65/wiki/wiki)
+
[](https://travis-ci.org/cc65/cc65/builds)
cc65 is a complete cross development package for 65(C)02 systems, including
diff --git a/asminc/cbm510.inc b/asminc/cbm510.inc
index abc363728..e1a86c487 100644
--- a/asminc/cbm510.inc
+++ b/asminc/cbm510.inc
@@ -4,7 +4,7 @@
; Taken from a kernal disassembly done by myself in 2000/2001.
;
; 2001-09-13, Ullrich von Bassewitz
-; 2013-08-26, Greg King
+; 2014-04-02, Greg King
;-----------------------------------------------------------------------------
@@ -14,6 +14,8 @@ ExecReg := $00 ; Controls execution memory bank
IndReg := $01 ; Controls indirect indexed load-store bank
TXTPTR := $85 ; Far pointer into BASIC source code
+FNAM := $90 ; Far pointer to LOAD/SAVE file-name
+FNAM_LEN := $9D ; Holds length of file-name
; ---------------------------------------------------------------------------
; Screen size
diff --git a/asminc/cbm610.inc b/asminc/cbm610.inc
index f442f5da8..b1b03eb1d 100644
--- a/asminc/cbm610.inc
+++ b/asminc/cbm610.inc
@@ -4,7 +4,7 @@
; Taken from a kernal disassembly done by myself in 1987.
;
; 1998-09-28, Ullrich von Bassewitz
-; 2013-08-26, Greg King
+; 2014-04-02, Greg King
; ---------------------------------------------------------------------------
@@ -14,6 +14,8 @@ ExecReg := $00 ; Controls execution memory bank
IndReg := $01 ; Controls indirect indexed load-store bank
TXTPTR := $85 ; Far pointer into BASIC source code
+FNAM := $90 ; Far pointer to LOAD/SAVE file-name
+FNAM_LEN := $9D ; Holds length of file-name
; ---------------------------------------------------------------------------
; Screen size
diff --git a/doc/Makefile b/doc/Makefile
index 159c30021..02ed6b1d3 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -6,11 +6,14 @@ endif
.SUFFIXES:
-all mostlyclean install:
+htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html
+infodir = $(prefix)/share/info
+
+all mostlyclean:
ifdef CMD_EXE
-clean zip doc:
+clean install zip doc:
else # CMD_EXE
@@ -21,9 +24,22 @@ TOC_LEVEL = 0
TOC_LEVEL = 2
+INSTALL = install
+
clean:
$(RM) -r ../html ../info
+install:
+ $(if $(prefix),,$(error variable `prefix' must be set))
+ifeq ($(wildcard ../html),../html)
+ $(INSTALL) -d $(DESTDIR)$(htmldir)
+ $(INSTALL) -m644 ../html/*.* $(DESTDIR)$(htmldir)
+endif
+ifeq ($(wildcard ../info),../info)
+ $(INSTALL) -d $(DESTDIR)$(infodir)
+ $(INSTALL) -m644 ../info/*.* $(DESTDIR)$(infodir)
+endif
+
zip:
@cd .. && zip cc65 html/*.*
diff --git a/doc/apple2.sgml b/doc/apple2.sgml
index 940496a41..e58565359 100644
--- a/doc/apple2.sgml
+++ b/doc/apple2.sgml
@@ -3,8 +3,8 @@
Apple ][ specific information for cc65
-Oliver Schmidt,
-2009-10-07
+
+2014-04-10
An overview over the Apple ][ runtime system as it is
@@ -24,7 +24,7 @@ Apple ][ specific header files, available drivers, and any
pitfalls specific to that platform.
Please note that Apple ][ specific functions are just mentioned
-here, they are described in detail in the separate . Even functions marked as "platform dependent" may
be available on more than one platform. Please see the function reference for
more information.
@@ -45,7 +45,7 @@ containing DOS 3.3 as well as ProDOS 8.
For ProDOS 8 system programs the load address is fixed to $2000 so there
is no need for a header. Thus the linker configuration
- for those programs
+ for those programs
omits the DOS 3.3 header. The right AppleCommander option to put system files
without a header on a ProDOS 8 disk image is .
+on the chosen .
-Linker configurations
+Linker configurations
-
-
-
diff --git a/doc/c128.sgml b/doc/c128.sgml
index 5ea44b970..4154c0a8d 100644
--- a/doc/c128.sgml
+++ b/doc/c128.sgml
@@ -2,9 +2,9 @@
-Commodore 128 specific information for cc65
-Ullrich von Bassewitz,
-2003-12-14
+Commodore 128-specific information for cc65
+
+2014-04-12
An overview over the C128 runtime system as it is implemented for the cc65 C
@@ -19,11 +19,11 @@ compiler.
Overview
This file contains an overview of the C128 runtime system as it comes with the
-cc65 C compiler. It describes the memory layout, C128 specific header files,
+cc65 C compiler. It describes the memory layout, C128-specific header files,
available drivers, and any pitfalls specific to that platform.
-Please note that C128 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -59,27 +59,27 @@ Special locations:
The text screen is located at $400 (as in the standard setup).
-Platform specific header files
+Platform-specific header files
-Programs containing C128 specific code may use the C128 specific functions
+C128-specific functions
-The functions listed below are special for the C128. See the for declaration and usage.
@@ -90,10 +90,10 @@ url="funcref.html" name="function reference"> for declaration and usage.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -164,26 +164,28 @@ The names in the parentheses denote the symbols to be used for static linking of
Graphics drivers
+The default drivers,
- This driver was written by Maciej Witkowiak. It uses the 80 column display
+ This driver was written by Maciej Witkowiak. It uses the 80-column display,
and features a resolution of 640*200 with two colors and an adjustable
palette (that means that the two colors can be chosen out of the 16 VDC
colors).
- This driver was written by Maciej Witkowiak. This driver uses the 80 column
- display and features a resolution of 640*480 with two colors and an
+ This driver was written by Maciej Witkowiak. This driver uses the 80-column
+ display, and features a resolution of 640*480 with two colors and an
adjustable palette (that means that the two colors can be chosen out of the
16 VDC colors). The driver requires 64KB VDC RAM.
-Note: The colors are translated from definitions in headers to correct VDC values
-so please use definitions or VIC color numbers only. Colors Extended memory drivers
@@ -217,8 +219,8 @@ missing on VDC and are translated to the two colors missing from VIC palette.
it has better knowledge about the hardware than the driver.
- A driver for the VDC memory of the C128 written and contributed by Maciej
- Witkowiak. Autodetects the amount of memory available (16 or 64K) and offers
+ A driver for the VDC memory of the C128, written and contributed by Maciej
+ Witkowiak. Autodetects the amount of memory available (16 or 64K), and offers
64 or 256 pages of 256 bytes each. Note: This driver is incompatible with
any of the graphics drivers using the VDC!
@@ -227,17 +229,18 @@ missing on VDC and are translated to the two colors missing from VIC palette.
Joystick drivers
+The default drivers,
Driver for the Protovision 4-player adapter originally written by Groepaz
- for the C64 and converted for the C128 by me. See for prices and
+ for the C64, and converted for the C128 by Uz. See for prices and
building instructions. Up to four joysticks are supported.
- Supports up to two joysticks connected to the standard joysticks port of
+ Supports up to two joysticks connected to the standard joysticks ports of
the C128.
@@ -246,6 +249,8 @@ missing on VDC and are translated to the two colors missing from VIC palette.
Mouse drivers
+The default drivers,
@@ -259,11 +264,11 @@ missing on VDC and are translated to the two colors missing from VIC palette.
only the 40-column screen.
- Supports a mouse emulated by a standard joystick e.g. 1350 mouse in port
+ Supports a mouse emulated by a standard joystick, e.g. 1350 mouse, in port
#1 of the C128.
- Supports a potentiometer device e.g. Koala Pad connected to port #1 of
+ Supports a potentiometer device, e.g. Koala Pad, connected to port #1 of
the C128.
@@ -274,10 +279,10 @@ missing on VDC and are translated to the two colors missing from VIC palette.
- Driver for the SwiftLink cartridge. Supports up to 38400 baud, hardware flow
- control (RTS/CTS) and interrupt driven receives. Note that because of the
- peculiarities of the 6551 chip together with the use of the NMI, transmits
- are not interrupt driven, and the transceiver blocks if the receiver asserts
+ Driver for the SwiftLink cartridge. Supports up to 38400 BPS, hardware flow
+ control (RTS/CTS), and interrupt-driven receives. Note that, because of the
+ peculiarities of the 6551 chip, together with the use of the NMI, transmits
+ are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.
The driver uses the RS232 variables and buffers of the kernal (buffers at
@@ -293,10 +298,11 @@ missing on VDC and are translated to the two colors missing from VIC palette.
Other hints
+
Passing arguments to the program
-Command line arguments can be passed to
RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
@@ -307,7 +313,7 @@ supported by BASIC, the following syntax was chosen:
Arguments may be quoted.
Leading and trailing spaces around an argument are ignored. Spaces within
a quoted argument are allowed.
-The first argument passed to The first argument passed to A maximum number of 10 arguments (including the program name) are
supported.
@@ -325,7 +331,7 @@ The runtime for the C128 uses routines marked as .
+feature in the .
diff --git a/doc/c16.sgml b/doc/c16.sgml
index 5d4a5d372..1614516b7 100644
--- a/doc/c16.sgml
+++ b/doc/c16.sgml
@@ -3,8 +3,8 @@
Commodore 16/116 specific information for cc65
-Ullrich von Bassewitz,
-2003-12-15
+
+2014-04-10
An overview over the C16 runtime system as it is implemented for the cc65 C
@@ -23,13 +23,13 @@ cc65 C compiler. It describes the memory layout, C16/116 specific header
files, available drivers, and any pitfalls specific to that platform.
Please note that C16 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
Since the C16/C116 and the Commodore Plus/4 are almost identical (the former
-don't have the 6551 ACIA and only 16KB of memory), the is also worth a look. The
difference between both cc65 targets is that the Plus/4 runtime uses banking
to support full 64K RAM, while the C16 does not use banking and supports up to
@@ -97,7 +97,7 @@ There are currently no special C16/C116 functions.
CBM specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -232,7 +232,7 @@ The runtime for the C16 uses routines marked as .
+feature in the .
diff --git a/doc/c64.sgml b/doc/c64.sgml
index a5014414c..ca99e0061 100644
--- a/doc/c64.sgml
+++ b/doc/c64.sgml
@@ -2,9 +2,9 @@
-Commodore 64 specific information for cc65
-Ullrich von Bassewitz,
-2003-09-23
+Commodore 64-specific information for cc65
+
+2014-04-14
An overview over the C64 runtime system as it is implemented for the cc65 C
@@ -19,11 +19,11 @@ compiler.
Overview
This file contains an overview of the C64 runtime system as it comes with the
-cc65 C compiler. It describes the memory layout, C64 specific header files,
+cc65 C compiler. It describes the memory layout, C64-specific header files,
available drivers, and any pitfalls specific to that platform.
-Please note that C64 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -117,17 +117,17 @@ Please note that in this case a changed start address doesn't make sense,
since the program must be loaded to the BASIC start address.
-Platform specific header files
+Platform-specific header files
-Programs containing C64 specific code may use the C64 specific functions
+C64-specific functions
-The functions listed below are special for the C64. See the for declaration and usage.
@@ -135,10 +135,10 @@ url="funcref.html" name="function reference"> for declaration and usage.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -268,18 +268,18 @@ configuration.
Joystick drivers
+The default drivers,
- Driver for the Digital Excess & Hitmen adapter contributed by Groepaz. See
- on
+ Driver for the Digital Excess & Hitmen adapter contributed by Groepaz.
+ See on
instructions how to build one. Up to four joysticks are supported.
Driver for the Protovision 4-player adapter contributed by Groepaz. See
- for prices and
+ for prices and
building instructions. Up to four joysticks are supported.
@@ -295,6 +295,8 @@ configuration.
Mouse drivers
+The default drivers,
@@ -307,11 +309,11 @@ configuration.
joystick left-button pin or the paddle Y [up/down] pin.)
- Supports a mouse emulated by a standard joystick e.g. 1350 mouse in port
+ Supports a mouse emulated by a standard joystick, e.g. 1350 mouse, in port
#1 of the C64.
- Supports a potentiometer device e.g. Koala Pad connected to port #1 of
+ Supports a potentiometer device, e.g. Koala Pad, connected to port #1 of
the C64.
@@ -322,10 +324,10 @@ configuration.
- Driver for the SwiftLink cartridge. Supports up to 38400 baud, hardware flow
- control (RTS/CTS) and interrupt driven receives. Note that because of the
- peculiarities of the 6551 chip together with the use of the NMI, transmits
- are not interrupt driven, and the transceiver blocks if the receiver asserts
+ Driver for the SwiftLink cartridge. Supports up to 38400 BPS, hardware flow
+ control (RTS/CTS), and interrupt-driven receives. Note that, because of the
+ peculiarities of the 6551 chip, together with the use of the NMI, transmits
+ are not interrupt driven; and, the transceiver blocks if the receiver asserts
flow control because of a full buffer.
@@ -338,14 +340,16 @@ configuration.
Other hints
+
Escape code
-For an Esc press CTRL and [ key.
+For an Esc, press CTRL and the Passing arguments to the program
-Command line arguments can be passed to
RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
@@ -356,7 +360,7 @@ supported by BASIC, the following syntax was chosen:
Arguments may be quoted.
Leading and trailing spaces around an argument are ignored. Spaces within
a quoted argument are allowed.
-The first argument passed to The first argument passed to A maximum number of 10 arguments (including the program name) are
supported.
@@ -374,7 +378,7 @@ The runtime for the C64 uses routines marked as .
+feature in the .
diff --git a/doc/ca65.sgml b/doc/ca65.sgml
index 364790b52..caf022c16 100644
--- a/doc/ca65.sgml
+++ b/doc/ca65.sgml
@@ -2,8 +2,8 @@
ca65 Users Guide
-Ullrich von Bassewitz,
-2000-07-19, 2000-11-29, 2001-10-02, 2005-09-08
+
+2014-04-10
ca65 is a powerful macro assembler for the 6502, 65C02 and 65816 CPUs. It is
@@ -453,9 +453,8 @@ mnemonics:
6502X mode is an extension to the normal 6502 mode. In this mode, several
mnemonics for illegal instructions of the NMOS 6502 CPUs are accepted. Since
these instructions are illegal, there are no official mnemonics for them. The
-unofficial ones are taken from . Please note that only the
+unofficial ones are taken from . Please note that only the
ones marked as "stable" are supported. The following table uses information
from the mentioned web page, for more information, see there.
@@ -502,8 +501,7 @@ nor does it call the interpreter. All this must be done by your program. Apple
][ programmers do probably know how to use sweet16 mode.
For more information about SWEET 16, see
-.
+.
Number format
diff --git a/doc/cbm510.sgml b/doc/cbm510.sgml
index 75497d977..3d01ab5bb 100644
--- a/doc/cbm510.sgml
+++ b/doc/cbm510.sgml
@@ -3,10 +3,11 @@
Commodore 510 (aka P500) specific information for cc65
-Ullrich von Bassewitz, &nl;
-Stefan A. Haubenthal, &nl;
-
-2013-08-23
+
+,
+,
+
+2014-04-02
An overview over the Commodore 510 runtime system as it is implemented for the
@@ -21,11 +22,11 @@ cc65 C compiler.
Overview
This file contains an overview of the CBM 510 runtime system as it comes with
-the cc65 C compiler. It describes the memory layout, CBM 510 specific header
+the cc65 C compiler. It describes the memory layout, CBM 510-specific header
files, available drivers, and any pitfalls specific to that platform.
-Please note that CBM 510 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -38,10 +39,10 @@ machines are supported by this cc65 target.
Binary format
The standard binary output format generated by the linker for the Commodore
-510 target is a machine language program with a one line BASIC stub, which
-transfers control to the machine language running in bank 0. This means that a
-program can be loaded as BASIC program and started with RUN. It is of course
-possible to change this behaviour by using a modified startup file and linker
+510 target is a machine language program with a one-line BASIC stub, which
+transfers control to the machine language running in bank 0. That means that a
+program can be loaded as a BASIC program, and started with RUN. It is, of course,
+possible to change that behaviour by using a modified startup file and linker
config.
@@ -58,7 +59,7 @@ The default memory configuration for the CBM 510 allocates all memory between
in low memory is lost, because a separate hardware stack is set up in page 1,
and the kernal replacement functions need some more memory locations. A few
more pages are lost in high memory, because the runtime sets up a copy of the
-character ROM, a text screen and a CBM compatible jump table at $FF81.
+character ROM, a text screen, and a CBM-compatible jump table at $FF81.
The main startup code is located at $0400, so about 54K of the complete
bank are actually usable for applications.
@@ -66,25 +67,25 @@ Special locations:
-Platform specific header files
+Platform-specific header files
-Programs containing CBM 510 specific code may use the CBM 510 specific functions
+CBM 510-specific functions
-The functions listed below are special for the CBM 510. See the for declaration and usage.
@@ -95,10 +96,10 @@ url="funcref.html" name="function reference"> for declaration and usage.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -133,11 +134,11 @@ declaration and usage.
The following pseudo variables declared in the Note: All I/O chips are located in the system bank (bank 15) and can
+Note: All I/O chips are located in the system bank (bank 15); and can
therefore not be accessed like on other platforms. Please use one of the
-not work!
@@ -164,7 +165,7 @@ will not work!
declaration of the structure.
- The two 6525 triport chips may be accessed by using this variable. See the
+ The two 6525 triport chips may be accessed by using these variables. See the
- Supports up to two standard joysticks connected to the joysticks port of
+ Supports up to two standard joysticks connected to the joysticks ports of
the Commodore 510.
@@ -204,6 +205,8 @@ No graphics drivers are currently available for the Commodore 510.
Mouse drivers
+The default drivers,
@@ -220,20 +223,22 @@ No graphics drivers are currently available for the Commodore 510.
+
RS232 device drivers
Driver for the 6551 ACIA chip built into the Commodore 510. Supports up to
- 19200 baud, hardware flow control (RTS/CTS) and interrupt driven receives.
- Note that because of the peculiarities of the 6551 chip transmits are not
- interrupt driven, and the transceiver blocks if the receiver asserts flow
+ 19200 BPS, hardware flow control (RTS/CTS), and interrupt-driven receives.
+ 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.
+
Limitations
@@ -243,27 +248,44 @@ Since the program runs in bank 0, and the kernal and all I/O chips are located
in bank 15, calling ROM routines or accessing hardware needs special code. The
cc65 runtime implements wrappers for all functions in the kernal jump table.
While this simplifies things, it should be noted that the wrappers do have
-quite an impact on performance: A cross bank call has an extra 300µs
+quite an impact on performance: A cross-bank call has an extra 300µs
penalty added by the wrapper.
+
Interrupts
Compiled programs contain an interrupt handler that runs in the program bank.
-This has several advantages, one of them being performance (see cross bank
+This has several advantages, one of them being performance (see cross-bank
call overhead mentioned above). However, this introduces one problem:
Interrupts are lost while the CPU executes code in the kernal bank. As a
-result, the clock may go wrong and (worse) serial interrupts may get lost.
+result, the clock may go wrong; and (worse), serial interrupts may get lost.
Since the cc65 runtime does only call the kernal for disk I/O, this means that
a program should not do file I/O while it depends on interrupts.
+
Other hints
+
Passing arguments to the program
-Command line argument passing is currently not supported for the Commodore
-510.
+Command-line arguments can be passed to
+ RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+Program return code
@@ -278,7 +300,7 @@ The runtime for the Commodore 510 uses routines marked as .
+.
diff --git a/doc/cbm610.sgml b/doc/cbm610.sgml
index a6ec4650b..2025c0792 100644
--- a/doc/cbm610.sgml
+++ b/doc/cbm610.sgml
@@ -2,9 +2,11 @@
-Commodore 610 specific information for cc65
-Ullrich von Bassewitz,
-2003-12-16
+Commodore 610-specific information for cc65
+
+,
+
+2014-04-02
An overview over the Commodore 610 runtime system as it is implemented for the
@@ -19,11 +21,11 @@ cc65 C compiler.
Overview
This file contains an overview of the CBM 610 runtime system as it comes with
-the cc65 C compiler. It describes the memory layout, CBM 610 specific header
+the cc65 C compiler. It describes the memory layout, CBM 610-specific header
files, available drivers, and any pitfalls specific to that platform.
-Please note that CBM 610 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -31,21 +33,22 @@ information.
In addition to the Commodore 610 (named B40 in the U.S.), several other
machines are supported by this cc65 target, since they have identical
hardware: The Commodore 620 and 630 (more memory, additional coprocessor
-card), and the Commodore 710, 720 and 730 (same hardware in another case with
-a builtin monitor).
+card), and the Commodore 710, 720, and 730 (same hardware in another case with
+a built-in monitor).
Binary format
The standard binary output format generated by the linker for the Commodore
-610 target is a machine language program with a one line BASIC stub, which
-transfers control to the machine language running in bank 1. This means that a
-program can be loaded as BASIC program and started with RUN. It is of course
-possible to change this behaviour by using a modified startup file and linker
+610 target is a machine language program with a one-line BASIC stub, which
+transfers control to the machine language running in bank 1. That means that a
+program can be loaded as a BASIC program, and started with RUN. It is, of course,
+possible to change that behaviour by using a modified startup file and linker
config.
+
Memory layout
cc65 generated programs for the Commodore 610 run in bank 1, the memory bank
@@ -57,8 +60,8 @@ The default memory configuration for the CBM 610 allocates all memory between
$0002 and $FFF0 in bank 1 for the compiled program. Some space
in low memory is lost, because a separate hardware stack is set up in page 1,
and the kernal replacement functions need some more memory locations. A few
-more bytes are lost in high memory, because the runtime sets up a CBM
-compatible jump table at $FF81. The main startup code is located at
+more bytes are lost in high memory, because the runtime sets up a CBM-compatible
+jump table at $FF81. The main startup code is located at
$0400, so about 63K of the complete bank are actually usable for
applications.
@@ -66,25 +69,26 @@ Special locations:
-Platform specific header files
+Platform-specific header files
-Programs containing CBM 610 specific code may use the CBM 610 specific functions
-The functions listed below are special for the CBM 610. See the CBM 610-specific functions
+
+The functions listed below are special for the CBM 610. See the for declaration and usage.
@@ -95,10 +99,10 @@ url="funcref.html" name="function reference"> for declaration and usage.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -128,16 +132,15 @@ declaration and usage.
-
Hardware access
The following pseudo variables declared in the Note: All I/O chips are located in the system bank (bank 15) and can
+Note: All I/O chips are located in the system bank (bank 15); and can
therefore not be accessed like on other platforms. Please use one of the
-not work!
@@ -163,7 +166,7 @@ will not work!
declaration of the structure.
- The two 6525 triport chips may be accessed by using this variable. See the
+ The two 6525 triport chips may be accessed by using these variables. See the
Extended memory drivers
-The Commodore 610 is a business machine and doesn't have joystick ports. There
-are no drivers for the non existing ports available.
-
+The Commodore 610 is a business machine, and doesn't have joystick ports. There
+are no drivers for the non-existing ports available.
Mouse drivers
@@ -210,14 +212,15 @@ No mouse drivers are currently available for the Commodore 610.
Driver for the 6551 ACIA chip built into the Commodore 610. Supports up to
- 19200 baud, hardware flow control (RTS/CTS) and interrupt driven receives.
- Note that because of the peculiarities of the 6551 chip transmits are not
- interrupt driven, and the transceiver blocks if the receiver asserts flow
+ 19200 BPS, hardware flow control (RTS/CTS), and interrupt-driven receives.
+ 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.
+
Limitations
@@ -227,27 +230,44 @@ Since the program runs in bank 1, and the kernal and all I/O chips are located
in bank 15, calling ROM routines or accessing hardware needs special code. The
cc65 runtime implements wrappers for all functions in the kernal jump table.
While this simplifies things, it should be noted that the wrappers do have
-quite an impact on performance: A cross bank call has an extra 300µs
+quite an impact on performance: A cross-bank call has an extra 300µs
penalty added by the wrapper.
+
Interrupts
Compiled programs contain an interrupt handler that runs in the program bank.
-This has several advantages, one of them being performance (see cross bank
+This has several advantages, one of them being performance (see cross-bank
call overhead mentioned above). However, this introduces one problem:
Interrupts are lost while the CPU executes code in the kernal bank. As a
-result, the clock may go wrong and (worse) serial interrupts may get lost.
+result, the clock may go wrong; and (worse), serial interrupts may get lost.
Since the cc65 runtime does only call the kernal for disk I/O, this means that
a program should not do file I/O while it depends on interrupts.
+
Other hints
+
Passing arguments to the program
-Command line argument passing is currently not supported for the Commodore
-610.
+Command-line arguments can be passed to
+ RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+Program return code
@@ -262,7 +282,7 @@ The runtime for the Commodore 610 uses routines marked as .
+.
diff --git a/doc/cc65.sgml b/doc/cc65.sgml
index 1079782bb..275a73168 100644
--- a/doc/cc65.sgml
+++ b/doc/cc65.sgml
@@ -2,7 +2,7 @@
cc65 Users Guide
-Ullrich von Bassewitz,
+2000-09-03, 2001-10-02, 2005-08-01
diff --git a/doc/cl65.sgml b/doc/cl65.sgml
index 2667ab555..6e044b8d5 100644
--- a/doc/cl65.sgml
+++ b/doc/cl65.sgml
@@ -2,7 +2,7 @@
cl65 Users Guide
-Ullrich von Bassewitz,
+01.08.2000, 27.11.2000, 02.10.2001
diff --git a/doc/co65.sgml b/doc/co65.sgml
index ea75dcf7c..9d70ffe6a 100644
--- a/doc/co65.sgml
+++ b/doc/co65.sgml
@@ -2,7 +2,7 @@
co65 Users Guide
-Ullrich von Bassewitz,
+12.02.2003
diff --git a/doc/coding.sgml b/doc/coding.sgml
index 1aa454f12..f6dfc3a35 100644
--- a/doc/coding.sgml
+++ b/doc/coding.sgml
@@ -2,7 +2,7 @@
cc65 coding hints
-Ullrich von Bassewitz,
+2000-12-03, 2009-09-01
diff --git a/doc/da65.sgml b/doc/da65.sgml
index 4dd6800d5..2b8cdb2a3 100644
--- a/doc/da65.sgml
+++ b/doc/da65.sgml
@@ -2,7 +2,7 @@
da65 Users Guide
-Ullrich von Bassewitz,
+2003-08-08
diff --git a/doc/debugging.sgml b/doc/debugging.sgml
index 7566370b9..c7c7792db 100644
--- a/doc/debugging.sgml
+++ b/doc/debugging.sgml
@@ -3,8 +3,8 @@
Using emulators with cc65
-Ullrich von Bassewitz,
-03.12.2000
+
+2014-04-11
How to debug your code using the VICE and Oricutron emulators.
@@ -29,7 +29,7 @@ Win32, OS/2, Acorn RISC OS, BeOS, QNX 6.x, Amiga, GP2X and Mac OS X. It emulates
the Commodore 64, 128, VIC20, PET and the 600/700 machines. For more information
see the VICE home page:
-
+.
VICE has a builtin machine language monitor that may be used for debugging
your programs. Using an emulator for debugging has some advantages:
diff --git a/doc/dio.sgml b/doc/dio.sgml
index f340fa254..c85992a4a 100644
--- a/doc/dio.sgml
+++ b/doc/dio.sgml
@@ -2,8 +2,8 @@
Diskette Sector I/O Routines
-Christian Groessler,
-20-Feb-2005
+
+2014-04-10
The cc65 library provides functions to read and write raw disk sectors.
@@ -89,8 +89,8 @@ The following function returns the sector size of the currently inserted disk:
On the Atari platform, the sector size is handled specially. Please refer
-to the DIO section in the
-specific platform documentation.
+to the DIO section in the .
The following function returns the sector count of the currently inserted disk:
diff --git a/doc/funcref.sgml b/doc/funcref.sgml
index ba8fb8abc..adfeaf4b2 100644
--- a/doc/funcref.sgml
+++ b/doc/funcref.sgml
@@ -2,8 +2,8 @@
cc65 function reference
-Ullrich von Bassewitz,
-07.11.2002
+
+2014-04-10
cc65 is a C compiler for 6502 based systems. This function reference describes
@@ -23,7 +23,7 @@ just some of the supported machines. This function refrence describes the
available functions together with any limitations.
For an overview about the available libraries, their purpose, and any
-differences to the ISO standard, please have a look at the .
-
-Low-level disk I/O API.
+.
@@ -416,8 +415,8 @@ Low-level disk I/O API.
The .
+may be used when dealing with files in .
It does not declare any functions.
diff --git a/doc/geos.sgml b/doc/geos.sgml
index 8a5a948a1..aa3725bdf 100644
--- a/doc/geos.sgml
+++ b/doc/geos.sgml
@@ -5,8 +5,8 @@
GEOSLib docs
-Maciej Witkowiak,
-v1.5, 26.12.1999, 2000, 2001, 2002, 2003, 2005
+
+2014-04-11
This is the documentation of cc65's GEOSLib, but information contained here may be also
useful for writing GEOS applications in general.
@@ -71,22 +71,19 @@ programs.
The software needed:
+ can get it from: .
. The VICE package contains the
- c1541 program that is able to convert/unconvert GEOS files to disk images.
+ can obtain it from: .
+ The VICE package contains the
- .
+
+ this purpose. Check out: .
VICE and cc65 are portable - they run on variety of platforms - DOS, Win32 and UNIX. GEOSLib only
diff --git a/doc/grc65.sgml b/doc/grc65.sgml
index d2433f65a..49d3f6798 100644
--- a/doc/grc65.sgml
+++ b/doc/grc65.sgml
@@ -4,8 +4,9 @@
grc65 -- GEOS Resource Compiler
-
-
+
+,
+VII 2000; VI,VII 2002; 2005-8-3
This document describes a compiler that can create GEOS headers and menues for
diff --git a/doc/index.sgml b/doc/index.sgml
index 1e78a2cdc..f9eed769d 100644
--- a/doc/index.sgml
+++ b/doc/index.sgml
@@ -2,7 +2,7 @@
cc65 Documentation Overview
-
+Program documentation
diff --git a/doc/intro.sgml b/doc/intro.sgml
index 1db4c0c04..d9f6c863a 100644
--- a/doc/intro.sgml
+++ b/doc/intro.sgml
@@ -3,9 +3,10 @@
cc65 Compiler Intro
-Ullrich von Bassewitz, ,
-CbmNut, ,
-
+
+,
+,
+2005-7-22
@@ -285,8 +286,8 @@ Apple:
BRUN TEST
-You will see the "Hello, World!" appear on the same line. Thanks to Oliver
-Schmidt, for his help
+You will see "Hello, World!" appear on the same line. Thanks to
+ for his help
in completing this section.
diff --git a/doc/ld65.sgml b/doc/ld65.sgml
index 4f74b04c1..329f975e1 100644
--- a/doc/ld65.sgml
+++ b/doc/ld65.sgml
@@ -2,8 +2,8 @@
ld65 Users Guide
-Ullrich von Bassewitz,
-02.12.2000, 02.10.2001
+
+2014-04-20
The ld65 linker combines object files into an executable file. ld65 is highly
@@ -36,7 +36,7 @@ It complements the features that are built into the ca65 macroassembler:
the symbol was referenced.
Flexible output. The output of ld65 is highly configurable by a config
- file. More common platforms are supported by builtin configurations
+ file. Some more-common platforms are supported by default configurations
that may be activated by naming the target system. The output
generation was designed with different output formats in mind, so
adding other formats shouldn't be a great problem.
@@ -47,7 +47,7 @@ It complements the features that are built into the ca65 macroassembler:
Usage
-Command line option overview
+Command-line option overview
The linker is called as follows:
@@ -93,9 +93,9 @@ Long options:
-Command line options in detail
+Command-line options in detail
-Here is a description of all the command line options:
+Here is a description of all of the command-line options:
@@ -104,7 +104,7 @@ Here is a description of all the command line options:
Start a library group. The libraries specified within a group are searched
multiple times to resolve crossreferences within the libraries. Normally,
- crossreferences are only resolved within a library, that is the library is
+ crossreferences are resolved only within a library, that is the library is
searched multiple times. Libraries specified later on the command line
cannot reference otherwise unreferenced symbols in libraries specified
earlier, because the linker has already handled them. Library groups are
@@ -138,7 +138,7 @@ Here is a description of all the command line options:
-o name
The -o switch is used to give the name of the default output file.
- Depending on your output configuration, this name may NOT be used as
+ Depending on your output configuration, this name c16 (works also for the c116 with memory up to 32K)
c64
c128
- cbm510 (CBM-II series with 40 column video)
- cbm610 (all CBM series-II computers with 80 column video)
+ cbm510 (CBM-II series with 40-column video)
+ cbm610 (all CBM series-II computers with 80-column video)
geos-apple
geos-cbm
lunix
@@ -186,15 +186,15 @@ Here is a description of all the command line options:
Force an import of a symbol. While object files are always linked to the
output file, regardless if there are any references, object modules from
libraries get only linked in if an import can be satisfied by this module.
- The
@@ -211,7 +211,9 @@ Here is a description of all the command line options:
Must be used in conjunction with
(generate map file). Normally the map file will not include empty segments
and sections, or unreferenced symbols. Using this option, you can force the
- linker to include all this information into the map file.
+ linker to include all that information into the map file. Also, it will
+ include a second
@@ -227,8 +229,8 @@ Here is a description of all the command line options:
This option allows to define an external symbol on the command line. Value
may start with a '$' sign or with in the configuration file.
+ otherwise a leading zero denotes octal values. See also in the configuration file.
@@ -236,18 +238,18 @@ Here is a description of all the command line options:
Specify a library search path. This option may be used more than once. It
adds a directory to the search path for library files. Libraries specified
- without a path are searched in current directory, in the directory given in
- the -Ln
This option allows you to create a file that contains all global labels and
- may be loaded into VICE emulator using the version.
@@ -261,7 +263,7 @@ Here is a description of all the command line options:
-V, --version
- This option print the version number of the linker. If you send any
+ This option prints the version number of the linker. If you send any
suggestions or bugfixes, please include this number.
@@ -271,9 +273,9 @@ Here is a description of all the command line options:
Specify a config file search path. This option may be used more than once.
It adds a directory to the search path for config files. A config file given
with the option that has no path in
- its name is searched in the current directory, in the directory given in the
-
@@ -288,14 +290,14 @@ Here is a description of all the command line options:
--lib file
- Links a library to the output. Use this command line option instead of just
+ Links a library to the output. Use this command-line option instead of just
naming the library file, if the linker is not able to determine the file
type because of an unusual extension.
--obj file
- Links an object file to the output. Use this command line option instead
+ Links an object file to the output. Use this command-line option instead
of just naming the object file, if the linker is not able to determine the
file type because of an unusual extension.
@@ -305,9 +307,9 @@ Here is a description of all the command line options:
Specify an object file search path. This option may be used more than once.
It adds a directory to the search path for object files. An object file
- passed to the linker that has no path in its name is searched in current
- directory, in the directory given in the
@@ -378,22 +380,22 @@ name is given (libraries are also recognized by a magic word, there are no
special naming conventions), all modules in the library are checked if an
export from this module would satisfy an import from other modules. All
modules where this is the case are marked. If duplicate identifiers are
-found, the linker issues a warning.
+found, the linker issues warnings.
-This procedure (parsing and reading from left to right) does mean, that a
+That procedure (parsing and reading from left to right) does mean that a
library may only satisfy references for object modules (given directly or from
a library) named
- ld65 crt0.o clib.lib test.o
+ ld65 crt0.o clib.lib test.o
-the module test.o may not contain references to modules in the library
-clib.lib. If this is the case, you have to change the order of the modules
+the module
- ld65 crt0.o test.o clib.lib
+ ld65 crt0.o test.o clib.lib
Step two is, to read the configuration file, and assign start addresses
@@ -403,7 +405,7 @@ name="Configuration files">).
After that, the linker is ready to produce an output file. Before doing that,
it checks its data for consistency. That is, it checks for unresolved
externals (if the output format is not relocatable) and for symbol type
-mismatches (for example a zero page symbol is imported by a module as absolute
+mismatches (for example a zero-page symbol is imported by a module as an absolute
symbol).
Step four is, to write the actual target files. In this step, the linker will
@@ -416,7 +418,7 @@ segments and symbols encountered.
And, last step, if you give the switch
twice, you get a dump of the segment data. However, this may be quite
-unreadable if you're not a developer:-)
+unreadable if you're not a developer. :-)
@@ -434,23 +436,23 @@ Case is ignored for keywords, that is, section or attribute names, but it is
Memory areas
-Memory areas are specified in a
- MEMORY {
- RAM1: start = $0800, size = $9800;
- ROM1: start = $A000, size = $2000;
- RAM2: start = $C000, size = $1000;
- ROM2: start = $E000, size = $2000;
- }
+ MEMORY {
+ RAM1: start = $0800, size = $9800;
+ ROM1: start = $A000, size = $2000;
+ RAM2: start = $C000, size = $1000;
+ ROM2: start = $E000, size = $2000;
+ }
-As you can see, there are two ram areas and two rom areas. The names
+As you can see, there are two RAM areas and two ROM areas. The names
(before the colon) are arbitrary names that must start with a letter, with
the remaining characters being letters or digits. The names of the memory
areas are used when assigning segments. As mentioned above, case is
-significant for these names.
+significant for those names.
The syntax above is used in all sections of the config file. The name
(
- # Start of memory section
- MEMORY
- {
- RAM1:
- start $0800
- size $9800;
- ROM1:
- start $A000
- size $2000;
- RAM2:
- start $C000
- size $1000;
- ROM2:
- start $E000
- size $2000;
- }
+ # Start of memory section
+ MEMORY
+ {
+ RAM1:
+ start $0800
+ size $9800;
+ ROM1:
+ start $A000
+ size $2000;
+ RAM2:
+ start $C000
+ size $1000;
+ ROM2:
+ start $E000
+ size $2000;
+ }
There are of course more attributes for a memory section than just start and
@@ -495,26 +497,26 @@ we will start to assign segments to memory sections in the
- SEGMENTS {
- CODE: load = RAM1, type = ro;
- RODATA: load = RAM1, type = ro;
- DATA: load = RAM1, type = rw;
- BSS: load = RAM1, type = bss, define = yes;
- }
+ SEGMENTS {
+ CODE: load = RAM1, type = ro;
+ RODATA: load = RAM1, type = ro;
+ DATA: load = RAM1, type = rw;
+ BSS: load = RAM1, type = bss, define = yes;
+ }
What we are doing here is telling the linker, that all segments go into the
- ro means readonly
- rw means read/write
- bss means that this is an uninitialized segment
- zp a zeropage segment
+ ro means readonly
+ rw means read/write
+ bss means that this is an uninitialized segment
+ zp a zeropage segment
So, because we specified that the segment with the name BSS is of type bss,
@@ -531,19 +533,19 @@ a warning if this is not the case.
For a
- __NAME_LOAD__ This is set to the address where the
- segment is loaded.
- __NAME_RUN__ This is set to the run address of the
- segment. We will cover run addresses
- later.
- __NAME_SIZE__ This is set to the segment size.
+ __NAME_LOAD__ This is set to the address where the
+ segment is loaded.
+ __NAME_RUN__ This is set to the run address of the
+ segment. We will cover run addresses
+ later.
+ __NAME_SIZE__ This is set to the segment size.
Replace option on the command line. Since the
-default behaviour is ok for our purposes, I did not use the attribute in the
+default behaviour is OK for our purposes, I did not use the attribute in the
example above. Let's have a look at it now.
The "file" attribute (the keyword may also be written as "FILE" if you like
-that better) takes a string enclosed in double quotes (`"') that specifies the
+that better) takes a string enclosed in double quotes (`&dquot;') that specifies the
file, where the data is written. You may specify the same file several times,
in that case the data for all memory areas having this file name is written
into this file, in the order of the memory areas defined in the
- MEMORY {
- RAM1: start = $0800, size = $9800, file = %O;
- ROM1: start = $A000, size = $2000, file = "rom1.bin";
- RAM2: start = $C000, size = $1000, file = %O;
- ROM2: start = $E000, size = $2000, file = "rom2.bin";
- }
+ MEMORY {
+ RAM1: start = $0800, size = $9800, file = %O;
+ ROM1: start = $A000, size = $2000, file = "rom1.bin";
+ RAM2: start = $C000, size = $1000, file = %O;
+ ROM2: start = $E000, size = $2000, file = "rom2.bin";
+ }
The
- MEMORY {
- ROM1: start = $A000, size = $2000, file = "%O-1.bin";
- ROM2: start = $E000, size = $2000, file = "%O-2.bin";
- }
+ MEMORY {
+ ROM1: start = $A000, size = $2000, file = "%O-1.bin";
+ ROM2: start = $E000, size = $2000, file = "%O-2.bin";
+ }
would write two files that start with the name of the output file specified on
@@ -624,17 +626,17 @@ read/write data. But now, if the code is in ROM, we must care about it.
Remember the default segments (you may of course specify your own):
- CODE read only code
- RODATA read only data
- DATA read/write data
- BSS uninitialized data, read/write
+ CODE read-only code
+ RODATA read-only data
+ DATA read/write data
+ BSS uninitialized data, read/write
Since
- SEGMENTS {
- CODE: load = ROM1, type = ro;
- RODATA: load = ROM2, type = ro;
- DATA: load = ROM2, run = RAM2, type = rw, define = yes;
- BSS: load = RAM2, type = bss, define = yes;
- }
+ SEGMENTS {
+ CODE: load = ROM1, type = ro;
+ RODATA: load = ROM2, type = ro;
+ DATA: load = ROM2, run = RAM2, type = rw, define = yes;
+ BSS: load = RAM2, type = bss, define = yes;
+ }
Let's have a closer look at this
- __DATA_LOAD__ This is set to the address where the segment
- is loaded, in this case, it is an address in
- ROM2.
- __DATA_RUN__ This is set to the run address of the segment,
- in this case, it is an address in RAM2.
- __DATA_SIZE__ This is set to the segment size.
+ __DATA_LOAD__ This is set to the address where the segment
+ is loaded, in this case, it is an address in
+ ROM2.
+ __DATA_RUN__ This is set to the run address of the segment,
+ in this case, it is an address in RAM2.
+ __DATA_SIZE__ This is set to the segment size.
So, what your startup code must do, is to copy
- MEMORY {
- STACK: start = $C000, size = $1000, define = yes;
- }
+ MEMORY {
+ STACK: start = $C000, size = $1000, define = yes;
+ }
This will define some external symbols that may be used in your code:
- __STACK_START__ This is set to the start of the memory
- area, $C000 in this example.
- __STACK_SIZE__ The size of the area, here $1000.
- __STACK_LAST__ This is NOT the same as START+SIZE.
- Instead, it it defined as the first
- address that is not used by data. If we
- don't define any segments for this area,
- the value will be the same as START.
+ __STACK_START__ This is set to the start of the memory
+ area, $C000 in this example.
+ __STACK_SIZE__ The size of the area, here $1000.
+ __STACK_LAST__ This is NOT the same as START+SIZE.
+ Instead, it is defined as the first
+ address that is not used by data. If we
+ don't define any segments for this area,
+ the value will be the same as START.
__STACK_FILEOFFS__ The binary offset in the output file. This
is not defined for relocatable output file
formats (o65).
@@ -721,8 +723,8 @@ This will define some external symbols that may be used in your code:
A memory section may also have a type. Valid types are
- ro for readonly memory
- rw for read/write memory.
+ ro for readonly memory
+ rw for read/write memory.
The linker will assure, that no segment marked as read/write or bss is put
@@ -734,16 +736,16 @@ you don't like this, you may specify a byte value that is used to fill these
areas with the " section, or the
+the one defined in , or the
value given on the command line with the
option).
To support systems with banked memory, a special attribute named
- SEGMENTS {
- CODE: load = ROM1, type = ro, align = $100;
- RODATA: load = ROM2, type = ro, align = $100;
- DATA: load = ROM2, run = RAM2, type = rw, define = yes,
- align = $100;
- BSS: load = RAM2, type = bss, define = yes, align = $100;
- }
+ SEGMENTS {
+ CODE: load = ROM1, type = ro, align = $100;
+ RODATA: load = ROM2, type = ro, align = $100;
+ DATA: load = ROM2, run = RAM2, type = rw, define = yes,
+ align = $100;
+ BSS: load = RAM2, type = bss, define = yes, align = $100;
+ }
If an alignment is requested, the linker will add enough space to the output
@@ -788,17 +790,17 @@ specified offset (this may happen if other segments in this area are too
large). Here's an example:
- SEGMENTS {
- VECTORS: load = ROM2, type = ro, start = $FFFA;
- }
+ SEGMENTS {
+ VECTORS: load = ROM2, type = ro, start = $FFFA;
+ }
or (for the segment definitions from above)
- SEGMENTS {
- VECTORS: load = ROM2, type = ro, offset = $1FFA;
- }
+ SEGMENTS {
+ VECTORS: load = ROM2, type = ro, offset = $1FFA;
+ }
The "
- FILES {
- %O: format = bin;
- }
+ FILES {
+ %O: format = bin;
+ }
The only other available output format is the o65 format specified by Andre
-Fachat (see the ). It is defined like this:
- FILES {
- %O: format = o65;
- }
+ FILES {
+ %O: format = o65;
+ }
The necessary o65 attributes are defined in a special section labeled
-.
-The FORMAT section
+The FORMAT section
The ,
+,
has several attributes that may be defined here.
@@ -885,12 +887,12 @@ linker has features that may be enabled by an additional section labeled
tables.
- FEATURES {
- CONDES: segment = RODATA,
- type = constructor,
- label = __CONSTRUCTOR_TABLE__,
- count = __CONSTRUCTOR_COUNT__;
- }
+ FEATURES {
+ CONDES: segment = RODATA,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ }
The label
This specifies the label to use for the table. The label points to the start
- of the table in memory and may be used from within user written code.
+ of the table in memory and may be used from within user-written code.
count
@@ -926,7 +928,7 @@ The order
- Optional attribute that takes one of the keywords import
This attribute defines a valid symbol name, that is added as an import
- to the modules defining a constructor/desctructor of the given type.
+ to the modules defining a constructor/destructor of the given type.
This can be used to force linkage of a module if this module exports the
requested symbol.
@@ -949,7 +951,7 @@ The .
@@ -960,10 +962,10 @@ which can be referenced by the
- FEATURES {
+ FEATURES {
# Default start address is $1000
- STARTADDRESS: default = $1000;
- }
+ STARTADDRESS: default = $1000;
+ }
Please note that order is important: The default start address must be defined
@@ -1016,10 +1018,10 @@ the programmer to override the value by specifying
- SYMBOLS {
+ SYMBOLS {
# Define the stack size for the application
- __STACKSIZE__: type = weak, value = $800;
- }
+ __STACKSIZE__: type = weak, value = $800;
+ }
diff --git a/doc/library.sgml b/doc/library.sgml
index 6c2ced433..9b923c308 100644
--- a/doc/library.sgml
+++ b/doc/library.sgml
@@ -3,8 +3,8 @@
cc65 Library Overview
-Ullrich von Bassewitz,
-2000-12-02, 2002-11-26
+
+2014-04-12
An overview over the runtime and C libraries that come with the cc65 compiler,
@@ -19,7 +19,7 @@ including a discussion of the differences to the ISO standard.
Overview
This file contains a short overview of the libraries available for the cc65 C
-compiler. Please have a look at the for a list function by function. Since the function reference is
not complete (I'm working on that) it may happen that you don't find a
specific function. In this case, have a look into the header files. All
diff --git a/doc/lynx.sgml b/doc/lynx.sgml
index f83552e50..73763f1dd 100644
--- a/doc/lynx.sgml
+++ b/doc/lynx.sgml
@@ -3,9 +3,10 @@
Atari Lynx specific information for cc65
-Karri Kaksonen,
-Ullrich von Bassewitz,
-2011-04-01
+
+,
+
+2014-04-12
An overview over the Atari Lynx runtime system as it is implemented for the
@@ -24,7 +25,7 @@ with the cc65 C compiler. It describes the memory layout, Lynx specific header
files, available drivers, and any pitfalls specific to that platform.
Please note that Lynx specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
diff --git a/doc/nes.sgml b/doc/nes.sgml
index 5d465c813..ca9ce72b3 100644
--- a/doc/nes.sgml
+++ b/doc/nes.sgml
@@ -3,9 +3,10 @@
Nintendo Entertainment System specific information for cc65
-Ullrich von Bassewitz,
-Stefan A. Haubenthal,
-2005-07-17
+
+,
+
+2014-04-12
An overview over the NES runtime system as it is implemented for the
@@ -24,7 +25,7 @@ with the cc65 C compiler. It describes the memory layout, NES specific header
files, available drivers, and any pitfalls specific to that platform.
Please note that NES specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
diff --git a/doc/od65.sgml b/doc/od65.sgml
index a1960109d..f5611a889 100644
--- a/doc/od65.sgml
+++ b/doc/od65.sgml
@@ -2,12 +2,12 @@
od65 Users Guide
-Ullrich von Bassewitz,
-2010-07-30
+
+2014-04-14
od65 is the object file dump utility. It is able to output most parts of
- generated object files in readable form.
+ object files in readable form.
@@ -19,7 +19,7 @@ od65 is the object file dump utility. It is able to output most parts of
Overview
od65 is an object file dump utility. It is able to output most parts of
- generated object files in readable form.
+ object files in readable form.
Since the contents and format of the object files are not documented
elsewhere and may change at any time, this tool is a portable way to look at
the contents.
diff --git a/doc/pet.sgml b/doc/pet.sgml
index 6d816ad77..7c5bd71ea 100644
--- a/doc/pet.sgml
+++ b/doc/pet.sgml
@@ -2,10 +2,11 @@
-Commodore PET specific information for cc65
-Ullrich von Bassewitz,
-Stefan A. Haubenthal,
-2005-05-24
+Commodore PET-specific information for cc65
+
+,
+
+2014-04-12
An overview over the PET runtime system as it is implemented for the cc65 C
@@ -20,11 +21,11 @@ compiler.
Overview
This file contains an overview of the PET runtime system as it comes with the
-cc65 C compiler. It describes the memory layout, PET specific header files,
+cc65 C compiler. It describes the memory layout, PET-specific header files,
available drivers, and any pitfalls specific to that platform.
-Please note that PET specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -63,24 +64,24 @@ Special locations:
-Platform specific header files
+Platform-specific header files
-Programs containing PET specific code may use the PET specific functions
+PET-specific functions
There are currently no special PET functions.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -148,12 +149,13 @@ No extended memory drivers are currently available for the PET.
Joystick drivers
+The default drivers,
Driver for the Protovision 4-player adapter contributed by Groepaz. See
- for prices and
+ for prices and
building instructions. Up to two joysticks are supported.
@@ -179,10 +181,11 @@ No serial drivers are currently available for the PET.
Other hints
+
Passing arguments to the program
-Command line arguments can be passed to
RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
@@ -193,7 +196,7 @@ supported by BASIC, the following syntax was chosen:
Arguments may be quoted.
Leading and trailing spaces around an argument are ignored. Spaces within
a quoted argument are allowed.
-The first argument passed to The first argument passed to A maximum number of 10 arguments (including the program name) are
supported.
@@ -211,7 +214,7 @@ The runtime for the PET uses routines marked as .
+feature in the .
Using extended memory
@@ -228,6 +231,7 @@ the following code:
+
License
This software is provided 'as-is', without any expressed or implied
diff --git a/doc/plus4.sgml b/doc/plus4.sgml
index a16eef9d3..36d53e753 100644
--- a/doc/plus4.sgml
+++ b/doc/plus4.sgml
@@ -3,8 +3,8 @@
Commodore Plus/4 specific information for cc65
-Ullrich von Bassewitz,
-2003-12-14
+
+2014-04-12
An overview over the Plus/4 runtime system as it is implemented for the cc65 C
@@ -23,13 +23,13 @@ cc65 C compiler. It describes the memory layout, Plus/4 specific header files,
available drivers, and any pitfalls specific to that platform.
Please note that Plus/4 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
Since the Plus/4 and the Commodore 16/116 are almost identical (the latter are
-missing the 6551 ACIA and do only have 16KB of memory), the is also worth a look. The difference
between both cc65 targets is that the Plus/4 runtime uses banking to support
full 64K RAM, while the C16 does not use banking and supports up to 32K RAM.
@@ -95,7 +95,7 @@ There are currently no special Plus/4 functions.
CBM specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -232,7 +232,7 @@ The runtime for the Plus/4 uses routines marked as .
+feature in the .
diff --git a/doc/sp65.sgml b/doc/sp65.sgml
index 3cf749e20..909ac6d25 100644
--- a/doc/sp65.sgml
+++ b/doc/sp65.sgml
@@ -2,7 +2,7 @@
sp65 Users Guide
-Ullrich von Bassewitz,
+2012-03-11
diff --git a/doc/supervision.sgml b/doc/supervision.sgml
index 0aa990ac5..97495dea5 100644
--- a/doc/supervision.sgml
+++ b/doc/supervision.sgml
@@ -3,8 +3,8 @@
Watara Supervision specific information for cc65
-Stefan A. Haubenthal,
-2005-07-17
+
+2014-04-12
An overview over the Supervision runtime system as it is implemented for the
@@ -23,7 +23,7 @@ with the cc65 C compiler. It describes the memory layout, Supervision specific h
files, available drivers, and any pitfalls specific to that platform.
Please note that Supervision specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more information.
@@ -92,7 +92,7 @@ allow access to hardware located in the address space.
No graphics drivers are currently available for the Supervision.
Extended memory drivers
@@ -105,7 +105,7 @@ No extended memory drivers are currently available for the Supervision.
No joystick drivers are currently available for the Supervision.
Mouse drivers
diff --git a/doc/using-make.sgml b/doc/using-make.sgml
index 5affe3b9f..0c3c13a6e 100644
--- a/doc/using-make.sgml
+++ b/doc/using-make.sgml
@@ -3,8 +3,8 @@
Using GNU Make with cc65
-Oliver Schmidt,
-2009-06-26
+
+2014-04-12
How to build your program using the GNU Make utility.
@@ -114,10 +114,10 @@ of creating a Understanding the sample Makefile
Most parts of the sample Makefile follow the guidelines in the
-
+
that can be searched online for background information. The automatic generation of
dependency however rather works as described by the GNU Make maintainer Paul D. Smith in
-.
+.
Fortunately both GCC and cc65 directly support this method in the meantime.
@@ -133,8 +133,8 @@ then the sample Makefile may be invoked from the Windows Command Prompt (cmd.exe
by downloading the following programs:
-make.exe:
-rm.exe:
+
+
@@ -144,9 +144,9 @@ by downloading the following programs:
The very limited resources of the cc65 target machines now and then require
manual optimization of the build process by compiling individual source files
with different compiler options. GNU Make offers
-
+
perfectly suited for doing so. For example placing the code of the two modules
-
diff --git a/doc/vic20.sgml b/doc/vic20.sgml
index 562ea002a..5fba59a13 100644
--- a/doc/vic20.sgml
+++ b/doc/vic20.sgml
@@ -3,9 +3,10 @@
Commodore VIC20 (aka VC20) specific information for cc65
-Ullrich von Bassewitz,
-Stefan A. Haubenthal,
-2004-09-13
+
+,
+
+2014-04-12
An overview over the VIC20 runtime system as it is implemented for the cc65 C
@@ -20,11 +21,11 @@ compiler.
Overview
This file contains an overview of the VIC20 runtime system as it comes with the
-cc65 C compiler. It describes the memory layout, VIC20 specific header files,
+cc65 C compiler. It describes the memory layout, VIC20-specific header files,
available drivers, and any pitfalls specific to that platform.
-Please note that VIC20 specific functions are just mentioned here, they are
-described in detail in the separate . Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
@@ -63,24 +64,24 @@ Special locations:
-Platform specific header files
+Platform-specific header files
-Programs containing VIC20 specific code may use the VIC20 specific functions
+VIC20-specific functions
There are currently no special VIC20 functions.
-CBM specific functions
+CBM-specific functions
Some functions are available for all (or at least most) of the Commodore
-machines. See the for
+machines. See the for
declaration and usage.
@@ -151,6 +152,8 @@ No extended memory drivers are currently available for the VIC20.
Joystick drivers
+The default drivers,
@@ -158,8 +161,7 @@ No extended memory drivers are currently available for the VIC20.
Driver for the Protovision 4-player adapter contributed by Groepaz. See
- for prices and
+ for prices and
building instructions. Up to three joysticks are supported.
@@ -182,14 +184,16 @@ No VIC1011 drivers are currently available for the VIC20.
Other hints
+
Escape code
-For an Esc press CTRL and [ key.
+For an Esc, press CTRL and the Passing arguments to the program
-Command line arguments can be passed to
RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
@@ -200,7 +204,7 @@ supported by BASIC, the following syntax was chosen:
Arguments may be quoted.
Leading and trailing spaces around an argument are ignored. Spaces within
a quoted argument are allowed.
-The first argument passed to The first argument passed to A maximum number of 10 arguments (including the program name) are
supported.
@@ -232,7 +236,7 @@ The runtime for the VIC20 uses routines marked as .
+feature in the .
diff --git a/include/tgi.h b/include/tgi.h
index a43eb0cc3..51d0eaebc 100644
--- a/include/tgi.h
+++ b/include/tgi.h
@@ -275,6 +275,11 @@ unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);
* for unknown codes or values.
*/
+int __fastcall__ tgi_imulround (int rhs, int lhs);
+/* Helper function for functions using sine/cosine: Multiply two values, one
+ * being an 8.8 fixed point one, and return the rounded and scaled result.
+ */
+
/* End of tgi.h */
diff --git a/include/tgi/tgi-kernel.h b/include/tgi/tgi-kernel.h
index 8367e4453..bc5fdc3c6 100644
--- a/include/tgi/tgi-kernel.h
+++ b/include/tgi/tgi-kernel.h
@@ -67,19 +67,6 @@ extern unsigned tgi_charheight; /* Height of scaled bitmap font */
-/*****************************************************************************/
-/* Code */
-/*****************************************************************************/
-
-
-
-int __fastcall__ tgi_imulround (int rhs, int lhs);
-/* Helper function for functions using sine/cosine: Multiply two values, one
- * being an 8.8 fixed point one, and return the rounded and scaled result.
- */
-
-
-
/* End of tgi-kernel.h */
#endif
diff --git a/libsrc/atari/Makefile.inc b/libsrc/atari/Makefile.inc
index af5a17e59..4488ddf22 100644
--- a/libsrc/atari/Makefile.inc
+++ b/libsrc/atari/Makefile.inc
@@ -31,3 +31,7 @@ CA65FLAGS += -D NUMDRVS=4 -D LINEBUF=80 -D UCASE_FILENAME=1 -D DEFAULT_DEVICE=1
# Disabled by default, you should enable it if the linker script relocates the
# character generator (like atarixl-largehimem.cfg).
#CA65FLAGS += -D CHARGEN_RELOC -D USEWSYNC
+
+# Disable if you don't want to use page 6 for mouse P/M data.
+# If disabled, top of the RAM is used for P/M data.
+CA65FLAGS += -D USE_PAGE6
diff --git a/libsrc/atari/libref.s b/libsrc/atari/libref.s
index 4f7cbbef6..171bd6de6 100644
--- a/libsrc/atari/libref.s
+++ b/libsrc/atari/libref.s
@@ -2,19 +2,14 @@
; Oliver Schmidt, 2013-05-31
;
- .export em_libref, joy_libref, tgi_libref, ser_libref, mouse_libref
+ .export em_libref, joy_libref, tgi_libref
.import _exit
- .import atari_ser_libref
em_libref := _exit
joy_libref := _exit
-ser_libref := atari_ser_libref
.ifdef __ATARIXL__
.import CIO_handler
tgi_libref := CIO_handler
- .import set_VTIMR1_handler
-mouse_libref := set_VTIMR1_handler
.else
-mouse_libref := _exit
tgi_libref := _exit
.endif
diff --git a/libsrc/atari/mcbdefault.s b/libsrc/atari/mcbdefault.s
index ac5056cf9..75a7c74bc 100644
--- a/libsrc/atari/mcbdefault.s
+++ b/libsrc/atari/mcbdefault.s
@@ -1,126 +1,8 @@
;
-; Default mouse callbacks for the Ataris
-;
-; Christian Groessler, 03.01.2014
-;
-; derived from Apple2 version by
-; Oliver Schmidt, 22.09.2005
-;
-; All functions in this module should be interrupt safe, because they may
-; be called from an interrupt handler
+; This file defines the default mouse callback
;
- .export _mouse_def_callbacks
- .importzp tmp4
- .import mul40,loc_tmp
+.import _mouse_pm_callbacks
+.export _mouse_def_callbacks
- .include "atari.inc"
-
-; ------------------------------------------------------------------------
-
- .bss
-
-backup: .res 1
-visible:.res 1
-
-; ------------------------------------------------------------------------
-
- .segment "EXTZP" : zeropage
-scrptr: .res 2
-
-; ------------------------------------------------------------------------
-
-
- .rodata
-
- ; Callback structure
-_mouse_def_callbacks:
- .addr hide
- .addr show
- .addr prep
- .addr draw
- .addr movex
- .addr movey
-
-; ------------------------------------------------------------------------
-
- .data
-
-cursor = 11 ; '+' screen code'
-
-; setcursor
-
-getcursor:
-column: ldy #$00 ; Patched at runtime
- lda (scrptr),y
- rts
-
-setcursor:
-column2:ldy #$00 ; Patched at runtime
- sta (scrptr),y
- rts
-
-; ------------------------------------------------------------------------
-
- .code
-
-done:
- rts
-
-; Hide the mouse cursor.
-hide:
- dec visible
-
-prep:
- jsr getcursor ; Get character at cursor position
- cmp #cursor ; "mouse" character
- bne overwr ; no, probably program has overwritten it
- lda backup ;
- jmp setcursor ; Draw character
-overwr: sta backup
- rts
-
-; Show the mouse cursor.
-show:
- inc visible
-
-draw:
- lda visible
- beq done
- jsr getcursor ; Cursor visible at current position?
- sta backup ; Save character at cursor position
- lda #cursor
- jmp setcursor ; Draw cursor
-
-
-; Move the mouse cursor x position to the value in A/X.
-movex:
- cpx #1
- ror a
- lsr a ; convert to character position
- lsr a
- sta column+1
- sta column2+1
- rts
-
-; Move the mouse cursor y position to the value in A/X.
-movey:
- tax
- ldy tmp4 ; mul40 uses tmp4
- lda loc_tmp ; and this local variable
- pha
- txa ; get parameter back
- lsr a ; convert y position to character line
- lsr a
- lsr a
- jsr mul40
- clc
- adc SAVMSC
- sta scrptr
- txa
- adc SAVMSC+1
- sta scrptr+1
- pla
- sta loc_tmp
- sty tmp4
- rts
+_mouse_def_callbacks := _mouse_pm_callbacks
diff --git a/libsrc/atari/mcbpm-shape.s b/libsrc/atari/mcbpm-shape.s
new file mode 100644
index 000000000..bb754f48a
--- /dev/null
+++ b/libsrc/atari/mcbpm-shape.s
@@ -0,0 +1,31 @@
+;
+; P/M mouse shape default definition
+;
+; Christian Groessler, 11.04.2014
+;
+; Note that the height of the mouse cursor must not exceed 32
+; lines, otherwise the display routines won't do The Right
+; Thing(tm).
+;
+
+ .export mouse_pm_bits
+ .export mouse_pm_height : zeropage
+ .export mouse_pm_hotspot_x : zeropage
+ .export mouse_pm_hotspot_y : zeropage
+
+ .rodata
+
+mouse_pm_bits:
+ .byte %11110000
+ .byte %11000000
+ .byte %10100000
+ .byte %10010000
+ .byte %10001000
+ .byte %00000100
+ .byte %00000010
+
+mouse_pm_height = * - mouse_pm_bits
+
+; hot spot is upper left corner
+mouse_pm_hotspot_x = 0
+mouse_pm_hotspot_y = 0
diff --git a/libsrc/atari/mcbpm.s b/libsrc/atari/mcbpm.s
new file mode 100644
index 000000000..b546faced
--- /dev/null
+++ b/libsrc/atari/mcbpm.s
@@ -0,0 +1,237 @@
+;
+; P/M mouse callbacks for the Ataris
+;
+; Christian Groessler, 11.04.2014
+;
+; All functions in this module should be interrupt safe, because they may
+; be called from an interrupt handler
+;
+
+ .include "atari.inc"
+ .importzp sp
+ .export _mouse_pm_callbacks
+ .constructor pm_init,27
+ .destructor pm_down,7
+
+; get mouse shape data
+ .import mouse_pm_bits
+ .importzp mouse_pm_height
+ .importzp mouse_pm_hotspot_x
+ .importzp mouse_pm_hotspot_y
+
+
+; P/M definitions. The MOUSE_PM_NUM value can be changed to adjust the
+; number of the P/M used for the mouse. All others depend on this value.
+; Valid P/M numbers are 0 to 4. When 4 is used, the missiles are used
+; as a player.
+.ifdef USE_PAGE6
+MOUSE_PM_NUM = 2 ; P/M used for the mouse
+ ; This cannot be changed since only player #2 uses the memory at $600.
+.else
+MOUSE_PM_NUM = 4 ; P/M used for the mouse
+ ; Using player #4 (missiles) wastes the least amount of memory on the
+ ; atari target, since top of memory is typically at $xC20, and the
+ ; missiles use the space at $xB00-$xBFF.
+ ; On the atarixl target this configuration (not using page 6) is not
+ ; really satisfying since the top of memory typically lies beneath
+ ; the ROM and there is flickering visible while the ROM is banked in.
+.endif
+MOUSE_PM_BASE = pm_base ; ZP location pointing to the hw area used by the selected P/M
+
+.if MOUSE_PM_NUM = 4
+MOUSE_PM_RAW = 0 ; MOUSE_PM_RAW is the hardware P/M number for MOUSE_PM_NUM
+.macro set_mouse_x
+ ; assume CF = 0
+ sta HPOSM3
+ adc #2
+ sta HPOSM2
+ adc #2
+ sta HPOSM1
+ adc #2
+ sta HPOSM0
+.endmacro
+.else
+MOUSE_PM_RAW = MOUSE_PM_NUM + 1
+.macro set_mouse_x
+ sta HPOSP0 + MOUSE_PM_NUM
+.endmacro
+.endif
+
+; ------------------------------------------------------------------------
+
+ .rodata
+
+ ; Callback structure
+_mouse_pm_callbacks:
+ .addr hide
+ .addr show
+ .addr prep
+ .addr draw
+ .addr movex
+ .addr movey
+
+; ------------------------------------------------------------------------
+
+ .bss
+
+omy: .res 1 ; old Mouse Y position
+colhlp: .res 1 ; helper variable to set P/M color
+
+; ------------------------------------------------------------------------
+
+ .segment "EXTZP" : zeropage
+
+pm_base:.res 2
+
+; ------------------------------------------------------------------------
+
+ .code
+
+; Hide the mouse cursor.
+hide: lda #0
+ sta GRACTL
+ rts
+
+; Show the mouse cursor.
+show:
+.if MOUSE_PM_NUM < 4
+ lda #2
+.else
+ lda #1
+.endif
+ sta GRACTL
+ jmp update_colors
+
+prep:
+draw:
+ rts
+
+; Move the mouse cursor x position to the value in A/X.
+movex: cpx #1
+ ror a
+ clc
+ adc #48
+ sbc #(mouse_pm_hotspot_x - 1) & $FF
+ set_mouse_x
+ jmp update_colors
+
+; Move the mouse cursor y position to the value in A/X.
+movey: clc
+ adc #32
+ sbc #(mouse_pm_hotspot_y - 1) & $FF
+ pha
+ lda omy
+ jsr clr_pm ; remove player at old position
+ jsr update_colors
+ pla
+ sta omy
+ ;jmp set_pm ; put player to new position
+ ; fall thru
+
+; Set P/M data from 'mouse_pm_bits'
+set_pm: tay
+ ldx #0
+set_l: lda mouse_pm_bits,x
+ sta (MOUSE_PM_BASE),y
+ inx
+ iny
+ beq set_end
+ cpx #mouse_pm_height
+ bcc set_l
+set_end:rts
+
+; Clear (zero) P/M data
+clr_pm: ldx #mouse_pm_height
+ tay
+ lda #0
+clr_l: sta (MOUSE_PM_BASE),y
+ iny
+ beq clr_end
+ dex
+ bne clr_l
+clr_end:rts
+
+
+pm_down = hide
+
+
+; this assumes a GRAPHICS 0 screen
+update_colors:
+ lda COLOR2 ; get background color
+ and #$F0
+ sta colhlp
+ lda COLOR1
+ and #$0F
+ ora colhlp
+
+.if MOUSE_PM_NUM = 4
+ sta PCOLR0
+ sta PCOLR1
+ sta PCOLR2
+ sta PCOLR3
+ lda #0
+ sta SIZEM
+.else
+ sta PCOLR0 + MOUSE_PM_NUM
+ lda #0
+ sta SIZEP0 + MOUSE_PM_NUM
+.endif
+ rts
+
+; ------------------------------------------------------------------------
+
+ .segment "INIT"
+
+pm_init:
+ lda #0
+
+.ifdef USE_PAGE6
+
+ sta MOUSE_PM_BASE
+ ldx #6 ; page 6
+ stx MOUSE_PM_BASE+1
+
+.else
+
+; use top of memory and lower sp accordingly
+ sta sp
+ sta MOUSE_PM_BASE
+ lda sp+1
+ and #7 ; offset within 2K
+ cmp #3 + MOUSE_PM_RAW + 1 ; can we use it?
+ bcc @decr ; no
+
+ lda sp+1
+ and #$F8
+@set: adc #3 + MOUSE_PM_RAW - 1 ; CF is set, so adding MOUSE_PM_RAW + 3
+ sta MOUSE_PM_BASE+1
+ sta sp+1
+ bne @cont ; jump always
+
+@decr: lda sp+1
+ and #$F8
+ sbc #8 - 1 ; CF is clear, subtracts 8
+ bcs @set ; jump always
+
+@cont: lda #0
+
+.endif
+
+ tay
+@iniloo:sta (MOUSE_PM_BASE),y
+ iny
+ bne @iniloo
+
+.ifndef USE_PAGE6
+ lda MOUSE_PM_BASE+1
+ and #$F8
+.endif
+ sta PMBASE
+
+ lda #62
+ sta SDMCTL
+
+ lda #1
+ sta GPRIOR
+
+ jmp update_colors
diff --git a/libsrc/atari/mcbtxtchar-char.s b/libsrc/atari/mcbtxtchar-char.s
new file mode 100644
index 000000000..1f0862129
--- /dev/null
+++ b/libsrc/atari/mcbtxtchar-char.s
@@ -0,0 +1,7 @@
+;
+; Default text mode mouse cursor character
+;
+; Christian Groessler, 11.04.2014
+;
+
+ .export mouse_txt_char : zp = 96 ; 'diamond' screen code
diff --git a/libsrc/atari/mcbtxtchar.s b/libsrc/atari/mcbtxtchar.s
new file mode 100644
index 000000000..90a25f673
--- /dev/null
+++ b/libsrc/atari/mcbtxtchar.s
@@ -0,0 +1,125 @@
+;
+; Text mode character mouse callbacks for the Ataris
+;
+; Christian Groessler, 03.01.2014
+;
+; derived from Apple2 version by
+; Oliver Schmidt, 22.09.2005
+;
+; All functions in this module should be interrupt safe, because they may
+; be called from an interrupt handler
+;
+
+ .export _mouse_txt_callbacks
+ .importzp tmp4
+ .import mul40,loc_tmp
+ .importzp mouse_txt_char ; screen code of mouse cursor
+
+ .include "atari.inc"
+
+; ------------------------------------------------------------------------
+
+ .bss
+
+backup: .res 1
+visible:.res 1
+
+; ------------------------------------------------------------------------
+
+ .segment "EXTZP" : zeropage
+scrptr: .res 2
+
+; ------------------------------------------------------------------------
+
+
+ .rodata
+
+ ; Callback structure
+_mouse_txt_callbacks:
+ .addr hide
+ .addr show
+ .addr prep
+ .addr draw
+ .addr movex
+ .addr movey
+
+; ------------------------------------------------------------------------
+
+ .data
+
+; setcursor
+
+getcursor:
+column: ldy #$00 ; Patched at runtime
+ lda (scrptr),y
+ rts
+
+setcursor:
+column2:ldy #$00 ; Patched at runtime
+ sta (scrptr),y
+ rts
+
+; ------------------------------------------------------------------------
+
+ .code
+
+done:
+ rts
+
+; Hide the mouse cursor.
+hide:
+ dec visible
+
+prep:
+ jsr getcursor ; Get character at cursor position
+ cmp #mouse_txt_char ; "mouse" character
+ bne overwr ; no, probably program has overwritten it
+ lda backup ;
+ jmp setcursor ; Draw character
+overwr: sta backup
+ rts
+
+; Show the mouse cursor.
+show:
+ inc visible
+
+draw:
+ lda visible
+ beq done
+ jsr getcursor ; Cursor visible at current position?
+ sta backup ; Save character at cursor position
+ lda #mouse_txt_char
+ jmp setcursor ; Draw cursor
+
+
+; Move the mouse cursor x position to the value in A/X.
+movex:
+ cpx #1
+ ror a
+ lsr a ; convert to character position
+ lsr a
+ sta column+1
+ sta column2+1
+ rts
+
+; Move the mouse cursor y position to the value in A/X.
+movey:
+ tax
+ ldy tmp4 ; mul40 uses tmp4
+ lda loc_tmp ; and this local variable
+ pha
+ txa ; get parameter back
+ lsr a ; convert y position to character line
+ lsr a
+ lsr a
+ jsr mul40
+ clc
+ adc SAVMSC
+ sta scrptr
+ txa
+ adc SAVMSC+1
+ sta scrptr+1
+ pla
+ sta loc_tmp
+ sty tmp4
+ rts
diff --git a/libsrc/atari/mouseref.s b/libsrc/atari/mouseref.s
new file mode 100644
index 000000000..b75df93d1
--- /dev/null
+++ b/libsrc/atari/mouseref.s
@@ -0,0 +1,13 @@
+;
+; Christian Groessler, 2014-04-22
+;
+
+ .export mouse_libref
+
+.ifdef __ATARIXL__
+ .import set_VTIMR1_handler
+mouse_libref := set_VTIMR1_handler
+.else
+ .import _exit
+mouse_libref := _exit
+.endif
diff --git a/libsrc/atari/ser_libref.s b/libsrc/atari/serref.s
similarity index 58%
rename from libsrc/atari/ser_libref.s
rename to libsrc/atari/serref.s
index 4b5c58508..89ef1e519 100644
--- a/libsrc/atari/ser_libref.s
+++ b/libsrc/atari/serref.s
@@ -1,7 +1,12 @@
+;
+; Christian Groessler, 2014-04-22
+;
- .include "atari.inc"
+ .include "atari.inc"
- .import _close, pushax, popax
+ .export ser_libref
+
+ .import _close, pushax, popax
.import findfreeiocb
.import __do_oserror
.import fddecusage
@@ -10,19 +15,19 @@
.import clriocb
.import newfd
- .export atari_ser_libref
+ser_libref := atari_ser_libref
.rodata
atari_ser_libref:
- .word newfd
- .word _close
- .word pushax
- .word popax
+ .word newfd
+ .word _close
+ .word pushax
+ .word popax
.word findfreeiocb
.word __do_oserror
.word fddecusage
.word fdtoiocb
.word __inviocb
.word clriocb
- .word CIOV
+ .word CIOV
diff --git a/libsrc/cbm/diskinit.s b/libsrc/cbm/diskinit.s
index d84123a06..8a83a0212 100644
--- a/libsrc/cbm/diskinit.s
+++ b/libsrc/cbm/diskinit.s
@@ -21,7 +21,7 @@
tax
jsr isdisk
bcc open
- lda #9 ; "Ilegal device"
+ lda #9 ; "Illegal device"
rts
; Open channel
diff --git a/libsrc/cbm/oserrlist.s b/libsrc/cbm/oserrlist.s
index c85723910..b856ed0a8 100644
--- a/libsrc/cbm/oserrlist.s
+++ b/libsrc/cbm/oserrlist.s
@@ -48,7 +48,7 @@ __sys_oserrlist:
sys_oserr_entry 6, "File not input"
sys_oserr_entry 7, "File not output"
sys_oserr_entry 8, "Filename missing"
- sys_oserr_entry 9, "Ilegal device"
+ sys_oserr_entry 9, "Illegal device"
sys_oserr_entry 20, "Read error"
sys_oserr_entry 21, "Read error"
sys_oserr_entry 22, "Read error"
diff --git a/libsrc/cbm/oserror.s b/libsrc/cbm/oserror.s
index 29980548a..6df0d6711 100644
--- a/libsrc/cbm/oserror.s
+++ b/libsrc/cbm/oserror.s
@@ -40,7 +40,7 @@ ErrTab:
.byte 6, EINVAL ; File not input
.byte 7, EINVAL ; File not output
.byte 8, EINVAL ; Filename missing
- .byte 9, ENODEV ; Ilegal device
+ .byte 9, ENODEV ; Illegal device
; .byte 20, ; Read error
; .byte 21, ; Read error
; .byte 22, ; Read error
diff --git a/libsrc/cbm/syschdir.s b/libsrc/cbm/syschdir.s
index 78b2df82d..9361d56f0 100644
--- a/libsrc/cbm/syschdir.s
+++ b/libsrc/cbm/syschdir.s
@@ -74,7 +74,7 @@ init: txa
; Return with error in A
-err: lda #9 ; "Ilegal device"
+err: lda #9 ; "Illegal device"
done: rts
.endproc
@@ -92,4 +92,4 @@ done: rts
@L0: cmp #10
rts
-.endproc
\ No newline at end of file
+.endproc
diff --git a/libsrc/cbm510/mainargs.s b/libsrc/cbm510/mainargs.s
index 7ed8d46f4..542b1ec65 100644
--- a/libsrc/cbm510/mainargs.s
+++ b/libsrc/cbm510/mainargs.s
@@ -1,24 +1,156 @@
+; mainargs.s
;
-; Ullrich von Bassewitz, 2003-03-07
+; 2003-03-07, Ullrich von Bassewitz,
+; based on code from Stefan A. Haubenthal,
+; 2005-02-26, Ullrich von Bassewitz
+; 2014-04-02, Greg King
;
-; Setup arguments for main
+; Scan a group of arguments that are in BASIC's input-buffer.
+; Build an array that points to the beginning of each argument.
+; Send, to main(), that array and the count of the arguments.
;
-
+; Command-lines look like these lines:
+;
+; run
+; run : rem
+; run:rem arg1 " arg 2 is quoted " arg3 "" arg5
+;
+; "run" and "rem" are entokenned; the args. are not. Leading and trailing
+; spaces outside of quotes are ignored.
+;
+; TO-DO:
+; - The "file-name" might be a path-name; don't copy the directory-components.
+; - Add a control-character quoting mechanism.
.constructor initmainargs, 24
.import __argc, __argv
+ .import sys_bank, restore_bank
+ .import sysp0:zp, ptr1:zp
+
+ .include "cbm510.inc"
+ .macpack generic
-;---------------------------------------------------------------------------
+
+MAXARGS = 10 ; Maximum number of arguments allowed
+REM = $8f ; BASIC token-code
+NAME_LEN = 16 ; maximum length of command-name
+
; Get possible command-line arguments. Goes into the special INIT segment,
-; which may be reused after the startup code is run
-
+; which may be reused after the startup code is run.
+;
.segment "INIT"
-.proc initmainargs
+initmainargs:
+; Assume that the program was loaded, a moment ago, by the traditional LOAD
+; statement. Save the "most-recent filename" as argument #0.
+; Because the buffer, that we're copying into, was zeroed out,
+; we don't need to add a NUL character.
+;
+ jsr sys_bank
+ ldy #FNAM
+ lda (sysp0),y ; Get file-name pointer from system bank
+ sta ptr1
+ iny
+ lda (sysp0),y
+ sta ptr1+1
+ iny ; FNAM_BANK
+ lda (sysp0),y
+ tax
+ ldy #FNAM_LEN
+ lda (sysp0),y
+ tay
+ stx IndReg ; Look for name in correct bank
+ cpy #NAME_LEN + 1
+ blt L1
+ ldy #NAME_LEN - 1 ; limit the length
+L0: lda (ptr1),y
+ sta name,y
+L1: dey
+ bpl L0
+ jsr restore_bank
+ inc __argc ; argc always is equal to at least 1
+
+; Find a "rem" token.
+;
+ ldx #0
+L2: lda BASIC_BUF,x
+ bze done ; no "rem," no args.
+ inx
+ cmp #REM
+ bne L2
+ ldy #1 * 2
+
+; Find the next argument.
+;
+next: lda BASIC_BUF,x
+ bze done ; End of line reached
+ inx
+ cmp #' ' ; Skip leading spaces
+ beq next ;
+
+; Found start of next argument. We've incremented the pointer in X already, so
+; it points to the second character of the argument. That is useful because we
+; will check now for a quoted argument; in which case, we will have to skip that
+; first character.
+;
+found: cmp #'"' ; Is the argument quoted?
+ beq setterm ; Jump if so
+ dex ; Reset pointer to first argument character
+ lda #' ' ; A space ends the argument
+setterm:sta term ; Set end-of-argument marker
+
+; Now, store a pointer to the argument into the next slot.
+;
+ txa ; Get low byte
+ add #0
+ adc #>BASIC_BUF
+ sta argv+1,y
+ iny
+ iny
+ inc __argc ; Found another arg
+
+; Search for the end of the argument.
+;
+argloop:lda BASIC_BUF,x
+ bze done
+ inx
+ cmp term
+ bne argloop
+
+; We've found the end of the argument. X points one character behind it, and
+; A contains the terminating character. To make the argument a valid C string,
+; replace the terminating character by a zero.
+;
+ lda #0
+ sta BASIC_BUF-1,x
+
+; Check if the maximum number of command-line arguments is reached. If not,
+; parse the next one.
+;
+ lda __argc ; Get low byte of argument count
+ cmp #MAXARGS ; Maximum number of arguments reached?
+ blt next ; Parse next one if not
+
+; (The last vector in argv[] already is NULL.)
+;
+done: lda #argv
+ sta __argv
+ stx __argv + 1
rts
-.endproc
-
+; These arrays are zeroed before initmainargs is called.
+; char name[16+1];
+; char* argv[MAXARGS+1]={name};
+;
+.bss
+term: .res 1
+name: .res NAME_LEN + 1
+.data
+argv: .addr name
+ .res MAXARGS * 2, 0
diff --git a/libsrc/cbm610/mainargs.s b/libsrc/cbm610/mainargs.s
index 7ed8d46f4..9b9aea650 100644
--- a/libsrc/cbm610/mainargs.s
+++ b/libsrc/cbm610/mainargs.s
@@ -1,24 +1,156 @@
+; mainargs.s
;
-; Ullrich von Bassewitz, 2003-03-07
+; 2003-03-07, Ullrich von Bassewitz,
+; based on code from Stefan A. Haubenthal,
+; 2005-02-26, Ullrich von Bassewitz
+; 2014-04-02, Greg King
;
-; Setup arguments for main
+; Scan a group of arguments that are in BASIC's input-buffer.
+; Build an array that points to the beginning of each argument.
+; Send, to main(), that array and the count of the arguments.
;
-
+; Command-lines look like these lines:
+;
+; run
+; run : rem
+; run:rem arg1 " arg 2 is quoted " arg3 "" arg5
+;
+; "run" and "rem" are entokenned; the args. are not. Leading and trailing
+; spaces outside of quotes are ignored.
+;
+; TO-DO:
+; - The "file-name" might be a path-name; don't copy the directory-components.
+; - Add a control-character quoting mechanism.
.constructor initmainargs, 24
.import __argc, __argv
+ .import sys_bank, restore_bank
+ .import sysp0:zp, ptr1:zp
+
+ .include "cbm610.inc"
+ .macpack generic
-;---------------------------------------------------------------------------
+
+MAXARGS = 10 ; Maximum number of arguments allowed
+REM = $8f ; BASIC token-code
+NAME_LEN = 16 ; maximum length of command-name
+
; Get possible command-line arguments. Goes into the special INIT segment,
-; which may be reused after the startup code is run
-
+; which may be reused after the startup code is run.
+;
.segment "INIT"
-.proc initmainargs
+initmainargs:
+; Assume that the program was loaded, a moment ago, by the traditional LOAD
+; statement. Save the "most-recent filename" as argument #0.
+; Because the buffer, that we're copying into, was zeroed out,
+; we don't need to add a NUL character.
+;
+ jsr sys_bank
+ ldy #FNAM
+ lda (sysp0),y ; Get file-name pointer from system bank
+ sta ptr1
+ iny
+ lda (sysp0),y
+ sta ptr1+1
+ iny ; FNAM_BANK
+ lda (sysp0),y
+ tax
+ ldy #FNAM_LEN
+ lda (sysp0),y
+ tay
+ stx IndReg ; Look for name in correct bank
+ cpy #NAME_LEN + 1
+ blt L1
+ ldy #NAME_LEN - 1 ; limit the length
+L0: lda (ptr1),y
+ sta name,y
+L1: dey
+ bpl L0
+ jsr restore_bank
+ inc __argc ; argc always is equal to at least 1
+
+; Find a "rem" token.
+;
+ ldx #0
+L2: lda BASIC_BUF,x
+ bze done ; no "rem," no args.
+ inx
+ cmp #REM
+ bne L2
+ ldy #1 * 2
+
+; Find the next argument.
+;
+next: lda BASIC_BUF,x
+ bze done ; End of line reached
+ inx
+ cmp #' ' ; Skip leading spaces
+ beq next ;
+
+; Found start of next argument. We've incremented the pointer in X already, so
+; it points to the second character of the argument. That is useful because we
+; will check now for a quoted argument; in which case, we will have to skip that
+; first character.
+;
+found: cmp #'"' ; Is the argument quoted?
+ beq setterm ; Jump if so
+ dex ; Reset pointer to first argument character
+ lda #' ' ; A space ends the argument
+setterm:sta term ; Set end-of-argument marker
+
+; Now, store a pointer to the argument into the next slot.
+;
+ txa ; Get low byte
+ add #0
+ adc #>BASIC_BUF
+ sta argv+1,y
+ iny
+ iny
+ inc __argc ; Found another arg
+
+; Search for the end of the argument.
+;
+argloop:lda BASIC_BUF,x
+ bze done
+ inx
+ cmp term
+ bne argloop
+
+; We've found the end of the argument. X points one character behind it, and
+; A contains the terminating character. To make the argument a valid C string,
+; replace the terminating character by a zero.
+;
+ lda #0
+ sta BASIC_BUF-1,x
+
+; Check if the maximum number of command-line arguments is reached. If not,
+; parse the next one.
+;
+ lda __argc ; Get low byte of argument count
+ cmp #MAXARGS ; Maximum number of arguments reached?
+ blt next ; Parse next one if not
+
+; (The last vector in argv[] already is NULL.)
+;
+done: lda #argv
+ sta __argv
+ stx __argv + 1
rts
-.endproc
-
+; These arrays are zeroed before initmainargs is called.
+; char name[16+1];
+; char* argv[MAXARGS+1]={name};
+;
+.bss
+term: .res 1
+name: .res NAME_LEN + 1
+.data
+argv: .addr name
+ .res MAXARGS * 2, 0
diff --git a/libsrc/common/cc65_umul8x8r16.s b/libsrc/common/cc65_umul8x8r16.s
new file mode 100644
index 000000000..5cbb4f8b0
--- /dev/null
+++ b/libsrc/common/cc65_umul8x8r16.s
@@ -0,0 +1,23 @@
+;
+; Oliver Schmidt, 2014-03-27
+;
+; CC65 library: 8x8 => 16 unsigned multiplication
+;
+
+ .export _cc65_umul8x8r16
+ .import umul8x8r16, popa
+
+ .include "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 8x8 => 16 unsigned multiplication routine.
+
+
+.proc _cc65_umul8x8r16
+
+ sta ptr1
+ jsr popa
+ jmp umul8x8r16
+
+.endproc
diff --git a/samples/Makefile b/samples/Makefile
index a17288ced..79988ea70 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -43,6 +43,25 @@ endif
# This one comes with VICE
C1541 = c1541
+# --------------------------------------------------------------------------
+# System dependent settings
+
+# The Apple machines need the start address adjusted when using TGI
+LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
+LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
+
+# The Apple ][ needs the start address adjusted for the mousetest
+LDFLAGS_mousetest_apple2 = --start-addr 0x4000
+
+# The atarixl target needs the start address adjusted when using TGI
+LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
+LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
+
+# The atari target needs to reserve some memory when using TGI
+LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
+LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
# --------------------------------------------------------------------------
# Generic rules
@@ -59,9 +78,10 @@ C1541 = c1541
@echo $<
@$(AS) $(AFLAGS) -t $(SYS) $<
-.o:
- @$(LD) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
+.PRECIOUS: %.o
+.o:
+ @$(LD) $(LDFLAGS_$(basename $@)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
# --------------------------------------------------------------------------
# List of executables. This list could be made target dependent by checking
@@ -88,62 +108,6 @@ EXELIST = ascii \
.PHONY: all
all: $(EXELIST)
-ascii: ascii.o
-
-diodemo: diodemo.o
-
-fire: fire.o
-
-gunzip65: gunzip65.o
-
-hello: hello.o
-
-# The Apple machines need the start address adjusted for the mandelbrot demo
-ifeq "$(SYS)" "apple2"
-mandelbrot: mandelbrot.o
- @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-mandelbrot: mandelbrot.o
- @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-mandelbrot: mandelbrot.o
-endif
-endif
-
-# The Apple ][ needs the start address adjusted for the mousetest
-ifeq "$(SYS)" "apple2"
-mousetest: mousetest.o
- @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-mousetest: mousetest.o
-endif
-
-multdemo: multidemo.o
- @$(LD) -o $@ -m $@.map -C $(SYS)-overlay.cfg $^ $(CLIB)
-
-nachtm: nachtm.o
-
-ovrldemo: overlaydemo.o
- @$(LD) -o $@ -m $@.map -C $(SYS)-overlay.cfg $^ $(CLIB)
-
-plasma: plasma.o
-
-sieve: sieve.o
-
-# The Apple machines need the start address adjusted for the tgidemo
-ifeq "$(SYS)" "apple2"
-tgidemo: tgidemo.o
- @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-tgidemo: tgidemo.o
- @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-tgidemo: tgidemo.o
-endif
-endif
-
# --------------------------------------------------------------------------
# Rule to make a disk with all samples. Needs the c1541 program that comes
# with the VICE emulator.
diff --git a/samples/tgidemo.c b/samples/tgidemo.c
index a7e3b10f6..a08020640 100644
--- a/samples/tgidemo.c
+++ b/samples/tgidemo.c
@@ -5,7 +5,6 @@
#include
#include
#include
-#include
diff --git a/src/Makefile b/src/Makefile
index 2c2267ae7..5aafc4bb8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,6 +27,17 @@ LD65_LIB = $(datadir)/lib
LD65_OBJ = $(datadir)/lib
LD65_CFG = $(datadir)/cfg
+ifdef CMD_EXE
+ NULLDEV = nul:
+ DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
+ MKDIR = mkdir $(subst /,\,$1)
+ RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
+else
+ NULLDEV = /dev/null
+ MKDIR = mkdir -p $1
+ RMDIR = $(RM) -r $1
+endif
+
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
@@ -39,13 +50,15 @@ ifdef USER_CFLAGS
$(info USER_CFLAGS: $(USER_CFLAGS))
endif
-ifndef GIT_SHA
- GIT_SHA := $(if $(wildcard ../.git),$(shell git rev-parse --short HEAD))
+ifdef GIT_SHA
+ $(info GIT_SHA: $(GIT_SHA))
+else
+ GIT_SHA := $(shell git rev-parse --short HEAD 2>$(NULLDEV))
ifneq ($(words $(GIT_SHA)),1)
GIT_SHA := N/A
+ $(info GIT_SHA: N/A)
endif
endif
-$(info GIT_SHA: $(GIT_SHA))
CFLAGS += -MMD -MP -O -I common \
-Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
@@ -62,15 +75,6 @@ ifdef CROSS_COMPILE
EXE_SUFFIX=.exe
endif
-ifdef CMD_EXE
- DIRLIST = $(strip $(foreach dir,$1,$(wildcard $(dir))))
- MKDIR = mkdir $(subst /,\,$1)
- RMDIR = $(if $(DIRLIST),rmdir /s /q $(subst /,\,$(DIRLIST)))
-else
- MKDIR = mkdir -p $1
- RMDIR = $(RM) -r $1
-endif
-
all bin: $(PROGS)
mostlyclean:
diff --git a/src/cc65/shiftexpr.h b/src/cc65/shiftexpr.h
index 281710ff8..2a000fd58 100644
--- a/src/cc65/shiftexpr.h
+++ b/src/cc65/shiftexpr.h
@@ -34,7 +34,7 @@
#ifndef SHIFTEXPR_H
-#define SHIFTEXPT_H
+#define SHIFTEXPR_H
diff --git a/src/ld65/exports.c b/src/ld65/exports.c
index 9caa2ba57..937883d0d 100644
--- a/src/ld65/exports.c
+++ b/src/ld65/exports.c
@@ -870,8 +870,8 @@ static char GetAddrSizeCode (unsigned char AddrSize)
-void PrintExportMap (FILE* F)
-/* Print an export map to the given file */
+void PrintExportMapByName (FILE* F)
+/* Print an export map, sorted by symbol name, to the given file */
{
unsigned I;
unsigned Count;
@@ -902,6 +902,61 @@ void PrintExportMap (FILE* F)
+static int CmpExpValue (const void* I1, const void* I2)
+/* Compare function for qsort */
+{
+ long V1 = GetExportVal (ExpPool [*(unsigned *)I1]);
+ long V2 = GetExportVal (ExpPool [*(unsigned *)I2]);
+
+ return V1 < V2 ? -1 : V1 == V2 ? 0 : 1;
+}
+
+
+
+void PrintExportMapByValue (FILE* F)
+/* Print an export map, sorted by symbol value, to the given file */
+{
+ unsigned I;
+ unsigned Count;
+ unsigned *ExpValXlat;
+
+ /* Create a translation table where the symbols are sorted by value. */
+ ExpValXlat = xmalloc (ExpCount * sizeof (unsigned));
+ for (I = 0; I < ExpCount; ++I) {
+ /* Initialize table with current sort order. */
+ ExpValXlat [I] = I;
+ }
+
+ /* Sort them by value */
+ qsort (ExpValXlat, ExpCount, sizeof (unsigned), CmpExpValue);
+
+ /* Print all exports */
+ Count = 0;
+ for (I = 0; I < ExpCount; ++I) {
+ const Export* E = ExpPool [ExpValXlat [I]];
+
+ /* Print unreferenced symbols only if explictly requested */
+ if (VerboseMap || E->ImpCount > 0 || SYM_IS_CONDES (E->Type)) {
+ fprintf (F,
+ "%-25s %06lX %c%c%c%c ",
+ GetString (E->Name),
+ GetExportVal (E),
+ E->ImpCount? 'R' : ' ',
+ SYM_IS_LABEL (E->Type)? 'L' : 'E',
+ GetAddrSizeCode ((unsigned char) E->AddrSize),
+ SYM_IS_CONDES (E->Type)? 'I' : ' ');
+ if (++Count == 2) {
+ Count = 0;
+ fprintf (F, "\n");
+ }
+ }
+ }
+ fprintf (F, "\n");
+ xfree (ExpValXlat);
+}
+
+
+
void PrintImportMap (FILE* F)
/* Print an import map to the given file */
{
diff --git a/src/ld65/exports.h b/src/ld65/exports.h
index 2b7c55bed..2c0bbca95 100644
--- a/src/ld65/exports.h
+++ b/src/ld65/exports.h
@@ -186,8 +186,11 @@ void CheckUnresolvedImports (ExpCheckFunc F, void* Data);
* called (see the comments on ExpCheckFunc in the data section).
*/
-void PrintExportMap (FILE* F);
-/* Print an export map to the given file */
+void PrintExportMapByName (FILE* F);
+/* Print an export map to the given file (sorted by symbol name) */
+
+void PrintExportMapByValue (FILE* F);
+/* Print an export map to the given file (sorted by export value) */
void PrintImportMap (FILE* F);
/* Print an import map to the given file */
diff --git a/src/ld65/main.c b/src/ld65/main.c
index b47831c39..e68ebc9f7 100644
--- a/src/ld65/main.c
+++ b/src/ld65/main.c
@@ -80,6 +80,24 @@
static unsigned ObjFiles = 0; /* Count of object files linked */
static unsigned LibFiles = 0; /* Count of library files linked */
+/* struct InputFile.Type definitions */
+#define INPUT_FILES_FILE 0 /* Entry is a file (unknown type) */
+#define INPUT_FILES_FILE_OBJ 1 /* Entry is a object file */
+#define INPUT_FILES_FILE_LIB 2 /* Entry is a library file */
+#define INPUT_FILES_SGROUP 3 /* Entry is 'StartGroup' */
+#define INPUT_FILES_EGROUP 4 /* Entry is 'EndGroup' */
+
+#define MAX_INPUTFILES 256
+
+/* Array of inputs (libraries and object files) */
+static struct InputFile {
+ const char *FileName;
+ unsigned Type;
+} *InputFiles;
+static unsigned InputFilesCount = 0;
+static const char *CmdlineCfgFile = NULL,
+ *CmdlineTarget = NULL;
+
/*****************************************************************************/
@@ -390,7 +408,10 @@ static void OptHelp (const char* Opt attribute ((unused)),
static void OptLib (const char* Opt attribute ((unused)), const char* Arg)
/* Link a library */
{
- LinkFile (Arg, FILETYPE_LIB);
+ InputFiles[InputFilesCount].Type = INPUT_FILES_FILE_LIB;
+ InputFiles[InputFilesCount].FileName = Arg;
+ if (++InputFilesCount >= MAX_INPUTFILES)
+ Error ("Too many input files");
}
@@ -406,6 +427,9 @@ static void OptLibPath (const char* Opt attribute ((unused)), const char* Arg)
static void OptMapFile (const char* Opt attribute ((unused)), const char* Arg)
/* Give the name of the map file */
{
+ if (MapFileName) {
+ Error ("Cannot use -m twice");
+ }
MapFileName = Arg;
}
@@ -426,7 +450,10 @@ static void OptModuleId (const char* Opt, const char* Arg)
static void OptObj (const char* Opt attribute ((unused)), const char* Arg)
/* Link an object file */
{
- LinkFile (Arg, FILETYPE_OBJ);
+ InputFiles[InputFilesCount].Type = INPUT_FILES_FILE_OBJ;
+ InputFiles[InputFilesCount].FileName = Arg;
+ if (++InputFilesCount >= MAX_INPUTFILES)
+ Error ("Too many input files");
}
@@ -439,16 +466,14 @@ static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg)
-static void OptOutputName (const char* Opt, const char* Arg)
+static void OptOutputName (const char* Opt attribute ((unused)), const char* Arg)
/* Give the name of the output file */
{
- /* If the name of the output file has been used in the config before
- * (by using %O) we're actually changing it later, which - in most cases -
- * gives unexpected results, so emit a warning in this case.
- */
- if (OutputNameUsed) {
- Warning ("Option `%s' should precede options `-t' or `-C'", Opt);
+ static int OutputNameSeen = 0;
+ if (OutputNameSeen) {
+ Error ("Cannot use -o twice");
}
+ OutputNameSeen = 1;
OutputName = Arg;
}
@@ -457,6 +482,9 @@ static void OptOutputName (const char* Opt, const char* Arg)
static void OptStartAddr (const char* Opt, const char* Arg)
/* Set the default start address */
{
+ if (HaveStartAddr) {
+ Error ("Cannot use -S twice");
+ }
StartAddr = CvtNumber (Opt, Arg);
HaveStartAddr = 1;
}
@@ -520,16 +548,61 @@ static void OptVersion (const char* Opt attribute ((unused)),
-int main (int argc, char* argv [])
-/* Assembler main program */
+static void CmdlOptStartGroup (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Remember 'start group' occurrence in input files array */
+{
+ InputFiles[InputFilesCount].Type = INPUT_FILES_SGROUP;
+ InputFiles[InputFilesCount].FileName = Arg; /* Unused */
+ if (++InputFilesCount >= MAX_INPUTFILES)
+ Error ("Too many input files");
+}
+
+
+
+static void CmdlOptEndGroup (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Remember 'end group' occurrence in input files array */
+{
+ InputFiles[InputFilesCount].Type = INPUT_FILES_EGROUP;
+ InputFiles[InputFilesCount].FileName = Arg; /* Unused */
+ if (++InputFilesCount >= MAX_INPUTFILES)
+ Error ("Too many input files");
+}
+
+
+
+static void CmdlOptConfig (const char* Opt attribute ((unused)), const char* Arg)
+/* Set 'config file' command line parameter */
+{
+ if (CmdlineCfgFile || CmdlineTarget) {
+ Error ("Cannot use -C/-t twice");
+ }
+ CmdlineCfgFile = Arg;
+}
+
+
+
+static void CmdlOptTarget (const char* Opt attribute ((unused)), const char* Arg)
+/* Set 'target' command line parameter */
+{
+ if (CmdlineCfgFile || CmdlineTarget) {
+ Error ("Cannot use -C/-t twice");
+ }
+ CmdlineTarget = Arg;
+}
+
+
+
+static void ParseCommandLine(void)
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--cfg-path", 1, OptCfgPath },
- { "--config", 1, OptConfig },
+ { "--config", 1, CmdlOptConfig },
{ "--dbgfile", 1, OptDbgFile },
{ "--define", 1, OptDefine },
- { "--end-group", 0, OptEndGroup },
+ { "--end-group", 0, CmdlOptEndGroup },
{ "--force-import", 1, OptForceImport },
{ "--help", 0, OptHelp },
{ "--lib", 1, OptLib },
@@ -539,27 +612,18 @@ int main (int argc, char* argv [])
{ "--obj", 1, OptObj },
{ "--obj-path", 1, OptObjPath },
{ "--start-addr", 1, OptStartAddr },
- { "--start-group", 0, OptStartGroup },
- { "--target", 1, OptTarget },
+ { "--start-group", 0, CmdlOptStartGroup },
+ { "--target", 1, CmdlOptTarget },
{ "--version", 0, OptVersion },
};
unsigned I;
- unsigned MemoryAreaOverflows;
+ unsigned LabelFileGiven = 0;
- /* Initialize the cmdline module */
- InitCmdLine (&argc, &argv, "ld65");
+ /* Allocate memory for input file array */
+ InputFiles = xmalloc (MAX_INPUTFILES * sizeof (struct InputFile));
- /* Initialize the input file search paths */
- InitSearchPaths ();
-
- /* Initialize the string pool */
- InitStrPool ();
-
- /* Initialize the type pool */
- InitTypePool ();
-
- /* Check the parameters */
+ /* Defer setting of config/target and input files until all options are parsed */
I = 1;
while (I < ArgCount) {
@@ -577,11 +641,11 @@ int main (int argc, char* argv [])
break;
case '(':
- OptStartGroup (Arg, 0);
+ CmdlOptStartGroup (Arg, 0);
break;
case ')':
- OptEndGroup (Arg, 0);
+ CmdlOptEndGroup (Arg, 0);
break;
case 'h':
@@ -594,14 +658,11 @@ int main (int argc, char* argv [])
break;
case 'o':
- OptOutputName (Arg, GetArg (&I, 2));
+ OptOutputName (NULL, GetArg (&I, 2));
break;
case 't':
- if (CfgAvail ()) {
- Error ("Cannot use -C/-t twice");
- }
- OptTarget (Arg, GetArg (&I, 2));
+ CmdlOptTarget (Arg, GetArg (&I, 2));
break;
case 'u':
@@ -617,7 +678,7 @@ int main (int argc, char* argv [])
break;
case 'C':
- OptConfig (Arg, GetArg (&I, 2));
+ CmdlOptConfig (Arg, GetArg (&I, 2));
break;
case 'D':
@@ -626,9 +687,17 @@ int main (int argc, char* argv [])
case 'L':
switch (Arg [2]) {
- /* ## The first one is obsolete and will go */
- case 'n': LabelFileName = GetArg (&I, 3); break;
- default: OptLibPath (Arg, GetArg (&I, 2)); break;
+ case 'n':
+ /* ## This one is obsolete and will go */
+ if (LabelFileGiven) {
+ Error ("Cannot use -Ln twice");
+ }
+ LabelFileGiven = 1;
+ LabelFileName = GetArg (&I, 3);
+ break;
+ default:
+ OptLibPath (Arg, GetArg (&I, 2));
+ break;
}
break;
@@ -648,7 +717,10 @@ int main (int argc, char* argv [])
} else {
/* A filename */
- LinkFile (Arg, FILETYPE_UNKNOWN);
+ InputFiles[InputFilesCount].Type = INPUT_FILES_FILE;
+ InputFiles[InputFilesCount].FileName = Arg;
+ if (++InputFilesCount >= MAX_INPUTFILES)
+ Error ("Too many input files");
}
@@ -656,6 +728,61 @@ int main (int argc, char* argv [])
++I;
}
+ if (CmdlineTarget) {
+ OptTarget (NULL, CmdlineTarget);
+ } else if (CmdlineCfgFile) {
+ OptConfig (NULL, CmdlineCfgFile);
+ }
+
+ /* Process input files */
+ for (I = 0; I < InputFilesCount; ++I) {
+ switch (InputFiles[I].Type) {
+ case INPUT_FILES_FILE:
+ LinkFile (InputFiles[I].FileName, FILETYPE_UNKNOWN);
+ break;
+ case INPUT_FILES_FILE_LIB:
+ LinkFile (InputFiles[I].FileName, FILETYPE_LIB);
+ break;
+ case INPUT_FILES_FILE_OBJ:
+ LinkFile (InputFiles[I].FileName, FILETYPE_OBJ);
+ break;
+ case INPUT_FILES_SGROUP:
+ OptStartGroup (NULL, 0);
+ break;
+ case INPUT_FILES_EGROUP:
+ OptEndGroup (NULL, 0);
+ break;
+ default:
+ abort ();
+ }
+ }
+
+ /* Free memory used for input file array */
+ xfree (InputFiles);
+}
+
+
+
+int main (int argc, char* argv [])
+/* Linker main program */
+{
+ unsigned MemoryAreaOverflows;
+
+ /* Initialize the cmdline module */
+ InitCmdLine (&argc, &argv, "ld65");
+
+ /* Initialize the input file search paths */
+ InitSearchPaths ();
+
+ /* Initialize the string pool */
+ InitStrPool ();
+
+ /* Initialize the type pool */
+ InitTypePool ();
+
+ /* Parse the command line */
+ ParseCommandLine ();
+
/* Check if we had any object files */
if (ObjFiles == 0) {
Error ("No object files to link");
diff --git a/src/ld65/mapfile.c b/src/ld65/mapfile.c
index 6b13e46ec..8ca1a388f 100644
--- a/src/ld65/mapfile.c
+++ b/src/ld65/mapfile.c
@@ -111,11 +111,17 @@ void CreateMapFile (int ShortMap)
/* The remainder is not written for short map files */
if (!ShortMap) {
- /* Write the exports list */
+ /* Write the exports list by name */
fprintf (F, "\n\n"
- "Exports list:\n"
- "-------------\n");
- PrintExportMap (F);
+ "Exports list by name:\n"
+ "---------------------\n");
+ PrintExportMapByName (F);
+
+ /* Write the exports list by value */
+ fprintf (F, "\n\n"
+ "Exports list by value:\n"
+ "----------------------\n");
+ PrintExportMapByValue (F);
/* Write the imports list */
fprintf (F, "\n\n"
diff --git a/testcode/lib/exec-test1.c b/testcode/lib/exec-test1.c
index e2548fb0a..ea74ee60a 100644
--- a/testcode/lib/exec-test1.c
+++ b/testcode/lib/exec-test1.c
@@ -1,5 +1,5 @@
/*
-** These programs test CC65's exec() program-chaining function.
+** These programs test cc65's exec() program-chaining function.
** exec-test1 runs exec-test2 -- that tests the loading and starting of another
** program. Then, exec-test2 runs arg-test -- that tests command-line argument
** passing.
diff --git a/testcode/lib/exec-test2.c b/testcode/lib/exec-test2.c
index e6c844a8e..a0aa82a3f 100644
--- a/testcode/lib/exec-test2.c
+++ b/testcode/lib/exec-test2.c
@@ -1,5 +1,5 @@
/*
-** These programs test CC65's exec() program-chaining function.
+** These programs test cc65's exec() program-chaining function.
** exec-test1 runs exec-test2 -- that tests the loading and starting of another
** program. Then, exec-test2 runs arg-test -- that tests command-line argument
** passing.