1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-09 13:25:06 +00:00

Merge branch 'master' into ca65_jmp_abs_wrap_error

This commit is contained in:
Brad Smith
2023-05-03 21:12:37 -04:00
committed by GitHub
149 changed files with 1649 additions and 519 deletions

View File

@@ -134,7 +134,22 @@ You can refer to Annex B of the ISO C99 standard ([here](https://www.open-std.or
* Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context. * Hexadecimal number constants should be used except where decimal or binary numbers make much more sense in that constant's context.
* Hexadecimal letters should be upper-case. * Hexadecimal letters should be upper-case.
* When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes). * When you set two registers or two memory locations to an immediate 16-bit zero, you should use the expressions ```#<$0000``` and ```#>$0000``` (they make it obvious where you are putting the lower and upper bytes).
* If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) * If a function is declared to return a char-sized value, it actually must return an integer-sized value. (When cc65 promotes a returned value, it sometimes assumes that the value already is an integer.) This must be done in one of the following ways:
<pre>
lda #RETURN_VALUE
ldx #0 ; return value is char
</pre>
or, if the value is 0, you can use:
<pre>
lda #RETURN_VALUE
.assert RETURN_VALUE = 0
tax
</pre>
sometimes jumping to return0 could save a byte:
<pre>
.assert RETURN_VALUE = 0
jmp return 0
</pre>
* Functions, that are intended for a platform's system library, should be optimized as much as possible. * Functions, that are intended for a platform's system library, should be optimized as much as possible.
* Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast. * Sometimes, there must be a trade-off between size and speed. If you think that a library function won't be used often, then you should make it small. Otherwise, you should make it fast.
* Comments that are put on the right side of instructions must be aligned (start in the same character columns). * Comments that are put on the right side of instructions must be aligned (start in the same character columns).

View File

