1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00

Updated the cx16 library to the ROM's prerelease 36.

This commit is contained in:
Greg King 2020-01-10 15:17:23 -05:00
parent 244dc358e5
commit b66f7272af
19 changed files with 357 additions and 214 deletions

View File

@ -1,11 +1,21 @@
; ;
; Olli Savia <ops@iki.fi> ; Olli Savia <ops@iki.fi>
; Greg King
; ;
; Commodore Kernal functions ; Commodore-compatibles Kernal functions
; ;
.if .def(__CX16__) .if .def(__CX16__)
; CX16 extended jump table ; CX16 extended jump table
CONSOLE_INIT := $FEDB
CONSOLE_PUT_CHAR := $FEDE
CONSOLE_GET_CHAR := $FEE1
MEMORY_FILL := $FEE4
MEMORY_COPY := $FEE7
MEMORY_CRC := $FEEA
MEMORY_DECOMPRESS := $FEED
SPRITE_SET_IMAGE := $FEF0
SPRITE_SET_POSITION := $FEF3
FB_INIT := $FEF6 FB_INIT := $FEF6
FB_GET_INFO := $FEF9 FB_GET_INFO := $FEF9
FB_SET_PALETTE := $FEFC FB_SET_PALETTE := $FEFC
@ -37,7 +47,8 @@
CLOCK_GET_DATE_TIME := $FF50 CLOCK_GET_DATE_TIME := $FF50
JOYSTICK_SCAN := $FF53 JOYSTICK_SCAN := $FF53
JOYSTICK_GET := $FF56 JOYSTICK_GET := $FF56
SCRMOD := $FF5F SCREEN_SET_MODE := $FF5F
SCREEN_SET_CHARSET := $FF62
MOUSE_CONFIG := $FF68 MOUSE_CONFIG := $FF68
MOUSE_GET := $FF6B MOUSE_GET := $FF6B
.endif .endif

View File

@ -1,5 +1,5 @@
; ;
; CX16 r35 definitions ; CX16 r36 definitions
; ;
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
@ -17,7 +17,8 @@
YELLOW YELLOW
ORANGE ORANGE
BROWN BROWN
LIGHTRED PINK
LIGHTRED = PINK
GRAY1 GRAY1
GRAY2 GRAY2
LIGHTGREEN LIGHTGREEN
@ -25,20 +26,81 @@
GRAY3 GRAY3
.endenum .endenum
; Special keys ; Special characters
.enum KEY .enum CH
F1 = $85 COLOR_SWAP = $01
F3 STOP = $03
F5 UNDERLINE
F7 WHITE
F2 BOLD
F4 BELL
F6 BACKSPACE
F8 TAB
F9 = $10 LINEFEED
F10 = $15 ITALIC
F11 OUTLINE
F12 ENTER
FONT_LOWER
FONT_ISO
F9
CURS_DOWN
REVERSE
HOME
DEL
F10
F11
F12
SHIFT_TAB
RED = $1C
CURS_RIGHT
GREEN
BLUE
LIRA = $5C
ORANGE = $81
RUN = $83
HELP
F1
F3
F5
F7
F2
F4
F6
F8
SHIFT_ENTER
FONT_UPPER
FONT_PET
BLACK
CURS_UP
ATTR_CLEAR
SCRN_CLEAR
INS
BROWN
PINK
LIGHTRED = PINK
GRAY1
GRAY2
LIGHTGREEN
LIGHTBLUE
GRAY3
PURPLE
VIOLET = PURPLE
CURS_LEFT
YELLOW
CYAN
SHIFT_SPACE
LTEE = $AB
LLCORNER = $AD
URCORNER
ULCORNER = $B0
BTEE
TTEE
RTEE
LRCORNER = $BD
HLINE = $C0
CROSS = $DB
VLINE = $DD
PI
.endenum .endenum
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
@ -162,10 +224,9 @@
.endstruct .endstruct
; Kernal ; Kernal
FNAM := $84 ; Pointer to filename KTEMP2 := $80 ; 2 bytes for temporary storage
KTEMP2 := $86 ; 2 bytes for temporary storage IMPARM := $82 ; Pointer for PRIMM function
IMPARM := $88 ; Pointer for PRIMM function FNAM := $8C ; Pointer to filename
SCREEN_PTR := $90 ; Pointer to current row on text screen (16 bits)
; BASIC ; BASIC
TXTPTR := $EE ; Pointer into BASIC source code TXTPTR := $EE ; Pointer into BASIC source code
@ -175,23 +236,25 @@ TXTPTR := $EE ; Pointer into BASIC source code
BASIC_BUF := $0200 ; Location of command-line BASIC_BUF := $0200 ; Location of command-line
BASIC_BUF_LEN = 81 ; Maximum length of command-line BASIC_BUF_LEN = 81 ; Maximum length of command-line
STATUS := $0275 ; Status from previous I/O operation SCREEN_MODE := $0262 ; Current screen mode (set by SCREEN_SET_MODE)
IN_DEV := $0279 ; Current input device number SCREEN_PTR := $0263 ; Pointer to current row on text screen (16 bits)
OUT_DEV := $027A ; Current output device number STATUS := $0286 ; Status from previous I/O operation
FNAM_LEN := $027D ; Length of filename IN_DEV := $028A ; Current input device number
SECADR := $027F ; Secondary address OUT_DEV := $028B ; Current output device number
DEVNUM := $0280 ; Device number FNAM_LEN := $028E ; Length of filename
SECADR := $0290 ; Secondary address
DEVNUM := $0291 ; Device number
CURS_COLOR := $0373 ; Color under the cursor CURS_COLOR := $0373 ; Color under the cursor
CHARCOLOR := $0377 ; Cursor's color nybbles (high: background, low: foreground) CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground)
RVS := $0378 ; Reverse flag RVS := $0377 ; Reverse flag
CURS_FLAG := $037C ; 1 = cursor off CURS_FLAG := $037B ; 1 = cursor off
CURS_BLINK := $037D ; Blink counter CURS_BLINK := $037C ; Blink counter
CURS_CHAR := $037E ; Character under the cursor CURS_CHAR := $037D ; Character under the cursor
CURS_STATE := $037F ; Cursor blink state CURS_STATE := $037E ; Cursor blink state
CURS_X := $0381 ; Cursor column CURS_X := $0380 ; Cursor column
CURS_Y := $0384 ; Cursor row CURS_Y := $0383 ; Cursor row
LLEN := $0387 ; Line length LLEN := $0386 ; Line length
NLINES := $0388 ; Number of screen lines NLINES := $0387 ; Number of screen lines
; BASIC ; BASIC
VARTAB := $03E3 ; Pointer to start of BASIC variables VARTAB := $03E3 ; Pointer to start of BASIC variables
@ -453,7 +516,7 @@ NMIVec := $0318
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Banked RAM and ROM ; Banked RAM and ROM
KEY_COUNT := $A00A ; (bank 0) Number of keys in input buffer KEY_COUNT := $A00B ; (bank 0) Number of keys in input buffer
TIMER := $A03E ; (bank 0) 60 Hz. timer (3 bytes, big-endian) TIMER := $A03E ; (bank 0) 60 Hz. timer (3 bytes, big-endian)
.struct BANK .struct BANK

