diff --git a/doc/Makefile b/doc/Makefile index 883828922..9c4afc029 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -13,6 +13,7 @@ SGML = apple2.sgml \ c64.sgml \ ca65.sgml \ ca65html.sgml \ + cbm610.sgml \ cc65.sgml \ cl65.sgml \ co65.sgml \ diff --git a/doc/cbm610.sgml b/doc/cbm610.sgml new file mode 100644 index 000000000..d7ad73237 --- /dev/null +++ b/doc/cbm610.sgml @@ -0,0 +1,282 @@ + + +
+ +Commodore 610 specific information for cc65 +<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org"> +<date>2003-12-16 + +<abstract> +An overview over the Commodore 610 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 CBM 610 runtime system as it comes with +the cc65 C compiler. It describes the memory layout, CBM 610 specific header +files, available drivers, and any pitfalls specific to that platform. + +Please note that CBM 610 specific functions are just mentioned here, they are +described in detail in the separate <htmlurl 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. + +In addition to the Commodore 610 (named B40 in the U.S.), several other +machines are supported by this cc65 target, since they have identical +hardware: The Commodore 620 and 630 (more memory, additional coprocessor +card), and the Commodore 710, 720 and 730 (same hardware in another case with +a builtin monitor). + + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the CBM610 +target is a machine language program with a short BASIC stub. This means that +a program can be loaded as BASIC program and started with RUN. 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 for the Commodore 610 run in bank 1, the memory bank +reserved for BASIC programs. Since there are no ROMs in this memory bank, the +program has almost full 64K for its own. A disadvantage is that kernal +subroutines cannot be called (at least not in a fast and effective manner), so +the runtime has replace kernal functionality. + +The default memory configuration for the CBM 610 allocates all memory between +$0002 and $FFF0 in bank 1 for the compiled program. Some space +in low memory is lost, because a separate hardware stack is set up in page 1, +and the kernal replacement functions need some more memory locations. A few +more bytes are lost in high memory, because the runtime sets up a CBM +compatible jump table at $FF81. The main startup code is located at +$0400, so about 63K of the complete bank are actually usable for +applications. + +<bf>Note:</bf> The zero page from $02 to $5F is free to use for +applications! + +Special locations: + +<descrip> + <tag/Stack/ + The C runtime stack is located at $FF81 and growing downwards. + + <tag/Heap/ + The C heap is located at the end of the program and grows towards the C + runtime stack. +</descrip><p> + + + +<sect>Platform specific header files<p> + +Programs containing CBM 610 specific code may use the <tt/cbm610.h/ or +<tt/cbm.h/ header files. Using the later may be an option when writing code +for more than one CBM platform, since it includes <tt/cbm610.h/ and declares +several functions common to all CBM platforms. + +Please note that because of <ref id="limitations" name="current limitations"> +of the runtime library for the platform, several standard C and CBM functions +are not available. + + +<sect1>CBM 610 specific functions<p> + +The functions listed below are special for the CBM 610. See the <htmlurl +url="funcref.html" name="function reference"> for declaration and usage. + +<itemize> +<item>peekbsys +<item>peewsys +<item>pokebsys +<item>pokewsys +</itemize> + + +<sect1>CBM specific functions<p> + +Some functions are available for all (or at least most) of the Commodore +machines. See the <htmlurl url="funcref.html" name="function reference"> for +declaration and usage. + + +<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/cbm610.h/ header file do +allow access to hardware located in the address space. Some variables are +structures, accessing the struct fields will access the chip registers. + +<bf>Note:</bf> All I/O chips are located in the system bank (bank 15) and can +therefore not be accessed like on other platforms. Please use one of the +<tt/peekbsys/, <tt/peewsys/, <tt/pokebsys/ and <tt/pokewsys/ functions to +access the I/O chips. Direct reads and writes to the structures named below +will <em>not</em> work! + +<descrip> + + <tag><tt/CRTC/</tag> + The <tt/CRTC/ structure allows access to the CRTC (the video controller). + See the <tt/_6545.h/ header file located in the include directory for the + declaration of the structure. + + <tag><tt/SID/</tag> The <tt/SID/ structure allows access to the SID (the + sound interface device). See the <tt/_sid.h/ header file located in the + include directory for the declaration of the structure. + + <tag><tt/ACIA/</tag> + Access to the ACIA (the RS232 chip) is available via the <tt/ACIA/ variable. + See the <tt/_6551.h/ header file located in the include directory for the + declaration of the structure. + + <tag><tt/CIA/</tag> + Access to the CIA chip is available via the <tt/CIA/ variable. See the + <tt/_6526.h/ header file located in the include directory for the + declaration of the structure. + + <tag><tt/TPI1, TPI2/</tag> + The two 6525 triport chips may be accessed by using this variable. See the + <tt/_6525.h/ header file located in the include directory for the + declaration of the structure. + +</descrip><p> + + + +<sect>Loadable drivers<p> + +<bf>Note:</bf> Since the CBM 610 doesn't have working disk I/O (see <ref +id="limitations" name="section "Limitations"">), the available +drivers cannot be loaded at runtime (so the term "loadable drivers" is +somewhat misleading). Instead, the drivers have to be converted using the +<htmlurl url="co65.html" name="co65 utility"> and statically linked. While +this may seem overhead, it has two advantages: + +<enum> +<item>The interface is identical to the one used for other platforms + and to the one for the CBM 610 once it has disk I/O. +<item>Once disk I/O is available, existing code can be changed to load drivers + at runtime with almost no effort. +</enum> + + +<sect1>Graphics drivers<p> + +No graphics drivers are currently available for the Commodore 610 (and since +the machine has no graphics capabilities, chances for a graphics driver aren't +really good:-). + + +<sect1>Extended memory drivers<p> + +<descrip> + <tag><tt/cbm610-ram.emd/</tag> + A driver for the RAM in bank 2. Supports up to 255 pages with 256 bytes + each. Untested! +</descrip><p> + + +<sect1>Joystick drivers<p> + +The Commodore 610 is a business machine and doesn't have joystick ports. There +are no drivers for the non existing ports available. + + + +<sect1>Mouse drivers<p> + +Currently no drivers available (in fact, the API for loadable mouse drivers +does not exist). + + +<sect1>RS232 device drivers<p> + +Currently no RS232 drivers exist for the Commodore 610. + + + +<sect>Limitations<label id="limitations"><p> + + +<sect1>Disk I/O<p> + +The existing library for the CBM 610 doesn't implement C file I/O. Please note +that this includes <tt/printf/! You may use the conio functions for screen I/O. + +To be more concrete, this limitation means that you cannot use any of the +following functions (and a few others): + +<itemize> +<item>fclose +<item>fgets +<item>fopen +<item>fread +<item>fprintf +<item>fputc +<item>fscanf +<item>fwrite +<item>gets +<item>printf +<item>... +</itemize> + + +<sect1>Kernal and hardware access<p> + +Since the program runs in bank 1, and the kernal and all I/O chips are located +in bank 15, calling ROM routines or accessing hardware needs special code. + + + +<sect>Other hints<p> + +<sect1>Passing arguments to the program<p> + +Command line argument passing is currently not supported for the Commodore +610. + + + +<sect>Bugs/Feedback<p> + +If you have problems using the library, if you find any bugs, or if you're +doing something interesting with it, I would be glad to hear from you. Feel +free to contact me by email (<htmlurl url="mailto:uz@cc65.org" +name="uz@cc65.org">). + + + +<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> + + + diff --git a/doc/index.sgml b/doc/index.sgml index 6a3528028..d056cf56b 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -99,6 +99,9 @@ Main documentation page, contains links to other available stuff. <tag><htmlurl url="c64.html" name="c64.html"></tag> Topics specific to the Commodore 64. + <tag><htmlurl url="cbm610.html" name="cbm610.html"></tag> + Topics specific to the Commodore 610. + <tag><htmlurl url="plus4.html" name="plus4.html"></tag> Topics specific to the Commodore Plus/4.