git-svn-id: https://localhost/svn/Project64/trunk@35 111125ac-702d-7242-af9c-5ba8ae61c1ef

This commit is contained in:
zilmar 2010-06-14 21:14:58 +00:00
parent a5bfa92557
commit 1c585a93bd
37 changed files with 1531 additions and 1422 deletions

View File

@ -19,6 +19,8 @@ class CNotification;
#include "N64 System/Mips/OpCode.h"
#include "N64 System/Mips/OpCode Analysis Class.h"
#include "N64 System/Recompiler/X86ops.h"
#include "N64 System/Mips/Eeprom.h"
#include "N64 System/Mips/Pif Ram.h"
#include "N64 System/Mips/Register Class.h"
#include "N64 System/Mips/TranslateVaddr.h"
#include "N64 System/Mips/TLB Class.h"

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "eeprom.h"
#include "mempak.h"
#include "Plugin.h"
#include "Logging.h"
@ -9,9 +8,9 @@
//settings
BOOL g_ShowUnhandledMemory = false, g_ShowCPUPer = false, g_ShowTLBMisses = false, g_UseTlb = true,
g_HaveDebugger = false, g_AudioSignal = false, g_ShowDListAListCount = false,
g_ShowPifRamErrors = false, g_GenerateLog = false, g_DelaySI = false,
g_DisableRegCaching = false, g_ShowCompMem = false, g_UseLinking = false,
g_HaveDebugger = false, g_AudioSignal = false,
g_ShowPifRamErrors = false, g_GenerateLog = false,
g_UseLinking = false,
g_FixedAudio = false, g_LogX86Code = false;
DWORD g_RomFileSize = 0, g_CountPerOp = 2, g_ViRefreshRate = 1500;
enum CPU_TYPE g_CPU_Type;
@ -37,7 +36,6 @@ void CC_Core::SetSettings ( )
if (g_HaveDebugger)
{
g_ShowUnhandledMemory = _Settings->LoadBool(Debugger_ShowUnhandledMemory);
g_ShowDListAListCount = _Settings->LoadBool(Debugger_ShowDListAListCount);
} else {
g_ShowUnhandledMemory = false;
g_ShowUnhandledMemory = false;
@ -53,13 +51,10 @@ void CC_Core::SetSettings ( )
g_ShowPifRamErrors = _Settings->LoadDword(Debugger_ShowPifErrors);
g_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
g_GenerateLog = _Settings->LoadDword(Debugger_GenerateDebugLog);
g_DelaySI = _Settings->LoadBool(Game_DelaySI);
g_FixedAudio = _Settings->LoadBool(Game_FixedAudio);
g_LogX86Code = _Settings->LoadBool(Debugger_GenerateLogFiles);
g_LookUpMode = (FUNC_LOOKUP_METHOD)_Settings->LoadDword(Game_FuncLookupMode);
g_DisableRegCaching = !_Settings->LoadBool(Game_RegCache);
g_UseLinking = _Settings->LoadBool(Game_BlockLinking);
g_ShowCompMem = false;
g_ViRefreshRate = _Settings->LoadDword(Game_ViRefreshRate);
strcpy(g_RomName, _Settings->LoadString(Game_GameName).c_str());
}
@ -306,7 +301,6 @@ void ResetX86Logs ( void )
void CloseSaveChips ( void )
{
CloseEeprom();
CloseMempak();
CloseSram();
CloseFlashRam();

View File

@ -67,8 +67,8 @@ DWORD StopTimer ( void );
//settings
extern BOOL g_ShowUnhandledMemory, g_ShowCPUPer, g_ShowTLBMisses, g_UseTlb,
g_HaveDebugger, g_AudioSignal, g_ShowDListAListCount, g_ShowPifRamErrors,
g_GenerateLog, g_DelaySI, g_DisableRegCaching, g_ShowCompMem,
g_HaveDebugger, g_AudioSignal, g_ShowPifRamErrors,
g_GenerateLog, g_ShowCompMem,
g_UseLinking, g_FixedAudio, g_LogX86Code;
extern DWORD g_RomFileSize, g_CountPerOp;
extern enum CPU_TYPE g_CPU_Type;

View File

@ -5,7 +5,6 @@
#include "..\\Types.h"
#include "r4300i Commands.h"
#include "DMA.h"
#include "eeprom.h"
#include "sram.h"
#include "flashram.h"
#include "mempak.h"

View File

@ -160,191 +160,6 @@ void PI_DMA_WRITE (void) {
}
void SI_DMA_READ (void) {
BYTE * PIF_Ram = _MMU->PifRam();
BYTE * PifRamPos = _MMU->PifRam();
BYTE * RDRAM = _MMU->Rdram();
DWORD & SI_DRAM_ADDR_REG = _Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)g_RdramSize) {
#ifndef EXTERNAL_RELEASE
DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRam space");
#endif
return;
}
PifRamRead();
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
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; }
RDRAM[RdramPos ^3] = PIF_Ram[count];
}
} else {
_asm {
mov edi, dword ptr [SI_DRAM_ADDR_REG]
mov edi, dword ptr [edi]
add edi, RDRAM
mov ecx, PifRamPos
mov edx, 0
memcpyloop:
mov eax, dword ptr [ecx + edx]
bswap eax
mov dword ptr [edi + edx],eax
mov eax, dword ptr [ecx + edx + 4]
bswap eax
mov dword ptr [edi + edx + 4],eax
mov eax, dword ptr [ecx + edx + 8]
bswap eax
mov dword ptr [edi + edx + 8],eax
mov eax, dword ptr [ecx + edx + 12]
bswap eax
mov dword ptr [edi + edx + 12],eax
add edx, 16
cmp edx, 64
jb memcpyloop
}
}
#if (!defined(EXTERNAL_RELEASE))
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) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
sprintf(Addon,"%c%c%c%c",
PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1],
PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
}
#endif
if (g_DelaySI) {
_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
}
}
void SI_DMA_WRITE (void) {
BYTE * PIF_Ram = _MMU->PifRam();
BYTE * PifRamPos = PIF_Ram;
DWORD & SI_DRAM_ADDR_REG = _Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)g_RdramSize) {
#ifndef EXTERNAL_RELEASE
DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRam space");
#endif
return;
}
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
BYTE * RDRAM = _MMU->Rdram();
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) { PIF_Ram[count] = 0; continue; }
PIF_Ram[count] = RDRAM[RdramPos ^3];
}
} else {
_asm {
mov ecx, dword ptr [SI_DRAM_ADDR_REG]
mov ecx, dword ptr [ecx]
add ecx, RDRAM
mov edi, PifRamPos
mov edx, 0
memcpyloop:
mov eax, dword ptr [ecx + edx]
bswap eax
mov dword ptr [edi + edx],eax
mov eax, dword ptr [ecx + edx + 4]
bswap eax
mov dword ptr [edi + edx + 4],eax
mov eax, dword ptr [ecx + edx + 8]
bswap eax
mov dword ptr [edi + edx + 8],eax
mov eax, dword ptr [ecx + edx + 12]
bswap eax
mov dword ptr [edi + edx + 12],eax
add edx, 16
cmp edx, 64
jb memcpyloop
}
}
#if (!defined(EXTERNAL_RELEASE))
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) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
sprintf(Addon,"%c%c%c%c",
PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1],
PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
}
#endif
PifRamWrite();
if (g_DelaySI) {
_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
}
}
void SP_DMA_READ (void) {
_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF;

View File

@ -10,98 +10,3 @@ void CloseEeprom (void) {
hEepromFile = NULL;
}
}
void EepromCommand ( BYTE * Command) {
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Eeprom_4K; }
switch (Command[2]) {
case 0: // check
if (g_SaveUsing != SaveChip_Eeprom_4K && g_SaveUsing != SaveChip_Eeprom_16K) {
Command[1] |= 0x80;
break;
}
if (Command[1] != 3) {
Command[1] |= 0x40;
if ((Command[1] & 3) > 0) { Command[3] = 0x00; }
if (g_SaveUsing == SaveChip_Eeprom_4K) {
if ((Command[1] & 3) > 1) { Command[4] = 0x80; }
} else {
if ((Command[1] & 3) > 1) { Command[4] = 0xC0; }
}
if ((Command[1] & 3) > 2) { Command[5] = 0x00; }
} else {
Command[3] = 0x00;
Command[4] = g_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[5] = 0x00;
}
break;
case 4: // Read from Eeprom
#ifndef EXTERNAL_RELEASE
if (Command[0] != 2) { DisplayError("What am I meant to do with this Eeprom Command"); }
if (Command[1] != 8) { DisplayError("What am I meant to do with this Eeprom Command"); }
#endif
ReadFromEeprom(&Command[4],Command[3]);
break;
case 5:
#ifndef EXTERNAL_RELEASE
if (Command[0] != 10) { DisplayError("What am I meant to do with this Eeprom Command"); }
if (Command[1] != 1) { DisplayError("What am I meant to do with this Eeprom Command"); }
#endif
WriteToEeprom(&Command[4],Command[3]);
break;
default:
if (g_ShowPifRamErrors) { DisplayError("Unkown EepromCommand %d",Command[2]); }
}
}
void LoadEeprom (void) {
char File[255], Directory[255];
DWORD dwRead;
GetAutoSaveDir(Directory);
sprintf(File,"%s%s.eep",Directory,g_RomName);
hEepromFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (hEepromFile == INVALID_HANDLE_VALUE) {
switch (GetLastError()) {
case ERROR_PATH_NOT_FOUND:
CreateDirectory(Directory,NULL);
hEepromFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (hEepromFile == INVALID_HANDLE_VALUE) {
DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
}
return;
break;
default:
DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return;
}
}
memset(EEPROM,0,sizeof(EEPROM));
SetFilePointer(hEepromFile,0,NULL,FILE_BEGIN);
ReadFile(hEepromFile,EEPROM,sizeof(EEPROM),&dwRead,NULL);
}
void ReadFromEeprom(BYTE * Buffer, int line) {
int i;
if (hEepromFile == NULL) {
LoadEeprom();
}
for(i=0;i<8;i++) { Buffer[i]=EEPROM[line*8+i]; }
}
void WriteToEeprom(BYTE * Buffer, int line) {
DWORD dwWritten;
int i;
if (hEepromFile == NULL) {
LoadEeprom();
}
for(i=0;i<8;i++) { EEPROM[line*8+i]=Buffer[i]; }
SetFilePointer(hEepromFile,line*8,NULL,FILE_BEGIN);
WriteFile( hEepromFile,Buffer,8,&dwWritten,NULL );
}

View File

@ -1,70 +1,13 @@
#include "stdafx.h"
#ifdef toremove
#include "Eeprom.h"
#include "mempak.h"
void ProcessControllerCommand ( int Control, BYTE * Command);
void ReadControllerCommand (int Control, BYTE * Command);
BYTE PifRom[0x7C0];
int GetCicChipID (char * RomData) {
_int64 CRC = 0;
int count;
for (count = 0x40; count < 0x1000; count += 4) {
CRC += *(DWORD *)(RomData+count);
}
switch (CRC) {
case 0x000000D0027FDF31: return 1;
case 0x000000CFFB631223: return 1;
case 0x000000D057C85244: return 2;
case 0x000000D6497E414B: return 3;
case 0x0000011A49F60E96: return 5;
case 0x000000D6D5BE5580: return 6;
default:
return -1;
}
}
void LogControllerPakData (char * Description) {
BYTE * PIF_Ram = _MMU->PifRam();
#if (!defined(EXTERNAL_RELEASE))
int count, count2;
char HexData[100], AsciiData[100], Addon[20];
LogMessage("\t%s:",Description);
LogMessage("\t------------------------------");
for (count = 0; count < 16; count ++ ) {
if ((count % 4) == 0) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
Addon[0] = 0;
for (count2 = 0; count2 < 4; count2++) {
if (PIF_Ram[(count << 2) + count2] < 30) {
strcat(Addon,".");
} else {
sprintf(Addon,"%s%c",Addon,PIF_Ram[(count << 2) + count2]);
}
}
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
#endif
}
#define IncreaseMaxPif2 300
int MaxPif2Cmds = 300;
@ -131,283 +74,6 @@ void LoadPIF2 () {
fclose (pif2db);
}
void PifRamRead (void) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
BYTE * PIF_Ram = _MMU->PifRam();
int Channel, CurPos;
Channel = 0;
CurPos = 0;
if (PIF_Ram[0x3F] == 0x2) {
int cnt = 0;
char buff[256];
if (pif2valid == FALSE)
LoadPIF2 ();
while (Pif2Reply[0][cnt] != -1) {
if (Pif2Reply[0][cnt] == *(unsigned __int64 *)&PIF_Ram[48]) {
if (Pif2Reply[1][cnt] == *(unsigned __int64 *)&PIF_Ram[56]) {
PIF_Ram[46] = PIF_Ram[47] = 0x00;
*(unsigned __int64 *)&PIF_Ram[48] = Pif2Reply[2][cnt];
*(unsigned __int64 *)&PIF_Ram[56] = Pif2Reply[3][cnt];
cnt = -1;
break;
}
}
cnt++;
}
if (cnt != -1) {
char buff2[256];
int count;
sprintf (buff, "%s :(\r\n\r\nInfo:\r\nP1=%08X%08X P2=%08X%08X\r\n", GS(MSG_PIF2_ERROR),
*(DWORD *)&PIF_Ram[52],
*(DWORD *)&PIF_Ram[48],
*(DWORD *)&PIF_Ram[60],
*(DWORD *)&PIF_Ram[56]);
for (count = 48; count < 64; count++) {
if (count % 4 == 0) {
strcat(buff,count == 48?"0x":", 0x");
}
sprintf(buff2,"%02X",PIF_Ram[count]);
strcat(buff,buff2);
}
DisplayError("%s\n\n%s",GS(MSG_PIF2_TITLE),buff);
}
/*
PIF_Ram[48] = 0x3E; PIF_Ram[49] = 0xC6; PIF_Ram[50] = 0xC0; PIF_Ram[51] = 0x4E;
PIF_Ram[52] = 0xBD; PIF_Ram[53] = 0x37; PIF_Ram[54] = 0x15; PIF_Ram[55] = 0x55;
PIF_Ram[56] = 0x5A; PIF_Ram[57] = 0x8C; PIF_Ram[58] = 0x2A; PIF_Ram[59] = 0x8C;
PIF_Ram[60] = 0xD3; PIF_Ram[61] = 0x71; PIF_Ram[62] = 0x71; PIF_Ram[63] = 0x00;
*/
CurPos = 0x40;
}
do {
switch(PIF_Ram[CurPos]) {
case 0x00:
Channel += 1;
if (Channel > 6) { CurPos = 0x40; }
break;
case 0xFE: CurPos = 0x40; break;
case 0xFF: break;
case 0xB4: case 0x56: case 0xB8: break; /* ??? */
default:
if ((PIF_Ram[CurPos] & 0xC0) == 0) {
if (Channel < 4) {
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(Channel,&PIF_Ram[CurPos]); }
} else {
ReadControllerCommand(Channel,&PIF_Ram[CurPos]);
}
}
CurPos += PIF_Ram[CurPos] + (PIF_Ram[CurPos + 1] & 0x3F) + 1;
Channel += 1;
} else {
if (g_ShowPifRamErrors) { DisplayError("Unknown Command in PifRamRead(%X)",PIF_Ram[CurPos]); }
CurPos = 0x40;
}
break;
}
CurPos += 1;
} while( CurPos < 0x40 );
if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(-1,NULL); }
}
void PifRamWrite (void) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
BYTE * PIF_Ram = _MMU->PifRam();
int Channel, CurPos;
Channel = 0;
if( PIF_Ram[0x3F] > 0x1) {
switch (PIF_Ram[0x3F]) {
case 0x08:
PIF_Ram[0x3F] = 0;
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
break;
case 0x10:
memset(PifRom,0,0x7C0);
break;
case 0x30:
PIF_Ram[0x3F] = 0x80;
break;
case 0xC0:
memset(PIF_Ram,0,0x40);
break;
default:
if (g_ShowPifRamErrors) { DisplayError("Unkown PifRam control: %d",PIF_Ram[0x3F]); }
}
return;
}
for (CurPos = 0; CurPos < 0x40; CurPos++){
switch(PIF_Ram[CurPos]) {
case 0x00:
Channel += 1;
if (Channel > 6) { CurPos = 0x40; }
break;
case 0xFE: CurPos = 0x40; break;
case 0xFF: break;
case 0xB4: case 0x56: case 0xB8: break; /* ??? */
default:
if ((PIF_Ram[CurPos] & 0xC0) == 0) {
if (Channel < 4) {
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Channel,&PIF_Ram[CurPos]); }
} else {
ProcessControllerCommand(Channel,&PIF_Ram[CurPos]);
}
} else if (Channel == 4) {
EepromCommand(&PIF_Ram[CurPos]);
} else {
#ifndef EXTERNAL_RELEASE
DisplayError("Command on channel 5?");
#endif
}
CurPos += PIF_Ram[CurPos] + (PIF_Ram[CurPos + 1] & 0x3F) + 1;
Channel += 1;
} else {
if (g_ShowPifRamErrors) { DisplayError("Unknown Command in PifRamWrite(%X)",PIF_Ram[CurPos]); }
CurPos = 0x40;
}
break;
}
}
PIF_Ram[0x3F] = 0;
if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(-1,NULL); }
}
void ProcessControllerCommand ( int Control, BYTE * Command) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
switch (Command[2]) {
case 0x00: // check
case 0xFF: // reset & check ?
if ((Command[1] & 0x80) != 0) { break; }
#ifndef EXTERNAL_RELEASE
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 3) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
if (Controllers[Control].Present == TRUE) {
Command[3] = 0x05;
Command[4] = 0x00;
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 {
Command[1] |= 0x80;
}
break;
case 0x01: // read controller
#ifndef EXTERNAL_RELEASE
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 4) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
if (Controllers[Control].Present == FALSE) {
Command[1] |= 0x80;
}
break;
case 0x02: //read from controller pack
#ifndef EXTERNAL_RELEASE
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: Before Gettting Results"); }
if (Command[0] != 3) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 33) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
if (Controllers[Control].Present == TRUE) {
DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) {
case PLUGIN_RUMBLE_PAK:
memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20);
Command[0x25] = Mempacks_CalulateCrc(&Command[5]);
break;
case PLUGIN_MEMPAK: ReadFromMempak(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
default:
memset(&Command[5], 0, 0x20);
Command[0x25] = 0;
}
} else {
Command[1] |= 0x80;
}
#ifndef EXTERNAL_RELEASE
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: After Gettting Results"); }
#endif
break;
case 0x03: //write controller pak
#ifndef EXTERNAL_RELEASE
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: Before Processing"); }
if (Command[0] != 35) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
if (Controllers[Control].Present == TRUE) {
DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) {
case PLUGIN_MEMPAK: WriteToMempak(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
case PLUGIN_RUMBLE_PAK:
if ((address & 0xFFE0) == 0xC000 && _Plugins->Control()->RumbleCommand != NULL) {
_Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5]));
}
default:
Command[0x25] = Mempacks_CalulateCrc(&Command[5]);
}
} else {
Command[1] |= 0x80;
}
#ifndef EXTERNAL_RELEASE
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: After Processing"); }
#endif
break;
default:
if (g_ShowPifRamErrors) { DisplayError("Unknown ControllerCommand %d",Command[2]); }
}
}
void ReadControllerCommand (int Control, BYTE * Command) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
switch (Command[2]) {
case 0x01: // read controller
if (Controllers[Control].Present == TRUE) {
#ifndef EXTERNAL_RELEASE
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 4) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
if (_Plugins->Control()->GetKeys) {
BUTTONS Keys;
_Plugins->Control()->GetKeys(Control,&Keys);
*(DWORD *)&Command[3] = Keys.Value;
} else {
*(DWORD *)&Command[3] = 0;
}
}
break;
case 0x02: //read from controller pack
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
case PLUGIN_RAW: if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(Control, Command); } break;
}
}
break;
case 0x03: //write controller pak
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
case PLUGIN_RAW: if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(Control, Command); } break;
}
}
break;
}
}
int LoadPifRom(int country) {
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR];
@ -452,3 +118,5 @@ int LoadPifRom(int country) {
CloseHandle( hPifFile );
return TRUE;
}
#endif

