1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-10 19:29:45 +00:00

Merge pull request #1 from cc65/master

sync
This commit is contained in:
silverdr 2016-02-26 23:42:50 +01:00
commit 2abd077dfd
314 changed files with 10910 additions and 2145 deletions

View File

@ -1,10 +1,12 @@
language:
- c
install:
- sudo apt-get update
- sudo apt-get install linuxdoc-tools linuxdoc-tools-info binutils-mingw-w64-i686 gcc-mingw-w64-i686 sshpass
script:
- make bin USER_CFLAGS=-Werror
- make lib QUIET=1
- make -C test
- make -C src clean
- make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
- make doc zip

41
LICENSE
View File

@ -1,44 +1,3 @@
This is the original cc65 compiler copyright:
-*- Mode: Text -*-
This is the copyright notice for RA65, LINK65, LIBR65, and other
Atari 8-bit programs. Said programs are Copyright 1989, by John R.
Dunning. All rights reserved, with the following exceptions:
Anyone may copy or redistribute these programs, provided that:
1: You don't charge anything for the copy. It is permissable to
charge a nominal fee for media, etc.
2: All source code and documentation for the programs is made
available as part of the distribution.
3: This copyright notice is preserved verbatim, and included in
the distribution.
You are allowed to modify these programs, and redistribute the
modified versions, provided that the modifications are clearly noted.
There is NO WARRANTY with this software, it comes as is, and is
distributed in the hope that it may be useful.
This copyright notice applies to any program which contains
this text, or the refers to this file.
This copyright notice is based on the one published by the Free
Software Foundation, sometimes known as the GNU project. The idea
is the same as theirs, ie the software is free, and is intended to
stay that way. Everybody has the right to copy, modify, and re-
distribute this software. Nobody has the right to prevent anyone
else from copying, modifying or redistributing it.
In acknowledgment of this copyright, I (Ullrich von Bassewitz) will place
my own changes to the compiler under the same copyright.
The library and the binary utils are a complete rewrite done by me and
covered by the following license:
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.

View File

@ -24,7 +24,7 @@ endif
SF_USER = oliverschmidt
SF_HOST = frs.sourceforge.net
SF_FILE = /home/frs/project/cc65/cc65-snapshot-win64.zip
SF_FILE = /home/frs/project/cc65/cc65-snapshot-win32.zip
SCPFLAGS = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q

View File

