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

Commit

Permalink
Changed Triforce specific EXI interrupt handling, all games should bo…
Browse files Browse the repository at this point in the history
…ot without any patches now

Increased DIMM memory size to 8MB
Added memory area for IP address configuration
Added memory area for network control
Added some info about the hardware test command
Fixed buttons for Mario Kart GP/GP2
Fixed a few typos
  • Loading branch information
crediar committed Jan 27, 2014
1 parent a18d3a4 commit afba901
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 47 deletions.
142 changes: 111 additions & 31 deletions Source/Core/Core/Src/HW/AMBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ static File::IOFile *m_dimm;

static u32 m_controllertype;

static unsigned char media_buffer[0x40];
static unsigned char media_buffer[0x60];
static unsigned char ip_buffer[0x200];

static inline void PrintMBBuffer( u32 Address )
{
NOTICE_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address),
Memory::Read_U32(Address+4),
Memory::Read_U32(Address+8),
Memory::Read_U32(Address+12) );
NOTICE_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address+16),
Memory::Read_U32(Address+20),
Memory::Read_U32(Address+24),
Memory::Read_U32(Address+28) );
}

void Init( void )
{
Expand Down Expand Up @@ -55,7 +68,7 @@ void Init( void )
m_controllertype = 3;
break;
default:
PanicAlertT("Unknown game ID, using default controls.");
// PanicAlertT("Unknown game ID, using default controls.");
m_controllertype = 3;
break;
}
Expand Down Expand Up @@ -103,13 +116,13 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
break;
// Read
case 0xA8:
if( Offset & 0x80000000 )
if( (Offset & 0x8FFF0000) == 0x80000000 )
{
switch(Offset)
{
// Media board status (1)
case 0x80000000:
memset( Memory::GetPointer(Address), 0, Length );
Memory::Write_U16( Common::swap16( 0x0100 ), Address );
break;
// Media board status (2)
case 0x80000020:
Expand All @@ -118,21 +131,22 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
// Media board status (3)
case 0x80000040:
memset( Memory::GetPointer(Address), 0xFFFFFFFF, Length );
// DIMM size
Memory::Write_U32( 0x20, Address );
// DIMM size (512MB)
Memory::Write_U32( Common::swap32( 0x20000000 ), Address );
// GCAM signature
Memory::Write_U32( 0x4743414D, Address+4 );
break;
// Firmware status (1)
case 0x80000120:
memset( Memory::GetPointer(Address), 0x01010101, Length );
Memory::Write_U32( Common::swap32( (u32)0x00000001 ), Address );
break;
// Firmware status (2)
case 0x80000140:
memset( Memory::GetPointer(Address), 0x01010101, Length );
Memory::Write_U32( Common::swap32( (u32)0x00000001 ), Address );
break;
default:
PanicAlertT("Unknown Media Board Read");
PrintMBBuffer(Address);
PanicAlertT("Unhandled Media Board Read");
break;
}
return 0;
Expand All @@ -159,20 +173,45 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
memcpy( Memory::GetPointer(Address), media_buffer + dimmoffset, Length );

NOTICE_LOG(DVDINTERFACE, "GC-AM: Read MEDIA BOARD COMM AREA (%08x)", dimmoffset );
NOTICE_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address),
Memory::Read_U32(Address+4),
Memory::Read_U32(Address+8),
Memory::Read_U32(Address+12) );
NOTICE_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address+16),
Memory::Read_U32(Address+20),
Memory::Read_U32(Address+24),
Memory::Read_U32(Address+28) );
PrintMBBuffer(Address);
return 0;
}
// Get IP address
if( (Offset >= 0x1F800200) && (Offset <= 0x1F8003FF) )
{
NOTICE_LOG(DVDINTERFACE, "GC-AM: Get IP:%s", Memory::GetPointer(Address) );
memcpy( Memory::GetPointer(Address), ip_buffer, Length );
return 0;
}
// DIMM command
if( (Offset >= 0x84000000) && (Offset <= 0x8400005F) )
{
u32 dimmoffset = Offset - 0x84000000;
memcpy( Memory::GetPointer(Address), media_buffer + dimmoffset, Length );

NOTICE_LOG(DVDINTERFACE, "GC-AM: Read MEDIA BOARD COMM AREA (%08x)", dimmoffset );
PrintMBBuffer(Address);
return 0;
}
// DIMM memory (8MB)
if( (Offset >= 0xFF000000) && (Offset <= 0xFF800000) )
{
u32 dimmoffset = Offset - 0xFF000000;
m_dimm->Seek( dimmoffset, SEEK_SET );
m_dimm->ReadBytes( Memory::GetPointer(Address), Length );
return 0;
}
// Network control
if( (Offset == 0xFFFF0000) && (Length == 0x20) )
{
m_netctrl->Seek( 0, SEEK_SET );
m_netctrl->ReadBytes( Memory::GetPointer(Address), Length );
return 0;
}
// Max GC disc offset
if( Offset >= 0x57058000 )
{
_dbg_assert_msg_(DVDINTERFACE, 0, "Unhandeled Media Board Read");
PanicAlertT("Unhandled Media Board Read");
}
if( !DVDInterface::DVDRead( Offset, Address, Length) )
{
Expand Down Expand Up @@ -203,27 +242,58 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
m_dimm->WriteBytes( Memory::GetPointer(Address), Length );
return 0;
}
// Set IP address
if( (Offset >= 0x1F800200) && (Offset <= 0x1F8003FF) )
{
NOTICE_LOG(DVDINTERFACE, "GC-AM: Set IP:%s", Memory::GetPointer(Address) );
memcpy( ip_buffer, Memory::GetPointer(Address), Length );
return 0;
}
// DIMM command
if( (Offset >= 0x1F900000) && (Offset <= 0x1F90003F) )
{
u32 dimmoffset = Offset - 0x1F900000;
memcpy( media_buffer + dimmoffset, Memory::GetPointer(Address), Length );

ERROR_LOG(DVDINTERFACE, "GC-AM: Write MEDIA BOARD COMM AREA (%08x)", dimmoffset );
ERROR_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address),
Memory::Read_U32(Address+4),
Memory::Read_U32(Address+8),
Memory::Read_U32(Address+12) );
ERROR_LOG(DVDINTERFACE, "GC-AM: %08x %08x %08x %08x", Memory::Read_U32(Address+16),
Memory::Read_U32(Address+20),
Memory::Read_U32(Address+24),
Memory::Read_U32(Address+28) );
PrintMBBuffer(Address);
return 0;
}
// DIMM command
if( (Offset >= 0x84000000) && (Offset <= 0x8400005F) )
{
u32 dimmoffset = Offset - 0x84000000;
memcpy( media_buffer + dimmoffset, Memory::GetPointer(Address), Length );

if( dimmoffset == 0x40 )
{
ERROR_LOG(DVDINTERFACE, "GC-AM: EXECUTE (%03x)", *(u16*)(media_buffer+0x22) );
}

ERROR_LOG(DVDINTERFACE, "GC-AM: Write MEDIA BOARD COMM AREA (%08x)", dimmoffset );
PrintMBBuffer(Address);
return 0;
}
// DIMM memory (8MB)
if( (Offset >= 0xFF000000) && (Offset <= 0xFF800000) )
{
u32 dimmoffset = Offset - 0xFF000000;
m_dimm->Seek( dimmoffset, SEEK_SET );
m_dimm->WriteBytes( Memory::GetPointer(Address), Length );
return 0;
}
// Network control
if( (Offset == 0xFFFF0000) && (Length == 0x20) )
{
m_netctrl->Seek( 0, SEEK_SET );
m_netctrl->WriteBytes( Memory::GetPointer(Address), Length );
return 0;
}
// Max GC disc offset
if( Offset >= 0x57058000 )
{
PanicAlertT("Unhandeled Media Board Write");
PrintMBBuffer(Address);
PanicAlertT("Unhandled Media Board Write");
}
break;
// Execute
Expand Down Expand Up @@ -286,19 +356,29 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
// enable development mode (Sega Boot)
media_buffer[6] = 1;
break;
// Media board serial
case 0x103:
// Media board Serial
memcpy(media_buffer + 4, "A89E27A50364511", 15);
break;
case 0x104:
media_buffer[4] = 1;
break;
// Media Board Test
// Hardware test
case 0x301:
// Test type
/*
0x01: Media board
0x04: Network
*/
ERROR_LOG(DVDINTERFACE, "GC-AM: 0x301: (%08X)", *(u32*)(media_buffer+0x24) );

