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