View File

@ -1,3 +1,4 @@
#ifdef toremove
/*
* Project 64 - A Nintendo 64 emulator.
*
@ -29,7 +30,6 @@ extern "C" {
extern BYTE PifRom[0x7C0];
int GetCicChipID ( char * RomData );
int LoadPifRom ( int country );
void PifRamWrite ( void );
void PifRamRead ( void );
@ -37,3 +37,4 @@ void PifRamRead ( void );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -324,6 +324,16 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
*_NextTimer -= m_CountPerOp;
m_R4300i_Opcode[ Opcode.op ]();
/*static DWORD TestAddress = 0x80255E3C, TestValue = 0, CurrentValue = 0;
if (_MMU->LW_VAddr(TestAddress, TestValue))
{
if (TestValue != CurrentValue)
{
WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iOpcodeName(m_Opcode.Hex,PROGRAM_COUNTER) );
CurrentValue = TestValue;
}
}*/
switch (R4300iOp::m_NextInstruction)
{
case NORMAL:

View File

@ -1,104 +1,70 @@
#include "stdafx.h"
// ****************** Testing Audio Stuff *****************
CAudio::CAudio (void)
{
ResetAudioSettings();
Reset();
}
// I seem to be getting clicking when I set CF to 1 and VSyncTiming to 789000
void CAudio::ResetAudioSettings (void)
CAudio::~CAudio (void)
{
//float CAudio::VSyncTiming = 789000.0f; // 500000
////const float VSyncTiming = 760000.0f;
m_FramesPerSecond = 60.0f;
m_BytesPerSecond = 0;
m_Length = 0;
m_Status = 0;
m_CountsPerByte = 0;
m_SecondBuff = 0;
m_CurrentCount = 0;
m_CurrentLength = 0;
m_IntScheduled = 0;
m_VSyncTiming = 789000.0f;
}
void CAudio::AiCallBack ()
void CAudio::Reset ( void )
{
m_CurrentLength = 0;
m_SecondBuff = 0;
m_Status = 0;
m_CountsPerByte = 50; // should be calculated ... see below
}
DWORD CAudio::GetLength ( void )
{
DWORD TimeLeft = _SystemTimer->GetTimer(CSystemTimer::AiTimer);
if (TimeLeft > 0)
{
return TimeLeft / m_CountsPerByte;
}
return 0;
}
DWORD CAudio::GetStatus ( void )
{
return m_Status;
}
void CAudio::LenChanged ( void )
{
if (_Reg->AI_LEN_REG == 0)
{
return;
}
if (m_CurrentLength == 0) {
m_CurrentLength = _Reg->AI_LEN_REG;
_SystemTimer->SetTimer(CSystemTimer::AiTimer,m_CurrentLength * m_CountsPerByte,false);
} else {
m_SecondBuff = _Reg->AI_LEN_REG;
m_Status |= 0x80000000;
}
if (_Plugins->Audio()->LenChanged != NULL)
{
_Plugins->Audio()->LenChanged();
}
}
void CAudio::TimerDone ( void )
{
if (m_SecondBuff != 0) {
m_IntScheduled = (DWORD)((double)m_SecondBuff * m_CountsPerByte);
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_Reg->ChangeTimerFixed(AiTimer, m_IntScheduled);
#endif
_SystemTimer->SetTimer(CSystemTimer::AiTimer,m_SecondBuff * m_CountsPerByte,true);
}
m_CurrentCount = _Reg->COUNT_REGISTER;
m_CurrentLength = m_SecondBuff;
m_SecondBuff = 0;
m_Status &= 0x7FFFFFFF;
}
DWORD CAudio::AiGetLength (void)
void CAudio::SetViIntr ( DWORD VI_INTR_TIME )
{
double AiCounts;
// static DWORD LengthReadHack = 0;
// if ((COUNT_REGISTER - LengthReadHack) < 0x20) {
// // This is a Spin Lock... ;-/
// //COUNT_REGISTER += (DWORD)(CountsPerByte*0.5); // Lets speed up the CPU to the next Event
// //CurrentLength = 0;
// COUNT_REGISTER+=0xA; // This hack is necessary... but what is a good value??
// }
// LengthReadHack = COUNT_REGISTER;
AiCounts = m_CountsPerByte * m_CurrentLength;
AiCounts = AiCounts - (double)(_Reg->COUNT_REGISTER - m_CurrentCount);
if (AiCounts < 0)
{
return 0;
}
// return 0;
return (DWORD)(AiCounts / m_CountsPerByte);
}
DWORD CAudio::AiGetStatus (void)
{
return m_Status;
}
void CAudio::AiSetLength (void)
{
// Set Status to FULL for a few COUNT cycles
if (m_CurrentLength == 0) {
m_CurrentLength = _Reg->AI_LEN_REG;
m_CurrentCount = _Reg->COUNT_REGISTER;
m_IntScheduled = (DWORD)((double)_Reg->AI_LEN_REG * m_CountsPerByte);
_SystemTimer->SetTimer(CSystemTimer::AiTimer,m_IntScheduled,false);
} else {
m_SecondBuff = _Reg->AI_LEN_REG;
m_Status |= 0x80000000;
}
}
void CAudio::UpdateAudioTimer (DWORD CountsPerFrame)
{
double CountsPerSecond = (DWORD)((double)CountsPerFrame * m_FramesPerSecond); // This will only work with NTSC... VSyncTiming...
m_CountsPerByte = CountsPerSecond / (double)m_BytesPerSecond;
}
void CAudio::AiSetFrequency (DWORD Dacrate, DWORD System) {
double CountsPerSecond;
switch (System) {
case SYSTEM_NTSC: m_BytesPerSecond = 48681812 / (Dacrate + 1); break;
case SYSTEM_PAL: m_BytesPerSecond = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: m_BytesPerSecond = 48628316 / (Dacrate + 1); break;
}
if (System == SYSTEM_PAL) {
m_FramesPerSecond = 50.0;
} else {
m_FramesPerSecond = 60.0;
}
m_BytesPerSecond = (m_BytesPerSecond * 4); // This makes it Bytes Per Second...
CountsPerSecond = (double)(((double)m_VSyncTiming) * (double)60.0); // This will only work with NTSC... VSyncTiming...
m_CountsPerByte = (double)CountsPerSecond / (double)m_BytesPerSecond;
m_SecondBuff = m_Status = m_CurrentLength = 0;
//CountsPerByte /= CountPerOp;
}

View File

@ -2,24 +2,29 @@ class CAudio
{
public:
CAudio (void);
~CAudio (void);
void AiCallBack ( void );
DWORD AiGetLength ( void );
DWORD AiGetStatus ( void );
void AiSetLength ( void );
DWORD GetLength ( void );
DWORD GetStatus ( void );
void LenChanged ( void );
void TimerDone ( void );
void Reset ( void );
void SetViIntr ( DWORD VI_INTR_TIME );
/* void AiCallBack ( void );
void AiSetFrequency ( DWORD Dacrate, DWORD System );
void UpdateAudioTimer ( DWORD CountsPerFrame );
void ResetAudioSettings ( void);
*/
private:
float m_VSyncTiming;
DWORD m_CurrentLength;
DWORD m_SecondBuff;
DWORD m_Status;
double m_CountsPerByte;
/* float m_VSyncTiming;
double m_FramesPerSecond;
DWORD m_BytesPerSecond;
DWORD m_Length;
DWORD m_Status;
double m_CountsPerByte;
DWORD m_SecondBuff;
DWORD m_CurrentCount;
DWORD m_CurrentLength;
DWORD m_IntScheduled;
DWORD m_IntScheduled;*/
};

View File

@ -0,0 +1,114 @@
#include "stdafx.h"
CEeprom::CEeprom (bool ReadOnly):
m_ReadOnly(ReadOnly),
m_hFile(NULL)
{
memset(m_EEPROM,0,sizeof(m_EEPROM));
//LoadEeprom();
}
CEeprom::~CEeprom (void) {
if (m_hFile) {
CloseHandle(m_hFile);
m_hFile = NULL;
}
}
void CEeprom::EepromCommand ( BYTE * Command) {
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Eeprom_4K; }
switch (Command[2]) {
case 0: // check
if (g_SaveUsing != SaveChip_Eeprom_4K && g_SaveUsing != SaveChip_Eeprom_16K) {
Command[1] |= 0x80;
break;
}
if (Command[1] != 3) {
Command[1] |= 0x40;
if ((Command[1] & 3) > 0) { Command[3] = 0x00; }
if (g_SaveUsing == SaveChip_Eeprom_4K) {
if ((Command[1] & 3) > 1) { Command[4] = 0x80; }
} else {
if ((Command[1] & 3) > 1) { Command[4] = 0xC0; }
}
if ((Command[1] & 3) > 2) { Command[5] = 0x00; }
} else {
Command[3] = 0x00;
Command[4] = g_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[5] = 0x00;
}
break;
case 4: // Read from Eeprom
#ifndef EXTERNAL_RELEASE
if (Command[0] != 2) { DisplayError("What am I meant to do with this Eeprom Command"); }
if (Command[1] != 8) { DisplayError("What am I meant to do with this Eeprom Command"); }
#endif
ReadFrom(&Command[4],Command[3]);
break;
case 5:
#ifndef EXTERNAL_RELEASE
if (Command[0] != 10) { DisplayError("What am I meant to do with this Eeprom Command"); }
if (Command[1] != 1) { DisplayError("What am I meant to do with this Eeprom Command"); }
#endif
WriteTo(&Command[4],Command[3]);
break;
default:
if (g_ShowPifRamErrors) { DisplayError("Unkown EepromCommand %d",Command[2]); }
}
}
void CEeprom::LoadEeprom (void) {
CPath FileName;
DWORD dwRead;
memset(m_EEPROM,0,sizeof(m_EEPROM));
FileName.SetDriveDirectory( _Settings->LoadString(Directory_NativeSave).c_str());
FileName.SetName(_Settings->LoadString(Game_GameName).c_str());
FileName.SetExtension("eep");
if (!FileName.DirectoryExists())
{
FileName.CreateDirectory();
}
m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
WriteTraceF(TraceError,"CEeprom::LoadEeprom: Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError());
DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return;
}
SetFilePointer(m_hFile,0,NULL,FILE_BEGIN);
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL);
}
void CEeprom::ReadFrom(BYTE * Buffer, int line) {
int i;
if (m_hFile == NULL)
{
LoadEeprom();
}
for(i=0; i < 8; i++)
{
Buffer[i] = m_EEPROM[line*8+i];
}
}
void CEeprom::WriteTo(BYTE * Buffer, int line) {
DWORD dwWritten;
int i;
if (m_hFile == NULL)
{
LoadEeprom();
}
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);
}

View File

@ -0,0 +1,17 @@
class CEeprom
{
public:
CEeprom ( bool ReadOnly );
~CEeprom ( void );
void EepromCommand ( BYTE * Command );
private:
void LoadEeprom ( void );
void ReadFrom ( BYTE * Buffer, int line );
void WriteTo ( BYTE * Buffer, int line );
BYTE m_EEPROM[0x800];
bool m_ReadOnly;
HANDLE m_hFile;
};

View File

