+ --warnings-as-errors
+
+ An error will be generated if any warnings were produced.
+
+
@@ -431,6 +439,15 @@ The assembler accepts
command was given).
+On 6502-derived platforms the
+ brk ; 1-byte: $00
+ brk $34 ; 2-bytes: $00 $34
+ brk #$34 ; 2-bytes: $00 $34
+
+
65816 mode
@@ -448,6 +465,17 @@ mnemonics:
TSA is an alias for TSC
+The
+ 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
+
+
6502X mode
@@ -1381,10 +1409,6 @@ either a string or an expression value.
.endmacro
- This command is new and must be enabled with the
-
.BANK
@@ -2019,7 +2043,7 @@ Here's a list of all control commands and a description, what they do:
.A16
- 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
create 16 bit operands for immediate accumulator addressing mode.
@@ -2029,7 +2053,7 @@ Here's a list of all control commands and a description, what they do:
.A8
- 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
create 8 bit operands for immediate accu addressing mode.
@@ -2112,15 +2136,15 @@ Here's a list of all control commands and a description, what they do:
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
- assembler will issue a warning when the combined alignment exceeds 256. The
- command line option will disable this warning.
+ 15, 18 and 251 - which is 22590. To protect the user against errors, when the
+ combined alignment is larger than the explicitly requested alignments,
+ the assembler will issue a warning if it also exceeds 256. The command line
+ option
+ will disable this warning.
- Please note that with alignments that are a power of two (which were the
- only alignments possible in older versions of the assembler), the problem is
- less severe, because the least common multiple of powers to the same base is
- always the larger one.
+ Please note that with only alignments that are a power of two, a warning will
+ never occur, because the least common multiple of powers to the same base is
+ always simply the larger one.
@@ -2255,7 +2279,7 @@ See: , , ,
- Marks the end of a macro definition.
+ Marks the end of a macro definition. Note, .ENDMACRO should be on
+ its own line to successfully end the macro definition. It is possible to use
+ to create a symbol that references
+ .ENDMACRO without ending the macro definition.
+
+ Example:
+
+
+ .macro new_mac
+ .define startmac .macro
+ .define endmac .endmacro
+ .endmacro
+
See: ,
,
@@ -2738,25 +2774,23 @@ See: ,[
-
- Enables the .ADDRSIZE pseudo function. This function is experimental and not enabled by default.
-
- See also: ]
-
at_in_identifiers
Accept the at character ('@') as a valid character in identifiers. The
@@ -2825,6 +2859,23 @@ See: ,[
+
+ Affects 65816 mode only.
+
+ Allows ]jsr and jmp to produce long jumps if the target
+ address has been previously declared in a far segment,
+ or imported as far .
+ Otherwise jsl and jml must be used instead.
+
+ Also allows to convert rts
+ to a long return rtl when the enclosing scope or memory model
+ indicates returning from a far procedure.
+
+ This permits compatibility with the old behavior of this assembler, or other
+ assemblers which similarly allowed jsr and jmp to be used
+ this way.
+
loose_char_term
Accept single quotes as well as double quotes as terminators for char
@@ -3036,7 +3087,7 @@ See: ,
- 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
create 16 bit operands for immediate operands.
@@ -3047,7 +3098,7 @@ See: ,
- 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
create 8 bit operands for immediate operands.
@@ -3319,7 +3370,7 @@ See: , ,
- 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
output.
The option has no effect if the listing is not enabled by the command line
@@ -3979,7 +4030,7 @@ See: ,.SMART
- 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
(that is, the assembler doesn't try to be smart), but this default may be
changed by the -s switch on the command line.
@@ -3994,7 +4045,9 @@ See: ,[In 65816 mode, replace a ]In 65816 mode, if the feature is enabled,
+ smart mode will replace a tests the rest of the line and
returns true, if there are any tokens on the remainder of the line. Since
@@ -4211,15 +4269,15 @@ opposite.
Look at this example:
-.macro ldaxy a, x, y
-.ifnblank a
- lda #a
+.macro ldaxy i, j, k
+.ifnblank i
+ lda #i
.endif
-.ifnblank x
- ldx #x
+.ifnblank j
+ ldx #j
.endif
-.ifnblank y
- ldy #y
+.ifnblank k
+ ldy #k
.endif
.endmacro
diff --git a/doc/cc65-intern.sgml b/doc/cc65-intern.sgml
index 8e36578b5..904cee070 100644
--- a/doc/cc65-intern.sgml
+++ b/doc/cc65-intern.sgml
@@ -6,7 +6,8 @@
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.
@@ -16,6 +17,76 @@ such as calling assembly functions from C.
+Linker configuration
+
+The C libraries and code generation depend directly on a suitable linker configuration.
+There are premade configuration files in the
+
+Used by the C library and generated code for efficient internal and temporary state storage,
+also called "pseudo-registers".
+
+
+
+Used by each platform instance of the C library in
+
+The default segment for generated code, and most C library code will be located here.
+
+Use
+
+Used for uninitialized variables.
+Originally an acronym for "Block Started by Symbol", but the meaning of this is now obscure.
+
+Use
+
+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
+
+Used for read-only (constant) data.
+
+Use
+
+This currently defines table locations for the Calling assembly functions from C
Calling conventions
diff --git a/doc/cc65.sgml b/doc/cc65.sgml
index 683249bda..4303edb48 100644
--- a/doc/cc65.sgml
+++ b/doc/cc65.sgml
@@ -741,7 +741,7 @@ Here is a description of all the command line options:
Warn about no return statement in function returning non-void.
- Warn when passing structs by value.
+ Warn when passing structs by value. (Disabled by default.)
Warn about #pragmas that aren't recognized by cc65.
@@ -754,6 +754,8 @@ Here is a description of all the command line options:
Warn about unused function parameters.
Warn about unused variables.
+
+ Warn if numerical constant conversion implies overflow. (Disabled by default.)
The full list of available warning names can be retrieved by using the
@@ -806,9 +808,8 @@ and the one defined by the ISO standard:
- The datatypes "float" and "double" are not available.
-- C Functions may not return structs (or unions), and structs may not
- be passed as parameters by value. However, struct assignment *is*
- possible.
+
- C Functions may pass and return structs (or unions) by value, but only
+ of 1, 2 or 4 byte sizes.
- Most of the C library is available with only the fastcall calling
convention (
[). It means
diff --git a/doc/da65.sgml b/doc/da65.sgml
index bf074a667..3a01ce4f5 100644
--- a/doc/da65.sgml
+++ b/doc/da65.sgml
@@ -115,14 +115,14 @@ Here is a description of all the command line options:
]- 6502dtv
- 65sc02
- 65c02
+
- 65816
- huc6280
- 4510
6502x is for the NMOS 6502 with unofficial opcodes. 6502dtv is for the
emulated CPU of the C64DTV device. huc6280 is the CPU of the PC engine.
- 4510 is the CPU of the Commodore C65. Support for the 65816 currently
- is not available.
+ 4510 is the CPU of the Commodore C65. 65816 is the CPU of the SNES.
@@ -263,8 +263,9 @@ can produce output that can not be re-assembled, when one or more of those
branches point outside of the disassembled memory. This can happen when text
or binary data is processed.
-While there is some code for the 65816 in the sources, it is currently
-unsupported.
+The 65816 support requires annotating ranges with the M and X flag states.
+This can be recorded with an emulator that supports Code and Data Logging,
+for example. Disassemble one bank at a time.
Attribute map
@@ -461,7 +462,8 @@ following attributes are recognized:
END
This gives the end address of the range. The end address is inclusive, that
means, it is part of the range. Of course, it may not be smaller than the
- start address.
+ start address. Optionally, the end may be given as a decimal offset instead
+ of an absolute address, "+3", to specify it as a size.
NAME
This is a convenience attribute. It takes a string argument and will cause
@@ -520,6 +522,16 @@ following attributes are recognized:
+ UNIT
+ Split the table into sections of this size. For example, if you have a
+ ByteTable of size 48, but it has logical groups of size 16, specifying
+ 16 for UNIT adds newlines after every 16 bytes. UNIT is always in bytes.
+
+ ADDRMODE
+ When disassembling 65816 code, this specifies the M and X flag states
+ for this range. It's a string argument of the form "mx", capital letters
+ mean the flag is enabled.
+
@@ -692,6 +704,20 @@ directives explained above:
+Helper scripts
+
+util/parse-bsnes-log.awk is a supplied script for 65816 disassembly,
+to parse bsnes-plus Code-Data log files and output the RANGE sections
+for your info file. For typical usage, you'd check the S-CPU log and trace
+log mask boxes in the bsnes-plus debugger, play through the game, then grep
+for the bank you're disassembling, and pass that to this script.
+
+
+grep ^83 my-game-log | parse-bsnes-log.awk
+
+
+
+
Copyright
da65 (and all cc65 binutils) is (C) Copyright 1998-2011, Ullrich von
diff --git a/doc/doc.css b/doc/doc.css
index e4c316e16..0f6e90d67 100644
--- a/doc/doc.css
+++ b/doc/doc.css
@@ -2,12 +2,14 @@ body {
font-family: arial, helvetica, sans-serif;
font-size: 100%;
text-align: justify;
- margin-left: 110px;
- margin-top: 10px;
- margin-right: 30px;
- margin-bottom: 10px;
+ margin: 0px;
+ padding-left: 110px;
+ padding-top: 10px;
+ padding-right: 30px;
+ padding-bottom: 10px;
background-image: url(doc.png);
background-repeat: repeat-y;
+ background-position:left top;
}
h1, h2, h2 a:link, h2 a:active, h2 a:visited {
@@ -25,7 +27,7 @@ h1 {
}
h2 {
- font-size: 160%;
+ font-size: 150%;
text-shadow: 1px 1px 3px #303030;
letter-spacing: 1px;
margin-top: 2em;
diff --git a/doc/funcref.sgml b/doc/funcref.sgml
index a8593ebb5..2a6d77adc 100644
--- a/doc/funcref.sgml
+++ b/doc/funcref.sgml
@@ -126,6 +126,7 @@ function.
+[
][
@@ -975,7 +976,7 @@ previously been allocated by ]/, / or /.
- Passing a pointer to a block that was is not the result of one of the
-allocation functions, or that has been free'd will give unpredicable results.
+allocation functions, or that has been free'd will give unpredictable results.
- The function is available only as a fastcall function; so, it may be used
only in the presence of a prototype.
@@ -1108,6 +1109,46 @@ considered random to a certain degree.
+
_sound
+
+
+/
+
+- The function is available only as a fastcall function; so, it may be used
+only in the presence of a prototype.
+
- The function is specific to the Atari 8 bit.
+
- Voice can be any of 0-3 different sound channels.
+
- Pitch goes from 0-255 (about 125 Hz to 32 Khz).
+
- Distortion (0-14) uses poly dividers to reshape wave in order to create a noise effect. Use 10 for a "pure" square-wave sound.
+
- Volume (0-15) is the intensity for the wave.
+
- Extra bits in those parameters will be ignored.
+
- Parameters are the same as for the AtariBASIC SOUND statement.
+
+
+
+#include
+int main(void)
+{
+ int i=0;
+ unsigned char j;
+ printf("playing sound \n");
+ for (j=0; j<144; j++) {
+ _sound(1,144-j,10,8); //change the pitch for voice 1
+ for (i=0; i<50; i++); //pause for sound duration
+ }
+ _sound(1,0,0,0); //use zero in other parameters to stop the sound
+ return 0;
+}
+
+
+
+
_stroserror
@@ -4148,7 +4189,7 @@ be used in presence of a prototype.
chdir (getdevicedir (device, buf, sizeof buf));
-cf.
@@ -6908,7 +6949,6 @@ switching the CPU into single clock mode.
-
srand
diff --git a/doc/index.sgml b/doc/index.sgml
index bb3ad5357..727364028 100644
--- a/doc/index.sgml
+++ b/doc/index.sgml
@@ -59,7 +59,7 @@
Contains hints on creating the most effective code with cc65.
- Describes internal details of cc65, such as calling conventions.
+ Describes internal details of cc65: linker configuration, calling conventions, etc.
Build programs, using the GNU Make utility.
@@ -154,6 +154,9 @@
Topics specific to the Bit Corporation Gamate Console.
+
+ Topics specific to the MOS Technology KIM-1.
+
Topics specific to the Atari Lynx Game Console.
diff --git a/doc/kim1.sgml b/doc/kim1.sgml
new file mode 100644
index 000000000..1387d3b19
--- /dev/null
+++ b/doc/kim1.sgml
@@ -0,0 +1,150 @@
+
+
+
+MOS Technology KIM-1 specific information for cc65
+
+
+
+An overview of the KIM-1 runtime system as it is implemented for the cc65 C compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the KIM-1 runtime system as it comes with the cc65 C compiler.
+It describes the memory layout, KIM-1 specific header files, available drivers, and any pitfalls
+specific to the platform.
+
+Please note that KIM-1 specific functions are just mentioned here, they are described in detail
+in the separate . Even functions marked as
+"platform dependent" may be available on more than one platform. Please see the
+function reference for more information.
+
+Binary format
+
+The output format generated by the linker for the KIM-1 target is a raw binary BIN file, which
+is essentially a memory image. You can convert this to a papertape format file using
+Convert8bithexformat or KIMPaper, which are open-source conversion utility programs.
+A papertape format files can be transferred to the KIM-1 using the RS-232 terminal port (TTY),
+just as if the machine-code was entered by hand. Enter 'L' in the TTY and start the paper tape file
+transfer.
+
+
+
+Included with this distribution is a 4k configuration file and a 60k config file. The KIM-1
+on-board memory is limited to 4 kbytes but system memory can be increased to 60 kbytes of
+contiguous RAM with aftermarket add-on boards. So choose the config file that matches your
+system configuration before compiling and linking user programs.
+
+Memory layout
+
+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
+using 4k config run in the memory range of $200 - $0FFF. The 60k config expands
+this range to $DFFF. When using the 4k config the starting memory location and entry point
+for running the program is $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 $2000.
+
+Special locations:
+
+
+
+
+Platform specific header files
+
+Programs containing KIM-1 code may use the Loadable drivers
+
+Graphics drivers
+
+No graphics drivers are currently available for the KIM-1.
+
+Joystick drivers
+
+No joystick driver is currently available for the KIM-1.
+
+Mouse drivers
+
+No mouse drivers are currently available for the KIM-1.
+
+RS232 device drivers
+
+No communication port drivers are currently available for the KIM-1. It has only the "master console"
+e.g. stdin and stdout.
+
+Limitations
+
+Disk I/O
+
+The existing library for the KIM-1 doesn't implement C file I/O.
+
+To be more specific, this limitation means that you cannot use any of the following functions (and a few others):
+
+
+- fopen
+
- fclose
+
- fread
+
- fwrite
+
- ...
+
+
+Other hints
+
+kim1.h
+This header exposes KIM-1 specific I/O functions that are useful for reading and writing its ports and front panel.
+See the Limited memory applications
+
+As stated earlier, there are config files for 4kb and 60kb systems. If you have 60kb RAM, then you will probably
+want to use the kim1-60k configuration, but if not - if you are using the kim1-4k configuration - then you may
+want to use functions like getchar, putchar, gets and puts rather than functions like scanf and printf.
+Printf, for example, requires about 1KB because it needs to know how to process all the format specifiers.
+
+Sample programs
+
+These sample programs can be found in the samples/kim1 directory:
+
+
+- kimHello prints "Hello World!" and then inputs characters, which are echoed on the screen.
+ This program will run on both 4kb and 60kb systems.
+- kimSieve finds the prime numbers up to 100,000 using the Sieve of Eratosthenes algorithm, and prints how many
+ prime numbers were found. This program requires a 60kb system to run.
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied warranty. In no event will the authors be held
+liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter
+it and redistribute it freely, subject to the following restrictions:
+
+
+- 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.
+
- Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+
- This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/ld65.sgml b/doc/ld65.sgml
index 307caeaa4..1ad04b395 100644
--- a/doc/ld65.sgml
+++ b/doc/ld65.sgml
@@ -90,6 +90,7 @@ Long options:
--start-group Start a library group
--target sys Set the target system
--version Print the linker version
+ --warnings-as-errors Treat warnings as errors
---------------------------------------------------------------------------
@@ -330,6 +331,13 @@ Here is a description of all of the command-line options:
directory, in the list of directories specified using
+ --warnings-as-errors
+
+ An error will be generated if any warnings were produced.
+
+
diff --git a/doc/osi.sgml b/doc/osi.sgml
index eeaee4a97..62d466406 100644
--- a/doc/osi.sgml
+++ b/doc/osi.sgml
@@ -187,8 +187,21 @@ Currently the following extra screen configuration modules are implemented:
osic1p-screen-s3-32x28.o : 32 columns by 28 lines mode
for Briel Superboard ///
+osic1p-screen-c1p-48x12.s : 48 columns by 12 lines mode
+for Challenger 1P
+On the Briel Superboard /// you enter 32 column mode by holding down
+the BREAK key on powerup.
+
+On the Challenger 1P you can enable 48 column mode by writing a 1 to
+bit 0 of address $D800, and writing a 0 to go back to 24 column mode.
+You can use code like the following to do this:
+
+
+*(char*)0xd800 = 1; /* Switch to 48 column mode */
+
+
Limitations
stdio implementation
diff --git a/doc/sim65.sgml b/doc/sim65.sgml
index 310de4667..b1e5afbdc 100644
--- a/doc/sim65.sgml
+++ b/doc/sim65.sgml
@@ -44,6 +44,13 @@ The simulator is called as follows:
--version Print the simulator version number
+sim65 will exit with the error code of the simulated program,
+which is limited to an 8-bit result 0-255.
+
+An error in sim65, like bad arguments or an internal problem will exit with Command line options in detail
@@ -126,9 +133,17 @@ a set of built-in paravirtualization functions ([Creating a Test in Assembly]
Assembly tests may similarly be assembled and linked with
-
+
+- Return from
The binary file has a 12 byte header:
diff --git a/doc/sp65.sgml b/doc/sp65.sgml
index 255d7a552..e1bcdd558 100644
--- a/doc/sp65.sgml
+++ b/doc/sp65.sgml
@@ -44,6 +44,7 @@ Short options:
-lc List all possible conversions
-r file[,attrlist] Read an input file
-v Increase verbosity
+ -p tgt,file[,attrlist] Write the palette to a file
-w file[,attrlist] Write the output to a file
Long options:
@@ -56,6 +57,7 @@ Long options:
--slice x,y,w,h Generate a slice from the loaded bitmap
--verbose Increase verbosity
--version Print the version number and exit
+ --palette tgt,file{,attrlist] Write the palette to a file
--write file[,attrlist] Write the output to a file
---------------------------------------------------------------------------
@@ -124,6 +126,13 @@ attribute lists see [.
bugfixes, please include the version number.
+ ]
+ -p, --palette target,filename[,attrlist]
+
+ Write the palette of the input bitmap to a file in a format suitable of
+ the target.
+
+
-w, --write filename[,attrlist]
@@ -265,6 +274,7 @@ of a sprite is roughly 508 pixels but in reality the Lynx screen is only 160 by
102 pixels which makes very large sprites useless.
The number per pixels is taken from the number of colors of the input bitmap.
+You can also force the number of pens used in the conversion.
There are a few attributes that you can give to the conversion software.
@@ -273,7 +283,7 @@ There are a few attributes that you can give to the conversion software.
diff --git a/include/_atari5200os.h b/include/_atari5200os.h
index 5bba43016..196b69e56 100644
--- a/include/_atari5200os.h
+++ b/include/_atari5200os.h
@@ -54,7 +54,21 @@ struct __os {
unsigned char color2; // = $0E PF color 2
unsigned char color3; // = $0F PF color 3
unsigned char color4; // = $10 PF color 4
- unsigned char _free_1[0xEF]; // = $11-$FF User space
+ unsigned char paddl0; // = $11 POT0 Shadow
+ unsigned char paddl1; // = $12 POT1 Shadow
+ unsigned char paddl2; // = $13 POT2 Shadow
+ unsigned char paddl3; // = $14 POT3 Shadow
+ unsigned char paddl4; // = $15 POT4 Shadow
+ unsigned char paddl5; // = $16 POT5 Shadow
+ unsigned char paddl6; // = $17 POT6 Shadow
+ unsigned char paddl7; // = $18 POT7 Shadow
+
+ /*cc65 runtime zero page variables*/
+ unsigned char rowcrs_5200; // = $19 Cursor row (conio)
+ unsigned char colcrs_5200; // = $1A Cursor column (conio)
+ unsigned char* savmsc; // = $1B/$1C Pointer to screen memory (conio)
+
+ unsigned char _filler_1[0xE3]; // = $1D-$FF Filler
/*Stack*/
unsigned char stack[0x100]; // = $100-$1FF Stack
diff --git a/include/_atarios.h b/include/_atarios.h
index ec33b98c9..cbf33bda6 100644
--- a/include/_atarios.h
+++ b/include/_atarios.h
@@ -334,17 +334,17 @@ struct __os {
void (*vserin)(void); // = $020A/$020B POKEY SERIAL INPUT READY IRQ
void (*vseror)(void); // = $020C/$020D POKEY SERIAL OUTPUT READY IRQ
void (*vseroc)(void); // = $020E/$020F POKEY SERIAL OUTPUT COMPLETE IRQ
- void (*vtimr1)(void); // = $0210/$0201 POKEY TIMER 1 IRQ
- void (*vtimr2)(void); // = $0212/$0203 POKEY TIMER 2 IRQ
- void (*vtimr4)(void); // = $0214/$0205 POKEY TIMER 4 IRQ
- void (*vimirq)(void); // = $0216/$0207 IMMEDIATE IRQ VECTOR
- unsigned int cdtmv1; // = $0218/$0210 COUNT DOWN TIMER 1
+ void (*vtimr1)(void); // = $0210/$0211 POKEY TIMER 1 IRQ
+ void (*vtimr2)(void); // = $0212/$0213 POKEY TIMER 2 IRQ
+ void (*vtimr4)(void); // = $0214/$0215 POKEY TIMER 4 IRQ
+ void (*vimirq)(void); // = $0216/$0217 IMMEDIATE IRQ VECTOR
+ unsigned int cdtmv1; // = $0218/$0219 COUNT DOWN TIMER 1
unsigned int cdtmv2; // = $021A/$021B COUNT DOWN TIMER 2
unsigned int cdtmv3; // = $021C/$021D COUNT DOWN TIMER 3
unsigned int cdtmv4; // = $021E/$021F COUNT DOWN TIMER 4
unsigned int cdtmv5; // = $0220/$0221 COUNT DOWN TIMER 5
void (*vvblki)(void); // = $0222/$0223 IMMEDIATE VERTICAL BLANK NMI VECTOR
- void (*vvblkd)(void); // = $0224/$0224 DEFERRED VERTICAL BLANK NMI VECTOR
+ void (*vvblkd)(void); // = $0224/$0225 DEFERRED VERTICAL BLANK NMI VECTOR
void (*cdtma1)(void); // = $0226/$0227 COUNT DOWN TIMER 1 JSR ADDRESS
void (*cdtma2)(void); // = $0228/$0229 COUNT DOWN TIMER 2 JSR ADDRESS
unsigned char cdtmf3; // = $022A COUNT DOWN TIMER 3 FLAG
diff --git a/include/_heap.h b/include/_heap.h
index c054cfa34..62a7f4bed 100644
--- a/include/_heap.h
+++ b/include/_heap.h
@@ -37,13 +37,20 @@ struct freeblock {
/* Variables that describe the heap */
-extern unsigned* _heaporg; /* Bottom of heap */
-extern unsigned* _heapptr; /* Current top */
-extern unsigned* _heapend; /* Upper limit */
-extern struct freeblock* _heapfirst; /* First free block in list */
-extern struct freeblock* _heaplast; /* Last free block in list */
-
+extern unsigned* __heaporg; /* Bottom of heap */
+extern unsigned* __heapptr; /* Current top */
+extern unsigned* __heapend; /* Upper limit */
+extern struct freeblock* __heapfirst; /* First free block in list */
+extern struct freeblock* __heaplast; /* Last free block in list */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heaporg __heaporg
+#define _heapptr __heapptr
+#define _heapend __heapend
+#define _heapfirst __heapfirst
+#define _heaplast __heaplast
+#endif
/* End of _heap.h */
diff --git a/include/apple2.h b/include/apple2.h
index cb15cab97..9f644bc97 100644
--- a/include/apple2.h
+++ b/include/apple2.h
@@ -171,7 +171,7 @@ extern struct {
extern void a2_auxmem_emd[];
extern void a2_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void a2_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
-extern void a2_ssc_ser[];
+extern void a2_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
extern void a2_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void a2_lo_tgi[];
#endif
diff --git a/include/apple2enh.h b/include/apple2enh.h
index 58e0b397f..bfe5cdb18 100644
--- a/include/apple2enh.h
+++ b/include/apple2enh.h
@@ -99,7 +99,7 @@
extern void a2e_auxmem_emd[];
extern void a2e_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
extern void a2e_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
-extern void a2e_ssc_ser[];
+extern void a2e_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
extern void a2e_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void a2e_lo_tgi[];
diff --git a/include/assert.h b/include/assert.h
index a4dcd5d7f..ca8d4acc1 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -42,8 +42,8 @@
#ifdef NDEBUG
# define assert(expr)
#else
-extern void __fastcall__ _afailed (const char*, unsigned);
-# define assert(expr) ((expr)? (void)0 : _afailed(__FILE__, __LINE__))
+extern void __fastcall__ __afailed (const char*, unsigned);
+# define assert(expr) ((expr)? (void)0 : __afailed(__FILE__, __LINE__))
#endif
/* TODO: Guard with #if __CC65_STD__ >= __CC65_STD_C11__ if there
diff --git a/include/atari.h b/include/atari.h
index 781ee7a80..04cacab33 100644
--- a/include/atari.h
+++ b/include/atari.h
@@ -235,6 +235,12 @@ extern void __fastcall__ _scroll (signed char numlines);
/* numlines < 0 scrolls down */
+/*****************************************************************************/
+/* Sound function */
+/*****************************************************************************/
+
+extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
+
/*****************************************************************************/
/* Misc. functions */
/*****************************************************************************/
@@ -261,7 +267,7 @@ extern void atrst_mou[]; /* referred to by mouse_static_stddrv[]
extern void atrami_mou[];
extern void atrtrk_mou[];
extern void atrtt_mou[];
-extern void atrrdev_ser[];
+extern void atrrdev_ser[]; /* referred to by ser_static_stddrv[] */
extern void atr3_tgi[];
extern void atr4_tgi[];
extern void atr5_tgi[];
@@ -286,7 +292,7 @@ extern void atrxst_mou[]; /* referred to by mouse_static_stddrv[]
extern void atrxami_mou[];
extern void atrxtrk_mou[];
extern void atrxtt_mou[];
-extern void atrxrdev_ser[];
+extern void atrxrdev_ser[]; /* referred to by ser_static_stddrv[] */
extern void atrx3_tgi[];
extern void atrx4_tgi[];
extern void atrx5_tgi[];
diff --git a/include/atmos.h b/include/atmos.h
index 227c387aa..38d423c46 100644
--- a/include/atmos.h
+++ b/include/atmos.h
@@ -133,7 +133,7 @@
/* The addresses of the static drivers */
extern void atmos_pase_joy[]; /* Referred to by joy_static_stddrv[] */
extern void atmos_ijk_joy[];
-extern void atmos_acia_ser[];
+extern void atmos_acia_ser[]; /* Referred to by ser_static_stddrv[] */
extern void atmos_228_200_3_tgi[];
extern void atmos_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
diff --git a/include/c128.h b/include/c128.h
index ee1dce99e..5a34904e0 100644
--- a/include/c128.h
+++ b/include/c128.h
@@ -140,7 +140,7 @@ extern void c128_1351_mou[]; /* Referred to by mouse_static_stddrv[] */
extern void c128_joy_mou[];
extern void c128_inkwell_mou[];
extern void c128_pot_mou[];
-extern void c128_swlink_ser[];
+extern void c128_swlink_ser[]; /* Referred to by ser_static_stddrv[] */
extern void c128_hi_tgi[];
extern void c128_vdc_tgi[]; /* Referred to by tgi_static_stddrv[] */
extern void c128_vdc2_tgi[];
diff --git a/include/c64.h b/include/c64.h
index 13d252dcb..ffac801ef 100644
--- a/include/c64.h
+++ b/include/c64.h
@@ -155,7 +155,7 @@ extern void c64_1351_mou[]; /* Referred to by mouse_static_stddrv[]
extern void c64_joy_mou[];
extern void c64_inkwell_mou[];
extern void c64_pot_mou[];
-extern void c64_swlink_ser[];
+extern void c64_swlink_ser[]; /* Referred to by ser_static_stddrv[] */
extern void c64_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
diff --git a/include/cbm.h b/include/cbm.h
index cceb76b1b..0679b2d65 100644
--- a/include/cbm.h
+++ b/include/cbm.h
@@ -225,7 +225,7 @@ void cbm_k_untlk (void);
-/* The cbm_* I/O functions below set _oserror (see errno.h),
+/* The cbm_* I/O functions below set __oserror (see errno.h),
** in case of an error.
**
** error-code BASIC error
@@ -251,7 +251,7 @@ unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void
** address of the file if "data" is the null pointer (like load"name",8,1
** in BASIC).
** Returns number of bytes that were loaded if loading was successful;
-** otherwise 0, "_oserror" contains an error-code, then (see table above).
+** otherwise 0, "__oserror" contains an error-code, then (see table above).
*/
unsigned char __fastcall__ cbm_save (const char* name, unsigned char device,
@@ -274,7 +274,7 @@ void __fastcall__ cbm_close (unsigned char lfn);
int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
/* Reads up to "size" bytes from a file into "buffer".
** Returns the number of actually-read bytes, 0 if there are no bytes left.
-** -1 in case of an error; then, _oserror contains an error-code (see table
+** -1 in case of an error; then, __oserror contains an error-code (see table
** above). (Remember: 0 means end-of-file; -1 means error.)
*/
@@ -282,7 +282,7 @@ int __fastcall__ cbm_write (unsigned char lfn, const void* buffer,
unsigned int size);
/* Writes up to "size" bytes from "buffer" to a file.
** Returns the number of actually-written bytes, or -1 in case of an error;
-** _oserror contains an error-code, then (see above table).
+** __oserror contains an error-code, then (see above table).
*/
unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...);
diff --git a/include/cbm510.h b/include/cbm510.h
index 20b334ed9..8ebbdf3c1 100644
--- a/include/cbm510.h
+++ b/include/cbm510.h
@@ -128,7 +128,7 @@ extern void cbm510_inkwl_mou[];
extern void cbm510_joy_mou[]; /* Referred to by mouse_static_stddrv[] */
extern void cbm510_ram_emd[];
extern void cbm510_std_joy[]; /* Referred to by joy_static_stddrv[] */
-extern void cbm510_std_ser[];
+extern void cbm510_std_ser[]; /* Referred to by ser_static_stddrv[] */
diff --git a/include/cbm610.h b/include/cbm610.h
index de7aa50f8..64beab9e6 100644
--- a/include/cbm610.h
+++ b/include/cbm610.h
@@ -105,7 +105,7 @@
/* The addresses of the static drivers */
extern void cbm610_ram_emd[];
-extern void cbm610_std_ser[];
+extern void cbm610_std_ser[]; /* Referred to by ser_static_stddrv[] */
diff --git a/include/dio.h b/include/dio.h
index 4201728cc..2521a90ff 100644
--- a/include/dio.h
+++ b/include/dio.h
@@ -35,9 +35,9 @@
-/* Please note: All functions in this file will set _oserror *and* return its
-** value. The only exception is dio_open, which will return NULL, but _oserror
-** will be set. All function will also set _oserror in case of successful
+/* Please note: All functions in this file will set __oserror *and* return its
+** value. The only exception is dio_open, which will return NULL, but __oserror
+** will be set. All function will also set __oserror in case of successful
** execution, effectively clearing it.
*/
diff --git a/include/errno.h b/include/errno.h
index 92d304938..8f329e3cc 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -45,12 +45,17 @@
/* Operating system specific error code */
-extern unsigned char _oserror;
+extern unsigned char __oserror;
-extern int _errno;
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _oserror __oserror
+#endif
+
+extern int __errno;
/* System errors go here */
-#define errno _errno
+#define errno __errno
/* errno must be a macro */
@@ -83,27 +88,45 @@ extern int _errno;
-int __fastcall__ _osmaperrno (unsigned char oserror);
-/* Map an operating system specific error code (for example from _oserror)
+int __fastcall__ __osmaperrno (unsigned char oserror);
+/* Map an operating system specific error code (for example from __oserror)
** into one of the E... codes above. It is user callable.
*/
-unsigned char __fastcall__ _seterrno (unsigned char code);
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _osmaperrno __osmaperrno
+#endif
+
+unsigned char __fastcall__ __seterrno (unsigned char code);
/* Set errno to a specific error code and return zero. Used by the library */
-int __fastcall__ _directerrno (unsigned char code);
-/* Set errno to a specific error code, clear _oserror and return -1. Used
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _seterrno __seterrno
+#endif
+
+int __fastcall__ __directerrno (unsigned char code);
+/* Set errno to a specific error code, clear __oserror and return -1. Used
** by the library.
*/
-int __fastcall__ _mappederrno (unsigned char code);
-/* Set _oserror to the given platform specific error code. If it is a real
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _directerrno __directerrno
+#endif
+
+int __fastcall__ __mappederrno (unsigned char code);
+/* Set __oserror to the given platform specific error code. If it is a real
** error code (not zero) set errno to the corresponding system error code
** and return -1. Otherwise return zero.
** Used by the library.
*/
-
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _mappederrno __mappederrno
+#endif
/* End of errno.h */
#endif
diff --git a/include/geos/gconst.h b/include/geos/gconst.h
index e70eb9304..3e42feed7 100644
--- a/include/geos/gconst.h
+++ b/include/geos/gconst.h
@@ -4,13 +4,15 @@
reassembled by Maciej 'YTM/Elysium' Witkowiak
*/
-/* Here are constants which didn't fit into any other cathegory... */
+/* Here are constants which didn't fit into any other category... */
#ifndef _GCONST_H
#define _GCONST_H
-#define NULL 0
-#define FALSE NULL
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+#define FALSE 0
#define TRUE 0xff
#define MOUSE_SPRNUM 0
#define DISK_DRV_LGH 0x0d80
diff --git a/include/kim1.h b/include/kim1.h
new file mode 100644
index 000000000..03c496223
--- /dev/null
+++ b/include/kim1.h
@@ -0,0 +1,73 @@
+/*****************************************************************************/
+/* */
+/* kim1.h */
+/* */
+/* KIM-1 system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2022 Dave Plummer */
+/* Email: davepl@davepl.com */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _KIM1_H
+#define _KIM1_H
+
+/* Check for errors */
+#if !defined(__KIM1__)
+# error This module may only be used when compiling for the KIM-1!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Hardware */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+/* Read from tape */
+int __fastcall__ loadt (unsigned char);
+
+/* Write to tape */
+int __fastcall__ dumpt (unsigned char, const void*, const void*);
+
+
+/* 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
diff --git a/include/locale.h b/include/locale.h
index 3f23e01d2..f408e1ef3 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -39,9 +39,8 @@
/* NULL pointer */
-#ifndef _HAVE_NULL
-#define NULL 0
-#define _HAVE_NULL
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
/* Locale information constants */
@@ -82,6 +81,3 @@ char* __fastcall__ setlocale (int category, const char* locale);
/* End of locale.h */
#endif
-
-
-
diff --git a/include/lynx.h b/include/lynx.h
index 1b4828a72..41dc5acb3 100644
--- a/include/lynx.h
+++ b/include/lynx.h
@@ -115,7 +115,7 @@
/* The addresses of the static drivers */
extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
-extern void lynx_comlynx_ser[];
+extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */
extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
diff --git a/include/osic1p.h b/include/osic1p.h
index d6ab5fee1..479d9fd52 100644
--- a/include/osic1p.h
+++ b/include/osic1p.h
@@ -36,6 +36,24 @@
# error "This module may only be used when compiling for the Challenger 1P!"
#endif
+/* Colors are not functional, display is black and white only. */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+
+#define CH_ULCORNER 0xCC
+#define CH_URCORNER 0xCD
+#define CH_LLCORNER 0xCB
+#define CH_LRCORNER 0xCE
+#define CH_TTEE 0xD9
+#define CH_BTEE 0xD7
+#define CH_LTEE 0xD8
+#define CH_RTEE 0xDA
+#define CH_CROSS 0xDB
+#define CH_HLINE 0x94
+#define CH_VLINE 0x95
+
+#define CH_ENTER 0x0D
+
/* The following #defines will cause the matching functions calls in conio.h
** to be overlaid by macros with the same names, saving the function call
** overhead.
@@ -43,5 +61,6 @@
#define _textcolor(color) COLOR_WHITE
#define _bgcolor(color) COLOR_BLACK
#define _bordercolor(color) COLOR_BLACK
+#define _cpeekcolor(color) COLOR_WHITE
#endif
diff --git a/include/plus4.h b/include/plus4.h
index 325ba7d89..7730938e8 100644
--- a/include/plus4.h
+++ b/include/plus4.h
@@ -56,7 +56,7 @@
/* The addresses of the static drivers */
extern void plus4_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
-extern void plus4_stdser_ser[];
+extern void plus4_stdser_ser[]; /* Referred to by ser_static_stddrv[] */
diff --git a/include/serial.h b/include/serial.h
index 35d7b8f66..0510cd219 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -123,6 +123,13 @@ struct ser_params {
unsigned char handshake; /* Type of handshake to use */
};
+/* The name of the standard serial driver for a platform */
+extern const char ser_stddrv[];
+
+/* The address of the static standard serial driver for a platform */
+extern const void ser_static_stddrv[];
+
+
/*****************************************************************************/
/* Code */
diff --git a/include/setjmp.h b/include/setjmp.h
index 460829e38..5fac25634 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -42,8 +42,8 @@ typedef char jmp_buf [5];
-int __fastcall__ _setjmp (jmp_buf buf);
-#define setjmp _setjmp /* ISO insists on a macro */
+int __fastcall__ __setjmp (jmp_buf buf);
+#define setjmp __setjmp /* ISO insists on a macro */
void __fastcall__ longjmp (jmp_buf buf, int retval) __attribute__((noreturn));
diff --git a/include/signal.h b/include/signal.h
index 0d5f6ad09..d67cebf7c 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -45,12 +45,12 @@ typedef unsigned char sig_atomic_t;
typedef void __fastcall__ (*__sigfunc) (int);
/* Functions that implement SIG_IGN and SIG_DFL */
-void __fastcall__ _sig_ign (int);
-void __fastcall__ _sig_dfl (int);
+void __fastcall__ __sig_ign (int);
+void __fastcall__ __sig_dfl (int);
/* Standard signal handling functions */
-#define SIG_DFL _sig_dfl
-#define SIG_IGN _sig_ign
+#define SIG_DFL __sig_dfl
+#define SIG_IGN __sig_ign
#define SIG_ERR ((__sigfunc) 0x0000)
/* Signal numbers */
diff --git a/include/stddef.h b/include/stddef.h
index ca93edf62..d2bfd6138 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -53,9 +53,8 @@ typedef unsigned size_t;
#endif
/* NULL pointer */
-#ifndef _HAVE_NULL
-#define NULL ((void *) 0)
-#define _HAVE_NULL
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
/* offsetof macro */
@@ -65,6 +64,3 @@ typedef unsigned size_t;
/* End of stddef.h */
#endif
-
-
-
diff --git a/include/stdio.h b/include/stdio.h
index 84a991a98..012b8e2ba 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -38,9 +38,8 @@
/* NULL pointer */
-#ifndef _HAVE_NULL
-#define NULL 0
-#define _HAVE_NULL
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
/* size_t is needed */
@@ -147,7 +146,11 @@ int __fastcall__ vfscanf (FILE* f, const char* format, __va_list ap);
FILE* __fastcall__ fdopen (int fd, const char* mode); /* Unix */
int __fastcall__ fileno (FILE* f); /* Unix */
#endif
-void __fastcall__ _poserror (const char* msg); /* cc65 */
+void __fastcall__ __poserror (const char* msg); /* cc65 */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _poserror __poserror
+#endif
/* Masking macros for some functions */
#define getc(f) fgetc (f) /* ANSI */
diff --git a/include/stdlib.h b/include/stdlib.h
index 99151317f..e789f732b 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -44,6 +44,11 @@ typedef unsigned size_t;
#define _HAVE_size_t
#endif
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
/* Standard exit codes */
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
@@ -92,24 +97,44 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size);
*/
#endif
-void __fastcall__ _heapadd (void* mem, size_t size);
+void __fastcall__ __heapadd (void* mem, size_t size);
/* Add a block to the heap */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapadd __heapadd
+#endif
-size_t __fastcall__ _heapblocksize (const void* block);
+size_t __fastcall__ __heapblocksize (const void* block);
/* Return the size of an allocated block */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapblocksize __heapblocksize
+#endif
-size_t _heapmemavail (void);
+size_t __heapmemavail (void);
/* Return the total free heap space */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapmemavail __heapmemavail
+#endif
-size_t _heapmaxavail (void);
+size_t __heapmaxavail (void);
/* Return the size of the largest free block on the heap */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapmaxavail __heapmaxavail
+#endif
/* Random numbers */
#define RAND_MAX 0x7FFF
int rand (void);
void __fastcall__ srand (unsigned seed);
-void _randomize (void); /* Non-standard */
+void __randomize (void); /* Non-standard */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _randomize __randomize
+#endif
/* Other standard stuff */
void abort (void) __attribute__ ((noreturn));
@@ -130,7 +155,11 @@ unsigned long __fastcall__ strtoul (const char* nptr, char** endptr, int base);
int __fastcall__ system (const char* s);
/* Non-ANSI functions */
-void __fastcall__ _swap (void* p, void* q, size_t size);
+void __fastcall__ __swap (void* p, void* q, size_t size);
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _swap __swap
+#endif
#if __CC65_STD__ == __CC65_STD_CC65__
char* __fastcall__ itoa (int val, char* buf, int radix);
char* __fastcall__ utoa (unsigned val, char* buf, int radix);
@@ -143,6 +172,3 @@ int __fastcall__ putenv (char* s);
/* End of stdlib.h */
#endif
-
-
-
diff --git a/include/string.h b/include/string.h
index 1bd83b385..abaf80e7d 100644
--- a/include/string.h
+++ b/include/string.h
@@ -37,9 +37,8 @@
#define _STRING_H
/* NULL pointer */
-#ifndef _HAVE_NULL
-#define NULL 0
-#define _HAVE_NULL
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
/* size_t is needed */
@@ -74,7 +73,7 @@ void* __fastcall__ memset (void* s, int c, size_t count);
/* The following is an internal function, the compiler will replace memset
** with it if the fill value is zero. Never use this one directly!
*/
-void* __fastcall__ _bzero (void* ptr, size_t n);
+void* __fastcall__ __bzero (void* ptr, size_t n);
/* Non standard: */
#if __CC65_STD__ == __CC65_STD_CC65__
@@ -92,8 +91,12 @@ char* __fastcall__ strupper (char* s);
char* __fastcall__ strqtok (char* s1, const char* s2);
#endif
-const char* __fastcall__ _stroserror (unsigned char errcode);
+const char* __fastcall__ __stroserror (unsigned char errcode);
/* Map an operating system error number to an error message. */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _stroserror __stroserror
+#endif
/* End of string.h */
diff --git a/include/time.h b/include/time.h
index 99bb1c8e3..bfc2ac435 100644
--- a/include/time.h
+++ b/include/time.h
@@ -39,9 +39,8 @@
/* NULL pointer */
-#ifndef _HAVE_NULL
-#define NULL 0
-#define _HAVE_NULL
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
/* size_t is needed */
@@ -89,8 +88,8 @@ struct tm {
# define CLOCKS_PER_SEC 10
#elif defined(__ATARI__) || defined (__LYNX__)
/* Read the clock rate at runtime */
-clock_t _clocks_per_sec (void);
-# define CLOCKS_PER_SEC _clocks_per_sec()
+clock_t __clocks_per_sec (void);
+# define CLOCKS_PER_SEC __clocks_per_sec()
#endif
#define CLOCK_REALTIME 0
diff --git a/libsrc/Makefile b/libsrc/Makefile
index 2018de801..0873d019f 100644
--- a/libsrc/Makefile
+++ b/libsrc/Makefile
@@ -27,6 +27,7 @@ TARGETS = apple2 \
$(CBMS) \
$(GEOS) \
gamate \
+ kim1 \
lynx \
nes \
none \
@@ -38,6 +39,10 @@ TARGETS = apple2 \
sym1 \
telestrat
+TARGETTEST = none \
+ sim6502 \
+ sim65c02
+
DRVTYPES = emd \
joy \
mou \
@@ -52,7 +57,7 @@ OUTPUTDIRS := lib
$(subst ../,,$(wildcard ../target/*/drv/*)) \
$(subst ../,,$(wildcard ../target/*/util))
-.PHONY: all mostlyclean clean install zip lib $(TARGETS)
+.PHONY: all mostlyclean clean install zip lib libtest $(TARGETS)
.SUFFIXES:
@@ -80,6 +85,8 @@ datadir = $(PREFIX)/share/cc65
all lib: $(TARGETS)
+libtest: $(TARGETTEST)
+
mostlyclean:
$(call RMDIR,../libwrk)
@@ -115,9 +122,13 @@ endef # ZIP_recipe
zip:
$(foreach dir,$(OUTPUTDIRS),$(ZIP_recipe))
-$(TARGETS):
+$(TARGETS): | ../lib
@$(MAKE) --no-print-directory $@
+# ../lib must be created globally before doing lib targets in parallel
+../lib:
+ @$(call MKDIR,$@)
+
else # TARGET
CA65FLAGS =
@@ -286,10 +297,12 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib
@echo $(TARGET) - $(JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; Fall through
; UNINSTALL routine. Is called before the driver is removed from memory.
diff --git a/libsrc/apple2/lseek.s b/libsrc/apple2/lseek.s
index b6c31515e..be0078c1b 100644
--- a/libsrc/apple2/lseek.s
+++ b/libsrc/apple2/lseek.s
@@ -107,13 +107,13 @@ seek_common:
einval: lda #EINVAL
; Set __errno
-errno: jsr __directerrno ; leaves -1 in AX
+errno: jsr ___directerrno ; leaves -1 in AX
stx sreg ; extend return value to 32 bits
stx sreg+1
rts
- ; Set __oserror
-oserr: jsr __mappederrno ; leaves -1 in AX
+ ; Set ___oserror
+oserr: jsr ___mappederrno ; leaves -1 in AX
stx sreg ; extend return value to 32 bits
stx sreg+1
rts
diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s
index dfc69a942..c54c09d34 100644
--- a/libsrc/apple2/mou/a2.stdmou.s
+++ b/libsrc/apple2/mou/a2.stdmou.s
@@ -133,8 +133,8 @@ next: inc ptr1+1
bcc :+
; Mouse firmware not found
- lda #MOUSE_ERR_NO_DEVICE
+ lda #MOUSE_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
; Check Pascal 1.1 Firmware Protocol ID bytes
diff --git a/libsrc/apple2/open.s b/libsrc/apple2/open.s
index e47722973..68c203cd6 100644
--- a/libsrc/apple2/open.s
+++ b/libsrc/apple2/open.s
@@ -64,7 +64,7 @@ _open:
errno: jsr incsp4 ; Preserves A
; Set __errno
- jmp __directerrno
+ jmp ___directerrno
; Save fdtab slot
found: tya
@@ -147,8 +147,8 @@ oserr1: ldy tmp2 ; Restore fdtab slot
jsr freebuffer
pla ; Restore oserror code
- ; Set __oserror
- jmp __mappederrno
+ ; Set ___oserror
+ jmp ___mappederrno
open: ldy tmp2 ; Restore fdtab slot
@@ -209,7 +209,7 @@ done: lda tmp1 ; Restore fd
; Return success
ldx #$00
- stx __oserror
+ stx ___oserror
rts
freebuffer:
diff --git a/libsrc/apple2/oserror.s b/libsrc/apple2/oserror.s
index ae3efcacc..5f523340f 100644
--- a/libsrc/apple2/oserror.s
+++ b/libsrc/apple2/oserror.s
@@ -1,14 +1,14 @@
;
; Ullrich von Bassewitz, 17.05.2000
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
;
- .export __osmaperrno
+ .export ___osmaperrno
.include "errno.inc"
-__osmaperrno:
+___osmaperrno:
ldx #ErrTabSize
: cmp ErrTab-2,x ; Search for the error code
beq :+ ; Jump if found
diff --git a/libsrc/apple2/randomize.s b/libsrc/apple2/randomize.s
index 1558d85a7..e9cd063b8 100644
--- a/libsrc/apple2/randomize.s
+++ b/libsrc/apple2/randomize.s
@@ -1,16 +1,16 @@
;
; Ullrich von Bassewitz, 07.11.2002
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "apple2.inc"
-__randomize:
+___randomize:
ldx RNDH ; Use random value supplied by ROM
lda RNDL
jmp _srand ; Initialize generator
diff --git a/libsrc/apple2/read.s b/libsrc/apple2/read.s
index 99c189cbd..d29d6cdfb 100644
--- a/libsrc/apple2/read.s
+++ b/libsrc/apple2/read.s
@@ -52,7 +52,7 @@ _read:
; Device succeeds always
device: lda #$00
- sta __oserror
+ sta ___oserror
; Set counter to zero
sta ptr3
@@ -107,4 +107,4 @@ check: lda ptr3
einval: lda #EINVAL
; Set __errno
-errno: jmp __directerrno
+errno: jmp ___directerrno
diff --git a/libsrc/apple2/rwcommon.s b/libsrc/apple2/rwcommon.s
index e5fd9ae90..769247e63 100644
--- a/libsrc/apple2/rwcommon.s
+++ b/libsrc/apple2/rwcommon.s
@@ -49,10 +49,10 @@ rwcommon:
rwepilog:
; Return success
- sta __oserror ; A = 0
+ sta ___oserror ; A = 0
lda mliparam + MLI::RW::TRANS_COUNT
ldx mliparam + MLI::RW::TRANS_COUNT+1
rts
- ; Set __oserror
-oserr: jmp __mappederrno
+ ; Set ___oserror
+oserr: jmp ___mappederrno
diff --git a/libsrc/apple2/ser/a2.ssc.s b/libsrc/apple2/ser/a2.ssc.s
index a32110ef2..6ad9c3825 100644
--- a/libsrc/apple2/ser/a2.ssc.s
+++ b/libsrc/apple2/ser/a2.ssc.s
@@ -57,7 +57,9 @@
;----------------------------------------------------------------------------
; I/O definitions
-ACIA = $C088
+Offset = $8F ; Move 6502 false read out of I/O to page $BF
+
+ACIA = $C088-Offset
ACIA_DATA = ACIA+0 ; Data register
ACIA_STATUS = ACIA+1 ; Status register
ACIA_CMD = ACIA+2 ; Command register
@@ -166,8 +168,9 @@ SER_CLOSE:
sta ACIA_CMD,x
; Done, return an error code
-: lda #SER_ERR_NO_DEVICE
+NoDevice:lda #SER_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
; Invalid parameter
-InvParam:lda #SER_ERR_INIT_FAILED
+InvParam:lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
-InvBaud:lda #SER_ERR_BAUD_UNAVAIL
+InvBaud:lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -289,8 +294,8 @@ SER_GET:
: lda RecvFreeCnt ; (25)
cmp #$FF
bne :+
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -333,8 +338,8 @@ SER_PUT:
; Put byte into send buffer & send
: ldy SendFreeCnt
bne :+
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
: ldy SendTail
@@ -343,7 +348,8 @@ SER_PUT:
dec SendFreeCnt
lda #$FF ; TryHard = true
jsr TryToSend
- lda #SER_ERR_INV_IOCTL
+: lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/apple2/ser_stat_stddrv.s b/libsrc/apple2/ser_stat_stddrv.s
new file mode 100644
index 000000000..690fe4853
--- /dev/null
+++ b/libsrc/apple2/ser_stat_stddrv.s
@@ -0,0 +1,22 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .ifdef __APPLE2ENH__
+ .import _a2e_ssc_ser
+ .else
+ .import _a2_ssc_ser
+ .endif
+
+.rodata
+
+ .ifdef __APPLE2ENH__
+_ser_static_stddrv := _a2e_ssc_ser
+ .else
+_ser_static_stddrv := _a2_ssc_ser
+ .endif
diff --git a/libsrc/apple2/ser_stddrv.s b/libsrc/apple2/ser_stddrv.s
new file mode 100644
index 000000000..2e8361865
--- /dev/null
+++ b/libsrc/apple2/ser_stddrv.s
@@ -0,0 +1,18 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv:
+ .ifdef __APPLE2ENH__
+ .asciiz "A2E.SSC.SER"
+ .else
+ .asciiz "A2.SSC.SER"
+ .endif
diff --git a/libsrc/apple2/settime.s b/libsrc/apple2/settime.s
index f722f6f40..32ec8ee43 100644
--- a/libsrc/apple2/settime.s
+++ b/libsrc/apple2/settime.s
@@ -68,4 +68,4 @@ enosys: lda #ENOSYS
erange: lda #ERANGE
; Set __errno
-errno: jmp __directerrno
+errno: jmp ___directerrno
diff --git a/libsrc/apple2/write.s b/libsrc/apple2/write.s
index d9dd73ca9..7b50d0705 100644
--- a/libsrc/apple2/write.s
+++ b/libsrc/apple2/write.s
@@ -107,8 +107,8 @@ done: lda #$00
einval: lda #EINVAL
; Set __errno
-errno: jmp __directerrno
+errno: jmp ___directerrno
- ; Set __oserror
-oserr: jmp __mappederrno
+ ; Set ___oserror
+oserr: jmp ___mappederrno
diff --git a/libsrc/atari/clock.s b/libsrc/atari/clock.s
index 853870520..42809c4a4 100644
--- a/libsrc/atari/clock.s
+++ b/libsrc/atari/clock.s
@@ -3,10 +3,10 @@
; originally by Ullrich von Bassewitz and Sidney Cadot
;
; clock_t clock (void);
-; clock_t _clocks_per_sec (void);
+; clock_t __clocks_per_sec (void);
;
- .export _clock, __clocks_per_sec
+ .export _clock, ___clocks_per_sec
.importzp sreg
.include "atari.inc"
@@ -28,7 +28,7 @@
.endproc
-.proc __clocks_per_sec
+.proc ___clocks_per_sec
ldx #$00 ; Clear byte 1 of return value
stx sreg ; Clear byte 2 of return value
diff --git a/libsrc/atari/close.s b/libsrc/atari/close.s
index d18fbec34..b5bff4173 100644
--- a/libsrc/atari/close.s
+++ b/libsrc/atari/close.s
@@ -6,7 +6,7 @@
.include "atari.inc"
.export _close
- .import __do_oserror,popax,__oserror
+ .import __do_oserror,popax,___oserror
.import fdtoiocb_down,__inviocb
.proc _close
@@ -18,7 +18,7 @@
jsr CIOV
bmi closerr
ok: ldx #0
- stx __oserror ; clear system specific error code
+ stx ___oserror ; clear system specific error code
txa
rts
diff --git a/libsrc/atari/dio_cts.s b/libsrc/atari/dio_cts.s
index 551b9c0f6..22dc8f9fe 100644
--- a/libsrc/atari/dio_cts.s
+++ b/libsrc/atari/dio_cts.s
@@ -16,7 +16,7 @@
;
.export _dio_phys_to_log
- .import popax,__oserror
+ .import popax,___oserror
.importzp ptr1,ptr2,ptr3
.include "atari.inc"
@@ -54,7 +54,7 @@
ldx #0
txa
ret:
- sta __oserror
+ sta ___oserror
rts ; return success
; invalid handle
diff --git a/libsrc/atari/dio_stc.s b/libsrc/atari/dio_stc.s
index 768aca085..4edb78aa6 100644
--- a/libsrc/atari/dio_stc.s
+++ b/libsrc/atari/dio_stc.s
@@ -17,7 +17,7 @@
.export _dio_log_to_phys
.include "atari.inc"
.importzp ptr1,ptr2,ptr3
- .import popax,popptr1,__oserror
+ .import popax,popptr1,___oserror
.proc _dio_log_to_phys
@@ -56,7 +56,7 @@ _l1: lda (ptr1,x)
txa
ret:
- sta __oserror
+ sta ___oserror
rts ; return success
; invalid handle
diff --git a/libsrc/atari/diopncls.s b/libsrc/atari/diopncls.s
index 528c0fad8..f40d6bba4 100644
--- a/libsrc/atari/diopncls.s
+++ b/libsrc/atari/diopncls.s
@@ -14,7 +14,7 @@
.export _dio_open, _dio_close
.export sectsizetab
- .import __oserror, __sio_call, _dio_read
+ .import ___oserror, __sio_call, _dio_read
.import pushax, addysp, subysp
.importzp ptr2, sp
.include "atari.inc"
@@ -31,7 +31,7 @@ sectsizetab:
_inv_drive:
lda #NONDEV ; non-existent device
- sta __oserror
+ sta ___oserror
lda #0
tax
rts ; return NULL
@@ -49,7 +49,7 @@ _dio_open:
sta sectsizetab+sst_flag,x ; set flag that drive is "open"
lda #0
sta sectsizetab+sst_sectsize+1,x
- sta __oserror ; success
+ sta ___oserror ; success
tya
sta sectsizetab+sst_driveno,x
stx ptr2
@@ -156,7 +156,7 @@ s128: lda #128
lda #0
ldy #sst_flag
sta (ptr2),y
- sta __oserror ; success
+ sta ___oserror ; success
tax
rts ; return no error
diff --git a/libsrc/atari/dioqsize.s b/libsrc/atari/dioqsize.s
index caef0588f..3816c249c 100644
--- a/libsrc/atari/dioqsize.s
+++ b/libsrc/atari/dioqsize.s
@@ -7,7 +7,7 @@
.include "atari.inc"
.export _dio_query_sectsize
.importzp ptr1,tmp1
- .import popax, __oserror
+ .import popax, ___oserror
.proc _dio_query_sectsize
@@ -15,7 +15,7 @@
stx ptr1+1
lda #0
- sta __oserror
+ sta ___oserror
ldy #sst_sectsize+1
lda (ptr1),y
diff --git a/libsrc/atari/do_oserr.s b/libsrc/atari/do_oserr.s
index eb19dd9d1..9793ff462 100644
--- a/libsrc/atari/do_oserr.s
+++ b/libsrc/atari/do_oserr.s
@@ -1,5 +1,5 @@
;
-; __do_oserror updates __oserror and errno. Do a JMP here right after
+; __do_oserror updates ___oserror and errno. Do a JMP here right after
; calling CIOV. It will return with AX set to -1 ($FFFF). It expects the CIO
; status in Y.
;
@@ -9,4 +9,4 @@
__do_oserror:
tya
- jmp __mappederrno
+ jmp ___mappederrno
diff --git a/libsrc/atari/exec.s b/libsrc/atari/exec.s
index 16062a294..145b28e0d 100644
--- a/libsrc/atari/exec.s
+++ b/libsrc/atari/exec.s
@@ -34,7 +34,7 @@ notsupp:lda #ENOSYS ; "unsupported system call"
.byte $2C ; bit opcode, eats the next 2 bytes
noiocb: lda #EMFILE ; "too many open files"
jsr incsp2 ; clean up stack
-seterr: jmp __directerrno
+seterr: jmp ___directerrno
; entry point
@@ -148,7 +148,7 @@ copycd: lda #ATEOL
pha ; remember error code
jsr close ; close the IOCB (required even if open failed)
pla ; put error code back into A
-setmerr:jmp __mappederrno ; update errno from OS specific error code in A
+setmerr:jmp ___mappederrno ; update errno from OS specific error code in A
openok: lda #>buf
sta ICBAH,x ; set buffer address
diff --git a/libsrc/atari/getres.s b/libsrc/atari/getres.s
index f2e4874f9..9716040d8 100644
--- a/libsrc/atari/getres.s
+++ b/libsrc/atari/getres.s
@@ -41,7 +41,7 @@ _clock_getres:
enosys: lda #ENOSYS
; Set __errno
- jmp __directerrno
+ jmp ___directerrno
;----------------------------------------------------------------------------
; timespec struct with tv_sec set to 1 second
diff --git a/libsrc/atari/gettime.s b/libsrc/atari/gettime.s
index 093d34843..df6e24021 100644
--- a/libsrc/atari/gettime.s
+++ b/libsrc/atari/gettime.s
@@ -105,7 +105,7 @@ errexit:jsr incsp3 ; Preserves A
; set __errno
- jmp __directerrno
+ jmp ___directerrno
; -------
diff --git a/libsrc/atari/graphics.s b/libsrc/atari/graphics.s
index ab26ed0da..1f7844c39 100644
--- a/libsrc/atari/graphics.s
+++ b/libsrc/atari/graphics.s
@@ -10,7 +10,7 @@
.export __graphics
.import findfreeiocb
- .import __oserror
+ .import ___oserror
.import fddecusage
.import clriocb
.import fdtoiocb
@@ -45,7 +45,7 @@ parmok: jsr findfreeiocb
beq iocbok ; we found one
lda #EINVAL
@@ -94,7 +94,7 @@ doopen: txa
lda tmp2 ; get fd
ldx #0
- stx __oserror
+ stx ___oserror
rts
cioerr: sty tmp3 ; remember error code
@@ -103,6 +103,6 @@ cioerr: sty tmp3 ; remember error code
jsr CIOV ; close IOCB again since open failed
jsr fddecusage ; and decrement usage counter of fd
lda tmp3 ; put error code into A
- jmp __mappederrno
+ jmp ___mappederrno
.endproc ; __graphics
diff --git a/libsrc/atari/inviocb.s b/libsrc/atari/inviocb.s
index c1c27ee03..2ceb385b1 100644
--- a/libsrc/atari/inviocb.s
+++ b/libsrc/atari/inviocb.s
@@ -7,4 +7,4 @@
__inviocb:
lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
openerr:
rts
@@ -229,8 +229,9 @@ SER_OPEN:
jsr my_CIOV
bmi cioerr
- lda #SER_ERR_OK
+@done: lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
;----------------------------------------------------------------------------
@@ -365,16 +367,16 @@ SER_GET:
rts
@nix_da:lda #SER_ERR_NO_DATA
- ldx #0
+ ldx #0 ; return value is char
rts
ser_error:
lda #SER_ERR_OVERFLOW ; there is no large selection of serial error codes... :-/
- ldx #0
+ ldx #0 ; return value is char
rts
ni_err: lda #SER_ERR_NOT_OPEN
- ldx #0
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -427,8 +429,8 @@ SER_STATUS:
;
SER_IOCTL:
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -456,8 +458,8 @@ search: lda HATABS,y ; get device name
; R: device not found, return error
- lda #(charsperline * screenrows)
lda #<(charsperline * screenrows)
- jmp __bzero
+ jmp ___bzero
.endproc
diff --git a/libsrc/atari7800/joy/atari7800-stdjoy.s b/libsrc/atari7800/joy/atari7800-stdjoy.s
index d76e1d105..59f656ada 100644
--- a/libsrc/atari7800/joy/atari7800-stdjoy.s
+++ b/libsrc/atari7800/joy/atari7800-stdjoy.s
@@ -62,8 +62,9 @@ INSTALL:
sty SWCHB ; enable 2-button 7800 controller 2: pull pin 6 (INPT4) high
reset:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atari7800/mono_clrscr.s b/libsrc/atari7800/mono_clrscr.s
index 19f1fdfd6..f6f6735cb 100644
--- a/libsrc/atari7800/mono_clrscr.s
+++ b/libsrc/atari7800/mono_clrscr.s
@@ -4,7 +4,7 @@
.export _mono_clrscr
.import _mono_screen
- .import pushax, __bzero
+ .import pushax, ___bzero
.include "extzp.inc"
.code
@@ -16,7 +16,7 @@
jsr pushax
ldx #>(mono_charsperline * screenrows)
lda #<(mono_charsperline * screenrows)
- jmp __bzero
+ jmp ___bzero
.endproc
diff --git a/libsrc/atmos/joy/atmos-ijk.s b/libsrc/atmos/joy/atmos-ijk.s
index 6e75a3e0b..c2bdd67ab 100644
--- a/libsrc/atmos/joy/atmos-ijk.s
+++ b/libsrc/atmos/joy/atmos-ijk.s
@@ -55,11 +55,12 @@ INSTALL:
lda VIA::PRA
and #%00100000
bne ijkPresent
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atmos/joy/atmos-pase.s b/libsrc/atmos/joy/atmos-pase.s
index fd64901c9..d9982cafe 100644
--- a/libsrc/atmos/joy/atmos-pase.s
+++ b/libsrc/atmos/joy/atmos-pase.s
@@ -58,7 +58,8 @@ temp2: .byte $00
INSTALL:
lda #JOY_ERR_OK
- ldx #0
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/atmos/oserror.s b/libsrc/atmos/oserror.s
index 37c9bd7fc..2e902afdf 100644
--- a/libsrc/atmos/oserror.s
+++ b/libsrc/atmos/oserror.s
@@ -1,14 +1,14 @@
;
; Stefan Haubenthal, 2011-04-18
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system specific error into a system independent code */
;
.include "errno.inc"
- .export __osmaperrno
+ .export ___osmaperrno
-.proc __osmaperrno
+.proc ___osmaperrno
lda #EUNKNOWN
diff --git a/libsrc/atmos/ser/atmos-acia.s b/libsrc/atmos/ser/atmos-acia.s
index f84b66a0a..f679125d1 100644
--- a/libsrc/atmos/ser/atmos-acia.s
+++ b/libsrc/atmos/ser/atmos-acia.s
@@ -141,8 +141,9 @@ SER_CLOSE:
sta ACIA::CMD,x
; Done, return an error code
-: lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -277,8 +279,8 @@ SER_PUT:
; Put byte into send buffer & send
: ldy SendFreeCnt
bne :+
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
: ldy SendTail
@@ -287,7 +289,8 @@ SER_PUT:
dec SendFreeCnt
lda #$FF ; TryHard = true
jsr TryToSend
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/atmos/ser_stat_stddrv.s b/libsrc/atmos/ser_stat_stddrv.s
new file mode 100644
index 000000000..2b4373695
--- /dev/null
+++ b/libsrc/atmos/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _atmos_acia_ser
+
+.rodata
+
+_ser_static_stddrv := _atmos_acia_ser
diff --git a/libsrc/atmos/ser_stddrv.s b/libsrc/atmos/ser_stddrv.s
new file mode 100644
index 000000000..71e33115a
--- /dev/null
+++ b/libsrc/atmos/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "atmos-acia.ser"
diff --git a/libsrc/atmos/tgi/atmos-228-200-3.s b/libsrc/atmos/tgi/atmos-228-200-3.s
index 98d2cef96..466f6922a 100644
--- a/libsrc/atmos/tgi/atmos-228-200-3.s
+++ b/libsrc/atmos/tgi/atmos-228-200-3.s
@@ -215,7 +215,8 @@ SETPALETTE:
jsr PAPER
ldy #1
jsr flipcolor
- dey ; TGI_ERR_OK
+ .assert TGI_ERR_OK = 0, error
+ dey
sty ERROR
sty PARAM1+1
jmp INK
diff --git a/libsrc/c128/emd/c128-efnram.s b/libsrc/c128/emd/c128-efnram.s
index 788c73e0f..909c90048 100644
--- a/libsrc/c128/emd/c128-efnram.s
+++ b/libsrc/c128/emd/c128-efnram.s
@@ -87,16 +87,17 @@ INSTALL:
cli
cmp tmp1
beq @ram_present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@ram_present:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-georam.s b/libsrc/c128/emd/c128-georam.s
index 7511c6841..ecf12f6cd 100644
--- a/libsrc/c128/emd/c128-georam.s
+++ b/libsrc/c128/emd/c128-georam.s
@@ -120,16 +120,16 @@ INSTALL:
bne @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/c128/emd/c128-ifnram.s b/libsrc/c128/emd/c128-ifnram.s
index 01a4fdf8e..c51b775b2 100644
--- a/libsrc/c128/emd/c128-ifnram.s
+++ b/libsrc/c128/emd/c128-ifnram.s
@@ -87,16 +87,17 @@ INSTALL:
cli
cmp tmp1
beq @ram_present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@ram_present:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ram.s b/libsrc/c128/emd/c128-ram.s
index 3fc52c9cc..0ae504b84 100644
--- a/libsrc/c128/emd/c128-ram.s
+++ b/libsrc/c128/emd/c128-ram.s
@@ -68,8 +68,9 @@ INSTALL:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ram2.s b/libsrc/c128/emd/c128-ram2.s
index 7d2703fa5..92e72700a 100644
--- a/libsrc/c128/emd/c128-ram2.s
+++ b/libsrc/c128/emd/c128-ram2.s
@@ -107,8 +107,9 @@ INSTALL:
ldx #$FF
stx curpage
stx curpage+1 ; Invalidate the current page
+ .assert EM_ERR_OK = 0, error
inx
- txa ; A = X = EM_ERR_OK
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-ramcart.s b/libsrc/c128/emd/c128-ramcart.s
index e72d053ac..c58c1cd1b 100644
--- a/libsrc/c128/emd/c128-ramcart.s
+++ b/libsrc/c128/emd/c128-ramcart.s
@@ -97,13 +97,14 @@ INSTALL:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
@readonly:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s
index 84e7cb695..8228a0517 100644
--- a/libsrc/c128/emd/c128-reu.s
+++ b/libsrc/c128/emd/c128-reu.s
@@ -126,8 +126,9 @@ size_found:
pagecount_ok:
stx pagecount
sty pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
; common REU setup for size check
diff --git a/libsrc/c128/emd/c128-vdc.s b/libsrc/c128/emd/c128-vdc.s
index accb82154..8d0b77fd2 100644
--- a/libsrc/c128/emd/c128-vdc.s
+++ b/libsrc/c128/emd/c128-vdc.s
@@ -121,8 +121,9 @@ INSTALL:
lda vdc_cset_save
jsr vdcputreg
@keep64kBit:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/c128/joy/c128-ptvjoy.s b/libsrc/c128/joy/c128-ptvjoy.s
index 180f7667d..0a1c53587 100644
--- a/libsrc/c128/joy/c128-ptvjoy.s
+++ b/libsrc/c128/joy/c128-ptvjoy.s
@@ -53,8 +53,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s
index bf2e2fea7..ee04374ee 100644
--- a/libsrc/c128/joy/c128-stdjoy.s
+++ b/libsrc/c128/joy/c128-stdjoy.s
@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c128/mou/c128-1351.s b/libsrc/c128/mou/c128-1351.s
index 79ccbe0de..76e28d9f7 100644
--- a/libsrc/c128/mou/c128-1351.s
+++ b/libsrc/c128/mou/c128-1351.s
@@ -194,9 +194,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/mou/c128-inkwell.s b/libsrc/c128/mou/c128-inkwell.s
index b8e71bbb1..2aac7d32d 100644
--- a/libsrc/c128/mou/c128-inkwell.s
+++ b/libsrc/c128/mou/c128-inkwell.s
@@ -228,9 +228,10 @@ INSTALL:
jsr MoveX
cli
-; Done, return zero.
+; Done
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
diff --git a/libsrc/c128/mou/c128-joy.s b/libsrc/c128/mou/c128-joy.s
index 065674dc0..d809db526 100644
--- a/libsrc/c128/mou/c128-joy.s
+++ b/libsrc/c128/mou/c128-joy.s
@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/mou/c128-pot.s b/libsrc/c128/mou/c128-pot.s
index e582d64fb..1cbe4aa18 100644
--- a/libsrc/c128/mou/c128-pot.s
+++ b/libsrc/c128/mou/c128-pot.s
@@ -195,9 +195,10 @@ INSTALL:
sta (ptr3),y
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
diff --git a/libsrc/c128/randomize.s b/libsrc/c128/randomize.s
index ae63184a4..2b7754e86 100644
--- a/libsrc/c128/randomize.s
+++ b/libsrc/c128/randomize.s
@@ -2,16 +2,16 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "c128.inc"
-__randomize:
+___randomize:
ldx VIC_HLINE ; Use VIC rasterline as high byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator
diff --git a/libsrc/c128/ser/c128-swlink.s b/libsrc/c128/ser/c128-swlink.s
index 3337e2668..7d36eb5bc 100644
--- a/libsrc/c128/ser/c128-swlink.s
+++ b/libsrc/c128/ser/c128-swlink.s
@@ -187,8 +187,9 @@ SetNMI: sta NMIVec
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -300,8 +302,9 @@ SER_CLOSE:
; Return OK
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -370,7 +373,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c128/ser_stat_stddrv.s b/libsrc/c128/ser_stat_stddrv.s
new file mode 100644
index 000000000..8b0732703
--- /dev/null
+++ b/libsrc/c128/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _c128_swlink_ser
+
+.rodata
+
+_ser_static_stddrv := _c128_swlink_ser
diff --git a/libsrc/c128/ser_stddrv.s b/libsrc/c128/ser_stddrv.s
new file mode 100644
index 000000000..63f73cadd
--- /dev/null
+++ b/libsrc/c128/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "c128_swlink.ser"
diff --git a/libsrc/c16/emd/c16-ram.s b/libsrc/c16/emd/c16-ram.s
index a8083aca4..937019974 100644
--- a/libsrc/c16/emd/c16-ram.s
+++ b/libsrc/c16/emd/c16-ram.s
@@ -77,12 +77,13 @@ INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
rts
-nomem: ldx #>EM_ERR_NO_DEVICE
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@not_present:
cli
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/emd/c64-c256k.s b/libsrc/c64/emd/c64-c256k.s
index 79706e8fb..5a4bc54c3 100644
--- a/libsrc/c64/emd/c64-c256k.s
+++ b/libsrc/c64/emd/c64-c256k.s
@@ -158,13 +158,14 @@ INSTALL:
jsr restore_data
cpy #$01
beq @present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-dqbb.s b/libsrc/c64/emd/c64-dqbb.s
index 986c5939d..6a63b3baa 100644
--- a/libsrc/c64/emd/c64-dqbb.s
+++ b/libsrc/c64/emd/c64-dqbb.s
@@ -147,13 +147,14 @@ INSTALL:
jsr restore_data
cpy #$01
beq @present
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-georam.s b/libsrc/c64/emd/c64-georam.s
index 97f1a7cc4..0116fe8ea 100644
--- a/libsrc/c64/emd/c64-georam.s
+++ b/libsrc/c64/emd/c64-georam.s
@@ -121,16 +121,17 @@ INSTALL:
bne @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/c64/emd/c64-isepic.s b/libsrc/c64/emd/c64-isepic.s
index 3764443e2..2b7949757 100644
--- a/libsrc/c64/emd/c64-isepic.s
+++ b/libsrc/c64/emd/c64-isepic.s
@@ -76,13 +76,14 @@ INSTALL:
beq @setok
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-kerberos.s b/libsrc/c64/emd/c64-kerberos.s
index 30183362f..20be4e409 100644
--- a/libsrc/c64/emd/c64-kerberos.s
+++ b/libsrc/c64/emd/c64-kerberos.s
@@ -82,13 +82,14 @@ INSTALL:
cmp #$AA
bne @notpresent
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; use rts from UNINSTALL below
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-ram.s b/libsrc/c64/emd/c64-ram.s
index 5355b552d..cdd7b8965 100644
--- a/libsrc/c64/emd/c64-ram.s
+++ b/libsrc/c64/emd/c64-ram.s
@@ -65,8 +65,9 @@ window: .res 256 ; Memory "window"
INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-ramcart.s b/libsrc/c64/emd/c64-ramcart.s
index 8998bb6d6..a99f25b4f 100644
--- a/libsrc/c64/emd/c64-ramcart.s
+++ b/libsrc/c64/emd/c64-ramcart.s
@@ -98,13 +98,13 @@ INSTALL:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
@notpresent:
@readonly:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s
index 07ac1fbed..832e66f51 100644
--- a/libsrc/c64/emd/c64-reu.s
+++ b/libsrc/c64/emd/c64-reu.s
@@ -127,8 +127,9 @@ size_found:
pagecount_ok:
stx pagecount
sty pagecount+1
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
; common REU setup for size check
@@ -152,6 +153,7 @@ reu_size_check_common:
nodevice:
lda #EM_ERR_NO_DEVICE
+ .assert EM_ERR_OK = 0, error
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/emd/c64-vdc.s b/libsrc/c64/emd/c64-vdc.s
index 2448f09d4..60fbccbbf 100644
--- a/libsrc/c64/emd/c64-vdc.s
+++ b/libsrc/c64/emd/c64-vdc.s
@@ -87,8 +87,8 @@ INSTALL:
bne @L0
iny
bne @L0
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+; ldx #0 ; return value is char
rts
@present:
@@ -131,8 +131,9 @@ INSTALL:
sta pagecount
stx pagecount+1
@endok:
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/c64/emd/dtv-himem.s b/libsrc/c64/emd/dtv-himem.s
index 6dde874f7..4d19b19d5 100644
--- a/libsrc/c64/emd/dtv-himem.s
+++ b/libsrc/c64/emd/dtv-himem.s
@@ -93,15 +93,16 @@ INSTALL:
; DTV not found
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@present:
ldx #$FF
stx curpage+1 ; Invalidate curpage
- inx ; X = 0
- txa ; A/X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-hitjoy.s b/libsrc/c64/joy/c64-hitjoy.s
index 3b4a0b909..a9d454fd0 100644
--- a/libsrc/c64/joy/c64-hitjoy.s
+++ b/libsrc/c64/joy/c64-hitjoy.s
@@ -59,8 +59,9 @@ temp4: .byte 0
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-numpad.s b/libsrc/c64/joy/c64-numpad.s
index 0ccdc4fcd..f6839d6cf 100644
--- a/libsrc/c64/joy/c64-numpad.s
+++ b/libsrc/c64/joy/c64-numpad.s
@@ -100,12 +100,14 @@ masktable:
;
INSTALL:
- lda #JOY_ERR_OK ; Assume we have a joystick
- ldx VIC_CLK_128 ; Test for a C128
- cpx #$FF
+ lda #JOY_ERR_OK ; Assume we have a "joystick"
+ .assert JOY_ERR_OK = 0, error
+ tax ; Set high byte
+ ldy VIC_CLK_128 ; Test for a C128
+ cpy #$FF
bne @C128 ; Jump if we have one
lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad
-@C128: ldx #0 ; Set high byte
+@C128:
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/joy/c64-ptvjoy.s b/libsrc/c64/joy/c64-ptvjoy.s
index a772fb5f6..30466b2c2 100644
--- a/libsrc/c64/joy/c64-ptvjoy.s
+++ b/libsrc/c64/joy/c64-ptvjoy.s
@@ -52,8 +52,9 @@ JOY_COUNT = 4 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/c64/joy/c64-stdjoy.s b/libsrc/c64/joy/c64-stdjoy.s
index d11093fba..511032507 100644
--- a/libsrc/c64/joy/c64-stdjoy.s
+++ b/libsrc/c64/joy/c64-stdjoy.s
@@ -56,8 +56,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/c64/mou/c64-1351.s b/libsrc/c64/mou/c64-1351.s
index a7d042c7b..ce0f18803 100644
--- a/libsrc/c64/mou/c64-1351.s
+++ b/libsrc/c64/mou/c64-1351.s
@@ -152,9 +152,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -307,8 +308,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-inkwell.s b/libsrc/c64/mou/c64-inkwell.s
index 9c876a7c8..d2f14a6f0 100644
--- a/libsrc/c64/mou/c64-inkwell.s
+++ b/libsrc/c64/mou/c64-inkwell.s
@@ -168,6 +168,7 @@ INSTALL:
; Done, return zero.
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
@@ -319,8 +320,8 @@ INFO: jsr POS
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-joy.s b/libsrc/c64/mou/c64-joy.s
index f2a501000..5ee1b4f84 100644
--- a/libsrc/c64/mou/c64-joy.s
+++ b/libsrc/c64/mou/c64-joy.s
@@ -156,9 +156,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -312,8 +313,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/mou/c64-pot.s b/libsrc/c64/mou/c64-pot.s
index 102ca351c..9bdf24f62 100644
--- a/libsrc/c64/mou/c64-pot.s
+++ b/libsrc/c64/mou/c64-pot.s
@@ -139,9 +139,10 @@ INSTALL:
jsr CMOVEY
cli
-; Done, return zero (= MOUSE_ERR_OK)
+; Done
- ldx #$00
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -297,8 +298,8 @@ INFO: jsr POS
; Must return an error code in a/x.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/randomize.s b/libsrc/c64/randomize.s
index a875203af..da32dfc28 100644
--- a/libsrc/c64/randomize.s
+++ b/libsrc/c64/randomize.s
@@ -2,16 +2,16 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "c64.inc"
-__randomize:
+___randomize:
ldx VIC_HLINE ; Use VIC rasterline as high byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator
diff --git a/libsrc/c64/ser/c64-swlink.s b/libsrc/c64/ser/c64-swlink.s
index 597cf1dd6..81c9916a6 100644
--- a/libsrc/c64/ser/c64-swlink.s
+++ b/libsrc/c64/ser/c64-swlink.s
@@ -161,8 +161,9 @@ SetNMI: sta NMIVec
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -274,8 +276,9 @@ SER_CLOSE:
; Return OK
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -344,7 +347,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/c64/ser_stat_stddrv.s b/libsrc/c64/ser_stat_stddrv.s
new file mode 100644
index 000000000..327abbe5f
--- /dev/null
+++ b/libsrc/c64/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _c64_swlink_ser
+
+.rodata
+
+_ser_static_stddrv := _c64_swlink_ser
diff --git a/libsrc/c64/ser_stddrv.s b/libsrc/c64/ser_stddrv.s
new file mode 100644
index 000000000..5b00b7642
--- /dev/null
+++ b/libsrc/c64/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "c64_swlink.ser"
diff --git a/libsrc/cbm/c_load.s b/libsrc/cbm/c_load.s
index d81430a03..7f2a054bd 100644
--- a/libsrc/cbm/c_load.s
+++ b/libsrc/cbm/c_load.s
@@ -7,7 +7,7 @@
.include "cbm.inc"
.export _cbm_k_load
- .import __oserror
+ .import ___oserror
.import popa
.importzp ptr1
@@ -19,7 +19,7 @@ _cbm_k_load:
ldy ptr1+1
jsr LOAD
bcc @Ok
- sta __oserror
+ sta ___oserror
ldx ptr1
ldy ptr1+1
@Ok: txa
diff --git a/libsrc/cbm/cbm_open.s b/libsrc/cbm/cbm_open.s
index db4179db8..c7590af2a 100644
--- a/libsrc/cbm/cbm_open.s
+++ b/libsrc/cbm/cbm_open.s
@@ -15,7 +15,7 @@
; {
; cbm_k_setlfs(lfn, device, sec_addr);
; cbm_k_setnam(name);
-; return _oserror = cbm_k_open();
+; return __oserror = cbm_k_open();
; }
;
@@ -23,7 +23,7 @@
.import popa
.import _cbm_k_setlfs, _cbm_k_setnam, _cbm_k_open
- .import __oserror
+ .import ___oserror
_cbm_open:
jsr _cbm_k_setnam
@@ -32,5 +32,5 @@ _cbm_open:
jsr _cbm_k_setlfs ; Call SETLFS, pop all args
jsr _cbm_k_open
- sta __oserror
+ sta ___oserror
rts
diff --git a/libsrc/cbm/cbm_read.s b/libsrc/cbm/cbm_read.s
index 29e0e1f19..8a9939eca 100644
--- a/libsrc/cbm/cbm_read.s
+++ b/libsrc/cbm/cbm_read.s
@@ -6,7 +6,7 @@
; int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size)
; /* Reads up to "size" bytes from a file to "buffer".
; ** Returns the number of actually read bytes, 0 if there are no bytes left
-; ** (EOF) or -1 in case of an error. _oserror contains an errorcode then (see
+; ** (EOF) or -1 in case of an error. __oserror contains an errorcode then (see
; ** table below).
; */
; {
@@ -14,7 +14,7 @@
; static unsigned char tmp;
;
; /* if we can't change to the inputchannel #lfn then return an error */
-; if (_oserror = cbm_k_chkin(lfn)) return -1;
+; if (__oserror = cbm_k_chkin(lfn)) return -1;
;
; bytesread = 0;
;
@@ -41,7 +41,7 @@
.export _cbm_read
.importzp ptr1, ptr2, ptr3, tmp1
.import popax, popa
- .import __oserror
+ .import ___oserror
_cbm_read:
@@ -106,7 +106,7 @@ _cbm_read:
; CHKIN failed
-@E1: sta __oserror
+@E1: sta ___oserror
lda #$FF
tax
rts ; return -1
diff --git a/libsrc/cbm/cbm_write.s b/libsrc/cbm/cbm_write.s
index 5ac07209c..18c6f4684 100644
--- a/libsrc/cbm/cbm_write.s
+++ b/libsrc/cbm/cbm_write.s
@@ -9,7 +9,7 @@
; static unsigned int byteswritten;
;
; /* if we can't change to the outputchannel #lfn then return an error */
-; if (_oserror = cbm_k_ckout(lfn)) return -1;
+; if (__oserror = cbm_k_ckout(lfn)) return -1;
;
; byteswritten = 0;
;
@@ -18,7 +18,7 @@
; }
;
; if (cbm_k_readst()) {
-; _oserror = 5; /* device not present */
+; __oserror = 5; /* device not present */
; byteswritten = -1;
; }
;
@@ -33,7 +33,7 @@
.export _cbm_write
.importzp ptr1, ptr2, ptr3
.import popax, popa
- .import __oserror
+ .import ___oserror
_cbm_write:
@@ -87,7 +87,7 @@ _cbm_write:
; Error entry, error code is in A
-@E2: sta __oserror
+@E2: sta ___oserror
lda #$FF
tax
rts ; return -1
diff --git a/libsrc/cbm/close.s b/libsrc/cbm/close.s
index 7fc600e87..d805e37cc 100644
--- a/libsrc/cbm/close.s
+++ b/libsrc/cbm/close.s
@@ -54,12 +54,12 @@
ldx unittab,y
jsr closecmdchannel ; Close the disk command channel
pla ; Get the error code from the disk
- jmp __mappederrno ; Set _oserror and _errno, return 0/-1
+ jmp ___mappederrno ; Set __oserror and _errno, return 0/-1
; Error entry: The given file descriptor is not valid or not open
invalidfd:
lda #EBADF
- jmp __directerrno ; Set _errno, clear _oserror, return -1
+ jmp ___directerrno ; Set _errno, clear __oserror, return -1
.endproc
diff --git a/libsrc/cbm/devicedir.s b/libsrc/cbm/devicedir.s
index 3a4e6d774..1f2b2166c 100644
--- a/libsrc/cbm/devicedir.s
+++ b/libsrc/cbm/devicedir.s
@@ -32,7 +32,7 @@
jsr popa
jsr diskinit
beq size
- jsr __mappederrno
+ jsr ___mappederrno
bne fail ; Branch always
; Check for sufficient buf size
@@ -43,7 +43,7 @@ size: lda ptr3+1
cmp #3
bcs okay ; Buf >= 3
lda #__cwd
@@ -27,15 +25,20 @@ devicestr:
lda #10
jsr tosudiva0
ldy #0
- lda sreg
- beq @L0 ; >=10
- add #'0'
+ tax ; result of the division (lsb)
+ beq @L0 ; < 10
+
+ clc
+ adc #'0'
sta (ptr2),y
iny
-@L0: lda ptr1 ; rem
- add #'0'
+@L0:
+ lda sreg ; reminder of the division
+ clc
+ adc #'0'
sta (ptr2),y
iny
- lda #0
+
+ lda #0 ; terminating 0
sta (ptr2),y
rts
diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s
index e9f0237cc..47224925d 100644
--- a/libsrc/cbm/open.s
+++ b/libsrc/cbm/open.s
@@ -94,10 +94,10 @@ parmok: jsr popax ; Get flags
lda #EINVAL
-; Error entry. Sets _errno, clears _oserror, returns -1
+; Error entry. Sets _errno, clears __oserror, returns -1
seterrno:
- jmp __directerrno
+ jmp ___directerrno
; Error entry: Close the file and exit. OS error code is in A on entry
@@ -113,7 +113,7 @@ closeandexit:
; Error entry: Set oserror and errno using error code in A and return -1
-oserror:jmp __mappederrno
+oserror:jmp ___mappederrno
; Read bit is set. Add an 'r' to the name
@@ -189,7 +189,7 @@ nofile: ; ... else use SA=0 (read)
txa ; Handle
ldx #0
- stx __oserror ; Clear _oserror
+ stx ___oserror ; Clear __oserror
rts
.endproc
diff --git a/libsrc/cbm/oserror.s b/libsrc/cbm/oserror.s
index 872c75912..92da03810 100644
--- a/libsrc/cbm/oserror.s
+++ b/libsrc/cbm/oserror.s
@@ -2,7 +2,7 @@
; 2000-05-17, Ullrich von Bassewitz
; 2014-05-28, Greg King
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system-specific error into a system-independent code. */
;
@@ -10,7 +10,7 @@
.code
-__osmaperrno:
+___osmaperrno:
ldx #ErrTabSize
@L1: cmp ErrTab-2,x ; Search for the error code
beq @L2 ; Jump if found
diff --git a/libsrc/cbm/read.s b/libsrc/cbm/read.s
index 1c2c670e7..5990ed2d0 100644
--- a/libsrc/cbm/read.s
+++ b/libsrc/cbm/read.s
@@ -66,7 +66,7 @@
jsr CHKIN
bcc @L3 ; Branch if ok
- jmp __mappederrno ; Store into __oserror, map to errno, return -1
+ jmp ___mappederrno ; Store into ___oserror, map to errno, return -1
; Read the next byte
@@ -123,10 +123,10 @@
done: jsr CLRCH
-; Clear _oserror and return the number of chars read
+; Clear __oserror and return the number of chars read
eof: lda #0
- sta __oserror
+ sta ___oserror
lda ptr3
ldx ptr3+1
rts
@@ -141,7 +141,7 @@ devnotpresent:
invalidfd:
lda #EBADF
- jmp __directerrno ; Sets _errno, clears _oserror, returns -1
+ jmp ___directerrno ; Sets _errno, clears __oserror, returns -1
.endproc
diff --git a/libsrc/cbm/readdir.c b/libsrc/cbm/readdir.c
index 1512edc4e..25627a9cb 100644
--- a/libsrc/cbm/readdir.c
+++ b/libsrc/cbm/readdir.c
@@ -126,7 +126,7 @@ struct dirent* __fastcall__ readdir (register DIR* dir)
}
/* Something went wrong when parsing the directory entry */
- _errno = EIO;
+ __errno = EIO;
exitpoint:
return 0;
}
diff --git a/libsrc/cbm/write.s b/libsrc/cbm/write.s
index 93bdda31d..172e45382 100644
--- a/libsrc/cbm/write.s
+++ b/libsrc/cbm/write.s
@@ -55,7 +55,7 @@
jsr CKOUT
bcc @L2
-@error: jmp __mappederrno ; Store into __oserror, map to errno, return -1
+@error: jmp ___mappederrno ; Store into ___oserror, map to errno, return -1
; Output the next character from the buffer
@@ -92,10 +92,10 @@
@L3: jsr CLRCH
-; Clear _oserror and return the number of chars written
+; Clear __oserror and return the number of chars written
lda #0
- sta __oserror
+ sta ___oserror
lda ptr3
ldx ptr3+1
rts
@@ -112,6 +112,6 @@ devnotpresent:
invalidfd:
lda #EBADF
- jmp __directerrno ; Sets _errno, clears _oserror, returns -1
+ jmp ___directerrno ; Sets _errno, clears __oserror, returns -1
.endproc
diff --git a/libsrc/cbm510/emd/cbm510-ram.s b/libsrc/cbm510/emd/cbm510-ram.s
index f724c7360..6cc319b7f 100644
--- a/libsrc/cbm510/emd/cbm510-ram.s
+++ b/libsrc/cbm510/emd/cbm510-ram.s
@@ -81,8 +81,9 @@ INSTALL:
sbc #$00
sta pagecount
-@L1: lda #EM_ERR_OK
+@L1: lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm510/joy/cbm510-std.s b/libsrc/cbm510/joy/cbm510-std.s
index 4e47fc1a0..f7cbb2cdc 100644
--- a/libsrc/cbm510/joy/cbm510-std.s
+++ b/libsrc/cbm510/joy/cbm510-std.s
@@ -57,8 +57,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm510/mou/cbm510-inkwl.s b/libsrc/cbm510/mou/cbm510-inkwl.s
index 91bc52fcd..ea6d95934 100644
--- a/libsrc/cbm510/mou/cbm510-inkwl.s
+++ b/libsrc/cbm510/mou/cbm510-inkwl.s
@@ -175,6 +175,7 @@ INSTALL:
; Done, return zero.
lda #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
tax
rts
@@ -331,8 +332,8 @@ INFO: jsr POS
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/mou/cbm510-joy.s b/libsrc/cbm510/mou/cbm510-joy.s
index 8aa3a778e..4daa49272 100644
--- a/libsrc/cbm510/mou/cbm510-joy.s
+++ b/libsrc/cbm510/mou/cbm510-joy.s
@@ -140,7 +140,8 @@ INSTALL:
; Done, return zero.
- ldx #>MOUSE_ERR_OK
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -315,8 +316,8 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
; Must return an error code in .XA.
;
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/randomize.s b/libsrc/cbm510/randomize.s
index 75c419ccb..8d21cde15 100644
--- a/libsrc/cbm510/randomize.s
+++ b/libsrc/cbm510/randomize.s
@@ -2,15 +2,15 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.importzp time
-__randomize:
+___randomize:
ldx time+2 ; Use 50/60HZ clock
lda time+1
jmp _srand ; Initialize generator
diff --git a/libsrc/cbm510/ser/cbm510-std.s b/libsrc/cbm510/ser/cbm510-std.s
index 64f613cd5..cc58c1233 100644
--- a/libsrc/cbm510/ser/cbm510-std.s
+++ b/libsrc/cbm510/ser/cbm510-std.s
@@ -148,8 +148,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -253,8 +255,8 @@ SER_GET:
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -301,7 +303,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm510/ser_stat_stddrv.s b/libsrc/cbm510/ser_stat_stddrv.s
new file mode 100644
index 000000000..a872f19b9
--- /dev/null
+++ b/libsrc/cbm510/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _cbm510_std_ser
+
+.rodata
+
+_ser_static_stddrv := _cbm510_std_ser
diff --git a/libsrc/cbm510/ser_stddrv.s b/libsrc/cbm510/ser_stddrv.s
new file mode 100644
index 000000000..ed785f914
--- /dev/null
+++ b/libsrc/cbm510/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "cbm510-std.ser"
diff --git a/libsrc/cbm610/emd/cbm610-ram.s b/libsrc/cbm610/emd/cbm610-ram.s
index 5c67df7a4..5aa43b0c2 100644
--- a/libsrc/cbm610/emd/cbm610-ram.s
+++ b/libsrc/cbm610/emd/cbm610-ram.s
@@ -81,8 +81,9 @@ INSTALL:
sbc #$00
sta pagecount
-@L1: lda #EM_ERR_OK
+@L1: lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cbm610/randomize.s b/libsrc/cbm610/randomize.s
index 75c419ccb..8d21cde15 100644
--- a/libsrc/cbm610/randomize.s
+++ b/libsrc/cbm610/randomize.s
@@ -2,15 +2,15 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.importzp time
-__randomize:
+___randomize:
ldx time+2 ; Use 50/60HZ clock
lda time+1
jmp _srand ; Initialize generator
diff --git a/libsrc/cbm610/ser/cbm610-std.s b/libsrc/cbm610/ser/cbm610-std.s
index 7cdb285bd..f7ddde935 100644
--- a/libsrc/cbm610/ser/cbm610-std.s
+++ b/libsrc/cbm610/ser/cbm610-std.s
@@ -149,8 +149,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -254,8 +256,8 @@ SER_GET:
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -302,7 +304,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/cbm610/ser_stat_stddrv.s b/libsrc/cbm610/ser_stat_stddrv.s
new file mode 100644
index 000000000..643a74c7d
--- /dev/null
+++ b/libsrc/cbm610/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _cbm610_std_ser
+
+.rodata
+
+_ser_static_stddrv := _cbm610_std_ser
diff --git a/libsrc/cbm610/ser_stddrv.s b/libsrc/cbm610/ser_stddrv.s
new file mode 100644
index 000000000..83702c1ef
--- /dev/null
+++ b/libsrc/cbm610/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "cbm610-std.ser"
diff --git a/libsrc/common/_afailed.c b/libsrc/common/_afailed.c
index ab8b94ca6..01e8d5397 100644
--- a/libsrc/common/_afailed.c
+++ b/libsrc/common/_afailed.c
@@ -12,7 +12,7 @@
#include
-void __fastcall__ _afailed (char* file, unsigned line)
+void __fastcall__ __afailed (char* file, unsigned line)
{
raise (SIGABRT);
fprintf (stderr, "ASSERTION FAILED IN %s:%u\n", file, line);
diff --git a/libsrc/common/_directerrno.s b/libsrc/common/_directerrno.s
index 794247148..20060bdd7 100644
--- a/libsrc/common/_directerrno.s
+++ b/libsrc/common/_directerrno.s
@@ -10,14 +10,14 @@
.macpack cpu
; ----------------------------------------------------------------------------
-; int __fastcall__ _directerrno (unsigned char code);
-; /* Set errno to a specific error code, clear _oserror, and return -1. Used
+; int __fastcall__ __directerrno (unsigned char code);
+; /* Set errno to a specific error code, clear __oserror, and return -1. Used
; ** by the library.
; */
-__directerrno:
- jsr __seterrno ; Set errno (returns with .A = 0)
- sta __oserror ; Clear __oserror
+___directerrno:
+ jsr ___seterrno ; Set errno (returns with .A = 0)
+ sta ___oserror ; Clear ___oserror
.if (.cpu .bitand CPU_ISET_65SC02)
dec a
.else
diff --git a/libsrc/common/_fopen.s b/libsrc/common/_fopen.s
index 29f1c4cd9..17a1ec19b 100644
--- a/libsrc/common/_fopen.s
+++ b/libsrc/common/_fopen.s
@@ -69,7 +69,7 @@
invmode:
lda #EINVAL
- jsr __seterrno ; Set __errno, returns zero in A
+ jsr ___seterrno ; Set __errno, returns zero in A
tax ; a/x = 0
jmp incsp4
@@ -91,7 +91,7 @@ modeok: ldy #$00
bne openok
cmp #$FF
bne openok
- jmp return0 ; Failure, errno/_oserror already set
+ jmp return0 ; Failure, errno/__oserror already set
; Open call succeeded
diff --git a/libsrc/common/_heap.s b/libsrc/common/_heap.s
index 4ec8c80cd..eb680fa20 100644
--- a/libsrc/common/_heap.s
+++ b/libsrc/common/_heap.s
@@ -13,15 +13,15 @@
.data
-__heaporg:
+___heaporg:
.word __BSS_RUN__+__BSS_SIZE__ ; Linker calculates this symbol
-__heapptr:
+___heapptr:
.word __BSS_RUN__+__BSS_SIZE__ ; Dito
-__heapend:
+___heapend:
.word __BSS_RUN__+__BSS_SIZE__
-__heapfirst:
+___heapfirst:
.word 0
-__heaplast:
+___heaplast:
.word 0
@@ -33,10 +33,10 @@ initheap:
sec
lda sp
sbc #<__STACKSIZE__
- sta __heapend
+ sta ___heapend
lda sp+1
sbc #>__STACKSIZE__
- sta __heapend+1
+ sta ___heapend+1
rts
diff --git a/libsrc/common/_heapadd.s b/libsrc/common/_heapadd.s
index 14080cb5e..7695a732d 100644
--- a/libsrc/common/_heapadd.s
+++ b/libsrc/common/_heapadd.s
@@ -10,7 +10,7 @@
.importzp ptr1, ptr2
.import popax
.import heapadd
- .export __heapadd
+ .export ___heapadd
.include "_heap.inc"
@@ -19,7 +19,7 @@
;-----------------------------------------------------------------------------
; Code
-__heapadd:
+___heapadd:
sta ptr1 ; Store size in ptr1
stx ptr1+1
jsr popax ; Get the block pointer
diff --git a/libsrc/common/_heapblocksize.s b/libsrc/common/_heapblocksize.s
index db33f594c..e9b0cdad9 100644
--- a/libsrc/common/_heapblocksize.s
+++ b/libsrc/common/_heapblocksize.s
@@ -7,7 +7,7 @@
;
.importzp ptr1, ptr2
- .export __heapblocksize
+ .export ___heapblocksize
.include "_heap.inc"
@@ -17,7 +17,7 @@
;-----------------------------------------------------------------------------
; Code
-__heapblocksize:
+___heapblocksize:
; Below the user data is a pointer that points to the start of the real
; (raw) memory block. The first word of this block is the size. To access
diff --git a/libsrc/common/_heapmaxavail.s b/libsrc/common/_heapmaxavail.s
index 19ae18b8d..b4e72f2d4 100644
--- a/libsrc/common/_heapmaxavail.s
+++ b/libsrc/common/_heapmaxavail.s
@@ -8,7 +8,7 @@
;
.importzp ptr1, ptr2
- .export __heapmaxavail
+ .export ___heapmaxavail
.include "_heap.inc"
@@ -17,22 +17,22 @@
;-----------------------------------------------------------------------------
; Code
-__heapmaxavail:
+___heapmaxavail:
; size_t Size = (_heapend - _heapptr) * sizeof (*_heapend);
- lda __heapend
- sub __heapptr
+ lda ___heapend
+ sub ___heapptr
sta ptr2
- lda __heapend+1
- sbc __heapptr+1
+ lda ___heapend+1
+ sbc ___heapptr+1
sta ptr2+1
; struct freeblock* F = _heapfirst;
- lda __heapfirst
+ lda ___heapfirst
sta ptr1
- lda __heapfirst+1
+ lda ___heapfirst+1
@L1: sta ptr1+1
; while (F) {
diff --git a/libsrc/common/_heapmemavail.s b/libsrc/common/_heapmemavail.s
index 69aa75f8a..14ecc853a 100644
--- a/libsrc/common/_heapmemavail.s
+++ b/libsrc/common/_heapmemavail.s
@@ -8,7 +8,7 @@
;
.importzp ptr1, ptr2
- .export __heapmemavail
+ .export ___heapmemavail
.include "_heap.inc"
@@ -17,7 +17,7 @@
;-----------------------------------------------------------------------------
; Code
-__heapmemavail:
+___heapmemavail:
; size_t Size = 0;
@@ -27,9 +27,9 @@ __heapmemavail:
; struct freeblock* F = _heapfirst;
- lda __heapfirst
+ lda ___heapfirst
sta ptr1
- lda __heapfirst+1
+ lda ___heapfirst+1
@L1: sta ptr1+1
; while (F) {
@@ -61,17 +61,17 @@ __heapmemavail:
; return Size + (_heapend - _heapptr) * sizeof (*_heapend);
@L2: lda ptr2
- add __heapend
+ add ___heapend
sta ptr2
lda ptr2+1
- adc __heapend+1
+ adc ___heapend+1
tax
lda ptr2
- sub __heapptr
+ sub ___heapptr
sta ptr2
txa
- sbc __heapptr+1
+ sbc ___heapptr+1
tax
lda ptr2
diff --git a/libsrc/common/_mappederrno.s b/libsrc/common/_mappederrno.s
index 33f654c29..83565b723 100644
--- a/libsrc/common/_mappederrno.s
+++ b/libsrc/common/_mappederrno.s
@@ -11,19 +11,19 @@
.macpack cpu
; ----------------------------------------------------------------------------
-; int __fastcall__ _mappederrno (unsigned char code);
-; /* Set _oserror to the given platform-specific error code. If it is a real
+; int __fastcall__ __mappederrno (unsigned char code);
+; /* Set __oserror to the given platform-specific error code. If it is a real
; ** error code (not zero), set errno to the corresponding system error code,
; ** and return -1. Otherwise, return zero.
; ** Used by the library.
; */
-__mappederrno:
- sta __oserror ; Store the error code
+___mappederrno:
+ sta ___oserror ; Store the error code
tax ; Did we have an error?
bze ok ; Branch if no
- jsr __osmaperrno ; Map OS error into errno code
- jsr __seterrno ; Save in errno (returns with .A = 0)
+ jsr ___osmaperrno ; Map OS error into errno code
+ jsr ___seterrno ; Save in errno (returns with .A = 0)
.if (.cpu .bitand CPU_ISET_65SC02)
dec a
.else
diff --git a/libsrc/common/_oserror.s b/libsrc/common/_oserror.s
index 256d89658..bd8e40711 100644
--- a/libsrc/common/_oserror.s
+++ b/libsrc/common/_oserror.s
@@ -1,14 +1,14 @@
;
; Ullrich von Bassewitz, 16.05.2000
;
-; extern unsigned char _oserror;
+; extern unsigned char __oserror;
; /* Operating system specific errors from the low level functions */
- .export __oserror
+ .export ___oserror
.bss
-__oserror:
+___oserror:
.res 1
diff --git a/libsrc/common/_poserror.c b/libsrc/common/_poserror.c
index 2777fee98..a2a67dd3e 100644
--- a/libsrc/common/_poserror.c
+++ b/libsrc/common/_poserror.c
@@ -39,10 +39,10 @@
-void __fastcall__ _poserror (const char* msg)
+void __fastcall__ __poserror (const char* msg)
{
/* Fetch the message that corresponds to _oserror */
- const char* errormsg = _stroserror (_oserror);
+ const char* errormsg = __stroserror (_oserror);
/* Different output depending on msg */
if (msg) {
diff --git a/libsrc/common/_printf.s b/libsrc/common/_printf.s
index 840d42127..a0074583e 100644
--- a/libsrc/common/_printf.s
+++ b/libsrc/common/_printf.s
@@ -502,10 +502,10 @@ DoFormat:
; It is a character
jsr GetIntArg ; Get the argument (promoted to int)
- sta Buf ; Place it as zero terminated string...
- lda #0
- sta Buf+1 ; ...into the buffer
- jmp HaveArg ; Done
+ sta Buf ; Place it into the buffer
+ ldx #0
+ lda #1 ; Buffer length is 1
+ jmp HaveArg1
; Is it an integer?
@@ -671,6 +671,7 @@ HaveArg:
lda Str
ldx Str+1
jsr _strlen ; Get length of argument
+HaveArg1: ; Jumped into here from %c handling
sta ArgLen
stx ArgLen+1
diff --git a/libsrc/common/_seterrno.s b/libsrc/common/_seterrno.s
index 79021143a..4344a3302 100644
--- a/libsrc/common/_seterrno.s
+++ b/libsrc/common/_seterrno.s
@@ -1,7 +1,7 @@
;
; Ullrich von Bassewitz, 2004-05-13
;
-; __seterrno: Will set __errno to the value in A and return zero in A. Other
+; ___seterrno: Will set ___errno to the value in A and return zero in A. Other
; registers aren't changed. The function is C callable, but
; currently only called from asm code.
;
@@ -10,11 +10,11 @@
.code
-.proc __seterrno
+.proc ___seterrno
- sta __errno
+ sta ___errno
lda #0
- sta __errno+1
+ sta ___errno+1
rts
.endproc
diff --git a/libsrc/common/_swap.s b/libsrc/common/_swap.s
index 9ad771de1..ba3e5922d 100644
--- a/libsrc/common/_swap.s
+++ b/libsrc/common/_swap.s
@@ -1,15 +1,15 @@
;
; Ullrich von Bassewitz, 1998-12-09, 2004-11-30
;
-; void __fastcall__ _swap (void* p, void* q, size_t size);
+; void __fastcall__ __swap (void* p, void* q, size_t size);
;
- .export __swap
+ .export ___swap
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
-__swap: eor #$FF
+___swap: eor #$FF
sta ptr3
txa
eor #$FF
diff --git a/libsrc/common/atexit.s b/libsrc/common/atexit.s
index 6edfd4a5d..47a1dfd4d 100644
--- a/libsrc/common/atexit.s
+++ b/libsrc/common/atexit.s
@@ -38,7 +38,7 @@
; Error, no space left
@Error: lda #ENOSPC ; No space left
- jsr __seterrno
+ jsr ___seterrno
ldx #$FF ; Return -1
txa
rts
diff --git a/libsrc/common/calloc.s b/libsrc/common/calloc.s
index 6e3e1bd3f..4cb701146 100644
--- a/libsrc/common/calloc.s
+++ b/libsrc/common/calloc.s
@@ -7,7 +7,7 @@
;
.export _calloc
- .import _malloc, __bzero
+ .import _malloc, ___bzero
.import tosumulax, pushax
@@ -48,7 +48,7 @@ ClearBlock:
jsr pushax ; ptr
lda Size
ldx Size+1 ; Size
- jmp __bzero
+ jmp ___bzero
.endproc
diff --git a/libsrc/common/chdir.s b/libsrc/common/chdir.s
index 3e638cb04..1f10a6804 100644
--- a/libsrc/common/chdir.s
+++ b/libsrc/common/chdir.s
@@ -7,7 +7,7 @@
.export _chdir
.import __syschdir
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -17,7 +17,7 @@
.proc _chdir
jsr __syschdir ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/errno.s b/libsrc/common/errno.s
index f448c3c14..43bbe3fb0 100644
--- a/libsrc/common/errno.s
+++ b/libsrc/common/errno.s
@@ -2,7 +2,7 @@
; 2003-08-12, Ullrich von Bassewitz
; 2015-09-24, Greg King
;
-; extern int _errno;
+; extern int __errno;
; /* Library errors go here. */
;
@@ -10,5 +10,5 @@
.bss
-__errno:
+___errno:
.word 0
diff --git a/libsrc/common/fclose.s b/libsrc/common/fclose.s
index 5365d70da..2368bf9f6 100644
--- a/libsrc/common/fclose.s
+++ b/libsrc/common/fclose.s
@@ -31,7 +31,7 @@
; File is not open
lda #EINVAL
- jsr __seterrno
+ jsr ___seterrno
lda #$FF ; Return -1
tax
rts
diff --git a/libsrc/common/fmisc.s b/libsrc/common/fmisc.s
index 156a80dbc..90b48e8a6 100644
--- a/libsrc/common/fmisc.s
+++ b/libsrc/common/fmisc.s
@@ -78,7 +78,7 @@ err: rts
; If the file is not valid, fileno must set errno and return -1
error: lda #prev field
lda (ptr1),y
sta ptr2+1 ; Remember f->prev in ptr2
- sta __heaplast+1
+ sta ___heaplast+1
dey
lda (ptr1),y
sta ptr2 ; Remember f->prev in ptr2
- sta __heaplast
- ora __heaplast+1 ; -> prev == 0?
+ sta ___heaplast
+ ora ___heaplast+1 ; -> prev == 0?
bne @L8 ; Jump if free list not empty
; Free list is now empty (A = 0)
- sta __heapfirst
- sta __heapfirst+1
+ sta ___heapfirst
+ sta ___heapfirst+1
; Done
@@ -283,9 +283,9 @@ _free: sta ptr2
; Check if the free list is empty, storing _hfirst into ptr3 for later
heapadd:
- lda __heapfirst
+ lda ___heapfirst
sta ptr3
- lda __heapfirst+1
+ lda ___heapfirst+1
sta ptr3+1
ora ptr3
bne SearchFreeList
@@ -301,10 +301,10 @@ heapadd:
lda ptr2
ldx ptr2+1
- sta __heapfirst
- stx __heapfirst+1 ; _heapfirst = f;
- sta __heaplast
- stx __heaplast+1 ; _heaplast = f;
+ sta ___heapfirst
+ stx ___heapfirst+1 ; _heapfirst = f;
+ sta ___heaplast
+ stx ___heaplast+1 ; _heaplast = f;
rts ; Done
@@ -351,9 +351,9 @@ SearchFreeList:
sta (ptr2),y ; Clear low byte of f->next
lda ptr2 ; _heaplast = f;
- sta __heaplast
+ sta ___heaplast
lda ptr2+1
- sta __heaplast+1
+ sta ___heaplast+1
; Since we have checked the case that the freelist is empty before, if the
; right pointer is NULL, the left *cannot* be NULL here. So skip the
@@ -414,9 +414,9 @@ CheckRightMerge:
; f->next is zero, this is now the last block
@L1: lda ptr2 ; _heaplast = f;
- sta __heaplast
+ sta ___heaplast
lda ptr2+1
- sta __heaplast+1
+ sta ___heaplast+1
jmp CheckLeftMerge
; No right merge, just set the link.
@@ -451,9 +451,9 @@ CheckLeftMerge:
sta (ptr2),y
lda ptr2 ; _heapfirst = f;
- sta __heapfirst
+ sta ___heapfirst
lda ptr2+1
- sta __heapfirst+1
+ sta ___heapfirst+1
rts ; Done
@@ -510,9 +510,9 @@ CheckLeftMerge2:
; This is now the last block, do _heaplast = left
@L1: lda ptr4
- sta __heaplast
+ sta ___heaplast
lda ptr4+1
- sta __heaplast+1
+ sta ___heaplast+1
rts ; Done
; No merge of the left block, just set the link. Y points to size+1 if
diff --git a/libsrc/common/fwrite.s b/libsrc/common/fwrite.s
index b0fa7ec42..861feb120 100644
--- a/libsrc/common/fwrite.s
+++ b/libsrc/common/fwrite.s
@@ -39,7 +39,7 @@
; File not open
@L1: lda #EBADF
- jsr __seterrno ; Returns with A = 0
+ jsr ___seterrno ; Returns with A = 0
tax ; A = X = 0
jmp incsp6
diff --git a/libsrc/common/getcwd.s b/libsrc/common/getcwd.s
index 9b856ea7c..5fc0bbf0a 100644
--- a/libsrc/common/getcwd.s
+++ b/libsrc/common/getcwd.s
@@ -51,7 +51,7 @@ loop: dec ptr2
overflow:
lda #next
@L1: lda (ptr2),y ; Load high byte of f->next
- sta __heapfirst+1
+ sta ___heapfirst+1
dey ; Points to next
lda (ptr2),y ; Load low byte of f->next
- sta __heapfirst
+ sta ___heapfirst
; Check f->next. Y points always to next if we come here
@@ -275,10 +275,10 @@ BlockFound:
; Do _hlast = f->prev
@L3: lda (ptr2),y ; Load low byte of f->prev
- sta __heaplast
+ sta ___heaplast
iny ; Points to prev+1
lda (ptr2),y ; Load high byte of f->prev
- sta __heaplast+1
+ sta ___heaplast+1
jmp RetUserPtr ; Done
; We must slice the block found. Cut off space from the upper end, so we
diff --git a/libsrc/common/memset.s b/libsrc/common/memset.s
index a57a90e5c..be78fc30d 100644
--- a/libsrc/common/memset.s
+++ b/libsrc/common/memset.s
@@ -1,6 +1,6 @@
;
; void* __fastcall__ memset (void* ptr, int c, size_t n);
-; void* __fastcall__ _bzero (void* ptr, size_t n);
+; void* __fastcall__ __bzero (void* ptr, size_t n);
; void __fastcall__ bzero (void* ptr, size_t n);
;
; Ullrich von Bassewitz, 29.05.1998
@@ -8,19 +8,19 @@
; Christian Krueger, 12.09.2009, slightly improved 12.01.2011
;
; NOTE: bzero will return it's first argument as memset does. It is no problem
-; to declare the return value as void, since it may be ignored. _bzero
-; (note the leading underscore) is declared with the proper return type,
-; because the compiler will replace memset by _bzero if the fill value
+; to declare the return value as void, since it may be ignored. __bzero
+; (note the leading underscores) is declared with the proper return type,
+; because the compiler will replace memset by __bzero if the fill value
; is zero, and the optimizer looks at the return type to see if the value
; in a/x is of any use.
;
- .export _memset, _bzero, __bzero
+ .export _memset, _bzero, ___bzero
.import popax
.importzp sp, ptr1, ptr2, ptr3
_bzero:
-__bzero:
+___bzero:
sta ptr3
stx ptr3+1 ; Save n
ldx #0 ; Fill with zeros
diff --git a/libsrc/common/mkdir.s b/libsrc/common/mkdir.s
index 1144983aa..1a5c7551f 100644
--- a/libsrc/common/mkdir.s
+++ b/libsrc/common/mkdir.s
@@ -7,7 +7,7 @@
.export _mkdir
.import __sysmkdir
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -15,6 +15,6 @@
.proc _mkdir
jsr __sysmkdir ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/perror.c b/libsrc/common/perror.c
index ddc015c1e..9b0dac7de 100644
--- a/libsrc/common/perror.c
+++ b/libsrc/common/perror.c
@@ -42,7 +42,7 @@
void __fastcall__ perror (const char* msg)
{
/* Fetch the message that corresponds to errno */
- const char* errormsg = strerror (_errno);
+ const char* errormsg = strerror (__errno);
/* Different output depending on msg */
if (msg) {
diff --git a/libsrc/common/putenv.s b/libsrc/common/putenv.s
index c68d20a32..5febcc71e 100644
--- a/libsrc/common/putenv.s
+++ b/libsrc/common/putenv.s
@@ -169,7 +169,7 @@ addentry:
; Error entries
nomem: lda #ENOMEM
-error: jsr __seterrno
+error: jsr ___seterrno
lda #$FF ; Return -1
tax
rts
diff --git a/libsrc/common/qsort.c b/libsrc/common/qsort.c
index 991db3ba1..913165814 100644
--- a/libsrc/common/qsort.c
+++ b/libsrc/common/qsort.c
@@ -32,13 +32,13 @@ static void QuickSort (register unsigned char* Base, int Lo, int Hi,
J -= Size;
}
if (I <= J) {
- _swap (Base + I, Base + J, Size);
+ __swap (Base + I, Base + J, Size);
I += Size;
J -= Size;
}
}
if (J != Lo) {
- _swap (Base + J, Base + Lo, Size);
+ __swap (Base + J, Base + Lo, Size);
}
if (((unsigned) J) * 2 > (Hi + Lo)) {
QuickSort (Base, J + Size, Hi, Size, Compare);
diff --git a/libsrc/common/raise.s b/libsrc/common/raise.s
index 07898ef90..205bbd471 100644
--- a/libsrc/common/raise.s
+++ b/libsrc/common/raise.s
@@ -33,9 +33,9 @@ _raise:
; introduce race conditions, but it's the simplest way to satisfy the
; standard).
- lda #<__sig_dfl
+ lda #<___sig_dfl
sta sigtable,x
- lda #>__sig_dfl
+ lda #>___sig_dfl
sta sigtable+1,x
; Restore the signal number and call the function
diff --git a/libsrc/common/realloc.c b/libsrc/common/realloc.c
index c47dbbb98..eeb1eeea5 100644
--- a/libsrc/common/realloc.c
+++ b/libsrc/common/realloc.c
@@ -74,12 +74,12 @@ void* __fastcall__ realloc (void* block, register size_t size)
oldsize = b->size;
/* Is the block at the current heap top? */
- if (((unsigned) b) + oldsize == ((unsigned) _heapptr)) {
+ if (((unsigned) b) + oldsize == ((unsigned) __heapptr)) {
/* Check if we've enough memory at the heap top */
- newhptr = ((unsigned) _heapptr) - oldsize + size;
- if (newhptr <= ((unsigned) _heapend)) {
+ newhptr = ((unsigned) __heapptr) - oldsize + size;
+ if (newhptr <= ((unsigned) __heapend)) {
/* Ok, there's space enough */
- _heapptr = (unsigned*) newhptr;
+ __heapptr = (unsigned*) newhptr;
b->size = size;
b->start = b;
return block;
diff --git a/libsrc/common/remove.s b/libsrc/common/remove.s
index e66f047ef..1b8515870 100644
--- a/libsrc/common/remove.s
+++ b/libsrc/common/remove.s
@@ -7,7 +7,7 @@
.export _remove
.import __sysremove
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -15,7 +15,7 @@
.proc _remove
jsr __sysremove ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/rename.s b/libsrc/common/rename.s
index 0fbffa426..122ae1501 100644
--- a/libsrc/common/rename.s
+++ b/libsrc/common/rename.s
@@ -7,7 +7,7 @@
.export _rename
.import __sysrename
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -15,7 +15,7 @@
.proc _rename
jsr __sysrename ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/rmdir.s b/libsrc/common/rmdir.s
index 84ae9a54c..ea0780387 100644
--- a/libsrc/common/rmdir.s
+++ b/libsrc/common/rmdir.s
@@ -7,7 +7,7 @@
.export _rmdir
.import __sysrmdir
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -15,6 +15,6 @@
.proc _rmdir
jsr __sysrmdir ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/setjmp.s b/libsrc/common/setjmp.s
index a763ac3ec..886853368 100644
--- a/libsrc/common/setjmp.s
+++ b/libsrc/common/setjmp.s
@@ -2,15 +2,15 @@
; 1998-06-06, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; int __fastcall__ setjmp (jmp_buf buf);
+; int __fastcall__ __setjmp (jmp_buf buf);
;
- .export __setjmp
+ .export ___setjmp
.import return0
.importzp sp, ptr1
-__setjmp:
+___setjmp:
sta ptr1 ; Save buf
stx ptr1+1
ldy #0
diff --git a/libsrc/common/signal.s b/libsrc/common/signal.s
index 333072801..65d0316b4 100644
--- a/libsrc/common/signal.s
+++ b/libsrc/common/signal.s
@@ -54,15 +54,15 @@ _signal:
pla
tax
pla
-__sig_ign:
+___sig_ign:
rts
; Error entry: We use our knowledge that SIG_ERR is zero here to save a byte
invalidsig:
lda #EINVAL ; = 0
- sta __errno+1
+ sta ___errno+1
; lda #$00 ; A contains zero: "Unknown error"
; Load the pointer to the error message and return
diff --git a/libsrc/common/stroserr.s b/libsrc/common/stroserr.s
index 25ca30daf..ae8e117f1 100644
--- a/libsrc/common/stroserr.s
+++ b/libsrc/common/stroserr.s
@@ -1,11 +1,11 @@
;
; Ullrich von Bassewitz, 17.07.2002
;
-; const char* __fastcall__ _stroserror (unsigned char errcode);
+; const char* __fastcall__ __stroserror (unsigned char errcode);
; /* Map an operating system error number to an error message. */
;
- .export __stroserror
+ .export ___stroserror
.import __sys_oserrlist
.importzp ptr1, tmp1
@@ -21,7 +21,7 @@
; and terminated by an entry with length zero that is returned if the
; error code could not be found.
-__stroserror:
+___stroserror:
sta tmp1 ; Save the error code
ldy #<__sys_oserrlist
diff --git a/libsrc/common/uname.s b/libsrc/common/uname.s
index 3c1b0840f..3f2a8ff14 100644
--- a/libsrc/common/uname.s
+++ b/libsrc/common/uname.s
@@ -7,7 +7,7 @@
.export _uname
.import __sysuname
- .import __mappederrno
+ .import ___mappederrno
;--------------------------------------------------------------------------
@@ -15,7 +15,7 @@
.proc _uname
jsr __sysuname ; Call the machine specific function
- jmp __mappederrno ; Store into _oserror, set errno, return 0/-1
+ jmp ___mappederrno ; Store into __oserror, set errno, return 0/-1
.endproc
diff --git a/libsrc/common/ungetc.s b/libsrc/common/ungetc.s
index 88595068c..7e8c1f94f 100644
--- a/libsrc/common/ungetc.s
+++ b/libsrc/common/ungetc.s
@@ -62,7 +62,7 @@
; File is not open or the character is invalid
error: lda #EINVAL
- jsr __seterrno
+ jsr ___seterrno
lda #$FF ; Return -1
tax
rts
diff --git a/libsrc/common/vsnprintf.s b/libsrc/common/vsnprintf.s
index 228e531d0..048a756c3 100644
--- a/libsrc/common/vsnprintf.s
+++ b/libsrc/common/vsnprintf.s
@@ -140,7 +140,7 @@ L0: ldy #EINVAL
pla ; Drop ap
pla
tya
- jsr __directerrno ; Return -1
+ jsr ___directerrno ; Return -1
jmp incsp6 ; Drop parameters
diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s
index 73b0c249f..43f9a2b40 100644
--- a/libsrc/creativision/joy/creativision-stdjoy.s
+++ b/libsrc/creativision/joy/creativision-stdjoy.s
@@ -59,7 +59,8 @@ JOY_RIGHT = $08
;
INSTALL: lda #JOY_ERR_OK
- ldx #>$0000
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Fall through
; ------------------------------------------------------------------------
diff --git a/libsrc/cx16/joy/cx16-std.s b/libsrc/cx16/joy/cx16-std.s
index a40fcb061..5def55511 100644
--- a/libsrc/cx16/joy/cx16-std.s
+++ b/libsrc/cx16/joy/cx16-std.s
@@ -55,8 +55,9 @@ JOY_COUNT = $05 ; Number of joysticks we support
; Must return a JOY_ERR_xx code in .XA .
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/cx16/mou/cx16-std.s b/libsrc/cx16/mou/cx16-std.s
index 3af7d2eb3..f211815de 100644
--- a/libsrc/cx16/mou/cx16-std.s
+++ b/libsrc/cx16/mou/cx16-std.s
@@ -139,7 +139,8 @@ INSTALL:
; Done, return zero
- ldx #>MOUSE_ERR_OK
+ ldx #MOUSE_ERR_OK
+ .assert MOUSE_ERR_OK = 0, error
txa
rts
@@ -300,8 +301,8 @@ INFO: jsr BUTTONS ; Will not touch ptr1
; specific data in ptr1, and the ioctl code in A.
; Must return an error code in .XA .
-IOCTL: lda #MOUSE_ERR_INV_IOCTL
+IOCTL: lda #MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
+ ldx #0 ; return value is char
; rts ; Fall through
;----------------------------------------------------------------------------
diff --git a/libsrc/cx16/randomize.s b/libsrc/cx16/randomize.s
index 3d965c82a..49051e012 100644
--- a/libsrc/cx16/randomize.s
+++ b/libsrc/cx16/randomize.s
@@ -1,14 +1,14 @@
;
; 2020-05-02, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import ENTROPY_GET, _srand
-__randomize:
+___randomize:
jsr ENTROPY_GET
jmp _srand ; Initialize generator
diff --git a/libsrc/gamate/joy/gamate-stdjoy.s b/libsrc/gamate/joy/gamate-stdjoy.s
index 8f927cdf5..514f92db4 100644
--- a/libsrc/gamate/joy/gamate-stdjoy.s
+++ b/libsrc/gamate/joy/gamate-stdjoy.s
@@ -47,8 +47,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/geos-cbm/disk/dio_cts.s b/libsrc/geos-cbm/disk/dio_cts.s
index 478181b69..81b189f65 100644
--- a/libsrc/geos-cbm/disk/dio_cts.s
+++ b/libsrc/geos-cbm/disk/dio_cts.s
@@ -10,7 +10,7 @@
.export _dio_phys_to_log
.export sectab_1541_l, sectab_1541_h ; for log_to_phys
- .import popax,__oserror
+ .import popax,___oserror
.importzp ptr1,ptr2,ptr3,tmp1,tmp2,tmp3,tmp4
.include "dio.inc"
@@ -82,7 +82,7 @@ dio_ctsend:
ldx #0
txa
ret:
- sta __oserror
+ sta ___oserror
rts ; return success
; errors
diff --git a/libsrc/geos-cbm/disk/dio_openclose.s b/libsrc/geos-cbm/disk/dio_openclose.s
index 327503017..953aed318 100644
--- a/libsrc/geos-cbm/disk/dio_openclose.s
+++ b/libsrc/geos-cbm/disk/dio_openclose.s
@@ -11,7 +11,7 @@
; dio_close does nothing special
.export _dio_open, _dio_close
- .import __oserror, _OpenDisk
+ .import ___oserror, _OpenDisk
.importzp ptr1, tmp1
.include "dio.inc"
@@ -69,7 +69,7 @@ _dio_open:
_inv_drive:
lda #DEV_NOT_FOUND
- sta __oserror
+ sta ___oserror
lda #0
tax
rts
@@ -80,6 +80,6 @@ _dio_close:
lda #0
ldy #sst_flag
sta (ptr1),y
- sta __oserror ; success
+ sta ___oserror ; success
tax
rts ; return no error
diff --git a/libsrc/geos-cbm/disk/dio_qcount.s b/libsrc/geos-cbm/disk/dio_qcount.s
index 5f10ac247..b5d380825 100644
--- a/libsrc/geos-cbm/disk/dio_qcount.s
+++ b/libsrc/geos-cbm/disk/dio_qcount.s
@@ -5,11 +5,11 @@
;
.export _dio_query_sectcount
- .import __oserror
+ .import ___oserror
_dio_query_sectcount:
lda #0
- sta __oserror
+ sta ___oserror
lda #<683
ldx #>683
rts
diff --git a/libsrc/geos-cbm/disk/dio_qsize.s b/libsrc/geos-cbm/disk/dio_qsize.s
index bf9178035..14c8a460a 100644
--- a/libsrc/geos-cbm/disk/dio_qsize.s
+++ b/libsrc/geos-cbm/disk/dio_qsize.s
@@ -5,10 +5,10 @@
;
.export _dio_query_sectsize
- .import __oserror
+ .import ___oserror
_dio_query_sectsize:
lda #<256
ldx #>256
- sta __oserror
+ sta ___oserror
rts
diff --git a/libsrc/geos-cbm/disk/dio_read.s b/libsrc/geos-cbm/disk/dio_read.s
index ac19f9afa..4c9297e65 100644
--- a/libsrc/geos-cbm/disk/dio_read.s
+++ b/libsrc/geos-cbm/disk/dio_read.s
@@ -8,7 +8,7 @@
;
.export _dio_read
- .import dio_params, __oserror
+ .import dio_params, ___oserror
.include "geossym.inc"
.include "jumptab.inc"
@@ -18,6 +18,6 @@ _dio_read:
tay
bne err
jsr ReadBlock
- stx __oserror
+ stx ___oserror
txa
err: rts
diff --git a/libsrc/geos-cbm/disk/dio_stc.s b/libsrc/geos-cbm/disk/dio_stc.s
index 469df93ca..3c3c9108f 100644
--- a/libsrc/geos-cbm/disk/dio_stc.s
+++ b/libsrc/geos-cbm/disk/dio_stc.s
@@ -9,7 +9,7 @@
.export _dio_log_to_phys
.importzp ptr1,ptr2,ptr3,tmp1,tmp2
- .import popax,__oserror
+ .import popax,___oserror
.import sectab_1541_l, sectab_1541_h
.include "dio.inc"
@@ -78,7 +78,7 @@ dio_stcend:
ldx #0
txa
_ret:
- sta __oserror
+ sta ___oserror
rts ; return success
; errors
diff --git a/libsrc/geos-cbm/disk/dio_writev.s b/libsrc/geos-cbm/disk/dio_writev.s
index 9b36ed096..962d7e77f 100644
--- a/libsrc/geos-cbm/disk/dio_writev.s
+++ b/libsrc/geos-cbm/disk/dio_writev.s
@@ -8,7 +8,7 @@
;
.export _dio_write_verify
- .import dio_params, __oserror
+ .import dio_params, ___oserror
.include "geossym.inc"
.include "jumptab.inc"
@@ -18,6 +18,6 @@ _dio_write_verify:
tay
bne err
jsr VerWriteBlock
- stx __oserror
+ stx ___oserror
txa
err: rts
diff --git a/libsrc/geos-cbm/emd/geos-vdc.s b/libsrc/geos-cbm/emd/geos-vdc.s
index 27316e1a0..2e7d19c03 100644
--- a/libsrc/geos-cbm/emd/geos-vdc.s
+++ b/libsrc/geos-cbm/emd/geos-vdc.s
@@ -125,8 +125,9 @@ INSTALL:
pla
sta $01
plp
- lda #EM_ERR_OK
+ lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
test64k:
diff --git a/libsrc/geos-cbm/joy/geos-stdjoy.s b/libsrc/geos-cbm/joy/geos-stdjoy.s
index 2787cb594..a3fd4ffc8 100644
--- a/libsrc/geos-cbm/joy/geos-stdjoy.s
+++ b/libsrc/geos-cbm/joy/geos-stdjoy.s
@@ -53,8 +53,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/geos-common/common/_afailed.c b/libsrc/geos-common/common/_afailed.c
index 97727d605..acc437fb0 100644
--- a/libsrc/geos-common/common/_afailed.c
+++ b/libsrc/geos-common/common/_afailed.c
@@ -8,7 +8,7 @@
#include
#include
-void _afailed (char* file, unsigned line)
+void __afailed (char* file, unsigned line)
{
ExitTurbo();
diff --git a/libsrc/geos-common/common/_poserror.c b/libsrc/geos-common/common/_poserror.c
index eeb3f368e..b47f0a7d9 100644
--- a/libsrc/geos-common/common/_poserror.c
+++ b/libsrc/geos-common/common/_poserror.c
@@ -9,9 +9,9 @@
#include
#include
-void __fastcall__ _poserror (const char* msg)
+void __fastcall__ __poserror (const char* msg)
{
- const char *errmsg = _stroserror(_oserror);
+ const char *errmsg = __stroserror(_oserror);
ExitTurbo();
if (msg && *msg) {
diff --git a/libsrc/geos-common/common/memset.s b/libsrc/geos-common/common/memset.s
index 2cb6732d1..82b7f4a87 100644
--- a/libsrc/geos-common/common/memset.s
+++ b/libsrc/geos-common/common/memset.s
@@ -1,14 +1,14 @@
;
; void* memset (void* ptr, int c, size_t n);
-; void* _bzero (void* ptr, size_t n);
+; void* __bzero (void* ptr, size_t n);
; void bzero (void* ptr, size_t n);
;
; Maciej 'YTM/Elysium' Witkowiak, 20.08.2003
;
- .export _memset, _bzero, __bzero
+ .export _memset, _bzero, ___bzero
.import _ClearRam, _FillRam
_bzero = _ClearRam
-__bzero = _ClearRam
+___bzero = _ClearRam
_memset = _FillRam
diff --git a/libsrc/geos-common/disk/calcblksfree.s b/libsrc/geos-common/disk/calcblksfree.s
index 7e1bb4f52..fec6d6690 100644
--- a/libsrc/geos-common/disk/calcblksfree.s
+++ b/libsrc/geos-common/disk/calcblksfree.s
@@ -5,7 +5,7 @@
; int CalcBlksFree (void);
- .import __oserror
+ .import ___oserror
.export _CalcBlksFree
.include "jumptab.inc"
@@ -18,7 +18,7 @@ _CalcBlksFree:
sta r5L
stx r5H
jsr CalcBlksFree
- stx __oserror
+ stx ___oserror
lda r4L
ldx r4H
rts
diff --git a/libsrc/geos-common/disk/getptrcurdknm.s b/libsrc/geos-common/disk/getptrcurdknm.s
index d92e5d91e..9112c9f99 100644
--- a/libsrc/geos-common/disk/getptrcurdknm.s
+++ b/libsrc/geos-common/disk/getptrcurdknm.s
@@ -7,7 +7,7 @@
; (fills curName[17] with current disk's name)
.importzp ptr4, ptr3
- .import __oserror
+ .import ___oserror
.export _GetPtrCurDkNm
.include "jumptab.inc"
@@ -34,5 +34,5 @@ namelp: lda (ptr4),y
bne namelp
fin: lda #0
sta (ptr3),y
- stx __oserror
+ stx ___oserror
rts
diff --git a/libsrc/geos-common/disk/setnextfree.s b/libsrc/geos-common/disk/setnextfree.s
index b24f16f6f..2d43c1e36 100644
--- a/libsrc/geos-common/disk/setnextfree.s
+++ b/libsrc/geos-common/disk/setnextfree.s
@@ -5,7 +5,7 @@
; struct tr_se SetNextFree (struct tr_se *startTS);
- .import __oserror
+ .import ___oserror
.import gettrse
.export _SetNextFree
@@ -18,7 +18,7 @@ _SetNextFree:
sta r3L
stx r3H
jsr SetNextFree
- stx __oserror
+ stx ___oserror
lda r3L
ldx r3H
rts
diff --git a/libsrc/geos-common/drivers/fio_module.s b/libsrc/geos-common/drivers/fio_module.s
index 1314fc4c5..affbf6ecc 100644
--- a/libsrc/geos-common/drivers/fio_module.s
+++ b/libsrc/geos-common/drivers/fio_module.s
@@ -14,7 +14,7 @@ FILEDES = 3 ; first free to use file descriptor
.importzp ptr1, ptr2, ptr3, tmp1
.import addysp, popax, popptr1
- .import __oserror
+ .import ___oserror
.import _FindFile, _ReadByte
.export _open, _close, _read
@@ -65,8 +65,8 @@ _open:
stx f_offset
stx f_offset+1
lda #0 ; clear errors
- sta __oserror
- jsr __seterrno
+ sta ___oserror
+ jsr ___seterrno
lda #FILEDES ; return fd
sta filedesc
rts
@@ -75,14 +75,14 @@ _open:
.byte $2c ; skip
@alreadyopen:
lda #EMFILE ; too many opened files (there can be only one)
- jmp __directerrno ; set errno, clear oserror, return -1
+ jmp ___directerrno ; set errno, clear oserror, return -1
@oserror:
- jmp __mappederrno ; set platform error code, return -1
+ jmp ___mappederrno ; set platform error code, return -1
_close:
lda #0
- sta __oserror
- jsr __seterrno ; clear errors
+ sta ___oserror
+ jsr ___seterrno ; clear errors
lda #0 ; clear fd
sta filedesc
tax
@@ -92,7 +92,7 @@ _read:
; a/x - number of bytes
; popax - buffer ptr
; popax - fd, must be == to the above one
- ; return -1+__oserror or number of bytes read
+ ; return -1+___oserror or number of bytes read
inx
stx ptr1+1
@@ -111,14 +111,14 @@ _read:
@filenotopen:
lda #EBADF
- jmp __directerrno ; Sets _errno, clears _oserror, returns -1
+ jmp ___directerrno ; Sets _errno, clears __oserror, returns -1
@fileok:
lda #0
sta ptr3
sta ptr3+1 ; put 0 into ptr3 (number of bytes read)
- sta __oserror ; clear error flags
- jsr __seterrno
+ sta ___oserror ; clear error flags
+ jsr ___seterrno
lda f_track ; restore stuff for ReadByte
ldx f_sector
@@ -147,11 +147,11 @@ _read:
bne @L2
inc ptr3+1
-@L2: lda __oserror ; was there error ?
+@L2: lda ___oserror ; was there error ?
beq @L3
cmp #BFR_OVERFLOW ; EOF?
beq @done ; yes, we're done
- jmp __mappederrno ; no, we're screwed
+ jmp ___mappederrno ; no, we're screwed
@L3: dec ptr1 ; decrement the count
bne @L0
diff --git a/libsrc/geos-common/file/get1stdirentry.s b/libsrc/geos-common/file/get1stdirentry.s
index f0ad59388..2217718ea 100644
--- a/libsrc/geos-common/file/get1stdirentry.s
+++ b/libsrc/geos-common/file/get1stdirentry.s
@@ -5,7 +5,7 @@
; struct filehandle* Get1stDirEntry (void);
- .import __oserror, return0
+ .import ___oserror, return0
.export _Get1stDirEntry
.include "diskdrv.inc"
@@ -13,7 +13,7 @@
_Get1stDirEntry:
jsr Get1stDirEntry
- stx __oserror
+ stx ___oserror
txa
bne L1 ; jump if disk error
lda r5L
diff --git a/libsrc/geos-common/file/getnxtdirentry.s b/libsrc/geos-common/file/getnxtdirentry.s
index e8ccbf3a2..0f74a0ed8 100644
--- a/libsrc/geos-common/file/getnxtdirentry.s
+++ b/libsrc/geos-common/file/getnxtdirentry.s
@@ -5,7 +5,7 @@
; struct filehandle* GetNxtDirEntry (void);
- .import __oserror, return0
+ .import ___oserror, return0
.export _GetNxtDirEntry
.include "diskdrv.inc"
@@ -13,7 +13,7 @@
_GetNxtDirEntry:
jsr GetNxtDirEntry
- stx __oserror
+ stx ___oserror
txa
bne L1 ; jump if disk error
tya
diff --git a/libsrc/geos-common/file/readbyte.s b/libsrc/geos-common/file/readbyte.s
index 9a24e68df..90616a426 100644
--- a/libsrc/geos-common/file/readbyte.s
+++ b/libsrc/geos-common/file/readbyte.s
@@ -5,13 +5,13 @@
; char ReadByte (void);
- .import __oserror
+ .import ___oserror
.export _ReadByte
.include "jumptab.inc"
_ReadByte:
jsr ReadByte
- stx __oserror
+ stx ___oserror
ldx #0
rts
diff --git a/libsrc/geos-common/system/oserror.s b/libsrc/geos-common/system/oserror.s
index f0915fd5b..fa45f3e14 100644
--- a/libsrc/geos-common/system/oserror.s
+++ b/libsrc/geos-common/system/oserror.s
@@ -3,16 +3,16 @@
; GEOS port: Maciej 'YTM/Elysium' Witkowiak
; 2.7.2001
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system specific error into a system independent code */
;
- .export __osmaperrno
+ .export ___osmaperrno
.include "errno.inc"
.include "const.inc"
-__osmaperrno:
+___osmaperrno:
ldx #ErrTabSize
@L1: cmp ErrTab-2,x ; Search for the error code
beq @L2 ; Jump if found
diff --git a/libsrc/geos-common/system/randomize.s b/libsrc/geos-common/system/randomize.s
index 67c217d80..d8f821356 100644
--- a/libsrc/geos-common/system/randomize.s
+++ b/libsrc/geos-common/system/randomize.s
@@ -1,16 +1,16 @@
;
; Ullrich von Bassewitz, 05.11.2002
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "geossym.inc"
-__randomize:
+___randomize:
lda random ; get random value from internal generator
ldx random+1
jmp _srand ; and use it as seed
diff --git a/libsrc/geos-common/system/setoserror.s b/libsrc/geos-common/system/setoserror.s
index adc6ad017..6fb89e96e 100644
--- a/libsrc/geos-common/system/setoserror.s
+++ b/libsrc/geos-common/system/setoserror.s
@@ -5,10 +5,10 @@
;
.export setoserror
- .import __oserror
+ .import ___oserror
setoserror:
- stx __oserror
+ stx ___oserror
txa
ldx #0 ; X is cleared (high byte for promoting char to int)
tay ; Y register is used just to save flags state
diff --git a/libsrc/joystick/joy_unload.s b/libsrc/joystick/joy_unload.s
index 25d54ff02..f52b7a2c1 100644
--- a/libsrc/joystick/joy_unload.s
+++ b/libsrc/joystick/joy_unload.s
@@ -10,7 +10,7 @@
.include "modload.inc"
.import joy_clear_ptr
- .import return0
+ .import return0, return1
@@ -31,7 +31,6 @@ _joy_unload:
jmp return0 ; Return JOY_ERR_OK
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #JOY_ERR_NO_DRIVER
- rts
+ .assert JOY_ERR_NO_DRIVER = 1, error
+ jmp return1 ; Return JOY_ERR_NO_DRIVER
diff --git a/libsrc/kim1/crt0.s b/libsrc/kim1/crt0.s
new file mode 100644
index 000000000..906b3b980
--- /dev/null
+++ b/libsrc/kim1/crt0.s
@@ -0,0 +1,45 @@
+;
+; Startup code for cc65 (KIM-1 version)
+;
+
+ .export _init, _exit
+ .export __STARTUP__ : absolute = 1 ; Mark as startup
+
+ .import _main
+ .import initlib, donelib, copydata, zerobss
+ .import __RAM_START__, __RAM_SIZE__ ; Linker generated
+ .import __STACKSIZE__ ; Linker generated
+
+ .include "zeropage.inc"
+ .include "kim1.inc"
+
+
+; Place the startup code in a special segment
+
+.segment "STARTUP"
+
+
+; A little light housekeeping
+
+_init: cld ; Clear decimal mode
+
+; Set cc65 argument stack pointer
+
+ lda #<(__RAM_START__ + __RAM_SIZE__)
+ sta sp
+ lda #>(__RAM_START__ + __RAM_SIZE__)
+ sta sp+1
+
+; Initialize memory storage
+
+ jsr zerobss ; Clear BSS segment
+ jsr copydata ; Initialize DATA segment
+ jsr initlib ; Run constructors
+
+; Call main()
+
+ jsr _main
+
+; Back from main (this is also the _exit entry). Jumps to the KIM-1 monitor.
+
+_exit: jmp START
diff --git a/libsrc/kim1/ctype.s b/libsrc/kim1/ctype.s
new file mode 100644
index 000000000..1301965eb
--- /dev/null
+++ b/libsrc/kim1/ctype.s
@@ -0,0 +1,5 @@
+; Character specification table.
+;
+; uses the "common" definition
+
+ .include "ctype_common.inc"
diff --git a/libsrc/kim1/getkey.s b/libsrc/kim1/getkey.s
new file mode 100644
index 000000000..b36cd4b4c
--- /dev/null
+++ b/libsrc/kim1/getkey.s
@@ -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
diff --git a/libsrc/kim1/read.s b/libsrc/kim1/read.s
new file mode 100644
index 000000000..dd178ee98
--- /dev/null
+++ b/libsrc/kim1/read.s
@@ -0,0 +1,46 @@
+;
+; int __fastcall__ read (int fd, void* buf, unsigned count);
+;
+
+.include "kim1.inc"
+
+.import popax, popptr1
+.importzp ptr1, ptr2, ptr3
+
+.export _read
+
+.proc _read
+
+ sta ptr3
+ stx ptr3+1 ; Count in ptr3
+ inx
+ stx ptr2+1 ; Increment and store in ptr2
+ tax
+ inx
+ stx ptr2
+ jsr popptr1 ; Buffer address in ptr1
+ jsr popax
+
+begin: dec ptr2
+ bne getch
+ dec ptr2+1
+ beq done ; If buffer full, return
+
+getch: jsr INTCHR ; Get character using Monitor ROM call
+ and #$7F ; Clear top bit
+ cmp #$0D ; Check for '\r'
+ bne putch ; ...if CR character
+ lda #$0A ; Replace with '\n'
+
+putch: ldy #$00 ; Put char into return buffer
+ sta (ptr1),y
+ inc ptr1 ; Increment pointer
+ bne begin
+ inc ptr1+1
+ bne begin
+
+done: lda ptr3
+ ldx ptr3+1
+ rts ; Return count
+
+.endproc
diff --git a/libsrc/kim1/scandisplay.s b/libsrc/kim1/scandisplay.s
new file mode 100644
index 000000000..0f46a5de4
--- /dev/null
+++ b/libsrc/kim1/scandisplay.s
@@ -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
diff --git a/libsrc/kim1/tapeio.s b/libsrc/kim1/tapeio.s
new file mode 100644
index 000000000..4a16d6b9c
--- /dev/null
+++ b/libsrc/kim1/tapeio.s
@@ -0,0 +1,39 @@
+;
+; int __fastcall__ loadt (unsigned char id);
+; int __fastcall__ dumpt (unsigned char id, void* start_addr, void* end_addr);
+;
+
+.include "kim1.inc"
+
+.import popa, popax, return0, return1
+
+.export _loadt, _dumpt
+
+.segment "CODE"
+
+.proc _loadt: near
+
+ sta ID ; Tape record ID to P1L
+ jsr LOADT ; Read data from tape
+ bcs error
+ jmp return0 ; Return 0 if sucessful
+error: jmp return1 ; or 1 if not
+
+.endproc
+
+.proc _dumpt: near
+
+ sta EAL ; End address
+ stx EAH
+ jsr popax
+ sta SAL ; Start address
+ stx SAH
+ jsr popa
+ sta ID ; Tape Record ID
+ ldx #$00
+ jsr DUMPT ; Write data to tape
+ bcs error
+ jmp return0 ; Return 0 if sucessful
+error: jmp return1 ; or 1 if not
+
+.endproc
diff --git a/libsrc/kim1/write.s b/libsrc/kim1/write.s
new file mode 100644
index 000000000..96bcc91d1
--- /dev/null
+++ b/libsrc/kim1/write.s
@@ -0,0 +1,48 @@
+;
+; int __fastcall__ write (int fd, const void* buf, int count);
+;
+
+.include "kim1.inc"
+
+.import popax, popptr1
+.importzp ptr1, ptr2, ptr3
+
+.export _write
+
+.proc _write
+
+ sta ptr3
+ stx ptr3+1 ; Count in ptr3
+ inx
+ stx ptr2+1 ; Increment and store in ptr2
+ tax
+ inx
+ stx ptr2
+ jsr popptr1 ; Buffer address in ptr1
+ jsr popax
+
+begin: dec ptr2
+ bne outch
+ dec ptr2+1
+ beq done
+
+outch: ldy #0
+ lda (ptr1),y
+ pha ; Save A (changed by OUTCHR)
+ jsr OUTCHR ; Send character using Monitor call
+ pla ; Restore A
+ cmp #$0A ; Check for '\n'
+ bne next ; ...if LF character
+ lda #$0D ; Add a carriage return
+ jsr OUTCHR
+
+next: inc ptr1
+ bne begin
+ inc ptr1+1
+ jmp begin
+
+done: lda ptr3
+ ldx ptr3+1
+ rts ; Return count
+
+.endproc
diff --git a/libsrc/lynx/clock.s b/libsrc/lynx/clock.s
index e29799df6..d881e5a67 100644
--- a/libsrc/lynx/clock.s
+++ b/libsrc/lynx/clock.s
@@ -3,13 +3,13 @@
; 2012-02-06, Greg King
;
; clock_t clock (void);
-; clock_t _clocks_per_sec (void);
+; clock_t __clocks_per_sec (void);
;
; clocks_per_sec()'s test-values are based on the numbers in "set_tv.s".
; If you change the numbers there, then change them here, too.
;
- .export _clock, __clocks_per_sec, clock_count
+ .export _clock, ___clocks_per_sec, clock_count
.interruptor update_clock, 2 ; (low priority)
.constructor init_clock
@@ -38,7 +38,7 @@
;-----------------------------------------------------------------------------
; Return the number of clock ticks in one second.
;
-__clocks_per_sec:
+___clocks_per_sec:
ldx #$00 ; >50, >60, >75
ldy PBKUP
lda #<75
diff --git a/libsrc/lynx/joy/lynx-stdjoy.s b/libsrc/lynx/joy/lynx-stdjoy.s
index c81a97dbf..45eb8ab4e 100644
--- a/libsrc/lynx/joy/lynx-stdjoy.s
+++ b/libsrc/lynx/joy/lynx-stdjoy.s
@@ -58,8 +58,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/lynx/open.s b/libsrc/lynx/open.s
index c48b8eb95..032f55a99 100644
--- a/libsrc/lynx/open.s
+++ b/libsrc/lynx/open.s
@@ -66,7 +66,7 @@ parmok: jsr popax
beq flagsok
jsr popax
lda #EINVAL
- jmp __directerrno
+ jmp ___directerrno
flagsok:
jsr popax
@@ -74,7 +74,7 @@ flagsok:
jsr _openn
ldx #$00
lda #$01
- stx __oserror
+ stx ___oserror
rts
.endproc
diff --git a/libsrc/lynx/oserror.s b/libsrc/lynx/oserror.s
index 5570a3bb7..b2ccbf4f0 100644
--- a/libsrc/lynx/oserror.s
+++ b/libsrc/lynx/oserror.s
@@ -1,7 +1,7 @@
;
; Karri Kaksonen, 2010
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system specific error into a system independent code */
;
@@ -9,6 +9,6 @@
.code
-__osmaperrno:
+___osmaperrno:
rts
diff --git a/libsrc/lynx/ser/lynx-comlynx.s b/libsrc/lynx/ser/lynx-comlynx.s
index ded862eaa..8aa3c838e 100644
--- a/libsrc/lynx/ser/lynx-comlynx.s
+++ b/libsrc/lynx/ser/lynx-comlynx.s
@@ -75,8 +75,9 @@ SER_UNINSTALL:
SER_CLOSE:
; Disable interrupts
; Done, return an error code
- lda #SER_ERR_OK
+ lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
;----------------------------------------------------------------------------
@@ -190,8 +191,8 @@ SER_OPEN:
cmp #SER_BAUD_134_5
beq setbaudrate
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
setprescaler:
stx TIM4CTLA
@@ -238,12 +239,13 @@ checkhs:
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
- lda #SER_ERR_OK
+ lda #SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ tax
rts
invparameter:
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -255,8 +257,8 @@ SER_GET:
lda RxPtrIn
cmp RxPtrOut
bne GetByte
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
GetByte:
ldy RxPtrOut
@@ -277,8 +279,8 @@ SER_PUT:
ina
cmp TxPtrOut
bne PutByte
- lda #SER_ERR_OVERFLOW
+ lda #SER_ERR_OVERFLOW
+ ldx #0 ; return value is char
rts
PutByte:
ldy TxPtrIn
@@ -296,7 +298,8 @@ PutByte:
sta TxDone
plp
@L1:
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
diff --git a/libsrc/lynx/ser_stat_stddrv.s b/libsrc/lynx/ser_stat_stddrv.s
new file mode 100644
index 000000000..37f481c47
--- /dev/null
+++ b/libsrc/lynx/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _lynx_comlynx_ser
+
+.rodata
+
+_ser_static_stddrv := _lynx_comlynx_ser
diff --git a/libsrc/mouse/mouse_unload.s b/libsrc/mouse/mouse_unload.s
index 8c9018484..ecd7846ab 100644
--- a/libsrc/mouse/mouse_unload.s
+++ b/libsrc/mouse/mouse_unload.s
@@ -8,7 +8,7 @@
.include "mouse-kernel.inc"
.include "modload.inc"
- .import return0
+ .import return0, return1
@@ -29,7 +29,6 @@ _mouse_unload:
jmp return0 ; Return MOUSE_ERR_OK
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #load_addr
sta load
@@ -57,9 +56,9 @@ LINEDIST = $20 ; Offset in video RAM between two lines
stx count+1 ; save size with each byte incremented separately
L1: dec count
- bnz L2
+ bne L2
dec count+1
- bze L3
+ beq L3
L2: jsr GETCHAR ; (doesn't change .Y)
sta (load),y
@@ -70,12 +69,12 @@ L2: jsr GETCHAR ; (doesn't change .Y)
lsr a
and #8 - 1
ora #$10 ; eight arrow characters
- sta SCRNBASE + FIRSTVISC + 2 * LINEDIST + 11
+ sta C1P_SCR_BASE + FIRSTVISC + 2 * LINEDIST + 11
iny
- bnz L1
+ bne L1
inc load+1
- bnz L1 ; branch always
+ bne L1 ; branch always
L3: jmp load_addr
@@ -112,18 +111,15 @@ CR = $0D
hex2 >load_addr
.byte CR, "85", CR, "08", CR
.byte "86", CR, "09", CR
- .byte "A9", CR
- hex2 load_size
- .byte CR, "49", CR, "FF", CR
- .byte "85", CR, "0B", CR
-
- .byte "E6", CR, "0A", CR
+ .byte "A2", CR
+ hex2 (load_size) + 1
+ .byte CR, "86", CR, "0B", CR
+ .byte "C6", CR, "0A", CR
.byte "D0", CR, "04", CR
- .byte "E6", CR, "0B", CR
+ .byte "C6", CR, "0B", CR
.byte "F0", CR, "16", CR
.byte "20", CR, "BF", CR, "FF", CR
.byte "91", CR, "08", CR
diff --git a/libsrc/osic1p/extra/screen-c1p-48x12.s b/libsrc/osic1p/extra/screen-c1p-48x12.s
new file mode 100644
index 000000000..91a61338b
--- /dev/null
+++ b/libsrc/osic1p/extra/screen-c1p-48x12.s
@@ -0,0 +1,16 @@
+;
+; Implementation of screen-layout related functions for Challenger 1P in 48x12 mode.
+;
+
+ .include "../osiscreen.inc"
+
+C1P_SCR_BASE := $D000 ; Base of C1P video RAM
+C1P_VRAM_SIZE = $0400 ; Size of C1P video RAM (1 kB)
+C1P_SCR_WIDTH = $30 ; Screen width
+C1P_SCR_HEIGHT = $0C ; Screen height
+C1P_SCR_FIRSTCHAR = $8B ; Offset of cursor position (0, 0) from base
+ ; of video RAM
+C1P_SCROLL_DIST = $40 ; Memory distance for scrolling by one line
+
+osi_screen_funcs C1P_SCR_BASE, C1P_VRAM_SIZE, C1P_SCR_FIRSTCHAR, \
+ C1P_SCR_WIDTH, C1P_SCR_HEIGHT, C1P_SCROLL_DIST
diff --git a/libsrc/osic1p/oserror.s b/libsrc/osic1p/oserror.s
index 073691a06..380c5ebb9 100644
--- a/libsrc/osic1p/oserror.s
+++ b/libsrc/osic1p/oserror.s
@@ -4,14 +4,14 @@
; original by
; Stefan Haubenthal, 2011-04-18
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system specific error into a system independent code */
;
.include "errno.inc"
- .export __osmaperrno
+ .export ___osmaperrno
-.proc __osmaperrno
+.proc ___osmaperrno
lda #EUNKNOWN
diff --git a/libsrc/pce/joy/pce-stdjoy.s b/libsrc/pce/joy/pce-stdjoy.s
index 2de3d0c4c..dc8576c87 100644
--- a/libsrc/pce/joy/pce-stdjoy.s
+++ b/libsrc/pce/joy/pce-stdjoy.s
@@ -50,8 +50,9 @@ padbuffer: .res JOY_COUNT
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/pce/memset.s b/libsrc/pce/memset.s
index 45a78d533..1148e00c8 100644
--- a/libsrc/pce/memset.s
+++ b/libsrc/pce/memset.s
@@ -6,21 +6,21 @@
; 1998-05-29, Ullrich von Bassewitz
; 2015-11-06, Greg King
;
-; void* __fastcall__ _bzero (void* ptr, size_t n);
+; void* __fastcall__ __bzero (void* ptr, size_t n);
; void __fastcall__ bzero (void* ptr, size_t n);
; void* __fastcall__ memset (void* ptr, int c, size_t n);
;
; NOTE: bzero() will return its first argument, as memset() does. It is no
; problem to declare the return value as void, because it can be ignored.
-; _bzero() (note the leading underscore) is declared with the proper
-; return type because the compiler will replace memset() by _bzero() if
+; __bzero() (note the leading underscores) is declared with the proper
+; return type because the compiler will replace memset() by __bzero() if
; the fill value is zero; and, the optimizer looks at the return type
; to see if the value in .XA is of any use.
;
; NOTE: This function uses entry points from "pce/memcpy.s"!
;
- .export __bzero, _bzero, _memset
+ .export ___bzero, _bzero, _memset
.import memcpy_getparams, memcpy_increment
.import pushax, popax
@@ -30,7 +30,7 @@
; ----------------------------------------------------------------------
-__bzero:
+___bzero:
_bzero: pha
cla ; fill with zeros
jsr pushax ; (high byte isn't important)
diff --git a/libsrc/pet/joy/pet-ptvjoy.s b/libsrc/pet/joy/pet-ptvjoy.s
index c098072fb..ee14c95c8 100644
--- a/libsrc/pet/joy/pet-ptvjoy.s
+++ b/libsrc/pet/joy/pet-ptvjoy.s
@@ -51,8 +51,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/pet/randomize.s b/libsrc/pet/randomize.s
index 44bf4c38e..a173cf076 100644
--- a/libsrc/pet/randomize.s
+++ b/libsrc/pet/randomize.s
@@ -2,16 +2,16 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "pet.inc"
-__randomize:
+___randomize:
ldx TIME+2
lda TIME+1 ; Use 60HZ clock
jmp _srand ; Initialize generator
diff --git a/libsrc/plus4/joy/plus4-stdjoy.s b/libsrc/plus4/joy/plus4-stdjoy.s
index e8e85fedc..86f080dae 100644
--- a/libsrc/plus4/joy/plus4-stdjoy.s
+++ b/libsrc/plus4/joy/plus4-stdjoy.s
@@ -58,8 +58,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/plus4/randomize.s b/libsrc/plus4/randomize.s
index 796ad118b..0d1ccaf03 100644
--- a/libsrc/plus4/randomize.s
+++ b/libsrc/plus4/randomize.s
@@ -2,16 +2,16 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "plus4.inc"
-__randomize:
+___randomize:
ldx TED_VLINELO ; Use TED rasterline as high byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator
diff --git a/libsrc/plus4/ser/plus4-stdser.s b/libsrc/plus4/ser/plus4-stdser.s
index bb44a4cf9..fbdc61b2e 100644
--- a/libsrc/plus4/ser/plus4-stdser.s
+++ b/libsrc/plus4/ser/plus4-stdser.s
@@ -157,8 +157,9 @@ SER_CLOSE:
; Done, return an error code
- lda #SER_ERR_INIT_FAILED
+ lda #SER_ERR_INIT_FAILED
+ ldx #0 ; return value is char
rts
; Baud rate not available
InvBaud:
- lda #SER_ERR_BAUD_UNAVAIL
+ lda #SER_ERR_BAUD_UNAVAIL
+ ldx #0 ; return value is char
rts
;----------------------------------------------------------------------------
@@ -261,8 +263,8 @@ SER_GET:
@L1: lda RecvFreeCnt ; (25)
cmp #$ff
bne @L2
- lda #SER_ERR_NO_DATA
+ lda #SER_ERR_NO_DATA
+ ldx #0 ; return value is char
rts
; Check for flow stopped & enough free: release flow control
@@ -309,7 +311,7 @@ SER_PUT:
@L2: ldx SendFreeCnt
bne @L3
- lda #SER_ERR_INV_IOCTL
+ lda #SER_ERR_INV_IOCTL ; We don't support ioclts for now
+ ldx #0 ; return value is char
rts ; Run into IRQ instead
;----------------------------------------------------------------------------
diff --git a/libsrc/plus4/ser_stat_stddrv.s b/libsrc/plus4/ser_stat_stddrv.s
new file mode 100644
index 000000000..f35b09232
--- /dev/null
+++ b/libsrc/plus4/ser_stat_stddrv.s
@@ -0,0 +1,14 @@
+;
+; Address of the static standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const void ser_static_stddrv[];
+;
+
+ .export _ser_static_stddrv
+ .import _plus4_stdser_ser
+
+.rodata
+
+_ser_static_stddrv := _plus4_stdser_ser
diff --git a/libsrc/plus4/ser_stddrv.s b/libsrc/plus4/ser_stddrv.s
new file mode 100644
index 000000000..f308d5f40
--- /dev/null
+++ b/libsrc/plus4/ser_stddrv.s
@@ -0,0 +1,13 @@
+;
+; Name of the standard serial driver
+;
+; Oliver Schmidt, 2022-12-22
+;
+; const char ser_stddrv[];
+;
+
+ .export _ser_stddrv
+
+.rodata
+
+_ser_stddrv: .asciiz "plus4-stdser.ser"
diff --git a/libsrc/serial/ser_unload.s b/libsrc/serial/ser_unload.s
index bf7201255..7cd0f7125 100644
--- a/libsrc/serial/ser_unload.s
+++ b/libsrc/serial/ser_unload.s
@@ -10,7 +10,7 @@
.include "modload.inc"
.import ser_clear_ptr
- .import return0
+ .import return0, return1
@@ -28,10 +28,10 @@ _ser_unload:
tax
pla ; Get pointer to driver
jsr _mod_free ; Free the driver
- jmp return0 ; Return SER_ERR_OK
+ .assert SER_ERR_OK = 0, error
+ jmp return0
no_driver:
- tax ; X = 0
pla ; Remove pushed junk
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
diff --git a/libsrc/telestrat/joy/telestrat.s b/libsrc/telestrat/joy/telestrat.s
index 0f5d28651..7472ab187 100644
--- a/libsrc/telestrat/joy/telestrat.s
+++ b/libsrc/telestrat/joy/telestrat.s
@@ -54,8 +54,9 @@ INSTALL:
sta VIA2::PRB
; 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.
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/telestrat/lseek.s b/libsrc/telestrat/lseek.s
new file mode 100644
index 000000000..11d1fad33
--- /dev/null
+++ b/libsrc/telestrat/lseek.s
@@ -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
diff --git a/libsrc/telestrat/oserror.s b/libsrc/telestrat/oserror.s
index e3b9e619a..8fe255656 100644
--- a/libsrc/telestrat/oserror.s
+++ b/libsrc/telestrat/oserror.s
@@ -1,14 +1,14 @@
;
; Jede, 2017-10-27
;
-; int __fastcall__ _osmaperrno (unsigned char oserror);
+; int __fastcall__ __osmaperrno (unsigned char oserror);
; /* Map a system specific error into a system independent code */
;
.include "errno.inc"
- .export __osmaperrno
+ .export ___osmaperrno
-.proc __osmaperrno
+.proc ___osmaperrno
lda #EUNKNOWN
diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s
index f31909f45..736546363 100644
--- a/libsrc/telestrat/read.s
+++ b/libsrc/telestrat/read.s
@@ -30,13 +30,14 @@
ldy ptr1+1
BRK_TELEMON XFREAD
; compute nb of bytes read
- lda PTR_READ_DEST+1
sec
+ lda PTR_READ_DEST
+ sbc ptr2
+ pha
+ lda PTR_READ_DEST+1
sbc ptr2+1
tax
- lda PTR_READ_DEST
- sec
- sbc ptr2
- ; here A and X contains number of bytes read
+ pla
+
rts
.endproc
diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s
index 2ce2657ac..37a896696 100644
--- a/libsrc/telestrat/write.s
+++ b/libsrc/telestrat/write.s
@@ -42,16 +42,16 @@ next:
ldy ptr3+1
ldx tmp1 ; send fd in X
BRK_TELEMON XFWRITE
+
; compute nb of bytes written
-
-
- lda PTR_READ_DEST+1
sec
+ lda PTR_READ_DEST
+ sbc ptr1
+ pha
+ lda PTR_READ_DEST+1
sbc ptr1+1
tax
- lda PTR_READ_DEST
- sec
- sbc ptr1
+ pla
rts
diff --git a/libsrc/tgi/tgi_unload.s b/libsrc/tgi/tgi_unload.s
index 1012969d2..c01228080 100644
--- a/libsrc/tgi/tgi_unload.s
+++ b/libsrc/tgi/tgi_unload.s
@@ -29,6 +29,6 @@ _tgi_unload:
jmp _mod_free ; Free the driver
no_driver:
- lda #EM_ERR_NO_DEVICE
+ lda #EM_ERR_NO_DEVICE
+ ldx #0 ; return value is char
rts
@setok:
lda #0
sta pagecount
stx pagecount+1
- lda #EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ tax
rts
check:
diff --git a/libsrc/vic20/emd/vic20-rama.s b/libsrc/vic20/emd/vic20-rama.s
index 133c3974b..4264e2caf 100644
--- a/libsrc/vic20/emd/vic20-rama.s
+++ b/libsrc/vic20/emd/vic20-rama.s
@@ -71,12 +71,13 @@ INSTALL:
ldx #$FF
stx curpage ; Invalidate the current page
- inx ; X = 0
- txa ; A = X = EM_ERR_OK
+ .assert EM_ERR_OK = 0, error
+ inx
+ txa
rts
-nomem: ldx #>EM_ERR_NO_DEVICE
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/vic20/joy/vic20-stdjoy.s b/libsrc/vic20/joy/vic20-stdjoy.s
index ee8dc93d7..b3de8766c 100644
--- a/libsrc/vic20/joy/vic20-stdjoy.s
+++ b/libsrc/vic20/joy/vic20-stdjoy.s
@@ -57,8 +57,9 @@ JOY_COUNT = 1 ; Number of joysticks we support
;
INSTALL:
- lda #JOY_ERR_OK
+ lda #JOY_ERR_OK
+ .assert JOY_ERR_OK = 0, error
+ tax
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
diff --git a/libsrc/vic20/randomize.s b/libsrc/vic20/randomize.s
index 69cf07bb3..ac2c09a7d 100644
--- a/libsrc/vic20/randomize.s
+++ b/libsrc/vic20/randomize.s
@@ -2,16 +2,16 @@
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
-; void _randomize (void);
+; void __randomize (void);
; /* Initialize the random number generator */
;
- .export __randomize
+ .export ___randomize
.import _srand
.include "vic20.inc"
-__randomize:
+___randomize:
lda VIC_LINES ; Get overflow bit
asl a ; Shift bit 7 into carry
lda VIC_HLINE ; Get bit 1-8 of rasterline
diff --git a/samples/Makefile b/samples/Makefile
index 4007e3522..0e5292306 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -154,7 +154,7 @@ endif
# Lists of subdirectories
# disasm depends on cpp
-DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 cbm
+DIRLIST = tutorial geos atari2600 atari5200 apple2 gamate lynx supervision sym1 kim1 cbm
# --------------------------------------------------------------------------
# Lists of executables
@@ -171,6 +171,7 @@ EXELIST_apple2 = \
multdemo \
ovrldemo \
sieve \
+ terminal \
tinyshell \
tgidemo
@@ -186,6 +187,7 @@ EXELIST_atari = \
multdemo \
ovrldemo \
sieve \
+ terminal \
tinyshell \
tgidemo
@@ -203,6 +205,7 @@ EXELIST_atmos = \
hello \
mandelbrot \
sieve \
+ terminal \
tgidemo
EXELIST_bbc = \
@@ -219,6 +222,7 @@ EXELIST_c64 = \
multdemo \
ovrldemo \
sieve \
+ terminal \
tinyshell \
tgidemo
@@ -231,6 +235,7 @@ EXELIST_c128 = \
mandelbrot \
mousedemo \
sieve \
+ terminal \
tinyshell \
tgidemo
@@ -247,6 +252,7 @@ EXELIST_cbm510 = \
gunzip65 \
hello \
mousedemo \
+ terminal \
tinyshell \
sieve
@@ -255,6 +261,7 @@ EXELIST_cbm610 = \
checkversion \
gunzip65 \
hello \
+ terminal \
tinyshell \
sieve
@@ -314,6 +321,7 @@ EXELIST_plus4 = \
enumdevdir \
gunzip65 \
hello \
+ terminal \
tinyshell \
sieve
@@ -329,6 +337,9 @@ EXELIST_supervision = \
EXELIST_sym1 = \
notavailable
+EXELIST_kim1 = \
+ notavailable
+
EXELIST_telestrat = \
ascii \
checkversion \
@@ -395,6 +406,7 @@ TARGETS := \
creativision \
cx16 \
gamate \
+ kim1 \
lunix \
lynx \
nes \
@@ -414,6 +426,7 @@ TARGETS := \
define TARGET_recipe
+@echo making samples for: $(T)
@$(MAKE) -j2 SYS:=$(T)
@$(MAKE) --no-print-directory clean SYS:=$(T)
diff --git a/samples/geos/Makefile b/samples/geos/Makefile
index 1fc49a873..03f6b8cdc 100644
--- a/samples/geos/Makefile
+++ b/samples/geos/Makefile
@@ -80,6 +80,14 @@ EXELIST_geos-apple = \
ifneq ($(EXELIST_$(SYS)),)
samples: $(EXELIST_$(SYS))
$(foreach dir,$(DIRLIST),$(SUBDIR_recipe))
+
+define samples-geos
+c1541 -attach $(0).d64 -geoswrite $(1);
+endef
+
+samples-geos: $(EXELIST_$(SYS))
+ c1541 -format "$@,01" d64 $@.d64
+ $(foreach tool,$(EXELIST_$(SYS)),$(call samples-geos,$(tool)))
else
samples:
ifeq ($(MAKELEVEL),0)
@@ -94,37 +102,37 @@ bitmap.c: logo.pcx
$(SP) -r logo.pcx -c geos-bitmap -w bitmap.c,ident=bitmap
bitmap-demo.cvt: bitmap.c bitmap-demores.grc bitmap-demo.c
- $(CL) -t $(SYS) -O -o bitmap-demo.cvt -m bitmap-demo.map bitmap-demores.grc bitmap-demo.c
+ $(CL) -t $(SYS) -O -o $@ -m bitmap-demo.map bitmap-demores.grc bitmap-demo.c
filesel.cvt: fileselres.grc filesel.c
- $(CL) -t $(SYS) -O -o filesel.cvt -m filesel.map fileselres.grc filesel.c
+ $(CL) -t $(SYS) -O -o $@ -m filesel.map fileselres.grc filesel.c
geosconio.cvt: geosconiores.grc geosconio.c
- $(CL) -t $(SYS) -O -o geosconio.cvt -m geosconio.map geosconiores.grc geosconio.c
+ $(CL) -t $(SYS) -O -o $@ -m geosconio.map geosconiores.grc geosconio.c
geosver.cvt: geosverres.grc geosver.c
- $(CL) -t $(SYS) -O -o geover.cvt -m geosver.map geosverres.grc geosver.c
+ $(CL) -t $(SYS) -O -o $@ -m geosver.map geosverres.grc geosver.c
getid.cvt: getidres.grc getid.c
- $(CL) -t $(SYS) -O -o getid.cvt -m getid.map getidres.grc getid.c
+ $(CL) -t $(SYS) -O -o $@ -m getid.map getidres.grc getid.c
hello1.cvt: hello1res.grc hello1.c
- $(CL) -t $(SYS) -O -o hello1.cvt -m hello1.map hello1res.grc hello1.c
+ $(CL) -t $(SYS) -O -o $@ -m hello1.map hello1res.grc hello1.c
hello2.cvt: hello2res.grc hello2.c
- $(CL) -t $(SYS) -O -o hello2.cvt -m hello2.map hello2res.grc hello2.c
+ $(CL) -t $(SYS) -O -o $@ -m hello2.map hello2res.grc hello2.c
overlay-demo.cvt: overlay-demores.grc overlay-demo.c
- $(CL) -t $(SYS) -O -o overlay-demo.cvt -m overlay-demo.map overlay-demores.grc overlay-demo.c
+ $(CL) -t $(SYS) -O -o $@ -m overlay-demo.map overlay-demores.grc overlay-demo.c
rmvprot.cvt: rmvprotres.grc rmvprot.c
- $(CL) -t $(SYS) -O -o rmvprot.cvt -m rmvprot.map rmvprotres.grc rmvprot.c
+ $(CL) -t $(SYS) -O -o $@ -m rmvprot.map rmvprotres.grc rmvprot.c
vector-demo.cvt: vector-demores.grc vector-demo.c
- $(CL) -t $(SYS) -O -o vector-demo.cvt -m vector-demo.map vector-demores.grc vector-demo.c
+ $(CL) -t $(SYS) -O -o $@ -m vector-demo.map vector-demores.grc vector-demo.c
yesno.cvt: yesnores.grc yesno.c
- $(CL) -t $(SYS) -O -o yesno.cvt -m yesno.map yesnores.grc yesno.c
+ $(CL) -t $(SYS) -O -o $@ -m yesno.map yesnores.grc yesno.c
clean:
diff --git a/samples/kim1/Makefile b/samples/kim1/Makefile
new file mode 100644
index 000000000..74c415fdc
--- /dev/null
+++ b/samples/kim1/Makefile
@@ -0,0 +1,62 @@
+
+# Run 'make SYS='; or, set a SYS env.
+# var. to build for another target system.
+SYS ?= kim1
+
+# Just the usual way to find out if we're
+# using cmd.exe to execute make rules.
+ifneq ($(shell echo),)
+ CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+ NULLDEV = nul:
+ DEL = -del /f
+ RMDIR = rmdir /s /q
+else
+ NULLDEV = /dev/null
+ DEL = $(RM)
+ RMDIR = $(RM) -r
+endif
+
+ifdef CC65_HOME
+ AS = $(CC65_HOME)/bin/ca65
+ CC = $(CC65_HOME)/bin/cc65
+ CL = $(CC65_HOME)/bin/cl65
+ LD = $(CC65_HOME)/bin/ld65
+else
+ AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
+ CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
+ CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+ LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
+endif
+
+EXELIST_kim1 = \
+ kimHello.bin \
+ kimSieve.bin
+
+ifneq ($(EXELIST_$(SYS)),)
+samples: $(EXELIST_$(SYS))
+else
+samples: notavailable
+endif
+
+# empty target used to skip systems that will not work with any program in this dir
+notavailable:
+ifeq ($(MAKELEVEL),0)
+ @echo "info: kim1 tests not available for" $(SYS)
+else
+# suppress the "nothing to be done for 'samples' message
+ @echo > $(NULLDEV)
+endif
+
+kimSieve.bin: kimSieve.c
+ $(CL) -t kim1 -C kim1-60k.cfg -O -o kimSieve.bin kimSieve.c
+
+kimHello.bin: kimHello.c
+ $(CL) -t kim1 -O -o kimHello.bin kimHello.c
+
+clean:
+ @$(DEL) kimSieve.bin 2>$(NULLDEV)
+ @$(DEL) kimHello.bin 2>$(NULLDEV)
+
diff --git a/samples/kim1/kimHello.c b/samples/kim1/kimHello.c
new file mode 100644
index 000000000..9e5ca8ab6
--- /dev/null
+++ b/samples/kim1/kimHello.c
@@ -0,0 +1,24 @@
+// --------------------------------------------------------------------------
+// Hello World for KIM-1
+//
+// Dave Plummer based on Sym-1 sample by Wayne Parham
+//
+// davepl@davepl.com
+// --------------------------------------------------------------------------
+
+#include
+#include
+
+int main (void)
+{
+ char str[100];
+ char c = 0x00;
+
+ printf ("\nHello World!\n\n");
+ printf ("Type a line and press ENTER, please.\n\n");
+
+ gets( str );
+
+ printf ("\n\nThanks: %s\n\n", str);
+ return 0;
+}
diff --git a/samples/kim1/kimKeyDisp.c b/samples/kim1/kimKeyDisp.c
new file mode 100644
index 000000000..63839d19e
--- /dev/null
+++ b/samples/kim1/kimKeyDisp.c
@@ -0,0 +1,52 @@
+/* Example illustrating scandisplay() and getkey() functions. */
+
+#include
+#include
+
+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;
+}
diff --git a/samples/kim1/kimSieve.c b/samples/kim1/kimSieve.c
new file mode 100644
index 000000000..d13f776ea
--- /dev/null
+++ b/samples/kim1/kimSieve.c
@@ -0,0 +1,125 @@
+#include
+#include
+
+typedef unsigned char byte;
+typedef unsigned short int ushort;
+typedef unsigned long int ulong;
+
+#define LIMIT 100000L
+
+// BITARRAY
+//
+// My bit-access macros pre-divide by two on the presumption that you'll never
+// try try access both odd and even bits!
+
+#define GETBIT(array, bit) (array[bit >> 4] & (1 << ((bit >> 1) & 7)))
+#define SETBIT(array, bit) (array[bit >> 4] |= (1 << ((bit >> 1) & 7)))
+#define CLRBIT(array, bit) (array[bit >> 4] &= ~(1 << ((bit >> 1) & 7)))
+
+// RepeatChar
+//
+// Outputs a given character N times
+
+void RepeatChar(char c, size_t count)
+{
+ while (count--)
+ putc(c, stdout);
+}
+
+// sqrti
+//
+// Binary search integer square root
+
+ushort sqrti(ulong num)
+{
+ long i;
+ ulong ret = 0;
+
+ for(i = 15; i >= 0; i--)
+ {
+ ulong temp = ret | (1L << (ulong)i);
+ if(temp * temp <= num)
+ {
+ ret = temp;
+ }
+ }
+ return ret;
+}
+
+// main()
+//
+// CC65 main function receives no parameters
+
+int main(void)
+{
+ // CC65 cannot mix code and data so we have to declare all variables here in the function prolog
+
+ ulong iNumber;
+ ushort currentFactor;
+ ulong numBytesAllocated, rootOfLimit;
+ byte *array;
+ ulong countOfPrimes;
+
+ rootOfLimit = sqrti(LIMIT);
+ puts("\r\n\r\n");
+ RepeatChar('*', 70);
+ puts("\r\n** Prime Number Sieve - Dave Plummer 2022 **");
+ RepeatChar('*', 70);
+
+ printf("\r\n\r\nCalculating primes to %ld using a sqrt of %ld...\r\n", LIMIT, rootOfLimit);
+
+ // Calculate how much memory should be allocated
+
+ numBytesAllocated = (LIMIT + 15) / 16;
+ array = malloc(numBytesAllocated);
+ if (!array)
+ {
+ printf("Unable to allocate %ld bytes for %ld bits\r\n", numBytesAllocated, LIMIT);
+ return 0;
+ }
+ else
+ {
+ printf("Allocated %ld bytes for %ld slots\r\n", numBytesAllocated, LIMIT);
+
+ // Preset all the bits to true
+
+ for (iNumber = 0; iNumber < numBytesAllocated; iNumber++)
+ array[iNumber] = 0xFF;
+ }
+
+ // Search for next unmarked factor
+
+ currentFactor = 3;
+ while (currentFactor <= rootOfLimit)
+ {
+ ulong num, n;
+
+ for (num = currentFactor; num <= LIMIT; num += 2)
+ {
+ if (GETBIT(array, num))
+ {
+ currentFactor = num;
+ break;
+ }
+ }
+
+ for (n = (ulong) currentFactor * currentFactor; n <= LIMIT; n += currentFactor * 2)
+ CLRBIT(array, n);
+
+ currentFactor += 2;
+ }
+
+ // Display results
+ //
+ // printf("The following primes were found at or below %ld:\r\n2, ", LIMIT);
+
+ countOfPrimes = 1;
+ for (iNumber = 3; iNumber <= LIMIT; iNumber += 2)
+ if (GETBIT(array, iNumber))
+ countOfPrimes++;
+
+ printf("[END: Count = %ld]\r\n", countOfPrimes);
+
+ free(array);
+ return 1;
+}
diff --git a/samples/terminal.c b/samples/terminal.c
new file mode 100644
index 000000000..51973f7a3
--- /dev/null
+++ b/samples/terminal.c
@@ -0,0 +1,76 @@
+/*
+** Minimalistic terminal program.
+**
+** Makes use of the serial drivers.
+**
+** 2022-12-23, Oliver Schmidt (ol.sc@web.de)
+**
+*/
+
+
+
+#include
+#include
+#include
+#include
+#include