Skip to content

Commit

Permalink
galaxian: add 4 way to some games
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Aug 9, 2023
1 parent 85eaf1b commit b8c4484
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 8 deletions.
53 changes: 46 additions & 7 deletions src/burn/drv/galaxian/d_galaxian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15855,6 +15855,12 @@ static void FroggerEncGfxPostLoad()
MapFrogger();
}

static void Frogger4WayInit()
{
GalSet4WAY( 0, GalInputPort2 + 4, GalInputPort2 + 6, GalInputPort0 + 5, GalInputPort0 + 4 );
GalSet4WAY( 1, GalInputPort0 + 0, GalInputPort2 + 0, GalInputPort1 + 5, GalInputPort1 + 4 );
}

static INT32 FroggerEncGfxInit()
{
INT32 nRet;
Expand All @@ -15865,6 +15871,8 @@ static INT32 FroggerEncGfxInit()
nRet = GalInit(); if (nRet) return 1;
FroggerSoundInit();

Frogger4WayInit();

GalScreenUnflipper = 1; // unflip coctail!

FroggerAdjust = 1;
Expand Down Expand Up @@ -15901,6 +15909,10 @@ static INT32 FroggermcInit()
nRet = GalInit(); if (nRet) return 1;
FroggerSoundInit();

// different from other frogger sets
GalSet4WAY( 0, GalInputPort0 + 4, GalInputPort0 + 5, GalInputPort0 + 2, GalInputPort0 + 3 );
GalSet4WAY( 1, GalInputPort1 + 4, GalInputPort1 + 5, GalInputPort1 + 2, GalInputPort1 + 3 );

GalScreenUnflipper = 1; // unflip coctail!

GalRenderBackgroundFunction = FroggerDrawBackground;
Expand All @@ -15921,6 +15933,8 @@ static INT32 FroggersInit()
nRet = GalInit(); if (nRet) return 1;
FroggerSoundInit();

Frogger4WayInit();

GalScreenUnflipper = 1; // unflip coctail!

KonamiPPIInit();
Expand Down Expand Up @@ -15960,7 +15974,9 @@ static INT32 FrogfInit()

nRet = GalInit(); if (nRet) return 1;
FroggerSoundInit();


Frogger4WayInit();

KonamiPPIInit();

GalRenderBackgroundFunction = FroggerDrawBackground;
Expand All @@ -15987,7 +16003,9 @@ static INT32 FroggInit()
GalPostLoadCallbackFunction = FroggPostLoad;

nRet = GalInit();


Frogger4WayInit();

GalRenderBackgroundFunction = FroggerDrawBackground;
GalExtendTileInfoFunction = FroggerExtendTileInfo;
GalExtendSpriteInfoFunction = FroggerExtendSpriteInfo;
Expand Down Expand Up @@ -16018,6 +16036,8 @@ static INT32 FroggrsInit()
nRet = GalInit(); if (nRet) return 1;
FroggerSoundInit();

Frogger4WayInit();

GalScreenUnflipper = 1; // unflip coctail!

KonamiPPIInit();
Expand Down Expand Up @@ -16433,6 +16453,9 @@ static INT32 TurtlesInit()
nRet = GalInit(); if (nRet) return 1;
KonamiSoundInit();

GalSet4WAY( 0, GalInputPort2 + 4, GalInputPort2 + 6, GalInputPort0 + 5, GalInputPort0 + 4 );
GalSet4WAY( 1, GalInputPort0 + 0, GalInputPort2 + 0, GalInputPort1 + 5, GalInputPort1 + 4 );

GalScreenUnflipper = 1; // unflip coctail!

GalRenderBackgroundFunction = TurtlesDrawBackground;
Expand Down Expand Up @@ -16462,7 +16485,10 @@ static INT32 TurpinsInit()

nRet = GalInit(); if (nRet) return 1;
KonamiSoundInit();


GalSet4WAY( 0, GalInputPort2 + 4, GalInputPort2 + 6, GalInputPort0 + 5, GalInputPort0 + 4 );
GalSet4WAY( 1, GalInputPort0 + 0, GalInputPort2 + 0, GalInputPort1 + 5, GalInputPort1 + 4 );

GalRenderBackgroundFunction = TurtlesDrawBackground;
GalDrawBulletsFunction = NULL;

Expand Down Expand Up @@ -19357,7 +19383,11 @@ static INT32 TriplepInit()
GalSoundSubType = 1; // diff. AY8910 clock

nRet = GalInit();


// 4-way same as turtles / amidar
GalSet4WAY( 0, GalInputPort2 + 4, GalInputPort2 + 6, GalInputPort0 + 5, GalInputPort0 + 4 );
GalSet4WAY( 1, GalInputPort0 + 0, GalInputPort2 + 0, GalInputPort1 + 5, GalInputPort1 + 4 );

GalRenderBackgroundFunction = ScrambleDrawBackground;
GalDrawBulletsFunction = ScrambleDrawBullets;

Expand Down Expand Up @@ -22274,7 +22304,10 @@ static INT32 AnteaterInit()

nRet = GalInit(); if (nRet) return 1;
KonamiSoundInit();


GalSet4WAY(0, GalInputPort0 + 2, GalInputPort0 + 3, GalInputPort0 + 5, GalInputPort0 + 4);
GalSet4WAY(1, GalInputPort1 + 2, GalInputPort1 + 3, GalInputPort1 + 5, GalInputPort1 + 4);

GalTempRom = (UINT8*)BurnMalloc(GalTilesSharedRomSize);
UINT8 *TempRom = (UINT8*)BurnMalloc(GalTilesSharedRomSize);
BurnLoadRom(TempRom + 0x0000, GAL_ROM_OFFSET_TILES_SHARED + 0, 1);
Expand Down Expand Up @@ -22347,7 +22380,10 @@ static INT32 AnteatergInit()

nRet = GalInit(); if (nRet) return 1;
KonamiSoundInit();


GalSet4WAY(0, GalInputPort0 + 4, GalInputPort0 + 6, GalInputPort2 + 5, GalInputPort2 + 4);
GalSet4WAY(1, GalInputPort2 + 0, GalInputPort0 + 0, GalInputPort1 + 5, GalInputPort1 + 4);

GalRenderBackgroundFunction = AnteaterDrawBackground;
GalDrawBulletsFunction = ScrambleDrawBullets;

Expand Down Expand Up @@ -22401,7 +22437,10 @@ static INT32 AnteaterukInit()

nRet = GalInit(); if (nRet) return 1;
KonamiSoundInit();


GalSet4WAY(0, GalInputPort2 + 4, GalInputPort2 + 6, GalInputPort0 + 5, GalInputPort0 + 4);
GalSet4WAY(1, GalInputPort0 + 0, GalInputPort2 + 0, GalInputPort1 + 5, GalInputPort1 + 4);

GalRenderBackgroundFunction = ScrambleDrawBackground;
GalDrawBulletsFunction = ScrambleDrawBullets;

Expand Down
4 changes: 4 additions & 0 deletions src/burn/drv/galaxian/gal.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ extern UINT8 GalFakeDip;
extern INT32 GalAnalogPort0;
extern INT32 GalAnalogPort1;

extern INT32 Gal4Way;
extern UINT8 *GalUDLR[2][4];
void GalSet4WAY(INT32 player, UINT8 *u, UINT8 *d, UINT8 *l, UINT8 *r);

extern UINT8 *GalMem;
extern UINT8 *GalMemEnd;
extern UINT8 *GalRamStart;
Expand Down
45 changes: 44 additions & 1 deletion src/burn/drv/galaxian/gal_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,49 @@ UINT8 Dingo = 0;
UINT8 Harem = 0;
UINT8 Namenayo = 0;

INT32 Gal4Way = 0;
UINT8 *GalUDLR[2][4] = { { NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL } };

void GalInit4WAY()
{
Gal4Way = 0;
memset(GalUDLR, 0, sizeof(GalUDLR));
}

void GalSet4WAY(INT32 player, UINT8 *u, UINT8 *d, UINT8 *l, UINT8 *r)
{
Gal4Way = 1 + player;

GalUDLR[player][0] = u;
GalUDLR[player][1] = d;
GalUDLR[player][2] = l;
GalUDLR[player][3] = r;
}

static inline void GalMakeInputs()
{
if (Gal4Way) {
// Some games on this hw spread u/d/l/r across different inputs.
// Since ProcessJoystick() doesn't support this:
// Compile raw inputs to a single input for ProcessJoystick()
// then update the raw inputs w/the result.
UINT8 inp0 = 0;
UINT8 inp1 = 0;

for (INT32 i = 0; i < 4; i++) {
inp0 |= *GalUDLR[0][i] << i;
if (Gal4Way > 1) inp1 |= *GalUDLR[1][i] << i;
}

ProcessJoystick(&inp0, 0, 0, 1, 2, 3, INPUT_4WAY);
ProcessJoystick(&inp1, 1, 0, 1, 2, 3, INPUT_4WAY);

for (INT32 i = 0; i < 4; i++) {
*GalUDLR[0][i] = (inp0 & (1 << i)) >> i;
if (Gal4Way > 1) *GalUDLR[1][i] = (inp1 & (1 << i)) >> i;
}
}

// Reset Inputs
GalInput[0] = GalInput[1] = GalInput[2] = GalInput[3] = GalInput[4] = 0x00;

Expand Down Expand Up @@ -606,7 +647,9 @@ INT32 GalInit()
GalMemIndex();

if (GalLoadRoms(1)) return 1;


GalInit4WAY(); // disable by default

// Setup the Z80 emulation
if (GalSoundType != GAL_SOUND_HARDWARE_TYPE_HUNCHBACKAY8910) {
if (GalZ80Rom3Size) {
Expand Down

0 comments on commit b8c4484

Please sign in to comment.