@ -2,7 +2,8 @@
DWORD RegModValue;
CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack ) :
CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOnly ) :
CPifRam(SavesReadOnly),
m_CBClass(CallBack),
m_TLB_ReadMap(NULL),
m_TLB_WriteMap(NULL),
@ -23,6 +24,32 @@ CMipsMemoryVM::~CMipsMemoryVM (void)
FreeMemory();
}
void CMipsMemoryVM::Reset( bool EraseMemory )
{
if (m_TLB_ReadMap)
{
memset(m_TLB_ReadMap,0,(0xFFFFF * sizeof(DWORD)));
memset(m_TLB_WriteMap,0,(0xFFFFF * sizeof(DWORD)));
for (DWORD count = 0x80000000; count < 0xC0000000; count += 0x1000)
{
m_TLB_ReadMap[count >> 12] = ((DWORD)m_RDRAM + (count & 0x1FFFFFFF)) - count;
m_TLB_WriteMap[count >> 12] = ((DWORD)m_RDRAM + (count & 0x1FFFFFFF)) - count;
}
if (_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0)
{
DWORD Start = _Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000;
DWORD Len = _Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000;
DWORD PAddr = _Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30;
DWORD End = Start + Len;
for (count = Start; count < End; count += 0x1000) {
m_TLB_ReadMap[count >> 12] = ((DWORD)m_RDRAM + (count - Start + PAddr)) - count;
m_TLB_WriteMap[count >> 12] = ((DWORD)m_RDRAM + (count - Start + PAddr)) - count;
}
}
}
}
BOOL CMipsMemoryVM::Initialize ( void )
{
if (m_RDRAM != NULL)
@ -82,7 +109,7 @@ BOOL CMipsMemoryVM::Initialize ( void )
m_Rom = _Rom->GetRomAddress();
m_RomSize = _Rom->GetRomSize();
}
memset(m_PIF_Ram,0,sizeof(m_PIF_Ram));
memset(m_PifRam,0,sizeof(m_PifRam));
m_TLB_ReadMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
if (m_TLB_ReadMap == NULL)
@ -99,26 +126,7 @@ BOOL CMipsMemoryVM::Initialize ( void )
FreeMemory();
return false;
}
memset(m_TLB_ReadMap,0,(0xFFFFF * sizeof(DWORD)));
memset(m_TLB_WriteMap,0,(0xFFFFF * sizeof(DWORD)));
for (DWORD count = 0x80000000; count < 0xC0000000; count += 0x1000)
{
m_TLB_ReadMap[count >> 12] = ((DWORD)m_RDRAM + (count & 0x1FFFFFFF)) - count;
m_TLB_WriteMap[count >> 12] = ((DWORD)m_RDRAM + (count & 0x1FFFFFFF)) - count;
}
if (_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0)
{
DWORD Start = _Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000;
DWORD Len = _Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000;
DWORD PAddr = _Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30;
DWORD End = Start + Len;
for (count = Start; count < End; count += 0x1000) {
m_TLB_ReadMap[count >> 12] = ((DWORD)m_RDRAM + (count - Start + PAddr)) - count;
m_TLB_WriteMap[count >> 12] = ((DWORD)m_RDRAM + (count - Start + PAddr)) - count;
}
}
Reset(false);
_Settings->RegisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged);
return true;
@ -145,7 +153,7 @@ void CMipsMemoryVM::FreeMemory ( void )
VirtualFree( m_TLB_WriteMap, 0 , MEM_RELEASE);
m_TLB_WriteMap = NULL;
}
memset(m_PIF_Ram,0,sizeof(m_PIF_Ram));
memset(m_PifRam,0,sizeof(m_PifRam));
}
BYTE * CMipsMemoryVM::Rdram ( void )
@ -170,7 +178,7 @@ BYTE * CMipsMemoryVM::Imem ( void )
BYTE * CMipsMemoryVM::PifRam ( void )
{
return m_PIF_Ram;
return m_PifRam;
}
BOOL CMipsMemoryVM::LB_VAddr ( DWORD VAddr, BYTE & Value )
@ -399,10 +407,10 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
switch (PAddr) {
case 0x04400010:
UpdateCounters(m_RegWorkingSet,false,true);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)this,x86_ECX);
Call_Direct(AddressOf(CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
MoveVariableToX86reg(&m_HalfLine,"m_HalfLine",Reg);
break;
default:
@ -413,21 +421,21 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
case 0x04500000: /* AI registers */
switch (PAddr) {
case 0x04500004:
if (_Settings->LoadBool(Game_FixedAudio))
if (g_FixedAudio)
{
UpdateCounters(m_RegWorkingSet,false,true);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::AiGetLength),"CAudio::AiGetLength");
Call_Direct(AddressOf(CAudio::GetLength),"CAudio::GetLength");
MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg);
} else {
if (_Plugins->Audio()->ReadLength != NULL) {
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(_Plugins->Audio()->ReadLength,"AiReadLength");
MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg);
} else {
MoveConstToX86reg(0,Reg);
@ -435,13 +443,13 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
}
break;
case 0x0450000C:
if (_Settings->LoadBool(Game_FixedAudio))
if (g_FixedAudio)
{
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::AiGetStatus),"AiGetStatus");
Call_Direct(AddressOf(CAudio::GetStatus),"GetStatus");
MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg);
} else {
MoveVariableToX86reg(&_Reg->AI_STATUS_REG,"AI_STATUS_REG",Reg);
@ -662,9 +670,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04040004: MoveConstToVariable(Value,&_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break;
case 0x04040008:
MoveConstToVariable(Value,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&SP_DMA_READ,"SP_DMA_READ");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04040010:
{
@ -704,22 +712,22 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
if ( ( Value & SP_SET_SIG0 ) != 0 && _Settings->LoadBool(Game_RspAudioSignal) )
{
OrConstToVariable(MI_INTR_SP,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
if ( ( Value & SP_CLR_INTR ) != 0) {
AndConstToVariable(~MI_INTR_SP,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(RunRsp,"RunRsp");
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
} else {
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(RunRsp,"RunRsp");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
}
break;
@ -792,9 +800,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
JeLabel8("Continue",0);
Jump = m_RecompPos - 1;
MoveConstToVariable(Value,&_Reg->VI_STATUS_REG,"VI_STATUS_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
*((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1);
@ -807,9 +815,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
JeLabel8("Continue",0);
Jump = m_RecompPos - 1;
MoveConstToVariable(Value,&_Reg->VI_WIDTH_REG,"VI_WIDTH_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
*((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1);
@ -818,10 +826,10 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x0440000C: MoveConstToVariable(Value,&_Reg->VI_INTR_REG,"VI_INTR_REG"); break;
case 0x04400010:
AndConstToVariable(~MI_INTR_VI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04400014: MoveConstToVariable(Value,&_Reg->VI_BURST_REG,"VI_BURST_REG"); break;
case 0x04400018: MoveConstToVariable(Value,&_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break;
@ -841,31 +849,31 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04500000: MoveConstToVariable(Value,&_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break;
case 0x04500004:
MoveConstToVariable(Value,&_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect();
if (_Settings->LoadBool(Game_FixedAudio))
BeforeCallDirect(m_RegWorkingSet);
if (g_FixedAudio)
{
X86BreakPoint(__FILE__,__LINE__);
MoveConstToX86reg((DWORD)Value,x86_EDX);
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::AiSetLength),"AiSetLength");
Call_Direct(AddressOf(CAudio::LenChanged),"LenChanged");
} else {
Call_Direct(_Plugins->Audio()->LenChanged,"AiLenChanged");
}
Call_Direct(_Plugins->Audio()->LenChanged,"AiLenChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04500008: MoveConstToVariable((Value & 1),&_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); break;
case 0x0450000C:
/* Clear Interrupt */;
AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
#ifdef tofix
if (!_Settings->LoadBool(Game_FixedAudio))
if (!g_FixedAudio)
{
AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg");
}
#endif
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04500010:
sprintf(VarName,"m_RDRAM + %X",PAddr);
@ -884,23 +892,23 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04600004: MoveConstToVariable(Value,&_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break;
case 0x04600008:
MoveConstToVariable(Value,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&PI_DMA_READ,"PI_DMA_READ");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x0460000C:
MoveConstToVariable(Value,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04600010:
if ((Value & PI_CLR_INTR) != 0 ) {
AndConstToVariable(~MI_INTR_PI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
break;
case 0x04600014: MoveConstToVariable((Value & 0xFF),&_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG"); break;
@ -926,23 +934,25 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04800000: MoveConstToVariable(Value,&_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break;
case 0x04800004:
MoveConstToVariable(Value,&_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG");
BeforeCallDirect();
Call_Direct(&SI_DMA_READ,"SI_DMA_READ");
AfterCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
Call_Direct(AddressOf(CPifRam::SI_DMA_READ),"CPifRam::SI_DMA_READ");
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04800010:
MoveConstToVariable(Value,&_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG");
BeforeCallDirect();
Call_Direct(&SI_DMA_WRITE,"SI_DMA_WRITE");
AfterCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
Call_Direct(AddressOf(CPifRam::SI_DMA_WRITE),"CPifRam::SI_DMA_WRITE");
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04800018:
AndConstToVariable(~MI_INTR_SI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
AndConstToVariable(~SI_STATUS_INTERRUPT,&_Reg->SI_STATUS_REG,"SI_STATUS_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
default:
if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Const\ntrying to store %X in %X?",Value,VAddr); }
@ -983,21 +993,21 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x04040004: MoveX86regToVariable(Reg,&_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break;
case 0x04040008:
MoveX86regToVariable(Reg,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&SP_DMA_READ,"SP_DMA_READ");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x0404000C:
MoveX86regToVariable(Reg,&_Reg->SP_WR_LEN_REG,"SP_WR_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&SP_DMA_WRITE,"SP_DMA_WRITE");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04040010:
MoveX86regToVariable(Reg,&RegModValue,"RegModValue");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(ChangeSpStatus,"ChangeSpStatus");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x0404001C: MoveConstToVariable(0,&_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG"); break;
case 0x04080000:
@ -1023,15 +1033,15 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
switch (PAddr) {
case 0x04300000:
MoveX86regToVariable(Reg,&RegModValue,"RegModValue");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(ChangeMiIntrMask,"ChangeMiModeReg");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x0430000C:
MoveX86regToVariable(Reg,&RegModValue,"RegModValue");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(ChangeMiIntrMask,"ChangeMiIntrMask");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
default:
CPU_Message(" Should be moving %s in to %X ?!?",x86_Name(Reg),VAddr);
@ -1046,9 +1056,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
JeLabel8("Continue",0);
Jump = m_RecompPos - 1;
MoveX86regToVariable(Reg,&_Reg->VI_STATUS_REG,"VI_STATUS_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
*((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1);
@ -1064,9 +1074,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
JeLabel8("Continue",0);
Jump = m_RecompPos - 1;
MoveX86regToVariable(Reg,&_Reg->VI_WIDTH_REG,"VI_WIDTH_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
CPU_Message("");
CPU_Message(" Continue:");
*((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1);
@ -1075,10 +1085,10 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x0440000C: MoveX86regToVariable(Reg,&_Reg->VI_INTR_REG,"VI_INTR_REG"); break;
case 0x04400010:
AndConstToVariable(~MI_INTR_VI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04400014: MoveX86regToVariable(Reg,&_Reg->VI_BURST_REG,"VI_BURST_REG"); break;
case 0x04400018: MoveX86regToVariable(Reg,&_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break;
@ -1100,14 +1110,15 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x04500004:
UpdateCounters(m_RegWorkingSet,false,true);
MoveX86regToVariable(Reg,&_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect();
if (_Settings->LoadBool(Game_FixedAudio))
BeforeCallDirect(m_RegWorkingSet);
if (g_FixedAudio)
{
MoveConstToX86reg((DWORD)_Audio,x86_ECX);
Call_Direct(AddressOf(CAudio::AiSetLength),"AiSetLength");
Call_Direct(AddressOf(CAudio::LenChanged),"LenChanged");
} else {
Call_Direct(_Plugins->Audio()->LenChanged,"_Plugins->Audio()->LenChanged");
}
Call_Direct(_Plugins->Audio()->LenChanged,"AiLenChanged");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04500008:
MoveX86regToVariable(Reg,&_Reg->AI_CONTROL_REG,"AI_CONTROL_REG");
@ -1116,10 +1127,10 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
/* Clear Interrupt */;
AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04500010:
sprintf(VarName,"m_RDRAM + %X",PAddr);
@ -1137,23 +1148,23 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x04600004: MoveX86regToVariable(Reg,&_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break;
case 0x04600008:
MoveX86regToVariable(Reg,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&PI_DMA_READ,"PI_DMA_READ");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x0460000C:
MoveX86regToVariable(Reg,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04600010:
if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Register\ntrying to store at %X?",VAddr); }
AndConstToVariable(~MI_INTR_PI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
MoveX86regToVariable(Reg,&_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG");
AndConstToVariable(0xFFFFFF,&_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG");
@ -1190,23 +1201,25 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x04800000: MoveX86regToVariable(Reg,&_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break;
case 0x04800004:
MoveX86regToVariable(Reg,&_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG");
BeforeCallDirect();
Call_Direct(&SI_DMA_READ,"SI_DMA_READ");
AfterCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
Call_Direct(AddressOf(CPifRam::SI_DMA_READ),"CPifRam::SI_DMA_READ");
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04800010:
MoveX86regToVariable(Reg,&_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG");
BeforeCallDirect();
Call_Direct(&SI_DMA_WRITE,"SI_DMA_WRITE");
AfterCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
Call_Direct(AddressOf(CPifRam::SI_DMA_WRITE),"CPifRam::SI_DMA_WRITE");
AfterCallDirect(m_RegWorkingSet);
break;
case 0x04800018:
AndConstToVariable(~MI_INTR_SI,&_Reg->MI_INTR_REG,"MI_INTR_REG");
AndConstToVariable(~SI_STATUS_INTERRUPT,&_Reg->SI_STATUS_REG,"SI_STATUS_REG");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
default:
if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Register\ntrying to store at %X?",VAddr); }
@ -1712,9 +1725,9 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
case 0x04500000:
switch (PAddr) {
case 0x04500004:
if (_Settings->LoadBool(Game_FixedAudio))
if (g_FixedAudio)
{
*Value = _Audio->AiGetLength();
*Value = _Audio->GetLength();
} else {
if (_Plugins->Audio()->ReadLength != NULL) {
*Value = _Plugins->Audio()->ReadLength();
@ -1724,9 +1737,9 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
}
break;
case 0x0450000C:
if (_Settings->LoadBool(Game_FixedAudio))
if (g_FixedAudio)
{
*Value = _Audio->AiGetStatus();
*Value = _Audio->GetStatus();
} else {
*Value = _Reg->AI_STATUS_REG;
}
@ -2196,9 +2209,10 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
_Reg->AI_LEN_REG = Value;
if (g_FixedAudio)
{
_Audio->AiSetLength();
_Audio->LenChanged();
} else {
if (_Plugins->Audio()->LenChanged != NULL) { _Plugins->Audio()->LenChanged(); }
}
if (_Plugins->Audio()->LenChanged != NULL) { _Plugins->Audio()->LenChanged(); }
break;
case 0x04500008: _Reg->AI_CONTROL_REG = (Value & 1); break;
case 0x0450000C:
@ -2210,7 +2224,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
case 0x04500010:
_Reg->AI_DACRATE_REG = Value;
DacrateChanged(g_SystemType);
if (_Settings->LoadBool(Game_FixedAudio))
if (g_FixedAudio)
{
#ifdef tofix
g_Audio->AiSetFrequency(Value,g_SystemType);
@ -2302,7 +2316,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
bswap eax
mov Value,eax
}
*(DWORD *)(&m_PIF_Ram[PAddr - 0x1FC007C0]) = Value;
*(DWORD *)(&m_PifRam[PAddr - 0x1FC007C0]) = Value;
if (PAddr == 0x1FC007FC) {
PifRamWrite();
}
@ -3053,10 +3067,10 @@ void CMipsMemoryVM::Compile_LDL (void)
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC));
if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); }
if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" );
Call_Direct(R4300iOp::LDL, "R4300iOp::LDL");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
#endif
}
@ -3068,10 +3082,10 @@ void CMipsMemoryVM::Compile_LDR (void)
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC));
if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); }
if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" );
Call_Direct(R4300iOp::LDR, "R4300iOp::LDR");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
#endif
}
@ -3705,10 +3719,10 @@ void CMipsMemoryVM::Compile_SDL (void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC));
if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); }
if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" );
Call_Direct(R4300iOp::SDL, "R4300iOp::SDL");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
#endif
}
@ -3719,10 +3733,10 @@ void CMipsMemoryVM::Compile_SDR (void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC));
if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); }
if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" );
Call_Direct(R4300iOp::SDR, "R4300iOp::SDR");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
#endif
}

View File

@ -2,12 +2,13 @@ class CMipsMemoryVM :
public CMipsMemory,
public CTransVaddr,
private CRecompilerOps,
private R4300iOp
private R4300iOp,
private CPifRam
{
CMipsMemory_CallBack * const m_CBClass;
//Memory Locations
BYTE * m_RDRAM, * m_DMEM, * m_IMEM, m_PIF_Ram[0x40];
BYTE * m_RDRAM, * m_DMEM, * m_IMEM;
DWORD m_AllocatedRdramSize;
//Rom Information
@ -27,10 +28,11 @@ class CMipsMemoryVM :
void FreeMemory ( void );
public:
CMipsMemoryVM ( CMipsMemory_CallBack * CallBack );
CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOnly );
~CMipsMemoryVM ( void );
BOOL Initialize ( void );
void Reset ( bool EraseMemory );
BYTE * Rdram ( void );
DWORD RdramSize ( void );
@ -56,6 +58,7 @@ public:
//Compilation Functions
void ResetMemoryStack ( void );
void ResetTLB ( void );
void Compile_LB ( void );
void Compile_LBU ( void );

View File

@ -0,0 +1,812 @@
#include "stdafx.h"
#include "../C Core/mempak.h"
int CPifRamSettings::m_RefCount = 0;
bool CPifRamSettings::m_bShowPifRamErrors = false;
bool CPifRamSettings::m_DelaySI = false;
DWORD CPifRamSettings::m_RdramSize = 0;
CPifRamSettings::CPifRamSettings()
{
m_RefCount += 1;
if (m_RefCount == 1)
{
_Settings->RegisterChangeCB(Debugger_ShowPifErrors,NULL,RefreshSettings);
_Settings->RegisterChangeCB(Game_RDRamSize,NULL,RefreshSettings);
RefreshSettings(NULL);
}
}
CPifRamSettings::~CPifRamSettings()
{
m_RefCount -= 1;
if (m_RefCount == 0)
{
_Settings->UnregisterChangeCB(Debugger_ShowPifErrors,NULL,RefreshSettings);
_Settings->UnregisterChangeCB(Game_RDRamSize,NULL,RefreshSettings);
}
}
void CPifRamSettings::RefreshSettings(void *)
{
m_bShowPifRamErrors = _Settings->LoadBool(Debugger_ShowPifErrors);
m_RdramSize = _Settings->LoadDword(Game_RDRamSize);
}
CPifRam::CPifRam( bool SavesReadOnly ) :
CEeprom(SavesReadOnly)
{
memset(m_PifRam,0,sizeof(m_PifRam));
}
CPifRam::~CPifRam( void )
{
}
void CPifRam::PifRamRead (void)
{
if (m_PifRam[0x3F] == 0x2)
{
return;
}
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
int Channel = 0;
for (int CurPos = 0; CurPos < 0x40; CurPos ++)
{
switch(m_PifRam[CurPos]) {
case 0x00:
Channel += 1;
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 (_Plugins->Control()->ReadController) { _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()) { DisplayError("Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]); }
CurPos = 0x40;
}
break;
}
} while( CurPos < 0x40 );
if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(-1,NULL); }
}
void CPifRam::PifRamWrite (void) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
int Channel, CurPos;
Channel = 0;
if( m_PifRam[0x3F] > 0x1) {
switch (m_PifRam[0x3F]) {
case 0x02: Pif2Write (); break;
case 0x08:
m_PifRam[0x3F] = 0;
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
break;
case 0x10:
memset(m_PifRom,0,0x7C0);
break;
case 0x30:
m_PifRam[0x3F] = 0x80;
break;
case 0xC0:
memset(m_PifRam,0,0x40);
break;
default:
if (bShowPifRamErrors()) { DisplayError("Unkown PifRam control: %d",m_PifRam[0x3F]); }
}
return;
}
for (CurPos = 0; CurPos < 0x40; CurPos++){
switch(m_PifRam[CurPos]) {
case 0x00:
Channel += 1;
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 (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]); }
} else {
ProcessControllerCommand(Channel,&m_PifRam[CurPos]);
}
} else if (Channel == 4) {
EepromCommand(&m_PifRam[CurPos]);
} else {
if (bShowPifRamErrors())
{
DisplayError("Command on channel 5?");
}
}
CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1;
Channel += 1;
} else {
if (bShowPifRamErrors()) { DisplayError("Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]); }
CurPos = 0x40;
}
break;
}
}
m_PifRam[0x3F] = 0;
if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(-1,NULL); }
}
void CPifRam::SI_DMA_READ (void)
{
BYTE * PifRamPos = m_PifRam;
BYTE * RDRAM = _MMU->Rdram();
DWORD & SI_DRAM_ADDR_REG = _Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize())
{
if (bShowPifRamErrors())
{
DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRam space");
}
return;
}
PifRamRead();
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
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; }
RDRAM[RdramPos ^3] = m_PifRam[count];
}
} else {
_asm {
mov edi, dword ptr [SI_DRAM_ADDR_REG]
mov edi, dword ptr [edi]
add edi, RDRAM
mov ecx, PifRamPos
mov edx, 0
memcpyloop:
mov eax, dword ptr [ecx + edx]
bswap eax
mov dword ptr [edi + edx],eax
mov eax, dword ptr [ecx + edx + 4]
bswap eax
mov dword ptr [edi + edx + 4],eax
mov eax, dword ptr [ecx + edx + 8]
bswap eax
mov dword ptr [edi + edx + 8],eax
mov eax, dword ptr [ecx + edx + 12]
bswap eax
mov dword ptr [edi + edx + 12],eax
add edx, 16
cmp edx, 64
jb memcpyloop
}
}
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) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
sprintf(Addon,"%c%c%c%c",
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
}
if (bDelaySI()) {
_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
}
}
void CPifRam::SI_DMA_WRITE (void)
{
BYTE * PifRamPos = m_PifRam;
DWORD & SI_DRAM_ADDR_REG = _Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize())
{
if (bShowPifRamErrors())
{
DisplayError("SI DMA\nSI_DRAM_ADDR_REG not in RDRam space");
}
return;
}
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
BYTE * RDRAM = _MMU->Rdram();
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; }
m_PifRam[count] = RDRAM[RdramPos ^3];
}
} else {
_asm {
mov ecx, dword ptr [SI_DRAM_ADDR_REG]
mov ecx, dword ptr [ecx]
add ecx, RDRAM
mov edi, PifRamPos
mov edx, 0
memcpyloop:
mov eax, dword ptr [ecx + edx]
bswap eax
mov dword ptr [edi + edx],eax
mov eax, dword ptr [ecx + edx + 4]
bswap eax
mov dword ptr [edi + edx + 4],eax
mov eax, dword ptr [ecx + edx + 8]
bswap eax
mov dword ptr [edi + edx + 8],eax
mov eax, dword ptr [ecx + edx + 12]
bswap eax
mov dword ptr [edi + edx + 12],eax
add edx, 16
cmp edx, 64
jb memcpyloop
}
}
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) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
sprintf(Addon,"%c%c%c%c",
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
}
PifRamWrite();
if (bDelaySI()) {
_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
_Reg->MI_INTR_REG |= MI_INTR_SI;
_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
_Reg->CheckInterrupts();
}
}
void CPifRam::Pif2Write (void)
{
static const QWORD Pif2Reply[][4] =
{
//; Jet Force Gemini
{ 0x8FBB1DB876B63CEC, 0x025BEAEDEC803A6B, 0xDEB04FDB4CF76A13, 0x000B73E74AC64045 },
//; Banjo TooiE },
{ 0x0004001000400000, 0x0200000000000001, 0xA862ECC671D39FBF, 0x00F9F9F9F9F9F9CB },
{ 0x0004001000400001, 0x0200001000400001, 0x71939FBF8C2AE6B4, 0x00171737C6A8EC76 },
{ 0x0004001000400002, 0x0200002000800001, 0xA862ECC671D399B9, 0x001717177171F9CB },
{ 0x0004001000400003, 0x0200003000C00001, 0x71939FBF8C2AC6BE, 0x005555558C2AEC76 },
{ 0x0004001000410004, 0x0200004000000001, 0xF91B1737E6B471B3, 0x00ECC6A8ECC66EFE },
{ 0x0004001000410005, 0x0200005000400001, 0xA862ECE69F2FC6B8, 0x00ECC6A81737F9CB },
{ 0x0004001000410006, 0x0200006000800001, 0x71939FBF8C5A37BD, 0x00C66E4EECE6EC76 },
{ 0x0004001000410007, 0x0200007000C00001, 0x8CCA6EEC9909A8B2, 0x00C66E4E17377163 },
{ 0x0004001000420008, 0x0200008000000001, 0xA862ECE69F5F17B7, 0x00717171F9F9F9CB },
{ 0x0004001000420009, 0x0200009000400001, 0xF91B1737C60E6EBC, 0x005555B5E6046EFE },
{ 0x000400100042000A, 0x020000A000800001, 0xA862ECE69F5F11B1, 0x009F9F9F7171F9CB },
{ 0x000400100042000B, 0x020000B000C00001, 0x55151111A8A2ECB6, 0x007171D38C2A8C5A },
{ 0x000400100043000C, 0x020000C000000001, 0xF91B1737C69855BB, 0x006E8C2AECC66EFE },
{ 0x000400100043000D, 0x020000D000400001, 0x4EE0C66E17A74EB0, 0x00ECC6A89FBF7163 },
{ 0x000400100043000E, 0x020000E000800001, 0xF91B1737C69855B5, 0x006E8C2A6E4E6EFE },
{ 0x000400100043000F, 0x020000F000C00001, 0x4EE0C66E17A78CBA, 0x006EECC617377163 },
{ 0x0004001100440010, 0x0200000000000001, 0x8CCA6E3CC62EE604, 0x0071717171717163 },
{ 0x0004001100440011, 0x0200001000400001, 0x5575716317D79909, 0x00171737C6A88C5A },
{ 0x0004001100440012, 0x0200002000800001, 0x8CCA6E3CC62EC60E, 0x009F9F9FF9F97163 },
{ 0x0004001100440013, 0x0200003000C00001, 0x37FDF9CB71B37103, 0x009F9FBF6E8C6E1C },
{ 0x0004001100450014, 0x0200004000000001, 0x37FDF9CB7123C608, 0x00ECC6A8ECC66E1C },
{ 0x0004001100450015, 0x0200005000400001, 0x8CCA6E3CC65E370D, 0x006E8C2A9FBF7163 },
{ 0x0004001100450016, 0x0200006000800001, 0x55757163370DA802, 0x00C66E4EECE68C5A },
{ 0x0004001100450017, 0x0200007000C00001, 0x8CCA6E3CC65E1707, 0x00C66E4E17377163 },
{ 0x0004001100460018, 0x0200008000000001, 0xA862EC16A8026E0C, 0x00717171F9F9F9CB },
{ 0x0004001100460019, 0x0200009000400001, 0x37FDF9CB71531101, 0x005555B5E6046E1C },
{ 0x000400110046001A, 0x020000A000800001, 0x4EE0E6B4ECA6EC06, 0x00171717F9F97163 },
{ 0x000400110046001B, 0x020000B000C00001, 0x557571631797550B, 0x007171D38C2A8C5A },
{ 0x000400110047001C, 0x020000C000000001, 0x55757143F9AB4E00, 0x00ECC6A8C66E8C5A },
{ 0x000400110047001D, 0x020000D000400001, 0x8CCA6E1C6E9C5505, 0x00ECC6A89FBF7163 },
{ 0x000400110047001E, 0x020000E000800001, 0x55757143F9AB8C0A, 0x006EECC6ECE68C5A },
{ 0x000400110047001F, 0x020000F000C00001, 0x4EE0E6B4ECD69F0F, 0x006EECC617377163 },
{ 0x0004001200480020, 0x0200000000000001, 0x4EE0C66811915555, 0x0071717171717163 },
{ 0x0004001200480021, 0x0200001000400001, 0x71939FBF4EA08C5A, 0x00171737C6A8EC76 },
{ 0x0004001200480022, 0x0200002000800001, 0x4EE0C648F9DB9F5F, 0x009F9F9FF9F97163 },
{ 0x0004001200480023, 0x0200003000C00001, 0x9959551BA822E654, 0x007171D3C6A8C69E },
{ 0x0004001200490024, 0x0200004000000001, 0x71939FBF4ED09959, 0x006E8C2AC66EEC76 },
{ 0x0004001200490025, 0x0200005000400001, 0x4EE0C6681727C65E, 0x006E8C2A9FBF7163 },
{ 0x0004001200490026, 0x0200006000800001, 0x557571116EBC7153, 0x00C66E4EECE68C5A },
{ 0x0004001200490027, 0x0200007000C00001, 0x4EE0C6681727C658, 0x00C66E4E17377163 },
{ 0x00040012004A0028, 0x0200008000000001, 0x4EE0C6681757375D, 0x00F9F9F971717163 },
{ 0x00040012004A0029, 0x0200009000400001, 0x379D99B9EC06A852, 0x005555B5E6046E1C },
{ 0x00040012004A002A, 0x020000A000800001, 0x4EE0C66817571757, 0x00171717F9F97163 },
{ 0x00040012004A002B, 0x020000B000C00001, 0x379D99B9EC066E5C, 0x001717376E8C6E1C },
{ 0x00040012004B002C, 0x020000C000000001, 0x557571116E5C1151, 0x00ECC6A8C66E8C5A },
{ 0x00040012004B002D, 0x020000D000400001, 0xA8624EE09FAFEC56, 0x006E8C2A1737F9CB },
{ 0x00040012004B002E, 0x020000E000800001, 0x71939FBF4E90555B, 0x006EECC6ECE6EC76 },
{ 0x00040012004B002F, 0x020000F000C00001, 0xA8624EE09FAF4E50, 0x00C66E4E9FBFF9CB },
{ 0x00040013004C0030, 0x0200000000000001, 0x4EE0C6BEEC26C6A8, 0x0071717171717163 },
{ 0x00040013004C0031, 0x0200001000400001, 0xF91B376D115137AD, 0x00171737E6046EFE },
{ 0x00040013004C0032, 0x0200002000800001, 0x4EE0E6B44E00A8A2, 0x009F9F9FF9F97163 },
{ 0x00040013004C0033, 0x0200003000C00001, 0xF91B376D115117A7, 0x009F9FBF6E8C6EFE },
{ 0x00040013004D0034, 0x0200004000000001, 0xF91B17A755056EAC, 0x00ECC6A8ECC66EFE },
{ 0x00040013004D0035, 0x0200005000400001, 0x4EE0E6B44EB071A1, 0x006E8C2A9FBF7163 },
{ 0x00040013004D0036, 0x0200006000800001, 0xF91B374DF9A9ECA6, 0x00ECC6A86E4E6EFE },
{ 0x00040013004D0037, 0x0200007000C00001, 0xA862EC36C638F9AB, 0x006EECC69FBFF9CB },
{ 0x00040013004E0038, 0x0200008000000001, 0xA862EC166EAE4EA0, 0x00717171F9F9F9CB },
{ 0x00040013004E0039, 0x0200009000400001, 0x995955E59F9F55A5, 0x001717378C2AC69E },
{ 0x00040013004E003A, 0x020000A000800001, 0xA862EC166EAE8CAA, 0x009F9F9F7171F9CB },
{ 0x00040013004E003B, 0x020000B000C00001, 0xF91B374DF9D99FAF, 0x001717376E8C6EFE },
{ 0x00040013004F003C, 0x020000C000000001, 0xF91B17A75525E6A4, 0x006E8C2AECC66EFE },
{ 0x00040013004F003D, 0x020000D000400001, 0xA8624E10A832F9A9, 0x006E8C2A1737F9CB },
{ 0x00040013004F003E, 0x020000E000800001, 0x995955E59F0F6EAE, 0x00C66E4EC66EC69E },
{ 0x00040013004F003F, 0x020000F000C00001, 0x4EE0C6BE8CBA71A3, 0x006EECC617377163 },
{ 0x0005001400500040, 0x0200000000000001, 0xA8F2F91B6E8CF9F9, 0x00F9F9F9F9F9F9CB },
{ 0x0005001400500041, 0x0200001000400001, 0x9FCF6EAC55556EFE, 0x009F9FBF8C2AE694 },
{ 0x0005001400500042, 0x0200002000800001, 0xC65E553BE60471F3, 0x009F9F9FF9F971E1 },
{ 0x0005001400500043, 0x0200003000C00001, 0x17678CCA7171C6F8, 0x009F9FBF6E8C6E1C },
{ 0x0005001400510044, 0x0200004000000001, 0x9FCFA86237AD37FD, 0x00ECE6046EECE694 },
{ 0x0005001400510045, 0x0200005000400001, 0x8C7A71B38C5AA8F2, 0x006E8C2A9FBF7163 },
{ 0x0005001400510046, 0x0200006000800001, 0x9FCFA86237AD17F7, 0x006EECC6C66EE694 },
{ 0x0005001400510047, 0x0200007000C00001, 0x8C7A71B38C5A6EFC, 0x00C66E4E17377163 },
{ 0x0005001400520048, 0x0200008000000001, 0xC65E553BC60E71F1, 0x00F9F9F9717171E1 },
{ 0x0005001400520049, 0x0200009000400001, 0x17678CCA71F3ECF6, 0x005555B5E6046E1C },
{ 0x000500140052004A, 0x020000A000800001, 0x8C7A71B3EC86F9FB, 0x00171717F9F97163 },
{ 0x000500140052004B, 0x020000B000C00001, 0x17678CCA71F34EF0, 0x001717376E8C6E1C },
{ 0x000500140053004C, 0x020000C000000001, 0x9FCFA842F9EB55F5, 0x00C66E8C6EECE694 },
{ 0x000500140053004D, 0x020000D000400001, 0xC65E553BC6F88CFA, 0x00ECC6A89FBF71E1 },
{ 0x000500140053004E, 0x020000E000800001, 0x17674EE099299FFF, 0x006E8C2A6E4E6E1C },
{ 0x000500140053004F, 0x020000F000C00001, 0xA8F2F9B94E70E6F4, 0x00C66E4E9FBFF9CB },
{ 0x0005001500540050, 0x0200000000000001, 0xC65E55E599596E4E, 0x00717171717171E1 },
{ 0x0005001500540051, 0x0200001000400001, 0x17674E30C6087143, 0x00171737E6046E1C },
{ 0x0005001500540052, 0x0200002000800001, 0x8C7A71A15575C648, 0x009F9F9Ff9f97163 },
{ 0x0005001500540053, 0x0200003000C00001, 0x17674E106EAC374D, 0x009F9FBF6E8C6E1C },
{ 0x0005001500550054, 0x0200004000000001, 0x17674E30C65EA842, 0x00ECC6A8ECC66E1C },
{ 0x0005001500550055, 0x0200005000400001, 0xC6989FCF71A11747, 0x006E8C2A9FBF71E1 },
{ 0x0005001500550056, 0x0200006000800001, 0x17674E30C65E6E4C, 0x00ECC6A86E4E6E1C },
{ 0x0005001500550057, 0x0200007000C00001, 0x4E101767370D7141, 0x00C66E4E17377163 },
{ 0x0005001500560058, 0x0200008000000001, 0x4E10176717F7EC46, 0x00F9F9F971717163 },
{ 0x0005001500560059, 0x0200009000400001, 0x55E5C6B88C8AF94B, 0x005555B5C6A88C5A },
{ 0x000500150056005A, 0x020000A000800001, 0x4E10176717F74E40, 0x00171717F9F97163 },
{ 0x000500150056005B, 0x020000B000C00001, 0x55E5C6B88CEA5545, 0x007171D38C2A8C5A },
{ 0x000500150057005C, 0x020000C000000001, 0x17674E106EFC8C4A, 0x006E8C2AECC66E1C },
{ 0x000500150057005D, 0x020000D000400001, 0x4E101767372D9F4F, 0x00ECC6A89FBF7163 },
{ 0x000500150057005E, 0x020000E000800001, 0x17674E30E674E644, 0x006E8C2A6E4E6E1C },
{ 0x000500150057005F, 0x020000F000C00001, 0xC6989FEF9F8FF949, 0x006EECC6173771E1 },
{ 0x0005001600580060, 0x0200000000000001, 0xC6989F1FA8229F9F, 0x00717171717171E1 },
{ 0x0005001600580061, 0x0200001000400001, 0x9FCF6E4CF979E694, 0x009F9FBF8C2AE694 },
{ 0x0005001600580062, 0x0200002000800001, 0xC65E5535E684F999, 0x009F9F9FF9F971E1 },
{ 0x0005001600580063, 0x0200003000C00001, 0x9FCF6E6C375D6E9E, 0x007171D3C6A8E694 },
{ 0x0005001600590064, 0x0200004000000001, 0x9FCF6E6C11017193, 0x00ECE6046EECE694 },
{ 0x0005001600590065, 0x0200005000400001, 0xC65E55156E7EC698, 0x006E8C2A9FBF71E1 },
{ 0x0005001600590066, 0x0200006000800001, 0x1767ECA655A5379D, 0x00ECC6A86E4E6E1C },
{ 0x0005001600590067, 0x0200007000C00001, 0xC6989F1FA852A892, 0x00C66E4E173771E1 },
{ 0x00050016005A0068, 0x0200008000000001, 0x4E1037BD8CAA1797, 0x00F9F9F971717163 },
{ 0x00050016005A0069, 0x0200009000400001, 0x9FCF6E6C17576E9C, 0x001717378C2AE694 },
{ 0x00050016005A006A, 0x020000A000800001, 0x4E1037BDEC067191, 0x00171717F9F97163 },
{ 0x00050016005A006B, 0x020000B000C00001, 0x9FCF6E4CF9FBEC96, 0x00555555C6A8E694 },
{ 0x00050016005B006C, 0x020000C000000001, 0x55E5E6C47183F99B, 0x00ECC6A8C66E8C5A },
{ 0x00050016005B006D, 0x020000D000400001, 0x8C7A71B34EF04E90, 0x00ECC6A89FBF7163 },
{ 0x00050016005B006E, 0x020000E000800001, 0x55E5E6C471E35595, 0x006EECC6ECE68C5A },
{ 0x00050016005B006F, 0x020000F000C00001, 0x8C7A71B34EF08C9A, 0x006EECC617377163 },
{ 0x00050017005C0070, 0x0200000000000001, 0xA8F2F9AB55F5ECE6, 0x00F9F9F9F9F9F9CB },
{ 0x00050017005C0071, 0x0200001000400001, 0x17678C3AC6E855EB, 0x00171737E6046E1C },
{ 0x00050017005C0072, 0x0200002000800001, 0xA8F2F9AB55F54EE0, 0x001717177171F9CB },
{ 0x00050017005C0073, 0x0200003000C00001, 0x17678C3AC6E855E5, 0x009F9FBF6E8C6E1C },
{ 0x00050017005D0074, 0x0200004000000001, 0x9FCFA8B28CFA8CEA, 0x00ECE6046EECE694 },
{ 0x00050017005D0075, 0x0200005000400001, 0xA8F2F9AB552B9FEF, 0x00ECC6A81737F9CB },
{ 0x00050017005D0076, 0x0200006000800001, 0x55E5E614A872E6E4, 0x00C66E4EECE68C5A },
{ 0x00050017005D0077, 0x0200007000C00001, 0xA8F2F9AB552B99E9, 0x006EECC69FBFF9CB },
{ 0x00050017005E0078, 0x0200008000000001, 0x8C1A11611777C6EE, 0x00F9F9F971717163 },
{ 0x00050017005E0079, 0x0200009000400001, 0x9FCFA8B28C0A71E3, 0x001717378C2AE694 },
{ 0x00050017005E007A, 0x020000A000800001, 0x8C1A11611777C6E8, 0x00171717F9F97163 },
{ 0x00050017005E007B, 0x020000B000C00001, 0x17678C1A6EAE37ED, 0x001717376E8C6E1C },
{ 0x00050017005F007C, 0x020000C000000001, 0x55E5C6B84E50A8E2, 0x00ECC6A8C66E8C5A },
{ 0x00050017005F007D, 0x020000D000400001, 0xA8F2F9C971A317E7, 0x006E8C2A1737F9CB },
{ 0x00050017005F007E, 0x020000E000800001, 0x55E5C6B84E506EEC, 0x006EECC6ECE68C5A },
{ 0x00050017005F007F, 0x020000F000C00001, 0xABF2F9C971A311E1, 0x00C66E4E9FBFF9CB },
{ 0x0006001800600080, 0x0200000000000001, 0x6E6CEC46F9F91737, 0x00F9F9F9F9F9F9CB },
{ 0x0006001800600081, 0x0200001000400001, 0x379D9F3FC6A86E3C, 0x00171737E6046E1C },
{ 0x0006001800600082, 0x0200002000800001, 0x6E6CEC46F9F91131, 0x001717177171F9CB },
{ 0x0006001800600083, 0x0200003000C00001, 0x379D9F1F6E4EEC36, 0x009F9FBF6E8C6E1C },
{ 0x0006001800610084, 0x0200004000000001, 0x379D9F1F6E3C553B, 0x00ECC6A8ECC66E1C },
{ 0x0006001800610085, 0x0200005000400001, 0xE6C46ECE71434E30, 0x006E8C2A9FBF71E1 },
{ 0x0006001800610086, 0x0200006000800001, 0x379D9F1F6E3C5535, 0x00ECC6A86E4E6E1C },
{ 0x0006001800610087, 0x0200007000C00001, 0xE6C46ECE71438C3A, 0x00C66E4E173771E1 },
{ 0x0006001800620088, 0x0200008000000001, 0x6E6CEC46F97B9F3F, 0x00717171F9F9F9CB },
{ 0x0006001800620089, 0x0200009000400001, 0x551537BD4EC0E634, 0x005555B5C6A88C5A },
{ 0x000600180062008A, 0x020000A000800001, 0x6E6CEC46F97B9939, 0x009F9F9F7171F9CB },
{ 0x000600180062008B, 0x020000B000C00001, 0x551537BD4EC0C63E, 0x007171D38C2A8C5A },
{ 0x000600180063008C, 0x020000C000000001, 0x379D9F3FE6547133, 0x006E8C2AECC66E1C },
{ 0x000600180063008D, 0x020000D000400001, 0x6E6C4EA055C5C638, 0x006E8C2A1737F9CB },
{ 0x000600180063008E, 0x020000E000800001, 0x379D9F3FC6F8373D, 0x006E8C2A6E4E6E1C },
{ 0x000600180063008F, 0x020000F000C00001, 0x6E6CEC6617A7A832, 0x00C66E4E9FBFF9CB },
{ 0x0006001900640090, 0x0200000000000001, 0x8CEAE6146EAC6E8C, 0x0071717171717163 },
{ 0x0006001900640091, 0x0200001000400001, 0x7153556B37FD1181, 0x00171737C6A8EC76 },
{ 0x0006001900640092, 0x0200002000800001, 0x8CEAC61EA842EC86, 0x009F9F9FF9F97163 },
{ 0x0006001900640093, 0x0200003000C00001, 0x715355A5553B558B, 0x005555558C2AEC76 },
{ 0x0006001900650094, 0x0200004000000001, 0x7153556B17474E80, 0x006E8C2AC66EEC76 },
{ 0x0006001900650095, 0x0200005000400001, 0xE6C4A8B24E305585, 0x006E8C2A9FBF71E1 },
{ 0x0006001900650096, 0x0200006000800001, 0x7153556B17478C8A, 0x00C66E4EECE6EC76 },
{ 0x0006001900650097, 0x0200007000C00001, 0xE6C46EBC8C7A9F8F, 0x00C66E4E173771E1 },
{ 0x0006001900660098, 0x0200008000000001, 0x8CEAE634E6C4E684, 0x00F9F9F971717163 },
{ 0x0006001900660099, 0x0200009000400001, 0x9F7F71E39F7F9989, 0x001717378C2AE694 },
{ 0x000600190066009A, 0x020000A000800001, 0x8CEAE634E6C4C68E, 0x00171717F9F97163 },
{ 0x000600190066009B, 0x020000B000C00001, 0x9F7F71C371537183, 0x00555555C6A8E694 },
{ 0x000600190067009C, 0x020000C000000001, 0x17F7F94BF9C9C688, 0x006E8C2AECC66E1C },
{ 0x000600190067009D, 0x020000D000400001, 0x8CEAE6146EFC378D, 0x00ECC6A89FBF7163 },
{ 0x000600190067009E, 0x020000E000800001, 0x17F7F94BF9ABA882, 0x006E8C2A6E4E6E1C },
{ 0x000600190067009F, 0x020000F000C00001, 0x8CEAE6146EFC1787, 0x006EECC617377163 },
{ 0x0002000A002800A0, 0x0200000000000000, 0xF97B71919F1F71D3, 0x00F9F9F9F9F9F9F9 },
{ 0x0002000A002800A1, 0x0200001000400000, 0x4EC06EEEE684C6D8, 0x009F9FBF8C2AC66E },
{ 0x0002000A002800A2, 0x0200002000800000, 0x71F3F91917B737DD, 0x009F9F9FF9F97171 },
{ 0x0002000A002800A3, 0x0200003000C00000, 0xC6684E60EC66A8D2, 0x009F9FBF6E8C6EEC },
{ 0x0002000A002900A4, 0x0200004000000000, 0xECE6C6C86EBC17D7, 0x00ECE6046EECC66E },
{ 0x0002000A002900A5, 0x0200005000400000, 0x71111757556B6EDC, 0x006E8C2A9FBF7171 },
{ 0x0002000A002900A6, 0x0200006000800000, 0x4EC06EEEE61471D1, 0x006EECC6C66EC66E },
{ 0x0002000A002900A7, 0x0200007000C00000, 0xF97B71131101ECD6, 0x006EECC69FBFF9F9 },
{ 0x0002000A002A00A8, 0x0200008000000000, 0xF97B71737191F9DB, 0x00717171F9F9F9F9 },
{ 0x0002000A002A00A9, 0x0200009000400000, 0xC6684E60EC064ED0, 0x005555B5E6046EEC },
{ 0x0002000A002A00AA, 0x020000A000800000, 0x71F3F9FBF9FB55D5, 0x00171717F9F97171 },
{ 0x0002000A002A00AB, 0x020000B000C00000, 0xC6684E60EC068CDA, 0x001717376E8C6EEC },
{ 0x0002000A002B00AC, 0x020000C000000000, 0x4EC06EEEC63E9FDF, 0x00C66E8C6EECC66E },
{ 0x0002000A002B00AD, 0x020000D000400000, 0xF97B71737183E6D4, 0x006E8C2A1737F9F9 },
{ 0x0002000A002B00AE, 0x020000E000800000, 0xC6684E60EC96F9D9, 0x006E8C2A6E4E6EEC },
{ 0x0002000A002B00AF, 0x020000F000C00000, 0x7111175755656EDE, 0x006EECC617377171 },
{ 0x0002000B002C00B0, 0x0200000000000000, 0x9F5F55654E008C2A, 0x009F9F9F9F9F9F9F },
{ 0x0002000B002C00B1, 0x0200001000400000, 0xECE6C67871339F2F, 0x009F9FBF8C2AC66E },
{ 0x0002000B002C00B2, 0x0200002000800000, 0xF97B71E3C688E624, 0x991717177171F9F9 },
{ 0x0002000B002C00B3, 0x0200003000C00000, 0xECE6C67871339929, 0x007171D3C6A8C66E },
{ 0x0002000B002D00B4, 0x0200004000000000, 0x4EC06E1E378DC62E, 0x00ECE6046EECC66E },
{ 0x0002000B002D00B5, 0x0200005000400000, 0xF97B71E3C6187123, 0x00ECC6A81737F9F9 },
{ 0x0002000B002D00B6, 0x0200006000800000, 0x4EC06E1E378DC628, 0x006EECC6C66EC66E },
{ 0x0002000B002D00B7, 0x0200007000C00000, 0x9F5F55654EB0372D, 0x00C66E8C55559F9F },
{ 0x0002000B002E00B8, 0x0200008000000000, 0xF97B71E3E664A822, 0x00717171F9F9F9F9 },
{ 0x0002000B002E00B9, 0x0200009000400000, 0x4EC06E5C55B51727, 0x001717378C2AC66E },
{ 0x0002000B002E00BA, 0x020000A000800000, 0xF97B71E3E6646E2C, 0x009F9F9F7171F9F9 },
{ 0x0002000B002E00BB, 0x020000B000C00000, 0xC6684EF0F9BB1121, 0x001717376E8C6EEC },
{ 0x0002000B002F00BC, 0x020000C000000000, 0xC668EC969F0FEC26, 0x006E8C2AECC66EEC },
{ 0x0002000B002F00BD, 0x020000D000400000, 0xF97B71E3E6F4552B, 0x006E8C2A1737F9F9 },
{ 0x0002000B002F00BE, 0x020000E000800000, 0xC668EC969F0F4E20, 0x006E8C2A6E4E6EEC },
{ 0x0002000B002F00BF, 0x020000F000C00000, 0xF97B71E3E6F45525, 0x00C66E4E9FBFF9F9 },
{ 0x0003000C003000C0, 0x0200000000000000, 0xF9EBC6E8C66E7171, 0x00F9F9F9F9F9F9F9 },
{ 0x0003000C003000C1, 0x0200001000400000, 0x4E1011515555EC76, 0x009F9FBF8C2AC66E },
{ 0x0003000C003000C2, 0x0200002000800000, 0x376D8C6AECE6F97B, 0x001717379F9F1717 },
{ 0x0003000C003000C3, 0x0200003000C00000, 0x4E10115155554E70, 0x007171D3C6A8C66E },
{ 0x0003000C003100C4, 0x0200004000000000, 0xEC16377D71435575, 0x00ECE6046EECC66E },
{ 0x0003000C003100C5, 0x0200005000400000, 0x376D8C6A8C5A8C7A, 0x00C66EEC55551717 },
{ 0x0003000C003100C6, 0x0200006000800000, 0xEC16371D11819F7F, 0x006EECC6C66EC66E },
{ 0x0003000C003100C7, 0x0200007000C00000, 0xF9EBC6E8C6D8E674, 0x006EECC69FBFF9F9 },
{ 0x0003000C003200C8, 0x0200008000000000, 0x376D8C6A4EE0F979, 0x009F9F9F17171717 },
{ 0x0003000C003200C9, 0x0200009000400000, 0xE654559599B96E7E, 0x005555B5E6046EEC },
{ 0x0003000C003200CA, 0x020000A000800000, 0xF9EBC6E8C6687173, 0x009F9F9F7171F9F9 },
{ 0x0003000C003200CB, 0x020000B000C00000, 0x4E70711337DDC678, 0x00555555C6A8C66E },
{ 0x0003000C003300CC, 0x020000C000000000, 0xEC16377D7103377D, 0x00C66E8C6EECC66E },
{ 0x0003000C003300CD, 0x020000D000400000, 0xF9EBC6E8E6B4A872, 0x006E8C2A1737F9F9 },
{ 0x0003000C003300CE, 0x020000E000800000, 0xEC16377D71031777, 0x00C66E4EC66EC66E },
{ 0x0003000C003300CF, 0x020000F000C00000, 0xF9EBC6E8C6BE6E7C, 0x00C66E4E9FBFF9F9 },
{ 0x0003000D003400D0, 0x0200000000000000, 0x376D8C9A9959ECC6, 0x0017171717171717 },
{ 0x0003000D003400D1, 0x0200001000400000, 0x6E9E9F6F8CEAF9CB, 0x00171737C6A8ECC6 },
{ 0x0003000D003400D2, 0x0200002000800000, 0x376D8C9A99594EC0, 0x001717379F9F1717 },
{ 0x0003000D003400D3, 0x0200003000C00000, 0xEC1617C7A84255C5, 0x007171D3C6A8C66E },
{ 0x0003000D003500D4, 0x0200004000000000, 0xEC1637EDC65E8CCA, 0x00ECE6046EECC66E },
{ 0x0003000D003500D5, 0x0200005000400000, 0x376DEC5655859FCF, 0x00C66EEC55551717 },
{ 0x0003000D003500D6, 0x0200006000800000, 0xEC1617C76EDCE6C4, 0x006EECC6C66EC66E },
{ 0x0003000D003500D7, 0x0200007000C00000, 0x376D4E909FEFF9C9, 0x00ECC6A871D31717 },
{ 0x0003000D003600D8, 0x0200008000000000, 0xF9EBC61837BD6ECE, 0x00717171F9F9F9F9 },
{ 0x0003000D003600D9, 0x0200009000400000, 0xEC1617C76E6C71C3, 0x001717378C2AC66E },
{ 0x0003000D003600DA, 0x020000A000800000, 0x55C5A87271D1C6C8, 0x009F9F9F71D35555 },
{ 0x0003000D003600DB, 0x020000B000C00000, 0xEC1617C7A80237CD, 0x00555555C6A8C66E },
{ 0x0003000D003700DC, 0x020000C000000000, 0xEC1637EDC6B8A8C2, 0x00C66E8C6EECC66E },
{ 0x0003000D003700DD, 0x020000D000400000, 0xF9EBC618170717C7, 0x006E8C2A1737F9F9 },
{ 0x0003000D003700DE, 0x020000E000800000, 0xEC1617C7A8B26ECC, 0x00C66E4EC66EC66E },
{ 0x0003000D003700DF, 0x020000F000C00000, 0x55C5A812116171C1, 0x006EECC611115555 },
{ 0x0003000E003800E0, 0x0200000000000000, 0x55C56ECC6E0C1717, 0x0055555555555555 },
{ 0x0003000E003800E1, 0x0200001000400000, 0xEC16371D17B76E1C, 0x009F9FBF8C2AC66E },
{ 0x0003000E003800E2, 0x0200002000800000, 0xF9EBE664EC667111, 0x001717177171F9F9 },
{ 0x0003000E003800E3, 0x0200003000C00000, 0xEC16371D375DEC16, 0x007171D3C6A8C66E },
{ 0x0003000E003900E4, 0x0200004000000000, 0xEC16177771E3F91B, 0x00ECE6046EECC66E },
{ 0x0003000E003900E5, 0x0200005000400000, 0x55C56ECCA8524E10, 0x006E8C2A99995555 },
{ 0x0003000E003900E6, 0x0200006000800000, 0x6E9E9FFFF94B5515, 0x00C66E4EECE6ECC6 },
{ 0x0003000E003900E7, 0x0200007000C00000, 0x55C56ECCA8528C1A, 0x00C66E4E11115555 },
{ 0x0003000E003A00E8, 0x0200008000000000, 0x55C5A8E2C68E9F1F, 0x007171D355555555 },
{ 0x0003000E003A00E9, 0x0200009000400000, 0xE654555B55D5E614, 0x005555B5E6046EEC },
{ 0x0003000E003A00EA, 0x020000A000800000, 0x55C5A8E2C6E8F919, 0x009F9F9F71D35555 },
{ 0x0003000E003A00EB, 0x020000B000C00000, 0xEC16171711B16E1E, 0x00555555C6A8C66E },
{ 0x0003000E003B00EC, 0x020000C000000000, 0xE654555B55657113, 0x006E8C2AECC66EEC },
{ 0x0003000E003B00ED, 0x020000D000400000, 0xF9EBE6648CDAC618, 0x006E8C2A1737F9F9 },
{ 0x0003000E003B00EE, 0x020000E000800000, 0xE654555B550B371D, 0x006E8C2A6E4E6EEC },
{ 0x0003000E003B00EF, 0x020000F000C00000, 0x55C56ECC6EBCA812, 0x006EECC611115555 },
{ 0x0003000F003C00F0, 0x0200000000000000, 0x376D8C9A9FDFC66E, 0x0017171717171717 },
{ 0x0003000F003C00F1, 0x0200001000400000, 0xC69899698C6A7163, 0x00171737E6046EEC },
{ 0x0003000F003C00F2, 0x0200002000800000, 0x376D8C9A9FDFC668, 0x001717379F9F1717 },
{ 0x0003000F003C00F3, 0x0200003000C00000, 0xC69899694E00376D, 0x009F9FBF6E8C6EEC },
{ 0x0003000F003D00F4, 0x0200004000000000, 0xC6989969ECB6A862, 0x00ECC6A8ECC66EEC },
{ 0x0003000F003D00F5, 0x0200005000400000, 0x376D4E5055051767, 0x00C66EEC55551717 },
{ 0x0003000F003D00F6, 0x0200006000800000, 0xC69899694EB06E6C, 0x00ECC6A86E4E6EEC },
{ 0x0003000F003D00F7, 0x0200007000C00000, 0x376D4E5055051161, 0x00ECC6A871D31717 },
{ 0x0003000F003E00F8, 0x0200008000000000, 0x376D4E50555BEC66, 0x009F9F9F17171717 },
{ 0x0003000F003E00F9, 0x0200009000400000, 0xEC1617E7E644556B, 0x001717378C2AC66E },
{ 0x0003000F003E00FA, 0x020000A000800000, 0x376D4E50555B4E60, 0x009F9FBF9F9F1717 },
{ 0x0003000F003E00FB, 0x020000B000C00000, 0xEC1617E7E6445565, 0x00555555C6A8C66E },
{ 0x0003000F003F00FC, 0x020000C000000000, 0xC69899694E508C6A, 0x006E8C2AECC66EEC },
{ 0x0003000F003F00FD, 0x020000D000400000, 0x55C5A81217879F6F, 0x00ECC6A899995555 },
{ 0x0003000F003F00FE, 0x020000E000800000, 0x4E7071C16EDEE664, 0x00C66E4EC66EC66E },
{ 0x0003000F003F00FF, 0x020000F000C00000, 0x55C5A81217879969, 0x006EECC611115555 },
{ 0x0006001A006800A0, 0x0200000000000001, 0x6E6C4E60375D71D3, 0x00F9F9F9F9F9F9CB },
{ 0x0006001A006800A1, 0x0200001000400001, 0x17F7F9196ECEC6D8, 0x00171737E6046E1C },
{ 0x0006001A006800A2, 0x0200002000800001, 0x8CEAC6C871F137DD, 0x009F9F9FF9F97163 },
{ 0x0006001A006800A3, 0x0200003000C00001, 0x551517B74EA0A8D2, 0x005555558C2A8C5A },
{ 0x0006001A006900A4, 0x0200004000000001, 0x9F1F11B1ECF617D7, 0x00ECE6046EECE694 },
{ 0x0006001A006900A5, 0x0200005000400001, 0x6E6C8CAA55A56EDC, 0x00ECC6A81737F9CB },
{ 0x0006001A006900A6, 0x0200006000800001, 0x9F7F7113A85271D1, 0x006EECC6C66EE694 },
{ 0x0006001A006900A7, 0x0200007000C00001, 0x6E6C4E40F94BECD6, 0x006EECC69FBFF9CB },
{ 0x0006001A006A00A8, 0x0200008000000001, 0x6E6C8CAA55D5F9DB, 0x00717171F9F9F9CB },
{ 0x0006001A006A00A9, 0x0200009000400001, 0x551517B74E404ED0, 0x005555B5C6A88C5A },
{ 0x0006001A006A00AA, 0x020000A000800001, 0xE6C46EEE993955D5, 0x00171717F9F971E1 },
};
bool found = false;
for (int i = 0, n = sizeof(Pif2Reply)/sizeof(Pif2Reply[0]); i < n; i++)
{
if (Pif2Reply[i][0] != *(QWORD *)&m_PifRam[48]) { continue; }
if (Pif2Reply[i][1] != *(QWORD *)&m_PifRam[56]) { continue; }
m_PifRam[46] = m_PifRam[47] = 0x00;
*(QWORD *)&m_PifRam[48] = Pif2Reply[i][2];
*(QWORD *)&m_PifRam[56] = Pif2Reply[i][3];
found = true;
break;
}
if (!found) {
char buff[256];
int count;
sprintf (buff, "%s :(\r\n\r\nInfo:\r\nP1=%08X%08X P2=%08X%08X\r\n", GS(MSG_PIF2_ERROR),
*(DWORD *)&m_PifRam[52],*(DWORD *)&m_PifRam[48],*(DWORD *)&m_PifRam[60],*(DWORD *)&m_PifRam[56]);
for (count = 48; count < 64; count++) {
if (count % 4 == 0) {
strcat(buff,count == 48?"0x":", 0x");
}
char buff2[20];
sprintf(buff2,"%02X",m_PifRam[count]);
strcat(buff,buff2);
_Notify->DisplayError(buff);
}
}
}
void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
switch (Command[2]) {
case 0x00: // check
case 0xFF: // reset & check ?
if ((Command[1] & 0x80) != 0) { break; }
if (bShowPifRamErrors())
{
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 3) { DisplayError("What am I meant to do with this Controller Command"); }
}
if (Controllers[Control].Present == TRUE) {
Command[3] = 0x05;
Command[4] = 0x00;
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 {
Command[1] |= 0x80;
}
break;
case 0x01: // read controller
if (bShowPifRamErrors())
{
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 4) { DisplayError("What am I meant to do with this Controller Command"); }
}
if (Controllers[Control].Present == FALSE) {
Command[1] |= 0x80;
}
break;
case 0x02: //read from controller pack
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: Before Gettting Results"); }
if (bShowPifRamErrors())
{
if (Command[0] != 3) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 33) { DisplayError("What am I meant to do with this Controller Command"); }
}
if (Controllers[Control].Present == TRUE) {
DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) {
case PLUGIN_RUMBLE_PAK:
memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20);
Command[0x25] = Mempacks_CalulateCrc(&Command[5]);
break;
case PLUGIN_MEMPAK: ReadFromMempak(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
default:
memset(&Command[5], 0, 0x20);
Command[0x25] = 0;
}
} else {
Command[1] |= 0x80;
}
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: After Gettting Results"); }
break;
case 0x03: //write controller pak
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: Before Processing"); }
if (bShowPifRamErrors())
{
if (Command[0] != 35) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
}
if (Controllers[Control].Present == TRUE) {
DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) {
case PLUGIN_MEMPAK: WriteToMempak(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
case PLUGIN_RUMBLE_PAK:
if ((address & 0xFFE0) == 0xC000 && _Plugins->Control()->RumbleCommand != NULL) {
_Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5]));
}
default:
Command[0x25] = Mempacks_CalulateCrc(&Command[5]);
}
} else {
Command[1] |= 0x80;
}
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: After Processing"); }
break;
default:
if (bShowPifRamErrors()) { DisplayError("Unknown ControllerCommand %d",Command[2]); }
}
}
void CPifRam::ReadControllerCommand (int Control, BYTE * Command) {
CONTROL * Controllers = _Plugins->Control()->PluginControllers();
switch (Command[2]) {
case 0x01: // read controller
if (Controllers[Control].Present == TRUE)
{
if (bShowPifRamErrors())
{
if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
if (Command[1] != 4) { DisplayError("What am I meant to do with this Controller Command"); }
}
*(DWORD *)&Command[3] = _BaseSystem->GetButtons(Control);
}
break;
case 0x02: //read from controller pack
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
case PLUGIN_RAW: if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(Control, Command); } break;
}
}
break;
case 0x03: //write controller pak
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
case PLUGIN_RAW: if (_Plugins->Control()->ReadController) { _Plugins->Control()->ReadController(Control, Command); } break;
}
}
break;
}
}
void CPifRam::LogControllerPakData (char * Description)
{
BYTE * PIF_Ram = _MMU->PifRam();
#if (!defined(EXTERNAL_RELEASE))
int count, count2;
char HexData[100], AsciiData[100], Addon[20];
LogMessage("\t%s:",Description);
LogMessage("\t------------------------------");
for (count = 0; count < 16; count ++ ) {
if ((count % 4) == 0) {
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
sprintf(Addon,"%02X %02X %02X %02X",
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) {
sprintf(Addon,"-");
strcat(HexData,Addon);
}
Addon[0] = 0;
for (count2 = 0; count2 < 4; count2++) {
if (PIF_Ram[(count << 2) + count2] < 30) {
strcat(Addon,".");
} else {
sprintf(Addon,"%s%c",Addon,PIF_Ram[(count << 2) + count2]);
}
}
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
#endif
}

View File

@ -0,0 +1,46 @@
class CPifRamSettings
{
protected:
CPifRamSettings();
virtual ~CPifRamSettings();
inline bool bShowPifRamErrors ( void ) const { return m_bShowPifRamErrors; }
inline bool bDelaySI ( void ) const { return m_DelaySI; }
inline DWORD RdramSize ( void ) const { return m_RdramSize; }
private:
static void RefreshSettings ( void * );
static bool m_bShowPifRamErrors;
static bool m_DelaySI;
static DWORD m_RdramSize;
static int m_RefCount;
};
class CPifRam :
private CPifRamSettings,
private CEeprom
{
public:
public:
CPifRam ( bool SavesReadOnly );
~CPifRam ( void );
void PifRamWrite ( void );
void PifRamRead ( void );
void SI_DMA_READ ( void );
void SI_DMA_WRITE ( void );
protected:
BYTE m_PifRom[0x7C0];
BYTE m_PifRam[0x40];
private:
void ProcessControllerCommand ( int Control, BYTE * Command );
void ReadControllerCommand ( int Control, BYTE * Command );
void LogControllerPakData ( char * Description );
void Pif2Write ( void );
};

View File

@ -50,7 +50,7 @@ void CSystemEvents::ExecuteEvents ( void )
_Plugins->Gfx()->SoftReset();
break;
case SysEvent_ResetCPU_SoftDone:
_System->SoftReset();
_System->Reset(true,false);
break;
case SysEvent_Profile_GenerateLogs:
GenerateProfileLog();

View File

@ -45,6 +45,20 @@ void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
FixTimers();
}
DWORD CSystemTimer::GetTimer ( TimerType Type )
{
if (Type >= MaxTimer || Type == UnknownTimer)
{
_Notify->BreakPoint(__FILE__,__LINE__);
return 0;
}
if (!m_TimerDetatils[Type].Active)
{
return 0;
}
return m_TimerDetatils[Type].CyclesToTimer + m_NextTimer;
}
void CSystemTimer::StopTimer ( TimerType Type )
{
if (Type >= MaxTimer || Type == UnknownTimer)
@ -172,7 +186,7 @@ void CSystemTimer::TimerDone (void)
_SystemTimer->StopTimer(CSystemTimer::AiTimer);
_Reg->MI_INTR_REG |= MI_INTR_AI;
_Reg->CheckInterrupts();
_Audio->AiCallBack();
_Audio->TimerDone();
break;
default:
BreakPoint(__FILE__,__LINE__);
@ -193,72 +207,16 @@ void CSystemTimer::UpdateCompareTimer ( void )
_SystemTimer->SetTimer(CSystemTimer::CompareTimer,NextCompare,false);
}
#ifdef toremove
extern CLog TlbLog;
void CSystemTimer::ChangeTimerFixed (TimerType Type, DWORD Cycles) {
if (Type >= MaxTimer || Type == UnknownTimer) { return; }
if (Cycles == 0) {
return; //Ignore when your setting time to go in 0 cycles
bool CSystemTimer::SaveAllowed ( void )
{
for (int i = 0; i < MaxTimer; i++)
{
if (i == CompareTimer) { continue; }
if (i == ViTimer) { continue; }
if (m_TimerDetatils[i].Active)
{
return false;
}
}
TimerDetatils[Type].CyclesToTimer = (double)Cycles - Timer; //replace the new cycles
TimerDetatils[Type].Active = true;
FixTimers();
return true;
}
void CSystemTimer::ChangeTimerRelative (TimerType Type, DWORD Cycles) {
if (Type >= MaxTimer || Type == UnknownTimer) { return; }
if (TimerDetatils[Type].Active) {
TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
} else {
TimerDetatils[Type].CyclesToTimer = Cycles - Timer; //replace the new cycles
}
TimerDetatils[Type].Active = true;
FixTimers();
}
void CSystemTimer::CheckTimer (void) {
if (Timer > 0) { return; }
// TlbLog.Log("%s: Timer = %d, CurrentTimerType = %d",_System->GetRecompiler() ? "Recomp" : "Interp",Timer, CurrentTimerType);
switch (CurrentTimerType) {
case ViTimer: _N64System->ExternalEvent(TimerDone_Vi); break;
case AiTimer: _N64System->ExternalEvent(TimerDone_Ai); break;
case AiTimerDMA: _N64System->ExternalEvent(TimerDone_AiDMA); break;
case RSPTimerDlist:_N64System->ExternalEvent(TimerDone_RSPDlist); break;
case CompareTimer: _N64System->ExternalEvent(TimerDone_Compare); break;
default:
_Notify->BreakPoint(__FILE__,__LINE__);
}
}
void CSystemTimer::DeactiateTimer (TimerType Type) {
if (Type >= MaxTimer || Type == UnknownTimer) { return; }
TimerDetatils[Type].Active = false;
FixTimers();
}
double CSystemTimer::GetTimer (TimerType Type) const {
if (!TimerDetatils[Type].Active) { return 0; }
return TimerDetatils[Type].CyclesToTimer + Timer;
}
void CSystemTimer::ResetTimer ( int NextVITimer ) {
//initilize Structure
for (int count = 0; count < MaxTimer; count ++) {
TimerDetatils[count].Active = false;
TimerDetatils[count].CyclesToTimer = 0;
}
CurrentTimerType = UnknownTimer;
Timer = 0;
//set the initial timer for Video Interrupts
ChangeTimerRelative(ViTimer,NextVITimer);
}
void CSystemTimer::UpdateTimer (int StepIncrease) {
Timer -= StepIncrease;
}
#endif

View File

@ -27,11 +27,13 @@ public:
public:
CSystemTimer ( int & NextTimer );
void SetTimer ( TimerType Type, DWORD Cycles, bool bRelative );
DWORD GetTimer ( TimerType Type );
void StopTimer ( TimerType Type );
void UpdateTimers ( void );
void TimerDone ( void );
void Reset ( void );
void UpdateCompareTimer ( void );
bool SaveAllowed ( void );
inline TimerType CurrentType ( void ) const { return m_Current; }

View File

@ -27,7 +27,7 @@ void InitializeCPUCore ( void )
}
CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
m_MMU_VM(this),
m_MMU_VM(this,SavesReadOnly),
m_TLB(this),
m_FPS(_Notify),
m_CPU_Usage(_Notify),
@ -46,21 +46,7 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
m_CPU_Handle(NULL),
m_CPU_ThreadID(0)
{
//InterpreterOpcode = NULL;
m_hPauseEvent = CreateEvent(NULL,true,false,NULL);
switch (_Rom->GetCountry())
{
case Germany: case french: case Italian:
case Europe: case Spanish: case Australia:
case X_PAL: case Y_PAL:
m_SystemType = SYSTEM_PAL;
break;
default:
m_SystemType = SYSTEM_NTSC;
break;
}
m_Audio.AiSetFrequency(m_Reg.AI_DACRATE_REG,m_SystemType);
m_Limitor.SetHertz(_Settings->LoadDword(Game_ScreenHertz));
m_Cheats.LoadCheats(!_Settings->LoadDword(Setting_RememberCheats));
}
@ -167,8 +153,7 @@ void CN64System::ExternalEvent ( SystemEvent action )
_MMU = new CMipsMemoryVM(this);
_MMU->FixRDramSize();
m_Audio.ResetAudioSettings();
m_Audio.AiSetFrequency(m_Reg.AI_DACRATE_REG,m_SystemType);
m_Audio.Reset();
m_InReset = false;
StartEmulation(true);
@ -508,14 +493,15 @@ bool CN64System::IsDialogMsg( MSG * msg )
return false;
}
void CN64System::Reset (void)
void CN64System::Reset (bool bInitReg, bool ClearMenory)
{
if (m_Recomp)
{
m_Recomp->ResetRecompCode();
}
if (_Plugins) { _Plugins->GameReset(); }
m_Audio.ResetAudioSettings();
m_Audio.Reset();
m_MMU_VM.Reset(ClearMenory);
Debug_Reset();
CloseSaveChips();
@ -523,23 +509,21 @@ void CN64System::Reset (void)
m_AlistCount = 0;
m_DlistCount = 0;
m_UnknownCount = 0;
m_SystemType = SYSTEM_NTSC;
m_DMAUsed = false;
m_Reg.Reset();
m_SystemTimer.Reset();
m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false);
}
void CN64System::SoftReset()
{
Reset();
bool PostPif = true;
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
if (bInitReg)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
bool PostPif = true;
InitRegisters(PostPif,m_MMU_VM);
if (PostPif)
{
memcpy((m_MMU_VM.Dmem()+0x40), (_Rom->GetRomAddress() + 0x040), 0xFBC);
}
}
}
@ -555,7 +539,7 @@ bool CN64System::SetActiveSystem( bool bActive )
{
return false;
}
SoftReset();
Reset(true,true);
m_bInitilized = true;
bInitPlugin = true;
}
@ -818,7 +802,7 @@ void CN64System::ExecuteSyncCPU (CC_Core & C_Core)
CPlugins SyncPlugins ( _Settings->LoadString(Directory_PluginSync) );
SyncPlugins.SetRenderWindows(&SyncWindow,&SyncWindow);
m_SyncCPU = new CN64System(&SyncPlugins, false);
m_SyncCPU = new CN64System(&SyncPlugins, true);
m_Recomp = new CRecompiler(m_Profile,m_EndEmulation);
SetActiveSystem();
@ -915,7 +899,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) {
for (int z = 0; z < 0x100; z++)
{
if (m_MMU_VM.Rdram()[0x00325044 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00325044 + z])
if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z])
{
ErrorFound = true;
}
@ -932,7 +916,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) {
#endif
}
if (m_Audio.AiGetLength() != SecondCPU->m_Audio.AiGetLength()) { ErrorFound = true; }
if (m_Audio.GetLength() != SecondCPU->m_Audio.GetLength()) { ErrorFound = true; }
if (m_SystemTimer.CurrentType() != SecondCPU->m_SystemTimer.CurrentType()) { ErrorFound = true; }
if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; }
if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; }
@ -1051,10 +1035,15 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) {
SecondCPU->m_Reg.m_HI.UW[1],SecondCPU->m_Reg.m_HI.UW[0]);
Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_LO.UW[1],m_Reg.m_LO.UW[0],
SecondCPU->m_Reg.m_LO.UW[1],SecondCPU->m_Reg.m_LO.UW[0]);
Error.Log("\r\n");
Error.Log(" Hi Recomp, PageMask, Hi Interp, PageMask\r\n");
bool bHasTlb = false;
for (count = 0; count < 32; count ++) {
if (!m_TLB.TlbEntry(count).EntryDefined) { continue; }
if (!bHasTlb)
{
Error.Log("\r\n");
Error.Log(" Hi Recomp, PageMask, Hi Interp, PageMask\r\n");
bHasTlb = true;
}
Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count,
m_TLB.TlbEntry(count).EntryHi.Value,m_TLB.TlbEntry(count).PageMask.Value,
SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value,SecondCPU->m_TLB.TlbEntry(count).PageMask.Value
@ -1062,18 +1051,26 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) {
}
Error.Log("\r\n");
Error.Log("Code at PC:\r\n");
//_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
COpcode Op(SecondCPU->_MMU,SecondCPU->m_Reg,SecondCPU->m_Reg.m_PROGRAM_COUNTER - (OpCode_Size * 10));
for (;Op.PC() < SecondCPU->m_Reg.m_PROGRAM_COUNTER + (OpCode_Size * 10); Op.Next()) {
Error.LogF("%X,%s\r\n",Op.PC(),Op.Name().c_str());
for (count = -10; count < 10; count++)
{
DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2);
if (_MMU->LW_VAddr(Addr,OpcodeValue))
{
Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr));
}
}
Error.Log("\r\n");
Error.Log("Code at Last Sync PC:\r\n");
for (Op.SetPC(m_LastSuccessSyncPC[0]); Op.PC() < m_LastSuccessSyncPC[0] + (OpCode_Size * 50); Op.Next()) {
Error.LogF("%X,%s\r\n",Op.PC(),Op.Name().c_str());
for (count = 0; count < 50; count++)
{
DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2);
if (_MMU->LW_VAddr(Addr,OpcodeValue))
{
Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr));
}
}
#endif
}
_Notify->DisplayError("Sync Error");
@ -1085,14 +1082,8 @@ bool CN64System::SaveState(void)
{
WriteTrace(TraceDebug,"CN64System::SaveState 1");
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
if (m_Reg.GetTimer(AiTimerDMA) != 0) { return false; }
if (m_Reg.GetTimer(SiTimer) != 0) { return false; }
if (m_Reg.GetTimer(PiTimer) != 0) { return false; }
if (m_Reg.GetTimer(RSPTimerDlist) != 0) { return false; }
if (!m_SystemTimer.SaveAllowed()) { return false; }
if ((m_Reg.STATUS_REGISTER & STATUS_EXL) != 0) { return false; }
#endif
//Get the file Name
stdstr FileName, CurrentSaveName = _Settings->LoadString(GameRunning_InstantSaveFile);
@ -1134,11 +1125,7 @@ bool CN64System::SaveState(void)
DWORD dwWritten, SaveID_0 = 0x23D8A6C8;
DWORD RdramSize = _Settings->LoadDword(Game_RDRamSize);
DWORD MiInterReg = _Reg->MI_INTR_REG;
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
DWORD NextViTimer = m_Reg.GetTimer(ViTimer);
if (m_Reg.GetTimer(AiTimer) != 0) { m_Reg.MI_INTR_REG |= MI_INTR_AI; }
#endif
DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer);
if (_Settings->LoadDword(Setting_AutoZipInstantSave)) {
zipFile file;
@ -1147,10 +1134,7 @@ _Notify->BreakPoint(__FILE__,__LINE__);
zipWriteInFileInZip(file,&SaveID_0,sizeof(SaveID_0));
zipWriteInFileInZip(file,&RdramSize,sizeof(DWORD));
zipWriteInFileInZip(file,_Rom->GetRomAddress(),0x40);
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
zipWriteInFileInZip(file,&NextViTimer,sizeof(DWORD));
#endif
zipWriteInFileInZip(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER));
zipWriteInFileInZip(file,m_Reg.m_GPR,sizeof(__int64)*32);
zipWriteInFileInZip(file,m_Reg.m_FPR,sizeof(__int64)*32);
@ -1188,9 +1172,7 @@ _Notify->BreakPoint(__FILE__,__LINE__);
WriteFile( hSaveFile,&SaveID_0,sizeof(DWORD),&dwWritten,NULL);
WriteFile( hSaveFile,&RdramSize,sizeof(DWORD),&dwWritten,NULL);
WriteFile( hSaveFile,_Rom->GetRomAddress(),0x40,&dwWritten,NULL);
#ifdef tofix
WriteFile( hSaveFile,&NextViTimer,sizeof(DWORD),&dwWritten,NULL);
#endif
WriteFile( hSaveFile,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER),&dwWritten,NULL);
WriteFile( hSaveFile,m_Reg.m_GPR,sizeof(_int64)*32,&dwWritten,NULL);
WriteFile( hSaveFile,m_Reg.m_FPR,sizeof(_int64)*32,&dwWritten,NULL);
@ -1322,7 +1304,7 @@ bool CN64System::LoadState(LPCSTR FileName) {
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if (result == IDNO) { return FALSE; }
}
m_Reg.Reset();
Reset(false,true);
_MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4);
_MMU->UnProtectMemory(0xA4000000,0xA4001FFC);
@ -1374,17 +1356,11 @@ bool CN64System::LoadState(LPCSTR FileName) {
MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2);
if (result == IDNO) { return FALSE; }
}
m_Reg.Reset();
_Notify->BreakPoint(__FILE__,__LINE__);
Reset(false,true);
_MMU->UnProtectMemory(0x80000000,0x80000000 + _Settings->LoadDword(Game_RDRamSize) - 4);
_MMU->UnProtectMemory(0xA4000000,0xA4001FFC);
WriteTrace(TraceError,"Make sure memory is tracking changes to Game_RDRamSize");
if (SaveRDRAMSize != _Settings->LoadDword(Game_RDRamSize)) {
_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize);
#ifdef tofix
//_MMU->FixRDramSize();
#endif
}
_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize);
ReadFile( hSaveFile,&NextVITimer,sizeof(NextVITimer),&dwRead,NULL);
ReadFile( hSaveFile,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER),&dwRead,NULL);
ReadFile( hSaveFile,m_Reg.m_GPR,sizeof(_int64)*32,&dwRead,NULL);
@ -1417,29 +1393,13 @@ bool CN64System::LoadState(LPCSTR FileName) {
while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER) {
m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER;
}
WriteTrace(TraceDebug,"CN64System::LoadState 1");
if (m_Recomp)
{
m_Recomp->ResetRecompCode();
}
SoftReset();
//Fix up timer
m_Reg.m_CP0[32] = 0;
WriteTrace(TraceDebug,"CN64System::LoadState 2");
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
m_Reg.ResetTimer(NextVITimer);
WriteTrace(TraceDebug,"CN64System::LoadState 3");
m_Reg.ChangeTimerFixed(CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER);
WriteTrace(TraceDebug,"CN64System::LoadState 4");
#endif
m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false);
m_SystemTimer.SetTimer(CSystemTimer::ViTimer,NextVITimer,false);
m_Reg.FixFpuLocations();
WriteTrace(TraceDebug,"CN64System::LoadState 5");
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_MMU->TLB_Reset(false);
#endif
m_TLB.Reset(false);
WriteTrace(TraceDebug,"CN64System::LoadState 6");
m_CPU_Usage.ResetCounters();
WriteTrace(TraceDebug,"CN64System::LoadState 7");
@ -1447,24 +1407,14 @@ bool CN64System::LoadState(LPCSTR FileName) {
WriteTrace(TraceDebug,"CN64System::LoadState 8");
m_FPS.Reset(true);
WriteTrace(TraceDebug,"CN64System::LoadState 9");
m_AlistCount = 0;
m_DlistCount = 0;
m_UnknownCount = 0;
m_EventList.clear();
m_NoOfEvents = m_EventList.size();
WriteTrace(TraceDebug,"CN64System::LoadState 10");
_Plugins->GameReset();
WriteTrace(TraceDebug,"CN64System::LoadState 11");
ResetX86Logs();
WriteTrace(TraceDebug,"CN64System::LoadState 12");
_Audio->ResetAudioSettings();
_Audio->AiSetFrequency(m_Reg.AI_DACRATE_REG,m_SystemType);
_Plugins->Audio()->DacrateChanged(m_SystemType);
#ifdef TEST_SP_TRACKING
m_CurrentSP = GPR[29].UW[0];
#endif
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_MMU->m_MemoryStack = (DWORD)(_MMU->Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF));
#endif
@ -1475,19 +1425,13 @@ bool CN64System::LoadState(LPCSTR FileName) {
for (int i = 0; i < (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])); i++) {
m_LastSuccessSyncPC[i] = 0;
}
m_SyncCPU->SetActiveSystem(true);
m_SyncCPU->LoadState(FileNameStr.c_str());
SetActiveSystem(true);
SyncCPU(m_SyncCPU);
}
// if (m_Recomp->_Sync) {
// m_Recomp->_Sync->LoadState();
// m_Recomp->_Sync->_Plugins->Control()->SetControl(_Plugins->Control());
// SyncCPU(m_Recomp->_Sync);
// _Settings->Save(RamSize,SaveRDRAMSize);
// }
}
WriteTrace(TraceDebug,"CN64System::LoadState 13");
_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize);
WriteTrace(TraceDebug,"CN64System::LoadState 14");
stdstr LoadMsg = _Lang->GetString(MSG_LOADED_STATE);
WriteTrace(TraceDebug,"CN64System::LoadState 15");
@ -1581,7 +1525,7 @@ void CN64System::SyncToAudio ( void ) {
// {
// return;
// }
if (_Audio->AiGetLength() == 0)
if (_Audio->GetLength() == 0)
{
return;
}
@ -1631,10 +1575,19 @@ void CN64System::RefreshScreen ( void ) {
_SystemTimer->SetTimer(CSystemTimer::ViTimer,VI_INTR_TIME,true);
if (g_FixedAudio)
{
_Audio->UpdateAudioTimer (VI_INTR_TIME);
_Audio->SetViIntr (VI_INTR_TIME);
}
// _Plugins->Control()->UpdateKeys();
if (_Plugins->Control()->GetKeys)
{
BUTTONS Keys;
for (int Control = 0; Control < 4; Control++)
{
_Plugins->Control()->GetKeys(Control,&Keys);
m_Buttons[Control] = Keys.Value;
}
}
if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); }
// if (bProfiling) { m_Profile.StartTimer(Timer_UpdateScreen); }