//Pointer to a memory address that is directly displayed on screen as a string
ERROR_LOG(DVDINTERFACE, "GC-AM: (%08X)", *(u32*)(media_buffer+0x28) );

Memory::Write_U32( 100, *(u32*)(media_buffer+0x28) );
// On real system it shows the status about the DIMM/GD-ROM here
// We just show "TEST OK"
Memory::Write_U32( 0x54534554, *(u32*)(media_buffer+0x28) );
Memory::Write_U32( 0x004B4F20, *(u32*)(media_buffer+0x28)+4 );

*(u32*)(media_buffer+0x04) = *(u32*)(media_buffer+0x24);
break;
Expand Down Expand Up @@ -393,7 +473,7 @@ u32 ExecuteCommand( u32 Command, u32 Length, u32 Address, u32 Offset )
return 0x66556677;
}

PanicAlertT("Unhandeled Media Board Execute");
PanicAlertT("Unhandled Media Board Execute");
break;
}

Expand Down
76 changes: 63 additions & 13 deletions Source/Core/Core/Src/HW/EXI_DeviceAMBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,62 @@ void CEXIAMBaseboard::TransferByte(u8& _byte)
{
case 0x01:
m_backoffset = (m_command[1] << 8) | m_command[2];
WARN_LOG(SP1,"AM-BB COMMAND: Backup Offset:%04X", m_backoffset );
DEBUG_LOG(SP1,"AM-BB COMMAND: Backup Offset:%04X", m_backoffset );
m_backup->Seek( m_backoffset, SEEK_SET );
_byte = 0x01;
break;
case 0x02:
WARN_LOG(SP1,"AM-BB COMMAND: Backup Write:%04X-%02X", m_backoffset, m_command[1] );
DEBUG_LOG(SP1,"AM-BB COMMAND: Backup Write:%04X-%02X", m_backoffset, m_command[1] );
m_backup->WriteBytes( &m_command[1], 1 );
m_backup->Flush();
_byte = 0x01;
break;
case 0x03:
WARN_LOG(SP1,"AM-BB COMMAND: Backup Read :%04X", m_backoffset );
DEBUG_LOG(SP1,"AM-BB COMMAND: Backup Read :%04X", m_backoffset );
_byte = 0x01;
break;
// Unknown
case 0x05:
_byte = 0x04;
break;
// Clear IRQ
case 0x82:
WARN_LOG(SP1,"AM-BB COMMAND: 0x82 :%02X %02X", m_command[1], m_command[2] );
_byte = 0x04;
break;
// Unknown
case 0x83:
WARN_LOG(SP1,"AM-BB COMMAND: 0x83 :%02X %02X", m_command[1], m_command[2] );
_byte = 0x04;
break;
// Unknown - 2 byte out
case 0x86:
WARN_LOG(SP1,"AM-BB COMMAND: 0x86 :%02X %02X", m_command[1], m_command[2] );
_byte = 0x04;
break;
// Unknown
case 0x87:
WARN_LOG(SP1,"AM-BB COMMAND: 0x87 :%02X %02X", m_command[1], m_command[2] );
_byte = 0x04;
break;
// Unknown
case 0xFF:
WARN_LOG(SP1,"AM-BB COMMAND: 0xFF :%02X %02X", m_command[1], m_command[2] );
if( (m_command[1] == 0) && (m_command[2] == 0) )
{
m_have_irq = true;
m_irq_timer = 0;
m_irq_status = 0x02;
}
if( (m_command[1] == 2) && (m_command[2] == 1) )
{
m_irq_status = 0;
}
_byte = 0x04;
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;
break;
}
}
Expand All @@ -109,11 +143,19 @@ void CEXIAMBaseboard::TransferByte(u8& _byte)
break;
// IMR - 2 byte out
case 0x82:
_byte = 0x00;
if(m_position == 6)
{
_byte = m_irq_status;
m_have_irq = false;
}
else
{
_byte = 0x00;
}
break;
case 0x86: // ?
case 0x87: // ?
_byte = 0x04;
// ? - 2 byte out
case 0x86:
_byte = 0x00;
break;
default:
_dbg_assert_msg_(SP1, 0, "Unknown AM-BB command");
Expand All @@ -132,8 +174,16 @@ void CEXIAMBaseboard::TransferByte(u8& _byte)
bool CEXIAMBaseboard::IsInterruptSet()
{
if (m_have_irq)
{
DEBUG_LOG(SP1, "AM-BB IRQ");
return m_have_irq;
if( ++m_irq_timer > 4 )
m_have_irq = false;
return 1;
}
else
{
return 0;
}
}

void CEXIAMBaseboard::DoState(PointerWrap &p)
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 @@ -21,6 +21,8 @@ class CEXIAMBaseboard : public IEXIDevice
virtual void TransferByte(u8& _uByte);
int m_position;
bool m_have_irq;
u32 m_irq_timer;
u32 m_irq_status;
unsigned char m_command[4];
unsigned short m_backoffset;
File::IOFile *m_backup;
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,10 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
player_data[0] |= 0x40;
// Item button
if( PadStatus.button & PAD_BUTTON_A )
player_data[1] |= 0x40;
player_data[1] |= 0x20;
// VS-Cancel button
if( PadStatus.button & PAD_BUTTON_B )
player_data[1] |= 0x10;
player_data[1] |= 0x02;
break;
}

Expand Down Expand Up @@ -1027,7 +1027,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
d10_1 &= ~1;
break;
default:
DEBUG_LOG(AMBASEBOARDDEBUG, "JVS IO, node=%d, command=%02x", node, cmd);
ERROR_LOG(AMBASEBOARDDEBUG, "JVS IO, node=%d, command=%02x", node, cmd);
break;
}

Expand Down

0 comments on commit afba901

Please sign in to comment.