View File

@ -46,9 +46,9 @@ file and linker config.
<sect>Memory layout<p> <sect>Memory layout<p>
cc65-generated programs with the default setup run with the I/O area, RAM bank cc65-generated programs with the default setup run with the I/O area, RAM bank
zero, and the Kernal ROM visible. That means that Kernal entry points can be one, and the Kernal ROM being visible. That means that Kernal entry points
called directly. The usable memory ranges are &dollar;0800 - &dollar;9EFF and can be called directly. The usable memory ranges are &dollar;0800 -
&dollar;A000 - &dollar;BFFF. &dollar;9EFF, &dollar;0400 - &dollar;07FF, and &dollar;A000 - &dollar;BFFF.
Special locations: Special locations:
@ -77,7 +77,7 @@ The ld65 linker comes with a default config. file for the Commander X16, which
is used via <tt/-t cx16/. The cx16 package comes with additional secondary is used via <tt/-t cx16/. The cx16 package comes with additional secondary
linker config. files which are used via <tt/-t cx16 -C &lt;configfile&gt;/. linker config. files which are used via <tt/-t cx16 -C &lt;configfile&gt;/.
Those files use 126 bytes in the zero page. (The rest of page zero is reserved Those files use 94 bytes in the zero page. (The rest of page zero is reserved
for Kernal and BASIC.) for Kernal and BASIC.)

View File