View File

@ -40,12 +40,13 @@ public:
bool IsDialogMsg ( MSG * msg );
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
void SoftReset ( void );
void Reset ( bool bInitReg, bool ClearMenory );
bool m_EndEmulation;
// inline CPlugins * Plugins ( void ) const { return m_Plugins; }
inline bool DmaUsed ( void ) const { return m_DMAUsed; }
inline void SetDmaUsed ( bool DMAUsed) { m_DMAUsed = DMAUsed; }
inline DWORD GetButtons ( int Control ) { return m_Buttons[Control]; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core
#ifdef TEST_SP_TRACKING
@ -75,7 +76,6 @@ private:
void RefreshScreen ( void );
bool InternalEvent ( void );
bool InPermLoop ( void );
void Reset ( void );
void RunRSP ( void );
bool SaveState ( void );
bool LoadState ( LPCSTR FileName );
@ -121,11 +121,11 @@ private:
CSpeedLimitor m_Limitor;
bool m_InReset;
CSystemTimer m_SystemTimer;
SystemType m_SystemType;
bool m_bCleanFrameBox;
bool m_bInitilized;
int m_NextTimer;
bool m_DMAUsed;
DWORD m_Buttons[4];
//When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10];

View File

@ -126,8 +126,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS
}
//CPU_Message("CompileExit: %d",reason);
CCodeSection TempSection(m_BlockInfo,-1,0);
TempSection.m_RegWorkingSet = ExitRegSet;
ExitRegSet.WriteBackRegisters();
if (TargetPC != (DWORD)-1)
{
@ -136,19 +135,18 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS
} else {
UpdateCounters(ExitRegSet,false,reason == CExitInfo::Normal);
}
TempSection.m_RegWorkingSet.WriteBackRegisters();
switch (reason) {
case CExitInfo::Normal: case CExitInfo::Normal_NoSysCheck:
TempSection.m_RegWorkingSet.SetBlockCycleCount(0);
ExitRegSet.SetBlockCycleCount(0);
if (TargetPC != (DWORD)-1)
{
if (TargetPC <= JumpPC && reason == CExitInfo::Normal)
{
CompileSystemCheck((DWORD)-1,TempSection.m_RegWorkingSet);
CompileSystemCheck((DWORD)-1,ExitRegSet);
}
} else {
if (reason == CExitInfo::Normal) { CompileSystemCheck((DWORD)-1,TempSection.m_RegWorkingSet); }
if (reason == CExitInfo::Normal) { CompileSystemCheck((DWORD)-1,ExitRegSet); }
}
if (_SyncSystem)
{
@ -249,22 +247,25 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegS
ExitCodeBlock();
break;
case CExitInfo::DoSysCall:
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
MoveConstToX86reg(NextInstruction == JUMP || NextInstruction == DELAY_SLOT,x86_ECX);
Call_Direct(DoSysCallException,"DoSysCallException");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
ExitCodeBlock();
#endif
{
bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
PushImm32(bDelay ? "true" : "false", bDelay);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::DoSysCallException), "CRegisters::DoSysCallException");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
ExitCodeBlock();
}
break;
case CExitInfo::COP1_Unuseable:
PushImm32("1",1);
PushImm32((m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT) ? "true" : "false",
m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
ExitCodeBlock();
{
bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT;
PushImm32("1",1);
PushImm32(bDelay ? "true" : "false", bDelay);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
ExitCodeBlock();
}
break;
case CExitInfo::ExitResetRecompCode:
_Notify->BreakPoint(__FILE__,__LINE__);
@ -675,17 +676,18 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
{
m_BlockInfo->SetVAddrLast(m_CompilePC);
}
/*if (m_CompilePC == 0x80194A40)
/*if (m_CompilePC == 0x8031E02C)
{
// m_RegWorkingSet.UnMap_AllFPRs();
}*/
/*if (m_CompilePC >= 0x802CF644 && m_CompilePC <= 0x802CF650 && m_NextInstruction == NORMAL)
X86BreakPoint(__FILE__,__LINE__);
//m_RegWorkingSet.UnMap_AllFPRs();
}
/*if (m_CompilePC >= 0x8031DF84 && m_CompilePC <= 0x8031E034 && m_NextInstruction == NORMAL)
{
m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet,false,true);
MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
}*/
}
/*if (m_CompilePC == 0x803254F0 && m_NextInstruction == NORMAL)
{
@ -694,9 +696,17 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER");
if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); }
}*/
/*if (m_CompilePC == 0x803254F0 && m_NextInstruction == NORMAL)
/*if (m_CompilePC == 0x80000EC4 && m_NextInstruction == NORMAL)
{
X86BreakPoint(__FILE__,__LINE__);
//m_RegWorkingSet.UnMap_AllFPRs();
_Notify->BreakPoint(__FILE__,__LINE__);
//X86HardBreakPoint();
//X86BreakPoint(__FILE__,__LINE__);
//m_RegWorkingSet.UnMap_AllFPRs();
}
/*if (m_CompilePC >= 0x80179DC4 && m_CompilePC <= 0x80179DF0 && m_NextInstruction == NORMAL)
{
m_RegWorkingSet.UnMap_AllFPRs();
}*/
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp);
@ -954,15 +964,6 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
}
}
#ifdef tofix
if (DelaySlotSection)
{
Cont.RegSet = m_RegWorkingSet;
GenerateSectionLinkage();
NextInstruction = END_BLOCK;
}
#endif
switch (m_NextInstruction) {
case NORMAL:
m_CompilePC += 4;

View File

@ -81,16 +81,12 @@ void CRecompiler::RecompilerMain_VirtualTable ( void )
}
if (!_TransVaddr->ValidVaddr(PROGRAM_COUNTER))
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
DoTLBMiss(m_NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL;
_Reg->DoTLBMiss(false,PROGRAM_COUNTER);
if (!_TransVaddr->ValidVaddr(PROGRAM_COUNTER))
{
DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return;
}
#endif
continue;
}
@ -1828,20 +1824,13 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R
PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex];
if (table)
{
memset(((BYTE *)table) + WriteStart,0,DataToWrite);
memset(((BYTE *)&table[0]) + WriteStart,0,DataToWrite);
}
if (DataLeft > 0)
{
_Notify->BreakPoint(__FILE__,__LINE__);
}
//if (length >)
/*for (, EndAddress = Address + length; BaseAddress < )
PCCompiledFunc_TABLE & table = m_FunctionTable[PROGRAM_COUNTER >> 0xC];
DWORD TableEntry = (PROGRAM_COUNTER & 0xFFF) >> 2;*/
}
break;
}

