Move paths.[ch] to firmware
[kugel-rb.git] / apps / plugins / pacbox / arcade.h
blob33f79e1d5327cccfce1e04ff5a34838faaa97fd8
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);
126 void playSound( int16_t * buf, int len );
130 Tells the emulator that the status of an input device has changed.
132 void setDeviceMode( enum InputDevice device, enum InputDeviceMode mode );
135 Returns the value of the DIP switches.
137 unsigned getDipSwitches(void);
140 Sets the value of the DIP switches that control several game settings
141 (see the Dip... constants above).
143 Most of the DIP switches are read at program startup and take effect
144 only after a machine reset.
146 void setDipSwitches( unsigned value );
149 Draws the current video into the specified buffer.
151 The buffer must be at least 224*288 bytes long. Pixels are stored in
152 left-to-right/top-to-bottom order starting from the upper left corner.
153 There is one byte per pixel, containing an index into the color palette
154 returned by getPalette().
156 It's up to the application to display the buffer to the user. The
157 code might look like this:
158 <BLOCKQUOTE>
159 <PRE>
160 @@ unsigned char video_buffer[ PacmanMachine::ScreenWidth * PacmanMachine::ScreenHeight ];
161 @@ unsigned char * vbuf = video_buffer;
162 @@ const unsigned * palette = arcade.getPalette();
164 @@ arcade.renderVideo( vbuf );
166 @@ for( int y=0; y<PacmanMachine::ScreenHeight; y++ ) {
167 @@ for( int x=0; x<PacmanMachine::ScreenWidth; x++ ) {
168 @@ unsigned color = palette[ *vbuf++ ];
169 @@ unsigned char red = color & 0xFF;
170 @@ unsigned char green = (color >> 8) & 0xFF;
171 @@ unsigned char blue = (color >> 16) & 0xFF;
173 @@ setPixel( x, y, red, green, blue );
174 @@ }
175 @@ }
176 </PRE>
177 </BLOCKQUOTE>
180 bool renderBackground( unsigned char * buffer );
181 void renderSprites( unsigned char * buffer );
184 Enables/disables a common speed hack that allows Pacman to
185 move four times faster than the ghosts.
187 @param enabled true to enabled the hack, false to disable
189 @return 0 if successful, otherwise the patch could not be applied
190 (probably because the loaded ROM set does not support it)
192 int setSpeedHack( int enabled );
194 /* Implementation of the Z80 Environment interface */
195 unsigned char readByteHigh( unsigned addr );
197 void writeByte( unsigned, unsigned char );
199 unsigned char readPort( unsigned port );
201 void writePort( unsigned, unsigned char );
203 #endif // ARCADE_H_