@@ -12,7 +12,7 @@ Core team members:
* [Christian Groessler](https://github.com/groessler): Atari, Atari5200, and CreatiVision library Maintainer * [Christian Groessler](https://github.com/groessler): Atari, Atari5200, and CreatiVision library Maintainer
* [dqh](https://github.com/dqh-au): GHA help * [dqh](https://github.com/dqh-au): GHA help
* [Greg King](https://github.com/greg-king5): all around hackery * [Greg King](https://github.com/greg-king5): all around hackery
* [groepaz](https://github.com/mrdudz): CBM libary, Project Maintainer * [groepaz](https://github.com/mrdudz): CBM library, Project Maintainer
* [Oliver Schmidt](https://github.com/oliverschmidt): Apple II library Maintainer * [Oliver Schmidt](https://github.com/oliverschmidt): Apple II library Maintainer
External contributors: External contributors:

View File

@@ -239,12 +239,12 @@ 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
SCREEN_PTR := $0262 ; Pointer to current row on text screen (16 bits) SCREEN_PTR := $0262 ; Pointer to current row on text screen (16 bits)
STATUS := $0289 ; Status from previous I/O operation STATUS := $0287 ; Status from previous I/O operation
IN_DEV := $028D ; Current input device number IN_DEV := $028B ; Current input device number
OUT_DEV := $028E ; Current output device number OUT_DEV := $028C ; Current output device number
FNAM_LEN := $0291 ; Length of filename FNAM_LEN := $028F ; Length of filename
SECADR := $0293 ; Secondary address SECADR := $0291 ; Secondary address
DEVNUM := $0294 ; Device number DEVNUM := $0292 ; Device number
CURS_COLOR := $0373 ; Color under the cursor CURS_COLOR := $0373 ; Color under the cursor
CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground) CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground)
RVS := $0377 ; Reverse flag RVS := $0377 ; Reverse flag
@@ -258,8 +258,8 @@ LLEN := $0386 ; Line length
NLINES := $0387 ; Number of screen lines NLINES := $0387 ; Number of screen lines
; BASIC ; BASIC
VARTAB := $03E2 ; Pointer to start of BASIC variables VARTAB := $03E1 ; Pointer to start of BASIC variables
MEMSIZE := $03EA ; Pointer to highest BASIC RAM location (+1) MEMSIZE := $03E9 ; Pointer to highest BASIC RAM location (+1)
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; Vector and other locations ; Vector and other locations

View File

@@ -15,6 +15,10 @@ OUTCHR := $1EA0 ; Output character
INTCHR := $1E5A ; Input character without case conversion INTCHR := $1E5A ; Input character without case conversion
DUMPT := $1800 ; Dump memory to tape DUMPT := $1800 ; Dump memory to tape
LOADT := $1873 ; Load memory from tape LOADT := $1873 ; Load memory from tape
START := $1C4F ; Enter KIM-1 monitor
SCANDS := $1F1F ; Scan 7-segment display
KEYIN := $1F40 ; Open up keyboard channel
GETKEY := $1F6A ; Return key from keyboard
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------

View File

@@ -277,6 +277,8 @@ XRECLK = $3C ; Reset clock
XCLCL = $3D ; Close clock XCLCL = $3D ; Close clock
XWRCLK = $3E ; Displays clock in the address in A & Y registers XWRCLK = $3E ; Displays clock in the address in A & Y registers
XFSEEK = $3F ; Only in Orix
; Sound primitives ; Sound primitives
XSONPS = $40 ; Send data to PSG register (14 values) XSONPS = $40 ; Send data to PSG register (14 values)
XOUPS = $42 ; Send Oups sound into PSG XOUPS = $42 ; Send Oups sound into PSG

View File

@@ -184,7 +184,7 @@ Here is a description of all the command line options:
Enable an emulation feature. This is identical as using <tt/.FEATURE/ Enable an emulation feature. This is identical as using <tt/.FEATURE/
in the source with two exceptions: Feature names must be lower case, and in the source with two exceptions: Feature names must be lower case, and
each feature must be specified by using an extra <tt/--feature/ option, each feature must be specified by using a separate <tt/--feature/ option,
comma separated lists are not allowed. comma separated lists are not allowed.
See the discussion of the <tt><ref id=".FEATURE" name=".FEATURE"></tt> See the discussion of the <tt><ref id=".FEATURE" name=".FEATURE"></tt>
@@ -439,6 +439,15 @@ The assembler accepts
<tt><ref id=".P4510" name=".P4510"></tt> command was given). <tt><ref id=".P4510" name=".P4510"></tt> command was given).
</itemize> </itemize>
On 6502-derived platforms the <tt/BRK/ instruction has an optional signature
byte. If omitted, the assembler will only produce only 1 byte.
<tscreen><verb>
brk ; 1-byte: $00
brk $34 ; 2-bytes: $00 $34
brk #$34 ; 2-bytes: $00 $34
</verb></tscreen>
<sect1>65816 mode<p> <sect1>65816 mode<p>
@@ -456,6 +465,17 @@ mnemonics:
<item><tt>TSA</tt> is an alias for <tt>TSC</tt> <item><tt>TSA</tt> is an alias for <tt>TSC</tt>
</itemize> </itemize>
The <tt/MVN/ and <tt/MVP/ instructions accept two different argument forms.
Either two bank bytes may be given with a <tt/#/ prefix,
or two far addresses whose high byte will be used.
<tscreen><verb>
mvn #^src, #^dst ; bank of src to bank of dst
mvn src, dst ; bank of src to bank of dst
mvp #$12, #$78 ; bank $12 to $78
mvp $123456, $789ABC ; bank $12 to $78
</verb></tscreen>
<sect1>6502X mode<label id="6502X-mode"><p> <sect1>6502X mode<label id="6502X-mode"><p>
@@ -2027,7 +2047,7 @@ Here's a list of all control commands and a description, what they do:
<sect1><tt>.A16</tt><label id=".A16"><p> <sect1><tt>.A16</tt><label id=".A16"><p>
Valid only in 65816 mode. Switch the accumulator to 16 bit. Valid only in 65816 mode. Assume the accumulator is 16 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 16 bit operands for immediate accumulator addressing mode. create 16 bit operands for immediate accumulator addressing mode.
@@ -2037,7 +2057,7 @@ Here's a list of all control commands and a description, what they do:
<sect1><tt>.A8</tt><label id=".A8"><p> <sect1><tt>.A8</tt><label id=".A8"><p>
Valid only in 65816 mode. Switch the accumulator to 8 bit. Valid only in 65816 mode. Assume the accumulator is 8 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 8 bit operands for immediate accu addressing mode. create 8 bit operands for immediate accu addressing mode.
@@ -2120,15 +2140,15 @@ Here's a list of all control commands and a description, what they do:
</verb></tscreen> </verb></tscreen>
the assembler will force a segment alignment to the least common multiple of the assembler will force a segment alignment to the least common multiple of
15, 18 and 251 - which is 22590. To protect the user against errors, the 15, 18 and 251 - which is 22590. To protect the user against errors, when the
assembler will issue a warning when the combined alignment exceeds 256. The combined alignment is larger than the explicitly requested alignments,
command line option <tt><ref id="option--large-alignment" the assembler will issue a warning if it also exceeds 256. The command line
name="--large-alignment"></tt> will disable this warning. option <tt><ref id="option--large-alignment" name="--large-alignment"></tt>
will disable this warning.
Please note that with alignments that are a power of two (which were the Please note that with only alignments that are a power of two, a warning will
only alignments possible in older versions of the assembler), the problem is never occur, because the least common multiple of powers to the same base is
less severe, because the least common multiple of powers to the same base is always simply the larger one.
always the larger one.
@@ -2263,7 +2283,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
Switch on or off case sensitivity on identifiers. The default is off Switch on or off case sensitivity on identifiers. The default is off
(that is, identifiers are case sensitive), but may be changed by the (that is, identifiers are case sensitive), but may be changed by the
-i switch on the command line. -i switch on the command line.
The command must be followed by a '+' or '-' character to switch the The command can be followed by a '+' or '-' character to switch the
option on or off respectively. option on or off respectively.
Example: Example:
@@ -2412,7 +2432,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
Switch on or off debug info generation. The default is off (that is, Switch on or off debug info generation. The default is off (that is,
the object file will not contain debug infos), but may be changed by the the object file will not contain debug infos), but may be changed by the
-g switch on the command line. -g switch on the command line.
The command must be followed by a '+' or '-' character to switch the The command can be followed by a '+' or '-' character to switch the
option on or off respectively. option on or off respectively.
Example: Example:
@@ -2522,7 +2542,19 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.ENDMAC, .ENDMACRO</tt><label id=".ENDMACRO"><p> <sect1><tt>.ENDMAC, .ENDMACRO</tt><label id=".ENDMACRO"><p>
Marks the end of a macro definition. Marks the end of a macro definition. Note, <tt>.ENDMACRO</tt> should be on
its own line to successfully end the macro definition. It is possible to use
<tt><ref id=".DEFINE" name=".DEFINE"></tt> to create a symbol that references
<tt>.ENDMACRO</tt> without ending the macro definition.
Example:
<tscreen><verb>
.macro new_mac
.define startmac .macro
.define endmac .endmacro
.endmacro
</verb></tscreen>
See: <tt><ref id=".DELMACRO" name=".DELMACRO"></tt>, See: <tt><ref id=".DELMACRO" name=".DELMACRO"></tt>,
<tt><ref id=".EXITMACRO" name=".EXITMACRO"></tt>, <tt><ref id=".EXITMACRO" name=".EXITMACRO"></tt>,
@@ -2746,15 +2778,19 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
This directive may be used to enable one or more compatibility features This directive may be used to enable one or more compatibility features
of the assembler. While the use of <tt/.FEATURE/ should be avoided when of the assembler. While the use of <tt/.FEATURE/ should be avoided when
possible, it may be useful when porting sources written for other possible, it may be useful when porting sources written for other
assemblers. There is no way to switch a feature off, once you have assemblers. After the feature name an optional '+' or '-' may specify whether
enabled it, so using to enable or disable the feature (enable if omitted). Multiple features may be
enabled, separated by commas. Examples:
<tscreen><verb> <tscreen><verb>
.FEATURE xxx ; enable c_comments
.feature c_comments
.feature c_comments +
; enable force_range, disable underline_in_numbers, enable labels_without_colons
.feature force_range, underline_in_numbers -, labels_without_colons +
.feature force_range +, underline_in_numbers off, labels_without_colons on
</verb></tscreen> </verb></tscreen>
will enable the feature until end of assembly is reached.
The following features are available: The following features are available:
<descrip> <descrip>
@@ -2833,6 +2869,23 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
overridden. When using this feature, you may also get into trouble if overridden. When using this feature, you may also get into trouble if
later versions of the assembler define new keywords starting with a dot. later versions of the assembler define new keywords starting with a dot.
<tag><tt>long_jsr_jmp_rts</tt><label id="long_jsr_jmp_rts"></tag>
Affects 65816 mode only.
Allows <tt>jsr</tt> and <tt>jmp</tt> to produce long jumps if the target
address has been previously declared in a <tt>far</tt> segment,
or imported as <tt>far</tt>.
Otherwise <tt>jsl</tt> and <tt>jml</tt> must be used instead.
Also allows <tt><ref id=".SMART" name=".SMART"></tt> to convert <tt>rts</tt>
to a long return <tt>rtl</tt> when the enclosing scope or memory model
indicates returning from a <tt>far</tt> procedure.
This permits compatibility with the old behavior of this assembler, or other
assemblers which similarly allowed <tt>jsr</tt> and <tt>jmp</tt> to be used
this way.
<tag><tt>loose_char_term</tt><label id="loose_char_term"></tag> <tag><tt>loose_char_term</tt><label id="loose_char_term"></tag>
Accept single quotes as well as double quotes as terminators for char Accept single quotes as well as double quotes as terminators for char
@@ -3044,7 +3097,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.I16</tt><label id=".I16"><p> <sect1><tt>.I16</tt><label id=".I16"><p>
Valid only in 65816 mode. Switch the index registers to 16 bit. Valid only in 65816 mode. Assume the index registers are 16 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 16 bit operands for immediate operands. create 16 bit operands for immediate operands.
@@ -3055,7 +3108,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.I8</tt><label id=".I8"><p> <sect1><tt>.I8</tt><label id=".I8"><p>
Valid only in 65816 mode. Switch the index registers to 8 bit. Valid only in 65816 mode. Assume the index registers are 8 bit.
Note: This command will not emit any code, it will tell the assembler to Note: This command will not emit any code, it will tell the assembler to
create 8 bit operands for immediate operands. create 8 bit operands for immediate operands.
@@ -3327,7 +3380,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
Note: Line continuations do not work in a comment. A backslash at the Note: Line continuations do not work in a comment. A backslash at the
end of a comment is treated as part of the comment and does not trigger end of a comment is treated as part of the comment and does not trigger
line continuation. line continuation.
The command must be followed by a '+' or '-' character to switch the The command can be followed by a '+' or '-' character to switch the
option on or off respectively. option on or off respectively.
Example: Example:
@@ -3342,7 +3395,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".CHARMAP" name=".CH
<sect1><tt>.LIST</tt><label id=".LIST"><p> <sect1><tt>.LIST</tt><label id=".LIST"><p>
Enable output to the listing. The command must be followed by a boolean Enable output to the listing. The command can be followed by a boolean
switch ("on", "off", "+" or "-") and will enable or disable listing switch ("on", "off", "+" or "-") and will enable or disable listing
output. output.
The option has no effect if the listing is not enabled by the command line The option has no effect if the listing is not enabled by the command line
@@ -3987,7 +4040,7 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
<sect1><tt>.SMART</tt><label id=".SMART"><p> <sect1><tt>.SMART</tt><label id=".SMART"><p>
Switch on or off smart mode. The command must be followed by a '+' or '-' Switch on or off smart mode. The command can be followed by a '+' or '-'
character to switch the option on or off respectively. The default is off character to switch the option on or off respectively. The default is off
(that is, the assembler doesn't try to be smart), but this default may be (that is, the assembler doesn't try to be smart), but this default may be
changed by the -s switch on the command line. changed by the -s switch on the command line.
@@ -4002,7 +4055,9 @@ See: <tt><ref id=".ASCIIZ" name=".ASCIIZ"></tt>,<tt><ref id=".BYTE" name=".BYTE"
the assembler cannot trace the execution flow this may lead to false the assembler cannot trace the execution flow this may lead to false
results in some cases. If in doubt, use the <tt/.Inn/ and <tt/.Ann/ results in some cases. If in doubt, use the <tt/.Inn/ and <tt/.Ann/
instructions to tell the assembler about the current settings. instructions to tell the assembler about the current settings.
<item>In 65816 mode, replace a <tt/RTS/ instruction by <tt/RTL/ if it is <item>In 65816 mode, if the <tt><ref id="long_jsr_jmp_rts"
name="long_jsr_jmp_rts"></tt> feature is enabled,
smart mode will replace a <tt/RTS/ instruction by <tt/RTL/ if it is
used within a procedure declared as <tt/far/, or if the procedure has used within a procedure declared as <tt/far/, or if the procedure has
no explicit address specification, but it is <tt/far/ because of the no explicit address specification, but it is <tt/far/ because of the
memory model used. memory model used.
@@ -4207,8 +4262,13 @@ macro actually takes in the definition. You may also leave intermediate
parameters empty. Empty parameters are replaced by empty space (that is, parameters empty. Empty parameters are replaced by empty space (that is,
they are removed when the macro is expanded). If you have a look at our they are removed when the macro is expanded). If you have a look at our
macro definition above, you will see, that replacing the "addr" parameter macro definition above, you will see, that replacing the "addr" parameter
by nothing will lead to wrong code in most lines. To help you, writing by nothing will lead to wrong code in most lines.
macros with a variable parameter list, there are some control commands:
The names "a", "x" and "y" should be avoided for macro parameters, as these
will usually conflict with the 6502 registers.
For writing macros with a variable parameter list, control commands are
available:
<tt><ref id=".IFBLANK" name=".IFBLANK"></tt> tests the rest of the line and <tt><ref id=".IFBLANK" name=".IFBLANK"></tt> tests the rest of the line and
returns true, if there are any tokens on the remainder of the line. Since returns true, if there are any tokens on the remainder of the line. Since
@@ -4219,15 +4279,15 @@ opposite.
Look at this example: Look at this example:
<tscreen><verb> <tscreen><verb>
.macro ldaxy a, x, y .macro ldaxy i, j, k
.ifnblank a .ifnblank i
lda #a lda #i
.endif .endif
.ifnblank x .ifnblank j
ldx #x ldx #j
.endif .endif
.ifnblank y .ifnblank k
ldy #y ldy #k
.endif .endif
.endmacro .endmacro
</verb></tscreen> </verb></tscreen>

View File

@@ -6,7 +6,8 @@
<abstract> <abstract>
Internal details of cc65 code generation, Internal details of cc65 code generation,
such as calling assembly functions from C. such as the expected linker configuration,
and calling assembly functions from C.
</abstract> </abstract>
<!-- Table of contents --> <!-- Table of contents -->
@@ -16,6 +17,76 @@ such as calling assembly functions from C.
<sect>Linker configuration<p>
The C libraries and code generation depend directly on a suitable linker configuration.
There are premade configuration files in the <tt/cfg&sol;/ directory, normally chosen by the
linker's selected target. These can be used as a template for customization.
The C libraries depend on several special segments to be defined in your linker configuration.
Generated code will also use some of them by default.
Some platform libraries have additional special segments.
Memory areas are free to be defined in a way that is appropriate to each platform,
and the segments they contain are used as a layer of semantics and abstraction,
to allow much of the reorganization to be done with the linker config,
rather than requiring platform-specific code source changes.
<sect1><tt/ZEROPAGE/ segment<p>
Used by the C library and generated code for efficient internal and temporary state storage,
also called "pseudo-registers".
<sect1><tt/STARTUP/ segment<p>
Used by each platform instance of the C library in <tt/crt0.s/ to contain the entry point
of the program.
The startup module will export <tt/__STARTUP__ : absolute = 1/ to force the linker to
always include <tt/crt0.s/ from the library.
<sect1><tt/CODE/ segment<p>
The default segment for generated code, and most C library code will be located here.
Use <tt/#pragma code-name/ to redirect generated code to another segment.
<sect1><tt/BSS/ segment<p>
Used for uninitialized variables.
Originally an acronym for "Block Started by Symbol", but the meaning of this is now obscure.
Use <tt/#pragma bss-name/ to redirect uninitialized variables to another segment.
<sect1><tt/DATA/ segment<p>
Used for initialized variables.
On some platforms, this may be initialized as part of the program loading process,
but on others it may have a separate <tt/LOAD/ and <tt/RUN/ address,
allowing <tt/copydata/ to copy the initialization from the loaded location
into their run destination in RAM.
Use <tt/#pragma data-name/ to redirect initialized variables to another segment.
<sect1><tt/RODATA/ segment<p>
Used for read-only (constant) data.
Use <tt/#pragma rodata-name/ to redirect constant data to another segment.
<sect1><tt/FEATURES/ table<p>
This currently defines table locations for the <tt/CONDES/
constructor, destructor, and interruptor features.
Some platform libraries use these.
The constructors will be called with <tt/initlib/ at startup,
and the destructors with <tt/donelib/ at program exit.
Interruptors are called with <tt/callirq/.
<sect>Calling assembly functions from C<p> <sect>Calling assembly functions from C<p>
<sect1>Calling conventions<p> <sect1>Calling conventions<p>

View File

@@ -741,7 +741,7 @@ Here is a description of all the command line options:
<tag><tt/return-type/</tag> <tag><tt/return-type/</tag>
Warn about no return statement in function returning non-void. Warn about no return statement in function returning non-void.
<tag><tt/struct-param/</tag> <tag><tt/struct-param/</tag>
Warn when passing structs by value. Warn when passing structs by value. (Disabled by default.)
<tag><tt/unknown-pragma/</tag> <tag><tt/unknown-pragma/</tag>
Warn about #pragmas that aren't recognized by cc65. Warn about #pragmas that aren't recognized by cc65.
<tag><tt/unreachable-code/</tag> <tag><tt/unreachable-code/</tag>
@@ -806,9 +806,8 @@ and the one defined by the ISO standard:
<item> The datatypes "float" and "double" are not available. <item> The datatypes "float" and "double" are not available.
<p> <p>
<item> C Functions may not return structs (or unions), and structs may not <item> C Functions may pass and return structs (or unions) by value, but only
be passed as parameters by value. However, struct assignment *is* of 1, 2 or 4 byte sizes.
possible.
<p> <p>
<item> Most of the C library is available with only the fastcall calling <item> Most of the C library is available with only the fastcall calling
convention (<ref id="extension-fastcall" name="see below">). It means convention (<ref id="extension-fastcall" name="see below">). It means

View File

@@ -59,7 +59,7 @@
Contains hints on creating the most effective code with cc65. Contains hints on creating the most effective code with cc65.
<tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag> <tag><htmlurl url="cc65-intern.html" name="cc65-intern.html"></tag>
Describes internal details of cc65, such as calling conventions. Describes internal details of cc65: linker configuration, calling conventions, etc.
<tag><htmlurl url="using-make.html" name="using-make.html"></tag> <tag><htmlurl url="using-make.html" name="using-make.html"></tag>
Build programs, using the GNU Make utility. Build programs, using the GNU Make utility.

View File

@@ -45,8 +45,10 @@ system configuration before compiling and linking user programs.
The ROMs and I/O areas are defined in the configuration files, as are most of the entry points The ROMs and I/O areas are defined in the configuration files, as are most of the entry points
for useful subroutines in the KIM-1 monitor ROM. cc65 generated programs compiled and linked for useful subroutines in the KIM-1 monitor ROM. cc65 generated programs compiled and linked
using 4k config run in the memory range of &dollar;200 - &dollar;0FFF. The 60k config expands using 4k config run in the memory range of &dollar;200 - &dollar;0FFF. The 60k config expands
this range to &dollar;DFFF. The starting memory location and entry point for running the program is this range to &dollar;DFFF. When using the 4k config the starting memory location and entry point
&dollar;200, so when the program is transferred to the KIM-1, it is executed by typing '200 G'. for running the program is &dollar;200, so when the program is transferred to the KIM-1, it is
executed by typing '200 G'. With the 60k config the default starting memory location and entry
point is &dollar;2000.
Special locations: Special locations:
@@ -65,7 +67,7 @@ Special locations:
<sect>Platform specific header files<p> <sect>Platform specific header files<p>
Programs containing KIM-1 code may use the <tt/kim.h/ header file. See the header file for more information. Programs containing KIM-1 code may use the <tt/kim1.h/ header file. See the header file for more information.
<sect>Loadable drivers<p> <sect>Loadable drivers<p>

View File

@@ -56,5 +56,18 @@ int __fastcall__ loadt (unsigned char);
/* Write to tape */ /* Write to tape */
int __fastcall__ dumpt (unsigned char, const void*, const void*); int __fastcall__ dumpt (unsigned char, const void*, const void*);
/* End of sym1.h */
/* Write to 7-segment LED display. Due to hardware limitations it only
** displays briefly, so must be called repeatedly to update the
** display.
**/
void __fastcall__ scandisplay(unsigned char left, unsigned char middle, unsigned char right);
/*
** Get a keypress from the keypad. Returns $00-$0F(0-F), $10(AD), $11(DA), $12(+),
** $13(GO), $14(PC) or $15 for no keypress.
**/
int __fastcall__ getkey();
/* End of kim1.h */
#endif #endif

View File

@@ -73,7 +73,8 @@ INSTALL:
and #$f0 and #$f0
cmp #$80 cmp #$80
bne @L1 bne @L1
lda #EM_ERR_OK .assert EM_ERR_OK = 0, error
txa
rts rts
@L1: lda #EM_ERR_NO_DEVICE @L1: lda #EM_ERR_NO_DEVICE
; rts ; rts

View File

@@ -71,8 +71,9 @@ INSTALL:
stx gettype+2 stx gettype+2
gettype:jsr $0000 gettype:jsr $0000
sta ostype sta ostype
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; Fall through ; Fall through
; UNINSTALL routine. Is called before the driver is removed from memory. ; UNINSTALL routine. Is called before the driver is removed from memory.

View File

@@ -133,8 +133,8 @@ next: inc ptr1+1
bcc :+ bcc :+
; Mouse firmware not found ; Mouse firmware not found
lda #<MOUSE_ERR_NO_DEVICE lda #MOUSE_ERR_NO_DEVICE
ldx #>MOUSE_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
; Check Pascal 1.1 Firmware Protocol ID bytes ; Check Pascal 1.1 Firmware Protocol ID bytes

View File

@@ -168,8 +168,9 @@ SER_CLOSE:
sta ACIA_CMD,x sta ACIA_CMD,x
; Done, return an error code ; Done, return an error code
: lda #<SER_ERR_OK : lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
stx Index ; Mark port as closed stx Index ; Mark port as closed
rts rts
@@ -256,23 +257,24 @@ SER_OPEN:
; Done ; Done
stx Index ; Mark port as open stx Index ; Mark port as open
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Device (hardware) not found ; Device (hardware) not found
NoDevice:lda #<SER_ERR_NO_DEVICE NoDevice:lda #SER_ERR_NO_DEVICE
ldx #>SER_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
; Invalid parameter ; Invalid parameter
InvParam:lda #<SER_ERR_INIT_FAILED InvParam:lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud:lda #<SER_ERR_BAUD_UNAVAIL InvBaud:lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -292,8 +294,8 @@ SER_GET:
: lda RecvFreeCnt ; (25) : lda RecvFreeCnt ; (25)
cmp #$FF cmp #$FF
bne :+ bne :+
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -336,8 +338,8 @@ SER_PUT:
; Put byte into send buffer & send ; Put byte into send buffer & send
: ldy SendFreeCnt : ldy SendFreeCnt
bne :+ bne :+
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
: ldy SendTail : ldy SendTail
@@ -346,7 +348,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$FF ; TryHard = true lda #$FF ; TryHard = true
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -359,7 +362,8 @@ SER_STATUS:
lda ACIA_STATUS,x lda ACIA_STATUS,x
ldx #$00 ldx #$00
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -379,11 +383,12 @@ SER_IOCTL:
bcs :+ bcs :+
stx Slot stx Slot
tax ; SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
: lda #<SER_ERR_INV_IOCTL : lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -69,7 +69,8 @@ INSTALL:
lda #$34 lda #$34
sta PACTL sta PACTL
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -62,7 +62,8 @@ JOY_COUNT = 4 ; Number of joysticks we support
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -137,9 +137,10 @@ INSTALL:
ldx YPos+1 ldx YPos+1
jsr CMOVEY jsr CMOVEY
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -268,9 +268,10 @@ INSTALL:
and #$0f and #$0f
sta old_porta_vbi sta old_porta_vbi
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -132,9 +132,10 @@ INSTALL:
ldx YPos+1 ldx YPos+1
jsr CMOVEY jsr CMOVEY
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -135,8 +135,8 @@ my_CIOV:
.code .code
invbaud: invbaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
openerr: openerr:
rts rts
@@ -229,8 +229,9 @@ SER_OPEN:
jsr my_CIOV jsr my_CIOV
bmi cioerr bmi cioerr
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
inverr: jmp my___inviocb inverr: jmp my___inviocb
@@ -240,8 +241,8 @@ cioerr:
jsr my_fddecusage ; decrement usage counter of fd as open failed jsr my_fddecusage ; decrement usage counter of fd as open failed
init_err: init_err:
ldx #0
lda #SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #0 ; return value is char
rts rts
;---- open the device ;---- open the device
@@ -313,8 +314,9 @@ SER_CLOSE:
stx rshand+1 stx rshand+1
inx inx
stx cm_run stx cm_run
@done: lda #<SER_ERR_OK @done: lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -365,16 +367,16 @@ SER_GET:
rts rts
@nix_da:lda #SER_ERR_NO_DATA @nix_da:lda #SER_ERR_NO_DATA
ldx #0 ldx #0 ; return value is char
rts rts
ser_error: ser_error:
lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/ lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/
ldx #0 ldx #0 ; return value is char
rts rts
ni_err: lda #SER_ERR_NOT_OPEN ni_err: lda #SER_ERR_NOT_OPEN
ldx #0 ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -427,8 +429,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -456,8 +458,8 @@ search: lda HATABS,y ; get device name
; R: device not found, return error ; R: device not found, return error
lda #<SER_ERR_NO_DEVICE lda #SER_ERR_NO_DEVICE
ldx #0 ldx #0 ; return value is char
rts rts
; R: device found, initialize jump table into main program ; R: device found, initialize jump table into main program
@@ -554,8 +556,9 @@ found: lda ptr3
pla pla
sta ptr3 sta ptr3
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts

View File

@@ -47,7 +47,8 @@ INSTALL:
lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in lda #$04 ; enable POT input from the joystick ports, see section "GTIA" in
sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html sta CONSOL ; http://www.atarimuseum.com/videogames/consoles/5200/conv_to_5200.html
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -62,8 +62,9 @@ INSTALL:
sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high
reset: reset:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -55,11 +55,12 @@ INSTALL:
lda VIA::PRA lda VIA::PRA
and #%00100000 and #%00100000
bne ijkPresent bne ijkPresent
lda #<JOY_ERR_NO_DEVICE lda #JOY_ERR_NO_DEVICE
.byte $2C ; Skip next opcode .byte $2C ; Skip next opcode
ijkPresent: ijkPresent:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -58,7 +58,8 @@ temp2: .byte $00
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -141,8 +141,9 @@ SER_CLOSE:
sta ACIA::CMD,x sta ACIA::CMD,x
; Done, return an error code ; Done, return an error code
: lda #<SER_ERR_OK : lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
stx Index ; Mark port as closed stx Index ; Mark port as closed
rts rts
@@ -205,8 +206,9 @@ SER_OPEN:
; Done ; Done
stx Index ; Mark port as open stx Index ; Mark port as open
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
@@ -235,8 +237,8 @@ SER_GET:
: lda RecvFreeCnt ; (25) : lda RecvFreeCnt ; (25)
cmp #$FF cmp #$FF
bne :+ bne :+
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -277,8 +279,8 @@ SER_PUT:
; Put byte into send buffer & send ; Put byte into send buffer & send
: ldy SendFreeCnt : ldy SendFreeCnt
bne :+ bne :+
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
: ldy SendTail : ldy SendTail
@@ -287,7 +289,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$FF ; TryHard = true lda #$FF ; TryHard = true
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -299,7 +302,8 @@ SER_STATUS:
lda ACIA::STATUS lda ACIA::STATUS
ldx #$00 ldx #$00
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -308,8 +312,8 @@ SER_STATUS:
; Must return an SER_ERR_xx code in a/x. ; Must return an SER_ERR_xx code in a/x.
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -215,7 +215,8 @@ SETPALETTE:
jsr PAPER jsr PAPER
ldy #1 ldy #1
jsr flipcolor jsr flipcolor
dey ; TGI_ERR_OK .assert TGI_ERR_OK = 0, error
dey
sty ERROR sty ERROR
sty PARAM1+1 sty PARAM1+1
jmp INK jmp INK

View File

@@ -87,16 +87,17 @@ INSTALL:
cli cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@ram_present: @ram_present:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -120,16 +120,16 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@@ -87,16 +87,17 @@ INSTALL:
cli cli
cmp tmp1 cmp tmp1
beq @ram_present beq @ram_present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@ram_present: @ram_present:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -68,8 +68,9 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -107,8 +107,9 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage stx curpage
stx curpage+1 ; Invalidate the current page stx curpage+1 ; Invalidate the current page
.assert EM_ERR_OK = 0, error
inx inx
txa ; A = X = EM_ERR_OK txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -97,13 +97,14 @@ INSTALL:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@notpresent: @notpresent:
@readonly: @readonly:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -126,8 +126,9 @@ size_found:
pagecount_ok: pagecount_ok:
stx pagecount stx pagecount
sty pagecount+1 sty pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
; common REU setup for size check ; common REU setup for size check

View File

@@ -121,8 +121,9 @@ INSTALL:
lda vdc_cset_save lda vdc_cset_save
jsr vdcputreg jsr vdcputreg
@keep64kBit: @keep64kBit:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@@ -53,8 +53,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -194,9 +194,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -228,9 +228,10 @@ INSTALL:
jsr MoveX jsr MoveX
cli cli
; Done, return zero. ; Done
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts

View File

@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y sta (ptr3),y
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts

View File

@@ -187,8 +187,9 @@ SetNMI: sta NMIVec
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -264,22 +265,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -300,8 +302,9 @@ SER_CLOSE:
; Return OK ; Return OK
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -322,8 +325,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -370,7 +373,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@@ -379,7 +382,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -392,7 +396,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -402,8 +407,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -77,12 +77,13 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
rts rts
nomem: ldx #>EM_ERR_NO_DEVICE nomem: ldx #EM_ERR_NO_DEVICE
lda #<EM_ERR_NO_DEVICE lda #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -120,13 +120,14 @@ INSTALL:
dex dex
@noextradex: @noextradex:
stx bankcount stx bankcount
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@not_present: @not_present:
cli cli
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -158,13 +158,14 @@ INSTALL:
jsr restore_data jsr restore_data
cpy #$01 cpy #$01
beq @present beq @present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -147,13 +147,14 @@ INSTALL:
jsr restore_data jsr restore_data
cpy #$01 cpy #$01
beq @present beq @present
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -121,16 +121,17 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE .assert EM_ERR_OK = 0, error
tax
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@@ -76,13 +76,14 @@ INSTALL:
beq @setok beq @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -82,13 +82,14 @@ INSTALL:
cmp #$AA cmp #$AA
bne @notpresent bne @notpresent
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; use rts from UNINSTALL below ; use rts from UNINSTALL below
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -65,8 +65,9 @@ window: .res 256 ; Memory "window"
INSTALL: INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -98,13 +98,13 @@ INSTALL:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
@notpresent: @notpresent:
@readonly: @readonly:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -127,8 +127,9 @@ size_found:
pagecount_ok: pagecount_ok:
stx pagecount stx pagecount
sty pagecount+1 sty pagecount+1
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
; common REU setup for size check ; common REU setup for size check
@@ -152,6 +153,7 @@ reu_size_check_common:
nodevice: nodevice:
lda #EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
.assert EM_ERR_OK = 0, error
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -87,8 +87,8 @@ INSTALL:
bne @L0 bne @L0
iny iny
bne @L0 bne @L0
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ; ldx #0 ; return value is char
rts rts
@present: @present:
@@ -131,8 +131,9 @@ INSTALL:
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
@endok: @endok:
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@@ -93,15 +93,16 @@ INSTALL:
; DTV not found ; DTV not found
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@present: @present:
ldx #$FF ldx #$FF
stx curpage+1 ; Invalidate curpage stx curpage+1 ; Invalidate curpage
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A/X = EM_ERR_OK inx
txa
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -59,8 +59,9 @@ temp4: .byte 0
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -100,12 +100,14 @@ masktable:
; ;
INSTALL: INSTALL:
lda #JOY_ERR_OK ; Assume we have a joystick lda #JOY_ERR_OK ; Assume we have a "joystick"
ldx VIC_CLK_128 ; Test for a C128 .assert JOY_ERR_OK = 0, error
cpx #$FF tax ; Set high byte
ldy VIC_CLK_128 ; Test for a C128
cpy #$FF
bne @C128 ; Jump if we have one bne @C128 ; Jump if we have one
lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad
@C128: ldx #0 ; Set high byte @C128:
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -52,8 +52,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -56,8 +56,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -152,9 +152,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@@ -307,8 +308,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -168,6 +168,7 @@ INSTALL:
; Done, return zero. ; Done, return zero.
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts
@@ -319,8 +320,8 @@ INFO: jsr POS
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -156,9 +156,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@@ -312,8 +313,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -139,9 +139,10 @@ INSTALL:
jsr CMOVEY jsr CMOVEY
cli cli
; Done, return zero (= MOUSE_ERR_OK) ; Done
ldx #$00 ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@@ -297,8 +298,8 @@ INFO: jsr POS
; Must return an error code in a/x. ; Must return an error code in a/x.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -161,8 +161,9 @@ SetNMI: sta NMIVec
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -238,22 +239,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -274,8 +276,9 @@ SER_CLOSE:
; Return OK ; Return OK
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -296,8 +299,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -344,7 +347,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@@ -353,7 +356,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -366,7 +370,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -376,8 +381,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -81,8 +81,9 @@ INSTALL:
sbc #$00 sbc #$00
sta pagecount sta pagecount
@L1: lda #<EM_ERR_OK @L1: lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -175,6 +175,7 @@ INSTALL:
; Done, return zero. ; Done, return zero.
lda #MOUSE_ERR_OK lda #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
tax tax
rts rts
@@ -331,8 +332,8 @@ INFO: jsr POS
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -140,7 +140,8 @@ INSTALL:
; Done, return zero. ; Done, return zero.
ldx #>MOUSE_ERR_OK ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@@ -315,8 +316,8 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
; Must return an error code in .XA. ; Must return an error code in .XA.
; ;
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -148,8 +148,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -217,22 +218,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -253,8 +255,8 @@ SER_GET:
@L1: lda RecvFreeCnt @L1: lda RecvFreeCnt
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -301,7 +303,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@@ -310,7 +312,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -328,7 +331,8 @@ SER_STATUS:
sta (ptr1,x) sta (ptr1,x)
lda IndReg lda IndReg
sta ExecReg sta ExecReg
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -338,8 +342,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -81,8 +81,9 @@ INSTALL:
sbc #$00 sbc #$00
sta pagecount sta pagecount
@L1: lda #<EM_ERR_OK @L1: lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -149,8 +149,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -218,22 +219,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -254,8 +256,8 @@ SER_GET:
@L1: lda RecvFreeCnt @L1: lda RecvFreeCnt
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -302,7 +304,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@@ -311,7 +313,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -339,8 +342,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -502,10 +502,10 @@ DoFormat:
; It is a character ; It is a character
jsr GetIntArg ; Get the argument (promoted to int) jsr GetIntArg ; Get the argument (promoted to int)
sta Buf ; Place it as zero terminated string... sta Buf ; Place it into the buffer
lda #0 ldx #0
sta Buf+1 ; ...into the buffer lda #1 ; Buffer length is 1
jmp HaveArg ; Done jmp HaveArg1
; Is it an integer? ; Is it an integer?
@@ -671,6 +671,7 @@ HaveArg:
lda Str lda Str
ldx Str+1 ldx Str+1
jsr _strlen ; Get length of argument jsr _strlen ; Get length of argument
HaveArg1: ; Jumped into here from %c handling
sta ArgLen sta ArgLen
stx ArgLen+1 stx ArgLen+1

View File

@@ -59,7 +59,8 @@ JOY_RIGHT = $08
; ;
INSTALL: lda #JOY_ERR_OK INSTALL: lda #JOY_ERR_OK
ldx #>$0000 .assert JOY_ERR_OK = 0, error
tax
; rts ; Fall through ; rts ; Fall through
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -55,8 +55,9 @@ JOY_COUNT = $05 ; Number of joysticks we support
; Must return a JOY_ERR_xx code in .XA . ; Must return a JOY_ERR_xx code in .XA .
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -139,7 +139,8 @@ INSTALL:
; Done, return zero ; Done, return zero
ldx #>MOUSE_ERR_OK ldx #MOUSE_ERR_OK
.assert MOUSE_ERR_OK = 0, error
txa txa
rts rts
@@ -300,8 +301,8 @@ INFO: jsr BUTTONS ; Will not touch ptr1
; specific data in ptr1, and the ioctl code in A. ; specific data in ptr1, and the ioctl code in A.
; Must return an error code in .XA . ; Must return an error code in .XA .
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
ldx #>MOUSE_ERR_INV_IOCTL ldx #0 ; return value is char
; rts ; Fall through ; rts ; Fall through
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -47,8 +47,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -125,8 +125,9 @@ INSTALL:
pla pla
sta $01 sta $01
plp plp
lda #<EM_ERR_OK lda #EM_ERR_OK
ldx #>EM_ERR_OK .assert EM_ERR_OK = 0, error
tax
rts rts
test64k: test64k:

View File

@@ -53,8 +53,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -10,7 +10,7 @@
.include "modload.inc" .include "modload.inc"
.import joy_clear_ptr .import joy_clear_ptr
.import return0 .import return0, return1
@@ -31,7 +31,6 @@ _joy_unload:
jmp return0 ; Return JOY_ERR_OK jmp return0 ; Return JOY_ERR_OK
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #JOY_ERR_NO_DRIVER .assert JOY_ERR_NO_DRIVER = 1, error
rts jmp return1 ; Return JOY_ERR_NO_DRIVER

View File

@@ -40,8 +40,6 @@ _init: cld ; Clear decimal mode
jsr _main jsr _main
; Back from main (this is also the _exit entry). There may be a more elegant way to ; Back from main (this is also the _exit entry). Jumps to the KIM-1 monitor.
; return to the monitor on the KIM-1, but I don't know it!
_exit: brk
_exit: jmp START

18
libsrc/kim1/getkey.s Normal file
View File

@@ -0,0 +1,18 @@
;
; int __fastcall__ getkey();
;
.include "kim1.inc"
.import popa
.export _getkey
.proc _getkey
jsr KEYIN ; Open up keyboard channel
jsr GETKEY ; Get key code
ldx #0 ; MSB of return value is zero
rts
.endproc

View File

@@ -27,15 +27,10 @@ begin: dec ptr2
beq done ; If buffer full, return beq done ; If buffer full, return
getch: jsr INTCHR ; Get character using Monitor ROM call getch: jsr INTCHR ; Get character using Monitor ROM call
;jsr OUTCHR ; Echo it
and #$7F ; Clear top bit and #$7F ; Clear top bit
cmp #$07 ; Check for '\a' cmp #$0D ; Check for '\r'
bne chkcr ; ...if BEL character
;jsr BEEP ; Make beep sound TODO
chkcr: cmp #$0D ; Check for '\r'
bne putch ; ...if CR character bne putch ; ...if CR character
lda #$0A ; Replace with '\n' lda #$0A ; Replace with '\n'
jsr OUTCHR ; and echo it
putch: ldy #$00 ; Put char into return buffer putch: ldy #$00 ; Put char into return buffer
sta (ptr1),y sta (ptr1),y

21
libsrc/kim1/scandisplay.s Normal file
View File

@@ -0,0 +1,21 @@
;
; void __fastcall__ scandisplay(unsigned char left, unsigned char middle, unsigned char right);
;
.include "kim1.inc"
.import popa
.export _scandisplay
.proc _scandisplay
sta $F9 ; Rightmost display data
jsr popa
sta $FA ; Middle display data
jsr popa
sta $FB ; Leftmost display data
jsr SCANDS
rts
.endproc

View File

@@ -28,11 +28,10 @@ begin: dec ptr2
outch: ldy #0 outch: ldy #0
lda (ptr1),y lda (ptr1),y
pha ; Save A (changed by OUTCHR)
jsr OUTCHR ; Send character using Monitor call jsr OUTCHR ; Send character using Monitor call
cmp #$07 ; Check for '\a' pla ; Restore A
bne chklf ; ...if BEL character cmp #$0A ; Check for '\n'
;jsr BEEP ; Make beep sound
chklf: cmp #$0A ; Check for 'n'
bne next ; ...if LF character bne next ; ...if LF character
lda #$0D ; Add a carriage return lda #$0D ; Add a carriage return
jsr OUTCHR jsr OUTCHR

View File

@@ -58,8 +58,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -75,8 +75,9 @@ SER_UNINSTALL:
SER_CLOSE: SER_CLOSE:
; Disable interrupts ; Disable interrupts
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -190,8 +191,8 @@ SER_OPEN:
cmp #SER_BAUD_134_5 cmp #SER_BAUD_134_5
beq setbaudrate beq setbaudrate
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
setprescaler: setprescaler:
stx TIM4CTLA stx TIM4CTLA
@@ -238,12 +239,13 @@ checkhs:
lda contrl lda contrl
ora #RxIntEnable|ResetErr ora #RxIntEnable|ResetErr
sta SERCTL sta SERCTL
lda #<SER_ERR_OK lda #SER_ERR_OK
ldx #>SER_ERR_OK .assert SER_ERR_OK = 0, error
tax
rts rts
invparameter: invparameter:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -255,8 +257,8 @@ SER_GET:
lda RxPtrIn lda RxPtrIn
cmp RxPtrOut cmp RxPtrOut
bne GetByte bne GetByte
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
GetByte: GetByte:
ldy RxPtrOut ldy RxPtrOut
@@ -277,8 +279,8 @@ SER_PUT:
ina ina
cmp TxPtrOut cmp TxPtrOut
bne PutByte bne PutByte
lda #<SER_ERR_OVERFLOW lda #SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW ldx #0 ; return value is char
rts rts
PutByte: PutByte:
ldy TxPtrIn ldy TxPtrIn
@@ -296,7 +298,8 @@ PutByte:
sta TxDone sta TxDone
plp plp
@L1: @L1:
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -317,8 +320,8 @@ SER_STATUS:
; Must return an SER_ERR_xx code in a/x. ; Must return an SER_ERR_xx code in a/x.
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL lda #SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -8,7 +8,7 @@
.include "mouse-kernel.inc" .include "mouse-kernel.inc"
.include "modload.inc" .include "modload.inc"
.import return0 .import return0, return1
@@ -29,7 +29,6 @@ _mouse_unload:
jmp return0 ; Return MOUSE_ERR_OK jmp return0 ; Return MOUSE_ERR_OK
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #<MOUSE_ERR_NO_DRIVER .assert MOUSE_ERR_NO_DRIVER = 1, error
rts jmp return1 ; Return MOUSE_ERR_NO_DRIVER

View File

@@ -53,7 +53,8 @@ JOY_COUNT = 2 ; Number of joysticks we support
INSTALL: INSTALL:
lda #JOY_ERR_OK lda #JOY_ERR_OK
ldx #0 .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -50,8 +50,9 @@ padbuffer: .res JOY_COUNT
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -51,8 +51,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -58,8 +58,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -157,8 +157,9 @@ SER_CLOSE:
; Done, return an error code ; Done, return an error code
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -225,22 +226,23 @@ SER_OPEN:
; Done ; Done
lda #<SER_ERR_OK lda #SER_ERR_OK
tax ; A is zero .assert SER_ERR_OK = 0, error
tax
rts rts
; Invalid parameter ; Invalid parameter
InvParam: InvParam:
lda #<SER_ERR_INIT_FAILED lda #SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED ldx #0 ; return value is char
rts rts
; Baud rate not available ; Baud rate not available
InvBaud: InvBaud:
lda #<SER_ERR_BAUD_UNAVAIL lda #SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL ldx #0 ; return value is char
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -261,8 +263,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25) @L1: lda RecvFreeCnt ; (25)
cmp #$ff cmp #$ff
bne @L2 bne @L2
lda #<SER_ERR_NO_DATA lda #SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA ldx #0 ; return value is char
rts rts
; Check for flow stopped & enough free: release flow control ; Check for flow stopped & enough free: release flow control
@@ -309,7 +311,7 @@ SER_PUT:
@L2: ldx SendFreeCnt @L2: ldx SendFreeCnt
bne @L3 bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero lda #SER_ERR_OVERFLOW ; X is already zero
rts rts
@L3: ldx SendTail @L3: ldx SendTail
@@ -318,7 +320,8 @@ SER_PUT:
dec SendFreeCnt dec SendFreeCnt
lda #$ff lda #$ff
jsr TryToSend jsr TryToSend
lda #<SER_ERR_OK lda #SER_ERR_OK
.assert SER_ERR_OK = 0, error
tax tax
rts rts
@@ -331,7 +334,8 @@ SER_STATUS:
lda ACIA_STATUS lda ACIA_STATUS
ldx #0 ldx #0
sta (ptr1,x) sta (ptr1,x)
txa ; SER_ERR_OK .assert SER_ERR_OK = 0, error
txa
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -341,8 +345,8 @@ SER_STATUS:
; ;
SER_IOCTL: SER_IOCTL:
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL ldx #0 ; return value is char
rts ; Run into IRQ instead rts ; Run into IRQ instead
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------

