]> git.sur5r.net Git - cc65/blobdiff - doc/atari.sgml
Improved cbm_dir routines by Thomas Giesel.
[cc65] / doc / atari.sgml
index cc5bf26f945034c87f6c885064f364c1431e9251..804fb92efe28060c0bc210b68fa6c6bfa2897e32 100644 (file)
@@ -7,7 +7,7 @@
 url="mailto:shawnjefferson@24fightingchickens.com"
 name="shawnjefferson@24fightingchickens.com"> and 
 Christian Groessler, <htmlurl url="mailto:cpg@aladdin.de" name="cpg@aladdin.de">
-<date>14-Sep-2004
+<date>03-Jan-2006
 
 <abstract>
 An overview over the Atari runtime system as it is implemented for the cc65 C
@@ -72,7 +72,7 @@ Special locations:
   <tag/Stack/
   The C runtime stack is located at MEMTOP and grows downwards,
   regardless of how your linker config file is setup.  This
-  accomodates the different memory configurations of the Atari
+  accommodates the different memory configurations of the Atari
   machines, as well as having a cartridge installed.  You can override
   this behaviour by writing your own crt0.s file and linking it to
   your program (see also <ref name="Final note"
@@ -152,6 +152,69 @@ chip registers.
 <sect1>Graphics drivers<p>
 
 Currently there are no graphics drivers available for the Atari platform.
+However, the runtime library provides a function named _graphics, with
+a mode parameter just like the BASIC GRAPHICS command. This function will
+switch to the requested graphics mode.
+There are currently no functions available to access the graphics
+memory. The access must be implemented manually.
+
+Many graphics modes require more memory than the text screen which is
+in effect when the program starts up. Therefore the programmer has to
+tell the program beforehand the memory requirements of the graphics
+modes the program intends to use. 
+This can be done by using the __RESERVED_MEMORY__ linker config
+variable. The number specified there describes the number of bytes to
+subtract from the top of available memory as seen from the runtime
+library. This memory is then used by the screen buffer.
+
+The numbers for the different graphics modes presented below should
+only be seen as a rule of thumb. Since the screen buffer memory needs
+to start at specific boundaries, the numbers depend on the current top
+of available memory.
+The following numbers were determined by a BASIC program.
+
+<table>
+<tabular ca="rr">
+graphics mode|reserved memory@<hline>
+0|1@
+1|1@
+2|1@
+3|1@
+4|1@
+5|182@
+6|1182@
+7|3198@
+8|7120@
+9|7146@
+10|7146@
+11|7146@
+12|162@
+13|1@
+14|3278@
+15|7120@
+16|1@
+17|1@
+18|1@
+19|1@
+20|1@
+21|184@
+22|1192@
+23|3208@
+24|7146@
+25|7146@
+26|7146@
+27|7146@
+28|160@
+29|1@
+30|3304@
+31|7146
+</tabular>
+<caption>reserved memory required for different graphics modes
+</table>
+
+The values of "1" are needed because the graphics command crashes if
+it doesn't have at least one byte available. This seems to be a bug of
+the Atari ROM code.
 
 <sect1>Extended memory drivers<p>
 
@@ -162,7 +225,7 @@ platform.
 
 <descrip>
 
-  <tag><tt/atari-stdjoy.joy/</tag>
+  <tag><tt/ataristd.joy/</tag>
   Supports up to four standard joysticks connected to the joystick ports of
   the Atari.
 
@@ -195,6 +258,12 @@ Therefore the DIO read and write functions transfer only 128 bytes
 for sectors 1 to 3, regardless of the type of diskette.
 
 
+<sect>CONIO implementation<label id="conio"><p>
+
+The console I/O is speed optimized therefore support for XEP80 hardware
+or f80.com software is missing. Of course you may use stdio.h functions.
+
+
 <sect>Other hints<p>
 
 <sect1>Function keys<p>
@@ -224,12 +293,13 @@ memory area from &dollar;4000 to &dollar;7FFF. The CODE segment of
 the program should go below &dollar;4000 and the DATA and RODATA
 segments should go above &dollar;7FFF.
 <p>
-The main problem is that the EXE header generated by the cc65 runtine
+The main problem is that the EXE header generated by the cc65 runtime
 lib is wrong. It defines a single load chunk with the sizes/addresses
-of the CODE, RODATA, and DATA segments (the whole user program).
+of the LOWCODE, INIT, CODE, RODATA, and DATA segments (the whole user
+program).
 <p>
 The contents of the EXE header come from the EXEHDR segment, which is
-defined in crt0.s. This cannot be changed w/o modifiying and
+defined in crt0.s. This cannot be changed w/o modifying and
 recompiling the cc65 atari runtime lib. Therefore the original EXE
 header must be discarded. It will be replaced by a user created
 one.
@@ -253,20 +323,23 @@ MEMORY {
 
     SECHDR: start = $0000, size = $4, file = %O;        # second load chunk
     RAM: start = $8000, size = $3C20, file = %O;        # $3C20: matches upper bound $BC1F
+    TRAILER: start = $0000, size = $0006, file = %O;
 }
 SEGMENTS {
-    EXEHDR: load = BANK, type = wprot;
+    EXEHDR: load = BANK, type = ro;
 
-    NEXEHDR: load = HEADER, type = wprot;               # first load chunk
-    CODE: load = RAMLO, type = wprot, define = yes;
+    NEXEHDR: load = HEADER, type = ro;                  # first load chunk
+    LOWCODE: load = RAMLO, type = ro, define = yes, optional = yes;
+    INIT: load = RAMLO, type = ro, optional = yes;
+    CODE: load = RAMLO, type = ro, define = yes;
 
-    CHKHDR: load = SECHDR, type = wprot;                # second load chunk
-    RODATA: load = RAM, type = wprot, define = yes;
+    CHKHDR: load = SECHDR, type = ro;                   # second load chunk
+    RODATA: load = RAM, type = ro, define = yes;
     DATA: load = RAM, type = rw, define = yes;
     BSS: load = RAM, type = bss, define = yes;
 
     ZEROPAGE: load = ZP, type = zp;
-    AUTOSTRT: load = RAM, type = wprot;                 # defines program entry point
+    AUTOSTRT: load = TRAILER, type = ro;                # defines program entry point
 }
 FEATURES {
     CONDES: segment = RODATA,
@@ -280,6 +353,7 @@ FEATURES {
 }
 SYMBOLS {
     __STACKSIZE__ = $800;       # 2K stack
+    __RESERVED_MEMORY__: value = $0, weak = yes;
 }
 </verb></tscreen>
 <p>
@@ -300,13 +374,13 @@ memory area).
 The contents of the new NEXEHDR and CHKHDR segments come from this
 file (split.s):
 <tscreen><verb>
-        .import __CODE_LOAD__, __BSS_LOAD__, __CODE_SIZE__
-        .import __DATA_LOAD__, __RODATA_LOAD__
+        .import __LOWCODE_LOAD__, __BSS_LOAD__, __CODE_SIZE__
+        .import __CODE_LOAD__, __DATA_LOAD__, __RODATA_LOAD__
 
         .segment "NEXEHDR"
         .word    $FFFF          ; EXE file magic number
         ; 1st load chunk
-        .word    __CODE_LOAD__
+        .word    __LOWCODE_LOAD__
         .word    __CODE_LOAD__ + __CODE_SIZE__ - 1
 
         .segment "CHKHDR"
@@ -323,8 +397,8 @@ cl65 -t atari -C split.cfg -o prog.com prog.c split.s
 <sect2>Low data and high code example<p>
 
 
-Goal: Put RODATA and DATA into low memory and CODE with BSS into high
-memory (split2.cfg):
+Goal: Put RODATA and DATA into low memory and LOWCODE, INIT, CODE, BSS
+into high memory (split2.cfg):
 
 <tscreen><verb>
 MEMORY {
@@ -337,20 +411,23 @@ MEMORY {
 
     SECHDR: start = $0000, size = $4, file = %O;        # second load chunk
     RAM: start = $8000, size = $3C20, file = %O;        # $3C20: matches upper bound $BC1F
+    TRAILER: start = $0000, size = $0006, file = %O;
 }
 SEGMENTS {
-    EXEHDR: load = BANK, type = wprot;                  # discarded old EXE header
+    EXEHDR: load = BANK, type = ro;                     # discarded old EXE header
 
-    NEXEHDR: load = HEADER, type = wprot;               # first load chunk
-    RODATA: load = RAMLO, type = wprot, define = yes;
+    NEXEHDR: load = HEADER, type = ro;                  # first load chunk
+    RODATA: load = RAMLO, type = ro, define = yes;
     DATA: load = RAMLO, type = rw, define = yes;
 
-    CHKHDR: load = SECHDR, type = wprot;                # second load chunk
-    CODE: load = RAM, type = wprot, define = yes;
+    CHKHDR: load = SECHDR, type = ro;                   # second load chunk
+    LOWCODE: load = RAM, type = ro, define = yes, optional = yes;
+    INIT: load = RAM, type = ro, optional = yes;
+    CODE: load = RAM, type = ro, define = yes;
     BSS: load = RAM, type = bss, define = yes;
 
     ZEROPAGE: load = ZP, type = zp;
-    AUTOSTRT: load = RAM, type = wprot;                 # defines program entry point
+    AUTOSTRT: load = TRAILER, type = ro;                # defines program entry point
 }
 FEATURES {
     CONDES: segment = RODATA,
@@ -364,12 +441,13 @@ FEATURES {
 }
 SYMBOLS {
     __STACKSIZE__ = $800;       # 2K stack
+    __RESERVED_MEMORY__: value = $0, weak = yes;
 }
 </verb></tscreen>
 
 New contents for NEXEHDR and CHKHDR are needed (split2.s):
 <tscreen><verb>
-        .import __CODE_LOAD__, __BSS_LOAD__, __DATA_SIZE__
+        .import __LOWCODE_LOAD__, __BSS_LOAD__, __DATA_SIZE__
         .import __DATA_LOAD__, __RODATA_LOAD__
 
         .segment "NEXEHDR"
@@ -378,7 +456,7 @@ New contents for NEXEHDR and CHKHDR are needed (split2.s):
         .word    __DATA_LOAD__ + __DATA_SIZE__ - 1
 
         .segment "CHKHDR"
-        .word    __CODE_LOAD__
+        .word    __LOWCODE_LOAD__
         .word    __BSS_LOAD__ - 1
 </verb></tscreen>