@ -17,9 +17,9 @@ the C functions available in the standard library.
<sect>Introduction<p> <sect>Introduction<p>
cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO cc65 is a C compiler for 6502-based systems. It implements a subset of the ISO
C standard plus additional functions specially crafted for 6502 systems or C standard plus additional functions specially crafted for 6502 systems or
just some of the supported machines. This function refrence describes the just some of the supported machines. This function reference describes the
available functions together with any limitations. available functions together with any limitations.
For an overview about the available libraries, their purpose, and any For an overview about the available libraries, their purpose, and any
@ -27,8 +27,8 @@ differences to the ISO standard, please have a look at the <url
url="library.html" name="cc65 Library Overview">. url="library.html" name="cc65 Library Overview">.
<em/Note:/ Standard C functions are listed here, but not described in detail. <em/Note:/ Standard C functions are listed here, but not described in detail.
Since these functions behave identical on all standard compliant systems, they Because those functions behave identically on all standard-compliant systems,
are described in any book covering standard C. they are described in any book covering standard C.
Each entry for a function contains a detailed description Each entry for a function contains a detailed description
@ -200,6 +200,7 @@ function.
<item><ref id="cbm_k_second" name="cbm_k_second"> <item><ref id="cbm_k_second" name="cbm_k_second">
<item><ref id="cbm_k_setlfs" name="cbm_k_setlfs"> <item><ref id="cbm_k_setlfs" name="cbm_k_setlfs">
<item><ref id="cbm_k_setnam" name="cbm_k_setnam"> <item><ref id="cbm_k_setnam" name="cbm_k_setnam">
<item><ref id="cbm_k_settim" name="cbm_k_settim">
<item><ref id="cbm_k_talk" name="cbm_k_talk"> <item><ref id="cbm_k_talk" name="cbm_k_talk">
<item><ref id="cbm_k_tksa" name="cbm_k_tksa"> <item><ref id="cbm_k_tksa" name="cbm_k_tksa">
<item><ref id="cbm_k_udtim" name="cbm_k_udtim"> <item><ref id="cbm_k_udtim" name="cbm_k_udtim">
@ -321,6 +322,7 @@ function.
<sect1><tt/cx16.h/<label id="cx16.h"><p> <sect1><tt/cx16.h/<label id="cx16.h"><p>
<itemize> <itemize>
<!-- <item><ref id="get_numbanks" name="get_numbanks"> -->
<!-- <item><ref id="get_ostype" name="get_ostype"> --> <!-- <item><ref id="get_ostype" name="get_ostype"> -->
<!-- <item><ref id="get_tv" name="get_tv"> --> <!-- <item><ref id="get_tv" name="get_tv"> -->
<!-- <item><ref id="set_tv" name="set_tv"> --> <!-- <item><ref id="set_tv" name="set_tv"> -->
@ -2281,6 +2283,9 @@ only be used in presence of a prototype.
</itemize> </itemize>
<tag/Availability/cc65 <tag/Availability/cc65
<tag/See also/ <tag/See also/
<ref id="cbm_k_load" name="cbm_k_load">,
<ref id="cbm_k_open" name="cbm_k_open">,
<ref id="cbm_k_save" name="cbm_k_save">,
<ref id="cbm_k_setnam" name="cbm_k_setnam"> <ref id="cbm_k_setnam" name="cbm_k_setnam">
<tag/Example/None. <tag/Example/None.
</descrip> </descrip>
@ -2302,9 +2307,34 @@ only be used in presence of a prototype.
</itemize> </itemize>
<tag/Availability/cc65 <tag/Availability/cc65
<tag/See also/ <tag/See also/
<ref id="cbm_k_open" name="cbm_k_open">,
<ref id="cbm_k_load" name="cbm_k_load">, <ref id="cbm_k_load" name="cbm_k_load">,
<ref id="cbm_k_save" name="cbm_k_save"> <ref id="cbm_k_open" name="cbm_k_open">,
<ref id="cbm_k_save" name="cbm_k_save">,
<ref id="cbm_k_setlfs" name="cbm_k_setlfs">
<tag/Example/None.
</descrip>
</quote>
<sect1>cbm_k_settim<label id="cbm_k_settim"><p>
<quote>
<descrip>
<tag/Function/Set the Jiffy clock.
<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
<tag/Declaration/<tt/void __fastcall__ cbm_k_settim (unsigned long timer);/
<tag/Description/This function changes the Jiffy clock to a different value.
That clock counts sixtieths of a second. It is used by the library's
<tt/clock()/ function. The Jiffy clock is updated by the Kernal's Interrupt
Service Routine.
<tag/Notes/<itemize>
<item>The function is available only as a fastcall function; therefore, it may
be used only in the presence of a prototype.
</itemize>
<tag/Availability/cc65
<tag/See also/
<ref id="cbm_k_udtim" name="cbm_k_udtim">,
<ref id="clock" name="clock">
<tag/Example/None. <tag/Example/None.
</descrip> </descrip>
</quote> </quote>
@ -2368,6 +2398,7 @@ then that ISR must call this function, in order to keep the clock valid.
<tag/Availability/cc65 <tag/Availability/cc65
<tag/See also/ <tag/See also/
<ref id="cbm_k_scnkey" name="cbm_k_scnkey">, <ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
<ref id="cbm_k_settim" name="cbm_k_settim">,
<ref id="clock" name="clock"> <ref id="clock" name="clock">
<tag/Example/None. <tag/Example/None.
</descrip> </descrip>
@ -2585,6 +2616,7 @@ changing values. (See the description of <tt/cbm_k_udtim()/.)
</itemize> </itemize>
<tag/Availability/ISO 9899 <tag/Availability/ISO 9899
<tag/See also/ <tag/See also/
<ref id="cbm_k_settim" name="cbm_k_settim">,
<ref id="cbm_k_udtim" name="cbm_k_udtim">, <ref id="cbm_k_udtim" name="cbm_k_udtim">,
<ref id="time" name="time"> <ref id="time" name="time">
<tag/Example/None. <tag/Example/None.

View File

