Update N64 System/Mips files to Allman
This commit is contained in:
parent
1b4d2d0cfb
commit
3eddfb8115
|
@ -17,6 +17,7 @@ CAudio::CAudio (void)
|
|||
|
||||
CAudio::~CAudio (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAudio::Reset ( void )
|
||||
|
@ -65,12 +66,16 @@ void CAudio::LenChanged ( void )
|
|||
}
|
||||
WriteTraceF(TraceAudio,__FUNCTION__ ": Set Timer AI_LEN_REG: %d m_CountsPerByte: %d",g_Reg->AI_LEN_REG,m_CountsPerByte);
|
||||
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,g_Reg->AI_LEN_REG * m_CountsPerByte,false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTraceF(TraceAudio,__FUNCTION__ ": Increasing Second Buffer (m_SecondBuff %d Increase: %d)",m_SecondBuff,g_Reg->AI_LEN_REG);
|
||||
m_SecondBuff += g_Reg->AI_LEN_REG;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0");
|
||||
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
|
||||
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
|
||||
|
@ -92,7 +97,9 @@ void CAudio::InterruptTimerDone ( void )
|
|||
{
|
||||
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false);
|
||||
m_SecondBuff = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_Reg->m_AudioIntrReg == 0)
|
||||
{
|
||||
g_System->SyncToAudio();
|
||||
|
@ -128,7 +135,8 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
|
|||
WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,g_Reg->AI_BITRATE_REG);
|
||||
DWORD Frequency;
|
||||
|
||||
switch (System) {
|
||||
switch (System)
|
||||
{
|
||||
case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break;
|
||||
case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break;
|
||||
default: Frequency = 48681812 / (Dacrate + 1); break;
|
||||
|
@ -141,4 +149,3 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
|
|||
|
||||
m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
class CAudio
|
||||
{
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ai_full = 0x80000000,
|
||||
ai_busy = 0x40000000,
|
||||
};
|
||||
|
|
|
@ -14,10 +14,13 @@ CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
|
|||
m_FlashRam(FlashRam),
|
||||
m_Sram(Sram)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDMA::OnFirstDMA (void) {
|
||||
switch (g_Rom->CicChipID()) {
|
||||
void CDMA::OnFirstDMA (void)
|
||||
{
|
||||
switch (g_Rom->CicChipID())
|
||||
{
|
||||
case CIC_NUS_6101: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
case CIC_UNKNOWN:
|
||||
case CIC_NUS_6102: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
|
||||
|
@ -28,21 +31,30 @@ void CDMA::OnFirstDMA (void) {
|
|||
}
|
||||
}
|
||||
|
||||
void CDMA::PI_DMA_READ (void) {
|
||||
void CDMA::PI_DMA_READ (void)
|
||||
{
|
||||
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
|
||||
|
||||
if ( g_Reg->PI_DRAM_ADDR_REG + g_Reg->PI_RD_LEN_REG + 1 > g_MMU->RdramSize())
|
||||
{
|
||||
if (bHaveDebugger()) { g_Notify->DisplayError(L"PI_DMA_READ not in Memory"); }
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"PI_DMA_READ not in Memory");
|
||||
}
|
||||
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->CheckInterrupts();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) {
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Sram; }
|
||||
if (g_System->m_SaveUsing == SaveChip_Sram) {
|
||||
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
|
||||
{
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto)
|
||||
{
|
||||
g_System->m_SaveUsing = SaveChip_Sram;
|
||||
}
|
||||
if (g_System->m_SaveUsing == SaveChip_Sram)
|
||||
{
|
||||
m_Sram.DmaToSram(
|
||||
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
|
||||
g_Reg->PI_CART_ADDR_REG - 0x08000000,
|
||||
|
@ -53,7 +65,8 @@ void CDMA::PI_DMA_READ (void) {
|
|||
g_Reg->CheckInterrupts();
|
||||
return;
|
||||
}
|
||||
if (g_System->m_SaveUsing == SaveChip_FlashRam) {
|
||||
if (g_System->m_SaveUsing == SaveChip_FlashRam)
|
||||
{
|
||||
m_FlashRam.DmaToFlashram(
|
||||
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
|
||||
g_Reg->PI_CART_ADDR_REG - 0x08000000,
|
||||
|
@ -102,9 +115,14 @@ void CDMA::PI_DMA_WRITE (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) {
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Sram; }
|
||||
if (g_System->m_SaveUsing == SaveChip_Sram) {
|
||||
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
|
||||
{
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto)
|
||||
{
|
||||
g_System->m_SaveUsing = SaveChip_Sram;
|
||||
}
|
||||
if (g_System->m_SaveUsing == SaveChip_Sram)
|
||||
{
|
||||
m_Sram.DmaFromSram(
|
||||
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
|
||||
g_Reg->PI_CART_ADDR_REG - 0x08000000,
|
||||
|
@ -115,7 +133,8 @@ void CDMA::PI_DMA_WRITE (void)
|
|||
g_Reg->CheckInterrupts();
|
||||
return;
|
||||
}
|
||||
if (g_System->m_SaveUsing == SaveChip_FlashRam) {
|
||||
if (g_System->m_SaveUsing == SaveChip_FlashRam)
|
||||
{
|
||||
m_FlashRam.DmaFromFlashram(
|
||||
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
|
||||
g_Reg->PI_CART_ADDR_REG - 0x08000000,
|
||||
|
@ -133,7 +152,8 @@ void CDMA::PI_DMA_WRITE (void)
|
|||
DWORD i;
|
||||
#ifdef tofix
|
||||
#ifdef ROM_IN_MAPSPACE
|
||||
if (WrittenToRom) {
|
||||
if (WrittenToRom)
|
||||
{
|
||||
DWORD OldProtect;
|
||||
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
|
||||
}
|
||||
|
@ -142,17 +162,23 @@ void CDMA::PI_DMA_WRITE (void)
|
|||
BYTE * ROM = g_Rom->GetRomAddress();
|
||||
BYTE * RDRAM = g_MMU->Rdram();
|
||||
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
|
||||
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize()) {
|
||||
for (i = 0; i < PI_WR_LEN_REG; i ++) {
|
||||
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
|
||||
{
|
||||
for (i = 0; i < PI_WR_LEN_REG; i ++)
|
||||
{
|
||||
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD Len;
|
||||
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
|
||||
for (i = 0; i < Len; i ++) {
|
||||
for (i = 0; i < Len; i ++)
|
||||
{
|
||||
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
|
||||
}
|
||||
for (i = Len; i < PI_WR_LEN_REG - Len; i ++) {
|
||||
for (i = Len; i < PI_WR_LEN_REG - Len; i ++)
|
||||
{
|
||||
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +208,8 @@ void CDMA::PI_DMA_WRITE (void)
|
|||
|
||||
}
|
||||
|
||||
void CDMA::SP_DMA_READ (void) {
|
||||
void CDMA::SP_DMA_READ (void)
|
||||
{
|
||||
g_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF;
|
||||
|
||||
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
|
||||
|
@ -205,9 +232,18 @@ void CDMA::SP_DMA_READ (void) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
|
||||
memcpy( g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF), g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG,
|
||||
g_Reg->SP_RD_LEN_REG + 1 );
|
||||
|
@ -236,9 +272,18 @@ void CDMA::SP_DMA_WRITE (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
|
||||
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
|
||||
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
|
||||
memcpy( g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
|
||||
g_Reg->SP_WR_LEN_REG + 1);
|
||||
|
@ -246,4 +291,3 @@ void CDMA::SP_DMA_WRITE (void)
|
|||
g_Reg->SP_DMA_BUSY_REG = 0;
|
||||
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,5 +33,3 @@ private:
|
|||
|
||||
void OnFirstDMA ( void );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@ CEeprom::CEeprom (bool ReadOnly):
|
|||
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
|
||||
}
|
||||
|
||||
CEeprom::~CEeprom (void) {
|
||||
if (m_hFile) {
|
||||
CEeprom::~CEeprom (void)
|
||||
{
|
||||
if (m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = NULL;
|
||||
}
|
||||
|
@ -31,15 +33,21 @@ unsigned char byte2bcd(int n)
|
|||
return (unsigned char)(((n / 10) << 4) | (n % 10));
|
||||
}
|
||||
|
||||
void CEeprom::EepromCommand ( BYTE * Command) {
|
||||
void CEeprom::EepromCommand ( BYTE * Command)
|
||||
{
|
||||
time_t curtime_time;
|
||||
struct tm curtime;
|
||||
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Eeprom_4K; }
|
||||
if (g_System->m_SaveUsing == SaveChip_Auto)
|
||||
{
|
||||
g_System->m_SaveUsing = SaveChip_Eeprom_4K;
|
||||
}
|
||||
|
||||
switch (Command[2]) {
|
||||
switch (Command[2])
|
||||
{
|
||||
case 0: // check
|
||||
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) {
|
||||
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K)
|
||||
{
|
||||
Command[1] |= 0x80;
|
||||
break;
|
||||
}
|
||||
|
@ -52,20 +60,34 @@ void CEeprom::EepromCommand ( BYTE * Command) {
|
|||
Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
|
||||
if ((Command[1] & 3) > 2)
|
||||
Command[5] = 0x00;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Command[3] = 0x00;
|
||||
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
|
||||
Command[5] = 0x00;
|
||||
}
|
||||
break;
|
||||
case 4: // Read from Eeprom
|
||||
if (Command[0] != 2 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
|
||||
if (Command[1] != 8 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
|
||||
if (Command[0] != 2 && bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
|
||||
}
|
||||
if (Command[1] != 8 && bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
|
||||
}
|
||||
ReadFrom(&Command[4],Command[3]);
|
||||
break;
|
||||
case 5: //Write to Eeprom
|
||||
if (Command[0] != 10 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
|
||||
if (Command[1] != 1 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
|
||||
if (Command[0] != 10 && bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
|
||||
}
|
||||
if (Command[1] != 1 && bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
|
||||
}
|
||||
WriteTo(&Command[4],Command[3]);
|
||||
break;
|
||||
case 6: //RTC Status query
|
||||
|
@ -74,7 +96,7 @@ void CEeprom::EepromCommand ( BYTE * Command) {
|
|||
Command[5] = 0x00;
|
||||
break;
|
||||
case 7: //Read RTC block
|
||||
switch(Command[3])
|
||||
switch (Command[3])
|
||||
{
|
||||
case 0: //Block number
|
||||
Command[4] = 0x00;
|
||||
|
@ -101,14 +123,21 @@ void CEeprom::EepromCommand ( BYTE * Command) {
|
|||
break;
|
||||
case 8:
|
||||
//Write RTC, unimplemented
|
||||
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) { g_Notify->DisplayError(L"Write RTC, unimplemented"); }
|
||||
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
|
||||
{
|
||||
g_Notify->DisplayError(L"Write RTC, unimplemented");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) { g_Notify->DisplayError(L"Unknown EepromCommand %d",Command[2]); }
|
||||
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
|
||||
{
|
||||
g_Notify->DisplayError(L"Unknown EepromCommand %d",Command[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEeprom::LoadEeprom (void) {
|
||||
void CEeprom::LoadEeprom (void)
|
||||
{
|
||||
CPath FileName;
|
||||
DWORD dwRead;
|
||||
|
||||
|
@ -135,7 +164,8 @@ void CEeprom::LoadEeprom (void) {
|
|||
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL);
|
||||
}
|
||||
|
||||
void CEeprom::ReadFrom(BYTE * Buffer, int line) {
|
||||
void CEeprom::ReadFrom(BYTE * Buffer, int line)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (m_hFile == NULL)
|
||||
|
@ -143,13 +173,14 @@ void CEeprom::ReadFrom(BYTE * Buffer, int line) {
|
|||
LoadEeprom();
|
||||
}
|
||||
|
||||
for(i=0; i < 8; i++)
|
||||
for (i=0; i < 8; i++)
|
||||
{
|
||||
Buffer[i] = m_EEPROM[line*8+i];
|
||||
}
|
||||
}
|
||||
|
||||
void CEeprom::WriteTo(BYTE * Buffer, int line) {
|
||||
void CEeprom::WriteTo(BYTE * Buffer, int line)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
int i;
|
||||
|
||||
|
@ -157,7 +188,10 @@ void CEeprom::WriteTo(BYTE * Buffer, int line) {
|
|||
{
|
||||
LoadEeprom();
|
||||
}
|
||||
for(i=0;i<8;i++) { m_EEPROM[line*8+i]=Buffer[i]; }
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
m_EEPROM[line*8+i]=Buffer[i];
|
||||
}
|
||||
SetFilePointer(m_hFile,line*8,NULL,FILE_BEGIN);
|
||||
WriteFile( m_hFile,Buffer,8,&dwWritten,NULL );
|
||||
FlushFileBuffers(m_hFile);
|
||||
|
|
|
@ -18,10 +18,13 @@ CFlashram::CFlashram (bool ReadOnly):
|
|||
m_ReadOnly(ReadOnly),
|
||||
m_hFile(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFlashram::~CFlashram (void) {
|
||||
if (m_hFile) {
|
||||
CFlashram::~CFlashram (void)
|
||||
{
|
||||
if (m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = NULL;
|
||||
}
|
||||
|
@ -32,10 +35,15 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
|
|||
BYTE FlipBuffer[0x10000];
|
||||
DWORD dwRead, count;
|
||||
|
||||
switch (m_FlashFlag) {
|
||||
switch (m_FlashFlag)
|
||||
{
|
||||
case FLASHRAM_MODE_READ:
|
||||
if (m_hFile == NULL) {
|
||||
if (!LoadFlashram()) { return; }
|
||||
if (m_hFile == NULL)
|
||||
{
|
||||
if (!LoadFlashram())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (len > 0x10000)
|
||||
{
|
||||
|
@ -57,10 +65,12 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
|
|||
StartOffset = StartOffset << 1;
|
||||
SetFilePointer(m_hFile,StartOffset,NULL,FILE_BEGIN);
|
||||
ReadFile(m_hFile,FlipBuffer,len,&dwRead,NULL);
|
||||
for (count = dwRead; (int)count < len; count ++) {
|
||||
for (count = dwRead; (int)count < len; count ++)
|
||||
{
|
||||
FlipBuffer[count] = 0xFF;
|
||||
}
|
||||
_asm {
|
||||
_asm
|
||||
{
|
||||
mov edi, dest
|
||||
lea ecx, [FlipBuffer]
|
||||
mov edx, 0
|
||||
|
@ -94,8 +104,10 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
|
|||
}
|
||||
}
|
||||
|
||||
void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) {
|
||||
switch (m_FlashFlag) {
|
||||
void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len)
|
||||
{
|
||||
switch (m_FlashFlag)
|
||||
{
|
||||
case FLASHRAM_MODE_WRITE:
|
||||
m_FlashRamPointer = Source;
|
||||
break;
|
||||
|
@ -110,7 +122,8 @@ void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) {
|
|||
|
||||
DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr)
|
||||
{
|
||||
switch (PAddr) {
|
||||
switch (PAddr)
|
||||
{
|
||||
case 0x08000000: return (DWORD)(m_FlashStatus >> 32);
|
||||
default:
|
||||
if (bHaveDebugger())
|
||||
|
@ -122,7 +135,8 @@ DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr)
|
|||
return (DWORD)(m_FlashStatus >> 32);
|
||||
}
|
||||
|
||||
bool CFlashram::LoadFlashram (void) {
|
||||
bool CFlashram::LoadFlashram (void)
|
||||
{
|
||||
CPath FileName;
|
||||
|
||||
FileName.SetDriveDirectory( g_Settings->LoadString(Directory_NativeSave).c_str());
|
||||
|
@ -146,27 +160,36 @@ bool CFlashram::LoadFlashram (void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) {
|
||||
void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command)
|
||||
{
|
||||
BYTE EmptyBlock[128];
|
||||
DWORD dwWritten;
|
||||
|
||||
switch (FlashRAM_Command & 0xFF000000) {
|
||||
switch (FlashRAM_Command & 0xFF000000)
|
||||
{
|
||||
case 0xD2000000:
|
||||
switch (m_FlashFlag) {
|
||||
switch (m_FlashFlag)
|
||||
{
|
||||
case FLASHRAM_MODE_NOPES: break;
|
||||
case FLASHRAM_MODE_READ: break;
|
||||
case FLASHRAM_MODE_STATUS: break;
|
||||
case FLASHRAM_MODE_ERASE:
|
||||
memset(EmptyBlock,0xFF,sizeof(EmptyBlock));
|
||||
if (m_hFile == NULL) {
|
||||
if (!LoadFlashram()) { return; }
|
||||
if (!LoadFlashram())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetFilePointer(m_hFile,m_FlashRAM_Offset,NULL,FILE_BEGIN);
|
||||
WriteFile(m_hFile,EmptyBlock,128,&dwWritten,NULL);
|
||||
break;
|
||||
case FLASHRAM_MODE_WRITE:
|
||||
if (m_hFile == NULL) {
|
||||
if (!LoadFlashram()) { return; }
|
||||
if (!LoadFlashram())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
BYTE FlipBuffer[128];
|
||||
|
@ -174,7 +197,8 @@ void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) {
|
|||
BYTE * FlashRamPointer = m_FlashRamPointer;
|
||||
|
||||
memset(FlipBuffer,0,sizeof(FlipBuffer));
|
||||
_asm {
|
||||
_asm
|
||||
{
|
||||
lea edi, [FlipBuffer]
|
||||
mov ecx, FlashRamPointer
|
||||
mov edx, 0
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
class CFlashram :
|
||||
private CDebugSettings
|
||||
{
|
||||
enum Modes {
|
||||
enum Modes
|
||||
{
|
||||
FLASHRAM_MODE_NOPES = 0,
|
||||
FLASHRAM_MODE_ERASE = 1,
|
||||
FLASHRAM_MODE_WRITE = 2,
|
||||
|
|
|
@ -10,15 +10,21 @@
|
|||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
|
||||
DWORD CMemoryLabel::AsciiToHex (char * HexValue) {
|
||||
DWORD CMemoryLabel::AsciiToHex (char * HexValue)
|
||||
{
|
||||
DWORD Count, Finish, Value = 0;
|
||||
|
||||
Finish = strlen(HexValue);
|
||||
if (Finish > 8 ) { Finish = 8; }
|
||||
if (Finish > 8 )
|
||||
{
|
||||
Finish = 8;
|
||||
}
|
||||
|
||||
for (Count = 0; Count < Finish; Count++){
|
||||
for (Count = 0; Count < Finish; Count++)
|
||||
{
|
||||
Value = (Value << 4);
|
||||
switch( HexValue[Count] ) {
|
||||
switch ( HexValue[Count] )
|
||||
{
|
||||
case '0': break;
|
||||
case '1': Value += 1; break;
|
||||
case '2': Value += 2; break;
|
||||
|
@ -49,9 +55,11 @@ DWORD CMemoryLabel::AsciiToHex (char * HexValue) {
|
|||
return Value;
|
||||
}
|
||||
|
||||
void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... ) {
|
||||
void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... )
|
||||
{
|
||||
StringMap::iterator Item = m_LabelList.find(Address);
|
||||
if (Item == m_LabelList.end()) {
|
||||
if (Item == m_LabelList.end())
|
||||
{
|
||||
char Msg[1000];
|
||||
va_list ap;
|
||||
|
||||
|
@ -65,9 +73,11 @@ void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... ) {
|
|||
}
|
||||
}
|
||||
|
||||
stdstr CMemoryLabel::LabelName ( DWORD Address ) const {
|
||||
stdstr CMemoryLabel::LabelName ( DWORD Address ) const
|
||||
{
|
||||
//StringMap::iterator theIterator = m_LabelList.find(Address);
|
||||
//if (theIterator != m_LabelList.end()) {
|
||||
//if (theIterator != m_LabelList.end())
|
||||
//{
|
||||
// return (*theIterator).second;
|
||||
//}
|
||||
|
||||
|
@ -76,36 +86,47 @@ stdstr CMemoryLabel::LabelName ( DWORD Address ) const {
|
|||
return stdstr(strLabelName);
|
||||
}
|
||||
|
||||
stdstr CMemoryLabel::StoredLabelName ( DWORD Address ) {
|
||||
stdstr CMemoryLabel::StoredLabelName ( DWORD Address )
|
||||
{
|
||||
StringMap::iterator theIterator = m_LabelList.find(Address);
|
||||
if (theIterator != m_LabelList.end()) {
|
||||
if (theIterator != m_LabelList.end())
|
||||
{
|
||||
return (*theIterator).second;
|
||||
}
|
||||
return stdstr("");
|
||||
}
|
||||
|
||||
void CMemoryLabel::LoadLabelList ( char * file ) {
|
||||
void CMemoryLabel::LoadLabelList ( char * file )
|
||||
{
|
||||
m_LabelList.clear();
|
||||
CurrentLabelFile = file;
|
||||
|
||||
HANDLE hFile = CreateFile(file,GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
|
||||
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE) { return; }
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
|
||||
|
||||
DWORD FileSize = GetFileSize(hFile,NULL);
|
||||
void * FileContents = VirtualAlloc(NULL,FileSize,MEM_COMMIT,PAGE_READWRITE );
|
||||
|
||||
if (FileContents) {
|
||||
if (FileContents)
|
||||
{
|
||||
DWORD dwRead;
|
||||
if (!ReadFile(hFile,FileContents,FileSize,&dwRead,NULL)) {
|
||||
if (!ReadFile(hFile,FileContents,FileSize,&dwRead,NULL))
|
||||
{
|
||||
VirtualFree(FileContents, 0, MEM_RELEASE);
|
||||
FileContents = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (FileContents) { ProcessCODFile((BYTE *)FileContents, FileSize); }
|
||||
if (FileContents)
|
||||
{
|
||||
ProcessCODFile((BYTE *)FileContents, FileSize);
|
||||
}
|
||||
|
||||
VirtualFree(FileContents, 0, MEM_RELEASE);
|
||||
CloseHandle(hFile);
|
||||
|
@ -113,21 +134,27 @@ void CMemoryLabel::LoadLabelList ( char * file ) {
|
|||
m_NewLabels = 0;
|
||||
}
|
||||
|
||||
// How many new labels been added since loading/saveing label file
|
||||
int CMemoryLabel::NewLabels ( void ) {
|
||||
// How many new labels been added since loading/saving label file
|
||||
int CMemoryLabel::NewLabels ( void )
|
||||
{
|
||||
return m_NewLabels;
|
||||
}
|
||||
|
||||
void CMemoryLabel::SaveLabelList ( void ) {
|
||||
void CMemoryLabel::SaveLabelList ( void )
|
||||
{
|
||||
m_NewLabels = 0;
|
||||
|
||||
if (CurrentLabelFile.length() == 0) { return; }
|
||||
if (CurrentLabelFile.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HANDLE hFile = CreateFile(CurrentLabelFile.c_str(),GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
|
||||
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
|
||||
|
||||
for (StringMap::iterator Item = m_LabelList.begin(); Item != m_LabelList.end(); Item++) {
|
||||
for (StringMap::iterator Item = m_LabelList.begin(); Item != m_LabelList.end(); Item++)
|
||||
{
|
||||
char Text[300];
|
||||
DWORD dwWritten;
|
||||
|
||||
|
@ -140,33 +167,51 @@ void CMemoryLabel::SaveLabelList ( void ) {
|
|||
|
||||
}
|
||||
|
||||
void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen) {
|
||||
void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen)
|
||||
{
|
||||
char * CurrentPos = (char *)File;
|
||||
char Label[40];
|
||||
DWORD Address;
|
||||
int Length;
|
||||
|
||||
while ( CurrentPos < (char *)File + FileLen ) {
|
||||
if (*CurrentPos != '0') { return; }
|
||||
while ( CurrentPos < (char *)File + FileLen )
|
||||
{
|
||||
if (*CurrentPos != '0')
|
||||
{
|
||||
return;
|
||||
}
|
||||
CurrentPos += 1;
|
||||
if (*CurrentPos != 'x') { return; }
|
||||
if (*CurrentPos != 'x')
|
||||
{
|
||||
return;
|
||||
}
|
||||
CurrentPos += 1;
|
||||
|
||||
if (strchr(CurrentPos,',') - CurrentPos != 8) { return; }
|
||||
if (strchr(CurrentPos,',') - CurrentPos != 8)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Address = AsciiToHex (CurrentPos);
|
||||
CurrentPos += 9;
|
||||
|
||||
|
||||
if (strchr(CurrentPos,'\r') == NULL) {
|
||||
if (strchr(CurrentPos,'\r') == NULL)
|
||||
{
|
||||
Length = strchr(CurrentPos,'\n') - CurrentPos;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Length = strchr(CurrentPos,'\r') - CurrentPos;
|
||||
if (Length > (strchr(CurrentPos,'\n') - CurrentPos)) {
|
||||
if (Length > (strchr(CurrentPos,'\n') - CurrentPos))
|
||||
{
|
||||
Length = strchr(CurrentPos,'\n') - CurrentPos;
|
||||
}
|
||||
}
|
||||
|
||||
if (Length > 40) { Length = 40; }
|
||||
if (Length > 40)
|
||||
{
|
||||
Length = 40;
|
||||
}
|
||||
memcpy(Label,CurrentPos,Length);
|
||||
Label[Length] = '\0';
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
typedef std::map<DWORD, stdstr> StringMap;
|
||||
|
||||
class CMemoryLabel {
|
||||
class CMemoryLabel
|
||||
{
|
||||
// Variable dealing with Labels
|
||||
StringMap m_LabelList;
|
||||
int m_NewLabels;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -160,7 +160,7 @@ private:
|
|||
DWORD m_FieldSerration;
|
||||
DWORD m_TempValue;
|
||||
|
||||
//Initilizing and reseting information about the memory system
|
||||
//Initializing and resetting information about the memory system
|
||||
void FreeMemory ( void );
|
||||
|
||||
mutable char m_strLabelName[100];
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
static BYTE Mempaks[4][0x8000];
|
||||
HANDLE hMempakFile[4];
|
||||
|
||||
void Mempak::Close(void) {
|
||||
void Mempak::Close(void)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (hMempakFile[i])
|
||||
|
@ -23,7 +24,8 @@ void Mempak::Close(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void LoadMempak (int Control) {
|
||||
void LoadMempak (int Control)
|
||||
{
|
||||
CPath FileName;
|
||||
DWORD dwRead;
|
||||
stdstr MempakName;
|
||||
|
@ -92,21 +94,28 @@ void LoadMempak (int Control) {
|
|||
}
|
||||
}
|
||||
|
||||
BYTE Mempak::CalculateCrc(BYTE * DataToCrc) {
|
||||
BYTE Mempak::CalculateCrc(BYTE * DataToCrc)
|
||||
{
|
||||
DWORD Count;
|
||||
DWORD XorTap;
|
||||
|
||||
int Length;
|
||||
BYTE CRC = 0;
|
||||
|
||||
for (Count = 0; Count < 0x21; Count++) {
|
||||
for (Length = 0x80; Length >= 1; Length >>= 1) {
|
||||
for (Count = 0; Count < 0x21; Count++)
|
||||
{
|
||||
for (Length = 0x80; Length >= 1; Length >>= 1)
|
||||
{
|
||||
XorTap = (CRC & 0x80) ? 0x85 : 0;
|
||||
CRC <<= 1;
|
||||
if (Count == 0x20) {
|
||||
if (Count == 0x20)
|
||||
{
|
||||
CRC &= 0xFF;
|
||||
} else {
|
||||
if ((*DataToCrc & Length) != 0) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*DataToCrc & Length) != 0)
|
||||
{
|
||||
CRC |= 1;
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +127,18 @@ BYTE Mempak::CalculateCrc(BYTE * DataToCrc) {
|
|||
return CRC;
|
||||
}
|
||||
|
||||
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer) {
|
||||
if (Address < 0x8000) {
|
||||
if (hMempakFile[Control] == NULL) {
|
||||
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer)
|
||||
{
|
||||
if (Address < 0x8000)
|
||||
{
|
||||
if (hMempakFile[Control] == NULL)
|
||||
{
|
||||
LoadMempak(Control);
|
||||
}
|
||||
memcpy(Buffer, &Mempaks[Control][Address], 0x20);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(Buffer, 0, 0x20);
|
||||
/* Rumble pack area */
|
||||
}
|
||||
|
@ -132,18 +146,23 @@ void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer) {
|
|||
Buffer[0x20] = CalculateCrc(Buffer);
|
||||
}
|
||||
|
||||
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer) {
|
||||
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
|
||||
if (Address < 0x8000) {
|
||||
if (hMempakFile[Control] == NULL) {
|
||||
if (Address < 0x8000)
|
||||
{
|
||||
if (hMempakFile[Control] == NULL)
|
||||
{
|
||||
LoadMempak(Control);
|
||||
}
|
||||
memcpy(&Mempaks[Control][Address], Buffer, 0x20);
|
||||
|
||||
SetFilePointer(hMempakFile[Control], 0,NULL,FILE_BEGIN);
|
||||
WriteFile(hMempakFile[Control], &Mempaks[Control][0], 0x8000, &dwWritten, NULL);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Rumble pack area */
|
||||
}
|
||||
Buffer[0x20] = CalculateCrc(Buffer);
|
||||
|
|
|
@ -10,30 +10,35 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
typedef union {
|
||||
typedef union
|
||||
{
|
||||
unsigned long Hex;
|
||||
unsigned char Ascii[4];
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned offset : 16;
|
||||
unsigned rt : 5;
|
||||
unsigned rs : 5;
|
||||
unsigned op : 6;
|
||||
};
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned immediate : 16;
|
||||
unsigned : 5;
|
||||
unsigned base : 5;
|
||||
unsigned : 6;
|
||||
};
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned target : 26;
|
||||
unsigned : 6;
|
||||
};
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned funct : 6;
|
||||
unsigned sa : 5;
|
||||
unsigned rd : 5;
|
||||
|
@ -42,7 +47,8 @@ typedef union {
|
|||
unsigned : 6;
|
||||
};
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned : 6;
|
||||
unsigned fd : 5;
|
||||
unsigned fs : 5;
|
||||
|
|
|
@ -45,6 +45,7 @@ CPifRam::CPifRam( bool SavesReadOnly ) :
|
|||
|
||||
CPifRam::~CPifRam( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPifRam::Reset ( void )
|
||||
|
@ -66,16 +67,21 @@ void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length)
|
|||
char key, *lut;
|
||||
int i, sgn, mag, mod;
|
||||
|
||||
for (key = 0xB, lut = lut0, i = 0; i < length; i++) {
|
||||
for (key = 0xB, lut = lut0, i = 0; i < length; i++)
|
||||
{
|
||||
respone[i] = (key + 5 * challenge[i]) & 0xF;
|
||||
key = lut[respone[i]];
|
||||
sgn = (respone[i] >> 3) & 0x1;
|
||||
mag = ((sgn == 1) ? ~respone[i] : respone[i]) & 0x7;
|
||||
mod = (mag % 3 == 1) ? sgn : 1 - sgn;
|
||||
if (lut == lut1 && (respone[i] == 0x1 || respone[i] == 0x9))
|
||||
{
|
||||
mod = 1;
|
||||
}
|
||||
if (lut == lut1 && (respone[i] == 0xB || respone[i] == 0xE))
|
||||
{
|
||||
mod = 0;
|
||||
}
|
||||
lut = (mod == 1) ? lut1 : lut0;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +99,8 @@ void CPifRam::PifRamRead (void)
|
|||
int Channel = 0;
|
||||
for (int CurPos = 0; CurPos < 0x40; CurPos ++)
|
||||
{
|
||||
switch(m_PifRam[CurPos]) {
|
||||
switch (m_PifRam[CurPos])
|
||||
{
|
||||
case 0x00:
|
||||
Channel += 1;
|
||||
if (Channel > 6)
|
||||
|
@ -107,31 +114,49 @@ void CPifRam::PifRamRead (void)
|
|||
default:
|
||||
if ((m_PifRam[CurPos] & 0xC0) == 0)
|
||||
{
|
||||
if (Channel < 4) {
|
||||
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
|
||||
if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Channel,&m_PifRam[CurPos]); }
|
||||
} else {
|
||||
if (Channel < 4)
|
||||
{
|
||||
if (Controllers[Channel].Present && Controllers[Channel].RawData)
|
||||
{
|
||||
if (g_Plugins->Control()->ReadController)
|
||||
{
|
||||
g_Plugins->Control()->ReadController(Channel,&m_PifRam[CurPos]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadControllerCommand(Channel,&m_PifRam[CurPos]);
|
||||
}
|
||||
}
|
||||
CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1;
|
||||
Channel += 1;
|
||||
} else {
|
||||
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]); }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
g_Notify->DisplayError(L"Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]);
|
||||
}
|
||||
CurPos = 0x40;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(-1,NULL); }
|
||||
if (g_Plugins->Control()->ReadController)
|
||||
{
|
||||
g_Plugins->Control()->ReadController(-1,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CPifRam::PifRamWrite (void) {
|
||||
void CPifRam::PifRamWrite (void)
|
||||
{
|
||||
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
|
||||
int Channel = 0, CurPos;
|
||||
|
||||
if( m_PifRam[0x3F] > 0x1) {
|
||||
switch (m_PifRam[0x3F]) {
|
||||
if ( m_PifRam[0x3F] > 0x1)
|
||||
{
|
||||
switch (m_PifRam[0x3F])
|
||||
{
|
||||
case 0x02:
|
||||
// format the 'challenge' message into 30 nibbles for X-Scale's CIC code
|
||||
{
|
||||
|
@ -173,31 +198,51 @@ void CPifRam::PifRamWrite (void) {
|
|||
memset(m_PifRam,0,0x40);
|
||||
break;
|
||||
default:
|
||||
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unkown PifRam control: %d",m_PifRam[0x3F]); }
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
g_Notify->DisplayError(L"Unkown PifRam control: %d",m_PifRam[0x3F]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (CurPos = 0; CurPos < 0x40; CurPos++){
|
||||
switch(m_PifRam[CurPos]) {
|
||||
for (CurPos = 0; CurPos < 0x40; CurPos++)
|
||||
{
|
||||
switch (m_PifRam[CurPos]
|
||||
{
|
||||
case 0x00:
|
||||
Channel += 1;
|
||||
if (Channel > 6) { CurPos = 0x40; }
|
||||
if (Channel > 6)
|
||||
{
|
||||
CurPos = 0x40;
|
||||
}
|
||||
break;
|
||||
case 0xFE: CurPos = 0x40; break;
|
||||
case 0xFF: break;
|
||||
case 0xB4: case 0x56: case 0xB8: break; /* ??? */
|
||||
default:
|
||||
if ((m_PifRam[CurPos] & 0xC0) == 0) {
|
||||
if (Channel < 4) {
|
||||
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
|
||||
if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]); }
|
||||
} else {
|
||||
if ((m_PifRam[CurPos] & 0xC0) == 0)
|
||||
{
|
||||
if (Channel < 4)
|
||||
{
|
||||
if (Controllers[Channel].Present && Controllers[Channel].RawData)
|
||||
{
|
||||
if (g_Plugins->Control()->ControllerCommand)
|
||||
{
|
||||
g_Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessControllerCommand(Channel,&m_PifRam[CurPos]);
|
||||
}
|
||||
} else if (Channel == 4) {
|
||||
}
|
||||
else if (Channel == 4)
|
||||
{
|
||||
EepromCommand(&m_PifRam[CurPos]);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
g_Notify->DisplayError(L"Command on channel 5?");
|
||||
|
@ -205,15 +250,23 @@ void CPifRam::PifRamWrite (void) {
|
|||
}
|
||||
CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1;
|
||||
Channel += 1;
|
||||
} else {
|
||||
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]); }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
g_Notify->DisplayError(L"Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]);
|
||||
}
|
||||
CurPos = 0x40;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_PifRam[0x3F] = 0;
|
||||
if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(-1,NULL); }
|
||||
if (g_Plugins->Control()->ControllerCommand)
|
||||
{
|
||||
g_Plugins->Control()->ControllerCommand(-1,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CPifRam::SI_DMA_READ (void)
|
||||
|
@ -233,16 +286,24 @@ void CPifRam::SI_DMA_READ (void)
|
|||
|
||||
PifRamRead();
|
||||
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
|
||||
if ((int)SI_DRAM_ADDR_REG < 0) {
|
||||
if ((int)SI_DRAM_ADDR_REG < 0)
|
||||
{
|
||||
int count, RdramPos;
|
||||
|
||||
RdramPos = (int)SI_DRAM_ADDR_REG;
|
||||
for (count = 0; count < 0x40; count++, RdramPos++) {
|
||||
if (RdramPos < 0) { continue; }
|
||||
for (count = 0; count < 0x40; count++, RdramPos++)
|
||||
{
|
||||
if (RdramPos < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
RDRAM[RdramPos ^3] = m_PifRam[count];
|
||||
}
|
||||
} else {
|
||||
_asm {
|
||||
}
|
||||
else
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov edi, dword ptr [SI_DRAM_ADDR_REG]
|
||||
mov edi, dword ptr [edi]
|
||||
add edi, RDRAM
|
||||
|
@ -267,13 +328,16 @@ void CPifRam::SI_DMA_READ (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (LogOptions.LogPRDMAMemStores) {
|
||||
if (LogOptions.LogPRDMAMemStores)
|
||||
{
|
||||
int count;
|
||||
char HexData[100], AsciiData[100], Addon[20];
|
||||
LogMessage("\tData DMAed to RDRAM:");
|
||||
LogMessage("\t--------------------");
|
||||
for (count = 0; count < 16; count ++ ) {
|
||||
if ((count % 4) == 0) {
|
||||
for (count = 0; count < 16; count ++ )
|
||||
{
|
||||
if ((count % 4) == 0)
|
||||
{
|
||||
sprintf(HexData,"\0");
|
||||
sprintf(AsciiData,"\0");
|
||||
}
|
||||
|
@ -281,7 +345,8 @@ void CPifRam::SI_DMA_READ (void)
|
|||
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
|
||||
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
|
||||
strcat(HexData,Addon);
|
||||
if (((count + 1) % 4) != 0) {
|
||||
if (((count + 1) % 4) != 0)
|
||||
{
|
||||
sprintf(Addon,"-");
|
||||
strcat(HexData,Addon);
|
||||
}
|
||||
|
@ -291,16 +356,20 @@ void CPifRam::SI_DMA_READ (void)
|
|||
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
|
||||
strcat(AsciiData,Addon);
|
||||
|
||||
if (((count + 1) % 4) == 0) {
|
||||
if (((count + 1) % 4) == 0)
|
||||
{
|
||||
LogMessage("\t%s %s",HexData, AsciiData);
|
||||
}
|
||||
}
|
||||
LogMessage("");
|
||||
}
|
||||
|
||||
if (g_System->bDelaySI()) {
|
||||
if (g_System->bDelaySI())
|
||||
{
|
||||
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_SI;
|
||||
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
@ -324,16 +393,24 @@ void CPifRam::SI_DMA_WRITE (void)
|
|||
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
|
||||
BYTE * RDRAM = g_MMU->Rdram();
|
||||
|
||||
if ((int)SI_DRAM_ADDR_REG < 0) {
|
||||
if ((int)SI_DRAM_ADDR_REG < 0)
|
||||
{
|
||||
int count, RdramPos;
|
||||
|
||||
RdramPos = (int)SI_DRAM_ADDR_REG;
|
||||
for (count = 0; count < 0x40; count++, RdramPos++) {
|
||||
if (RdramPos < 0) { m_PifRam[count] = 0; continue; }
|
||||
for (count = 0; count < 0x40; count++, RdramPos++)
|
||||
{
|
||||
if (RdramPos < 0)
|
||||
{
|
||||
m_PifRam[count] = 0; continue;
|
||||
}
|
||||
m_PifRam[count] = RDRAM[RdramPos ^3];
|
||||
}
|
||||
} else {
|
||||
_asm {
|
||||
}
|
||||
else
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov ecx, dword ptr [SI_DRAM_ADDR_REG]
|
||||
mov ecx, dword ptr [ecx]
|
||||
add ecx, RDRAM
|
||||
|
@ -358,14 +435,17 @@ void CPifRam::SI_DMA_WRITE (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (LogOptions.LogPRDMAMemLoads) {
|
||||
if (LogOptions.LogPRDMAMemLoads)
|
||||
{
|
||||
int count;
|
||||
char HexData[100], AsciiData[100], Addon[20];
|
||||
LogMessage("");
|
||||
LogMessage("\tData DMAed to the Pif Ram:");
|
||||
LogMessage("\t--------------------------");
|
||||
for (count = 0; count < 16; count ++ ) {
|
||||
if ((count % 4) == 0) {
|
||||
for (count = 0; count < 16; count ++ )
|
||||
{
|
||||
if ((count % 4) == 0)
|
||||
{
|
||||
sprintf(HexData,"\0");
|
||||
sprintf(AsciiData,"\0");
|
||||
}
|
||||
|
@ -373,7 +453,8 @@ void CPifRam::SI_DMA_WRITE (void)
|
|||
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
|
||||
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
|
||||
strcat(HexData,Addon);
|
||||
if (((count + 1) % 4) != 0) {
|
||||
if (((count + 1) % 4) != 0)
|
||||
{
|
||||
sprintf(Addon,"-");
|
||||
strcat(HexData,Addon);
|
||||
}
|
||||
|
@ -383,7 +464,8 @@ void CPifRam::SI_DMA_WRITE (void)
|
|||
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
|
||||
strcat(AsciiData,Addon);
|
||||
|
||||
if (((count + 1) % 4) == 0) {
|
||||
if (((count + 1) % 4) == 0)
|
||||
{
|
||||
LogMessage("\t%s %s",HexData, AsciiData);
|
||||
}
|
||||
}
|
||||
|
@ -392,9 +474,12 @@ void CPifRam::SI_DMA_WRITE (void)
|
|||
|
||||
PifRamWrite();
|
||||
|
||||
if (g_System->bDelaySI()) {
|
||||
if (g_System->bDelaySI())
|
||||
{
|
||||
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_SI;
|
||||
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
@ -405,48 +490,80 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
|
|||
{
|
||||
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
|
||||
|
||||
switch (Command[2]) {
|
||||
switch (Command[2])
|
||||
{
|
||||
case 0x00: // check
|
||||
case 0xFF: // reset & check ?
|
||||
if ((Command[1] & 0x80) != 0) { break; }
|
||||
if ((Command[1] & 0x80) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[1] != 3) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[0] != 1)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
if (Command[1] != 3)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
}
|
||||
if (Controllers[Control].Present == TRUE) {
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
Command[3] = 0x05;
|
||||
Command[4] = 0x00;
|
||||
switch ( Controllers[Control].Plugin) {
|
||||
switch ( Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RUMBLE_PAK: Command[5] = 1; break;
|
||||
case PLUGIN_MEMPAK: Command[5] = 1; break;
|
||||
case PLUGIN_RAW: Command[5] = 1; break;
|
||||
default: Command[5] = 0; break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
break;
|
||||
case 0x01: // read controller
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[1] != 4) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[0] != 1)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
if (Command[1] != 4)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
}
|
||||
if (Controllers[Control].Present == FALSE) {
|
||||
if (Controllers[Control].Present == FALSE)
|
||||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
break;
|
||||
case 0x02: //read from controller pack
|
||||
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: Before Gettting Results"); }
|
||||
if (LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Read: Before Gettting Results");
|
||||
}
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
if (Command[0] != 3) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[1] != 33) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[0] != 3)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
if (Command[1] != 33)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
}
|
||||
if (Controllers[Control].Present == TRUE) {
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
DWORD address = ((Command[3] << 8) | Command[4] & 0xE0);
|
||||
switch (Controllers[Control].Plugin) {
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RUMBLE_PAK:
|
||||
|
||||
memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20);
|
||||
|
@ -458,44 +575,70 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
|
|||
memset(&Command[5], 0, 0x20);
|
||||
Command[0x25] = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: After Gettting Results"); }
|
||||
if (LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Read: After Gettting Results");
|
||||
}
|
||||
break;
|
||||
case 0x03: //write controller pak
|
||||
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: Before Processing"); }
|
||||
if (LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Write: Before Processing");
|
||||
}
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
if (Command[0] != 35) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[1] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
|
||||
if (Command[0] != 35)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
if (Command[1] != 1)
|
||||
{
|
||||
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
|
||||
}
|
||||
}
|
||||
if (Controllers[Control].Present == TRUE) {
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
DWORD address = ((Command[3] << 8) | Command[4] & 0xE0 );
|
||||
switch (Controllers[Control].Plugin) {
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_MEMPAK: Mempak::WriteTo(Control, address, &Command[5]); break;
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break;
|
||||
case PLUGIN_RUMBLE_PAK:
|
||||
if ((address & 0xFFE0) == 0xC000 && g_Plugins->Control()->RumbleCommand != NULL) {
|
||||
if ((address & 0xFFE0) == 0xC000 && g_Plugins->Control()->RumbleCommand != NULL)
|
||||
{
|
||||
g_Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5]));
|
||||
}
|
||||
default:
|
||||
Command[0x25] = Mempak::CalculateCrc(&Command[5]);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Command[1] |= 0x80;
|
||||
}
|
||||
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: After Processing"); }
|
||||
if (LogOptions.LogControllerPak)
|
||||
{
|
||||
LogControllerPakData("Write: After Processing");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown ControllerCommand %d",Command[2]); }
|
||||
if (bShowPifRamErrors())
|
||||
{
|
||||
g_Notify->DisplayError(L"Unknown ControllerCommand %d",Command[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPifRam::ReadControllerCommand (int Control, BYTE * Command) {
|
||||
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
|
||||
|
||||
switch (Command[2]) {
|
||||
switch (Command[2])
|
||||
{
|
||||
case 0x01: // read controller
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
|
@ -508,15 +651,19 @@ void CPifRam::ReadControllerCommand (int Control, BYTE * Command) {
|
|||
}
|
||||
break;
|
||||
case 0x02: //read from controller pack
|
||||
if (Controllers[Control].Present == TRUE) {
|
||||
switch (Controllers[Control].Plugin) {
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x03: //write controller pak
|
||||
if (Controllers[Control].Present == TRUE) {
|
||||
switch (Controllers[Control].Plugin) {
|
||||
if (Controllers[Control].Present == TRUE)
|
||||
{
|
||||
switch (Controllers[Control].Plugin)
|
||||
{
|
||||
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
|
||||
}
|
||||
}
|
||||
|
@ -532,8 +679,10 @@ void CPifRam::LogControllerPakData (char * Description)
|
|||
char HexData[100], AsciiData[100], Addon[20];
|
||||
LogMessage("\t%s:",Description);
|
||||
LogMessage("\t------------------------------");
|
||||
for (count = 0; count < 16; count ++ ) {
|
||||
if ((count % 4) == 0) {
|
||||
for (count = 0; count < 16; count ++ )
|
||||
{
|
||||
if ((count % 4) == 0)
|
||||
{
|
||||
sprintf(HexData,"\0");
|
||||
sprintf(AsciiData,"\0");
|
||||
}
|
||||
|
@ -541,22 +690,28 @@ void CPifRam::LogControllerPakData (char * Description)
|
|||
PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1],
|
||||
PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3] );
|
||||
strcat(HexData,Addon);
|
||||
if (((count + 1) % 4) != 0) {
|
||||
if (((count + 1) % 4) != 0)
|
||||
{
|
||||
sprintf(Addon,"-");
|
||||
strcat(HexData,Addon);
|
||||
}
|
||||
|
||||
Addon[0] = 0;
|
||||
for (count2 = 0; count2 < 4; count2++) {
|
||||
if (PIF_Ram[(count << 2) + count2] < 30) {
|
||||
for (count2 = 0; count2 < 4; count2++)
|
||||
{
|
||||
if (PIF_Ram[(count << 2) + count2] < 30)
|
||||
{
|
||||
strcat(Addon,".");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(Addon,"%s%c",Addon,PIF_Ram[(count << 2) + count2]);
|
||||
}
|
||||
}
|
||||
strcat(AsciiData,Addon);
|
||||
|
||||
if (((count + 1) % 4) == 0) {
|
||||
if (((count + 1) % 4) == 0)
|
||||
{
|
||||
LogMessage("\t%s %s",HexData, AsciiData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ protected:
|
|||
CPifRamSettings();
|
||||
virtual ~CPifRamSettings();
|
||||
|
||||
inline bool bShowPifRamErrors ( void ) const { return m_bShowPifRamErrors; }
|
||||
inline bool bShowPifRamErrors ( void ) const
|
||||
{
|
||||
return m_bShowPifRamErrors;
|
||||
}
|
||||
|
||||
private:
|
||||
static void RefreshSettings ( void * );
|
||||
|
|
|
@ -80,6 +80,7 @@ CP0registers::CP0registers(DWORD * _CP0) :
|
|||
ERROREPC_REGISTER(_CP0[30]),
|
||||
FAKE_CAUSE_REGISTER(_CP0[32])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Rdram_InterfaceReg::Rdram_InterfaceReg(DWORD * _RdramInterface) :
|
||||
|
@ -95,6 +96,7 @@ Rdram_InterfaceReg::Rdram_InterfaceReg(DWORD * _RdramInterface) :
|
|||
RDRAM_ADDR_SELECT_REG(_RdramInterface[8]),
|
||||
RDRAM_DEVICE_MANUF_REG(_RdramInterface[9])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Mips_InterfaceReg::Mips_InterfaceReg(DWORD * _MipsInterface) :
|
||||
|
@ -105,6 +107,7 @@ Mips_InterfaceReg::Mips_InterfaceReg(DWORD * _MipsInterface) :
|
|||
MI_INTR_REG(_MipsInterface[2]),
|
||||
MI_INTR_MASK_REG(_MipsInterface[3])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Video_InterfaceReg::Video_InterfaceReg(DWORD * _VideoInterface) :
|
||||
|
@ -132,6 +135,7 @@ Video_InterfaceReg::Video_InterfaceReg(DWORD * _VideoInterface) :
|
|||
VI_X_SCALE_REG(_VideoInterface[12]),
|
||||
VI_Y_SCALE_REG(_VideoInterface[13])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AudioInterfaceReg::AudioInterfaceReg(DWORD * _AudioInterface) :
|
||||
|
@ -142,6 +146,7 @@ AudioInterfaceReg::AudioInterfaceReg(DWORD * _AudioInterface) :
|
|||
AI_DACRATE_REG(_AudioInterface[4]),
|
||||
AI_BITRATE_REG(_AudioInterface[5])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PeripheralInterfaceReg::PeripheralInterfaceReg(DWORD * PeripheralInterface) :
|
||||
|
@ -161,6 +166,7 @@ PeripheralInterfaceReg::PeripheralInterfaceReg(DWORD * PeripheralInterface) :
|
|||
PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]),
|
||||
PI_BSD_DOM2_RLS_REG(PeripheralInterface[12])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(DWORD * RdramInterface) :
|
||||
|
@ -174,6 +180,7 @@ RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(DWORD * RdramInterface) :
|
|||
RI_RERROR_REG(RdramInterface[6]),
|
||||
RI_WERROR_REG(RdramInterface[7])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DisplayControlReg::DisplayControlReg(DWORD * _DisplayProcessor) :
|
||||
|
@ -186,6 +193,7 @@ DisplayControlReg::DisplayControlReg(DWORD * _DisplayProcessor) :
|
|||
DPC_PIPEBUSY_REG(_DisplayProcessor[6]),
|
||||
DPC_TMEM_REG(_DisplayProcessor[7])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInterface) :
|
||||
|
@ -200,6 +208,7 @@ SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInt
|
|||
SP_PC_REG(_SignalProcessorInterface[8]),
|
||||
SP_IBIST_REG(_SignalProcessorInterface[9])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) :
|
||||
|
@ -208,6 +217,7 @@ Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) :
|
|||
SI_PIF_ADDR_WR64B_REG(SerialInterface[2]),
|
||||
SI_STATUS_REG(SerialInterface[3])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRegisters::CRegisters(CN64System * System, CSystemEvents * SystemEvents) :
|
||||
|
@ -276,23 +286,37 @@ void CRegisters::SetAsCurrentSystem ( void )
|
|||
|
||||
void CRegisters::CheckInterrupts ( void )
|
||||
{
|
||||
if (!m_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores) {
|
||||
if (!m_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores)
|
||||
{
|
||||
MI_INTR_REG &= ~MI_INTR_AI;
|
||||
MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI);
|
||||
}
|
||||
MI_INTR_REG |= (m_RspIntrReg & MI_INTR_SP);
|
||||
MI_INTR_REG |= (m_GfxIntrReg & MI_INTR_DP);
|
||||
if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) {
|
||||
if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0)
|
||||
{
|
||||
FAKE_CAUSE_REGISTER |= CAUSE_IP2;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
FAKE_CAUSE_REGISTER &= ~CAUSE_IP2;
|
||||
}
|
||||
|
||||
if (( STATUS_REGISTER & STATUS_IE ) == 0 ) { return; }
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) { return; }
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return; }
|
||||
if (( STATUS_REGISTER & STATUS_IE ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) {
|
||||
if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0)
|
||||
{
|
||||
if (m_FirstInterupt)
|
||||
{
|
||||
m_FirstInterupt = false;
|
||||
|
@ -310,37 +334,50 @@ void CRegisters::DoAddressError ( BOOL DelaySlot, DWORD BadVaddr, BOOL FromRead)
|
|||
if (bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"AddressError");
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"EXL set in AddressError Exception");
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"ERL set in AddressError Exception");
|
||||
}
|
||||
}
|
||||
|
||||
if (FromRead) {
|
||||
if (FromRead)
|
||||
{
|
||||
CAUSE_REGISTER = EXC_RADE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CAUSE_REGISTER = EXC_WADE;
|
||||
}
|
||||
BAD_VADDR_REGISTER = BadVaddr;
|
||||
if (DelaySlot) {
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
m_PROGRAM_COUNTER = 0x80000180;
|
||||
}
|
||||
|
||||
void CRegisters::FixFpuLocations ( void ) {
|
||||
if ((STATUS_REGISTER & STATUS_FR) == 0) {
|
||||
for (int count = 0; count < 32; count ++) {
|
||||
void CRegisters::FixFpuLocations ( void )
|
||||
{
|
||||
if ((STATUS_REGISTER & STATUS_FR) == 0)
|
||||
{
|
||||
for (int count = 0; count < 32; count ++)
|
||||
{
|
||||
m_FPR_S[count] = &m_FPR[count >> 1].F[count & 1];
|
||||
m_FPR_D[count] = &m_FPR[count >> 1].D;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int count = 0; count < 32; count ++) {
|
||||
m_FPR_S[count] = &m_FPR[count].F[1];
|
||||
m_FPR_D[count] = &m_FPR[count].D;
|
||||
|
@ -352,19 +389,24 @@ void CRegisters::DoBreakException ( BOOL DelaySlot)
|
|||
{
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"EXL set in Break Exception");
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"ERL set in Break Exception");
|
||||
}
|
||||
}
|
||||
|
||||
CAUSE_REGISTER = EXC_BREAK;
|
||||
if (DelaySlot) {
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
|
@ -375,20 +417,28 @@ void CRegisters::DoCopUnusableException ( BOOL DelaySlot, int Coprocessor )
|
|||
{
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"EXL set in Break Exception");
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"ERL set in Break Exception");
|
||||
}
|
||||
}
|
||||
|
||||
CAUSE_REGISTER = EXC_CPU;
|
||||
if (Coprocessor == 1) { CAUSE_REGISTER |= 0x10000000; }
|
||||
if (DelaySlot) {
|
||||
if (Coprocessor == 1)
|
||||
{
|
||||
CAUSE_REGISTER |= 0x10000000;
|
||||
}
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
|
@ -398,18 +448,31 @@ void CRegisters::DoCopUnusableException ( BOOL DelaySlot, int Coprocessor )
|
|||
|
||||
BOOL CRegisters::DoIntrException ( BOOL DelaySlot )
|
||||
{
|
||||
if (( STATUS_REGISTER & STATUS_IE ) == 0 ) { return FALSE; }
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) { return FALSE; }
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return FALSE; }
|
||||
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
|
||||
LogMessage("%08X: Interupt Generated", m_PROGRAM_COUNTER );
|
||||
if (( STATUS_REGISTER & STATUS_IE ) == 0 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts)
|
||||
{
|
||||
LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER );
|
||||
}
|
||||
CAUSE_REGISTER = FAKE_CAUSE_REGISTER;
|
||||
CAUSE_REGISTER |= EXC_INT;
|
||||
if (DelaySlot) {
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
|
@ -424,21 +487,29 @@ void CRegisters::DoTLBReadMiss ( BOOL DelaySlot, DWORD BadVaddr )
|
|||
CONTEXT_REGISTER &= 0xFF80000F;
|
||||
CONTEXT_REGISTER |= (BadVaddr >> 9) & 0x007FFFF0;
|
||||
ENTRYHI_REGISTER = (BadVaddr & 0xFFFFE000);
|
||||
if ((STATUS_REGISTER & STATUS_EXL) == 0) {
|
||||
if (DelaySlot) {
|
||||
if ((STATUS_REGISTER & STATUS_EXL) == 0)
|
||||
{
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
if (g_TLB->AddressDefined(BadVaddr))
|
||||
{
|
||||
m_PROGRAM_COUNTER = 0x80000180;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PROGRAM_COUNTER = 0x80000000;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
g_Notify->DisplayError(L"TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,g_TLB->AddressDefined(BadVaddr)?"TRUE":"FALSE");
|
||||
|
@ -451,22 +522,26 @@ void CRegisters::DoSysCallException ( BOOL DelaySlot)
|
|||
{
|
||||
if (bHaveDebugger())
|
||||
{
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"EXL set in SysCall Exception");
|
||||
}
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
|
||||
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
|
||||
{
|
||||
g_Notify->DisplayError(L"ERL set in SysCall Exception");
|
||||
}
|
||||
}
|
||||
|
||||
CAUSE_REGISTER = EXC_SYSCALL;
|
||||
if (DelaySlot) {
|
||||
if (DelaySlot)
|
||||
{
|
||||
CAUSE_REGISTER |= CAUSE_BD;
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
EPC_REGISTER = m_PROGRAM_COUNTER;
|
||||
}
|
||||
STATUS_REGISTER |= STATUS_EXL;
|
||||
m_PROGRAM_COUNTER = 0x80000180;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
};
|
||||
|
||||
//CPO register flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
//Status Register
|
||||
STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004,
|
||||
STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400,
|
||||
|
@ -83,7 +84,8 @@ enum {
|
|||
};
|
||||
|
||||
//Float point control status register flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
FPCSR_FS = 0x01000000, /* flush denorm to zero */
|
||||
FPCSR_C = 0x00800000, /* condition bit */
|
||||
FPCSR_CE = 0x00020000, /* cause: unimplemented operation */
|
||||
|
@ -149,7 +151,8 @@ public:
|
|||
};
|
||||
|
||||
//Mips interface flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
MI_MODE_INIT = 0x0080, /* Bit 7: init mode */
|
||||
MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */
|
||||
MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */
|
||||
|
@ -245,7 +248,8 @@ public:
|
|||
DWORD & DPC_TMEM_REG;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
DPC_CLR_XBUS_DMEM_DMA = 0x0001, /* Bit 0: clear xbus_dmem_dma */
|
||||
DPC_SET_XBUS_DMEM_DMA = 0x0002, /* Bit 1: set xbus_dmem_dma */
|
||||
DPC_CLR_FREEZE = 0x0004, /* Bit 2: clear freeze */
|
||||
|
@ -289,7 +293,8 @@ public:
|
|||
DWORD & AI_BITRATE_REG;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
AI_STATUS_FIFO_FULL = 0x80000000, /* Bit 31: full */
|
||||
AI_STATUS_DMA_BUSY = 0x40000000, /* Bit 30: busy */
|
||||
};
|
||||
|
@ -360,7 +365,8 @@ public:
|
|||
};
|
||||
|
||||
//Signal Processor interface flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */
|
||||
SP_SET_HALT = 0x00002, /* Bit 1: set halt */
|
||||
SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */
|
||||
|
@ -405,7 +411,8 @@ enum {
|
|||
};
|
||||
|
||||
//Peripheral Interface flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
PI_STATUS_DMA_BUSY = 0x01,
|
||||
PI_STATUS_IO_BUSY = 0x02,
|
||||
PI_STATUS_ERROR = 0x04,
|
||||
|
@ -430,7 +437,8 @@ public:
|
|||
};
|
||||
|
||||
//Serial Interface flags
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SI_STATUS_DMA_BUSY = 0x0001,
|
||||
SI_STATUS_RD_BUSY = 0x0002,
|
||||
SI_STATUS_DMA_ERROR = 0x0008,
|
||||
|
@ -438,7 +446,8 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
enum ROUNDING_MODE {
|
||||
enum ROUNDING_MODE
|
||||
{
|
||||
ROUND_NEAR = _RC_NEAR,
|
||||
ROUND_DOWN = _RC_DOWN,
|
||||
ROUND_UP = _RC_UP,
|
||||
|
|
|
@ -14,17 +14,20 @@ CSram::CSram ( bool ReadOnly ) :
|
|||
m_hFile(NULL),
|
||||
m_ReadOnly(ReadOnly)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSram::~CSram (void)
|
||||
{
|
||||
if (m_hFile) {
|
||||
if (m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CSram::LoadSram (void) {
|
||||
BOOL CSram::LoadSram (void)
|
||||
{
|
||||
CPath FileName;
|
||||
|
||||
FileName.SetDriveDirectory( g_Settings->LoadString(Directory_NativeSave).c_str());
|
||||
|
@ -47,11 +50,14 @@ BOOL CSram::LoadSram (void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) {
|
||||
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len)
|
||||
{
|
||||
DWORD dwRead;
|
||||
|
||||
if (m_hFile == NULL) {
|
||||
if (!LoadSram()) {
|
||||
if (m_hFile == NULL)
|
||||
{
|
||||
if (!LoadSram())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +66,17 @@ void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) {
|
|||
|
||||
}
|
||||
|
||||
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len) {
|
||||
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len)
|
||||
{
|
||||
if (m_ReadOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_hFile == NULL) {
|
||||
if (!LoadSram()) {
|
||||
if (m_hFile == NULL)
|
||||
{
|
||||
if (!LoadSram())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ CSystemEvents::CSystemEvents(CN64System * System, CPlugins * Plugins) :
|
|||
m_System(System),
|
||||
m_Plugins(Plugins)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CSystemEvents::~CSystemEvents()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSystemEvents::QueueEvent(SystemEvent action)
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
enum SystemEvent {
|
||||
enum SystemEvent
|
||||
{
|
||||
SysEvent_ExecuteInterrupt,
|
||||
SysEvent_GSButtonPressed,
|
||||
SysEvent_ResetCPU_Soft,
|
||||
|
@ -61,7 +62,10 @@ public:
|
|||
void ExecuteEvents ( void );
|
||||
void QueueEvent ( SystemEvent action);
|
||||
|
||||
inline const BOOL & DoSomething ( void ) const { return m_bDoSomething; }
|
||||
inline const BOOL & DoSomething ( void ) const
|
||||
{
|
||||
return m_bDoSomething;
|
||||
}
|
||||
|
||||
private:
|
||||
CSystemEvents(void); // Disable default constructor
|
||||
|
|
|
@ -14,6 +14,7 @@ CSystemTimer::CSystemTimer( int & NextTimer ) :
|
|||
m_NextTimer(NextTimer),
|
||||
m_inFixTimer(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSystemTimer::Reset ( void )
|
||||
|
@ -47,10 +48,14 @@ void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
|
|||
if (m_TimerDetatils[Type].Active)
|
||||
{
|
||||
m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
|
||||
}
|
||||
FixTimers();
|
||||
|
@ -168,14 +173,17 @@ void CSystemTimer::TimerDone (void)
|
|||
UpdateTimers();
|
||||
|
||||
/* DWORD LastTimer;
|
||||
if (Profiling) {
|
||||
if (Profiling)
|
||||
{
|
||||
LastTimer = StartTimer(Timer_Done);
|
||||
}
|
||||
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
|
||||
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts)
|
||||
{
|
||||
LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", *_PROGRAM_COUNTER, m_Current, *_Timer );
|
||||
}
|
||||
*/
|
||||
switch (m_Current) {
|
||||
switch (m_Current)
|
||||
{
|
||||
case CSystemTimer::CompareTimer:
|
||||
g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP7;
|
||||
g_Reg->CheckInterrupts();
|
||||
|
@ -211,9 +219,12 @@ void CSystemTimer::TimerDone (void)
|
|||
break;
|
||||
case CSystemTimer::RspTimer:
|
||||
g_SystemTimer->StopTimer(CSystemTimer::RspTimer);
|
||||
try {
|
||||
try
|
||||
{
|
||||
g_System->RunRSP();
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
break;
|
||||
|
@ -234,7 +245,8 @@ void CSystemTimer::TimerDone (void)
|
|||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
}
|
||||
//CheckTimer();
|
||||
/*if (Profiling) {
|
||||
/*if (Profiling)
|
||||
{
|
||||
StartTimer(LastTimer);
|
||||
}*/
|
||||
}
|
||||
|
@ -266,8 +278,14 @@ bool CSystemTimer::SaveAllowed ( void )
|
|||
}
|
||||
for (int i = 0; i < MaxTimer; i++)
|
||||
{
|
||||
if (i == CompareTimer) { continue; }
|
||||
if (i == ViTimer) { continue; }
|
||||
if (i == CompareTimer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (i == ViTimer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_TimerDetatils[i].Active)
|
||||
{
|
||||
return false;
|
||||
|
@ -295,8 +313,16 @@ void CSystemTimer::LoadData ( void * file )
|
|||
unzReadCurrentFile( file,&TimerDetailsSize,sizeof(TimerDetailsSize));
|
||||
unzReadCurrentFile( file,&Entries,sizeof(Entries));
|
||||
|
||||
if (TimerDetailsSize != sizeof(TIMER_DETAILS)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return; }
|
||||
if (Entries != sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0])) { g_Notify->BreakPoint(__FILEW__,__LINE__); return; }
|
||||
if (TimerDetailsSize != sizeof(TIMER_DETAILS))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
return;
|
||||
}
|
||||
if (Entries != sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0]))
|
||||
{
|
||||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
unzReadCurrentFile(file,(void *)&m_TimerDetatils,sizeof(m_TimerDetatils));
|
||||
unzReadCurrentFile(file,(void *)&m_LastUpdate,sizeof(m_LastUpdate));
|
||||
|
@ -338,15 +364,33 @@ void CSystemTimer::RecordDifference( CLog &LogFile, const CSystemTimer& rSystemT
|
|||
|
||||
bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const
|
||||
{
|
||||
if (m_LastUpdate != rSystemTimer.m_LastUpdate) { return false; }
|
||||
if (m_NextTimer != rSystemTimer.m_NextTimer) { return false; }
|
||||
if (m_Current != rSystemTimer.m_Current) { return false; }
|
||||
if (m_inFixTimer != rSystemTimer.m_inFixTimer) { return false; }
|
||||
if (m_LastUpdate != rSystemTimer.m_LastUpdate)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_NextTimer != rSystemTimer.m_NextTimer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_Current != rSystemTimer.m_Current)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_inFixTimer != rSystemTimer.m_inFixTimer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MaxTimer; i++)
|
||||
{
|
||||
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active) { return false; }
|
||||
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer) { return false; }
|
||||
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
class CSystemTimer
|
||||
{
|
||||
public:
|
||||
enum TimerType {
|
||||
enum TimerType
|
||||
{
|
||||
UnknownTimer,
|
||||
CompareTimer,
|
||||
SoftResetTimer,
|
||||
|
@ -30,7 +31,8 @@ public:
|
|||
MaxTimer
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
bool Active;
|
||||
__int64 CyclesToTimer;
|
||||
} TIMER_DETAILS;
|
||||
|
|
|
@ -24,13 +24,16 @@ class CTLB :
|
|||
protected CSystemRegisters
|
||||
{
|
||||
public:
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
bool EntryDefined;
|
||||
union {
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned zero : 13;
|
||||
unsigned Mask : 12;
|
||||
unsigned zero2 : 7;
|
||||
|
@ -38,11 +41,13 @@ public:
|
|||
|
||||
} PageMask;
|
||||
|
||||
union {
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned ASID : 8;
|
||||
unsigned Zero : 4;
|
||||
unsigned G : 1;
|
||||
|
@ -51,11 +56,13 @@ public:
|
|||
|
||||
} EntryHi;
|
||||
|
||||
union {
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned GLOBAL: 1;
|
||||
unsigned V : 1;
|
||||
unsigned D : 1;
|
||||
|
@ -66,11 +73,13 @@ public:
|
|||
|
||||
} EntryLo0;
|
||||
|
||||
union {
|
||||
union
|
||||
{
|
||||
unsigned long Value;
|
||||
unsigned char A[4];
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
unsigned GLOBAL: 1;
|
||||
unsigned V : 1;
|
||||
unsigned D : 1;
|
||||
|
@ -96,7 +105,10 @@ public:
|
|||
//See if a VAddr has an entry to translate to a PAddr
|
||||
bool AddressDefined ( DWORD VAddr );
|
||||
|
||||
const TLB_ENTRY & TlbEntry ( int Entry) const { return m_tlb[Entry]; }
|
||||
const TLB_ENTRY & TlbEntry ( int Entry) const
|
||||
{
|
||||
return m_tlb[Entry];
|
||||
}
|
||||
|
||||
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
|
||||
|
||||
|
@ -106,7 +118,8 @@ public:
|
|||
bool operator != (const CTLB& rTLB) const;
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
DWORD VSTART;
|
||||
DWORD VEND;
|
||||
DWORD PHYSSTART;
|
||||
|
|
|
@ -20,12 +20,14 @@ CTLB::CTLB(CTLB_CB * CallBack ):
|
|||
WriteTrace(TraceTLB,__FUNCTION__ ": Done");
|
||||
}
|
||||
|
||||
CTLB::~CTLB (void) {
|
||||
CTLB::~CTLB (void)
|
||||
{
|
||||
WriteTrace(TraceTLB,__FUNCTION__ ": Start");
|
||||
WriteTrace(TraceTLB,__FUNCTION__ ": Done");
|
||||
}
|
||||
|
||||
void CTLB::Reset (bool InvalidateTLB) {
|
||||
void CTLB::Reset (bool InvalidateTLB)
|
||||
{
|
||||
DWORD count;
|
||||
|
||||
for (count = 0; count < 64; count++)
|
||||
|
@ -39,7 +41,9 @@ void CTLB::Reset (bool InvalidateTLB) {
|
|||
{
|
||||
m_tlb[count].EntryDefined = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (count = 0; count < 32; count ++)
|
||||
{
|
||||
SetupTLB_Entry(count,false);
|
||||
|
@ -47,10 +51,12 @@ void CTLB::Reset (bool InvalidateTLB) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CTLB::AddressDefined ( DWORD VAddr) {
|
||||
bool CTLB::AddressDefined ( DWORD VAddr)
|
||||
{
|
||||
DWORD i;
|
||||
|
||||
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) {
|
||||
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,7 +72,8 @@ bool CTLB::AddressDefined ( DWORD VAddr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void CTLB::Probe (void) {
|
||||
void CTLB::Probe (void)
|
||||
{
|
||||
int Counter;
|
||||
|
||||
WriteTrace(TraceTLB,__FUNCTION__ ": Start");
|
||||
|
@ -83,7 +90,8 @@ void CTLB::Probe (void) {
|
|||
DWORD TlbValueMasked = TlbEntryHiValue & Mask;
|
||||
DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask;
|
||||
|
||||
if (TlbValueMasked == EntryHiMasked) {
|
||||
if (TlbValueMasked == EntryHiMasked)
|
||||
{
|
||||
if ((TlbEntryHiValue & 0x100) != 0 || //Global
|
||||
((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid
|
||||
{
|
||||
|
@ -107,13 +115,15 @@ void CTLB::ReadEntry (void) {
|
|||
g_Reg->ENTRYLO1_REGISTER = m_tlb[index].EntryLo1.Value;
|
||||
}
|
||||
|
||||
void CTLB::WriteEntry (int index, bool Random) {
|
||||
void CTLB::WriteEntry (int index, bool Random)
|
||||
{
|
||||
int FastIndx;
|
||||
|
||||
WriteTraceF(TraceTLB,__FUNCTION__ ": %02d %d %08X %08X %08X %08X ",index,Random,g_Reg->PAGE_MASK_REGISTER,g_Reg->ENTRYHI_REGISTER,g_Reg->ENTRYLO0_REGISTER,g_Reg->ENTRYLO1_REGISTER);
|
||||
|
||||
//Check to see if entry is unmapping it self
|
||||
if (m_tlb[index].EntryDefined) {
|
||||
if (m_tlb[index].EntryDefined)
|
||||
{
|
||||
FastIndx = index << 1;
|
||||
if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART &&
|
||||
*_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND &&
|
||||
|
@ -134,16 +144,25 @@ void CTLB::WriteEntry (int index, bool Random) {
|
|||
//Reset old addresses
|
||||
if (m_tlb[index].EntryDefined)
|
||||
{
|
||||
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
|
||||
if (!m_FastTlb[FastIndx].ValidEntry) { continue; }
|
||||
if (!m_FastTlb[FastIndx].VALID) { continue; }
|
||||
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
|
||||
{
|
||||
if (!m_FastTlb[FastIndx].ValidEntry)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!m_FastTlb[FastIndx].VALID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER &&
|
||||
m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_REGISTER)
|
||||
{
|
||||
if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER) {
|
||||
if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER) {
|
||||
if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +180,13 @@ void CTLB::WriteEntry (int index, bool Random) {
|
|||
m_CB->TLB_Changed();
|
||||
}
|
||||
|
||||
void CTLB::SetupTLB_Entry (int index, bool Random) {
|
||||
void CTLB::SetupTLB_Entry (int index, bool Random)
|
||||
{
|
||||
//Fix up Fast TLB entries
|
||||
if (!m_tlb[index].EntryDefined) { return; }
|
||||
if (!m_tlb[index].EntryDefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int FastIndx = index << 1;
|
||||
if (m_FastTlb[FastIndx].VALID)
|
||||
|
@ -201,19 +224,24 @@ void CTLB::SetupTLB_Entry (int index, bool Random) {
|
|||
m_FastTlb[FastIndx].Probed = false;
|
||||
|
||||
//Test both entries to see if they are valid
|
||||
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
|
||||
if (!m_FastTlb[FastIndx].VALID) {
|
||||
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
|
||||
{
|
||||
if (!m_FastTlb[FastIndx].VALID)
|
||||
{
|
||||
m_FastTlb[FastIndx].ValidEntry = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) {
|
||||
if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) {
|
||||
if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) {
|
||||
if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -227,7 +255,10 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
|
|||
{
|
||||
for (int i = Index; i < 64; i++)
|
||||
{
|
||||
if (m_FastTlb[i].ValidEntry == false) { continue; }
|
||||
if (m_FastTlb[i].ValidEntry == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND)
|
||||
{
|
||||
VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART);
|
||||
|
@ -248,7 +279,10 @@ void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB)
|
|||
LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No");
|
||||
continue;
|
||||
}
|
||||
if (!m_tlb[i].EntryDefined) { continue; }
|
||||
if (!m_tlb[i].EntryDefined)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value)
|
||||
{
|
||||
LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value);
|
||||
|
@ -272,8 +306,14 @@ bool CTLB::operator == (const CTLB& rTLB) const
|
|||
{
|
||||
for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++)
|
||||
{
|
||||
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) { return false; }
|
||||
if (!m_tlb[i].EntryDefined) { continue; }
|
||||
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!m_tlb[i].EntryDefined)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value ||
|
||||
m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value ||
|
||||
m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value ||
|
||||
|
|
Loading…
Reference in New Issue