diff options
Diffstat (limited to 'apps/plugins/pacbox/arcade.h')
-rw-r--r-- | apps/plugins/pacbox/arcade.h | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/apps/plugins/pacbox/arcade.h b/apps/plugins/pacbox/arcade.h new file mode 100644 index 0000000000..5de2517e80 --- /dev/null +++ b/apps/plugins/pacbox/arcade.h | |||
@@ -0,0 +1,199 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef ARCADE_H_ | ||
26 | #define ARCADE_H_ | ||
27 | |||
28 | #include "plugin.h" | ||
29 | #include "z80.h" | ||
30 | #include "hardware.h" | ||
31 | |||
32 | extern fb_data palette[256]; /* Color palette in native Rockbox format */ | ||
33 | |||
34 | /** | ||
35 | Pacman sprite properties. | ||
36 | |||
37 | This information is only needed by applications that want to do their own | ||
38 | sprite rendering, as the renderVideo() function already draws the sprites. | ||
39 | |||
40 | @see PacmanMachine::renderVideo | ||
41 | */ | ||
42 | |||
43 | /** Machine hardware data */ | ||
44 | enum { | ||
45 | ScreenWidth = 224, | ||
46 | ScreenHeight = 288, | ||
47 | ScreenWidthChars = 28, | ||
48 | ScreenHeightChars = 36, | ||
49 | CharWidth = 8, | ||
50 | CharHeight = 8, | ||
51 | VideoFrequency = 60, | ||
52 | CpuClock = 3072000, | ||
53 | SoundClock = 96000, // CPU clock divided by 32 | ||
54 | CpuCyclesPerFrame = CpuClock / VideoFrequency | ||
55 | }; | ||
56 | |||
57 | /** Input devices and switches */ | ||
58 | enum InputDevice { | ||
59 | Joy1_Up = 0, | ||
60 | Joy1_Left, | ||
61 | Joy1_Right, | ||
62 | Joy1_Down, | ||
63 | Switch_RackAdvance, | ||
64 | CoinSlot_1, | ||
65 | CoinSlot_2, | ||
66 | Switch_AddCredit, | ||
67 | Joy2_Up, | ||
68 | Joy2_Left, | ||
69 | Joy2_Right, | ||
70 | Joy2_Down, | ||
71 | Switch_Test, | ||
72 | Key_OnePlayer, | ||
73 | Key_TwoPlayers, | ||
74 | Switch_CocktailMode | ||
75 | }; | ||
76 | |||
77 | /** Input device mode */ | ||
78 | enum InputDeviceMode { | ||
79 | DeviceOn, | ||
80 | DevicePushed = DeviceOn, | ||
81 | DeviceOff, | ||
82 | DeviceReleased = DeviceOff, | ||
83 | DeviceToggle | ||
84 | }; | ||
85 | |||
86 | /** DIP switches */ | ||
87 | enum { | ||
88 | DipPlay_Free = 0x00, // Coins per play | ||
89 | DipPlay_OneCoinOneGame = 0x01, | ||
90 | DipPlay_OneCoinTwoGames = 0x02, | ||
91 | DipPlay_TwoCoinsOneGame = 0x03, | ||
92 | DipPlay_Mask = 0x03, | ||
93 | DipLives_1 = 0x00, // Lives per game | ||
94 | DipLives_2 = 0x04, | ||
95 | DipLives_3 = 0x08, | ||
96 | DipLives_5 = 0x0C, | ||
97 | DipLives_Mask = 0x0C, | ||
98 | DipBonus_10000 = 0x00, // Bonus life | ||
99 | DipBonus_15000 = 0x10, | ||
100 | DipBonus_20000 = 0x20, | ||
101 | DipBonus_None = 0x30, | ||
102 | DipBonus_Mask = 0x30, | ||
103 | DipDifficulty_Normal = 0x40, // Difficulty | ||
104 | DipDifficulty_Hard = 0x00, | ||
105 | DipDifficulty_Mask = 0x40, | ||
106 | DipGhostNames_Normal = 0x80, // Ghost names | ||
107 | DipGhostNames_Alternate = 0x00, | ||
108 | DipGhostNames_Mask = 0x80, | ||
109 | DipMode_Play = 0x0000, // Play/test mode | ||
110 | DipMode_Test = 0x0100, | ||
111 | DipMode_Mask = 0x0100, | ||
112 | DipCabinet_Upright = 0x0000, // Cabinet upright/cocktail | ||
113 | DipCabinet_Cocktail = 0x0200, | ||
114 | DipCabinet_Mask = 0x0200, | ||
115 | DipRackAdvance_Off = 0x0000, // Automatic level advance | ||
116 | DipRackAdvance_Auto = 0x0400, | ||
117 | DipRackAdvance_Mask = 0x0400 | ||
118 | }; | ||
119 | |||
120 | void init_PacmanMachine(int dip); | ||
121 | int run(void); | ||
122 | void reset_PacmanMachine(void); | ||
123 | void decodeROMs(void); | ||
124 | |||
125 | /** | ||
126 | Tells the emulator that the status of an input device has changed. | ||
127 | */ | ||
128 | void setDeviceMode( enum InputDevice device, enum InputDeviceMode mode ); | ||
129 | |||
130 | /** | ||
131 | Returns the value of the DIP switches. | ||
132 | */ | ||
133 | unsigned getDipSwitches(void); | ||
134 | |||
135 | /** | ||
136 | Sets the value of the DIP switches that control several game settings | ||
137 | (see the Dip... constants above). | ||
138 | |||
139 | Most of the DIP switches are read at program startup and take effect | ||
140 | only after a machine reset. | ||
141 | */ | ||
142 | void setDipSwitches( unsigned value ); | ||
143 | |||
144 | /** | ||
145 | Draws the current video into the specified buffer. | ||
146 | |||
147 | The buffer must be at least 224*288 bytes long. Pixels are stored in | ||
148 | left-to-right/top-to-bottom order starting from the upper left corner. | ||
149 | There is one byte per pixel, containing an index into the color palette | ||
150 | returned by getPalette(). | ||
151 | |||
152 | It's up to the application to display the buffer to the user. The | ||
153 | code might look like this: | ||
154 | <BLOCKQUOTE> | ||
155 | <PRE> | ||
156 | @@ unsigned char video_buffer[ PacmanMachine::ScreenWidth * PacmanMachine::ScreenHeight ]; | ||
157 | @@ unsigned char * vbuf = video_buffer; | ||
158 | @@ const unsigned * palette = arcade.getPalette(); | ||
159 | @@ | ||
160 | @@ arcade.renderVideo( vbuf ); | ||
161 | @@ | ||
162 | @@ for( int y=0; y<PacmanMachine::ScreenHeight; y++ ) { | ||
163 | @@ for( int x=0; x<PacmanMachine::ScreenWidth; x++ ) { | ||
164 | @@ unsigned color = palette[ *vbuf++ ]; | ||
165 | @@ unsigned char red = color & 0xFF; | ||
166 | @@ unsigned char green = (color >> 8) & 0xFF; | ||
167 | @@ unsigned char blue = (color >> 16) & 0xFF; | ||
168 | @@ | ||
169 | @@ setPixel( x, y, red, green, blue ); | ||
170 | @@ } | ||
171 | @@ } | ||
172 | </PRE> | ||
173 | </BLOCKQUOTE> | ||
174 | |||
175 | */ | ||
176 | bool renderBackground( unsigned char * buffer ); | ||
177 | void renderSprites( unsigned char * buffer ); | ||
178 | |||
179 | /** | ||
180 | Enables/disables a common speed hack that allows Pacman to | ||
181 | move four times faster than the ghosts. | ||
182 | |||
183 | @param enabled true to enabled the hack, false to disable | ||
184 | |||
185 | @return 0 if successful, otherwise the patch could not be applied | ||
186 | (probably because the loaded ROM set does not support it) | ||
187 | */ | ||
188 | int setSpeedHack( int enabled ); | ||
189 | |||
190 | /* Implementation of the Z80 Environment interface */ | ||
191 | unsigned char readByteHigh( unsigned addr ); | ||
192 | |||
193 | void writeByte( unsigned, unsigned char ); | ||
194 | |||
195 | unsigned char readPort( unsigned port ); | ||
196 | |||
197 | void writePort( unsigned, unsigned char ); | ||
198 | |||
199 | #endif // ARCADE_H_ | ||