@ -18,22 +18,22 @@ including a discussion of the differences to the ISO standard.
This file contains a short overview of the libraries available for the cc65 C This file contains a short overview of the libraries available for the cc65 C
compiler. Please have a look at the <url url="funcref.html" name="function compiler. Please have a look at the <url url="funcref.html" name="function
reference"> for a list function by function. Since the function reference is reference"> for a function-by-function list. Because the function reference is
not complete (I'm working on that) it may happen that you don't find a not complete (we're 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 specific function. In that case, have a look into the header files. All
functions, that are not defined by the ISO C standard have a short comment in functions, that are not defined by the ISO C standard, have a short comment in
the headers, explaining their use. the headers, explaining their use.
<sect>ISO C compatible library<p> <sect>ISO C compatible library<p>
The C library contains a large subset of the ISO C library. Functions are The C library contains a large subset of the ISO C library. Functions usually
usually missing in areas, where there is no support on typical 6502 systems. are missing in areas where there are no support on typical 6502 systems.
Wide character sets are an example for this. Wide-character sets are an example for that.
I will not go into detail about the ISO functions. If a function is not I will not go into detail about the ISO functions. If a function is not
mentioned here explicitly, expect it to be available and to behave as defined mentioned here explicitly, expect it to be available, and to behave as defined
in the C standard. in the C standard.
Functions that are <em/not/ available: Functions that are <em/not/ available:
@ -45,13 +45,13 @@ Functions that are <em/not/ available:
<p> <p>
<item>All functions that handle floating point numbers in some manner. <item>All functions that handle floating point numbers in some manner.
<p> <p>
<item>The <tt/ldiv/ function (cc65 is currently not able to return structs <item>The <tt/ldiv/ function (cc65 currently is not able to return structs,
with a size not equal to 1, 2 or 4 bytes by value). by value, with a size not equal to 1, 2, or 4 bytes).
<p> <p>
<item>All functions handling wide character strings. <item>All functions handling wide-character strings.
<p> <p>
<item>Signals and all related functions (having <tt/SIGSEGV/ would be <item>Signals and all related functions (having <tt/SIGSEGV/ would be
cool:-) cool. :-)
<p> <p>
<item><tt>setbuf/setvbuf</tt> <item><tt>setbuf/setvbuf</tt>
</itemize> </itemize>
@ -60,7 +60,7 @@ Functions not available on all supported systems:
<itemize> <itemize>
<item><tt>fopen/fread/fwrite/fclose/fputs/fgets/fscanf</tt>: The functions <item><tt>fopen/fread/fwrite/fclose/fputs/fgets/fscanf</tt>: The functions
are built on open/read/write/close. These latter functions are not available are built on open/read/write/close. Those latter functions are not available
on all systems. on all systems.
<p> <p>
<item><tt>ftell/fseek/fgetpos/fsetpos</tt>: Support depends on the <item><tt>ftell/fseek/fgetpos/fsetpos</tt>: Support depends on the
@ -69,94 +69,95 @@ Functions not available on all supported systems:
<item><tt>rename/remove/rewind</tt>: Support depends on the capabilities of <item><tt>rename/remove/rewind</tt>: Support depends on the capabilities of
the target machine. the target machine.
<p> <p>
<item><tt>time</tt>: Since many of the supported systems do not have a real <item><tt>time</tt>: Many of the supported systems don't have a real-time
time clock, which means that the <tt/time/ function is not available. Please clock, which means that the <tt/time/ function is not available. Please note
note that the other functions from <tt/time.h/ <em/are/ available. that the other functions from <tt/time.h/ <em/are/ available.
</itemize> </itemize>
Functions that are limited in any way: Functions that are limited in any way:
<itemize> <itemize>
<item><tt>strcspn/strpbrk/strspn</tt>: These functions have a length <item><tt>strcspn/strpbrk/strspn</tt>: Those functions have a length
limitation of 256 for the second string argument. Since this string gives a limitation of 256 for the second string argument. Since that string gives a
character set, and there are only 256 distinct characters, this shouldn't be character set, and there are only 256 distinct characters, that shouldn't be
a problem. a problem.
<p> <p>
<item><tt>getenv</tt>: Since there is no such thing as an environment on all <item><tt>getenv</tt>: Since there is no such thing as an environment on all
supported systems, the <tt/getenv/ function will always return a <tt/NULL/ supported systems, the <tt/getenv/ function always will return a <tt/NULL/
pointer. pointer.
<p> <p>
<item><tt>locale</tt>: There is no other locale than the "C" locale. The <item><tt>locale</tt>: There is no locale other than the "C" locale. The
native locale is identical to the "C" locale. native locale is identical to the "C" locale.
</itemize> </itemize>
In addition to these limitations, some more functions are limited if inlined In addition to those limitations, some more functions are limited if inlined
versions are requested by using -Os: versions are requested by using the <tt/-Os/ command-line option:
<itemize> <itemize>
<item>The <tt/strlen/ function only works for strings with a maximum length <item>The <tt/strlen/ function works for only strings with a maximum length
of 255 characters. of 255 characters.
<p> <p>
<item>The <tt/isxxx/ character classification functions from <item>The <tt/isXXX/ character classification functions from
<tt/&lt;ctype.h&gt;/ will give unpredictable results if the argument is not <tt/&lt;ctype.h&gt;/ will give unpredictable results if the argument is not
in character range (0..255). This limitation may be removed by #undef'ing in character range (0..255). That limitation may be removed by #undef'ing
the function name (when using <tt/-Os/, the functions are actually macros the function name (when using <tt/-Os/, the functions are actually macros
that expand to inline assembler code, but the real functions are still that expand to inline assembly code, but the real functions still are
available if the macro definition is removed). available if the macro definition is removed).
</itemize> </itemize>
<sect>CPU specific stuff - 6502.h<p> <sect>CPU-specific stuff - 6502.h<p>
The header file 6502.h contains some functions that make only sense with the The header file 6502.h contains some functions that make sense only with the
6502 CPU. Examples are macros to insert more or less useful instructions into 6502 CPU. Examples are macros to insert more or less useful instructions into
your C code, or a function to call arbitrary machine language subroutines, your C code, or a function to call arbitrary machine language subroutines,
passing registers in and out. passing registers in and out.
<sect>Target specific stuff<p> <sect>Target-specific stuff<p>
For each supported system there's a header file that contains calls or defines For each supported system, there's a header file that contains calls or
specific for this system. So, when programming for the C64, include c64.h, for defines specific for that system. So, when programming for the C64, include
the C128, include c128.h and so on. To make the task for the Commodore systems <tt/&lt;c64.h&gt;/, for the C128, include <tt/&lt;c128.h&gt;/, and so on.
easier, there is also a header file named cbm.h that will define stuff common To make the task for the Commodore systems easier, there is also a header file
for all CBM systems, and include the header file for the specific target named <tt/&lt;cbm.h&gt;/ that will define stuff common for all CBM systems,
system. and include the header file for the specific target system.
The header files contain The header files contain
<itemize> <itemize>
<item>Defines for special keys (like function keys) <item>Defines for special keys (such as function keys)
<item>Defines for special characters (like the graphics characters) <item>Defines for special characters (such as the graphics characters)
<item>Variables with a fixed address in memory that may be used to access <item>Variables with a fixed address in memory that may be used to access
special hardware. For the C64 and C128 there is a variable struct named special hardware. For the C64 and C128, there is a variable struct named
<tt/SID/. Writing to the fields of this struct will write to the SID device <tt/SID/. Writing to the fields of that struct will write to the SID device
instead. Using these variables will make your program more readable and more instead. Using those variables will make your program more readable and more
portable. Don't fear ineffective code when using these variables, the portable. Don't fear ineffective code when using those variables, the
compiler will translate reads and writes to these structs into direct memory compiler will translate reads and writes to those structs into direct memory
accesses. accesses.
<item>Other routines that make only sense for a specific system. One example <item>Other routines that make sense for only a specific system. One example
are routines to write memory locations in the system bank for the CBM PET-II is routines to write memory locations in the system bank for the CBM-II
family. family.
</itemize> </itemize>
<sect>Direct console I/O - <tt/conio.h/<p> <sect>Direct console I/O - <tt/conio.h/<p>
The <tt/conio.h/ header file contains a large set of functions that do screen The <tt/conio.h/ header file contains a large set of functions that do screen
and keyboard I/O. The functions will write directly to the screen or poll the and keyboard I/O. The functions will write directly to the screen or poll the
keyboard directly with no more help from the operating system than needed. keyboard directly with no more help from the operating system than needed.
This has some disadvantages, but on the other side it's fast and reasonably This has some disadvantages, but on the other side it's fast and reasonably
portable. conio implementations exist for the following targets: portable. Conio implementations exist for the following targets:
<itemize> <itemize>
<item>apple2 <item>apple2
@ -165,13 +166,13 @@ portable. conio implementations exist for the following targets:
<item>atari5200 <item>atari5200
<item>atarixl <item>atarixl
<item>atmos <item>atmos
<item>c128
<item>c16 (works also for the c116 with up to 32K memory) <item>c16 (works also for the c116 with up to 32K memory)
<item>c64 <item>c64
<item>c128 <item>cbm510 (40-column video)
<item>plus4 (or expanded c16/c116) <item>cbm610 (all CBM series-II computers with 80-column video)
<item>cbm510 (40 column video)
<item>cbm610 (all CBM series-II computers with 80 column video)
<item>creativision <item>creativision
<item>cx16
<item>gamate <item>gamate
<item>geos-apple <item>geos-apple
<item>geos-cbm <item>geos-cbm
@ -179,11 +180,12 @@ portable. conio implementations exist for the following targets:
<item>osic1p <item>osic1p
<item>pce <item>pce
<item>pet (all CBM PET systems except the 2001) <item>pet (all CBM PET systems except the 2001)
<item>plus4 (or expanded c16/c116)
<item>telestrat <item>telestrat
<item>vic20 <item>vic20
</itemize> </itemize>
The conio.h header file does also include the system specific header files The <tt/conio.h/ header file does include the system-specific header files also,
which define constants for special characters and keys. which define constants for special characters and keys.
@ -191,14 +193,14 @@ which define constants for special characters and keys.
<sect>Using the joystick - <tt/joystick.h/<p> <sect>Using the joystick - <tt/joystick.h/<p>
For systems that have a joystick, <tt/joystick.h/ will define a subroutine to For systems that have a joystick, <tt/joystick.h/ will define a subroutine to
read the current value, including constants to evaluate the result of this read the current value, including constants to evaluate the result of that
function. function.
<sect>Using a mouse - <tt/mouse.h/<p> <sect>Using a mouse - <tt/mouse.h/<p>
Some target machines support a mouse. Mouse support is currently available for Some target machines support a mouse. Mouse support currently is available for
the following targets: the following targets:
<itemize> <itemize>
@ -206,19 +208,21 @@ the following targets:
<item>apple2enh <item>apple2enh
<item>atari <item>atari
<item>atarixl <item>atarixl
<item>c64
<item>c128 <item>c128
<item>c64
<item>cbm510 <item>cbm510
<item>cx16
</itemize> </itemize>
The available functions are declared in <tt/mouse.h/. The available functions are declared in <tt/mouse.h/.
<sect>Copyright<p> <sect>Copyright<p>
This C runtime library implementation for the cc65 compiler is (C) This C runtime library implementation for the cc65 compiler is (C)
Copyright 1998-2002 Ullrich von Bassewitz. For usage of the binaries Copyright 1998-2002 Ullrich von Bassewitz. For usage of the binaries
and/or sources the following conditions do apply: and/or sources, the following conditions do apply:
This software is provided 'as-is', without any expressed or implied This software is provided 'as-is', without any expressed or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@ -232,8 +236,8 @@ freely, subject to the following restrictions:
<item> The origin of this software must not be misrepresented; you must not <item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated, but is not required.
<item> Altered source versions must be plainly marked as such, and must not <item> Altered source versions must be marked plainly as such, and must not
be misrepresented as being the original software. be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source <item> This notice may not be removed or altered from any source
distribution. distribution.

View File

@ -208,6 +208,7 @@ void __fastcall__ cbm_k_second (unsigned char addr);
void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV, void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
unsigned char SA); unsigned char SA);
void __fastcall__ cbm_k_setnam (const char* Name); void __fastcall__ cbm_k_setnam (const char* Name);
void __fastcall__ cbm_k_settim (unsigned long timer);
void __fastcall__ cbm_k_talk (unsigned char dev); void __fastcall__ cbm_k_talk (unsigned char dev);
void __fastcall__ cbm_k_tksa (unsigned char addr); void __fastcall__ cbm_k_tksa (unsigned char addr);
void cbm_k_udtim (void); void cbm_k_udtim (void);

