extends PacmanMachine as public
Ms.Pacman machine emulator.
Ms. Pacman hardware is identical to the Pacman hardware
with an extra board added. This board mainly contains new ROMs for
both code and graphics.
The MsPacmanMachine class emulates the above hardware by extending the
base PacmanMachine class with the functions needed to emulate only the
extra board and logic. While not optimal for performance, this approach
is remarkably easy to implement are requires very little code.
- Source:
- arcade.h:554
- Author:
- Alessandro Scotti
- Version:
- 1.0
destructor ~MsPacmanMachine | ? ^
> |
Destructor.
- Source:
- arcade.h:566
- Code:
public virtual ~ MsPacmanMachine ( ) |
constructor MsPacmanMachine | ? ^
< > |
Constructor.
- Source:
- arcade.h:560
- Code:
public MsPacmanMachine ( | ) : PacmanMachine ( ) , aux_board_enabled_ ( 0 ) |
constructor MsPacmanMachine | ? ^
< > |
automatically generated
- Source:
- arcade.h
- Code:
public MsPacmanMachine ( | const MsPacmanMachine & ) |
static method decodeCharSet | ? ^
< > |
Decodes and expands the 4K ROM containing the character definitions into a 16K RAM
buffer where each byte correspond directly to a 8x8 character pixel.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:426
- Code:
public static void decodeCharSet ( | unsigned char * mem , |
| unsigned char * charset ) |
static method decodePaletteByte | ? ^
< > |
Decode one byte from the encoded color palette.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:435
- Code:
public static unsigned decodePaletteByte ( | unsigned char b ) |
static method decodeSprites | ? ^
< > |
Decodes and expands the 4K ROM containing the sprite definitions into a 16K RAM
buffer where each byte correspond directly to a 16x16 sprite pixel.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:432
- Code:
public static void decodeSprites ( | unsigned char * mem , |
| unsigned char * sprite_data ) |
method getCoinLockout | ? ^
< > |
Returns the status of the coin lockout door.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:450
- Code:
public unsigned char getCoinLockout ( | ) const |
method getCoinMeter | ? ^
< > |
Returns the number of coins inserted since the machine was powered on.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:254
- Code:
public unsigned getCoinMeter ( | ) const |
method getColorMem | ? ^
< > |
Returns a pointer to the color memory in "normalized" form
(224x288, one byte per pixel).
Note: Pacman has a rather peculiar video/color memory layout but this
buffer is kept "normalized" by the emulator so it has the same
format as the output buffer used by renderVideo(). The raw color
memory can be found in the RAM buffer at 0x4400-0x47FF.
This function is only necessary if the application wants to perform
its own rendering, because renderVideo() already draws the video.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:384
- See Also:
- renderVideo
- Code:
public const unsigned char * getColorMem ( | ) const |
method getDeviceMode | ? ^
< > |
Returns the current status of an input device.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:228
- Code:
-
method getDipSwitches | ? ^
< > |
Returns the value of the DIP switches.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:238
- Code:
public unsigned getDipSwitches ( | ) const |
method getFrameCount | ? ^
< > |
Returns how many times run() has been called since last reset.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:259
- Code:
public unsigned getFrameCount ( | ) const |
Returns a pointer to the decoded 32 color palette: each entry contains
a color in RGB format encoded as 0x00bbggrr.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:323
- Code:
public const unsigned * getPalette ( | ) const |
method getPlayerOneLight | ? ^
< > |
Returns the status of the start light for player one.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:440
- Code:
public unsigned char getPlayerOneLight ( | ) const |
method getPlayerTwoLight | ? ^
< > |
Returns the status of the start light for player two.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:445
- Code:
public unsigned char getPlayerTwoLight ( | ) const |
Returns a pointer to the 20K ROM/RAM buffer containing the 16K game
ROM (starting at 0x0000) and 4K of RAM (starting at 0x4000, this
includes the video RAM at 0x4000-0x43FF and the color RAM at
0x4400-0x47FF).
The first 16K of the buffer contain the game ROM as specified in the
setROM() function.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:336
- Code:
public const unsigned char * getRAM ( | ) const |
method getSizeOfSnapshotBuffer | ? ^
< > |
Returns the size of the buffer needed to take a snapshot of the machine.
- Source:
- arcade.h:596
- See Also:
- PacmanMachine::getSizeOfSnapshotBuffer
- Code:
public virtual unsigned getSizeOfSnapshotBuffer ( | ) const |
Returns a pointer to the current settings of the specified sprite.
This function is only necessary if the application wants to perform
its own rendering, because renderVideo() already draws the sprites.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:348
- See Also:
- renderVideo
- Code:
-
method getVideoMem | ? ^
< > |
Returns a pointer to the video memory in "normalized" form
(224x288, one byte per pixel).
Note: Pacman has a rather peculiar video/color memory layout but this
buffer is kept "normalized" by the emulator so it has the same
format as the output buffer used by renderVideo(). The raw video
memory can be found in the RAM buffer at 0x4000-0x43FF.
This function is only necessary if the application wants to perform
its own rendering, because renderVideo() already draws the video.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:366
- See Also:
- renderVideo
- Code:
public const unsigned char * getVideoMem ( | ) const |
method onReturnFromInterrupt | ? ^
< > |
Called immediately after a RETI is executed.
- Inherited From:
- Z80Environment
- Source:
- z80.h:94
- Code:
public virtual void onReturnFromInterrupt ( | ) |
automatically generated
- Source:
- arcade.h
- Code:
public MsPacmanMachine & operator = ( | const MsPacmanMachine & ) |
Reproduces the sound that is currently being generated by the sound
chip into the specified buffer.
The sound chip has three independent voices that generate 8-bit signed
PCM audio at 96 KHz. This function resamples the voices at the specified
sampling rate and mixes them into the output buffer. The output buffer
can be converted to 8-bit (signed) PCM by dividing each sample by 3 (since
there are three voices) or it can be expanded to 16-bit by multiplying
each sample by 85 (i.e. 256 divided by 3). If necessary, it is possible
to approximate these values with 4 and 64 in order to use arithmetic
shifts that are usually faster to execute.
Note: this function clears the content of the output buffer before
mixing voices into it.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:281
- Params:
buf
| pointer to sound buffer that receives the audio samples
|
len
| length of the sound buffer
|
samplingRate
| sampling rate (in Hertz or samples per second) of the sound buffer
|
- Code:
public virtual void playSound ( | int * buf , |
| int len , |
| int samplingRate ) |
Reads one byte from memory at the specified address.
The address parameter may contain any value, including
values greater than 0xFFFF (64k), so if necessary
the implementation must check for illegal values and
handle them according to the implemented system
specifications.
- Inherited From:
- Z80Environment
- Source:
- z80.h:59
- Code:
public virtual unsigned char readByte ( | unsigned addr ) |
Reads one byte from the specified port.
Note: the port value is always between 00h and FFh included.
- Inherited From:
- Z80Environment
- Source:
- z80.h:80
- Code:
public virtual unsigned char readPort ( | unsigned port ) |
method renderVideo | ? ^
< > |
Draws the current video into the specified buffer.
The buffer must be at least 224*288 bytes long. Pixels are stored in
left-to-right/top-to-bottom order starting from the upper left corner.
There is one byte per pixel, containing an index into the color palette
returned by getPalette().
It's up to the application to display the buffer to the user. The
code might look like this:
unsigned char video_buffer[ PacmanMachine::ScreenWidth * PacmanMachine::ScreenHeight ];
unsigned char * vbuf = video_buffer;
const unsigned * palette = arcade.getPalette();
arcade.renderVideo( vbuf );
for( int y=0; y<PacmanMachine::ScreenHeight; y++ ) {
for( int x=0; x<PacmanMachine::ScreenWidth; x++ ) {
unsigned color = palette[ *vbuf++ ];
unsigned char red = color & 0xFF;
unsigned char green = (color >> 8) & 0xFF;
unsigned char blue = (color >> 16) & 0xFF;
setPixel( x, y, red, green, blue );
}
}
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:315
- Code:
public virtual void renderVideo ( | unsigned char * buffer ) |
Resets the machine.
This function is equivalent to turning the machine off and on again,
but it preserves the ROMs that were previously set so the application does
not have to reinitialize them.
It is usually called on startup and to enable changes in the DIP switch settings.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:178
- Param:
- Code:
public virtual void reset ( | ) |
method restoreSnapshot | ? ^
< > |
Restores a snapshot taken with takeSnapshot().
This function uses the data saved in the snapshot buffer to restore the
machine status.
- Source:
- arcade.h:631
- Param:
buffer
| buffer where the snapshot data is stored
|
- Returns:
- the number of bytes read from the buffer
- See Also:
- PacmanMachine::restoreSnapshot
- Code:
public virtual unsigned restoreSnapshot ( | unsigned char * buffer ) |
Runs the machine for one frame, i.e.
1/60th of a second in Pacman.
Note that sound is updated after each frame, but the video is only updated
every other frame.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:186
- Code:
public virtual int run ( | ) |
Sets the ROMs found on the auxiliary board.
Note: the original encrypted ROMs must be specified here, they will
be decrypted by the emulator.
- Source:
- arcade.h:578
- Params:
u5
| 2K ROM at board location U5
|
u6
| 4K ROM at board location U6
|
u7
| 4K ROM at board location U7
|
- Code:
public void setAuxROM ( | unsigned char * u5 , |
| unsigned char * u6 , |
| unsigned char * u7 ) |
method setColorROMs | ? ^
< > |
Sets the color ROMs containing the color definitions and the color map.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:223
- Params:
palette
| pointer to 32 byte PROM containing color definitions
|
color
| pointer to 256-entry 4-bit PROM containing the mapping
between the color index and the color definition (from the
palette)
|
- Code:
public virtual void setColorROMs ( | const unsigned char * palette , |
| const unsigned char * color ) |
method setDeviceMode | ? ^
< > |
Tells the emulator that the status of an input device has changed.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:233
- Code:
-
method setDipSwitches | ? ^
< > |
Sets the value of the DIP switches that control several game settings
(see the Dip...
constants above).
Most of the DIP switches are read at program startup and take effect
only after a machine reset.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:247
- Code:
public void setDipSwitches ( | unsigned value ) |
Sets the main game ROM.
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:193
- Param:
rom
| pointer to the 16K game ROM
|
- Code:
public virtual void setROM ( | const unsigned char * rom ) |
method setSpeedHack | ? ^
< > |
Enables/disables a common speed hack that allows Pacman to
move four times faster than the ghosts.
- Source:
- arcade.h:589
- Param:
enabled
| true to enabled the hack, false to disable
|
- Returns:
- 0 if successful, otherwise the patch could not be applied
(probably because the loaded ROM set does not support it)
- Code:
public virtual int setSpeedHack ( | int enabled ) |
method setVideoROMs | ? ^
< > |
Sets the video ROMs that contain character and sprite definitions.
Usually character and sprite data come together with the game ROM in
a 24K ROM bundle and the application can use the following code:
unsigned char * rom_bundle = ...24K game and video ROM bundle...
pacmanMachine.setROM( rom_bundle );
pacmanMachine.setVideoROMs( rom_bundle+0x4000, rom_bundle+0x5000 );
- Inherited From:
- PacmanMachine
- Source:
- arcade.h:213
- Params:
charset
| pointer to 4K character definition data
|
spriteset
| pointer to 4K sprite definition data
|
- Code:
public virtual void setVideoROMs ( | const unsigned char * charset , |
| const unsigned char * spriteset ) |
method takeSnapshot | ? ^
< > |
Takes a snapshot of the machine.
A snapshot saves all of the machine memory and settings, including RAM,
ROM, CPU status and I/O registers. It can be restored at any time to bring
the machine back to the exact status it had when the snapshot was taken.
Snapshots come very handy to save the progress of a game during a good
performance!
Note: the size of the snapshot buffer must be no less than the size
returned by the getSizeOfSnapshotBuffer() function.
- Source:
- arcade.h:617
- Param:
buffer
| buffer where the snapshot data is stored
|
- Returns:
- the number of bytes written into the buffer
- See Also:
- PacmanMachine::takeSnapshot
- Code:
public virtual unsigned takeSnapshot ( | unsigned char * buffer ) |
Writes one byte to memory at the specified address.
The address parameter may contain any value, including
values greater than 0xFFFF (64k), so if necessary
the implementation must check for illegal values and
handle them according to the implemented system
specifications.
- Inherited From:
- Z80Environment
- Source:
- z80.h:71
- Code:
public virtual void writeByte ( | unsigned addr , |
| unsigned char value ) |
Writes one byte from the specified port.
Note: the port value is always between 00h and FFh included.
- Inherited From:
- Z80Environment
- Source:
- z80.h:88
- Code:
public virtual void writePort ( | unsigned port , |
| unsigned char value ) |
Copyright (c) 1997-2003,2004 Alessandro
Scotti. All rights reserved.