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