View File

@ -47,12 +47,32 @@
/* Additional output character codes */ /* Additional output character codes */
#define CH_COLOR_SWAP 0x01 #define CH_COLOR_SWAP 0x01
#define CH_UNDERLINE 0x04 #define CH_UNDERLINE 0x04
#define CH_WHITE 0x05
#define CH_BOLD 0x06 #define CH_BOLD 0x06
#define CH_BACKSPACE 0x08 #define CH_BACKSPACE 0x08
#define CH_ITALIC 0x0B #define CH_ITALIC 0x0B
#define CH_OUTLINE 0x0C #define CH_OUTLINE 0x0C
#define CH_FONT_ISO 0x0F #define CH_FONT_ISO 0x0F
#define CH_RED 0x1C
#define CH_GREEN 0x1E
#define CH_BLUE 0x1F
#define CH_ORANGE 0x81
#define CH_FONT_PET 0x8F #define CH_FONT_PET 0x8F
#define CH_BLACK 0x90
#define CH_ATTR_CLEAR 0x92
#define CH_BROWN 0x95
#define CH_PINK 0x96
#define CH_LIGHTRED CH_PINK
#define CH_GRAY1 0x97
#define CH_GRAY2 0x98
#define CH_LIGHTGREEN 0x99
#define CH_LIGHTBLUE 0x9A
#define CH_GRAY3 0x9B
#define CH_PURPLE 0x9C
#define CH_VIOLET CH_PURPLE
#define CH_YELLOW 0x9E
#define CH_CYAN 0x9F
#define CH_SHIFT_SPACE 0xA0
/* Additional key defines */ /* Additional key defines */
#define CH_SHIFT_TAB 0x18 #define CH_SHIFT_TAB 0x18
@ -82,7 +102,8 @@
#define COLOR_YELLOW 0x07 #define COLOR_YELLOW 0x07
#define COLOR_ORANGE 0x08 #define COLOR_ORANGE 0x08
#define COLOR_BROWN 0x09 #define COLOR_BROWN 0x09
#define COLOR_LIGHTRED 0x0A #define COLOR_PINK 0x0A
#define COLOR_LIGHTRED COLOR_PINK
#define COLOR_GRAY1 0x0B #define COLOR_GRAY1 0x0B
#define COLOR_GRAY2 0x0C #define COLOR_GRAY2 0x0C
#define COLOR_LIGHTGREEN 0x0D #define COLOR_LIGHTGREEN 0x0D
@ -91,27 +112,27 @@
/* NES controller masks for joy_read() */ /* NES controller masks for joy_read() */
#define JOY_BTN_1_MASK 0x80 #define JOY_BTN_1_MASK 0x80
#define JOY_BTN_2_MASK 0x40 #define JOY_BTN_2_MASK 0x40
#define JOY_BTN_3_MASK 0x20 #define JOY_BTN_3_MASK 0x20
#define JOY_BTN_4_MASK 0x10 #define JOY_BTN_4_MASK 0x10
#define JOY_UP_MASK 0x08 #define JOY_UP_MASK 0x08
#define JOY_DOWN_MASK 0x04 #define JOY_DOWN_MASK 0x04
#define JOY_LEFT_MASK 0x02 #define JOY_LEFT_MASK 0x02
#define JOY_RIGHT_MASK 0x01 #define JOY_RIGHT_MASK 0x01
#define JOY_BTN_A_MASK JOY_BTN_1_MASK #define JOY_BTN_A_MASK JOY_BTN_1_MASK
#define JOY_BTN_B_MASK JOY_BTN_2_MASK #define JOY_BTN_B_MASK JOY_BTN_2_MASK
#define JOY_SELECT_MASK JOY_BTN_3_MASK #define JOY_SELECT_MASK JOY_BTN_3_MASK
#define JOY_START_MASK JOY_BTN_4_MASK #define JOY_START_MASK JOY_BTN_4_MASK
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK) #define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK) #define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK) #define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
#define JOY_START(v) ((v) & JOY_START_MASK) #define JOY_START(v) ((v) & JOY_START_MASK)
#define JOY_FIRE2_MASK JOY_BTN_2_MASK #define JOY_FIRE2_MASK JOY_BTN_2_MASK
#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK) #define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK)
/* Additional mouse button mask */ /* Additional mouse button mask */
#define MOUSE_BTN_MIDDLE 0x02 #define MOUSE_BTN_MIDDLE 0x02
@ -119,21 +140,21 @@
/* get_tv() return codes /* get_tv() return codes
** set_tv() argument codes ** set_tv() argument codes
*/ */
#define TV_NONE 0 #define TV_NONE 0
#define TV_VGA 1 #define TV_VGA 1
#define TV_NTSC_COLOR 2 #define TV_NTSC_COLOR 2
#define TV_RGB 3 #define TV_RGB 3
#define TV_NONE2 4 #define TV_NONE2 4
#define TV_VGA2 5 #define TV_VGA2 5
#define TV_NTSC_MONO 6 #define TV_NTSC_MONO 6
#define TV_RGB2 7 #define TV_RGB2 7
/* Video modes for videomode() */ /* Video modes for videomode() */
#define VIDEOMODE_40x30 0x00 #define VIDEOMODE_40x30 0x00
#define VIDEOMODE_80x60 0x02 #define VIDEOMODE_80x60 0x02
#define VIDEOMODE_40COL VIDEOMODE_40x30 #define VIDEOMODE_40COL VIDEOMODE_40x30
#define VIDEOMODE_80COL VIDEOMODE_80x60 #define VIDEOMODE_80COL VIDEOMODE_80x60
#define VIDEOMODE_320x240 0x80 #define VIDEOMODE_320x200 0x80
#define VIDEOMODE_SWAP (-1) #define VIDEOMODE_SWAP (-1)
/* VERA's interrupt flags */ /* VERA's interrupt flags */
@ -193,6 +214,9 @@ extern void cx16_std_mou[]; /* Referred to by mouse_static_stddrv[]
unsigned char get_numbanks (void);
/* Return the number of RAM banks that the machine has. */
signed char get_ostype (void); signed char get_ostype (void);
/* Get the ROM build version. /* Get the ROM build version.
** -1 -- custom build ** -1 -- custom build
@ -201,12 +225,12 @@ signed char get_ostype (void);
*/ */
unsigned char get_tv (void); unsigned char get_tv (void);
/* Return the video type that the machine is using. /* Return the video signal type that the machine is using.
** Return a TV_xx constant. ** Return a TV_xx constant.
*/ */
void __fastcall__ set_tv (unsigned char type); void __fastcall__ set_tv (unsigned char type);
/* Set the video type that the machine will use. /* Set the video signal type that the machine will use.
** Call with a TV_xx constant. ** Call with a TV_xx constant.
*/ */

