diff --git a/cfg/atmos.cfg b/cfg/atmos.cfg index 137c0e9a9..a1f935efa 100644 --- a/cfg/atmos.cfg +++ b/cfg/atmos.cfg @@ -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, diff --git a/doc/atmos.sgml b/doc/atmos.sgml index 805fc7a03..68f7f9d65 100644 --- a/doc/atmos.sgml +++ b/doc/atmos.sgml @@ -7,7 +7,7 @@ , , -2014-03-27 +2015-01-09 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. + Binary format

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 $500. +is a machine language program with a one-line BASIC stub that jumps to the +machine-language part through Memory layout

-In the standard setup, cc65 generated programs use the memory from -$500 to $9800, so nearly 37K of memory (including the stack) is +In the standard setup, cc65-generated programs use the memory from +$0501 to $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,

@@ -90,7 +102,7 @@ structures; accessing the struct fields will access the chip registers. - Access to the VIA (versatile interface adapter) chip is available via the + Access to the VIA (Versatile Interface Adapter) chip is available via the

@@ -117,7 +129,8 @@ The names in the parentheses denote the symbols to be used for static linking of Graphics drivers

-The default drivers, @@ -175,13 +188,14 @@ No mouse drivers are currently available for the Atmos. Disk I/O

-The existing library for the Atmos doesn't implement C file -I/O. There are hacks for the @@ -202,7 +216,14 @@ following functions (and a few others): Function keys

-These are defined to be FUNCT + number key. +They are defined to be FUNCT + a number key. + + +Capitals lock

+ +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. Passing arguments to the program

@@ -211,10 +232,12 @@ Command-line arguments can be passed to - CALL#500:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5 + RUN:REM arg1 " ARG2 IS QUOTED" ARG3 "" ARG5 +You must turn Arguments are separated by spaces. Arguments may be quoted. Leading and trailing spaces around an argument are ignored. Spaces within @@ -225,6 +248,15 @@ supported directly by BASIC, the following syntax was chosen: +Automatic starting

+ +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 Interrupts

The runtime for the Atmos uses routines marked as > 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: diff --git a/libsrc/atmos/crt0.s b/libsrc/atmos/crt0.s index 1d919f348..e789b28c2 100644 --- a/libsrc/atmos/crt0.s +++ b/libsrc/atmos/crt0.s @@ -2,39 +2,18 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme and Ullrich von Bassewitz -; 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 ; ------------------------------------------------------------------------ diff --git a/libsrc/atmos/tapehdr.s b/libsrc/atmos/tapehdr.s new file mode 100644 index 000000000..d90c908eb --- /dev/null +++ b/libsrc/atmos/tapehdr.s @@ -0,0 +1,31 @@ +; +; Based on code by Debrune Jérôme +; 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)