1 /*****************************************************************************/
5 /* NES system specific definitions */
9 /* (C) 2002-2003 Groepaz/Hitmen */
12 /* This software is provided 'as-is', without any expressed or implied */
13 /* warranty. In no event will the authors be held liable for any damages */
14 /* arising from the use of this software. */
16 /* Permission is granted to anyone to use this software for any purpose, */
17 /* including commercial applications, and to alter it and redistribute it */
18 /* freely, subject to the following restrictions: */
20 /* 1. The origin of this software must not be misrepresented; you must not */
21 /* claim that you wrote the original software. If you use this software */
22 /* in a product, an acknowledgment in the product documentation would be */
23 /* appreciated but is not required. */
24 /* 2. Altered source versions must be plainly marked as such, and must not */
25 /* be misrepresented as being the original software. */
26 /* 3. This notice may not be removed or altered from any source */
29 /*****************************************************************************/
38 /* Check for errors */
40 # error This module may only be used when compiling for the NES!
45 /* Key and character defines */
47 #define CH_CURS_UP 0x01
48 #define CH_CURS_DOWN 0x02
49 #define CH_CURS_LEFT 0x03
50 #define CH_CURS_RIGHT 0x04
61 #define CH_ULCORNER 0x14
62 #define CH_URCORNER 0x12
63 #define CH_LLCORNER 0x11
64 #define CH_LRCORNER 0x08
68 #define COLOR_BLACK 0x00
69 #define COLOR_WHITE 0x01
70 #define COLOR_RED 0x02
71 #define COLOR_CYAN 0x03
72 #define COLOR_VIOLET 0x04
73 #define COLOR_GREEN 0x05
74 #define COLOR_BLUE 0x06
75 #define COLOR_YELLOW 0x07
76 #define COLOR_ORANGE 0x08
77 #define COLOR_BROWN 0x09
78 #define COLOR_LIGHTRED 0x0A
79 #define COLOR_GRAY1 0x0B
80 #define COLOR_GRAY2 0x0C
81 #define COLOR_LIGHTGREEN 0x0D
82 #define COLOR_LIGHTBLUE 0x0E
83 #define COLOR_GRAY3 0x0F
85 /* Return codes of get_tv */
90 /* No support for dynamically loadable drivers */
93 /* Expanding upon joystick.h */
94 #define JOY_BTN_A_IDX 4
95 #define JOY_BTN_B_IDX 5
96 #define JOY_SELECT_IDX 6
97 #define JOY_START_IDX 7
99 #define JOY_BTN_A(v) ((v) & joy_masks[JOY_BTN_A_IDX])
100 #define JOY_BTN_B(v) ((v) & joy_masks[JOY_BTN_B_IDX])
101 #define JOY_SELECT(v) ((v) & joy_masks[JOY_SELECT_IDX])
102 #define JOY_START(v) ((v) & joy_masks[JOY_START_IDX])
104 /* Define hardware */
106 /* Picture Processing Unit */
108 unsigned char control;
109 unsigned char mask; /* color; show sprites, background */
110 signed char volatile const status;
112 unsigned char address;
115 unsigned char scroll;
117 unsigned char address;
121 #define PPU (*(struct __ppu*)0x2000)
122 #define SPRITE_DMA (APU.sprite.dma)
124 /* Audio Processing Unit */
127 unsigned char control; /* duty, counter halt, volume/envelope */
129 unsigned char period_low; /* timing */
130 unsigned char len_period_high; /* length, timing */
133 unsigned char counter; /* counter halt, linear counter */
134 unsigned char unused;
135 unsigned char period_low; /* timing */
136 unsigned char len_period_high; /* length, timing */
139 unsigned char control; /* counter halt, volume/envelope */
140 unsigned char unused;
141 unsigned char period; /* loop, timing */
142 unsigned char len; /* length */
145 unsigned char control; /* IRQ, loop, rate */
146 unsigned char output; /* output value */
147 unsigned char address;
148 unsigned char length;
149 } delta_mod; /* delta pulse-code modulation */
153 signed char volatile status;
154 unsigned char unused;
155 unsigned char fcontrol;
157 #define APU (*(struct __apu*)0x4000)
159 #define JOYPAD ((unsigned char volatile[2])0x4016)
161 /* The addresses of the static drivers */
162 extern void nes_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
163 extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
167 void waitvsync (void);
168 /* Wait for start of the next frame */
170 unsigned char get_tv (void);
171 /* Return the video mode the machine is using. */