View File

@@ -10,7 +10,7 @@
.include "modload.inc" .include "modload.inc"
.import ser_clear_ptr .import ser_clear_ptr
.import return0 .import return0, return1
@@ -28,10 +28,10 @@ _ser_unload:
tax tax
pla ; Get pointer to driver pla ; Get pointer to driver
jsr _mod_free ; Free the driver jsr _mod_free ; Free the driver
jmp return0 ; Return SER_ERR_OK .assert SER_ERR_OK = 0, error
jmp return0
no_driver: no_driver:
tax ; X = 0
pla ; Remove pushed junk pla ; Remove pushed junk
lda #<SER_ERR_NO_DRIVER .assert SER_ERR_NO_DRIVER = 1, error
rts jmp return1

View File

@@ -46,8 +46,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead

View File

@@ -54,8 +54,9 @@ INSTALL:
sta VIA2::PRB sta VIA2::PRB
; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after ; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after
; But if some one press fire or press direction, we could reach others values which could break joystick detection. ; But if some one press fire or press direction, we could reach others values which could break joystick detection.
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

39
libsrc/telestrat/lseek.s Normal file
View File

@@ -0,0 +1,39 @@
;
; Jede (jede@oric.org), 2023-03-13
;
; off_t __fastcall__ lseek(int fd, off_t offset, int whence);
.export _lseek
.include "telestrat.inc"
.include "zeropage.inc"
.import popax
.proc _lseek
; Save whence
sta tmp1
; Skip X
; Get offset and store
jsr popax
sta tmp2
stx tmp3
jsr popax
sta RESB
stx RESB+1
; Get FD
jsr popax
; Does not need X
sta RES ; Save FD
lda tmp2
ldy tmp3
ldx tmp1 ; Get whence
BRK_TELEMON XFSEEK
rts
.endproc

