]> git.sur5r.net Git - cc65/blob - doc/nes.sgml
remote TABs in doc/ and test/
[cc65] / doc / nes.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4 <title>Nintendo Entertainment System specific information for cc65
5 <author>
6 <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
7 <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
8
9 <abstract>
10 An overview over the NES runtime system as it is implemented for the
11 cc65 C compiler.
12 </abstract>
13
14 <!-- Table of contents -->
15 <toc>
16
17 <!-- Begin the document -->
18
19 <sect>Overview<p>
20
21 This file contains an overview of the NES runtime system as it comes
22 with the cc65 C compiler. It describes the memory layout, NES specific header
23 files, available drivers, and any pitfalls specific to that platform.
24
25 Please note that NES specific functions are just mentioned here, they are
26 described in detail in the separate <url url="funcref.html" name="function
27 reference">. Even functions marked as "platform dependent" may be available on
28 more than one platform. Please see the function reference for more
29 information.
30
31
32 <sect>Binary format<p>
33
34 The standard binary output format generated by the linker for the NES target
35 is a machine language program with an INES cartridge header. It is of course
36 possible to change this behaviour by using a modified startup file and linker
37 config.
38
39 <sect>Memory layout<p>
40
41 cc65 generated programs with the default setup run with the I/O area and a
42 CHR bank enabled, which gives a usable memory range of &dollar;8000 - &dollar;FFF3.
43 All boot ROM entry points may be called directly without additional code.
44
45 Special locations:
46
47 <descrip>
48   <tag/Text screen/
49   The text screen is located at VRAM &dollar;2000.
50
51   <tag/Stack/
52   The C runtime stack is located at &dollar;7FFF and growing downwards.
53
54   <tag/Heap/
55   The C heap is located at the end of the program and grows towards the C
56   runtime stack.
57
58 </descrip><p>
59
60
61
62 <sect>Platform specific header files<p>
63
64 Programs containing NES specific code may use the <tt/nes.h/ header file.
65
66
67 <sect1>NES specific functions<p>
68
69 <itemize>
70 <item>waitvsync - wait until the start of the next frame</item>
71 <item>get_tv</item>
72 </itemize>
73
74
75
76 <sect1>Hardware access<p>
77
78 The following pseudo variables declared in the <tt/nes.inc/ include file do
79 allow access to hardware located in the address space.
80
81 <descrip>
82
83   <tag><tt/PPU/</tag>
84   The <tt/PPU/ defines allow access to the PPU chip.
85
86   <tag><tt/APU/</tag>
87   The <tt/APU/ defines allow access to the APU chip.
88
89 </descrip><p>
90
91
92
93 <sect>Loadable drivers<p>
94
95 All drivers must be statically linked because no file I/O is available.
96 The names in the parentheses denote the symbols to be used for static linking of the drivers.
97
98
99 <sect1>Graphics drivers<p>
100
101 <descrip>
102
103   <tag><tt/nes-64-56-2.tgi (nes_64_56_2)/</tag>
104   This driver features a resolution of 64&times;56 with 2 colors using the
105   CHR bank.
106
107 </descrip><p>
108
109
110 <sect1>Extended memory drivers<p>
111
112 No extended memory drivers are currently available for the NES.
113
114
115 <sect1>Joystick drivers<p>
116
117 <descrip>
118
119   <tag><tt/nes-stdjoy.joy (nes_stdjoy)/</tag>
120   A joystick driver for the standard four buttons joypad is available.
121
122 </descrip><p>
123
124 The generic interface doesn't export the start and select buttons. To
125 test for those, use the defines in nes.h instead of the generic masks.
126
127 Example:
128 <tscreen><verb>
129 if (joy_read(0) & KEY_A)
130 </verb></tscreen>
131
132
133 <sect1>Mouse drivers<p>
134
135 No mouse drivers are currently available for the NES.
136
137
138 <sect1>RS232 device drivers<p>
139
140 No serial drivers are currently available for the NES.
141
142
143
144 <sect>Limitations<p>
145
146 <sect1>Disk I/O<p>
147
148 The existing library for the NES doesn't implement C file
149 I/O. There are no hacks for the <tt/read()/ and <tt/write()/ routines.
150
151 To be more concrete, this limitation means that you cannot use any of the
152 following functions (and a few others):
153
154 <itemize>
155 <item>fclose
156 <item>fopen
157 <item>fread
158 <item>fprintf
159 <item>fputc
160 <item>fscanf
161 <item>fwrite
162 <item>...
163 </itemize>
164
165
166
167 <sect>Other hints<p>
168
169
170
171 <sect>License<p>
172
173 This software is provided 'as-is', without any expressed or implied
174 warranty.  In no event will the authors be held liable for any damages
175 arising from the use of this software.
176
177 Permission is granted to anyone to use this software for any purpose,
178 including commercial applications, and to alter it and redistribute it
179 freely, subject to the following restrictions:
180
181 <enum>
182 <item>  The origin of this software must not be misrepresented; you must not
183         claim that you wrote the original software. If you use this software
184         in a product, an acknowledgment in the product documentation would be
185         appreciated but is not required.
186 <item>  Altered source versions must be plainly marked as such, and must not
187         be misrepresented as being the original software.
188 <item>  This notice may not be removed or altered from any source
189         distribution.
190 </enum>
191
192 </article>