Skip to content

Commit

Permalink
Fix Ghost Squad Evolution inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbydilley committed May 27, 2024
1 parent 4c006d5 commit d8e8bb5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/lindbergh/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ static int detectGame(uint32_t elf_crc)
config.gameStatus = WORKING;
config.gameDVP = "DVP-0029A";
config.gameID = "SBNJ";
config.jvsAnalogueInBits = 8;
return 0;
}
break;
Expand Down Expand Up @@ -538,6 +539,7 @@ int initConfig()
config.gameDVP = "DVP-XXXX";
config.gameType = SHOOTING;
config.keymap = getDefaultKeymap();
config.jvsAnalogueInBits = 10;
if (detectGame(config.crc32) != 0)
{
printf("Warning: Unsure what game with CRC 0x%X is. Please submit this new game to the GitHub repository: https://github.com/bobbydilley/lindbergh-loader/issues/new?title=Please+add+new+game+0x%X&body=I+tried+to+launch+the+following+game:\n", config.crc32, config.crc32);
Expand Down
1 change: 1 addition & 0 deletions src/lindbergh/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ typedef struct
char *gameID;
char *gameTitle;
char *gameDVP;
int jvsAnalogueInBits;
} EmulatorConfig;

KeyMapping getDefaultKeymap();
Expand Down
3 changes: 2 additions & 1 deletion src/lindbergh/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
int (*_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) = dlsym(RTLD_NEXT, "glViewport");
switch (getConfig()->crc32)
{


case LETS_GO_JUNGLE:
case LETS_GO_JUNGLE_REVA:
{
Expand All @@ -201,7 +203,6 @@ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)

case LETS_GO_JUNGLE_SPECIAL:
{
printf("glViewPort(%d, %d, %d, %d);\n", x, y, width, height);

if (width == 2048 && height == 768)
{
Expand Down
18 changes: 10 additions & 8 deletions src/lindbergh/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
#include <math.h>

GameType gameType = SHOOTING;
int jvsAnalogueInBits = 10;

int initInput()
{
gameType = getConfig()->gameType;
jvsAnalogueInBits = getConfig()->jvsAnalogueInBits;
return 0;
}

Expand All @@ -44,16 +46,16 @@ int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
incrementCoin(PLAYER_1, event_return->type == KeyPress);

else if (event_return->xkey.keycode == keymap.player1.up)
setAnalogue(ANALOGUE_2, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
setAnalogue(ANALOGUE_2, event_return->type == KeyPress ? pow(2, jvsAnalogueInBits) - 1 : 0);

else if (event_return->xkey.keycode == keymap.player1.down)
setAnalogue(ANALOGUE_3, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
setAnalogue(ANALOGUE_3, event_return->type == KeyPress ? pow(2, jvsAnalogueInBits) - 1 : 0);

else if (event_return->xkey.keycode == keymap.player1.left)
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, 10) * 0.2 : pow(2, 10) * 0.5);
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, jvsAnalogueInBits) * 0.2 : pow(2, jvsAnalogueInBits) * 0.5);

else if (event_return->xkey.keycode == keymap.player1.right)
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, 10) * 0.8 : pow(2, 10) * 0.5);
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, jvsAnalogueInBits) * 0.8 : pow(2, jvsAnalogueInBits) * 0.5);

else if (event_return->xkey.keycode == keymap.player1.start)
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
Expand Down Expand Up @@ -136,11 +138,11 @@ int XNextEventShooting(Display *display, XEvent *event_return, int returnValue)

case MotionNotify:
{
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * pow(2, 10));
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * pow(2, 10));
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * pow(2, jvsAnalogueInBits));
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * pow(2, jvsAnalogueInBits));
// For The House of the Dead 4's Accelerometer
setAnalogue(ANALOGUE_5, pow(2, 10) / 2);
setAnalogue(ANALOGUE_6, pow(2, 10) / 2);
setAnalogue(ANALOGUE_5, pow(2, jvsAnalogueInBits) / 2);
setAnalogue(ANALOGUE_6, pow(2, jvsAnalogueInBits) / 2);
}
break;

Expand Down
4 changes: 3 additions & 1 deletion src/lindbergh/jvs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "jvs.h"

#include "config.h"

#include <time.h>
#include <string.h>
#include <math.h>
Expand Down Expand Up @@ -33,7 +35,7 @@ int initJVS()
io.capabilities.switches = 14;
io.capabilities.coins = 2;
io.capabilities.players = 2;
io.capabilities.analogueInBits = 10;
io.capabilities.analogueInBits = getConfig()->jvsAnalogueInBits;
io.capabilities.rightAlignBits = 0;
io.capabilities.analogueInChannels = 8;
io.capabilities.generalPurposeOutputs = 20;
Expand Down
3 changes: 0 additions & 3 deletions src/lindbergh/jvs.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ extern unsigned char outputBuffer[JVS_MAX_PACKET_SIZE], inputBuffer[JVS_MAX_PACK
int getSenseLine();
void setSenseLine(int senseLine);

JVSCapabilities *getCapabilities();
JVSState *getState();

int initIO();
int setSwitch(JVSPlayer player, JVSInput switchNumber, int value);
int incrementCoin(JVSPlayer player, int amount);
Expand Down
3 changes: 3 additions & 0 deletions src/lindbergh/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@ case VIRTUA_FIGHTER_5_FINAL_SHOWDOWN_REVA:
patchMemory(0x080e7db2, "01");
patchMemory(0x0009FF41, "15");
patchMemory(0x080e7f5f, "B80100000090");

// Stop the extra inputs by removing io_glut_init
detourFunction(0x080e7f94, stubRetZero);
}
break;
case HUMMER_EXTREME:
Expand Down

0 comments on commit d8e8bb5

Please sign in to comment.