View File

@@ -119,16 +119,16 @@ INSTALL:
bne @setok bne @setok
@notpresent: @notpresent:
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
ldx #>EM_ERR_NO_DEVICE ldx #0 ; return value is char
rts rts
@setok: @setok:
lda #0 lda #0
sta pagecount sta pagecount
stx pagecount+1 stx pagecount+1
lda #<EM_ERR_OK .assert EM_ERR_OK = 0, error
ldx #>EM_ERR_OK tax
rts rts
check: check:

View File

@@ -71,12 +71,13 @@ INSTALL:
ldx #$FF ldx #$FF
stx curpage ; Invalidate the current page stx curpage ; Invalidate the current page
inx ; X = 0 .assert EM_ERR_OK = 0, error
txa ; A = X = EM_ERR_OK inx
txa
rts rts
nomem: ldx #>EM_ERR_NO_DEVICE nomem: ldx #0 ; return value is char
lda #<EM_ERR_NO_DEVICE lda #EM_ERR_NO_DEVICE
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -53,8 +53,9 @@ JOY_COUNT = 3 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

View File

@@ -57,8 +57,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
; ;
INSTALL: INSTALL:
lda #<JOY_ERR_OK lda #JOY_ERR_OK
ldx #>JOY_ERR_OK .assert JOY_ERR_OK = 0, error
tax
; rts ; Run into UNINSTALL instead ; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------

52
samples/kim1/kimKeyDisp.c Normal file
View File

@@ -0,0 +1,52 @@
/* Example illustrating scandisplay() and getkey() functions. */
#include <stdio.h>
#include <kim1.h>
int main (void)
{
int i, j, k, l;
int last = 15;
printf("\nKIM-1 Demo\n");
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
for (k = 0; k < 16; k++) {
scandisplay(i, j, k);
l = getkey();
if (l != last) {
switch (l) {
case 0x0: case 0x1: case 0x2: case 0x3:
case 0x4: case 0x5: case 0x6: case 0x7:
case 0x8: case 0x9: case 0xa: case 0xb:
case 0xc: case 0xd: case 0xe: case 0xf:
printf("Key pressed: %X\n", l);
break;
case 0x10:
printf("Key pressed: AD\n");
break;
case 0x11:
printf("Key pressed: DA\n");
break;
case 0x12:
printf("Key pressed: +\n");
break;
case 0x13:
printf("Key pressed: GO\n");
break;
case 0x14:
printf("Key pressed: PC\n");
break;
}
last = l;
}
}
}
}
return 0;
}

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