16
libsrc/cbm/c_settim.s Normal file
View File

@ -0,0 +1,16 @@
;
; 2020-01-08, Greg King
;
; void __fastcall__ cbm_k_settim (unsigned long timer);
;
.export _cbm_k_settim
.importzp sreg
.include "cbm.inc"
.proc _cbm_k_settim
ldy sreg
jmp SETTIM
.endproc

View File

@ -25,7 +25,6 @@
.endproc .endproc
.proc _clock .proc _clock
stz sreg + 1 ; Byte 3 always is zero stz sreg + 1 ; Byte 3 always is zero

View File

@ -36,7 +36,7 @@ _bgcolor:
ora tmp1 ora tmp1
sta CHARCOLOR ; set new values sta CHARCOLOR ; set new values
txa txa
lsr a ; get screen color lsr a ; get old background color
lsr a lsr a
lsr a lsr a
lsr a lsr a

View File

@ -61,7 +61,7 @@ L2: lda zpsave,x
ldx spsave ldx spsave
txs ; Restore stack pointer txs ; Restore stack pointer
ldx ramsave ldx ramsave
stx VIA1::PRA2 ; Restore former RAM bank stx VIA1::PRA ; Restore former RAM bank
lda VIA1::PRB lda VIA1::PRB
and #<~$07 and #<~$07
ora #$04 ora #$04
@ -85,10 +85,10 @@ init:
; Change to the second RAM bank. ; Change to the second RAM bank.
lda VIA1::PRA2 lda VIA1::PRA
sta ramsave ; Save the current RAM bank number sta ramsave ; Save the current RAM bank number
lda #$01 lda #$01
sta VIA1::PRA2 sta VIA1::PRA
.if 0 ; We don't need to preserve zero-page space for cc65's variables. .if 0 ; We don't need to preserve zero-page space for cc65's variables.
; Save the zero-page locations that we need. ; Save the zero-page locations that we need.