@ -1,8 +1,10 @@
[documentation](http://cc65.github.io/doc)
[Windows Snapshot](http://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip)
[wiki](http://github.com/cc65/wiki/wiki)
[Documentation](http://cc65.github.io/doc)
[![build status](http://travis-ci.org/cc65/cc65.png)](http://travis-ci.org/cc65/cc65/builds)
[Wiki](http://github.com/cc65/wiki/wiki)
[![Build Status](https://api.travis-ci.org/cc65/cc65.svg?branch=master)](https://travis-ci.org/cc65/cc65/builds)
cc65 is a complete cross development package for 65(C)02 systems, including
a powerful macro assembler, a C compiler, linker, librarian and several
@ -19,14 +21,16 @@ including
- CBM 510 (aka P500)
- the 600/700 family
- newer PET machines (not 2001).
- the Apple ][+ and successors.
- the Apple ]\[+ and successors.
- the Atari 8 bit machines.
- the Atari 5200 console.
- GEOS for the C64, C128 and Apple //e.
- the NEC PC-Engine (aka TurboGrafx-16).
- the Nintendo Entertainment System (NES) console.
- the Supervision console.
- the Watara Supervision console.
- the Oric Atmos.
- the Lynx console.
- the Ohio Scientific Challenger 1P.
The libraries are fairly portable, so creating a version for other 6502s
shouldn't be too much work.

View File

@ -6,6 +6,8 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $7A ; Pointer into BASIC source code
TIME := $A0 ; 60 HZ clock
FNAM_LEN := $B7 ; Length of filename
@ -22,6 +24,7 @@ SCREEN_PTR := $D1 ; Pointer to current char in text screen
CURS_X := $D3 ; Cursor column
CURS_Y := $D6 ; Cursor row
CRAM_PTR := $F3 ; Pointer to current char in color RAM
FREKZP := $FB ; Five unused bytes
BASIC_BUF := $200 ; Location of command-line
BASIC_BUF_LEN = 89 ; Maximum length of command-line
@ -210,4 +213,3 @@ CASSMOT = $20 ; Cassette motor on
TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF

92
asminc/pce.inc Normal file
View File

@ -0,0 +1,92 @@
;
; PCE definitions. By Groepaz/Hitmem.
;
; FIXME: screen dimensions my change according to selected video mode
screenrows = (224/8)
charsperline = 61
CH_HLINE = 1
CH_VLINE = 2
; huc6270 - Video Display Controller (VDC)
VDC_MAWR = 0 ; Memory Address Write Register
VDC_MARR = 1 ; Memory Address Read Register
VDC_VWR = 2 ; VRAM Write Register (write only)
VDC_VRR = 2 ; VRAM Read Register (read only)
VDC_UNK03 = 3 ; (unknown)
VDC_UNK04 = 4 ; (unknown)
VDC_CR = 5 ; Control Register
VDC_RCR = 6 ; Raster Counter Register
VDC_BXR = 7 ; Background X-Scroll Register
VDC_BYR = 8 ; Background Y-Scroll Register
VDC_MWR = 9 ; Memory-access Width Register
VDC_HSR = 10 ; Horizontal Sync Register
VDC_HDR = 11 ; Horizontal Display Register
VDC_VPR = 12 ; Vertical synchronous register
VDC_VDW = 13 ; Vertical display register
VDC_VCR = 14 ; Vertical display END position register
VDC_DCR = 15 ; (DMA) Control Register
VDC_SOUR = 16 ; (DMA) Source Register
VDC_DESR = 17 ; (DMA) Destination Register
VDC_LENR = 18 ; (DMA) Length Register
VDC_SATB = 19 ; Sprite Attribute Table
; VDC port
; Note: absolute addressing mode must be used when writing to this port
VDC_CTRL = $0000
VDC_DATA_LO = $0002
VDC_DATA_HI = $0003
; huc6260 - Video Color Encoder (vce)
; The DAC has a palette of 512 colours.
; bitmap of the palette data is this: 0000000gggrrrbbb.
; You can read and write the DAC-registers.
VCE = $0400 ; base
VCE_CTRL = $0400 ; write$00 to reset
VCE_ADDR_LO = $0402 ; LSB of byte offset into palette
VCE_ADDR_HI = $0403 ; MSB of byte offset into palette
VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
; programmable sound generator (PSG)
PSG = $0800 ; base
PSG_CHAN_SELECT = $0800
PSG_GLOBAL_PAN = $0801
PSG_FREQ_LO = $0802
PSG_FREQ_HI = $0803
PSG_CHAN_CTRL = $0804
PSG_CHAN_PAN = $0805
PSG_CHAN_DATA = $0806
PSG_NOISE = $0807
PSG_LFO_FREQ = $0808
PSG_LFO_CTRL = $0809
; timer
TIMER = $0c00 ; base
TIMER_COUNT = $0c00
TIMER_CTRL = $0c01
JOY_CTRL = $1000
IRQ_MASK = $1402
IRQ_STATUS = $1403
CDR_MEM_DISABLE = $1803
CDR_MEM_ENABLE = $1807
; Write VDC register
.macro VREG arg1,arg2
st0 #arg1
st1 #<(arg2)
st2 #>(arg2)
.endmacro

View File

@ -6,6 +6,7 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2A ; Pointer to start of BASIC variables
MEMSIZE := $34 ; Size of memory installed
TXTPTR := $77 ; Pointer into BASIC source code
TIME := $8D ; 60HZ clock

View File

@ -7,6 +7,8 @@
; Zero page, Commodore stuff
TMPPTR := $22 ; Temporary ptr used by BASIC
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $3B ; Pointer into BASIC source code
TIME := $A3 ; 60HZ clock
FNAM_LEN := $AB ; Length of filename

View File

@ -6,6 +6,8 @@
; ---------------------------------------------------------------------------
; Zero page, Commodore stuff
VARTAB := $2D ; Pointer to start of BASIC variables
MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
TXTPTR := $7A ; Pointer into BASIC source code
TIME := $A0 ; 60HZ clock
FNAM_LEN := $B7 ; Length of filename

View File

@ -18,7 +18,7 @@ SYMBOLS {
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -45,7 +45,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -5,7 +5,7 @@ SYMBOLS {
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -21,7 +21,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -10,7 +10,7 @@ SYMBOLS {
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -28,7 +28,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -18,7 +18,7 @@ SYMBOLS {
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -45,7 +45,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -5,7 +5,7 @@ SYMBOLS {
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -21,7 +21,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -10,7 +10,7 @@ SYMBOLS {
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__LOADADDR__: type = weak, value = __STARTUP_RUN__;
__LOADSIZE__: type = weak, value = __ZPSAVE_RUN__ - __STARTUP_RUN__ +
__LOADSIZE__: type = weak, value = __INITBSS_RUN__ - __STARTUP_RUN__ +
__MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
@ -28,7 +28,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
INITBSS: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes;
INIT: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
LC: load = MOVE, run = LC, type = ro, optional = yes;

View File

@ -22,6 +22,7 @@ SEGMENTS {
CODE: load = ROM, type = ro, define = yes;
RODATA: load = ROM, type = ro, optional = yes;
DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes, optional = yes;
CARTHDR: load = CARTID, type = ro;
ZEROPAGE: load = ZP, type = zp, optional = yes;

View File

@ -19,6 +19,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro, optional = yes;
DATA: load = RAM, type = rw, optional = yes;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes, optional = yes;
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -49,6 +49,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -37,6 +37,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -70,6 +70,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -82,6 +82,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -68,6 +68,7 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss, optional = yes;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes;

View File

@ -1,22 +1,31 @@
SYMBOLS {
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__TAPEHDR__: type = import;
__BASHDR__: type = import;
__PROGFLAG__: type = weak, value = $00; # $00=BASIC, $80=machine code
__AUTORUN__: type = weak, value = $00; # $00=only load, $C7=run
__STACKSIZE__: type = weak, value = $0800; # 2K stack
__GRAB__: type = weak, value = 0; # 0=don't grab graphics RAM, 1=grab graphics RAM
__RAMEND__: type = weak, value = $9800 + $1C00 * __GRAB__;
}
MEMORY {
ZP: file = "", define = yes, start = $00E2, size = $001A;
TAPEHDR: file = %O, type = ro, start = $0000, size = $0011;
RAM: file = %O, define = yes, start = $0500, size = $9300 - __STACKSIZE__;
TAPEHDR: file = %O, type = ro, start = $0000, size = $001F;
BASHEAD: file = %O, define = yes, start = $0501, size = $000D;
RAM: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __RAM_START__ - __STACKSIZE__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
TAPEHDR: load = TAPEHDR, type = ro;
BASHDR: load = BASHEAD, type = ro, define = yes, optional = yes;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
INIT: load = RAM, type = ro, define = yes, optional = yes;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
ZPSAVE1: load = RAM, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together
ZPSAVE2: load = RAM, type = bss; # see "libsrc/atmos/crt0.s"
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}
FEATURES {
CONDES: type = constructor,

View File

@ -38,7 +38,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
OVL1ADDR: load = OVL1ADDR, type = ro;

View File

@ -18,7 +18,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -18,7 +18,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -1,64 +1,71 @@
FEATURES {
STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
__EXEHDR__: type = import;
__OVERLAYADDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
__LOADADDR__: type = import;
__EXEHDR__: type = import;
__OVERLAYADDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
__HIMEM__: type = weak, value = $D000;
__OVERLAYSTART__: type = export, value = __HIMEM__ - __OVERLAYSIZE__;
}
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $07FF, size = $0002;
HEADER: file = %O, start = $0801, size = $000C;
RAM: file = %O, define = yes, start = $080D, size = $C7F3 - __OVERLAYSIZE__ - __STACKSIZE__;
OVL1ADDR: file = "%O.1", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL1: file = "%O.1", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL2ADDR: file = "%O.2", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL2: file = "%O.2", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL3ADDR: file = "%O.3", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL3: file = "%O.3", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL4ADDR: file = "%O.4", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL4: file = "%O.4", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL5ADDR: file = "%O.5", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL5: file = "%O.5", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL6ADDR: file = "%O.6", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL6: file = "%O.6", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL7ADDR: file = "%O.7", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL7: file = "%O.7", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL8ADDR: file = "%O.8", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL8: file = "%O.8", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
OVL9ADDR: file = "%O.9", start = $CFFE - __OVERLAYSIZE__, size = $0002;
OVL9: file = "%O.9", start = $D000 - __OVERLAYSIZE__, size = __OVERLAYSIZE__;
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __OVERLAYSTART__ - __STACKSIZE__ - __HEADER_LAST__;
MOVE: file = %O, start = __INITBSS_LOAD__, size = __HIMEM__ - __BSS_RUN__;
INIT: file = "", start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__;
OVL1ADDR: file = "%O.1", start = __OVERLAYSTART__ - 2, size = $0002;
OVL1: file = "%O.1", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL2ADDR: file = "%O.2", start = __OVERLAYSTART__ - 2, size = $0002;
OVL2: file = "%O.2", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL3ADDR: file = "%O.3", start = __OVERLAYSTART__ - 2, size = $0002;
OVL3: file = "%O.3", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL4ADDR: file = "%O.4", start = __OVERLAYSTART__ - 2, size = $0002;
OVL4: file = "%O.4", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL5ADDR: file = "%O.5", start = __OVERLAYSTART__ - 2, size = $0002;
OVL5: file = "%O.5", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL6ADDR: file = "%O.6", start = __OVERLAYSTART__ - 2, size = $0002;
OVL6: file = "%O.6", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL7ADDR: file = "%O.7", start = __OVERLAYSTART__ - 2, size = $0002;
OVL7: file = "%O.7", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL8ADDR: file = "%O.8", start = __OVERLAYSTART__ - 2, size = $0002;
OVL8: file = "%O.8", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL9ADDR: file = "%O.9", start = __OVERLAYSTART__ - 2, size = $0002;
OVL9: file = "%O.9", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
}
SEGMENTS {
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = HEADER, type = ro;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
OVL1ADDR: load = OVL1ADDR, type = ro;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
OVL2ADDR: load = OVL2ADDR, type = ro;
OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
OVL3ADDR: load = OVL3ADDR, type = ro;
OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
OVL4ADDR: load = OVL4ADDR, type = ro;
OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
OVL5ADDR: load = OVL5ADDR, type = ro;
OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
OVL6ADDR: load = OVL6ADDR, type = ro;
OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
OVL7ADDR: load = OVL7ADDR, type = ro;
OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
OVL8ADDR: load = OVL8ADDR, type = ro;
OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
OVL9ADDR: load = OVL9ADDR, type = ro;
OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
ZEROPAGE: load = ZP, type = zp;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = HEADER, type = ro;
STARTUP: load = MAIN, type = ro;
LOWCODE: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INITBSS: load = MAIN, type = bss, define = yes;
BSS: load = MAIN, type = bss, define = yes;
INIT: load = MOVE, run = INIT, type = ro, define = yes;
OVL1ADDR: load = OVL1ADDR, type = ro;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
OVL2ADDR: load = OVL2ADDR, type = ro;
OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
OVL3ADDR: load = OVL3ADDR, type = ro;
OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
OVL4ADDR: load = OVL4ADDR, type = ro;
OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
OVL5ADDR: load = OVL5ADDR, type = ro;
OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
OVL6ADDR: load = OVL6ADDR, type = ro;
OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
OVL7ADDR: load = OVL7ADDR, type = ro;
OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
OVL8ADDR: load = OVL8ADDR, type = ro;
OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
OVL9ADDR: load = OVL9ADDR, type = ro;
OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
}
FEATURES {
CONDES: type = constructor,

View File

@ -1,26 +1,32 @@
FEATURES {
STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
__EXEHDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $D000;
}
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $07FF, size = $0002;
HEADER: file = %O, start = $0801, size = $000C;
RAM: file = %O, define = yes, start = $080D, size = $C7F3 - __STACKSIZE__;
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__;
MOVE: file = %O, start = __INITBSS_LOAD__, size = __HIMEM__ - __BSS_RUN__;
INIT: file = "", start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__;
}
SEGMENTS {
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = HEADER, type = ro;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
ZEROPAGE: load = ZP, type = zp;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = HEADER, type = ro;
STARTUP: load = MAIN, type = ro;
LOWCODE: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INITBSS: load = MAIN, type = bss, define = yes;
BSS: load = MAIN, type = bss, define = yes;
INIT: load = MOVE, run = INIT, type = ro, define = yes;
}
FEATURES {
CONDES: type = constructor,

View File

@ -22,6 +22,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = rw, define = yes;

View File

@ -19,6 +19,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = rw, define = yes;

25
cfg/osic1p-asm.cfg Normal file
View File

@ -0,0 +1,25 @@
FEATURES {
STARTADDRESS: default = $0200;
}
SYMBOLS {
# If you want ld65 to output a loadable-format file by default, then uncomment
# the next line. (Then, "-u __BOOT__" wouldn't be needed on the command line.)
# __BOOT__: type = import;
__STACKSIZE__: type = weak, value = $0400; # 1 kB stack
__HIMEM__: type = weak, value = $8000; # 32 kB RAM
}
MEMORY {
# for size of ZP, see runtime/zeropage.s and c1p/extzp.s
ZP: file = "", define = yes, start = $0002, size = $001A + $0006;
HEAD: file = %O, start = $0000, size = $00B6;
RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S;
}
SEGMENTS {
BOOT: load = HEAD, type = ro, optional = yes;
INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = rw;
RODATA: load = RAM, type = rw;
DATA: load = RAM, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

38
cfg/osic1p.cfg Normal file
View File

@ -0,0 +1,38 @@
FEATURES {
STARTADDRESS: default = $0200;
}
SYMBOLS {
# If you want ld65 to output a loadable-format file by default, then uncomment
# the next line. (Then, "-u __BOOT__" wouldn't be needed on the command line.)
# __BOOT__: type = import;
__STACKSIZE__: type = weak, value = $0400; # 1 kB stack
__HIMEM__: type = weak, value = $8000; # 32 kB RAM
}
MEMORY {
# for size of ZP, see runtime/zeropage.s and c1p/extzp.s
ZP: file = "", define = yes, start = $0002, size = $001A + $0020;
HEAD: file = %O, start = $0000, size = $00B6;
RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S;
}
SEGMENTS {
BOOT: load = HEAD, type = ro, optional = yes;
STARTUP: load = RAM, type = ro;
LOWCODE: load = RAM, type = ro, optional = yes;
INIT: load = RAM, type = ro, define = yes, optional = yes;
CODE: load = RAM, type = rw;
RODATA: load = RAM, type = rw;
DATA: load = RAM, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, define = yes, optional = yes;
}
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__,
segment = INIT;
CONDES: type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__,
segment = RODATA;
}

46
cfg/pce.cfg Normal file
View File

@ -0,0 +1,46 @@
# linker config to produce simple NEC PC-Engine cartridge (.pce)
SYMBOLS {
__STACKSIZE__: type = weak, value = $0300; # 3 pages stack
}
MEMORY {
# FIXME: is this correct? the first 3? bytes cant be used?
ZP: start = $03, size = $fd, type = rw, define = yes;
# reset-bank and hardware vectors
ROM0: start = $e000, size = $1ff6, file = %O ,fill = yes, define = yes;
ROMV: start = $fff6, size = $a, file = %O,fill = yes;
# first RAM page (also contains stack and zeropage)
RAM: start = $2200, size = $1e00, define = yes;
}
SEGMENTS {
STARTUP: load = ROM0, type = ro, define = yes;
INIT: load = ROM0, type = ro, define = yes, optional = yes;
CODE: load = ROM0, type = ro, define = yes;
RODATA: load = ROM0, type = ro, define = yes;
DATA: load = ROM0, run= RAM, type = rw, define = yes;
BSS: load = RAM, type = bss, define = yes;
VECTORS: load = ROMV, type = rw, define = yes;
ZEROPAGE: load = ZP, type = zp, define = yes;
EXTZP: load = ZP, type = zp, define = yes, optional = yes;
APPZP: load = ZP, type = zp, define = yes, optional = yes;
}
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__,
segment = INIT;
CONDES: type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__,
segment = RODATA;
CONDES: type = interruptor,
label = __INTERRUPTOR_TABLE__,
count = __INTERRUPTOR_COUNT__,
segment = RODATA,
import = __CALLIRQ__;
}

View File

@ -18,7 +18,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -18,7 +18,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -20,7 +20,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -18,7 +18,7 @@ SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss;
INITBSS: load = RAM, type = bss;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -2,7 +2,7 @@ ifneq ($(shell echo),)
CMD_EXE = 1
endif
.PHONY: all mostlyclean clean install zip doc html info gh-pages
.PHONY: all mostlyclean clean install zip doc html info
.SUFFIXES:

View File

@ -7,7 +7,7 @@
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2014-03-27
<date>2015-01-09
<abstract>
An overview over the Atmos runtime system as it is implemented for the cc65 C
@ -32,27 +32,39 @@ more than one platform. Please see the function reference for more
information.
<sect>Binary format<p>
The standard binary output format generated by the linker for the Atmos target
is a machine language program with a 17 byte tape header including a cc65 tag.
The standard load and autostart address is &dollar;500.
is a machine language program with a one-line BASIC stub that jumps to the
machine-language part through <tt/CALL/. It has one sacrificial byte attached
to the end (a bug in the Oric ROM means that BASIC can put a variable on top
of the last byte that was loaded). It has a 24-byte tape header. A file can
be CLOADed as a BASIC program, and started by typing <tt/RUN/. The standard
load address is &dollar;501.
<sect>Memory layout<p>
In the standard setup, cc65 generated programs use the memory from
&dollar;500 to &dollar;9800, so nearly 37K of memory (including the stack) is
In the standard setup, cc65-generated programs use the memory from
&dollar;0501 to &dollar;9800; so, nearly 37K of memory (including the stack) is
available. ROM calls are possible without further precautions.
If your program needs more memory, and it won't use TGI graphics, then you can
use the ld65 command-line option, <tt/-D __GRAB__=1/, when building the
program, to include the graphics screen RAM. Then, nearly 44K of memory
(&dollar;0501 to &dollar;B400) is available.
Special locations:
<descrip>
<tag/Stack/
The C runtime stack is located at &dollar;97FF and growing downwards.
The C runtime stack is located at &dollar;97FF (or &dollar;B3FF), and grows
downwards.
<tag/Heap/
The C heap is located at the end of the program and grows towards the C
The C heap is located at the end of the program, and grows towards the C
runtime stack.
</descrip><p>
@ -90,7 +102,7 @@ structures; accessing the struct fields will access the chip registers.
<descrip>
<tag><tt/VIA/</tag>
Access to the VIA (versatile interface adapter) chip is available via the
Access to the VIA (Versatile Interface Adapter) chip is available via the
<tt/VIA/ variable. The structure behind this variable is explained in <tt/_6522.h/.
</descrip><p>
@ -117,7 +129,8 @@ The names in the parentheses denote the symbols to be used for static linking of
<sect1>Graphics drivers<p>
The default drivers, <tt/tgi_stddrv (tgi_static_stddrv)/, point to <tt/atmos-240-200-2.tgi (atmos_240_200_2_tgi)/.
The default drivers, <tt/tgi_stddrv (tgi_static_stddrv)/,
point to <tt/atmos-240-200-2.tgi (atmos_240_200_2_tgi)/.
<descrip>
@ -175,13 +188,14 @@ No mouse drivers are currently available for the Atmos.
<sect1>Disk I/O<p>
The existing library for the Atmos doesn't implement C file
I/O. There are hacks for the <tt/read()/ and <tt/write()/ routines in
place, which will make functions work that read from and write to <tt/stdout/
(like <tt/printf()/). However, those functions have some shortcomings which
won't be fixed, because they're going to be replaced anyway.
The existing library for the Atmos doesn't implement C file I/O. There are
hacks for the <tt/read()/ and <tt/write()/ routines in place, which will make
functions work that read from <tt/stdin/ and write to <tt/stdout/ and
<tt/stderr/ (such as <tt/printf()/). However, those functions have some
shortcomings which won't be fixed, because they're going to be replaced
anyway.
To be more concrete, the limitation means that you cannot use any of the
To be more concrete, that limitation means that you cannot use any of the
following functions (and a few others):
<itemize>
@ -202,7 +216,14 @@ following functions (and a few others):
<sect1>Function keys<p>
These are defined to be FUNCT + number key.
They are defined to be FUNCT + a number key.
<sect1>Capitals lock<p>
The keyboard's "CAPS Lock" mode is turned off while the program is running.
The previous mode (usually, CAPS Lock turned on [because Oric BASIC keywords
must be UPPER-case]) is restored when the program stops.
<sect1>Passing arguments to the program<p>
@ -211,10 +232,12 @@ Command-line arguments can be passed to <tt/main()/. Since that is not
supported directly by BASIC, the following syntax was chosen:
<tscreen><verb>
CALL#500:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
RUN:REM arg1 " ARG2 IS QUOTED" ARG3 "" ARG5
</verb></tscreen>
<enum>
<item>You must turn <tt/CAPS/ lock off (tap CTRL-T) when you want to type
lower-case arguments (but, <tt/RUN/ and <tt/REM/ must be UPPER-case).
<item>Arguments are separated by spaces.
<item>Arguments may be quoted.
<item>Leading and trailing spaces around an argument are ignored. Spaces within
@ -225,6 +248,15 @@ supported directly by BASIC, the following syntax was chosen:
</enum>
<sect1>Automatic starting<p>
Usually, a cc65-built program just will sit quietly in memory, after it is
CLOADed. It waits for you to start it (by typing BASIC's <tt/RUN/ command).
But, if you want to create a program that will start running immediately after
it is loaded, then you can use the linker command-line option
<tt/-D __AUTORUN__=$C7/.
<sect1>Interrupts<p>
The runtime for the Atmos uses routines marked as <tt/.INTERRUPTOR/ for

View File

@ -116,6 +116,39 @@ cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg source.s
Please note that in this case a changed start address doesn't make sense,
since the program must be loaded to the BASIC start address.
<sect>Extras<p>
<sect1>80 Columns conio driver<p>
The C64 package comes with an alternative software driven 80 columns
module <tt/c64-soft80.o/ which uses the memory under I/O between &dollar;d000
and &dollar;ffff.
In memory constrained situations the memory from &dollar;400 to &dollar;7FF
can be made available to a program by calling <tt/_heapadd ((void *) 0x0400, 0x0400);/
at the beginning of <tt/main()/. Doing so is beneficial even if the program
doesn't use the the heap explicitly because loading a driver uses the heap implicitly.
Using <tt/c64-soft80.o/ is as simple as placing it on the linker command
line like this:
<tscreen><verb>
cl65 -t c64 myprog.c c64-soft80.o
</verb></tscreen>
Note that the soft80 conio driver is incompatible with the
<tt/c64-ram.emd (c64_ram_emd)/ extended memory driver and the
<tt/c64-hi.tgi (c64_hi_tgi)/ graphics driver.
<sect2>80 Columns conio driver (monochrome)<p>
In an (even more) memory constrained situation, a size optimized version of the
software driven 80 columns module may be used, which only supports one common
text color for the whole screen.
<tscreen><verb>
cl65 -t c64 myprog.c c64-soft80mono.o
</verb></tscreen>
<sect>Platform-specific header files<p>
@ -216,6 +249,9 @@ configuration.
palette of the 16 C64 colors).
</descrip><p>
Note that the graphics drivers are incompatible with the
<tt/c64-ram.emd (c64_ram_emd)/ extended memory driver and the
<tt/c64-soft80.o/ software 80 columns conio driver.
<sect1>Extended memory drivers<p>
@ -241,7 +277,7 @@ configuration.
<tag><tt/c64-ram.emd (c64_ram_emd)/</tag>
A driver for the hidden RAM below the I/O area and kernal ROM. Supports 48
256 byte pages. Please note that this driver is incompatible with any of the
graphics drivers!
graphics drivers, or the soft80 conio driver!
<tag><tt/c64-ramcart.emd (c64_ramcart_emd)/</tag>
A driver for the RamCart 64/128 written and contributed by Maciej Witkowiak.

View File

@ -2,11 +2,12 @@
<article>
<title>ca65 Users Guide
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
<date>2014-04-24
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2015-11-17
<abstract>
ca65 is a powerful macro assembler for the 6502, 65C02 and 65816 CPUs. It is
ca65 is a powerful macro assembler for the 6502, 65C02, and 65816 CPUs. It is
used as a companion assembler for the cc65 crosscompiler, but it may also be
used as a standalone product.
</abstract>
@ -430,24 +431,21 @@ The assembler accepts
<sect1>65816 mode<p>
In 65816 mode several aliases are accepted in addition to the official
In 65816 mode, several aliases are accepted, in addition to the official
mnemonics:
<tscreen><verb>
BGE is an alias for BCS
BLT is an alias for BCC
CPA is an alias for CMP
DEA is an alias for DEC A
INA is an alias for INC A
SWA is an alias for XBA
TAD is an alias for TCD
TAS is an alias for TCS
TDA is an alias for TDC
TSA is an alias for TSC
CPA is an alias for CMP
DEA is an alias for DEC A
INA is an alias for INC A
SWA is an alias for XBA
TAD is an alias for TCD
TAS is an alias for TCS
TDA is an alias for TDC
TSA is an alias for TSC
</verb></tscreen>
<sect1>6502X mode<label id="6502X-mode"><p>
6502X mode is an extension to the normal 6502 mode. In this mode, several
@ -1194,6 +1192,35 @@ writable.
assignments to <tt/*/, use <tt/<ref id=".ORG" name=".ORG">/ instead.
<sect1><tt>.ASIZE</tt><label id=".ASIZE"><p>
Reading this pseudo variable will return the current size of the
Accumulator in bits.
For the 65816 instruction set .ASIZE will return either 8 or 16, depending
on the current size of the operand in immediate accu addressing mode.
For all other CPU instruction sets, .ASIZE will always return 8.
Example:
<tscreen><verb>
; Reverse Subtract with Accumulator
; A = memory - A
.macro rsb param
.if .asize = 8
eor #$ff
.else
eor #$ffff
.endif
sec
adc param
.endmacro
</verb></tscreen>
See also: <tt><ref id=".ISIZE" name=".ISIZE"></tt>
<sect1><tt>.CPU</tt><label id=".CPU"><p>
Reading this pseudo variable will give a constant integer value that
@ -1221,6 +1248,19 @@ writable.
</verb></tscreen>
<sect1><tt>.ISIZE</tt><label id=".ISIZE"><p>
Reading this pseudo variable will return the current size of the Index
register in bits.
For the 65816 instruction set .ISIZE will return either 8 or 16, depending
on the current size of the operand in immediate index addressing mode.
For all other CPU instruction sets, .ISIZE will always return 8.
See also: <tt><ref id=".ASIZE" name=".ASIZE"></tt>
<sect1><tt>.PARAMCOUNT</tt><label id=".PARAMCOUNT"><p>
This builtin pseudo variable is only available in macros. It is replaced by
@ -1279,6 +1319,35 @@ Pseudo functions expect their arguments in parenthesis, and they have a result,
either a string or an expression.
<sect1><tt>.ADDRSIZE</tt><label id=".ADDRSIZE"><p>
The <tt/.ADDRSIZE/ function is used to return the interal address size
associated with a symbol. This can be helpful in macros when knowing the address
size of symbol can help with custom instructions.
Example:
<tscreen><verb>
.macro myLDA foo
.if .ADDRSIZE(foo) = 1
;do custom command based on zeropage addressing:
.byte 0A5h, foo
.elseif .ADDRSIZE(foo) = 2
;do custom command based on absolute addressing:
.byte 0ADh
.word foo
.elseif .ADDRSIZE(foo) = 0
; no address size defined for this symbol:
.out .sprintf("Error, address size unknown for symbol %s", .string(foo))
.endif
.endmacro
</verb></tscreen>
This command is new and must be enabled with the <tt/.FEATURE addrsize/ command.
See: <tt><ref id=".FEATURE" name=".FEATURE"></tt>
<sect1><tt>.BANK</tt><label id=".BANK"><p>
The <tt/.BANK/ function is used to support systems with banked memory. The
@ -2287,6 +2356,28 @@ Here's a list of all control commands and a description, what they do:
</verb></tscreen>
<sect1><tt>.DEFINEDMACRO</tt><label id=".DEFINEDMACRO"><p>
Builtin function. The function expects an identifier as argument in braces.
The argument is evaluated, and the function yields "true" if the identifier
has already been defined as the name of a macro. Otherwise the function yields
false. Example:
<tscreen><verb>
.macro add foo
clc
adc foo
.endmacro
.if .definedmacro(add)
add #$01
.else
clc
adc #$01
.endif
</verb></tscreen>
<sect1><tt>.DESTRUCTOR</tt><label id=".DESTRUCTOR"><p>
Export a symbol and mark it as a module destructor. This may be used
@ -2596,6 +2687,12 @@ Here's a list of all control commands and a description, what they do:
<descrip>
<tag><tt>addrsize</tt><label id="addrsize"></tag>
Enables the .ADDRSIZE pseudo function. This function is experimental and not enabled by default.
See also: <tt><ref id=".ADDRSIZE" name=".ADDRSIZE"></tt>
<tag><tt>at_in_identifiers</tt><label id="at_in_identifiers"></tag>
Accept the at character (`@') as a valid character in identifiers. The
@ -3105,6 +3202,23 @@ Here's a list of all control commands and a description, what they do:
the feature in more detail.
<sect1><tt>.ISMNEM, .ISMNEMONIC</tt><label id=".ISMNEMONIC"><p>
Builtin function. The function expects an identifier as argument in braces.
The argument is evaluated, and the function yields "true" if the identifier
is defined as an instruction mnemonic that is recognized by the assembler.
Example:
<tscreen><verb>
.if .not .ismnemonic(ina)
.macro ina
clc
adc #$01
.endmacro
.endif
</verb></tscreen>
<sect1><tt>.LINECONT</tt><label id=".LINECONT"><p>
Switch on or off line continuations using the backslash character
@ -3256,8 +3370,8 @@ Here's a list of all control commands and a description, what they do:
atari Defines the scrcode macro.
cbm Defines the scrcode macro.
cpu Defines constants for the .CPU variable.
generic Defines generic macros like add and sub.
longbranch Defines conditional long jump macros.
generic Defines generic macroes like add, sub, and blt.
longbranch Defines conditional long-jump macroes.
</verb></tscreen>
Including a macro package twice, or including a macro package that
@ -3596,7 +3710,7 @@ Here's a list of all control commands and a description, what they do:
segment, that is, a named section of data. The default segment is
"CODE". There may be up to 254 different segments per object file
(and up to 65534 per executable). There are shortcut commands for
the most common segments ("CODE", "DATA" and "BSS").
the most common segments ("ZEROPAGE", "CODE", "RODATA", "DATA", and "BSS").
The command is followed by a string containing the segment name (there are
some constraints for the name - as a rule of thumb use only those segment
@ -3630,8 +3744,9 @@ Here's a list of all control commands and a description, what they do:
</verb></tscreen>
See: <tt><ref id=".BSS" name=".BSS"></tt>, <tt><ref id=".CODE"
name=".CODE"></tt>, <tt><ref id=".DATA" name=".DATA"></tt> and <tt><ref
id=".RODATA" name=".RODATA"></tt>
name=".CODE"></tt>, <tt><ref id=".DATA" name=".DATA"></tt>, <tt><ref
id=".RODATA" name=".RODATA"></tt>, and <tt><ref id=".ZEROPAGE"
name=".ZEROPAGE"></tt>
<sect1><tt>.SET</tt><label id=".SET"><p>
@ -3792,7 +3907,7 @@ Here's a list of all control commands and a description, what they do:
shortcut for
<tscreen><verb>
.segment "ZEROPAGE", zeropage
.segment "ZEROPAGE": zeropage
</verb></tscreen>
Because of the "zeropage" attribute, labels declared in this segment are
@ -3821,10 +3936,10 @@ In its simplest form, a macro does not have parameters. Here's an
example:
<tscreen><verb>
.macro asr ; Arithmetic shift right
cmp #$80 ; Put bit 7 into carry
ror ; Rotate right with carry
.endmacro
.macro asr ; Arithmetic shift right
cmp #$80 ; Put bit 7 into carry
ror ; Rotate right with carry
.endmacro
</verb></tscreen>
The macro above consists of two real instructions, that are inserted into
@ -3832,9 +3947,9 @@ the code, whenever the macro is expanded. Macro expansion is simply done
by using the name, like this:
<tscreen><verb>
lda $2010
asr
sta $2010
lda $2010
asr
sta $2010
</verb></tscreen>
@ -3843,15 +3958,15 @@ by using the name, like this:
When using macro parameters, macros can be even more useful:
<tscreen><verb>
.macro inc16 addr
clc
lda addr
adc #$01
sta addr
lda addr+1
adc #$00
sta addr+1
.endmacro
.macro inc16 addr
clc
lda addr
adc #<$0001
sta addr
lda addr+1
adc #>$0001
sta addr+1
.endmacro
</verb></tscreen>
When calling the macro, you may give a parameter, and each occurrence of
@ -3859,19 +3974,19 @@ the name "addr" in the macro definition will be replaced by the given
parameter. So
<tscreen><verb>
inc16 $1000
inc16 $1000
</verb></tscreen>
will be expanded to
<tscreen><verb>
clc
lda $1000
adc #$01
sta $1000
lda $1000+1
adc #$00
sta $1000+1
clc
lda $1000
adc #<$0001
sta $1000
lda $1000+1
adc #>$0001
sta $1000+1
</verb></tscreen>
A macro may have more than one parameter, in this case, the parameters
@ -3892,40 +4007,40 @@ opposite.
Look at this example:
<tscreen><verb>
.macro ldaxy a, x, y
.ifnblank a
lda #a
.endif
.ifnblank x
ldx #x
.endif
.ifnblank y
ldy #y
.endif
.endmacro
.macro ldaxy a, x, y
.ifnblank a
lda #a
.endif
.ifnblank x
ldx #x
.endif
.ifnblank y
ldy #y
.endif
.endmacro
</verb></tscreen>
This macro may be called as follows:
That macro may be called as follows:
<tscreen><verb>
ldaxy 1, 2, 3 ; Load all three registers
ldaxy 1, 2, 3 ; Load all three registers
ldaxy 1, , 3 ; Load only a and y
ldaxy 1, , 3 ; Load only a and y
ldaxy , , 3 ; Load y only
ldaxy , , 3 ; Load y only
</verb></tscreen>
There's another helper command for determining, which macro parameters are
valid: <tt><ref id=".PARAMCOUNT" name=".PARAMCOUNT"></tt> This command is
replaced by the parameter count given, <em/including/ intermediate empty macro
There's another helper command for determining which macro parameters are
valid: <tt><ref id=".PARAMCOUNT" name=".PARAMCOUNT"></tt>. That command is
replaced by the parameter count given, <em/including/ explicitly empty
parameters:
<tscreen><verb>
ldaxy 1 ; .PARAMCOUNT = 1
ldaxy 1,,3 ; .PARAMCOUNT = 3
ldaxy 1,2 ; .PARAMCOUNT = 2
ldaxy 1, ; .PARAMCOUNT = 2
ldaxy 1,2,3 ; .PARAMCOUNT = 3
ldaxy 1 ; .PARAMCOUNT = 1
ldaxy 1,,3 ; .PARAMCOUNT = 3
ldaxy 1,2 ; .PARAMCOUNT = 2
ldaxy 1, ; .PARAMCOUNT = 2
ldaxy 1,2,3 ; .PARAMCOUNT = 3
</verb></tscreen>
Macro parameters may optionally be enclosed into curly braces. This allows the
@ -3933,19 +4048,19 @@ inclusion of tokens that would otherwise terminate the parameter (the comma in
case of a macro parameter).
<tscreen><verb>
.macro foo arg1, arg2
...
.endmacro
.macro foo arg1, arg2
...
.endmacro
foo ($00,x) ; Two parameters passed
foo {($00,x)} ; One parameter passed
foo ($00,x) ; Two parameters passed
foo {($00,x)} ; One parameter passed
</verb></tscreen>
In the first case, the macro is called with two parameters: '<tt/(&dollar;00/'
and 'x)'. The comma is not passed to the macro, since it is part of the
and '<tt/x)/'. The comma is not passed to the macro, because it is part of the
calling sequence, not the parameters.
In the second case, '(&dollar;00,x)' is passed to the macro, this time
In the second case, '<tt/(&dollar;00,x)/' is passed to the macro; this time,
including the comma.
@ -3958,17 +4073,17 @@ id=".MATCH" name=".MATCH">/ and <tt/<ref id=".XMATCH" name=".XMATCH">/
functions will allow you to do exactly this:
<tscreen><verb>
.macro ldax arg
.if (.match (.left (1, {arg}), #))
; immediate mode
lda #<(.right (.tcount ({arg})-1, {arg}))
ldx #>(.right (.tcount ({arg})-1, {arg}))
.else
; assume absolute or zero page
lda arg
ldx 1+(arg)
.endif
.endmacro
.macro ldax arg
.if (.match (.left (1, {arg}), #))
; immediate mode
lda #<(.right (.tcount ({arg})-1, {arg}))
ldx #>(.right (.tcount ({arg})-1, {arg}))
.else
; assume absolute or zero page
lda arg
ldx 1+(arg)
.endif
.endmacro
</verb></tscreen>
Using the <tt/<ref id=".MATCH" name=".MATCH">/ function, the macro is able to
@ -3982,11 +4097,11 @@ as end-of-list.
The macro can be used as
<tscreen><verb>
foo: .word $5678
...
ldax #$1234 ; X=$12, A=$34
...
ldax foo ; X=$56, A=$78
foo: .word $5678
...
ldax #$1234 ; X=$12, A=$34
...
ldax foo ; X=$56, A=$78
</verb></tscreen>
@ -3995,38 +4110,38 @@ The macro can be used as
Macros may be used recursively:
<tscreen><verb>
.macro push r1, r2, r3
lda r1
pha
.if .paramcount > 1
push r2, r3
.endif
.endmacro
.macro push r1, r2, r3
lda r1
pha
.ifnblank r2
push r2, r3
.endif
.endmacro
</verb></tscreen>
There's also a special macro to help writing recursive macros: <tt><ref
id=".EXITMACRO" name=".EXITMACRO"></tt> This command will stop macro expansion
immediately:
There's also a special macro command to help with writing recursive macros:
<tt><ref id=".EXITMACRO" name=".EXITMACRO"></tt>. That command will stop macro
expansion immediately:
<tscreen><verb>
.macro push r1, r2, r3, r4, r5, r6, r7
.ifblank r1
; First parameter is empty
.exitmacro
.else
lda r1
pha
.endif
push r2, r3, r4, r5, r6, r7
.endmacro
.macro push r1, r2, r3, r4, r5, r6, r7
.ifblank r1
; First parameter is empty
.exitmacro
.else
lda r1
pha
.endif
push r2, r3, r4, r5, r6, r7
.endmacro
</verb></tscreen>
When expanding this macro, the expansion will push all given parameters
When expanding that macro, the expansion will push all given parameters
until an empty one is encountered. The macro may be called like this:
<tscreen><verb>
push $20, $21, $32 ; Push 3 ZP locations
push $21 ; Push one ZP location
push $20, $21, $32 ; Push 3 ZP locations
push $21 ; Push one ZP location
</verb></tscreen>
@ -4037,27 +4152,27 @@ Now, with recursive macros, <tt><ref id=".IFBLANK" name=".IFBLANK"></tt> and
Have a look at the inc16 macro above. Here is it again:
<tscreen><verb>
.macro inc16 addr
clc
lda addr
adc #$01
sta addr
lda addr+1
adc #$00
sta addr+1
.endmacro
.macro inc16 addr
clc
lda addr
adc #<$0001
sta addr
lda addr+1
adc #>$0001
sta addr+1
.endmacro
</verb></tscreen>
If you have a closer look at the code, you will notice, that it could be
written more efficiently, like this:
<tscreen><verb>
.macro inc16 addr
inc addr
bne Skip
inc addr+1
Skip:
.endmacro
.macro inc16 addr
inc addr
bne Skip
inc addr+1
Skip:
.endmacro
</verb></tscreen>
But imagine what happens, if you use this macro twice? Since the label "Skip"
@ -4069,27 +4184,27 @@ local variables are replaced by a unique name in each separate macro
expansion. So we can solve the problem above by using <tt/.LOCAL/:
<tscreen><verb>
.macro inc16 addr
.local Skip ; Make Skip a local symbol
inc addr
bne Skip
inc addr+1
Skip: ; Not visible outside
.endmacro
.macro inc16 addr
.local Skip ; Make Skip a local symbol
inc addr
bne Skip
inc addr+1
Skip: ; Not visible outside
.endmacro
</verb></tscreen>
Another solution is of course to start a new lexical block inside the macro
that hides any labels:
<tscreen><verb>
.macro inc16 addr
.proc
inc addr
bne Skip
inc addr+1
Skip:
.endproc
.endmacro
.macro inc16 addr
.proc
inc addr
bne Skip
inc addr+1
Skip:
.endproc
.endmacro
</verb></tscreen>
@ -4126,7 +4241,7 @@ different:
be omitted.
<item> Since <tt><ref id=".DEFINE" name=".DEFINE"></tt> style macros may not
contain end-of-line tokens, there are things that cannot be done. They
contain end-of-line tokens, there are things that cannot be done. They
may not contain several processor instructions for example. So, while
some things may be done with both macro types, each type has special
usages. The types complement each other.
@ -4140,27 +4255,27 @@ To emulate assemblers that use "<tt/EQU/" instead of "<tt/=/" you may use the
following <tt/.DEFINE/:
<tscreen><verb>
.define EQU =
.define EQU =
foo EQU $1234 ; This is accepted now
foo EQU $1234 ; This is accepted now
</verb></tscreen>
You may use the directive to define string constants used elsewhere:
<tscreen><verb>
; Define the version number
.define VERSION "12.3a"
; Define the version number
.define VERSION "12.3a"
; ... and use it
.asciiz VERSION
; ... and use it
.asciiz VERSION
</verb></tscreen>
Macros with parameters may also be useful:
<tscreen><verb>
.define DEBUG(message) .out message
.define DEBUG(message) .out message
DEBUG "Assembling include file #3"
DEBUG "Assembling include file #3"
</verb></tscreen>
Note that, while formal parameters have to be placed in braces, this is
@ -4169,12 +4284,12 @@ detect the end of one parameter, only the first token is used. If you
don't like that, use classic macros instead:
<tscreen><verb>
.macro DEBUG message
.out message
.endmacro
.macro DEBUG message
.out message
.endmacro
</verb></tscreen>
(This is an example where a problem can be solved with both macro types).
(That is an example where a problem can be solved with both macro types).
<sect1>Characters in macros<p>
@ -4194,12 +4309,12 @@ be sure to take the translation into account.
<sect1>Deleting macros<p>
Macros can be deleted. This will not work if the macro that should be deleted
is currently expanded as in the following non working example:
is currently expanded as in the following non-working example:
<tscreen><verb>
.macro notworking
.delmacro notworking
.endmacro
.macro notworking
.delmacro notworking
.endmacro
notworking ; Will not work
</verb></tscreen>
@ -4210,19 +4325,19 @@ for <tt><ref id=".DEFINE" name=".DEFINE"></tt> style macros, <tt><ref
id=".UNDEFINE" name=".UNDEFINE"></tt> must be used. Example:
<tscreen><verb>
.define value 1
.macro mac
.byte 2
.endmacro
.define value 1
.macro mac
.byte 2
.endmacro
.byte value ; Emit one byte with value 1
mac ; Emit another byte with value 2
.byte value ; Emit one byte with value 1
mac ; Emit another byte with value 2
.undefine value
.delmacro mac
.undefine value
.delmacro mac
.byte value ; Error: Unknown identifier
mac ; Error: Missing ":"
.byte value ; Error: Unknown identifier
mac ; Error: Missing ":"
</verb></tscreen>
A separate command for <tt>.DEFINE</tt> style macros was necessary, because
@ -4234,6 +4349,7 @@ argument to <tt>.UNDEFINE</tt> is not allowed to come from another
different commands increases flexibility.
<sect>Macro packages<label id="macropackages"><p>
Using the <tt><ref id=".MACPACK" name=".MACPACK"></tt> directive, predefined
@ -4243,48 +4359,47 @@ are:
<sect1><tt>.MACPACK generic</tt><p>
This macro package defines macros that are useful in almost any program.
Currently defined macros are:
This macro package defines macroes that are useful in almost any program.
Currently defined macroes are:
<tscreen><verb>
.macro add Arg
.macro add Arg ; add without carry
clc
adc Arg
.endmacro
.macro sub Arg
.macro sub Arg ; subtract without borrow
sec
sbc Arg
.endmacro
.macro bge Arg
.macro bge Arg ; branch on greater-than or equal
bcs Arg
.endmacro
.macro blt Arg
.macro blt Arg ; branch on less-than
bcc Arg
.endmacro
.macro bgt Arg
.macro bgt Arg ; branch on greater-than
.local L
beq L
bcs Arg
L:
.endmacro
.macro ble Arg
.macro ble Arg ; branch on less-than or equal
beq Arg
bcc Arg
.endmacro
.macro bnz Arg
.macro bnz Arg ; branch on not zero
bne Arg
.endmacro
.macro bze Arg
.macro bze Arg ; branch on zero
beq Arg
.endmacro
</verb></tscreen>
@ -4384,7 +4499,7 @@ it is possible to determine if the
instruction is supported, which is the case for the 65SC02, 65C02 and 65816
CPUs (the latter two are upwards compatible to the 65SC02).
<sect1><tt>.MACPACK module</tt><p>
This macro package defines a macro named <tt/module_header/. It takes an
@ -4418,6 +4533,7 @@ compiler, depending on the target system selected:
<item><tt/__LUNIX__/ - Target system is <tt/lunix/
<item><tt/__LYNX__/ - Target system is <tt/lynx/
<item><tt/__NES__/ - Target system is <tt/nes/
<item><tt/__OSIC1P__/ - Target system is <tt/osic1p/
<item><tt/__PET__/ - Target system is <tt/pet/
<item><tt/__PLUS4__/ - Target system is <tt/plus4/
<item><tt/__SIM6502__/ - Target system is <tt/sim6502/
@ -4748,6 +4864,3 @@ freely, subject to the following restrictions:
</article>

View File

@ -3,7 +3,7 @@
<article>
<title>cc65 Users Guide
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
<date>2000-09-03, 2001-10-02, 2005-08-01
<date>2015-05-26
<abstract>
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
@ -74,6 +74,7 @@ Short options:
Long options:
--add-source Include source as comment
--all-cdecl Make functions default to __cdecl__
--bss-name seg Set the name of the BSS segment
--check-stack Generate stack overflow checks
--code-name seg Set the name of the CODE segment
@ -114,6 +115,14 @@ Here is a description of all the command line options:
<descrip>
<tag><tt>--all-cdecl</tt></tag>
Tells the compiler that functions which aren't declared explicitly with
either the <tt/__cdecl__/ or <tt/__fastcall__/ calling conventions should
have the cdecl convention. (Normally, functions that aren't variadic are
fast-called.)
<label id="option-bss-name">
<tag><tt>--bss-name seg</tt></tag>
@ -348,6 +357,7 @@ Here is a description of all the command line options:
<item>lunix
<item>lynx
<item>nes
<item>osic1p
<item>pet (all CBM PET systems except the 2001)
<item>plus4
<item>sim6502
@ -549,9 +559,10 @@ and the one defined by the ISO standard:
be passed as parameters by value. However, struct assignment *is*
possible.
<p>
<item> Part of the C library is available only with fastcall calling
conventions (see below). It means that you must not mix pointers to
those functions with pointers to user-written, not-fastcall functions.
<item> Most of the C library is available with only the fastcall calling
convention (<ref id="extension-fastcall" name="see below">). It means
that you must not mix pointers to those functions with pointers to
user-written, cdecl functions (the calling conventions are incompatible).
<p>
<item> The <tt/volatile/ keyword doesn't have an effect. This is not as bad
as it sounds, since the 6502 has so few registers that it isn't
@ -589,30 +600,58 @@ This cc65 version has some extensions to the ISO C standard.
<ref id="inline-asm" name="see there">.
<p>
<item> There is a special calling convention named "fastcall".
The syntax for a function declaration using fastcall is
<label id="extension-fastcall">
<item> The normal calling convention -- for non-variadic functions -- is
named "fastcall". The syntax for a function declaration that
<em/explicitly/ uses fastcall is
<tscreen><verb>
&lt;return type&gt; fastcall &lt;function name&gt; (&lt;parameter list&gt;)
</verb></tscreen>
or
<tscreen><verb>
&lt;return type&gt; __fastcall__ &lt;function name&gt; (&lt;parameter list&gt;)
&lt;return type&gt; __fastcall__ &lt;function name&gt; (&lt;parameter list&gt;)
</verb></tscreen>
An example would be
An example is
<tscreen><verb>
void __fastcall__ f (unsigned char c)
void __fastcall__ f (unsigned char c)
</verb></tscreen>
The first form of the fastcall keyword is in the user namespace and can
therefore be disabled with the <tt><ref id="option--standard"
name="--standard"></tt> command line option.
For functions declared as <tt/fastcall/, the rightmost parameter is not
For functions that are <tt/fastcall/, the rightmost parameter is not
pushed on the stack but left in the primary register when the function
is called. This will reduce the cost when calling assembler functions
significantly, especially when the function itself is rather small.
is called. That significantly reduces the cost of calling those functions.
<newline><newline>
<p>
<item> There is another calling convention named "cdecl". Variadic functions
(their prototypes have an ellipsis &lsqb;<tt/.../&rsqb;) always use that
convention. The syntax for a function declaration using cdecl is
<tscreen><verb>
&lt;return type&gt; cdecl &lt;function name&gt; (&lt;parameter list&gt;)
</verb></tscreen>
or
<tscreen><verb>
&lt;return type&gt; __cdecl__ &lt;function name&gt; (&lt;parameter list&gt;)
</verb></tscreen>
An example is
<tscreen><verb>
int* __cdecl__ f (unsigned char c)
</verb></tscreen>
The first form of the cdecl keyword is in the user namespace;
and therefore, can be disabled with the <tt/<ref id="option--standard"
name="--standard">/ command-line option.
For functions that are <tt/cdecl/, the rightmost parameter is pushed
onto the stack before the function is called. That increases the cost
of calling those functions, especially when they are called from many
places.<newline><newline>
<p>
<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
Both refer to the primary register that is used by the compiler to
evaluate expressions or return function results. <tt/__AX__/ is of
@ -819,6 +858,11 @@ The compiler defines several macros at startup:
Is defined if the compiler was called with the <tt/-Os/ command line option.
<tag><tt>__OSIC1P__</tt></tag>
This macro is defined if the target is the Ohio Scientific Challenger 1P
(-t osic1p).
<tag><tt>__PET__</tt></tag>
This macro is defined if the target is the PET family of computers (-t pet).

116
doc/chrcvt.sgml Normal file
View File

@ -0,0 +1,116 @@
<!doctype linuxdoc system> <!-- -*- text-mode -*- -->
<article>
<title>chrcvt Users Guide
<author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
<date>2013-02-10
<abstract>
chrcvt is the vector font converter. It is able to convert a foreign font into
the native format.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
chrcvt is a vector font converter. It is able to convert a "BGI Stroked
Font" to a compact TGI native vector font. See the function <url
url="funcref.html#tgi_load_vectorfont" name="tgi_load_vectorfont"> for usage.
<sect>Usage<p>
The chrcvt utility converts the font of one Borland file to its cc65 equivalent.
<sect1>Command line option overview<p>
The program may be called as follows:
<tscreen><verb>
---------------------------------------------------------------------------
Usage: chrcvt [options] file [options] [file]
Short options:
-h Help (this text)
-v Be more verbose
-V Print the version number and exit
Long options:
--help Help (this text)
--verbose Be more verbose
--version Print the version number and exit
---------------------------------------------------------------------------
</verb></tscreen>
<sect1>Command line options in detail<p>
Here is a description of all the command line options:
<descrip>
<tag><tt>-v, --verbose</tt></tag>
Increase the converter verbosity.
<tag><tt>-h, --help</tt></tag>
Print the short option summary shown above.
<tag><tt>-V, --version</tt></tag>
Print the version number of the utility. When submitting a bug report,
please include the operating system you're using, and the compiler
version.
</descrip>
<sect>Input and output<p>
The converter will read one CHR file per invocation and write the font
in TCH format to a new file.
Example output for the command
<tscreen><verb>
chrcvt --verbose LITT.CHR
</verb></tscreen>
<tscreen><verb>
BGI Stroked Font V1.1 - Aug 12, 1991
Copyright (c) 1987,1988 Borland International
</verb></tscreen>
<sect>Copyright<p>
chrcvt is (C) Copyright 2009, Ullrich von Bassewitz. For usage of the
binaries and/or sources the following conditions apply:
This software is provided 'as-is', without any expressed or implied
warranty. In no event will the authors be held liable for any damages
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:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

View File

@ -3,7 +3,7 @@
<article>
<title>Defining a Custom cc65 Target
<author>Bruce Reidenbach
<date>2010-02-22
<date>2015-03-13
<abstract>
This section provides step-by-step instructions on how to use the cc65
@ -525,15 +525,16 @@ The first step in creating the assembly language code for the driver is
to determine how to pass the C arguments to the assembly language
routine. The cc65 toolset allows the user to specify whether the data
is passed to a subroutine via the stack or by the processor registers by
using the <tt>__fastcall__</tt> function declaration (note that there
are two underscore characters in front of and two behind the
<tt>fastcall</tt> declaration). When <tt>__fastcall__</tt> is
specified, the rightmost argument in the function call is passed to the
using the <tt/__fastcall__/ and <tt/__cdecl__/ function qualifiers (note that
there are two underscore characters in front of and two behind each
qualifier). <tt/__fastcall__/ is the default. When <tt/__cdecl__/ <em/isn't/
specified, and the function isn't variadic (i.e., its prototype doesn't have
an ellipsis), the rightmost argument in the function call is passed to the
subroutine using the 6502 registers instead of the stack. Note that if
there is only one argument in the function call, the execution overhead
required by the stack interface routines is completely avoided.
Without <tt>__fastcall__</tt>, the argument is loaded in the A and X
With <tt/__cdecl__</tt>, the last argument is loaded into the A and X
registers and then pushed onto the stack via a call to <tt>pushax</tt>.
The first thing the subroutine does is retrieve the argument from the
stack via a call to <tt>ldax0sp</tt>, which copies the values into the A
@ -561,7 +562,7 @@ _foo: jsr ldax0sp ; Retrieve A and X from the stack
jmp incsp2 ; Pop A and X from the stack (includes return)
</verb></tscreen>
If <tt>__fastcall__</tt> is specified, the argument is loaded into the A
If <tt/__cdecl__/ isn't specified, then the argument is loaded into the A
and X registers as before, but the subroutine is then called
immediately. The subroutine does not need to retrieve the argument
since the value is already available in the A and X registers.

View File

@ -2,12 +2,14 @@
<article>
<title>da65 Users Guide
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
<date>2003-08-08
<author>
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2014-11-23
<abstract>
da65 is a 6502/65C02 disassembler that is able to read user supplied
information about its input data for better results. The output is ready for
da65 is a 6502/65C02 disassembler that is able to read user-supplied
information about its input data, for better results. The output is ready for
feeding into ca65, the macro assembler supplied with the cc65 C compiler.
</abstract>
@ -23,7 +25,7 @@ the cc65 C compiler and generates output that is suitable for the ca65
macro assembler.
Besides generating output for ca65, one of the design goals was that the user
is able to feed additional information about the code into the disassembler
is able to feed additional information about the code into the disassembler,
for improved results. This information may include the location and size of
tables, and their format.
@ -106,11 +108,16 @@ Here is a description of all the command line options:
<tag><tt>--cpu type</tt></tag>
Set the CPU type. The option takes a parameter, which may be one of
<itemize>
<item>6502
<item>6502x
<item>65sc02
<item>65c02
<item>huc6280
</itemize>
6502, 6502x, 65sc02, 65c02, huc6280
6502x is the NMOS 6502 with illegal opcodes. huc6280 is the CPU of the PC
engine. Support for the 65816 is currently not available.
6502x is for the NMOS 6502 with unofficial opcodes. huc6280 is the CPU of
the PC engine. Support for the 65816 currently is not available.
<label id="option--formfeeds">
@ -125,7 +132,7 @@ Here is a description of all the command line options:
<tag><tt>-g, --debug-info</tt></tag>
This option adds the <tt/.DEBUGINFO/ command to the output file, so the
assembler will generate debug information when reassembling the generated
assembler will generate debug information when re-assembling the generated
output.
@ -241,7 +248,7 @@ unsupported.
The disassembler works by creating an attribute map for the whole address
space ($0000 - $FFFF). Initially, all attributes are cleared. Then, an
external info file (if given) is read. Disassembly is done in several passes.
In all passes with the exception of the last one, information about the
In all passes, with the exception of the last one, information about the
disassembled code is gathered and added to the symbol and attribute maps. The
last pass generates output using the information from the maps.
@ -275,19 +282,19 @@ braces. Attributes have a name followed by a value. The syntax of the value
depends on the type of the attribute. String attributes are places in double
quotes, numeric attributes may be specified as decimal numbers or hexadecimal
with a leading dollar sign. There are also attributes where the attribute
value is a keyword, in this case the keyword is given as is (without quotes or
value is a keyword; in this case, the keyword is given as-is (without quotes or
anything). Each attribute is terminated by a semicolon.
<tscreen><verb>
group-name { attribute1 attribute-value; attribute2 attribute-value; }
group-name { attribute1 attribute-value; attribute2 attribute-value; }
</verb></tscreen>
<sect1>Comments<p>
Comments start with a hash mark (<tt/#/) and extend from the position of
Comments start with a hash mark (<tt/#/); and, extend from the position of
the mark to the end of the current line. Hash marks inside of strings will
of course <em/not/ start a comment.
<em/not/ start a comment, of course.
<sect1>Specifying global options<label id="global-options"><p>
@ -543,18 +550,17 @@ disassembled code. The following attributes are recognized:
<tag><tt>END</tt></tag>
Followed by a numerical value. Specifies the end address of the segment. The
end address is last the address that is part of the segment.
end address is the last address that is a part of the segment.
<tag><tt>NAME</tt></tag>
The attribute is followed by a string value which gives the name of the
segment.
</descrip>
All attributes are mandatory. Segments may not overlap. Since there is no
explicit "end this segment" pseudo op, the disassembler cannot notify the
assembler that one segment has ended. This may lead to errors if you don't
define your segments carefully. As a rule of thumb, if you're using segments,
your should define segments for all disassembled code.
All attributes are mandatory. Segments must not overlap. The disassembler will
change back to the (default) <tt/.code/ segment after the end of each defined
segment. That might not be what you want. As a rule of thumb, if you're using
segments, you should define segments for all disassembled code.
<sect1>Specifying Assembler Includes<label id="infofile-asminc"><p>
@ -563,8 +569,8 @@ The <tt/ASMINC/ directive is used to give the names of input files containing
symbol assignments in assembler syntax:
<tscreen><verb>
Name = value
Name := value
Name = value
Name := value
</verb></tscreen>
The usual conventions apply for symbol names. Values may be specified as hex
@ -613,48 +619,46 @@ directives explained above:
};
# One segment for the whole stuff
SEGMENT { START $E000; END $FFFF; NAME kernal; };
SEGMENT { START $E000; END $FFFF; NAME "kernal"; };
RANGE { START $E612; END $E631; TYPE Code; };
RANGE { START $E632; END $E640; TYPE ByteTable; };
RANGE { START $EA51; END $EA84; TYPE RtsTable; };
RANGE { START $EC6C; END $ECAB; TYPE RtsTable; };
RANGE { START $ED08; END $ED11; TYPE AddrTable; };
RANGE { START $E612; END $E631; TYPE Code; };
RANGE { START $E632; END $E640; TYPE ByteTable; };
RANGE { START $EA51; END $EA84; TYPE RtsTable; };
RANGE { START $EC6C; END $ECAB; TYPE RtsTable; };
RANGE { START $ED08; END $ED11; TYPE AddrTable; };
# Zero page variables
LABEL { NAME "fnadr"; ADDR $90; SIZE 3; };
LABEL { NAME "sal"; ADDR $93; };
LABEL { NAME "sah"; ADDR $94; };
LABEL { NAME "sas"; ADDR $95; };
# Zero-page variables
LABEL { NAME "fnadr"; ADDR $90; SIZE 3; };
LABEL { NAME "sal"; ADDR $93; };
LABEL { NAME "sah"; ADDR $94; };
LABEL { NAME "sas"; ADDR $95; };
# Stack
LABEL { NAME "stack"; ADDR $100; SIZE 255; };
LABEL { NAME "stack"; ADDR $100; SIZE 255; };
# Indirect vectors
LABEL { NAME "cinv"; ADDR $300; SIZE 2; }; # IRQ
LABEL { NAME "cbinv"; ADDR $302; SIZE 2; }; # BRK
LABEL { NAME "nminv"; ADDR $304; SIZE 2; }; # NMI
LABEL { NAME "cinv"; ADDR $300; SIZE 2; }; # IRQ
LABEL { NAME "cbinv"; ADDR $302; SIZE 2; }; # BRK
LABEL { NAME "nminv"; ADDR $304; SIZE 2; }; # NMI
# Jump table at end of kernal ROM
LABEL { NAME "kscrorg"; ADDR $FFED; };
LABEL { NAME "kplot"; ADDR $FFF0; };
LABEL { NAME "kiobase"; ADDR $FFF3; };
LABEL { NAME "kgbye"; ADDR $FFF6; };
LABEL { NAME "kscrorg"; ADDR $FFED; };
LABEL { NAME "kplot"; ADDR $FFF0; };
LABEL { NAME "kiobase"; ADDR $FFF3; };
LABEL { NAME "kgbye"; ADDR $FFF6; };
# Hardware vectors
LABEL { NAME "hanmi"; ADDR $FFFA; };
LABEL { NAME "hares"; ADDR $FFFC; };
LABEL { NAME "hairq"; ADDR $FFFE; };
LABEL { NAME "hanmi"; ADDR $FFFA; };
LABEL { NAME "hares"; ADDR $FFFC; };
LABEL { NAME "hairq"; ADDR $FFFE; };
</verb></tscreen>
<sect>Copyright<p>
da65 (and all cc65 binutils) are (C) Copyright 1998-2007 Ullrich von
Bassewitz. For usage of the binaries and/or sources the following
da65 (and all cc65 binutils) is (C) Copyright 1998-2011, Ullrich von
Bassewitz. For usage of the binaries and/or sources, the following
conditions do apply:
This software is provided 'as-is', without any expressed or implied
@ -666,20 +670,16 @@ including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,9 @@
<tag><htmlurl url="cc65.html" name="cc65.html"></tag>
Describes the cc65 C compiler.
<tag><htmlurl url="chrcvt.html" name="chrcvt.html"></tag>
Describes the vector font converter.
<tag><htmlurl url="cl65.html" name="cl65.html"></tag>
Describes the cl65 compile &amp; link utility.
@ -36,6 +39,9 @@
<tag><htmlurl url="od65.html" name="od65.html"></tag>
Describes the od65 object-file analyzer.
<tag><htmlurl url="sim65.html" name="sim65.html"></tag>
Describes the 6502 and 65C02 simulator.
<tag><htmlurl url="sp65.html" name="sp65.html"></tag>
Describes the sprite and bitmap utility.
@ -83,7 +89,7 @@
An overview over the cc65 runtime and C libraries.
<tag><htmlurl url="smc.html" name="smc.html"></tag>
Describes Christian Kr&uuml;gers macro package for writing self modifying
Describes Christian Kr&uuml;ger's macro package for writing self modifying
assembler code.
<tag><url name="6502 Binary Relocation Format document"
@ -134,6 +140,12 @@
<tag><htmlurl url="nes.html" name="nes.html"></tag>
Topics specific to the Nintendo Entertainment System.
<tag><htmlurl url="osi.html" name="osi.html"></tag>
Topics specific to the Ohio Scientific machines.
<tag><htmlurl url="pce.html" name="pce.html"></tag>
Topics specific to NEC PC-Engine (TurboGrafx) Console.
<tag><htmlurl url="pet.html" name="pet.html"></tag>
Topics specific to the Commodore PET machines.
@ -141,7 +153,7 @@
Topics specific to the Commodore Plus/4.
<tag><htmlurl url="supervision.html" name="supervision.html"></tag>
Topics specific to the Supervision Console.
Topics specific to the Watara Supervision Console.
<tag><htmlurl url="vic20.html" name="vic20.html"></tag>
Topics specific to the Commodore VIC20.
@ -150,4 +162,3 @@
</article>

View File

@ -6,8 +6,9 @@
<author>
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:cbmnut@hushmail.com" name="CbmNut">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2014-4-24
<url url="mailto:greg.king5@verizon.net" name="Greg King">,<newline>
<url url="mailto:stephan.muehlstrasser@web.de" name="Stephan M&uuml;hlstrasser">
<date>2015-03-07
<abstract>
How to use the cc65 C language system -- an introduction.
@ -342,8 +343,8 @@ Available at <url
url="http://code.google.com/p/oriculator/">:
Emulates Oric-1 and Atmos computers, with sound, disk images,
scanline-exact NTSC/PAL video, and movie export. Includes monitor.
Fortunately for all SDL platforms. You will just need the emulator, all
scanline-exact NTSC/PAL video, and movie export. Includes a monitor.
Fortunately, for all SDL platforms. You will need just the emulator; all
ROMs are supplied.
Compile the tutorial with
@ -353,8 +354,11 @@ cl65 -O -t atmos hello.c text.s -o hello.tap
</verb></tscreen>
Start the emulator, choose <bf/F1/ and <bf/Insert tape.../, and point to
the "<bf/hello.tap/" executable. The file has an auto start header meant to
be loaded directly from tape.
the "<bf/hello.tap/" executable. After it has finished loading, type
<tscreen><verb>
RUN
</verb></tscreen>
On a real Atmos, you would need a tape drive.
Turn on the computer, type
@ -363,7 +367,11 @@ Turn on the computer, type
CLOAD""
</verb></tscreen>
at the BASIC prompt.
at the BASIC prompt. After it has finished loading, type
<tscreen><verb>
RUN
</verb></tscreen>
The emulation, also, supports that method.
@ -514,6 +522,127 @@ The output is shown in a GEOS dialog box; click <bf/OK/ when you have finished
reading it.
<sect1>Ohio Scientific Challenger 1P<p>
The <tt/osic1p/ runtime library returns to the boot prompt when the main()
program exits. Therefore, the C file in the tutorial must be modified
slightly, in order to see the results on the screen. Otherwise, the program
would print the text string, and then jump to the boot prompt, making it
impossible to see the results of running the tutorial program.
In addition to that, the <tt/osic1p/ target does not yet have support for stdio
functions. Only the functions from the conio library are available.
Therefore, modify the "<tt/hello.c/" source file, as follows:
<tscreen><code>
#include <conio.h>
#include <stdlib.h>
extern const char text[]; /* In text.s */
int main (void)
{
clrscr ();
cprintf ("%s\r\nPress <RETURN>.\r\n", text);
cgetc ();
return EXIT_SUCCESS;
}
</code></tscreen>
Compile the tutorial with
<tscreen><verb>
cl65 -O -t osic1p -u __BOOT__ -o hello.lod hello.c text.s
</verb></tscreen>
The program is configured for a Challenger 1P computer with, at least, 32 kB
of RAM. See the <url url="osi.html"
name="Ohio Scientifc-specific documentation"> for instructions about how to
compile for other RAM sizes.
Plug a cassette player into your C1P computer; or, connect an RS-232 cable
between your C1P and a PC (set the PC's serial port to 300 Bits Per Second,
8 data bits, No parity, and 2 stop bits). (Turn on the computers.)
Tap the "<bf/BREAK/" key, to display the boot prompt; then, tap the "<tt/M/"
key, to enter the 65V PROM monitor. Tap the "<tt/L/" key. Either start the
cassette player (with a tape of the program), or start a transfer of the
program file "<tt/hello.lod/" from the PC. After a while, you should see the
following text on the screen:
<tscreen><verb>
Hello world!
Press <RETURN>.
</verb></tscreen>
(Stop the cassette player.) After hitting the RETURN key, you should see the
boot prompt again.
<sect2>WinOSI<p>
Available at <url
url="http://osi.marks-lab.com/#Emulator">:
Emulates the Ohio Scientific Challenger computers in different configurations.
Configure it to emulate a C1P (model 600 board) with 32 kB of RAM.
Compile the tutorial with the same command that is used to make the program
for a real machine.
Start the emulator. Tap the "<tt/M/" key, to enter the 65V PROM monitor; then,
tap the "<tt/L/" key. If you had configured WinOSI to ask for a file when it
starts to read data from the serial port, then you will see a file dialog box;
otherwise, you must tap your host keyboard's F10 function key. Select the file
"<tt/hello.lod/". After a moment, you should see the following text on the
screen:
<tscreen><verb>
Hello world!
Press <RETURN>.
</verb></tscreen>
After hitting the RETURN key, you should see the boot prompt again.
<sect2>C1Pjs<p>
Available at <url
url="http://www.pcjs.org/docs/c1pjs/">:
Emulates the Ohio Scientific Challenger 1P computer in different configurations.
The 32 kB RAM machine that must be used with the default compiler settings is
<url url="http://www.pcjs.org/devices/c1p/machine/32kb/" name="here">.
In addition to cc65, the <bf/srec_cat/ program from <url
url="http://srecord.sourceforge.net/" name="the SRecord tool collection">
must be installed. Some Linux distributions also provide srecord directly as
an installable package.
Compile the tutorial with this command line:
<tscreen><verb>
cl65 -O -t osic1p hello.c text.s
</verb></tscreen>
Convert the binary file into a text file that can be loaded via
the Ohio Scientific 65V PROM monitor, at start address 0x200:
<tscreen><verb>
srec_cat hello -binary -offset 0x200 -o hello.c1p -Ohio_Scientific -execution-start-address=0x200
</verb></tscreen>
Open the URL that points to the 32 kB machine; and, wait until the emulator
has been loaded. Click on the "<bf/BREAK/" button to display the boot prompt;
then, press the "<tt/M/" key to enter the 65V PROM monitor. Click the
"<bf/Browse.../" button; and, select the file "<tt/hello.c1p/" that was
created as the output of the above invocation of the "<tt/srec_cat/" command.
Press the "<bf/Load/" button. You should see the following text on the screen:
<tscreen><verb>
Hello world!
Press <RETURN>.
</verb></tscreen>
After hitting the RETURN key, you should see the boot prompt again.
<sect1>Contributions wanted<p>
We need your help! Recommended emulators and instructions for other targets

View File

@ -69,7 +69,7 @@ Programs containing NES specific code may use the <tt/nes.h/ header file.
<sect1>NES specific functions<p>
<itemize>
<item>waitvblank
<item>waitvblank - wait until the start of vblank
<item>get_tv
</itemize>
@ -123,6 +123,14 @@ No extended memory drivers are currently available for the NES.
</descrip><p>
The generic interface doesn't export the start and select buttons. To
test for those, use the defines in nes.h instead of the generic masks.
Example:
<tscreen><verb>
if (joy_read(0) & KEY_A)
</verb></tscreen>
<sect1>Mouse drivers<p>

233
doc/osi.sgml Normal file
View File

@ -0,0 +1,233 @@
<!doctype linuxdoc system>
<article>
<title>Ohio Scientific-specific information for cc65
<author>
<url url="mailto:stephan.muehlstrasser@web.de" name="Stephan M&uuml;hlstrasser">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2015-03-17
<abstract>
An overview over the Ohio Scientific runtime system as it is implemented for the cc65 C
compiler.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
This file contains an overview of the Ohio Scientific runtime system as it comes with the
cc65 C compiler. It describes the memory layout, Ohio Scientific-specific header files,
and any pitfalls specific to that platform.
Please note that Ohio Scientific-specific functions are just mentioned here, they are
described in detail in the separate <url url="funcref.html" name="function
reference">. Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
<sect>Targets<p>
Currently the target "osic1p" is implemented. This works for the Ohio Scientific
Challenger 1P machine and for the Briel Superboard /// replica.
<sect>Program file formats<p>
<descrip>
<tag/Binary, then text/
The standard binary output format generated by the linker for the osic1p
target is a pure machine language program.
For uploading into a real machine over its serial port or into an emulator,
that program must be converted into a text file that can be understood by
the 65V PROM monitor. For that purpose, the <bf/srec_cat/ program from <url
url="http://srecord.sourceforge.net/" name="the SRecord tool collection">
can be used.
Care must be taken that the <tt/-offset/ and <tt/-execution-start-address/
options for the <bf/srec_cat/ program correspond to the start address
of the executable.
Example for converting an executable "hello" file that was built for the
default start address &dollar;0200 to an uploadable file "hello.c1p":
<tscreen><verb>
srec_cat hello -bin -of 0x200 -o hello.c1p -os -esa=0x200
</verb></tscreen>
<tag/Hybrid/
The linker can create an alternate format that contains two parts:
<enum>
<item>A text header that is understood by the 65V PROM monitor.
It is a boot loader that reads the second part.
<item>The default binary code that is described above.
</enum>
You can make the alternate format by adding the option <tt/-u __BOOT__/ to
<tt/cl65/'s or <tt/ld65/'s command lines.
This format doesn't need to be converted. It is smaller than the text-only
format. But, it cannot be loaded by <url
url="http://www.pcjs.org/docs/c1pjs/" name="C1Pjs">; you must use the
SRecord-produced text-only format with that emulator. (However, if you know
that you never will use C1Pjs, then you can edit the
<tt>cfg/osic1p*.cfg</tt> files; uncomment the lines that import <tt/__BOOT__/.
Then, you won't need to use <tt/-u __BOOT__/ on your command lines.)
</descrip>
<sect>Memory layout<p>
By default programs compiled for the osic1p target are configured for 32 kB RAM.
The RAM size can be configured via the symbol <tt/__HIMEM__/.
Special locations:
<descrip>
<tag/Program start address/
The default start address is &dollar;0200. The start address is configurable
via the linker option <tt/--start-addr/.
<tag/Stack/
The C runtime stack is located at the top of RAM and growing downwards.
The size is configurable via the symbol <tt/__STACKSIZE__/. The default
stack size is &dollar;0400.
<tag/Heap/
The C heap is located at the end of the program and grows towards the C
runtime stack.
<tag/Video RAM/
The 1 kB video RAM is located at &dollar;D000. On the monitor, only a subset
of the available video RAM is visible. The address of the upper left corner
of the visible area is &dollar;D085 and corresponds to conio cursor
position (0, 0).
</descrip><p>
Example for building a program with start address &dollar;0300, stack size
&dollar;0200 and RAM size &dollar;2000:
<tscreen><verb>
cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p hello.c
</verb></tscreen>
<sect>Linker configurations<p>
The ld65 linker comes with a default config file "osic1p.cfg" for the Ohio Scientific
Challenger 1P, which is implicitly used via <tt/-t osic1p/. The
osic1p package comes with additional secondary linker config files, which are
used via <tt/-t osic1p -C &lt;configfile&gt;/.
<sect1>Default config file (<tt/osic1p.cfg/)<p>
The default configuration is tailored to C programs.
<sect1><tt/osic1p-asm.cfg/<p>
This configuration is made for assembler programmers who don't need a special
setup.
To use this config file, assemble with <tt/-t osic1p/ and link with
<tt/-C osic1p-asm.cfg/. The former will make sure that correct runtime library
is used, while the latter supplies the actual config. When using <tt/cl65/,
use both command line options.
Sample command lines for <tt/cl65/:
<tscreen><verb>
cl65 -t osic1p -C osic1p-asm.cfg -o program source.s
cl65 -t osic1p -C osic1p-asm.cfg -u __BOOT__ -o program.lod source.s
</verb></tscreen>
<sect>Platform-specific header files<p>
Programs containing Ohio Scientific-specific code may use the <tt/osic1p.h/
header file.
<sect1>Ohio Scientific-specific functions<p>
There are currently no special Ohio Scientific functions.
<sect1>Hardware access<p>
There is no specific support for direct hardware access.
<sect>Loadable drivers<p>
There are no loadable drivers available.
<sect>Support for different screen layouts<p>
By default the conio library uses a 24 columns by 24 lines screen layout
for the Challenger 1P, like under BASIC. In addition to that there is support
for other screen layouts with extra modules.
There is a module <tt/screen-c1p-24x24.o/ in the OSI-specific
cc65 runtime library that contains all conio functions that depend
on the screen layout. No further configuration is needed for using the
default screen layout of the Challenger 1P.
For other screen layouts additional versions of the screen module are
available. The linker finds these modules without further configuration
if they are specified on the compiler or linker command line. The
extra module then overrides the default module.
Sample <tt/cl65/ command line to override the default screen
module with the module <tt/osic1p-screen-s3-32x28.o/:
<tscreen><verb>
cl65 -o hello -t osic1p osic1p-screen-s3-32x28.o hello.c
</verb></tscreen>
Currently the following extra screen configuration modules are implemented:
<itemize>
<item><tt>osic1p-screen-s3-32x28.o</tt>: 32 columns by 28 lines mode
for Briel Superboard ///</item>
</itemize>
<sect>Limitations<p>
<sect1>stdio implementation<p>
There is no support for stdio at the moment.
<sect>Other hints<p>
<sect1>Passing arguments to the program<p>
There is currently no support for passing arguments to a program.
<sect1>Program return code<p>
The program return code currently has no effect. When the main() function
finishes, the boot prompt is shown again.
<sect>License<p>
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:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

215
doc/pce.sgml Normal file
View File

@ -0,0 +1,215 @@
<!doctype linuxdoc system>
<article>
<title>PC-Engine (TurboGrafx) System specific information for cc65
<author>
<url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen">
<date>2015-07-14
<abstract>
An overview over the PCE runtime system as it is implemented for the
cc65 C compiler.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
This file contains an overview of the PCE runtime system as it comes
with the cc65 C compiler. It describes the memory layout, PCE specific header
files, available drivers, and any pitfalls specific to that platform.
Please note that PCE specific functions are just mentioned here, they are
described in detail in the separate <url url="funcref.html" name="function
reference">. Even functions marked as "platform dependent" may be available on
more than one platform. Please see the function reference for more
information.
<sect>Binary format<p>
The standard binary output format generated by the linker for the PCE target
is a cartridge image with no header. It is of course possible to change this
behaviour by using a modified startup file and linker config.
<sect>Memory layout<p>
cc65 generated programs with the default setup run with the I/O area and a
CHR bank enabled, which gives a usable memory range of &dollar;8000 - &dollar;FFF3.
All boot ROM entry points may be called directly without additional code.
Special locations:
<descrip>
<tag/Text screen and Font/
The text screen is located at VRAM &dollar;0000,
the Font is located at VRAM &dollar;2000.
<tag/Stack/
The C runtime stack is located in system RAM at &dollar;3FFF and growing downwards.
<tag/BSS and Data/
The BSS (uninitialized variables) and Data (initialized variables) sections are
placed one after the other into system RAM at &dollar;2000.
<tag/Heap/
The C heap is located after the end of the Data section and grows towards the C
runtime stack.
<tag/Code/
The startup code is located at &dollar;E000 in the System/Hardware bank. Further
code can be placed in other ROM banks, this must be done manually however.
</descrip><p>
<sect>Platform specific header files<p>
Programs containing PCE specific code may use the <tt/pce.h/ header file.
<sect1>PCE specific functions<p>
<itemize>
<item>waitvblank</item>
<item>get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)</item>
</itemize>
<sect1>Hardware access<p>
The following pseudo variables declared in the <tt/pce.inc/ include file do
allow access to hardware located in the address space.
<descrip>
<tag><tt/PSG/</tag>
The <tt/PSG/ defines allow access to the PSG chip (Programmable Sound Generator).
<tag><tt/VCE/</tag>
The <tt/VCE/ defines allow access to the VCE chip (Video Color Encoder).
<tag><tt/VDC/</tag>
The <tt/VDC/ defines allow access to the VDC chip (Video Display Controller).
</descrip><p>
<sect>Loadable drivers<p>
All drivers must be statically linked because no file I/O is available.
The names in the parentheses denote the symbols to be used for static linking of the drivers.
<sect1>Graphics drivers<p>
No TGI graphics drivers are currently available for the PCE.
<sect1>Extended memory drivers<p>
No extended memory drivers are currently available for the PCE.
<sect1>Joystick drivers<p>
<descrip>
<tag><tt/pce-stdjoy.joy (pce_stdjoy)/</tag>
A joystick driver for the standard two buttons joypad is available.
Note that the japanese 6-button pad is currently not supported.
</descrip><p>
<sect1>Mouse drivers<p>
No mouse drivers are currently available for the PCE.
<sect1>RS232 device drivers<p>
No serial drivers are currently available for the PCE.
<sect>Limitations<p>
<itemize>
<item>interruptor support in crt0 (and cfg) is missing
</itemize>
<sect1>Disk I/O<p>
The existing library for the PCE doesn't implement C file
I/O. There are no hacks for the <tt/read()/ and <tt/write()/ routines.
To be more concrete, this limitation means that you cannot use any of the
following functions (and a few others):
<itemize>
<item>printf
<item>fclose
<item>fopen
<item>fread
<item>fprintf
<item>fputc
<item>fscanf
<item>fwrite
<item>...
</itemize>
<sect>Other hints<p>
<itemize>
<item>a good emulator to use for PC-Engine is "mednafen" (<url url="http://mednafen.fobby.net/">)
</itemize>
some useful resources on PCE coding:
<itemize>
<item><url url="http://blog.blockos.org/?tag=pc-engine">
<item><url url="http://pcedev.blockos.org/viewforum.php?f=5">
<item><url url="http://www.romhacking.net/?page=documents&amp;category=&amp;platform=4&amp:game=&amp;author=&amp;perpage=20&amp;level=&amp;title=&amp;desc=&amp;docsearch=Go">
<item><url url="http://archaicpixels.com/Main_Page">
<item><url url="http://www.magicengine.com/mkit/doc.html">
<item><url url="https://github.com/uli/huc">
<item><url url="http://www.zeograd.com/parse.php?src=hucf">
</itemize>
<sect>License<p>
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:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

125
doc/sim65.sgml Normal file
View File

@ -0,0 +1,125 @@
<!doctype linuxdoc system> <!-- -*- text-mode -*- -->
<article>
<title>sim65 Users Guide
<author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
<date>2016-01-05
<abstract>
sim65 is a simulator for 6502 and 65C02 CPUs. It allows to test target
independed code.
</abstract>
<!-- Table of contents -->
<toc>
<!-- Begin the document -->
<sect>Overview<p>
sim65 is the only solution as part of the toolchain to execute code. The
binary needs to be compiled with <tt/--target sim6502/ or <tt/--target sim65c02/.
<sect>Usage<p>
The simulator is called as follows:
<tscreen><verb>
Usage: sim65 [options] file [arguments]
Short options:
-h Help (this text)
-v Increase verbosity
-V Print the simulator version number
-x <num> Exit simulator after <num> cycles
Long options:
--help Help (this text)
--verbose Increase verbosity
--version Print the simulator version number
</verb></tscreen>
<sect1>Command line options in detail<p>
Here is a description of all the command line options:
<descrip>
<tag><tt>-h, --help</tt></tag>
Print the short option summary shown above.
<tag><tt>-v, --verbose</tt></tag>
Increase the simulator verbosity.
<tag><tt>-V, --version</tt></tag>
Print the version number of the utility. When submitting a bug report,
please include the operating system you're using, and the compiler
version.
<tag><tt>-x num</tt></tag>
Exit simulator after num cycles.
</descrip>
<sect>Input and output<p>
The simulator will read one binary file per invocation and can log the
program loading and paravirtualization calls to stderr.
Example output for the command
<tscreen><verb>
sim65 --verbose --verbose samples/gunzip65
</verb></tscreen>
<tscreen><verb>
Loaded `samples/gunzip65' at $0200-$151F
PVWrite ($0001, $13C9, $000F)
GZIP file name:PVWrite ($0001, $151F, $0001)
PVRead ($0000, $FFD7, $0001)
PVOpen ("", $0001)
PVRead ($0003, $1520, $6590)
PVClose ($0003)
PVWrite ($0001, $13D9, $000F)
Not GZIP formatPVWrite ($0001, $151F, $0001)
PVExit ($01)
</verb></tscreen>
<sect>Copyright<p>
sim65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
Bassewitz. For usage of the binaries and/or sources the following conditions
do apply:
This software is provided 'as-is', without any expressed or implied
warranty. In no event will the authors be held liable for any damages
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:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
</enum>
</article>

View File

@ -224,7 +224,7 @@ These marcos are determined to get, set and change arguments of instructions:
<label id="Change branch">
<tag><tt>SMC_ChangeBranch label, destination (, register)</tt></tag>
Used to modify the destination of a branch instruction. If the adress offset
Used to modify the destination of a branch instruction. If the address offset
exceeds the supported range of 8-bit of the 6502, a error will be thrown.
Example:
@ -296,7 +296,7 @@ SMC GetK, { LDX #SMC_Value }
<tag><tt>SMC_TransferLowByte label, value (, register)</tt></tag>
Does the same as '<tt>SMC_TransferValue</tt>' but should be used for
low-bytes of adresses for better readability.
low-bytes of addresses for better readability.
Example:
<tscreen><verb>
@ -312,7 +312,7 @@ SMC LoadData, { LDA $2000 }
<tag><tt>SMC_LoadLowByte label (, register)</tt></tag>
Does the same as '<tt>SMC_LoadValue</tt>' but should be used for low-bytes
of adresses for better readability.
of addresses for better readability.
Example:
<tscreen><verb>
@ -329,7 +329,7 @@ SMC LoadData, { LDA $2000 }
<tag><tt>SMC_StoreLowByte label (, register)</tt></tag>
Does the same as '<tt>SMC_StoreValue</tt>' but should be used for low-bytes
of adresses for better readability.
of addresses for better readability.
Example:
<tscreen><verb>
@ -352,7 +352,7 @@ SMC StoreCollisionData, { STY $2200 }
<tag><tt>SMC_TransferHighByte label, value (, register)</tt></tag>
Loads and stores the given value via the named register to the high-byte
adress portion of an SMC-instruction.
address portion of an SMC-instruction.
Example:
<tscreen><verb>
@ -370,7 +370,7 @@ PlayOtherSound:
<label id="Load high-byte">
<tag><tt>SMC_LoadHighByte label (, register)</tt></tag>
Loads the high-byte part of an SMC-instruction adress to the given register.
Loads the high-byte part of an SMC-instruction address to the given register.
Example:
<tscreen><verb>
@ -387,7 +387,7 @@ SMC GetVolume { LDA $3200,x }
<label id="Store high-byte">
<tag><tt>SMC_StoreHighByte label (, register)</tt></tag>
Stores the high-byte adress part of an SMC-instruction from the given
Stores the high-byte address part of an SMC-instruction from the given
register.
Example:
@ -407,7 +407,7 @@ SMC GetSoundData, { LDA Level1Base+Sound, y }
</verb></tscreen>
<label id="Transfer single adress">
<label id="Transfer single address">
<tag><tt>SMC_TransferAddressSingle label, address (, register)</tt></tag>
Transfers the contents of the given address via the given register to the
@ -428,7 +428,7 @@ SMC GetChar, { LDA SMC_AbsAdr, x }
</verb></tscreen>
<label id="Transfer adress">
<label id="Transfer address">
<tag><tt>SMC_TransferAddress label, address</tt></tag>
Loads contents of given address to A/X and stores the result to SMC
@ -559,11 +559,11 @@ allowing reuse of some instructions.
8: SMC FirstIncHighByte, { SMC_OperateOnHighByte inc, StoreAccuFirstSection } ; code will be overwritten to 'beq RestoreCode' (*)
9: ...
10: SMC_TransferOpcode FirstIncHighByte, OPC_BEQ , x ; change code marked above with (*)
11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative adress to 'RestoreCode'
11: SMC_TransferValue FirstIncHighByte, #(restoreCode - RestoreCodeBranchBaseAdr-2), x ; set relative address to 'RestoreCode'
12: ...
13: restoreCode:
14: SMC_TransferOpcode FirstIncHighByte, OPC_INC_abs , x ; restore original code...
15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of adress)
15: SMC_TransferValue FirstIncHighByte, #(<(StoreToFirstSection+2)), x ; (second byte of inc contained low-byte of address)
16: ...
</verb></tscreen>

View File

@ -2,14 +2,14 @@
/* */
/* ace.h */
/* */
/* ACE system specific definitions */
/* ACE system-specific definitions */
/* */
/* */
/* */
/* (C) 1998-2001 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -61,9 +61,9 @@ struct aceDirentBuf {
char ad_name [17]; /* Name itself, ASCIIZ */
};
int aceDirOpen (char* dir);
int aceDirClose (int handle);
int aceDirRead (int handle, struct aceDirentBuf* buf);
int __cdecl__ aceDirOpen (char* dir);
int __cdecl__ aceDirClose (int handle);
int __cdecl__ aceDirRead (int handle, struct aceDirentBuf* buf);
/* Type of an ACE key. Key in low byte, shift mask in high byte */
typedef unsigned int aceKey;
@ -92,23 +92,23 @@ typedef unsigned int aceKey;
#define aceOP_RPTRATE 11 /* Key repeat rate */
/* Console functions */
void aceConWrite (char* buf, size_t count);
void aceConPutLit (int c);
void aceConPos (unsigned x, unsigned y);
void aceConGetPos (unsigned* x, unsigned* y);
void __cdecl__ aceConWrite (char* buf, size_t count);
void __cdecl__ aceConPutLit (int c);
void __cdecl__ aceConPos (unsigned x, unsigned y);
void __cdecl__ aceConGetPos (unsigned* x, unsigned* y);
unsigned aceConGetX (void);
unsigned aceConGetY (void);
char* aceConInput (char* buf, unsigned initial);
char __cdecl__* aceConInput (char* buf, unsigned initial);
int aceConStopKey (void);
aceKey aceConGetKey (void);
int aceConKeyAvail (aceKey* key);
void aceConKeyMat (char* matrix);
void aceConSetOpt (unsigned char opt, unsigned char val);
int aceConGetOpt (unsigned char opt);
int __cdecl__ aceConKeyAvail (aceKey* key);
void __cdecl__ aceConKeyMat (char* matrix);
void __cdecl__ aceConSetOpt (unsigned char opt, unsigned char val);
int __cdecl__ aceConGetOpt (unsigned char opt);
/* Misc stuff */
int aceMiscIoPeek (unsigned addr);
void aceMiscIoPoke (unsigned addr, unsigned char val);
int __cdecl__ aceMiscIoPeek (unsigned addr);
void __cdecl__ aceMiscIoPoke (unsigned addr, unsigned char val);

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -42,7 +42,7 @@
#ifdef NDEBUG
# define assert(expr)
#else
extern void _afailed (const char*, unsigned);
extern void __fastcall__ _afailed (const char*, unsigned);
# define assert(expr) ((expr)? (void)0 : _afailed(__FILE__, __LINE__))
#endif

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* (C) 1998-2015, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@ -222,7 +222,7 @@ void cbm_k_unlsn (void);
unsigned int cbm_load (const char* name, unsigned char device, void* data);
unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void* data);
/* Loads file "name", from given device, to given address -- or, to the load
** address of the file if "data" is the null pointer (like load"name",8,1
** in BASIC).

View File

@ -77,6 +77,10 @@
# include <lynx.h>
#elif defined(__NES__)
# include <nes.h>
#elif defined(__OSIC1P__)
# include <osic1p.h>
#elif defined(__PCE__)
# include <pce.h>
#endif

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2000, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -88,7 +88,7 @@ unsigned __fastcall__ DbgDisAsmLen (unsigned Addr);
int __fastcall__ DbgIsRAM (unsigned Addr);
/* Return true if we can read and write the given address */
char* DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
char* __cdecl__ DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
/* Create a line of a memory dump in the given buffer. The buffer contains
** the starting address (4 digits hex), then Len bytes in this format:
** "AAAA__XX_YY_ZZ_...". The passed char buffer must hold Len*3+5 bytes

View File

@ -2,7 +2,7 @@
/* */
/* lynx.h */
/* */
/* Lynx system specific definitions */
/* Lynx system-specific definitions */
/* */
/* */
/* */
@ -109,25 +109,25 @@ extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
/* Sound support */
/*****************************************************************************/
void lynx_snd_init ();
void lynx_snd_init (void);
/* Initialize the sound driver */
void lynx_snd_pause ();
void lynx_snd_pause (void);
/* Pause sound */
void lynx_snd_continue ();
void lynx_snd_continue (void);
/* Continue sound after pause */
void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
/* Play tune on channel */
void lynx_snd_stop ();
void lynx_snd_stop (void);
/* Stop sound on all channels */
void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
/* Stop sound on all channels */
unsigned char lynx_snd_active();
unsigned char lynx_snd_active(void);
/* Show which channels are active */
/*****************************************************************************/

View File

@ -122,6 +122,16 @@ struct mouse_callbacks {
/* The default mouse callbacks */
extern const struct mouse_callbacks mouse_def_callbacks;
#if defined(__CBM__)
/* The default mouse pointer shape used by the default mouse callbacks */
extern const unsigned char mouse_def_pointershape[63];
/* The default mouse pointer color used by the default mouse callbacks */
extern const unsigned char mouse_def_pointercolor;
#endif
/* The name of the standard mouse driver for a platform */
extern const char mouse_stddrv[];
@ -208,6 +218,3 @@ unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
/* End of mouse.h */
#endif

View File

@ -90,7 +90,72 @@
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
/* The joystick keys - all keys are supported */
#define KEY_A 0x01
#define KEY_B 0x02
#define KEY_SELECT 0x04
#define KEY_START 0x08
#define KEY_UP 0x10
#define KEY_DOWN 0x20
#define KEY_LEFT 0x40
#define KEY_RIGHT 0x80
/* Define hardware */
/* Picture Processing Unit */
struct __ppu {
unsigned char control;
unsigned char mask; /* color; show sprites, background */
signed char volatile const status;
struct {
unsigned char address;
unsigned char data;
} sprite;
unsigned char scroll;
struct {
unsigned char address;
unsigned char data;
} vram;
};
#define PPU (*(struct __ppu*)0x2000)
#define SPRITE_DMA (APU.sprite.dma)
/* Audio Processing Unit */
struct __apu {
struct {
unsigned char control; /* duty, counter halt, volume/envelope */
unsigned char ramp;
unsigned char period_low; /* timing */
unsigned char len_period_high; /* length, timing */
} pulse[2];
struct {
unsigned char counter; /* counter halt, linear counter */
unsigned char unused;
unsigned char period_low; /* timing */
unsigned char len_period_high; /* length, timing */
} triangle;
struct {
unsigned char control; /* counter halt, volume/envelope */
unsigned char unused;
unsigned char period; /* loop, timing */
unsigned char len; /* length */
} noise;
struct {
unsigned char control; /* IRQ, loop, rate */
unsigned char output; /* output value */
unsigned char address;
unsigned char length;
} delta_mod; /* delta pulse-code modulation */
struct {
unsigned char dma;
} sprite;
signed char volatile status;
unsigned char unused;
unsigned char fcontrol;
};
#define APU (*(struct __apu*)0x4000)
#define JOYPAD ((unsigned char volatile[2])0x4016)
/* The addresses of the static drivers */
extern void nes_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */

47
include/osic1p.h Normal file
View File

@ -0,0 +1,47 @@
/*****************************************************************************/
/* */
/* osic1p.h */
/* */
/* Challenger 1P system specific definitions */
/* */
/* */
/* */
/* (C) 2015 Stephan Muehlstrasser */
/* */
/* */
/* 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 _OSIC1P_H
#define _OSIC1P_H
/* Check for errors */
#if !defined(__OSIC1P__)
# error "This module may only be used when compiling for the Challenger 1P!"
#endif
/* 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.
*/
#define _textcolor(color) COLOR_WHITE
#define _bgcolor(color) COLOR_BLACK
#define _bordercolor(color) COLOR_BLACK
#endif

94
include/pce.h Normal file
View File

@ -0,0 +1,94 @@
/*****************************************************************************/
/* */
/* pce.h */
/* */
/* PC-Engine system specific definitions */
/* */
/* */
/* */
/* (C) 2015 Groepaz/Hitmen */
/* */
/* */
/* 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 _PCE_H
#define _PCE_H
/* Check for errors */
#if !defined(__PCE__)
# error This module may only be used when compiling for the PCE!
#endif
#define CH_HLINE 1
#define CH_VLINE 2
#define CH_CROSS 3
#define CH_ULCORNER 4
#define CH_URCORNER 5
#define CH_LLCORNER 6
#define CH_LRCORNER 7
#define CH_TTEE 8
#define CH_BTEE 9
#define CH_LTEE 10
#define CH_RTEE 11
#define CH_ENTER 13
#define CH_PI 18
/* Color defines (CBM compatible, for conio) */
#define COLOR_BLACK 0x00
#define COLOR_WHITE 0x01
#define COLOR_RED 0x02
#define COLOR_CYAN 0x03
#define COLOR_VIOLET 0x04
#define COLOR_GREEN 0x05
#define COLOR_BLUE 0x06
#define COLOR_YELLOW 0x07
#define COLOR_ORANGE 0x08
#define COLOR_BROWN 0x09
#define COLOR_LIGHTRED 0x0A
#define COLOR_GRAY1 0x0B
#define COLOR_GRAY2 0x0C
#define COLOR_LIGHTGREEN 0x0D
#define COLOR_LIGHTBLUE 0x0E
#define COLOR_GRAY3 0x0F
#define TV_NTSC 0
#define TV_PAL 1
#define TV_OTHER 2
/* No support for dynamically loadable drivers */
#define DYN_DRV 0
/* The addresses of the static drivers */
extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
#define JOY_FIRE_B 5
#define JOY_SELECT 6
#define JOY_RUN 7
void waitvblank (void);
/* Wait for the vertical blanking */
/* NOTE: all PCE are NTSC */
#define get_tv() TV_NTSC
/* Return the video mode the machine is using. */
/* End of pce.h */
#endif

View File

@ -107,12 +107,12 @@ int __fastcall__ atoi (const char* s);
long __fastcall__ atol (const char* s);
int __fastcall__ atexit (void (*exitfunc) (void));
void* __fastcall__ bsearch (const void* key, const void* base, size_t n,
size_t size, int (*cmp) (const void*, const void*));
size_t size, int __fastcall__ (* cmp) (const void*, const void*));
div_t __fastcall__ div (int numer, int denom);
void __fastcall__ exit (int ret) __attribute__ ((noreturn));
char* __fastcall__ getenv (const char* name);
void __fastcall__ qsort (void* base, size_t count, size_t size,
int (*compare) (const void*, const void*));
int __fastcall__ (* compare) (const void*, const void*));
long __fastcall__ strtol (const char* nptr, char** endptr, int base);
unsigned long __fastcall__ strtoul (const char* nptr, char** endptr, int base);
int __fastcall__ system (const char* s);

View File

@ -99,6 +99,9 @@ unsigned _clocks_per_sec (void);
#elif defined(__NES__)
# define CLK_TCK 50 /* POSIX */
# define CLOCKS_PER_SEC 50 /* ANSI */
#elif defined(__PCE__)
# define CLK_TCK 60 /* POSIX */
# define CLOCKS_PER_SEC 60 /* ANSI */
#elif defined(__GEOS__)
# define CLK_TCK 1 /* POSIX */
# define CLOCKS_PER_SEC 1 /* ANSI */

View File

@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 2000-2001 Piotr Fusik <fox@scene.pl> */
/* (C) 2000-2015 Piotr Fusik <fox@scene.pl> */
/* */
/* This file is based on the zlib.h from 'zlib' general purpose compression */
/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */
@ -83,8 +83,8 @@ unsigned __fastcall__ inflatemem (char* dest, const char* source);
*/
int uncompress (char* dest, unsigned* destLen,
const char* source, unsigned sourceLen);
int __fastcall__ uncompress (char* dest, unsigned* destLen,
const char* source, unsigned sourceLen);
/*
Original zlib description:

View File

@ -24,6 +24,8 @@ TARGETS = apple2 \
$(GEOS) \
lynx \
nes \
osic1p \
pce \
sim6502 \
sim65c02 \
supervision

View File

@ -11,7 +11,7 @@
.import callmain
.import __LC_START__, __LC_LAST__ ; Linker generated
.import __INIT_RUN__, __INIT_SIZE__ ; Linker generated
.import __ZPSAVE_RUN__ ; Linker generated
.import __INITBSS_RUN__ ; Linker generated
.include "zeropage.inc"
.include "apple2.inc"
@ -29,14 +29,14 @@
bit $C081
; Set the source start address.
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $9B
sty $9C
; Set the source last address.
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
lda #<(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
sta $96
sty $97
@ -46,19 +46,19 @@
sta $94
sty $95
; Call into the Applesoft Block Transfer Utility -- which handles zero-
; Call into Applesoft Block Transfer Up -- which handles zero-
; sized blocks well -- to move the content of the LC memory area.
jsr $D396 ; BLTU + 3
jsr $D39A ; BLTU2
; Set the source start address.
lda #<__ZPSAVE_RUN__
ldy #>__ZPSAVE_RUN__
lda #<__INITBSS_RUN__
ldy #>__INITBSS_RUN__
sta $9B
sty $9C
; Set the source last address.
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $96
sty $97
@ -68,9 +68,9 @@
sta $94
sty $95
; Call into the Applesoft Block Transfer Utility -- which handles moving
; Call into Applesoft Block Transfer Up -- which handles moving
; overlapping blocks upwards well -- to move the INIT segment.
jsr $D396 ; BLTU + 3
jsr $D39A ; BLTU2
; Delegate all further processing, to keep the STARTUP segment small.
jsr init
@ -164,10 +164,6 @@ basic: lda HIMEM
: sta sp
stx sp+1
; Enable interrupts, as old ProDOS versions (i.e. 1.1.1)
; jump to SYS and BIN programs with interrupts disabled.
cli
; Call the module constructors.
jsr initlib
@ -205,7 +201,7 @@ q_param:.byte $04 ; param_count
; Final jump when we're done
done: jmp DOSWARM ; Potentially patched at runtime
.segment "ZPSAVE"
.segment "INITBSS"
zpsave: .res zpspace

View File

@ -23,11 +23,29 @@ oserr: jsr popname ; Preserves A
jmp __mappederrno
_exec:
; Save cmdline
sta ptr4
stx ptr4+1
; Get and push name
jsr popax
jsr pushname
bne oserr
; ProDOS TechRefMan, chapter 5.1.5.1:
; "The complete or partial pathname of the system program
; is stored at $280, starting with a length byte."
; In fact BASIC.SYSTEM does the same for BLOAD and BRUN of
; binary programs so we should do the same too in any case
; especially as _we_ rely on it in mainargs.s for argv[0]
ldy #$00
lda (sp),y
tay
: lda (sp),y
sta $0280,y
dey
bpl :-
; Set pushed name
lda sp
ldx sp+1
@ -52,24 +70,14 @@ _exec:
lda mliparam + MLI::INFO::FILE_TYPE
cmp #$FF ; SYS file?
bne binary ; No, check for BIN file
sta file_type ; Save file type for cmdline handling
; ProDOS TechRefMan, chapter 5.1.5.1:
; "The complete or partial pathname of the system program
; is stored at $280, starting with a length byte."
ldy #$00
lda (sp),y
tay
: lda (sp),y
sta $0280,y
dey
bpl :-
; SYS programs replace BASIC.SYSTEM so set in the ProDOS system bit map
; protection for pages $80 - $BF just in case BASIC.SYSTEM is there now
ldx #$0F ; Start with protection for pages $B8 - $BF
lda #%00000001 ; Protect only system global page
: sta $BF60,x ; Set protection for 8 pages
lda #$00 ; Protect no page
lda #%00000000 ; Protect no page
dex
bpl :-
bmi prodos ; Branch always
@ -112,7 +120,7 @@ setbuf: lda #$00 ; Low byte
dex
dex
dex
; Set I/O buffer
sta mliparam + MLI::OPEN::IO_BUFFER
stx mliparam + MLI::OPEN::IO_BUFFER+1
@ -126,7 +134,7 @@ setbuf: lda #$00 ; Low byte
stx level
beq :+
dec LEVEL
; Open file
: lda #OPEN_CALL
ldx #OPEN_COUNT
@ -158,8 +166,27 @@ setbuf: lda #$00 ; Low byte
bit $C080
.endif
; Reset stack as we already passed
; the point of no return anyway
ldx #$FF
txs
; Store up to 127 chars of cmdline (if any)
; including terminating zero in stack page
ldy #$00
lda ptr4+1 ; NULL?
beq :++ ; Yes, store as '\0'
: lda (ptr4),y
: sta $0100,y
beq :+ ; '\0' stored, done
iny
cpy #$7E
bcc :--
lda #$00 ; '\0'
beq :- ; Branch always
; Call loader stub after C libary shutdown
lda #<target
: lda #<target
ldx #>target
sta done+1
stx done+2
@ -177,16 +204,58 @@ level : .res 1
source: jsr $BF00
.byte READ_CALL
.word read_param
bcs :+
bcs error
; Close program file
jsr $BF00
.byte CLOSE_CALL
.word close_param
bcs :+
bcs error
; Check for cmdline handling
lda $0100 ; Valid cmdline?
beq jump ; No, jump to program right away
ldx file_type ; SYS file?
bne system ; Yes, check for startup filename
; Store REM and cmdline in BASIC input buffer
lda #$B2 ; REM token
bne :++ ; Branch always
: inx
lda a:$0100-1,x
: sta $0200,x
bne :--
beq jump ; Branch always
; Check for startup filename support
; ProDOS TechRefMan, chapter 5.1.5.1:
; "$2000 is a jump instruction. $2003 and $2004 are $EE."
system: lda $2000
cmp #$4C
bne jump
lda $2003
cmp #$EE
bne jump
lda $2004
cmp #$EE
bne jump
; Store cmdline in startup filename buffer
ldx #$01
: lda a:$0100-1,x
beq :+
sta $2006,x
inx
cpx $2005 ; Buffer full?
bcc :- ; No, continue
: dex
stx $2006 ; Store cmdline length
; Go for it ...
jmp (data_buffer)
jump: jmp (data_buffer)
file_type = * - source + target
.byte $00
read_param = * - source + target
.byte $04 ; PARAM_COUNT
@ -204,7 +273,7 @@ close_ref = * - source + target
; Quit to ProDOS dispatcher
quit = * - source + target
: jsr $BF00
error: jsr $BF00
.byte $65 ; QUIT
.word quit_param

View File

@ -21,20 +21,21 @@ initcwd:
jsr callmli
; Check for null prefix
lda __cwd
ldx __cwd
beq done
; Remove length byte and trailing slash
sta tmp1
ldx #$01
: lda __cwd,x
sta __cwd - 1,x
dex
stx tmp1
ldx #$00
: lda __cwd + 1,x
sta __cwd,x
inx
cpx tmp1
bcc :-
; Add terminating zero
lda #$00
sta __cwd - 1,x
sta __cwd,x
done: rts

View File

@ -21,6 +21,10 @@ initirq:
.byte $40 ; Alloc interrupt
.addr i_param
bcs prterr
; Enable interrupts, as old ProDOS versions (i.e. 1.1.1)
; jump to SYS and BIN programs with interrupts disabled.
cli
rts
; Print error message and exit

View File

@ -34,12 +34,12 @@
MAXARGS = 10
; ProDOS stores the filename in the second half of BASIC's input buffer, so
; there are 128 characters left. At least 7 characters are necessary for the
; CALLxxxx:REM so 121 characters may be used before overwriting the ProDOS
; filename. As we don't want to put further restrictions on the command-line
; length we reserve those 121 characters terminated by a zero.
; there are 128 characters left. At least 1 character is necessary for the
; REM so 127 characters (including the terminating zero) may be used before
; overwriting the ProDOS filename. As we don't want to further restrict the
; command-line length we reserve those 127 characters.
BUF_LEN = 122
BUF_LEN = 127
BASIC_BUF = $200
FNAM_LEN = $280
@ -176,4 +176,4 @@ argv: .addr FNAM
.bss
buffer: .res BUF_LEN
buffer: .res BUF_LEN

View File

@ -22,14 +22,14 @@ READ_CALL = $CA
CLOSE_CALL = $CC
FILE_NOT_FOUND_ERR = $46
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ------------------------------------------------------------------------
.import __CODE_0300_SIZE__, __DATA_0300_SIZE__
.import __CODE_0300_LOAD__, __CODE_0300_RUN__
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ------------------------------------------------------------------------
.segment "DATA_2000"
.segment "DATA_2000"
GET_FILE_INFO_PARAM:
.byte $0A ;PARAM_COUNT
@ -57,9 +57,9 @@ LOADING:
ELLIPSES:
.byte " ...", $0D, $0D, $00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ------------------------------------------------------------------------
.segment "DATA_0300"
.segment "DATA_0300"
READ_PARAM:
.byte $04 ;PARAM_COUNT
@ -81,22 +81,22 @@ QUIT_PARAM:
FILE_NOT_FOUND:
.asciiz "... File Not Found"
ERROR_NUMBER:
.asciiz "... Error $"
PRESS_ANY_KEY:
.asciiz " - Press Any Key "
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ------------------------------------------------------------------------
.segment "CODE_2000"
.segment "CODE_2000"
jmp :+
.byte $EE
.byte $EE
.byte 65
STARTUP:.res 65
.byte $7F
STARTUP:.res $7F
; Reset stack
: ldx #$FF
@ -104,8 +104,8 @@ STARTUP:.res 65
; Relocate CODE_0300 and DATA_0300
ldx #<(__CODE_0300_SIZE__ + __DATA_0300_SIZE__)
: lda __CODE_0300_LOAD__ - 1,x
sta __CODE_0300_RUN__ - 1,x
: lda __CODE_0300_LOAD__-1,x
sta __CODE_0300_RUN__-1,x
dex
bne :-
@ -118,23 +118,23 @@ STARTUP:.res 65
; Add trailing '\0' to pathname
tax
lda #$00
sta PATHNAME + 1,x
sta PATHNAME+1,x
; Copy ProDOS startup filename and trailing '\0' to stack
ldx STARTUP
lda #$00
beq :++ ; bra
: lda STARTUP + 1,x
beq :++ ; Branch always
: lda STARTUP+1,x
: sta STACK,x
dex
bpl :--
bpl :--
; Provide some user feedback
lda #<LOADING
ldx #>LOADING
jsr PRINT
lda #<(PATHNAME + 1)
ldx #>(PATHNAME + 1)
lda #<(PATHNAME+1)
ldx #>(PATHNAME+1)
jsr PRINT
lda #<ELLIPSES
ldx #>ELLIPSES
@ -159,16 +159,16 @@ STARTUP:.res 65
; Get load address from aux-type
lda FILE_INFO_ADDR
ldx FILE_INFO_ADDR + 1
ldx FILE_INFO_ADDR+1
sta READ_ADDR
stx READ_ADDR + 1
stx READ_ADDR+1
; It's high time to leave this place
jmp __CODE_0300_RUN__
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ------------------------------------------------------------------------
.segment "CODE_0300"
.segment "CODE_0300"
jsr MLI
.byte READ_CALL
@ -180,15 +180,15 @@ STARTUP:.res 65
.word CLOSE_PARAM
bcs ERROR
; Copy REM token and startup filename to BASIC input buffer
; Copy REM and startup filename to BASIC input buffer
ldx #$00
lda #$B2
bne :++ ; bra
lda #$B2 ; REM token
bne :++ ; Branch always
: inx
lda a:STACK - 1,x
lda a:STACK-1,x
: sta BUF,x
bne :--
; Go for it ...
jmp (READ_ADDR)
@ -207,7 +207,7 @@ PRINT:
: ora #$80
jsr COUT
iny
bne :-- ; bra
bne :-- ; Branch always
: rts
ERROR:
@ -216,7 +216,7 @@ ERROR:
lda #<FILE_NOT_FOUND
ldx #>FILE_NOT_FOUND
jsr PRINT
beq :++ ; bra
beq :++ ; Branch always
: pha
lda #<ERROR_NUMBER
ldx #>ERROR_NUMBER
@ -230,5 +230,3 @@ ERROR:
jsr MLI
.byte QUIT_CALL
.word QUIT_PARAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -5,7 +5,7 @@
;
.include "atari.inc"
.constructor detect,26
.constructor detect, 26
.export __dos_type
; ------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@ SPACE = 32 ; SPACE char.
.import __argc, __argv
.importzp ptr1
.import __dos_type
.constructor initmainargs,25
.constructor initmainargs, 25
; --------------------------------------------------------------------------
; Get command line

View File

@ -19,7 +19,7 @@
.export __getdefdev ; get default device
.export __defdev ; this is the default device string (e.g. "D1:")
.ifdef DYNAMIC_DD
.constructor __getdefdev,24
.constructor __getdefdev, 24
.endif
; Get default device (LBUF will be destroyed!!)

View File

@ -9,6 +9,8 @@
.proc initcwd
lda #0
sta __cwd
jsr findfreeiocb
bne oserr
lda #GETCWD
@ -19,13 +21,13 @@
sta ICBLH,x
jsr CIOV
bmi oserr
ldx #0 ; ATEOL -> \0
: lda __cwd,x
inx
ldx #$FF ; ATEOL -> \0
: inx
lda __cwd,x
cmp #ATEOL
bne :-
lda #0
sta __cwd-1,x
sta __cwd,x
oserr: rts
.endproc

View File

@ -10,8 +10,8 @@
.include "atari.inc"
.importzp sp
.export _mouse_pm_callbacks
.constructor pm_init,27
.destructor pm_down,7
.constructor pm_init, 27
.destructor pm_down
; get mouse shape data
.import mouse_pm_bits

View File

@ -7,9 +7,10 @@
SCREEN_BUF_SIZE = 20 * 24
SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
.code
.export screen_setup_20x24
.segment "INIT"
screen_setup_20x24:
; initialize SAVMSC
@ -79,5 +80,4 @@ dlist: .repeat 3
.assert ((* >> 10) = (dlist >> 10)), error, "Display list crosses 1K boundary"
.end

24
libsrc/atmos/bashdr.s Normal file
View File

@ -0,0 +1,24 @@
;
; 2010-11-14, Ullrich von Bassewitz
; 2014-09-06, Greg King
;
; This module supplies a small BASIC stub program that uses CALL
; to jump to the machine-language code that follows it.
;
; The following symbol is used by the linker config. file
; to force this module to be included into the output file.
.export __BASHDR__:abs = 1
.segment "BASHDR"
.addr Next
.word .version ; Line number
.byte $BF,'#' ; CALL token, mark number as hexadecimal
.byte <(Start >> 8 ) + '0' + (Start >> 8 > $09) * $07
.byte <(Start >> 4 & $0F) + '0' + (Start >> 4 & $0F > $09) * $07
.byte <(Start & $0F) + '0' + (Start & $0F > $09) * $07
.byte $00 ; End of BASIC line
Next: .addr $0000 ; BASIC program end marker
Start:

View File

@ -2,39 +2,18 @@
; Startup code for cc65 (Oric version)
;
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
; 2014-08-22, Greg King
; 2015-01-09, Greg King
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import callmain, zerobss
.import __RAM_START__, __RAM_SIZE__
.import __ZPSAVE_LOAD__, __STACKSIZE__
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.include "zeropage.inc"
.include "atmos.inc"
; ------------------------------------------------------------------------
; Oric tape header
.segment "TAPEHDR"
.byte $16, $16, $16 ; Sync bytes
.byte $24 ; End of header marker
.byte $00 ; $2B0
.byte $00 ; $2AF
.byte $80 ; $2AE Machine code flag
.byte $C7 ; $2AD Autoload flag
.dbyt __ZPSAVE_LOAD__ - 1 ; $2AB
.dbyt __RAM_START__ ; $2A9
.byte $00 ; $2A8
.byte ((.VERSION >> 8) & $0F) + '0'
.byte ((.VERSION >> 4) & $0F) + '0'
.byte (.VERSION & $0F) + '0'
.byte $00 ; Zero terminated compiler version
; ------------------------------------------------------------------------
; Place the startup code in a special segment.
@ -52,7 +31,8 @@ L1: lda sp,x
jsr zerobss
; Unprotect screen columns 0 and 1.
; Currently, color isn't supported on the text screen.
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
lda STATUS
sta stsave
@ -79,7 +59,7 @@ L1: lda sp,x
; Call the module destructors. This is also the exit() entry.
_exit: jsr donelib ; Run module destructors
_exit: jsr donelib
; Restore the system stuff.
@ -102,9 +82,23 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
.segment "ZPSAVE"
.segment "ZPSAVE1"
zpsave: .res zpspace
zpsave:
; This padding is needed by a bug in the ROM.
; (The CLOAD command starts BASIC's variables table on top of the last byte
; that was loaded [instead of at the next address].)
; This is overlaid on a buffer, so that it doesn't use extra space in RAM.
.byte 0
; The segments "ZPSAVE1" and "ZPSAVE2" always must be together.
; They create a single object (the zpsave buffer).
.segment "ZPSAVE2"
.res zpspace - 1
; ------------------------------------------------------------------------

31
libsrc/atmos/tapehdr.s Normal file
View File

@ -0,0 +1,31 @@
;
; Based on code by Debrune Jérôme <jede@oric.org>
; 2015-01-08, Greg King
;
; The following symbol is used by the linker config. file
; to force this module to be included into the output file.
.export __TAPEHDR__:abs = 1
; These symbols, also, come from the configuration file.
.import __BASHDR_LOAD__, __ZPSAVE1_LOAD__, __AUTORUN__, __PROGFLAG__
; ------------------------------------------------------------------------
; Oric cassette-tape header
.segment "TAPEHDR"
.byte $16, $16, $16 ; Sync bytes
.byte $24 ; Beginning-of-header marker
.byte $00 ; $2B0
.byte $00 ; $2AF
.byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
.byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
.dbyt __ZPSAVE1_LOAD__ ;$2AB Address of end of file
.dbyt __BASHDR_LOAD__ ; $2A9 Address of start of file
.byte $00 ; $2A8
; File name (a maximum of 17 characters), zero-terminated
.asciiz .sprintf("%u", .time)

View File

@ -108,7 +108,7 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
; Data
.segment "ZPSAVE"
.segment "INITBSS"
zpsave: .res zpspace

View File

@ -51,7 +51,7 @@ PAGES = (TOPMEM - BASE) / 256
; Data.
.bss
curpage: .res 1 ; Current page number
curpage: .res 2 ; Current page number
window: .res 256 ; Memory "window"
@ -70,7 +70,7 @@ INSTALL:
stx curpage+1 ; Invalidate the current page
inx
txa ; A = X = EM_ERR_OK
rts
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
@ -107,6 +107,7 @@ MAP: sta curpage
lda #<ptr1
sta FETVEC
sei
; Transfer one page
@ -115,6 +116,7 @@ MAP: sta curpage
sta window,y
iny
bne @L1
cli
; Return the memory window
@ -146,6 +148,7 @@ COMMIT: lda curpage ; Get the current page
lda #<ptr1
sta STAVEC
sei
; Transfer one page. Y must be zero on entry
@ -154,6 +157,7 @@ COMMIT: lda curpage ; Get the current page
jsr STASH
iny
bne @L1
cli
; Done
@ -196,6 +200,7 @@ COPYFROM:
; Copy full pages
ldy #$00
sei
@L1: ldx #MMU_CFG_RAM1
jsr FETCH
sta (ptr2),y
@ -223,7 +228,8 @@ COPYFROM:
; Done
@L4: rts
@L4: cli
rts
; ------------------------------------------------------------------------
; COPYTO: Copy from linear into extended memory. A pointer to a structure
@ -261,6 +267,7 @@ COPYTO: sta ptr3
; Copy full pages
ldy #$00
sei
@L1: lda (ptr2),y
ldx #MMU_CFG_RAM1
jsr STASH
@ -288,5 +295,5 @@ COPYTO: sta ptr3
; Done
@L4: rts
@L4: cli
rts

View File

@ -30,8 +30,7 @@
MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; which may be reused after the startup code is run
@ -42,26 +41,26 @@ initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD
; statement. Save the "most-recent filename" as argument #0.
; Because the buffer, that we're copying into, was zeroed out,
; we don't need to add a NUL character.
;
lda #0 ; The terminating NUL character
ldy FNAM_LEN
cpy #NAME_LEN + 1
bcc L1
ldy #NAME_LEN - 1 ; limit the length
ldy #NAME_LEN ; Limit the length
bne L1 ; Branch always
L0: lda #FNAM ; Load vector address for FETCH routine
ldx FNAM_BANK ; Load bank for FETCH routine
jsr INDFET ; Load byte from (FETVEC),y
sta name,y ; Save byte from filename
L1: dey
L1: sta name,y ; Save byte from filename
dey
bpl L0
inc __argc ; argc always is equal to, at least, 1
; Find the "rem" token.
;
ldx #0
L2: lda BASIC_BUF,x
beq done ; no "rem," no args.
beq done ; No "rem," no args.
inx
cmp #REM
bne L2
@ -73,7 +72,7 @@ next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
beq next
; Found start of next argument. We've incremented the pointer in X already, so
; it points to the second character of the argument. This is useful since we
@ -128,15 +127,13 @@ done: lda #<argv
stx __argv + 1
rts
; These arrays are zeroed before initmainargs is called.
; char name[16+1];
; char* argv[MAXARGS+1]={name};
;
.bss
.segment "INITBSS"
term: .res 1
name: .res NAME_LEN + 1
.data
; char* argv[MAXARGS+1]={name};
argv: .addr name
.res MAXARGS * 2

View File

@ -7,7 +7,10 @@
; be called from an interrupt handler
;
.constructor initmcb
.export _mouse_def_callbacks
.import _mouse_def_pointershape
.import _mouse_def_pointercolor
.include "mouse-kernel.inc"
.include "c128.inc"
@ -15,16 +18,45 @@
.macpack generic
; Sprite definitions. The first value can be changed to adjust the number
; of the sprite used for the mouse.
; of the sprite used for the mouse. All others depend on this value.
MOUSE_SPR = 0 ; Sprite used for the mouse
MOUSE_SPR_MEM = $0E00 ; Memory location
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
initmcb:
; Copy the mouse sprite data
ldx #64 - 1
@L0: lda _mouse_def_pointershape,x
sta MOUSE_SPR_MEM,x
dex
bpl @L0
; Set the mouse sprite pointer
lda #<(MOUSE_SPR_MEM / 64)
sta $07F8 + MOUSE_SPR
; Set the mouse sprite color
lda _mouse_def_pointercolor
sta VIC_SPR0_COLOR + MOUSE_SPR
rts
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
.code
hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 05.11.2002
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
; void _randomize (void);
; /* Initialize the random number generator */
@ -12,6 +13,6 @@
__randomize:
ldx VIC_HLINE ; Use VIC rasterline as high byte
lda TIME ; Use 60HZ clock as low byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator

View File

@ -63,6 +63,7 @@ BCD2dec:tax
; Constructor that writes to the 1/10 sec register of the TOD to kick it
; into action. If this is not done, the clock hangs. We will read the register
; and write it again, ignoring a possible change in between.
.segment "INIT"
.proc initsystime
@ -78,7 +79,6 @@ BCD2dec:tax
.endproc
;----------------------------------------------------------------------------
; TM struct with date set to 1970-01-01
.data
@ -92,4 +92,3 @@ TM: .word 0 ; tm_sec
.word 0 ; tm_wday
.word 0 ; tm_yday
.word 0 ; tm_isdst

View File

@ -90,7 +90,7 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
.segment "ZPSAVE"
.segment "INITBSS"
zpsave: .res zpspace

View File

@ -28,10 +28,9 @@
.include "plus4.inc"
MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; which may be reused after the startup code is run
@ -42,25 +41,25 @@ initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD
; statement. Save the "most-recent filename" as argument #0.
; Because the buffer, that we're copying into, was zeroed out,
; we don't need to add a NUL character.
;
lda #0 ; The terminating NUL character
ldy FNAM_LEN
cpy #NAME_LEN + 1
bcc L1
ldy #NAME_LEN - 1 ; limit the length
ldy #NAME_LEN ; Limit the length
bne L1 ; Branch always
L0: lda #FNAM ; Vector address
jsr FETCH ; Load byte from RAM
sta name,y
L1: dey
L1: sta name,y
dey
bpl L0
inc __argc ; argc always is equal to, at least, 1
; Find the "rem" token.
;
ldx #0
L2: lda BASIC_BUF,x
beq done ; no "rem," no args.
beq done ; No "rem," no args.
inx
cmp #REM
bne L2
@ -72,7 +71,7 @@ next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
beq next
; Found start of next argument. We've incremented the pointer in X already, so
; it points to the second character of the argument. This is useful since we
@ -127,15 +126,13 @@ done: lda #<argv
stx __argv + 1
rts
; These arrays are zeroed before initmainargs is called.
; char name[16+1];
; char* argv[MAXARGS+1]={name};
;
.bss
.segment "INITBSS"
term: .res 1
name: .res NAME_LEN + 1
.data
; char* argv[MAXARGS+1]={name};
argv: .addr name
.res MAXARGS * 2

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 05.11.2002
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
; void _randomize (void);
; /* Initialize the random number generator */
@ -12,6 +13,6 @@
__randomize:
ldx TED_VLINELO ; Use TED rasterline as high byte
lda TIME ; Use 60HZ clock as low byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator

17
libsrc/c64/bordercolor.s Normal file
View File

@ -0,0 +1,17 @@
;
; Ullrich von Bassewitz, 06.08.1998
;
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _bordercolor
.include "c64.inc"
_bordercolor:
ldx VIC_BORDERCOLOR ; get old value
sta VIC_BORDERCOLOR ; set new value
txa
rts

View File

@ -3,11 +3,10 @@
;
; unsigned char __fastcall__ textcolor (unsigned char color);
; unsigned char __fastcall__ bgcolor (unsigned char color);
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.export _textcolor, _bgcolor
.include "c64.inc"
@ -23,11 +22,3 @@ _bgcolor:
sta VIC_BG_COLOR0 ; set new value
txa
rts
_bordercolor:
ldx VIC_BORDERCOLOR ; get old value
sta VIC_BORDERCOLOR ; set new value
txa
rts

View File

@ -4,12 +4,12 @@
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import zerobss
.import callmain
.import RESTOR, BSOUT, CLRCH
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.import moveinit, zerobss, callmain
.import BSOUT
.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated
.import __STACKSIZE__ ; from configure file
.importzp ST
.include "zeropage.inc"
@ -23,14 +23,6 @@
Start:
; Save the zero-page locations that we need.
ldx #zpspace-1
L1: lda sp,x
sta zpsave,x
dex
bpl L1
; Switch to the second charset.
lda #14
@ -39,31 +31,34 @@ L1: lda sp,x
; Switch off the BASIC ROM.
lda $01
pha ; Remember the value
sta mmusave ; Save the memory configuration
and #$F8
ora #$06 ; Enable Kernal+I/O, disable BASIC
sta $01
; Clear the BSS data.
jsr zerobss
; Save some system settings; and, set up the stack.
pla
sta mmusave ; Save the memory configuration
tsx
stx spsave ; Save the system stack ptr
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1 ; Set argument stack ptr
; Allow some re-entrancy by skipping the next task if it already was done.
; This sometimes can let us rerun the program without reloading it.
; Call the module constructors.
ldx move_init
beq L0
jsr initlib
; Move the INIT segment from where it was loaded (over the bss segments)
; into where it must be run (over the BSS segment).
jsr moveinit
dec move_init ; Set to false
; Save space by putting some of the start-up code in the INIT segment,
; which can be re-used by the BSS segment, the heap and the C stack.
L0: jsr runinit
; Clear the BSS data.
jsr zerobss
; Push the command-line arguments; and, call main().
@ -98,14 +93,47 @@ L2: lda zpsave,x
rts
; ------------------------------------------------------------------------
.segment "INIT"
runinit:
; Save the zero-page locations that we need.
ldx #zpspace-1
L1: lda sp,x
sta zpsave,x
dex
bpl L1
; Set up the stack.
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
sta sp
stx sp+1 ; Set argument stack ptr
; Call the module constructors.
jmp initlib
; ------------------------------------------------------------------------
; Data
.segment "ZPSAVE"
.data
; These two variables were moved out of the BSS segment, and into DATA, because
; we need to use them before INIT is moved off of BSS, and before BSS is zeroed.
mmusave:.res 1
spsave: .res 1
move_init:
.byte 1
.segment "INITBSS"
zpsave: .res zpspace
.bss
spsave: .res 1
mmusave:.res 1

52
libsrc/c64/extra/soft80.s Normal file
View File

@ -0,0 +1,52 @@
;
; Groepaz/Hitmen, 12.10.2015
;
; import/overload stubs for the soft80 implementation
.include "../soft80.inc"
; soft80_cgetc.s
.import soft80_cgetc
.export _cgetc := soft80_cgetc ; cgetc.s
; soft80_color.s
.import soft80_textcolor
.import soft80_bgcolor
.export _textcolor := soft80_textcolor ; color.s
.export _bgcolor := soft80_bgcolor ; color.s
; soft80_cputc.s
.import soft80_cputc
.import soft80_cputcxy
.import soft80_cputdirect
.import soft80_putchar
.import soft80_newline
.import soft80_plot
.export _cputc := soft80_cputc ; cputc.s
.export _cputcxy := soft80_cputcxy ; cputc.s
.export cputdirect := soft80_cputdirect ; cputc.s
.export putchar := soft80_putchar ; cputc.s
.export newline := soft80_newline ; cputc.s
.export plot := soft80_plot ; cputc.s
; soft80_kclrscr.s
.import soft80_kclrscr
.export _clrscr := soft80_kclrscr ; clrscr.s
; soft80_kplot.s
.import soft80_kplot
.export PLOT := soft80_kplot ; kplot.s
; soft80_kscreen.s
.import soft80_screensize
.export screensize := soft80_screensize ; _scrsize.s
; FIXME: use _scrsize.s/remove soft80_scrsize.s
;.export SCREEN := soft80_screensize ; kernal func (kernal.s)
; VIC sprite data for the mouse pointer
.export mcb_spritememory := soft80_spriteblock
.export mcb_spritepointer := (soft80_vram + $03F8)
; Chars used by chline () and cvline ()
.exportzp chlinechar = CH_HLINE
.exportzp cvlinechar = CH_VLINE

View File

@ -0,0 +1,55 @@
;
; Groepaz/Hitmen, 19.10.2015
;
; import/overload stubs for the monochrome soft80 implementation
;
; - optimized for size, almost 1k smaller footprint than the full color version
; - textcolor() sets one common text color for the whole screen
;
.include "../soft80.inc"
; soft80mono_cgetc.s
.import soft80mono_cgetc
.export _cgetc := soft80mono_cgetc ; cgetc.s
; soft80mono_color.s
.import soft80mono_textcolor
.import soft80mono_bgcolor
.export _textcolor := soft80mono_textcolor ; color.s
.export _bgcolor := soft80mono_bgcolor ; color.s
; soft80mono_cputc.s
.import soft80mono_cputc
.import soft80mono_cputcxy
.import soft80mono_cputdirect
.import soft80mono_putchar
.import soft80mono_newline
.import soft80mono_plot
.export _cputc := soft80mono_cputc ; cputc.s
.export _cputcxy := soft80mono_cputcxy ; cputc.s
.export cputdirect := soft80mono_cputdirect ; cputc.s
.export putchar := soft80mono_putchar ; cputc.s
.export newline := soft80mono_newline ; cputc.s
.export plot := soft80mono_plot ; cputc.s
; soft80mono_kclrscr.s
.import soft80mono_kclrscr
.export _clrscr := soft80mono_kclrscr ; clrscr.s
; soft80mono_kplot.s
.import soft80mono_kplot
.export PLOT := soft80mono_kplot ; kplot.s
; soft80_kscreen.s
.import soft80_screensize
.export screensize := soft80_screensize ; _scrsize.s
; FIXME: use _scrsize.s/remove soft80_scrsize.s
;.export SCREEN := soft80_screensize ; kernal func (kernal.s)
; VIC sprite data for the mouse pointer
.export mcb_spritememory := soft80_spriteblock
.export mcb_spritepointer := (soft80_vram + $03F8)
; Chars used by chline () and cvline ()
.exportzp chlinechar = CH_HLINE
.exportzp cvlinechar = CH_VLINE

View File

@ -28,10 +28,9 @@
.include "c64.inc"
MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; which may be reused after the startup code is run
@ -42,24 +41,24 @@ initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD
; statement. Save the "most-recent filename" as argument #0.
; Because the buffer, that we're copying into, was zeroed out,
; we don't need to add a NUL character.
;
lda #0 ; The terminating NUL character
ldy FNAM_LEN
cpy #NAME_LEN + 1
bcc L1
ldy #NAME_LEN - 1 ; limit the length
ldy #NAME_LEN ; Limit the length
bne L1 ; Branch always
L0: lda (FNAM),y
sta name,y
L1: dey
L1: sta name,y
dey
bpl L0
inc __argc ; argc always is equal to, at least, 1
; Find the "rem" token.
;
ldx #0
L2: lda BASIC_BUF,x
beq done ; no "rem," no args.
beq done ; No "rem," no args.
inx
cmp #REM
bne L2
@ -71,7 +70,7 @@ next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
beq next
; Found start of next argument. We've incremented the pointer in X already, so
; it points to the second character of the argument. This is useful since we
@ -126,15 +125,13 @@ done: lda #<argv
stx __argv + 1
rts
; These arrays are zeroed before initmainargs is called.
; char name[16+1];
; char* argv[MAXARGS+1]={name};
;
.bss
.segment "INITBSS"
term: .res 1
name: .res NAME_LEN + 1
.data
; char* argv[MAXARGS+1]={name};
argv: .addr name
.res MAXARGS * 2

View File

@ -7,7 +7,12 @@
; be called from an interrupt handler
;
.constructor initmcb
.export _mouse_def_callbacks
.import _mouse_def_pointershape
.import _mouse_def_pointercolor
.import mcb_spritememory
.import mcb_spritepointer
.include "mouse-kernel.inc"
.include "c64.inc"
@ -22,9 +27,49 @@ MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
initmcb:
; Make all RAM accessible
lda #$30
ldy $01
sei
sta $01
; Copy the mouse sprite data
ldx #64 - 1
@L0: lda _mouse_def_pointershape,x
sta mcb_spritememory,x
dex
bpl @L0
; Set the mouse sprite pointer
lda #<(mcb_spritememory / 64)
sta mcb_spritepointer + MOUSE_SPR
; Restore memory configuration
sty $01
cli
; Set the mouse sprite color
lda _mouse_def_pointercolor
sta VIC_SPR0_COLOR + MOUSE_SPR
rts
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
.code
hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA

View File

@ -0,0 +1,4 @@
; VIC sprite data for the mouse pointer
.export mcb_spritememory := $0340
.export mcb_spritepointer := $07F8

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 05.11.2002
; 2002-11-05, Ullrich von Bassewitz
; 2015-09-11, Greg King
;
; void _randomize (void);
; /* Initialize the random number generator */
@ -12,6 +13,6 @@
__randomize:
ldx VIC_HLINE ; Use VIC rasterline as high byte
lda TIME ; Use 60HZ clock as low byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator

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