Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Commit

Permalink
*Added Triforce backup support
Browse files Browse the repository at this point in the history
*Added steering emulation
*Added controller support for F-Zero AX
*Added gameconfig for F-Zero AX
  • Loading branch information
crediar committed Jan 14, 2014
1 parent 4073b11 commit 9c58d4d
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 26 deletions.
39 changes: 39 additions & 0 deletions Data/User/GameConfig/GFXJ01.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[OnFrame_Enabled]
$No CMD encryption
$Disable Crypto
$Disable CARD
$Network wait
$English
$Motor init
$Crash fix
$Unlimited credits
$OSReport
$System waiting
[OnFrame]
$No CMD encryption
0x801857AC:dword:0x93A30008
0x801857B0:dword:0x93C3000C
0x801857B4:dword:0x93E30010
$Disable Crypto
0x801AD598:dword:0x4E800020
$Disable CARD
0x8017B2BC:dword:0x38C00000
$Network wait
0x80180FD8:dword:0x4800004C
$English
0x800DF698:dword:0x38000000
$Motor Init
0x80175710:dword:0x60000000
0x80175714:dword:0x60000000
0x801756AC:dword:0x60000000
$Crash Fix
0x803BC400:dword:0x803BB940
$Unlimited Credits
0x80400DE8:dword:0x00000001
$OSReport
0x80191B54:dword:0x4BFF676C
0x801C53CC:dword:0x4BFC2EF4
0x801CC684:dword:0x4BFBBC3C
$System waiting
0x80180DB8:dword:0x48000054
0x80180E1C:dword:0x48000054
44 changes: 36 additions & 8 deletions Source/Core/Core/Src/HW/EXI_DeviceAMBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CEXIAMBaseboard::CEXIAMBaseboard()
: m_position(0)
, m_have_irq(false)
{
m_backup = fopen("User/tribackup.bin","wb+");
}