View File

@ -151,7 +151,7 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc,
}
if (FallInfo->TargetPC <= m_CompilePC)
{
UpdateCounters(m_RegWorkingSet,true,true);
UpdateCounters(m_Section->m_Jump.RegSet,true,true);
ResetX86Protection();
}
} else {
@ -177,7 +177,7 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc,
}
JumpInfo->FallThrough = TRUE;
m_NextInstruction = DO_DELAY_SLOT;
memcpy(&m_RegWorkingSet,&RegBeforeDelay,sizeof(CRegInfo));
m_RegWorkingSet = RegBeforeDelay;
return;
}
}
@ -185,8 +185,8 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc,
} else {
CompareFunc();
ResetX86Protection();
memcpy(&m_Section->m_Cont.RegSet,&m_RegWorkingSet,sizeof(CRegInfo));
memcpy(&m_Section->m_Jump.RegSet,&m_RegWorkingSet,sizeof(CRegInfo));
m_Section->m_Cont.RegSet = m_RegWorkingSet;
m_Section->m_Jump.RegSet = m_RegWorkingSet;
}
m_Section->GenerateSectionLinkage();
m_NextInstruction = END_BLOCK;
@ -227,7 +227,7 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, BOOL Link
}
CompareFunc();
ResetX86Protection();
memcpy(&m_Section->m_Cont.RegSet,&m_RegWorkingSet,sizeof(CRegInfo));
m_Section->m_Cont.RegSet = m_RegWorkingSet;
if (g_UseLinking && m_Section->m_Jump.TargetPC == m_Section->m_Cont.TargetPC)
{
_Notify->BreakPoint(__FILE__,__LINE__);
@ -279,9 +279,9 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, BOOL Link
m_Section->m_Cont.LinkLocation2 = NULL;
}
}
m_Section->CompileExit(m_CompilePC, m_CompilePC + 8,m_RegWorkingSet,CExitInfo::Normal,TRUE,NULL);
CPU_Message(" ");
CPU_Message(" DoDelaySlot");
m_Section->CompileExit(m_CompilePC, m_CompilePC + 8,m_Section->m_Cont.RegSet,CExitInfo::Normal,TRUE,NULL);
CPU_Message("");
CPU_Message(" DoDelaySlot:");
m_Section->GenerateSectionLinkage();
m_NextInstruction = END_BLOCK;
} else {
@ -1392,10 +1392,10 @@ void CRecompilerOps::DADDIU (void) {
if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rs,TRUE); }
if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rt,TRUE); }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
Call_Direct(R4300iOp::DADDIU, "R4300iOp::DADDIU");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
void CRecompilerOps::CACHE (void){
@ -1409,9 +1409,9 @@ void CRecompilerOps::CACHE (void){
switch(m_Opcode.rt) {
case 0:
case 16:
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
PushImm32("CRecompiler::Remove_Cache",CRecompiler::Remove_Cache);
PushImm32("20",20);
PushImm32("0x20",0x20);
if (IsConst(m_Opcode.base)) {
DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset;
PushImm32("Address",Address);
@ -1425,7 +1425,7 @@ void CRecompilerOps::CACHE (void){
}
MoveConstToX86reg((DWORD)_Recompiler,x86_ECX);
Call_Direct(AddressOf(CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 1:
case 3:
@ -1847,10 +1847,9 @@ _Notify->BreakPoint(__FILE__,__LINE__);
}
void CRecompilerOps::SPECIAL_SYSCALL (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
m_Section->CompileExit(m_CompilePC,m_CompilePC,m_RegWorkingSet,CExitInfo::DoSysCall,TRUE,NULL);
#endif
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileExit(m_CompilePC,-1,m_RegWorkingSet,CExitInfo::DoSysCall,TRUE,NULL);
m_NextInstruction = END_BLOCK;
}
void CRecompilerOps::SPECIAL_MFLO (void) {
@ -2319,10 +2318,10 @@ void CRecompilerOps::SPECIAL_DDIV (void) {
UnMap_GPR(m_Opcode.rs,TRUE);
UnMap_GPR(m_Opcode.rt,TRUE);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
Call_Direct(R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
void CRecompilerOps::SPECIAL_DDIVU (void)
@ -2331,10 +2330,10 @@ void CRecompilerOps::SPECIAL_DDIVU (void)
UnMap_GPR(m_Opcode.rs,TRUE);
UnMap_GPR(m_Opcode.rt,TRUE);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
Call_Direct(R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
void CRecompilerOps::SPECIAL_ADD (void) {
@ -3407,12 +3406,11 @@ void CRecompilerOps::SPECIAL_DSUBU (void) {
}
void CRecompilerOps::SPECIAL_DSLL (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (m_Opcode.rd == 0) { return; }
if (IsConst(m_Opcode.rt)) {
if (IsConst(m_Opcode.rt))
{
if (IsMapped(m_Opcode.rd)) { UnMap_GPR(m_Opcode.rd, FALSE); }
m_Section->MipsReg(m_Opcode.rd) = Is64Bit(m_Opcode.rt)?m_Section->MipsReg(m_Opcode.rt):(__int64)m_Section->MipsRegLo_S(m_Opcode.rt) << m_Opcode.sa;
@ -3427,14 +3425,11 @@ void CRecompilerOps::SPECIAL_DSLL (void) {
}
Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt);
ShiftLeftDoubleImmed(MipsRegHi(m_Opcode.rd),cMipsRegLo(m_Opcode.rd),(BYTE)m_Opcode.sa);
ShiftLeftSignImmed( cMipsRegLo(m_Opcode.rd),(BYTE)m_Opcode.sa);
#endif
ShiftLeftDoubleImmed(cMipsRegMapHi(m_Opcode.rd),cMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa);
ShiftLeftSignImmed( cMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa);
}
void CRecompilerOps::SPECIAL_DSRL (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (m_Opcode.rd == 0) { return; }
@ -3452,9 +3447,8 @@ void CRecompilerOps::SPECIAL_DSRL (void) {
return;
}
Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt);
ShiftRightDoubleImmed(cMipsRegLo(m_Opcode.rd),MipsRegHi(m_Opcode.rd),(BYTE)m_Opcode.sa);
ShiftRightUnsignImmed(MipsRegHi(m_Opcode.rd),(BYTE)m_Opcode.sa);
#endif
ShiftRightDoubleImmed(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa);
ShiftRightUnsignImmed(cMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa);
}
void CRecompilerOps::SPECIAL_DSRA (void) {
@ -3637,10 +3631,10 @@ void CRecompilerOps::COP0_MT (void) {
break;
case 11: //Compare
UpdateCounters(m_RegWorkingSet,false,true);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
if (IsConst(m_Opcode.rt)) {
MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
} else if (IsMapped(m_Opcode.rt)) {
@ -3649,17 +3643,17 @@ void CRecompilerOps::COP0_MT (void) {
MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
}
AndConstToVariable(~CAUSE_IP7,&_Reg->FAKE_CAUSE_REGISTER,"FAKE_CAUSE_REGISTER");
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 9: //Count
UpdateCounters(m_RegWorkingSet,false,true);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
if (IsConst(m_Opcode.rt)) {
MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
} else if (IsMapped(m_Opcode.rt)) {
@ -3667,10 +3661,10 @@ void CRecompilerOps::COP0_MT (void) {
} else {
MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
}
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX);
Call_Direct(AddressOf(CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
case 12: //Status
{
@ -3687,28 +3681,28 @@ void CRecompilerOps::COP0_MT (void) {
TestConstToX86Reg(STATUS_FR,OldStatusReg);
JeLabel8("FpuFlagFine",0);
Jump = m_RecompPos - 1;
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(SetFpuLocations,"SetFpuLocations");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
*(BYTE *)(Jump)= (BYTE )(((BYTE )(m_RecompPos)) - (((BYTE )(Jump)) + 1));
//TestConstToX86Reg(STATUS_FR,OldStatusReg);
//BreakPoint(__FILE__,__LINE__); //m_Section->CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,FALSE,JneLabel32);
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
break;
case 6: //Wired
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE);
m_RegWorkingSet.BlockCycleCount() = 0;
m_RegWorkingSet.BlockRandomModifier() = 0;
Call_Direct(FixRandomReg,"FixRandomReg");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
if (IsConst(m_Opcode.rt)) {
MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]);
} else if (IsMapped(m_Opcode.rt)) {
@ -3730,10 +3724,10 @@ void CRecompilerOps::COP0_MT (void) {
CRecompilerOps::UnknownOpcode();
#endif
}
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_Reg,x86_ECX);
Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
break;
default:
_Notify->BreakPoint(__FILE__,__LINE__);
@ -3758,14 +3752,14 @@ void CRecompilerOps::COP0_CO_TLBR( void) {
void CRecompilerOps::COP0_CO_TLBWI( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!g_UseTlb) { return; }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
PushImm32("FALSE",FALSE);
MoveVariableToX86reg(&_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX);
AndConstToX86Reg(x86_ECX,0x1F);
Push(x86_ECX);
MoveConstToX86reg((DWORD)_TLB,x86_ECX);
Call_Direct(AddressOf(CTLB::WriteEntry),"CTLB::WriteEntry");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
void CRecompilerOps::COP0_CO_TLBWR( void) {
@ -3793,10 +3787,10 @@ void CRecompilerOps::COP0_CO_TLBP( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!g_UseTlb) { return; }
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)_TLB,x86_ECX);
Call_Direct(AddressOf(CTLB::Probe), "CTLB::TLB_Probe");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
}
void compiler_COP0_CO_ERET (void) {
@ -3957,9 +3951,9 @@ void CRecompilerOps::COP1_CT(void) {
} else {
MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),&_FPCR[m_Opcode.fs],CRegName::FPR_Ctrl[m_Opcode.fs]);
}
BeforeCallDirect();
BeforeCallDirect(m_RegWorkingSet);
Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel");
AfterCallDirect();
AfterCallDirect(m_RegWorkingSet);
m_RegWorkingSet.CurrentRoundingModel() = CRegInfo::RoundUnknown;
}
@ -4090,15 +4084,12 @@ void CRecompilerOps::COP1_S_DIV (void) {
}
void CRecompilerOps::COP1_S_ABS (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileCop1Test();
FixRoundModel(CRegInfo::RoundDefault);
Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float);
fpuAbs();
UnMap_FPR(m_Opcode.fd,TRUE);
#endif
}
void CRecompilerOps::COP1_S_NEG (void) {
@ -4162,9 +4153,8 @@ void CRecompilerOps::COP1_S_FLOOR_L (void) { //added by Witten
#endif
}
void CRecompilerOps::COP1_S_ROUND_W (void) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
void CRecompilerOps::COP1_S_ROUND_W (void)
{
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
m_Section->CompileCop1Test();
@ -4172,7 +4162,6 @@ void CRecompilerOps::COP1_S_ROUND_W (void) {
Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float);
}
ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundNearest);
#endif
}
void CRecompilerOps::COP1_S_TRUNC_W (void) {
@ -4715,16 +4704,16 @@ void CRecompilerOps::UnknownOpcode (void) {
#endif
}
void CRecompilerOps::BeforeCallDirect ( void )
void CRecompilerOps::BeforeCallDirect ( CRegInfo & RegSet )
{
UnMap_AllFPRs();
RegSet.UnMap_AllFPRs();
Pushad();
}
void CRecompilerOps::AfterCallDirect ( void )
void CRecompilerOps::AfterCallDirect ( CRegInfo & RegSet )
{
Popad();
m_RegWorkingSet.CurrentRoundingModel() = CRegInfo::RoundUnknown;
RegSet.CurrentRoundingModel() = CRegInfo::RoundUnknown;
}
void CRecompilerOps::EnterCodeBlock ( void )
@ -4749,12 +4738,12 @@ void CRecompilerOps::UpdateCounters ( CRegInfo & RegSet, bool CheckTimer, bool C
if (_SyncSystem) {
WriteX86Comment("Updating Sync CPU");
BeforeCallDirect();
BeforeCallDirect(RegSet);
PushImm32(stdstr_f("%d",RegSet.GetBlockCycleCount()).c_str(),RegSet.GetBlockCycleCount());
PushImm32("_SyncSystem",(DWORD)_SyncSystem);
MoveConstToX86reg((DWORD)_System,x86_ECX);
Call_Direct(AddressOf(CN64System::UpdateSyncCPU),"CN64System::UpdateSyncCPU");
AfterCallDirect();
AfterCallDirect(RegSet);
}
WriteX86Comment("Update Counter");
SubConstFromVariable(RegSet.GetBlockCycleCount(),_NextTimer,"_NextTimer"); // updates compare flag

View File

@ -182,8 +182,8 @@ protected:
static void UnknownOpcode ( void );
static void BeforeCallDirect ( void );
static void AfterCallDirect ( void );
static void BeforeCallDirect ( CRegInfo & RegSet );
static void AfterCallDirect ( CRegInfo & RegSet );
static void EnterCodeBlock ( void );
static void ExitCodeBlock ( void );
static void CompileReadTLBMiss (int AddressReg, int LookUpReg );

View File

@ -30,6 +30,7 @@ void CRegInfo::Initilize ( void )
for (count = 0; count < 8; count ++ ) {
x86fpu_MappedTo[count] = -1;
x86fpu_State[count] = FPU_Unknown;
x86fpu_StateChanged[count] = false;
x86fpu_RoundingModel[count] = RoundDefault;
}
Fpu_Used = false;
@ -77,19 +78,20 @@ void CRegInfo::ChangeFPURegFormat (int Reg, FPU_STATE OldFormat, FPU_STATE NewFo
{
for (DWORD i = 0; i < 8; i++)
{
if (FpuMappedTo(i) != (DWORD)Reg)
if (x86fpu_MappedTo[i] != (DWORD)Reg)
{
continue;
}
if (FpuState(i) != OldFormat) {
if (x86fpu_State[i] != OldFormat || x86fpu_StateChanged[i])
{
UnMap_FPR(Reg,TRUE);
Load_FPR_ToTop(Reg,Reg,OldFormat);
ChangeFPURegFormat(Reg,OldFormat,NewFormat,RoundingModel);
return;
} else {
CPU_Message(" regcache: Changed format of ST(%d) from %s to %s", (i - StackTopPos() + 8) & 7,Format_Name[OldFormat],Format_Name[NewFormat]);
}
CPU_Message(" regcache: Changed format of ST(%d) from %s to %s", (i - StackTopPos() + 8) & 7,Format_Name[OldFormat],Format_Name[NewFormat]);
FpuRoundingModel(i) = RoundingModel;
FpuState(i) = NewFormat;
FpuRoundingModel(i) = RoundingModel;
x86fpu_State[i] = NewFormat;
x86fpu_StateChanged[i] = true;
return;
}
@ -116,8 +118,8 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
} else {
if ((Reg & 1) != 0) {
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) == (DWORD)(Reg - 1)) {
if (FpuState(i) == FPU_Double || FpuState(i) == FPU_Qword) {
if (x86fpu_MappedTo[i] == (DWORD)(Reg - 1)) {
if (x86fpu_State[i] == FPU_Double || x86fpu_State[i] == FPU_Qword) {
UnMap_FPR(Reg,TRUE);
}
i = 8;
@ -126,8 +128,8 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
}
if ((RegToLoad & 1) != 0) {
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) == (DWORD)(RegToLoad - 1)) {
if (FpuState(i) == FPU_Double || FpuState(i) == FPU_Qword) {
if (x86fpu_MappedTo[i] == (DWORD)(RegToLoad - 1)) {
if (x86fpu_State[i] == FPU_Double || x86fpu_State[i] == FPU_Qword) {
UnMap_FPR(RegToLoad,TRUE);
}
i = 8;
@ -139,11 +141,11 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
if (Reg == RegToLoad) {
//if different format then unmap original reg from stack
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) != (DWORD)Reg)
if (x86fpu_MappedTo[i] != (DWORD)Reg)
{
continue;
}
if (FpuState(i) != (DWORD)Format) {
if (x86fpu_State[i] != (DWORD)Format) {
UnMap_FPR(Reg,TRUE);
}
break;
@ -152,26 +154,27 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
//if different format then unmap original reg from stack
for (i = 0; i < 8; i++)
{
if (FpuMappedTo(i) != (DWORD)Reg)
if (x86fpu_MappedTo[i] != (DWORD)Reg)
{
continue;
}
UnMap_FPR(Reg,FpuState(i) != (DWORD)Format);
UnMap_FPR(Reg,x86fpu_State[i] != (DWORD)Format);
break;
}
}
if (RegInStack(RegToLoad,Format)) {
if (Reg != RegToLoad) {
if (FpuMappedTo((StackTopPos() - 1) & 7) != (DWORD)RegToLoad) {
UnMap_FPR(FpuMappedTo((StackTopPos() - 1) & 7),TRUE);
if (x86fpu_MappedTo[(StackTopPos() - 1) & 7] != (DWORD)RegToLoad) {
UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7],TRUE);
CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]);
fpuLoadReg(&StackTopPos(),StackPosition(RegToLoad));
FpuRoundingModel(StackTopPos()) = RoundDefault;
FpuMappedTo(StackTopPos()) = Reg;
FpuState(StackTopPos()) = Format;
FpuRoundingModel(StackTopPos()) = RoundDefault;
x86fpu_MappedTo[StackTopPos()] = Reg;
x86fpu_State[StackTopPos()] = Format;
x86fpu_StateChanged[StackTopPos()] = false;
} else {
UnMap_FPR(FpuMappedTo((StackTopPos() - 1) & 7),TRUE);
UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7],TRUE);
Load_FPR_ToTop (Reg, RegToLoad, Format);
}
} else {
@ -179,7 +182,7 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
DWORD i;
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) == (DWORD)Reg) {
if (x86fpu_MappedTo[i] == (DWORD)Reg) {
RegPos = (x86FpuValues)i;
i = 8;
}
@ -191,24 +194,26 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
StackPos = StackPosition(Reg);
FpuRoundingModel(RegPos) = FpuRoundingModel(StackTopPos());
FpuMappedTo(RegPos) = FpuMappedTo(StackTopPos());
FpuState(RegPos) = FpuState(StackTopPos());
CPU_Message(" regcache: allocate ST(%d) to %s", StackPos,CRegName::FPR[FpuMappedTo(RegPos)]);
x86fpu_MappedTo[RegPos] = x86fpu_MappedTo[StackTopPos()];
x86fpu_State[RegPos] = x86fpu_State[StackTopPos()];
x86fpu_StateChanged[RegPos] = x86fpu_StateChanged[StackTopPos()];
CPU_Message(" regcache: allocate ST(%d) to %s", StackPos,CRegName::FPR[x86fpu_MappedTo[RegPos]]);
CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]);
fpuExchange(StackPos);
FpuRoundingModel(StackTopPos()) = RoundDefault;
FpuMappedTo(StackTopPos()) = Reg;
FpuState(StackTopPos()) = Format;
x86fpu_MappedTo[StackTopPos()] = Reg;
x86fpu_State[StackTopPos()] = Format;
x86fpu_StateChanged[StackTopPos()] = false;
}
} else {
char Name[50];
x86Reg TempReg;
UnMap_FPR(FpuMappedTo((StackTopPos() - 1) & 7),TRUE);
UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7],TRUE);
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) == (DWORD)RegToLoad) {
if (x86fpu_MappedTo[i] == (DWORD)RegToLoad) {
UnMap_FPR(RegToLoad,TRUE);
i = 8;
}
@ -243,8 +248,9 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format)
}
x86Protected(TempReg) = FALSE;
FpuRoundingModel(StackTopPos()) = RoundDefault;
FpuMappedTo(StackTopPos()) = Reg;
FpuState(StackTopPos()) = Format;
x86fpu_MappedTo[StackTopPos()] = Reg;
x86fpu_State[StackTopPos()] = Format;
x86fpu_StateChanged[StackTopPos()] = false;
}
}
@ -253,7 +259,7 @@ CRegInfo::x86FpuValues CRegInfo::StackPosition (int Reg)
int i;
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) == (DWORD)Reg) {
if (x86fpu_MappedTo[i] == (DWORD)Reg) {
return (x86FpuValues)((i - StackTopPos()) & 7);
}
}
@ -698,9 +704,9 @@ BOOL CRegInfo::RegInStack( int Reg, FPU_STATE Format) {
for (i = 0; i < 8; i++)
{
if (FpuMappedTo(i) == (DWORD)Reg)
if (x86fpu_MappedTo[i] == (DWORD)Reg)
{
if (FpuState(i) == Format || Format == FPU_Any)
if (x86fpu_State[i] == Format || Format == FPU_Any)
{
return TRUE;
}
@ -717,14 +723,14 @@ void CRegInfo::UnMap_AllFPRs ( void )
for (;;) {
int i, StartPos;
StackPos = StackTopPos();
if (FpuMappedTo(StackTopPos()) != -1 ) {
UnMap_FPR(FpuMappedTo(StackTopPos()),TRUE);
if (x86fpu_MappedTo[StackTopPos()] != -1 ) {
UnMap_FPR(x86fpu_MappedTo[StackTopPos()],TRUE);
continue;
}
//see if any more registers mapped
StartPos = StackTopPos();
for (i = 0; i < 8; i++) {
if (FpuMappedTo((StartPos + i) & 7) != -1 ) { fpuIncStack(&StackTopPos()); }
if (x86fpu_MappedTo[(StartPos + i) & 7] != -1 ) { fpuIncStack(&StackTopPos()); }
}
if (StackPos != StackTopPos()) { continue; }
return;
@ -738,63 +744,74 @@ void CRegInfo::UnMap_FPR (int Reg, int WriteBackValue )
if (Reg < 0) { return; }
for (i = 0; i < 8; i++) {
if (FpuMappedTo(i) != (DWORD)Reg) { continue; }
if (x86fpu_MappedTo[i] != (DWORD)Reg) { continue; }
CPU_Message(" regcache: unallocate %s from ST(%d)",CRegName::FPR[Reg],(i - StackTopPos() + 8) & 7);
if (WriteBackValue) {
int RegPos;
if (((i - StackTopPos() + 8) & 7) != 0) {
CRegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos());
FPU_STATE RegState = FpuState(StackTopPos());
DWORD MappedTo = FpuMappedTo(StackTopPos());
FpuRoundingModel(StackTopPos()) = FpuRoundingModel(i);
FpuMappedTo(StackTopPos()) = FpuMappedTo(i);
FpuState(StackTopPos()) = FpuState(i);
FpuRoundingModel(i) = RoundingModel;
FpuMappedTo(i) = MappedTo;
FpuState(i) = RegState;
fpuExchange((x86FpuValues)((i - StackTopPos()) & 7));
if (((i - StackTopPos() + 8) & 7) != 0)
{
if (x86fpu_MappedTo[StackTopPos()] == -1 && x86fpu_MappedTo[(StackTopPos() + 1) & 7] == Reg)
{
fpuIncStack(&StackTopPos());
} else {
CRegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos());
FPU_STATE RegState = x86fpu_State[StackTopPos()];
BOOL Changed = x86fpu_StateChanged[StackTopPos()];
DWORD MappedTo = x86fpu_MappedTo[StackTopPos()];
FpuRoundingModel(StackTopPos()) = FpuRoundingModel(i);
x86fpu_MappedTo[StackTopPos()] = x86fpu_MappedTo[i];
x86fpu_State[StackTopPos()] = x86fpu_State[i];
x86fpu_StateChanged[StackTopPos()] = x86fpu_StateChanged[i];
FpuRoundingModel(i) = RoundingModel;
x86fpu_MappedTo[i] = MappedTo;
x86fpu_State[i] = RegState;
x86fpu_StateChanged[i] = Changed;
fpuExchange((x86FpuValues)((i - StackTopPos()) & 7));
}
}
FixRoundModel(FpuRoundingModel(i));
RegPos = StackTopPos();
x86Reg TempReg = Map_TempReg(x86_Any,-1,FALSE);
switch (FpuState(StackTopPos())) {
switch (x86fpu_State[StackTopPos()]) {
case FPU_Dword:
sprintf(Name,"_FPR_S[%d]",FpuMappedTo(StackTopPos()));
MoveVariableToX86reg(&_FPR_S[FpuMappedTo(StackTopPos())],Name,TempReg);
sprintf(Name,"_FPR_S[%d]",x86fpu_MappedTo[StackTopPos()]);
MoveVariableToX86reg(&_FPR_S[x86fpu_MappedTo[StackTopPos()]],Name,TempReg);
fpuStoreIntegerDwordFromX86Reg(&StackTopPos(),TempReg, TRUE);
break;
case FPU_Qword:
sprintf(Name,"_FPR_D[%d]",FpuMappedTo(StackTopPos()));
MoveVariableToX86reg(&_FPR_D[FpuMappedTo(StackTopPos())],Name,TempReg);
sprintf(Name,"_FPR_D[%d]",x86fpu_MappedTo[StackTopPos()]);
MoveVariableToX86reg(&_FPR_D[x86fpu_MappedTo[StackTopPos()]],Name,TempReg);
fpuStoreIntegerQwordFromX86Reg(&StackTopPos(),TempReg, TRUE);
break;
case FPU_Float:
sprintf(Name,"_FPR_S[%d]",FpuMappedTo(StackTopPos()));
MoveVariableToX86reg(&_FPR_S[FpuMappedTo(StackTopPos())],Name,TempReg);
sprintf(Name,"_FPR_S[%d]",x86fpu_MappedTo[StackTopPos()]);
MoveVariableToX86reg(&_FPR_S[x86fpu_MappedTo[StackTopPos()]],Name,TempReg);
fpuStoreDwordFromX86Reg(&StackTopPos(),TempReg, TRUE);
break;
case FPU_Double:
sprintf(Name,"_FPR_D[%d]",FpuMappedTo(StackTopPos()));
MoveVariableToX86reg(&_FPR_D[FpuMappedTo(StackTopPos())],Name,TempReg);
sprintf(Name,"_FPR_D[%d]",x86fpu_MappedTo[StackTopPos()]);
MoveVariableToX86reg(&_FPR_D[x86fpu_MappedTo[StackTopPos()]],Name,TempReg);
fpuStoreQwordFromX86Reg(&StackTopPos(),TempReg, TRUE);
break;
#ifndef EXTERNAL_RELEASE
default:
DisplayError("UnMap_FPR\nUnknown format to load %d",FpuState(StackTopPos()));
DisplayError("UnMap_FPR\nUnknown format to load %d",x86fpu_State[StackTopPos()]);
#endif
}
x86Protected(TempReg) = FALSE;
FpuRoundingModel(RegPos) = RoundDefault;
FpuMappedTo(RegPos) = -1;
FpuState(RegPos) = FPU_Unknown;
x86fpu_MappedTo[RegPos] = -1;
x86fpu_State[RegPos] = FPU_Unknown;
x86fpu_StateChanged[RegPos] = false;
} else {
fpuFree((x86FpuValues)((i - StackTopPos()) & 7));
FpuRoundingModel(i) = RoundDefault;
FpuMappedTo(i) = -1;
FpuState(i) = FPU_Unknown;
x86fpu_MappedTo[i] = -1;
x86fpu_State[i] = FPU_Unknown;
x86fpu_StateChanged[i] = false;
}
return;
}
@ -933,6 +950,8 @@ bool CRegInfo::UnMap_X86reg ( CX86Ops::x86Reg Reg )
void CRegInfo::WriteBackRegisters (void)
{
UnMap_AllFPRs();
int count;
BOOL bEdiZero = FALSE;
BOOL bEsiSign = FALSE;
@ -1007,7 +1026,6 @@ void CRegInfo::WriteBackRegisters (void)
#endif
}
}
UnMap_AllFPRs();
}
const char * CRegInfo::RoundingModelName ( FPU_ROUND RoundType )

View File

@ -142,6 +142,7 @@ private:
int Stack_TopPos;
DWORD x86fpu_MappedTo[8];
FPU_STATE x86fpu_State[8];
BOOL x86fpu_StateChanged[8];
FPU_ROUND x86fpu_RoundingModel[8];
bool Fpu_Used;

View File

@ -146,6 +146,12 @@ void CX86Ops::BreakPointNotification (const char * const FileName, const int Lin
_Notify->BreakPoint(FileName,LineNumber);
}
void CX86Ops::X86HardBreakPoint (void)
{
CPU_Message(" int 3");
PUTDST8(m_RecompPos,0xCC);
}
void CX86Ops::X86BreakPoint (LPCSTR FileName, int LineNumber)
{
Pushad();

View File

@ -63,6 +63,7 @@ protected:
static void AndVariableToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg );
static void AndVariableDispToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, Multipler Multiply);
static void AndX86RegToX86Reg ( x86Reg Destination, x86Reg Source );
static void X86HardBreakPoint ( void );
static void X86BreakPoint ( LPCSTR FileName, int LineNumber );
static void Call_Direct ( void * FunctAddress, const char * FunctName );
static void Call_Indirect ( void * FunctAddress, const char * FunctName );

View File

@ -1,5 +1,4 @@
#ifndef __PLUGIN__H__
#define __PLUGIN__H__
#pragma once
#include "Support.h"
@ -10,4 +9,5 @@
#include ".\\Plugins\\RSP Plugin.h"
#include ".\\Plugins\\Plugin List.h"
#endif

View File

@ -259,14 +259,13 @@ void CAudioPlugin::UnloadPlugin(void) {
ProcessAList = NULL;
RomClosed = NULL;
CloseDLL = NULL;
m_CountsPerByte = 100;
}
void CAudioPlugin::DacrateChanged (SystemType Type) {
void CAudioPlugin::DacrateChanged (SystemType Type)
{
if (!Initilized()) { return; }
DWORD Frequency = _Reg->AI_DACRATE_REG * 66;
DWORD Frequency = _Reg->AI_DACRATE_REG * 30;
DWORD CountsPerSecond = (_Reg->VI_V_SYNC_REG != 0 ? (_Reg->VI_V_SYNC_REG + 1) * _Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60;
m_CountsPerByte = (double)CountsPerSecond / (double)Frequency;
m_DacrateChanged(Type);
}

View File

@ -5,7 +5,6 @@ class CAudioPlugin {
PLUGIN_INFO m_PluginInfo;
DWORD m_StatusReg;
DWORD m_CountsPerByte;
void UnloadPlugin ( void );
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
@ -34,7 +33,6 @@ public:
stdstr PluginName ( void ) const { return m_PluginInfo.Name; }
inline bool Initilized ( void ) const { return m_Initilized; }
inline DWORD CountsPerByte ( void ) const { return m_CountsPerByte; }
void (__cdecl *LenChanged) ( void );
void (__cdecl *Config) ( DWORD hParent );

View File

@ -1,7 +1,4 @@
#ifndef __PLUGIN_CLASS__H__
#define __PLUGIN_CLASS__H__
#include "..\N64 System.h"
#pragma once
#include <list>
typedef int BOOL;
@ -67,6 +64,7 @@ enum PLUGIN_TYPE {
};
class CSettings;
class CMainGui;
class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin;
class CPlugins {
@ -117,5 +115,3 @@ public:
void DummyCheckInterrupts ( void );
void DummyFunction (void);
#endif

View File

@ -354,6 +354,10 @@ SOURCE="N64 System\Mips\Audio.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\Eeprom.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Mips\Memory Labels Class.cpp"
# End Source File
# Begin Source File
@ -374,6 +378,10 @@ SOURCE="N64 System\Mips\OpCode Class.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\Pif Ram.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Mips\Register Class.cpp"
# End Source File
# Begin Source File
@ -414,10 +422,6 @@ SOURCE="N64 System\C Core\Dma.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Eeprom.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\FlashRam.cpp"
# End Source File
# Begin Source File
@ -971,6 +975,10 @@ SOURCE="N64 System\Mips\Audio.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\Eeprom.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\Exception.h"
# End Source File
# Begin Source File
@ -999,6 +1007,10 @@ SOURCE="N64 System\Mips\OpCode.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\Pif Ram.h"
# End Source File
# Begin Source File
SOURCE="N64 System\Mips\Register Class.h"
# End Source File
# Begin Source File

View File

@ -2,21 +2,6 @@
#include "SettingType/SettingsType-Base.h"
/*#ifndef __SETTINGS_CLASS__H__
#define __SETTINGS_CLASS__H__
#pragma warning(disable:4786)
#include "..\Settings.h"
#include "..\Support.h"
#include <string>
#include <map> //stl map
typedef unsigned long DWORD;
typedef const char * LPCSTR;
*/
enum SettingDataType {
Data_DWORD = 0,
Data_String = 1,
@ -26,170 +11,6 @@ enum SettingDataType {
Data_YesNo = 5,
Data_SaveChip = 6
};
/*
class CSettingInfo {
public:
CSettingInfo ( void ) {
this->Type = No_Default;
this->DefaultValue = No_Default;
this->StartOfRange = No_Default;
this->DataType = Data_DWORD;
this->Location = ConstValue;
this->Name = "";
this->SubNode = "";
this->Value = 0;
}
CSettingInfo ( SettingID Type, SettingID DefaultValue, SettingDataType DataType,
SettingLocation Location, LPCSTR Name, LPCSTR SubNode = NULL, DWORD Value = 0, SettingID StartOfRange = No_Default )
{
this->Type = Type;
this->DefaultValue = DefaultValue;
this->DataType = DataType;
this->Location = Location;
this->Name = Name;
this->SubNode = SubNode;
this->Value = Value;
if (StartOfRange == No_Default) {
this->StartOfRange = Type;
} else {
this->StartOfRange = StartOfRange;
}
}
SettingID Type;
SettingID DefaultValue;
SettingID StartOfRange;
SettingDataType DataType;
SettingLocation Location;
stdstr Name; //if in the registry this it the Registry key name
stdstr SubNode;
DWORD Value;
};
class CN64System;
class CMainGui;
typedef std::map<SettingID, CSettingInfo> SETTING_MAP;
class CTempInfo {
public:
SettingID Type;
SettingDataType DataType;
char * String;
DWORD Value;
CTempInfo ( CTempInfo const &b ) {
this->Type = b.Type;
this->DataType = b.DataType;
this->Value = b.Value;
this->String = NULL;
if (b.DataType == Data_String && b.String != NULL) {
this->String = new char [(strlen(b.String) + 1)];
strcpy(this->String,b.String);
}
}
CTempInfo ( SettingID Type, const char * String ) {
this->Type = Type;
this->DataType = Data_String;
this->String = new char [(strlen(String) + 1)];
strcpy(this->String,String);
this->Value = 0;
}
CTempInfo ( SettingID Type, DWORD Value ) {
this->Type = Type;
this->DataType = Data_DWORD;
this->String = 0;
this->Value = Value;
}
~CTempInfo ( void ) {
if (DataType == Data_String && String != NULL) {
delete [] String;
}
}
};
typedef std::map<SettingID, CTempInfo> TEMP_SETTING_MAP;
class CNotification;
class CriticalSection;
class CSettings {
public:
typedef void (* SettingChangedFunc)(void *);
private:
char Registrylocation[255];
int RegistryKey;
typedef struct {
SettingID Type;
void * Data;
SettingChangedFunc Func;
} SETTING_CHANGED_CB;
typedef std::list<SETTING_CHANGED_CB> SETTING_CHANGED_CB_LIST;
SETTING_MAP SettingInfo;
TEMP_SETTING_MAP TempKeys;
CIniFile * RomIniFile;
CIniFile * CheatIniFile;
CIniFile * SettingsIniFile;
CriticalSection m_CS;
SETTING_CHANGED_CB_LIST m_CBDwordList;
void AddHowToHandleSetting (void);
static void DisplayConfigWindow (CSettings * _this);
void UnknownSetting (SettingID Type);
public:
CSettings(void);
~CSettings(void);
bool Initilize ( const char * AppName );
void Config (void * ParentWindow, CN64System * System, CMainGui * Gui);
void ConfigRom (void * ParentWindow, CMainGui * Gui);
//Load a DWORD value from the settings, if value is not in settings then the passed
//DWORD is unchanged.
void Load(SettingID Type, DWORD & Value);
void Load(SettingID Type, char * Buffer, int BufferSize);
//return the values
bool LoadBool ( SettingID Type );
DWORD LoadDword ( SettingID Type );
stdstr LoadString ( SettingID Type );
//Update the settings
void SaveBool ( SettingID Type, bool Value );
void SaveDword ( SettingID Type, DWORD Value );
void SaveString ( SettingID Type, const char * Buffer );
// static functions for plugins
static DWORD GetSetting ( CSettings * _this, SettingID Type );
static LPCSTR GetSettingSz ( CSettings * _this, SettingID Type, char * Buffer, int BufferSize );
static void SetSetting ( CSettings * _this, SettingID ID, unsigned int Value );
static void SetSettingSz ( CSettings * _this, SettingID ID, const char * Value );
static void RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType Type,
SettingLocation Location, const char * Category, const char * DefaultStr,
DWORD Value );
// plugin call backs
void (*UnknownSetting_RSP) ( int ID );
void (*UnknownSetting_GFX) ( int ID );
void (*UnknownSetting_AUDIO) ( int ID );
void (*UnknownSetting_CTRL) ( int ID );
//Register Notification of change
void RegisterChangeCB(SettingID Type,void * Data, SettingChangedFunc Func);
void UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFunc Func);
};
extern CSettings * _Settings;
#endif*/
class CSettings {
public:

View File

@ -351,13 +351,7 @@ void CMainGui::Show (bool Visible) {
void CMainGui::EnterLogOptions (void)
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifndef EXTERNAL_RELEASE
#ifdef tofix
g_Settings = _Settings;
::EnterLogOptions((HWND)m_hMainWindow);
#endif
#endif
}
int CMainGui::Height (void) {