A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
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 * 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.
21 *
22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
23 * KIND, either express or implied.
24 *
25 ****************************************************************************/
26
27#ifndef ARCADE_H_
28#define ARCADE_H_
29
30#include "plugin.h"
31#include "z80.h"
32#include "hardware.h"
33
34extern fb_data palette[256]; /* Color palette in native Rockbox format */
35
36/**
37 Pacman sprite properties.
38
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.
41
42 @see PacmanMachine::renderVideo
43*/
44
45/** Machine hardware data */
46enum {
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
57};
58
59/** Input devices and switches */
60enum 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
77};
78
79/** Input device mode */
80enum InputDeviceMode {
81 DeviceOn,
82 DevicePushed = DeviceOn,
83 DeviceOff,
84 DeviceReleased = DeviceOff,
85 DeviceToggle
86};
87
88/** DIP switches */
89enum {
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
120};
121
122void init_PacmanMachine(int dip);
123int run(void);
124void reset_PacmanMachine(void);
125void decodeROMs(void);
126void playSound( int16_t * buf, int len );
127
128
129/**
130 Tells the emulator that the status of an input device has changed.
131*/
132void setDeviceMode( enum InputDevice device, enum InputDeviceMode mode );
133
134/**
135 Returns the value of the DIP switches.
136*/
137unsigned getDipSwitches(void);
138
139/**
140 Sets the value of the DIP switches that control several game settings
141 (see the Dip... constants above).
142
143 Most of the DIP switches are read at program startup and take effect
144 only after a machine reset.
145*/
146void setDipSwitches( unsigned value );
147
148/**
149 Draws the current video into the specified buffer.
150
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().
155
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();
163 @@
164 @@ arcade.renderVideo( vbuf );
165 @@
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;
172 @@
173 @@ setPixel( x, y, red, green, blue );
174 @@ }
175 @@ }
176 </PRE>
177 </BLOCKQUOTE>
178
179*/
180bool renderBackground( unsigned char * buffer );
181void renderSprites( unsigned char * buffer );
182
183/**
184 Enables/disables a common speed hack that allows Pacman to
185 move four times faster than the ghosts.
186
187 @param enabled true to enabled the hack, false to disable
188
189 @return 0 if successful, otherwise the patch could not be applied
190 (probably because the loaded ROM set does not support it)
191*/
192/* rockbox: not used
193int setSpeedHack( int enabled );
194*/
195/* Implementation of the Z80 Environment interface */
196unsigned char readByteHigh( unsigned addr );
197
198void writeByte( unsigned, unsigned char );
199
200unsigned char readPort( unsigned port );
201
202void writePort( unsigned, unsigned char );
203
204#endif // ARCADE_H_