View File

@ -0,0 +1,20 @@
;
; 2020-01-10, Greg King
;
; unsigned char get_numbanks (void);
; /* Return the number of RAM banks that the machine has. */
;
; The Commander X16 version of MEMTOP returns with an extra value:
; The accumulator describes the number of RAM banks that exist on the hardware.
;
.export _get_numbanks
.import MEMTOP
_get_numbanks:
sec
jsr MEMTOP
ldx #>$0000
rts

View File

@ -1,20 +0,0 @@
;
; 2019-12-22, Greg King
;
; Link an interrupt handler if joysticks are used by a program.
;
.interruptor joy_libref, 9
.include "cbm_kernal.inc"
.include "cx16.inc"
joy_libref:
lda VERA::IRQ_FLAGS
lsr a
bcc not_vsync
jsr JOYSTICK_SCAN ; Bit-bang game controllers
clc ; Let other Jiffy handlers run
not_vsync:
rts

View File

@ -1,5 +1,5 @@
; ;
; 2019-12-22, Greg King ; 2020-01-08, Greg King
; ;
; unsigned char kbhit (void); ; unsigned char kbhit (void);
; /* Returns non-zero (true) if a typed character is waiting. */ ; /* Returns non-zero (true) if a typed character is waiting. */
@ -11,10 +11,10 @@
.proc _kbhit .proc _kbhit
ldy VIA1::PRA2 ; (KEY_COUNT is in RAM bank 0) ldy VIA1::PRA ; (KEY_COUNT is in RAM bank 0)
stz VIA1::PRA2 stz VIA1::PRA
lda KEY_COUNT ; Get number of characters lda KEY_COUNT ; Get number of characters
sty VIA1::PRA2 sty VIA1::PRA
tax ; High byte of return (only its zero/nonzero ... tax ; High byte of return (only its zero/nonzero ...
rts ; ... state matters) rts ; ... state matters)
.endproc .endproc

View File

@ -1,11 +1,20 @@
; ;
; 2019-12-22, Greg King ; 2020-01-06, Greg King
; ;
; CX16 Kernal functions ; CX16 Kernal functions
; ;
.include "cbm_kernal.inc" .include "cbm_kernal.inc"
.export CONSOLE_INIT
.export CONSOLE_PUT_CHAR
.export CONSOLE_GET_CHAR
.export MEMORY_FILL
.export MEMORY_COPY
.export MEMORY_CRC
.export MEMORY_DECOMPRESS
.export SPRITE_SET_IMAGE
.export SPRITE_SET_POSITION
.export FB_INIT .export FB_INIT
.export FB_GET_INFO .export FB_GET_INFO
.export FB_SET_PALETTE .export FB_SET_PALETTE
@ -37,7 +46,8 @@
.export CLOCK_GET_DATE_TIME .export CLOCK_GET_DATE_TIME
.export JOYSTICK_SCAN .export JOYSTICK_SCAN
.export JOYSTICK_GET .export JOYSTICK_GET
.export SCRMOD .export SCREEN_SET_MODE
.export SCREEN_SET_CHARSET
.export MOUSE_CONFIG .export MOUSE_CONFIG
.export MOUSE_GET .export MOUSE_GET