void CEXIAMBaseboard::SetCS(int cs)
Expand Down Expand Up @@ -80,23 +81,50 @@ void CEXIAMBaseboard::TransferByte(u8& _byte)
{
if (m_position == 4)
{
_byte = 4;
ERROR_LOG(SP1, "AM-BB COMMAND: %02x %02x %02x", m_command[0], m_command[1], m_command[2]);
switch (m_command[0])
{
case 0x01:
m_backoffset = (m_command[1] << 8) | m_command[2];
DEBUG_LOG(OSREPORT,"AM-BB COMMAND: Backup Offset:%04X", m_backoffset );
fseek( m_backup, m_backoffset, SEEK_SET );
_byte = 0x01;
break;
case 0x02:
DEBUG_LOG(OSREPORT,"AM-BB COMMAND: Backup Write:%04X-%02X", m_backoffset, m_command[1] );
fputc( m_command[1], m_backup );
fflush( m_backup);
_byte = 0x01;
break;
case 0x03:
DEBUG_LOG(OSREPORT,"AM-BB COMMAND: Backup Read :%04X", m_backoffset );
_byte = (u32)(0x0100 | fgetc(m_backup));
break;
default:
_byte = 4;
ERROR_LOG(SP1, "AM-BB COMMAND: %02x %02x %02x", m_command[0], m_command[1], m_command[2]);

if ((m_command[0] == 0xFF) && (m_command[1] == 0) && (m_command[2] == 0))
m_have_irq = false;
else if (m_command[0] == 0x82)
m_have_irq = false;
if ((m_command[0] == 0xFF) && (m_command[1] == 0) && (m_command[2] == 0))
m_have_irq = false;
else if (m_command[0] == 0x82)
m_have_irq = false;
break;
}
}
else if (m_position > 4)
{
switch (m_command[0])
{
case 0xFF: // lan
_byte = 0xFF;
_byte = 0x04;
break;
case 0x83: // ?
_byte = 0x04;
break;
case 0x86: // imr
_byte = 0x00;
_byte = 0x04;
break;
case 0x87: // ?
_byte = 0x04;
break;
case 0x82: // isr
_byte = m_have_irq ? 0xFF : 0;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/Src/HW/EXI_DeviceAMBaseboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class CEXIAMBaseboard : public IEXIDevice
int m_position;
bool m_have_irq;
unsigned char m_command[4];
unsigned short m_backoffset;
FILE *m_backup;
};

#endif
132 changes: 114 additions & 18 deletions Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ CSIDevice_AMBaseboard::CSIDevice_AMBaseboard(SIDevices device, int _iDeviceNumbe
: ISIDevice(device, _iDeviceNumber)
{
memset(coin, 0, sizeof(coin));

STRInit = 0;
}

/* MKGP controls mapping:
Expand Down Expand Up @@ -161,7 +163,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
res[resp++] = 0x10;
res[resp++] = 0x2;
int d10_0 = 0xdf;
int d10_0 = 0xFF;

/* baseboard test/service switches ???, disabled for a while
if (PadStatus.button & PAD_BUTTON_Y) // Test
Expand Down Expand Up @@ -226,13 +228,60 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
}
case 0x31:
ERROR_LOG(AMBASEBOARDDEBUG, "GC-AM: Command 31 (UNKNOWN)");
res[resp++] = 0x31;
res[resp++] = 0x02;
res[resp++] = 0x00;
res[resp++] = 0x00;

if( ptr(1) )
{
u32 cmd =(ptr(2)^0x80) << 24;
cmd|= ptr(3) << 16;
cmd|= ptr(4) << 8;
// cmd|= ptr(5) << 0; // Checksum

if( cmd == 0xffffff00 )
{
res[resp++] = 0x31;
res[resp++] = 0x03;

res[resp++] = 'C';
res[resp++] = '0';

if( STRInit == 0 )
{
res[resp++] = '1';
STRInit = 1;
} else {
res[resp++] = '6';
}

} else if( cmd == 0xff000000 ) {

res[resp++] = 0x31;
res[resp++] = 0x03;

res[resp++] = 'C';
res[resp++] = '0';
res[resp++] = '1';

} else {

res[resp++] = 0x31;
res[resp++] = 0x03;

res[resp++] = 'C';
res[resp++] = '0';
res[resp++] = '6';
}

} else {
res[resp++] = 0x31;
res[resp++] = 0x03;

res[resp++] = 'C';
res[resp++] = '0';
res[resp++] = '1';
}
break;
case 0x32:
ERROR_LOG(AMBASEBOARDDEBUG, "GC-AM: Command 32 (UNKNOWN)");
ERROR_LOG(AMBASEBOARDDEBUG, "GC-AM: Command 32 (CARD-Interface)");
res[resp++] = 0x32;
res[resp++] = 0x02;
res[resp++] = 0x00;
Expand Down Expand Up @@ -308,6 +357,12 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
msg.addData((void *)"\x03\x08\x00\x00", 4); // 8 analogs
msg.addData((void *)"\x12\x0c\x00\x00", 4); // 12bit out
msg.addData((void *)"\x00\x00\x00\x00", 4);
} else if (!memcmp(SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), "GFXJ01", 6)) {
msg.addData((void *)"\x01\x01\x13\x00", 4); // 2 players, 19 bit
msg.addData((void *)"\x02\x01\x00\x00", 4); // 1 coin slots
msg.addData((void *)"\x03\x08\x00\x00", 4); // 8 analogs
msg.addData((void *)"\x12\x08\x00\x00", 4); // 6bit out
msg.addData((void *)"\x00\x00\x00\x00", 4);
} else {
msg.addData((void *)"\x01\x02\x0d\x00", 4); // 2 players, 13 bit
msg.addData((void *)"\x02\x02\x00\x00", 4); // 2 coin slots
Expand Down Expand Up @@ -357,6 +412,21 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
player_data[1] |= 0x20;
if (PadStatus.button & PAD_BUTTON_B) // Cancel button
player_data[1] |= 0x10;
} else if (!memcmp(SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), "GFXJ01", 6)) { // F-Zero AX
if (PadStatus.button & PAD_BUTTON_START)// Test button
player_data[0] |= 0x80;
if (PadStatus.button & PAD_TRIGGER_R) // Service button
player_data[0] |= 0x40;
if (PadStatus.button & PAD_BUTTON_A) // Boost
player_data[0] |= 0x02;
if (PadStatus.button & PAD_BUTTON_RIGHT)// View change 1
player_data[0] |= 0x20;
if (PadStatus.button & PAD_BUTTON_LEFT) // View change 2
player_data[0] |= 0x10;
if (PadStatus.button & PAD_BUTTON_UP) // View change 3
player_data[0] |= 0x08;
if (PadStatus.button & PAD_BUTTON_DOWN) // View change 4
player_data[0] |= 0x04;
} else {
if (PadStatus.button & PAD_BUTTON_START)
player_data[0] |= 0x80;
Expand Down Expand Up @@ -407,21 +477,47 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
SPADStatus PadStatus;
Pad::GetStatus(0, &PadStatus);

// 8 bit to 16 bit conversion
msg.addData(PadStatus.stickX); // steering
msg.addData(PadStatus.stickX);
if (!memcmp(SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), "GFXJ01", 6)) {
msg.addData(PadStatus.stickX); // steering
msg.addData((u8)0);

msg.addData(PadStatus.stickY); // steering
msg.addData((u8)0);

// 8 bit to 16 bit conversion
msg.addData(PadStatus.triggerRight); // gas
msg.addData(PadStatus.triggerRight);
msg.addData((u8)0); // unused
msg.addData((u8)0);

// 8 bit to 16 bit conversion
msg.addData(PadStatus.triggerLeft); // brake
msg.addData(PadStatus.triggerLeft);
msg.addData((u8)0); // unused
msg.addData((u8)0);

for( i=0; i < (analogs - 3); i++ ) {
msg.addData( 0 );
msg.addData( 0 );
msg.addData(PadStatus.triggerRight);// gas
msg.addData((u8)0);

msg.addData(PadStatus.triggerLeft); // brake
msg.addData((u8)0);

msg.addData((u8)0); // unused
msg.addData((u8)0);

msg.addData((u8)0); // unused
msg.addData((u8)0);
} else {
// 8 bit to 16 bit conversion
msg.addData(PadStatus.stickX); // steering
msg.addData(PadStatus.stickX);

// 8 bit to 16 bit conversion
msg.addData(PadStatus.triggerRight); // gas
msg.addData(PadStatus.triggerRight);

// 8 bit to 16 bit conversion
msg.addData(PadStatus.triggerLeft); // brake
msg.addData(PadStatus.triggerLeft);

for( i=0; i < (analogs - 3); i++ ) {
msg.addData( 0 );
msg.addData( 0 );
}
}
} break;
case 0x30: // sub coins
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class CSIDevice_AMBaseboard : public ISIDevice

unsigned short coin[2];
int coin_pressed[2];

u32 STRInit;

public:
// constructor
CSIDevice_AMBaseboard(SIDevices device, int _iDeviceNumber);
Expand Down

0 comments on commit 9c58d4d

Please sign in to comment.