Updated the cx16 library to the ROM's prerelease 36.
This commit is contained in:
parent
244dc358e5
commit
b66f7272af
19 changed files with 357 additions and 214 deletions
|
@ -1,11 +1,21 @@
|
|||
;
|
||||
; Olli Savia <ops@iki.fi>
|
||||
; Greg King
|
||||
;
|
||||
; Commodore Kernal functions
|
||||
; Commodore-compatibles Kernal functions
|
||||
;
|
||||
|
||||
.if .def(__CX16__)
|
||||
; 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_GET_INFO := $FEF9
|
||||
FB_SET_PALETTE := $FEFC
|
||||
|
@ -37,7 +47,8 @@
|
|||
CLOCK_GET_DATE_TIME := $FF50
|
||||
JOYSTICK_SCAN := $FF53
|
||||
JOYSTICK_GET := $FF56
|
||||
SCRMOD := $FF5F
|
||||
SCREEN_SET_MODE := $FF5F
|
||||
SCREEN_SET_CHARSET := $FF62
|
||||
MOUSE_CONFIG := $FF68
|
||||
MOUSE_GET := $FF6B
|
||||
.endif
|
||||
|
|
137
asminc/cx16.inc
137
asminc/cx16.inc
|
@ -1,5 +1,5 @@
|
|||
;
|
||||
; CX16 r35 definitions
|
||||
; CX16 r36 definitions
|
||||
;
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
|
@ -17,7 +17,8 @@
|
|||
YELLOW
|
||||
ORANGE
|
||||
BROWN
|
||||
LIGHTRED
|
||||
PINK
|
||||
LIGHTRED = PINK
|
||||
GRAY1
|
||||
GRAY2
|
||||
LIGHTGREEN
|
||||
|
@ -25,20 +26,81 @@
|
|||
GRAY3
|
||||
.endenum
|
||||
|
||||
; Special keys
|
||||
.enum KEY
|
||||
F1 = $85
|
||||
F3
|
||||
F5
|
||||
F7
|
||||
F2
|
||||
F4
|
||||
F6
|
||||
F8
|
||||
F9 = $10
|
||||
F10 = $15
|
||||
F11
|
||||
F12
|
||||
; Special characters
|
||||
.enum CH
|
||||
COLOR_SWAP = $01
|
||||
STOP = $03
|
||||
UNDERLINE
|
||||
WHITE
|
||||
BOLD
|
||||
BELL
|
||||
BACKSPACE
|
||||
TAB
|
||||
LINEFEED
|
||||
ITALIC
|
||||
OUTLINE
|
||||
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
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
|
@ -162,10 +224,9 @@
|
|||
.endstruct
|
||||
|
||||
; Kernal
|
||||
FNAM := $84 ; Pointer to filename
|
||||
KTEMP2 := $86 ; 2 bytes for temporary storage
|
||||
IMPARM := $88 ; Pointer for PRIMM function
|
||||
SCREEN_PTR := $90 ; Pointer to current row on text screen (16 bits)
|
||||
KTEMP2 := $80 ; 2 bytes for temporary storage
|
||||
IMPARM := $82 ; Pointer for PRIMM function
|
||||
FNAM := $8C ; Pointer to filename
|
||||
|
||||
; BASIC
|
||||
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_LEN = 81 ; Maximum length of command-line
|
||||
|
||||
STATUS := $0275 ; Status from previous I/O operation
|
||||
IN_DEV := $0279 ; Current input device number
|
||||
OUT_DEV := $027A ; Current output device number
|
||||
FNAM_LEN := $027D ; Length of filename
|
||||
SECADR := $027F ; Secondary address
|
||||
DEVNUM := $0280 ; Device number
|
||||
SCREEN_MODE := $0262 ; Current screen mode (set by SCREEN_SET_MODE)
|
||||
SCREEN_PTR := $0263 ; Pointer to current row on text screen (16 bits)
|
||||
STATUS := $0286 ; Status from previous I/O operation
|
||||
IN_DEV := $028A ; Current input device number
|
||||
OUT_DEV := $028B ; Current output device number
|
||||
FNAM_LEN := $028E ; Length of filename
|
||||
SECADR := $0290 ; Secondary address
|
||||
DEVNUM := $0291 ; Device number
|
||||
CURS_COLOR := $0373 ; Color under the cursor
|
||||
CHARCOLOR := $0377 ; Cursor's color nybbles (high: background, low: foreground)
|
||||
RVS := $0378 ; Reverse flag
|
||||
CURS_FLAG := $037C ; 1 = cursor off
|
||||
CURS_BLINK := $037D ; Blink counter
|
||||
CURS_CHAR := $037E ; Character under the cursor
|
||||
CURS_STATE := $037F ; Cursor blink state
|
||||
CURS_X := $0381 ; Cursor column
|
||||
CURS_Y := $0384 ; Cursor row
|
||||
LLEN := $0387 ; Line length
|
||||
NLINES := $0388 ; Number of screen lines
|
||||
CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground)
|
||||
RVS := $0377 ; Reverse flag
|
||||
CURS_FLAG := $037B ; 1 = cursor off
|
||||
CURS_BLINK := $037C ; Blink counter
|
||||
CURS_CHAR := $037D ; Character under the cursor
|
||||
CURS_STATE := $037E ; Cursor blink state
|
||||
CURS_X := $0380 ; Cursor column
|
||||
CURS_Y := $0383 ; Cursor row
|
||||
LLEN := $0386 ; Line length
|
||||
NLINES := $0387 ; Number of screen lines
|
||||
|
||||
; BASIC
|
||||
VARTAB := $03E3 ; Pointer to start of BASIC variables
|
||||
|
@ -453,7 +516,7 @@ NMIVec := $0318
|
|||
; ---------------------------------------------------------------------------
|
||||
; 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)
|
||||
|
||||
.struct BANK
|
||||
|
|
|
@ -46,9 +46,9 @@ file and linker config.
|
|||
<sect>Memory layout<p>
|
||||
|
||||
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
|
||||
called directly. The usable memory ranges are $0800 - $9EFF and
|
||||
$A000 - $BFFF.
|
||||
one, and the Kernal ROM being visible. That means that Kernal entry points
|
||||
can be called directly. The usable memory ranges are $0800 -
|
||||
$9EFF, $0400 - $07FF, and $A000 - $BFFF.
|
||||
|
||||
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
|
||||
linker config. files which are used via <tt/-t cx16 -C <configfile>/.
|
||||
|
||||
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.)
|
||||
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ the C functions available in the standard library.
|
|||
|
||||
<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
|
||||
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.
|
||||
|
||||
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">.
|
||||
|
||||
<em/Note:/ Standard C functions are listed here, but not described in detail.
|
||||
Since these functions behave identical on all standard compliant systems, they
|
||||
are described in any book covering standard C.
|
||||
Because those functions behave identically on all standard-compliant systems,
|
||||
they are described in any book covering standard C.
|
||||
|
||||
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_setlfs" name="cbm_k_setlfs">
|
||||
<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_tksa" name="cbm_k_tksa">
|
||||
<item><ref id="cbm_k_udtim" name="cbm_k_udtim">
|
||||
|
@ -321,6 +322,7 @@ function.
|
|||
<sect1><tt/cx16.h/<label id="cx16.h"><p>
|
||||
|
||||
<itemize>
|
||||
<!-- <item><ref id="get_numbanks" name="get_numbanks"> -->
|
||||
<!-- <item><ref id="get_ostype" name="get_ostype"> -->
|
||||
<!-- <item><ref id="get_tv" name="get_tv"> -->
|
||||
<!-- <item><ref id="set_tv" name="set_tv"> -->
|
||||
|
@ -2281,6 +2283,9 @@ only be used in presence of a prototype.
|
|||
</itemize>
|
||||
<tag/Availability/cc65
|
||||
<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">
|
||||
<tag/Example/None.
|
||||
</descrip>
|
||||
|
@ -2302,9 +2307,34 @@ only be used in presence of a prototype.
|
|||
</itemize>
|
||||
<tag/Availability/cc65
|
||||
<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_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.
|
||||
</descrip>
|
||||
</quote>
|
||||
|
@ -2368,6 +2398,7 @@ then that ISR must call this function, in order to keep the clock valid.
|
|||
<tag/Availability/cc65
|
||||
<tag/See also/
|
||||
<ref id="cbm_k_scnkey" name="cbm_k_scnkey">,
|
||||
<ref id="cbm_k_settim" name="cbm_k_settim">,
|
||||
<ref id="clock" name="clock">
|
||||
<tag/Example/None.
|
||||
</descrip>
|
||||
|
@ -2585,6 +2616,7 @@ changing values. (See the description of <tt/cbm_k_udtim()/.)
|
|||
</itemize>
|
||||
<tag/Availability/ISO 9899
|
||||
<tag/See also/
|
||||
<ref id="cbm_k_settim" name="cbm_k_settim">,
|
||||
<ref id="cbm_k_udtim" name="cbm_k_udtim">,
|
||||
<ref id="time" name="time">
|
||||
<tag/Example/None.
|
||||
|
|
118
doc/library.sgml
118
doc/library.sgml
|
@ -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
|
||||
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
|
||||
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
|
||||
functions, that are not defined by the ISO C standard have a short comment in
|
||||
reference"> for a function-by-function list. Because the function reference is
|
||||
not complete (we're working on that), it may happen that you don't find a
|
||||
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
|
||||
the headers, explaining their use.
|
||||
|
||||
|
||||
|
||||
<sect>ISO C compatible library<p>
|
||||
|
||||
The C library contains a large subset of the ISO C library. Functions are
|
||||
usually missing in areas, where there is no support on typical 6502 systems.
|
||||
Wide character sets are an example for this.
|
||||
The C library contains a large subset of the ISO C library. Functions usually
|
||||
are missing in areas where there are no support on typical 6502 systems.
|
||||
Wide-character sets are an example for that.
|
||||
|
||||
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.
|
||||
|
||||
Functions that are <em/not/ available:
|
||||
|
@ -45,13 +45,13 @@ Functions that are <em/not/ available:
|
|||
<p>
|
||||
<item>All functions that handle floating point numbers in some manner.
|
||||
<p>
|
||||
<item>The <tt/ldiv/ function (cc65 is currently not able to return structs
|
||||
with a size not equal to 1, 2 or 4 bytes by value).
|
||||
<item>The <tt/ldiv/ function (cc65 currently is not able to return structs,
|
||||
by value, with a size not equal to 1, 2, or 4 bytes).
|
||||
<p>
|
||||
<item>All functions handling wide character strings.
|
||||
<item>All functions handling wide-character strings.
|
||||
<p>
|
||||
<item>Signals and all related functions (having <tt/SIGSEGV/ would be
|
||||
cool:-)
|
||||
cool. :-)
|
||||
<p>
|
||||
<item><tt>setbuf/setvbuf</tt>
|
||||
</itemize>
|
||||
|
@ -60,7 +60,7 @@ Functions not available on all supported systems:
|
|||
|
||||
<itemize>
|
||||
<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.
|
||||
<p>
|
||||
<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
|
||||
the target machine.
|
||||
<p>
|
||||
<item><tt>time</tt>: Since many of the supported systems do not have a real
|
||||
time clock, which means that the <tt/time/ function is not available. Please
|
||||
note that the other functions from <tt/time.h/ <em/are/ available.
|
||||
<item><tt>time</tt>: Many of the supported systems don't have a real-time
|
||||
clock, which means that the <tt/time/ function is not available. Please note
|
||||
that the other functions from <tt/time.h/ <em/are/ available.
|
||||
</itemize>
|
||||
|
||||
|
||||
Functions that are limited in any way:
|
||||
|
||||
<itemize>
|
||||
<item><tt>strcspn/strpbrk/strspn</tt>: These functions have a length
|
||||
limitation of 256 for the second string argument. Since this string gives a
|
||||
character set, and there are only 256 distinct characters, this shouldn't be
|
||||
<item><tt>strcspn/strpbrk/strspn</tt>: Those functions have a length
|
||||
limitation of 256 for the second string argument. Since that string gives a
|
||||
character set, and there are only 256 distinct characters, that shouldn't be
|
||||
a problem.
|
||||
<p>
|
||||
<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.
|
||||
<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.
|
||||
</itemize>
|
||||
|
||||
|
||||
In addition to these limitations, some more functions are limited if inlined
|
||||
versions are requested by using -Os:
|
||||
In addition to those limitations, some more functions are limited if inlined
|
||||
versions are requested by using the <tt/-Os/ command-line option:
|
||||
|
||||
<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.
|
||||
<p>
|
||||
<item>The <tt/isxxx/ character classification functions from
|
||||
<item>The <tt/isXXX/ character classification functions from
|
||||
<tt/<ctype.h>/ 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
|
||||
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).
|
||||
</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
|
||||
your C code, or a function to call arbitrary machine language subroutines,
|
||||
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
|
||||
specific for this system. So, when programming for the C64, include c64.h, for
|
||||
the C128, include c128.h and so on. To make the task for the Commodore systems
|
||||
easier, there is also a header file named cbm.h that will define stuff common
|
||||
for all CBM systems, and include the header file for the specific target
|
||||
system.
|
||||
For each supported system, there's a header file that contains calls or
|
||||
defines specific for that system. So, when programming for the C64, include
|
||||
<tt/<c64.h>/, for the C128, include <tt/<c128.h>/, and so on.
|
||||
To make the task for the Commodore systems easier, there is also a header file
|
||||
named <tt/<cbm.h>/ that will define stuff common for all CBM systems,
|
||||
and include the header file for the specific target system.
|
||||
|
||||
The header files contain
|
||||
|
||||
<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
|
||||
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
|
||||
instead. Using these variables will make your program more readable and more
|
||||
portable. Don't fear ineffective code when using these variables, the
|
||||
compiler will translate reads and writes to these structs into direct memory
|
||||
special hardware. For the C64 and C128, there is a variable struct named
|
||||
<tt/SID/. Writing to the fields of that struct will write to the SID device
|
||||
instead. Using those variables will make your program more readable and more
|
||||
portable. Don't fear ineffective code when using those variables, the
|
||||
compiler will translate reads and writes to those structs into direct memory
|
||||
accesses.
|
||||
|
||||
<item>Other routines that make only sense for a specific system. One example
|
||||
are routines to write memory locations in the system bank for the CBM PET-II
|
||||
<item>Other routines that make sense for only a specific system. One example
|
||||
is routines to write memory locations in the system bank for the CBM-II
|
||||
family.
|
||||
|
||||
</itemize>
|
||||
|
||||
|
||||
|
||||
<sect>Direct console I/O - <tt/conio.h/<p>
|
||||
|
||||
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
|
||||
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
|
||||
portable. conio implementations exist for the following targets:
|
||||
portable. Conio implementations exist for the following targets:
|
||||
|
||||
<itemize>
|
||||
<item>apple2
|
||||
|
@ -165,13 +166,13 @@ portable. conio implementations exist for the following targets:
|
|||
<item>atari5200
|
||||
<item>atarixl
|
||||
<item>atmos
|
||||
<item>c128
|
||||
<item>c16 (works also for the c116 with up to 32K memory)
|
||||
<item>c64
|
||||
<item>c128
|
||||
<item>plus4 (or expanded c16/c116)
|
||||
<item>cbm510 (40 column video)
|
||||
<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>cx16
|
||||
<item>gamate
|
||||
<item>geos-apple
|
||||
<item>geos-cbm
|
||||
|
@ -179,11 +180,12 @@ portable. conio implementations exist for the following targets:
|
|||
<item>osic1p
|
||||
<item>pce
|
||||
<item>pet (all CBM PET systems except the 2001)
|
||||
<item>plus4 (or expanded c16/c116)
|
||||
<item>telestrat
|
||||
<item>vic20
|
||||
</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.
|
||||
|
||||
|
||||
|
@ -191,14 +193,14 @@ which define constants for special characters and keys.
|
|||
<sect>Using the joystick - <tt/joystick.h/<p>
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
<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:
|
||||
|
||||
<itemize>
|
||||
|
@ -206,19 +208,21 @@ the following targets:
|
|||
<item>apple2enh
|
||||
<item>atari
|
||||
<item>atarixl
|
||||
<item>c64
|
||||
<item>c128
|
||||
<item>c64
|
||||
<item>cbm510
|
||||
<item>cx16
|
||||
</itemize>
|
||||
|
||||
The available functions are declared in <tt/mouse.h/.
|
||||
|
||||
|
||||
|
||||
<sect>Copyright<p>
|
||||
|
||||
This C runtime library implementation for the cc65 compiler is (C)
|
||||
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
|
||||
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
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
<item> Altered source versions must be plainly marked as such, and must not
|
||||
appreciated, but is not required.
|
||||
<item> Altered source versions must be marked plainly as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
<item> This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
|
|
@ -208,6 +208,7 @@ void __fastcall__ cbm_k_second (unsigned char addr);
|
|||
void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
|
||||
unsigned char SA);
|
||||
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_tksa (unsigned char addr);
|
||||
void cbm_k_udtim (void);
|
||||
|
|
|
@ -47,12 +47,32 @@
|
|||
/* Additional output character codes */
|
||||
#define CH_COLOR_SWAP 0x01
|
||||
#define CH_UNDERLINE 0x04
|
||||
#define CH_WHITE 0x05
|
||||
#define CH_BOLD 0x06
|
||||
#define CH_BACKSPACE 0x08
|
||||
#define CH_ITALIC 0x0B
|
||||
#define CH_OUTLINE 0x0C
|
||||
#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_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 */
|
||||
#define CH_SHIFT_TAB 0x18
|
||||
|
@ -82,7 +102,8 @@
|
|||
#define COLOR_YELLOW 0x07
|
||||
#define COLOR_ORANGE 0x08
|
||||
#define COLOR_BROWN 0x09
|
||||
#define COLOR_LIGHTRED 0x0A
|
||||
#define COLOR_PINK 0x0A
|
||||
#define COLOR_LIGHTRED COLOR_PINK
|
||||
#define COLOR_GRAY1 0x0B
|
||||
#define COLOR_GRAY2 0x0C
|
||||
#define COLOR_LIGHTGREEN 0x0D
|
||||
|
@ -91,27 +112,27 @@
|
|||
|
||||
/* NES controller masks for joy_read() */
|
||||
|
||||
#define JOY_BTN_1_MASK 0x80
|
||||
#define JOY_BTN_2_MASK 0x40
|
||||
#define JOY_BTN_3_MASK 0x20
|
||||
#define JOY_BTN_4_MASK 0x10
|
||||
#define JOY_UP_MASK 0x08
|
||||
#define JOY_DOWN_MASK 0x04
|
||||
#define JOY_LEFT_MASK 0x02
|
||||
#define JOY_RIGHT_MASK 0x01
|
||||
#define JOY_BTN_1_MASK 0x80
|
||||
#define JOY_BTN_2_MASK 0x40
|
||||
#define JOY_BTN_3_MASK 0x20
|
||||
#define JOY_BTN_4_MASK 0x10
|
||||
#define JOY_UP_MASK 0x08
|
||||
#define JOY_DOWN_MASK 0x04
|
||||
#define JOY_LEFT_MASK 0x02
|
||||
#define JOY_RIGHT_MASK 0x01
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_START_MASK JOY_BTN_4_MASK
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_START_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
|
||||
#define JOY_FIRE2_MASK JOY_BTN_2_MASK
|
||||
#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK)
|
||||
#define JOY_FIRE2_MASK JOY_BTN_2_MASK
|
||||
#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK)
|
||||
|
||||
/* Additional mouse button mask */
|
||||
#define MOUSE_BTN_MIDDLE 0x02
|
||||
|
@ -119,21 +140,21 @@
|
|||
/* get_tv() return codes
|
||||
** set_tv() argument codes
|
||||
*/
|
||||
#define TV_NONE 0
|
||||
#define TV_VGA 1
|
||||
#define TV_NTSC_COLOR 2
|
||||
#define TV_RGB 3
|
||||
#define TV_NONE2 4
|
||||
#define TV_VGA2 5
|
||||
#define TV_NTSC_MONO 6
|
||||
#define TV_RGB2 7
|
||||
#define TV_NONE 0
|
||||
#define TV_VGA 1
|
||||
#define TV_NTSC_COLOR 2
|
||||
#define TV_RGB 3
|
||||
#define TV_NONE2 4
|
||||
#define TV_VGA2 5
|
||||
#define TV_NTSC_MONO 6
|
||||
#define TV_RGB2 7
|
||||
|
||||
/* Video modes for videomode() */
|
||||
#define VIDEOMODE_40x30 0x00
|
||||
#define VIDEOMODE_80x60 0x02
|
||||
#define VIDEOMODE_40COL VIDEOMODE_40x30
|
||||
#define VIDEOMODE_80COL VIDEOMODE_80x60
|
||||
#define VIDEOMODE_320x240 0x80
|
||||
#define VIDEOMODE_320x200 0x80
|
||||
#define VIDEOMODE_SWAP (-1)
|
||||
|
||||
/* 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);
|
||||
/* Get the ROM build version.
|
||||
** -1 -- custom build
|
||||
|
@ -201,12 +225,12 @@ signed char get_ostype (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.
|
||||
*/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
|
|
16
libsrc/cbm/c_settim.s
Normal file
16
libsrc/cbm/c_settim.s
Normal 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
|
|
@ -25,7 +25,6 @@
|
|||
.endproc
|
||||
|
||||
|
||||
|
||||
.proc _clock
|
||||
|
||||
stz sreg + 1 ; Byte 3 always is zero
|
||||
|
|
|
@ -36,7 +36,7 @@ _bgcolor:
|
|||
ora tmp1
|
||||
sta CHARCOLOR ; set new values
|
||||
txa
|
||||
lsr a ; get screen color
|
||||
lsr a ; get old background color
|
||||
lsr a
|
||||
lsr a
|
||||
lsr a
|
||||
|
|
|
@ -61,7 +61,7 @@ L2: lda zpsave,x
|
|||
ldx spsave
|
||||
txs ; Restore stack pointer
|
||||
ldx ramsave
|
||||
stx VIA1::PRA2 ; Restore former RAM bank
|
||||
stx VIA1::PRA ; Restore former RAM bank
|
||||
lda VIA1::PRB
|
||||
and #<~$07
|
||||
ora #$04
|
||||
|
@ -85,10 +85,10 @@ init:
|
|||
|
||||
; Change to the second RAM bank.
|
||||
|
||||
lda VIA1::PRA2
|
||||
lda VIA1::PRA
|
||||
sta ramsave ; Save the current RAM bank number
|
||||
lda #$01
|
||||
sta VIA1::PRA2
|
||||
sta VIA1::PRA
|
||||
|
||||
.if 0 ; We don't need to preserve zero-page space for cc65's variables.
|
||||
; Save the zero-page locations that we need.
|
||||
|
|
20
libsrc/cx16/get_numbanks.s
Normal file
20
libsrc/cx16/get_numbanks.s
Normal 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
|
|
@ -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
|
|
@ -1,5 +1,5 @@
|
|||
;
|
||||
; 2019-12-22, Greg King
|
||||
; 2020-01-08, Greg King
|
||||
;
|
||||
; unsigned char kbhit (void);
|
||||
; /* Returns non-zero (true) if a typed character is waiting. */
|
||||
|
@ -11,10 +11,10 @@
|
|||
|
||||
|
||||
.proc _kbhit
|
||||
ldy VIA1::PRA2 ; (KEY_COUNT is in RAM bank 0)
|
||||
stz VIA1::PRA2
|
||||
ldy VIA1::PRA ; (KEY_COUNT is in RAM bank 0)
|
||||
stz VIA1::PRA
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
sty VIA1::PRA2
|
||||
sty VIA1::PRA
|
||||
tax ; High byte of return (only its zero/nonzero ...
|
||||
rts ; ... state matters)
|
||||
.endproc
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
;
|
||||
; 2019-12-22, Greg King
|
||||
; 2020-01-06, Greg King
|
||||
;
|
||||
; CX16 Kernal functions
|
||||
;
|
||||
|
||||
.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_GET_INFO
|
||||
.export FB_SET_PALETTE
|
||||
|
@ -37,7 +46,8 @@
|
|||
.export CLOCK_GET_DATE_TIME
|
||||
.export JOYSTICK_SCAN
|
||||
.export JOYSTICK_GET
|
||||
.export SCRMOD
|
||||
.export SCREEN_SET_MODE
|
||||
.export SCREEN_SET_CHARSET
|
||||
.export MOUSE_CONFIG
|
||||
.export MOUSE_GET
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
;
|
||||
; 2013-05-31, Oliver Schmidt
|
||||
; 2019-11-14, Greg King
|
||||
; 2020-01-06, Greg King
|
||||
;
|
||||
|
||||
.export em_libref
|
||||
.export joy_libref
|
||||
.export mouse_libref
|
||||
.export ser_libref
|
||||
.export tgi_libref
|
||||
|
@ -11,6 +12,7 @@
|
|||
.import _exit
|
||||
|
||||
em_libref := _exit
|
||||
joy_libref := _exit
|
||||
mouse_libref := _exit
|
||||
ser_libref := _exit
|
||||
tgi_libref := _exit
|
||||
|
|
|
@ -1,44 +1,29 @@
|
|||
;
|
||||
; Default mouse callbacks for the CX16
|
||||
;
|
||||
; 2019-12-25, Greg King
|
||||
;
|
||||
; All functions in this module should be interrupt-safe
|
||||
; because they might be called from an interrupt handler.
|
||||
; 2020-01-10, Greg King
|
||||
;
|
||||
|
||||
.export _mouse_def_callbacks
|
||||
|
||||
.import MOUSE_GET, SPRITE_SET_POSITION
|
||||
.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: jsr msprite
|
||||
lda VERA::DATA0
|
||||
and #<~VERA::SPRITE::DEPTH::LAYER1
|
||||
sta VERA::DATA0
|
||||
rts
|
||||
hide: ldx #%10000000
|
||||
stx gREG::r0H
|
||||
bra mse
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Show the mouse pointer.
|
||||
|
||||
show: jsr msprite
|
||||
lda VERA::DATA0
|
||||
ora #VERA::SPRITE::DEPTH::LAYER1
|
||||
sta VERA::DATA0
|
||||
rts
|
||||
show: ldx #gREG::r0
|
||||
jsr MOUSE_GET
|
||||
mse: lda #$00 ; mouse sprite
|
||||
jmp SPRITE_SET_POSITION
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Prepare to move the mouse pointer.
|
||||
|
@ -53,13 +38,13 @@ draw: ; Fall through
|
|||
; --------------------------------------------------------------------------
|
||||
; Move the mouse pointer X position to the value in .XA .
|
||||
|
||||
movex: ; Already set by drivers
|
||||
movex: ; Already done by Kernal
|
||||
; Fall through
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; 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
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
;
|
||||
; 2019-11-06, Greg King
|
||||
; 2020-01-06, Greg King
|
||||
;
|
||||
; /* Video mode defines */
|
||||
; #define VIDEOMODE_40x30 0x00
|
||||
; #define VIDEOMODE_80x60 0x02
|
||||
; #define VIDEOMODE_320x240 0x80
|
||||
; #define VIDEOMODE_320x200 0x80
|
||||
; #define VIDEOMODE_SWAP (-1)
|
||||
;
|
||||
; signed char __fastcall__ videomode (signed char Mode);
|
||||
|
@ -16,29 +16,25 @@
|
|||
|
||||
.export _videomode
|
||||
|
||||
.import SCRMOD
|
||||
.import SCREEN_SET_MODE
|
||||
.include "cx16.inc"
|
||||
|
||||
|
||||
.proc _videomode
|
||||
tax
|
||||
clc ; (Get old mode)
|
||||
jsr SCRMOD
|
||||
pha
|
||||
txa
|
||||
ldx SCREEN_MODE ; Get old mode
|
||||
phx
|
||||
|
||||
sec ; (Set new mode)
|
||||
jsr SCRMOD
|
||||
jsr SCREEN_SET_MODE
|
||||
|
||||
pla ; Get back old mode
|
||||
bcs @L1
|
||||
ldx #>$0000 ; Clear high byte
|
||||
bcs @L1
|
||||
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
|
||||
jsr SCRMOD
|
||||
lda #<-1
|
||||
tax
|
||||
@L1: sta SCREEN_MODE
|
||||
dex
|
||||
txa
|
||||
rts
|
||||
.endproc
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;
|
||||
; 2019-12-23, Greg King
|
||||
; 2020-01-08, Greg King
|
||||
;
|
||||
; void waitvsync (void);
|
||||
; /* Wait for the start of the next video field. */
|
||||
|
@ -12,10 +12,10 @@
|
|||
.include "cx16.inc"
|
||||
|
||||
_waitvsync:
|
||||
ldx VIA1::PRA2 ; (TIMER is in RAM bank 0)
|
||||
stz VIA1::PRA2
|
||||
ldx VIA1::PRA ; (TIMER is in RAM bank 0)
|
||||
stz VIA1::PRA
|
||||
lda TIMER + 2
|
||||
: cmp TIMER + 2
|
||||
beq :- ; Wait for next jiffy
|
||||
stx VIA1::PRA2
|
||||
stx VIA1::PRA
|
||||
rts
|
||||
|
|
Loading…
Add table
Reference in a new issue