View File

@ -1,9 +1,10 @@
; ;
; 2013-05-31, Oliver Schmidt ; 2013-05-31, Oliver Schmidt
; 2019-11-14, Greg King ; 2020-01-06, Greg King
; ;
.export em_libref .export em_libref
.export joy_libref
.export mouse_libref .export mouse_libref
.export ser_libref .export ser_libref
.export tgi_libref .export tgi_libref
@ -11,6 +12,7 @@
.import _exit .import _exit
em_libref := _exit em_libref := _exit
joy_libref := _exit
mouse_libref := _exit mouse_libref := _exit
ser_libref := _exit ser_libref := _exit
tgi_libref := _exit tgi_libref := _exit

View File

@ -1,44 +1,29 @@
; ;
; Default mouse callbacks for the CX16 ; Default mouse callbacks for the CX16
; ;
; 2019-12-25, Greg King ; 2020-01-10, Greg King
;
; All functions in this module should be interrupt-safe
; because they might be called from an interrupt handler.
; ;
.export _mouse_def_callbacks .export _mouse_def_callbacks
.import MOUSE_GET, SPRITE_SET_POSITION
.include "cx16.inc" .include "cx16.inc"
msprite:
stz VERA::CTRL ; set address for VERA's data port zero
lda #<(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8)
ldx #>(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8)
ldy #^(VERA::SPRITE::ATTRIB::Z_FLIP + 0 * 8) | VERA::INC0
sta VERA::ADDR
stx VERA::ADDR+1
sty VERA::ADDR+2
rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Hide the mouse pointer. ; Hide the mouse pointer.
hide: jsr msprite hide: ldx #%10000000
lda VERA::DATA0 stx gREG::r0H
and #<~VERA::SPRITE::DEPTH::LAYER1 bra mse
sta VERA::DATA0
rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Show the mouse pointer. ; Show the mouse pointer.
show: jsr msprite show: ldx #gREG::r0
lda VERA::DATA0 jsr MOUSE_GET
ora #VERA::SPRITE::DEPTH::LAYER1 mse: lda #$00 ; mouse sprite
sta VERA::DATA0 jmp SPRITE_SET_POSITION
rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Prepare to move the mouse pointer. ; Prepare to move the mouse pointer.
@ -53,13 +38,13 @@ draw: ; Fall through
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in .XA . ; Move the mouse pointer X position to the value in .XA .
movex: ; Already set by drivers movex: ; Already done by Kernal
; Fall through ; Fall through
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Move the mouse pointer Y position to the value in .XA . ; Move the mouse pointer Y position to the value in .XA .
movey: rts ; Already set by drivers movey: rts ; Already done by Kernal
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Callback structure ; Callback structure

View File

@ -1,10 +1,10 @@
; ;
; 2019-11-06, Greg King ; 2020-01-06, Greg King
; ;
; /* Video mode defines */ ; /* Video mode defines */
; #define VIDEOMODE_40x30 0x00 ; #define VIDEOMODE_40x30 0x00
; #define VIDEOMODE_80x60 0x02 ; #define VIDEOMODE_80x60 0x02
; #define VIDEOMODE_320x240 0x80 ; #define VIDEOMODE_320x200 0x80
; #define VIDEOMODE_SWAP (-1) ; #define VIDEOMODE_SWAP (-1)
; ;
; signed char __fastcall__ videomode (signed char Mode); ; signed char __fastcall__ videomode (signed char Mode);
@ -16,29 +16,25 @@
.export _videomode .export _videomode
.import SCRMOD .import SCREEN_SET_MODE
.include "cx16.inc"
.proc _videomode .proc _videomode
tax ldx SCREEN_MODE ; Get old mode
clc ; (Get old mode) phx
jsr SCRMOD
pha
txa
sec ; (Set new mode) jsr SCREEN_SET_MODE
jsr SCRMOD
pla ; Get back old mode pla ; Get back old mode
bcs @L1
ldx #>$0000 ; Clear high byte ldx #>$0000 ; Clear high byte
bcs @L1
rts rts
; The new mode is invalid. Go back to the old mode. Return -1. ; The new mode is invalid. Go back to the old one. Return -1.
@L1: sec @L1: sta SCREEN_MODE
jsr SCRMOD dex
lda #<-1 txa
tax
rts rts
.endproc .endproc

View File

@ -1,5 +1,5 @@
; ;
; 2019-12-23, Greg King ; 2020-01-08, Greg King
; ;
; void waitvsync (void); ; void waitvsync (void);
; /* Wait for the start of the next video field. */ ; /* Wait for the start of the next video field. */
@ -12,10 +12,10 @@
.include "cx16.inc" .include "cx16.inc"
_waitvsync: _waitvsync:
ldx VIA1::PRA2 ; (TIMER is in RAM bank 0) ldx VIA1::PRA ; (TIMER is in RAM bank 0)
stz VIA1::PRA2 stz VIA1::PRA
lda TIMER + 2 lda TIMER + 2
: cmp TIMER + 2 : cmp TIMER + 2
beq :- ; Wait for next jiffy beq :- ; Wait for next jiffy
stx VIA1::PRA2 stx VIA1::PRA
rts rts