Merge remote-tracking branch 'project64/master'

This commit is contained in:
Samuel Yuan 2015-04-04 19:53:18 -04:00
commit bd275ae9e5
41 changed files with 4261 additions and 1571 deletions

View File

@ -177,7 +177,7 @@
#320# "ロムディレクトリを選択して下さい"
//Messages
#340# "不明なロム? GoodN64を使用するかINIファイルをアップデートして下さい"
#340# "不明なロム? GoodN64を使用するかRDBファイルをアップデートして下さい"
/*********************************************************************************
* Options *
@ -233,9 +233,9 @@
#466# "表示形式によってフレームレートを変更する:"
//ROM Browser Tab
#480# "最近開いたロムファイルの表示する数最大10:"
#480# "最近開いたロムファイルの表示する数(010):"
#481# "個"
#482# "最近開いたロムフォルダの表示する数最大10:"
#482# "最近開いたロムフォルダの表示する数(010):"
#483# "個"
#484# "ロムブラウザを使用する(&U)"
#485# "サブフォルダも検索(&S)"
@ -282,6 +282,9 @@
#534# "関数検索方法:"
#535# "カスタム自己書換方法"
#536# "オーディオに同期"
#537# "AIカウント/バイト"
#538# "32bitエンジン"
#539# "DP割り込み遅延"
//Core Styles
#540# "インタプリタ"
@ -348,6 +351,11 @@
#710# "スピードを上げる"
#711# "スピードを下げる"
//Bottom page buttons
#720# "この項目のリセット"
#721# "すべてリセット"
#722# "適用"
/*********************************************************************************
* ROM Information *
*********************************************************************************/
@ -359,7 +367,7 @@
#802# "ファイル名:"
#803# "保存場所:"
#804# "ロムサイズ:"
#805# "カートリッジID:"
#805# "カートリッジID:"
#806# "製造元:"
#807# "国情報:"
#808# "CRC1:"

View File

@ -535,7 +535,10 @@ void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
//Process the file
FILE *file = fopen(Filename.c_str(), "rb");
if (file == NULL) { return; }
if (file == NULL)
{
return;
}
//Search for utf8 file marker
BYTE utf_bom[3];
@ -549,7 +552,7 @@ void CLanguage::LoadCurrentStrings ( bool ShowSelectDialog )
}
//String;
while(!feof(file))
while (!feof(file))
{
m_CurrentStrings.insert(GetNextLangString(file));
}
@ -564,7 +567,8 @@ DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lPar
static bool m_fPressed = false;
static HBITMAP hOkButtonDown = NULL;
switch (uMsg) {
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
@ -590,7 +594,9 @@ DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lPar
SelectObject(memdc, save);
DeleteDC(memdc);
}
} else {
}
else
{
if (hOkButton)
{
RECT rcClient;
@ -610,14 +616,14 @@ DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lPar
}
break;
case WM_MOUSEMOVE:
if(::GetCapture() == hWnd)
if (::GetCapture() == hWnd)
{
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
ClientToScreen(hWnd, &ptCursor);
RECT rect;
GetWindowRect(hWnd, &rect);
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
if( m_fPressed != uPressed )
if ( m_fPressed != uPressed )
{
m_fPressed = uPressed;
::InvalidateRect(hWnd, NULL, TRUE);
@ -630,7 +636,7 @@ DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lPar
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
SetCapture(hWnd);
if( ::GetCapture()==hWnd )
if ( ::GetCapture()==hWnd )
{
m_fPressed = true;
@ -647,10 +653,10 @@ DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lPar
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
if(::GetCapture() == hWnd )
if ( ::GetCapture() == hWnd )
{
::ReleaseCapture();
if( m_fPressed )
if ( m_fPressed )
{
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
}
@ -673,14 +679,18 @@ LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
static HFONT hTextFont = NULL;
static CLanguage * lngClass;
switch (uMsg) {
switch (uMsg)
{
case WM_INITDIALOG:
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
{
lngClass = (CLanguage *)lParam;
LanguageList LangList = lngClass->GetLangList();
if (LangList.size() == 0) { EndDialog(hDlg,0); }
if (LangList.size() == 0)
{
EndDialog(hDlg,0);
}
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
{
int index = SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_ADDSTRING,0,(WPARAM)Language->LanguageName.c_str());
@ -690,10 +700,11 @@ LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
}
int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0);
if (Index < 0) { SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0); }
if (Index < 0)
{
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0);
}
enum { ROUND_EDGE = 15 };
@ -842,7 +853,8 @@ LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
switch (LOWORD(wParam))
{
case IDOK:
if (hbmpBackgroundTop)
{
@ -934,7 +946,10 @@ const std::wstring & CLanguage::GetString (LanguageStringID StringID)
std::wstring CLanguage::GetLangString ( const char * FileName, LanguageStringID ID )
{
FILE *file = fopen(FileName, "rb");
if (file == NULL) { return L""; }
if (file == NULL)
{
return L"";
}
//Search for utf8 file marker
BYTE utf_bom[3];
@ -947,7 +962,7 @@ std::wstring CLanguage::GetLangString ( const char * FileName, LanguageStringID
}
//String;
while(!feof(file))
while (!feof(file))
{
LANG_STR String = GetNextLangString(file);
if (String.first == ID)
@ -969,31 +984,55 @@ LANG_STR CLanguage::GetNextLangString (void * OpenFile)
FILE * file = (FILE *)OpenFile;
//while(token!='#' && !feof(file)) { fread(&token, 1, 1, file); }
if(feof(file)){ return LANG_STR(0,L""); }
if (feof(file))
{
return LANG_STR(0,L"");
}
//Search for token #
char token=0;
while(token!='#' && !feof(file)) { fread(&token, 1, 1, file); }
if(feof(file)){ return LANG_STR(0,L""); }
while (token!='#' && !feof(file))
{
fread(&token, 1, 1, file);
}
if (feof(file))
{
return LANG_STR(0,L"");
}
//get StringID after token
fscanf(file, "%d", &StringID);
//Search for token #
while(token!='#' && !feof(file)) { fread(&token, 1, 1, file); }
if(feof(file)){ StringID = EMPTY_STRING; return LANG_STR(0,L""); }
while(token!='#' && !feof(file))
{
fread(&token, 1, 1, file);
}
if (feof(file))
{
StringID = EMPTY_STRING; return LANG_STR(0,L"");
}
//Search for start of string '"'
while(token!='"' && !feof(file)) { fread(&token, 1, 1, file); }
if(feof(file)){ StringID = EMPTY_STRING; return LANG_STR(0,L""); }
while (token!='"' && !feof(file))
{
fread(&token, 1, 1, file);
}
if (feof(file))
{
StringID = EMPTY_STRING; return LANG_STR(0,L"");
}
int pos = 0;
fread(&token, 1, 1, file);
while(token!='"' && !feof(file))
while (token!='"' && !feof(file))
{
szString[pos++] = token;
fread(&token, 1, 1, file);
if (pos == MAX_STRING_LEN - 2) { token = '"'; }
if (pos == MAX_STRING_LEN - 2)
{
token = '"';
}
}
szString[pos++] = 0;
stdstr text(szString);

View File

@ -20,7 +20,8 @@
typedef std::map<int, std::wstring, std::less<int> > LANG_STRINGS;
typedef LANG_STRINGS::value_type LANG_STR;
typedef struct {
typedef struct
{
stdstr Filename;
std::wstring LanguageName;
} LanguageFile;

View File

@ -20,7 +20,8 @@ LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
LOG_OPTIONS LogOptions,TempOptions;
HANDLE hLogFile = NULL;
void EnterLogOptions(HWND hwndOwner) {
void EnterLogOptions(HWND hwndOwner)
{
PROPSHEETPAGE psp[3];
PROPSHEETHEADER psh;
@ -68,7 +69,8 @@ void EnterLogOptions(HWND hwndOwner) {
return;
}
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) {
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
{
long lResult;
HKEY hKeyResults = 0;
char String[200];
@ -77,9 +79,11 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) {
lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS,
&hKeyResults);
if (lResult == ERROR_SUCCESS) {
if (lResult == ERROR_SUCCESS)
{
//LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog);
if (LogOptions->GenerateLog || AlwaysFill) {
if (LogOptions->GenerateLog || AlwaysFill)
{
LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters);
LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters);
LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters);
@ -137,20 +141,26 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) {
LogOptions->LogUnknown = FALSE;
}
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value) {
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value)
{
DWORD Type, dwResult, Bytes = 4;
long lResult;
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes);
if (Type == REG_DWORD && lResult == ERROR_SUCCESS) {
if (Type == REG_DWORD && lResult == ERROR_SUCCESS)
{
*Value = (BOOL)dwResult;
} else {
}
else
{
*Value = FALSE;
}
}
LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) {
switch (uMsg) {
LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); }
if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg,IDC_CP0_READ,BST_CHECKED); }
@ -178,8 +188,12 @@ LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM
return TRUE;
}
void Log_LW (DWORD PC, DWORD VAddr) {
if (!LogOptions.GenerateLog) { return; }
void Log_LW (DWORD PC, DWORD VAddr)
{
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
@ -196,12 +210,20 @@ void Log_LW (DWORD PC, DWORD VAddr) {
}
DWORD Value;
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) { return; }
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) {
if (!LogOptions.LogRDRamRegisters) { return; }
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!LogOptions.LogRDRamRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return;
case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return;
case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return;
@ -215,12 +237,20 @@ void Log_LW (DWORD PC, DWORD VAddr) {
}
}
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) { return; }
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) {
if (!LogOptions.LogSPRegisters) { return; }
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC )
{
return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
{
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break;
@ -232,17 +262,26 @@ void Log_LW (DWORD PC, DWORD VAddr) {
}
return;
}
if ( VAddr == 0xA4080000) {
if (!LogOptions.LogSPRegisters) { return; }
if ( VAddr == 0xA4080000)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return;
}
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) {
if (!LogOptions.LogDPCRegisters) { return; }
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!LogOptions.LogDPCRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return;
case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return;
case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return;
@ -253,22 +292,32 @@ void Log_LW (DWORD PC, DWORD VAddr) {
case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) {
if (!LogOptions.LogMIPSInterface) { return; }
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!LogOptions.LogMIPSInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return;
case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return;
case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return;
case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) {
if (!LogOptions.LogVideoInterface) { return; }
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!LogOptions.LogVideoInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return;
case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return;
@ -285,11 +334,16 @@ void Log_LW (DWORD PC, DWORD VAddr) {
case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) {
if (!LogOptions.LogAudioInterface) { return; }
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{
if (!LogOptions.LogAudioInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return;
case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return;
@ -298,11 +352,16 @@ void Log_LW (DWORD PC, DWORD VAddr) {
case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) {
if (!LogOptions.LogPerInterface) { return; }
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!LogOptions.LogPerInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return;
@ -318,11 +377,16 @@ void Log_LW (DWORD PC, DWORD VAddr) {
case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) {
if (!LogOptions.LogRDRAMInterface) { return; }
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{
if (!LogOptions.LogRDRAMInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return;
case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return;
case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return;
@ -333,43 +397,74 @@ void Log_LW (DWORD PC, DWORD VAddr) {
case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return;
}
}
if ( VAddr == 0xA4800000) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800000)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800004) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800004)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800010) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800010)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800018) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800018)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return;
}
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) { return; }
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) {
if (!LogOptions.LogPRDirectMemLoads) { return; }
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 )
{
return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!LogOptions.LogPRDirectMemLoads)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return;
}
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) { return; }
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) {
if (!LogOptions.LogRomHeader) { return; }
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize()))
{
return;
}
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
{
if (!LogOptions.LogRomHeader)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) {
switch (VAddr)
{
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break;
case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break;
case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break;
@ -379,17 +474,27 @@ void Log_LW (DWORD PC, DWORD VAddr) {
}
return;
}
if (!LogOptions.LogUnknown) { return; }
if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
}
void __cdecl LogMessage (char * Message, ...) {
void __cdecl LogMessage (char * Message, ...)
{
DWORD dwWritten;
char Msg[400];
va_list ap;
if(!g_Settings->LoadBool(Debugger_Enabled)) { return; }
if(hLogFile == NULL) { return; }
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
if (hLogFile == NULL)
{
return;
}
va_start( ap, Message );
vsprintf( Msg, Message, ap );
@ -400,8 +505,12 @@ void __cdecl LogMessage (char * Message, ...) {
WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
if (!LogOptions.GenerateLog) { return; }
void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
{
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
@ -417,10 +526,18 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
VAddr = PAddr + 0xA0000000;
}
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) { return; }
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) {
if (!LogOptions.LogRDRamRegisters) { return; }
switch (VAddr) {
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!LogOptions.LogRDRamRegisters)
{
return;
}
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return;
case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return;
case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return;
@ -433,11 +550,19 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) { return; }
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC )
{
return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C) {
if (!LogOptions.LogSPRegisters) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return;
case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return;
@ -448,14 +573,23 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4080000) {
if (!LogOptions.LogSPRegisters) { return; }
if ( VAddr == 0xA4080000)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return;
}
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) {
if (!LogOptions.LogDPCRegisters) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!LogOptions.LogDPCRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return;
case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return;
case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return;
@ -467,9 +601,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
}
}
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C) {
if (!LogOptions.LogDPSRegisters) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
{
if (!LogOptions.LogDPSRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return;
case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return;
case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return;
@ -477,18 +616,28 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
}
}
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C) {
if (!LogOptions.LogMIPSInterface) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!LogOptions.LogMIPSInterface)
{
return;
}
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return;
case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return;
case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return;
case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) {
if (!LogOptions.LogVideoInterface) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!LogOptions.LogVideoInterface)
{
return;
}
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return;
case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return;
@ -506,9 +655,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
}
}
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014) {
if (!LogOptions.LogAudioInterface) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{
if (!LogOptions.LogAudioInterface)
{
return;
}
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return;
case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return;
@ -518,9 +672,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
}
}
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030) {
if (!LogOptions.LogPerInterface) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!LogOptions.LogPerInterface)
{
return;
}
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return;
case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return;
@ -536,9 +695,14 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) {
if (!LogOptions.LogRDRAMInterface) { return; }
switch (VAddr) {
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
{
if (!LogOptions.LogRDRAMInterface)
{
return;
}
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return;
case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return;
case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return;
@ -549,40 +713,67 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4800000) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800000)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800004) {
if (LogOptions.LogPRDMAOperations) {
if ( VAddr == 0xA4800004)
{
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC );
}
if (!LogOptions.LogSerialInterface) { return; }
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800010) {
if (LogOptions.LogPRDMAOperations) {
if ( VAddr == 0xA4800010)
{
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC );
}
if (!LogOptions.LogSerialInterface) { return; }
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800018) {
if (!LogOptions.LogSerialInterface) { return; }
if ( VAddr == 0xA4800018)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) {
if (!LogOptions.LogPRDirectMemStores) { return; }
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!LogOptions.LogPRDirectMemStores)
{
return;
}
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
return;
}
if (!LogOptions.LogUnknown) { return; }
if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr );
}
LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) {
switch (uMsg) {
LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); }
if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg,IDC_DIRECT_WRITE,BST_CHECKED); }
@ -592,7 +783,10 @@ LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPa
if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg,IDC_CONT_PAK,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; }
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg,IDC_SI_DMA) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg,IDC_DIRECT_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg,IDC_DMA_WRITE) == BST_CHECKED?TRUE:FALSE;
@ -606,8 +800,10 @@ LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPa
return TRUE;
}
LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) {
switch (uMsg) {
LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); }
if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg,IDC_SP_REG,BST_CHECKED); }
@ -621,7 +817,10 @@ LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPa
if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg,IDC_SI_REG,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; }
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg,IDC_RDRAM) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg,IDC_SP_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg,IDC_DPC_REG) == BST_CHECKED?TRUE:FALSE;
@ -639,12 +838,14 @@ LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPa
return TRUE;
}
void SaveLogSetting (HKEY hKey,char * String, BOOL Value) {
void SaveLogSetting (HKEY hKey,char * String, BOOL Value)
{
DWORD StoreValue = Value;
RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD));
}
void SaveLogOptions (void) {
void SaveLogOptions (void)
{
long lResult;
HKEY hKeyResults = 0;
DWORD Disposition = 0;
@ -684,11 +885,15 @@ void SaveLogOptions (void) {
void StartLog (void)
{
if (!LogOptions.GenerateLog) {
if (!LogOptions.GenerateLog)
{
StopLog();
return;
}
if (hLogFile) { return; }
if (hLogFile)
{
return;
}
CPath LogFile(CPath::MODULE_DIRECTORY);
LogFile.AppendDirectory(_T("Logs"));
@ -699,8 +904,10 @@ void StartLog (void)
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
}
void StopLog (void) {
if (hLogFile) {
void StopLog (void)
{
if (hLogFile)
{
CloseHandle(hLogFile);
}
hLogFile = NULL;

View File

@ -13,7 +13,8 @@
extern "C" {
#endif
typedef struct {
typedef struct
{
BOOL GenerateLog;
/* Registers Log */

View File

@ -16,32 +16,41 @@
BOOL InR4300iCommandsWindow = FALSE;
char CommandName[100];
void SetR4300iCommandToStepping ( void ) {
void SetR4300iCommandToStepping ( void )
{
}
void SetR4300iCommandViewto ( UINT /*NewLocation*/ ) {
void SetR4300iCommandViewto ( UINT /*NewLocation*/ )
{
}
void __cdecl Enter_R4300i_Commands_Window ( void ) {
void __cdecl Enter_R4300i_Commands_Window ( void )
{
}
char strLabelName[100];
char * LabelName (DWORD Address) {
char * LabelName (DWORD Address)
{
sprintf(strLabelName,"0x%08X",Address);
return strLabelName;
}
char * R4300iSpecialName ( DWORD OpCode, DWORD /*PC*/ ) {
char * R4300iSpecialName ( DWORD OpCode, DWORD /*PC*/ )
{
OPCODE command;
command.Hex = OpCode;
switch (command.funct) {
switch (command.funct)
{
case R4300i_SPECIAL_SLL:
if (command.Hex != 0) {
if (command.Hex != 0)
{
sprintf(CommandName,"sll\t%s, %s, 0x%X",CRegName::GPR[command.rd],
CRegName::GPR[command.rt], command.sa);
} else {
}
else
{
sprintf(CommandName,"nop");
}
break;
@ -230,18 +239,22 @@ char * R4300iSpecialName ( DWORD OpCode, DWORD /*PC*/ ) {
return CommandName;
}
char * R4300iRegImmName ( DWORD OpCode, DWORD PC ) {
char * R4300iRegImmName ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
switch (command.rt) {
switch (command.rt)
{
case R4300i_REGIMM_BLTZ:
sprintf(CommandName,"bltz\t%s, %s",CRegName::GPR[command.rs], LabelName(PC + ((short)command.offset << 2) + 4));
break;
case R4300i_REGIMM_BGEZ:
if (command.rs == 0) {
if (command.rs == 0)
{
sprintf(CommandName,"b\t%s", LabelName(PC + ((short)command.offset << 2) + 4));
} else {
} else
{
sprintf(CommandName,"bgez\t%s, %s",CRegName::GPR[command.rs], LabelName(PC + ((short)command.offset << 2) + 4));
}
break;
@ -273,9 +286,12 @@ char * R4300iRegImmName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"bltzal\t%s, %s",CRegName::GPR[command.rs], LabelName(PC + ((short)command.offset << 2) + 4));
break;
case R4300i_REGIMM_BGEZAL:
if (command.rs == 0) {
if (command.rs == 0)
{
sprintf(CommandName,"bal\t%s",LabelName(PC + ((short)command.offset << 2) + 4));
} else {
}
else
{
sprintf(CommandName,"bgezal\t%s, %s",CRegName::GPR[command.rs], LabelName(PC + ((short)command.offset << 2) + 4));
}
break;
@ -292,11 +308,13 @@ char * R4300iRegImmName ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * R4300iCop1Name ( DWORD OpCode, DWORD PC ) {
char * R4300iCop1Name ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
switch (command.fmt) {
switch (command.fmt)
{
case R4300i_COP1_MF:
sprintf(CommandName,"mfc1\t%s, %s",CRegName::GPR[command.rt], CRegName::FPR[command.fs]);
break;
@ -316,7 +334,8 @@ char * R4300iCop1Name ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"ctc1\t%s, %s",CRegName::GPR[command.rt], CRegName::FPR_Ctrl[command.fs]);
break;
case R4300i_COP1_BC:
switch (command.ft) {
switch (command.ft)
{
case R4300i_COP1_BC_BCF:
sprintf(CommandName,"BC1F\t%s", LabelName(PC + ((short)command.offset << 2) + 4));
break;
@ -338,7 +357,8 @@ char * R4300iCop1Name ( DWORD OpCode, DWORD PC ) {
case R4300i_COP1_D:
case R4300i_COP1_W:
case R4300i_COP1_L:
switch (command.funct) {
switch (command.funct)
{
case R4300i_COP1_FUNCT_ADD:
sprintf(CommandName,"ADD.%s\t%s, %s, %s",FPR_Type(command.fmt),
CRegName::FPR[command.fd], CRegName::FPR[command.fs],
@ -499,11 +519,13 @@ char * R4300iCop1Name ( DWORD OpCode, DWORD PC ) {
return CommandName;
}
char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
char * R4300iOpcodeName ( DWORD OpCode, DWORD PC )
{
OPCODE command;
command.Hex = OpCode;
switch (command.op) {
switch (command.op)
{
case R4300i_SPECIAL:
return R4300iSpecialName ( OpCode, PC );
break;
@ -517,21 +539,29 @@ char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"jal\t%s",LabelName((PC & 0xF0000000) + (command.target << 2)));
break;
case R4300i_BEQ:
if (command.rs == 0 && command.rt == 0) {
if (command.rs == 0 && command.rt == 0)
{
sprintf(CommandName,"b\t%s", LabelName(PC + ((short)command.offset << 2) + 4));
} else if (command.rs == 0 || command.rt == 0) {
}
else if (command.rs == 0 || command.rt == 0)
{
sprintf(CommandName,"beqz\t%s, %s", CRegName::GPR[command.rs == 0 ? command.rt : command.rs ],
LabelName(PC + ((short)command.offset << 2) + 4));
} else {
}
else
{
sprintf(CommandName,"beq\t%s, %s, %s", CRegName::GPR[command.rs], CRegName::GPR[command.rt],
LabelName(PC + ((short)command.offset << 2) + 4));
}
break;
case R4300i_BNE:
if ((command.rs == 0) ^ (command.rt == 0)){
if ((command.rs == 0) ^ (command.rt == 0))
{
sprintf(CommandName,"bnez\t%s, %s", CRegName::GPR[command.rs == 0 ? command.rt : command.rs ],
LabelName(PC + ((short)command.offset << 2) + 4));
} else {
}
else
{
sprintf(CommandName,"bne\t%s, %s, %s", CRegName::GPR[command.rs], CRegName::GPR[command.rt],
LabelName(PC + ((short)command.offset << 2) + 4));
}
@ -567,7 +597,8 @@ char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"lui\t%s, 0x%X",CRegName::GPR[command.rt], command.immediate);
break;
case R4300i_CP0:
switch (command.rs) {
switch (command.rs)
{
case R4300i_COP0_MF:
sprintf(CommandName,"mfc0\t%s, %s",CRegName::GPR[command.rt], CRegName::Cop0[command.rd]);
break;
@ -575,8 +606,10 @@ char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"mtc0\t%s, %s",CRegName::GPR[command.rt], CRegName::Cop0[command.rd]);
break;
default:
if ( (command.rs & 0x10 ) != 0 ) {
switch( command.funct ) {
if ( (command.rs & 0x10 ) != 0 )
{
switch ( command.funct )
{
case R4300i_COP0_CO_TLBR: sprintf(CommandName,"tlbr"); break;
case R4300i_COP0_CO_TLBWI: sprintf(CommandName,"tlbwi"); break;
case R4300i_COP0_CO_TLBWR: sprintf(CommandName,"tlbwr"); break;
@ -586,7 +619,9 @@ char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
sprintf(CommandName,"Unknown\t%02X %02X %02X %02X",
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]);
}
} else {
}
else
{
sprintf(CommandName,"Unknown\t%02X %02X %02X %02X",
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]);
}
@ -596,21 +631,29 @@ char * R4300iOpcodeName ( DWORD OpCode, DWORD PC ) {
case R4300i_CP1:
return R4300iCop1Name ( OpCode, PC );
case R4300i_BEQL:
if (command.rs == command.rt) {
if (command.rs == command.rt)
{
sprintf(CommandName,"b\t%s", LabelName(PC + ((short)command.offset << 2) + 4));
} else if ((command.rs == 0) ^ (command.rt == 0)){
}
else if ((command.rs == 0) ^ (command.rt == 0))
{
sprintf(CommandName,"beqzl\t%s, %s", CRegName::GPR[command.rs == 0 ? command.rt : command.rs ],
LabelName(PC + ((short)command.offset << 2) + 4));
} else {
}
else
{
sprintf(CommandName,"beql\t%s, %s, %s", CRegName::GPR[command.rs], CRegName::GPR[command.rt],
LabelName(PC + ((short)command.offset << 2) + 4));
}
break;
case R4300i_BNEL:
if ((command.rs == 0) ^ (command.rt == 0)){
if ((command.rs == 0) ^ (command.rt == 0))
{
sprintf(CommandName,"bnezl\t%s, %s", CRegName::GPR[command.rs == 0 ? command.rt : command.rs ],
LabelName(PC + ((short)command.offset << 2) + 4));
} else {
}
else
{
sprintf(CommandName,"bnel\t%s, %s, %s", CRegName::GPR[command.rs], CRegName::GPR[command.rt],
LabelName(PC + ((short)command.offset << 2) + 4));
}

View File

@ -61,7 +61,9 @@ public:
if (m_hWnd)
{
SetForegroundWindow((HWND)m_hWnd);
} else {
}
else
{
DWORD ThreadID;
ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID);

View File

@ -140,13 +140,19 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) {
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
// Finish = strlen(HexValue);
// if (Finish > 8 ) { Finish = 8; }
// for (Count = 0; Count < Finish; Count++){
// if (Finish > 8 )
// {
// Finish = 8;
// }
// for (Count = 0; Count < Finish; Count++
// {
// Value = (Value << 4);
// switch( HexValue[Count] ) {
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
@ -178,7 +184,8 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
//}
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg) {
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
@ -199,23 +206,39 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) {
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], szTmp2[20];
// DWORD Value;
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop) { Value = Stop; }
// //if (Value < Start) { Value = Start; }
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) {
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; }
// if (_this->SelStop == 0)
// {
// _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop;
// }
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// } else {
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0) { _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; }
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;
@ -348,15 +371,21 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) {
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
//
// Finish = strlen(HexValue);
// if (Finish > 8 ) { Finish = 8; }
// if (Finish > 8 )
// {
// Finish = 8;
// }
//
// for (Count = 0; Count < Finish; Count++){
// for (Count = 0; Count < Finish; Count++)
// {
// Value = (Value << 4);
// switch( HexValue[Count] ) {
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
@ -389,7 +418,8 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
//
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg) {
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
@ -412,7 +442,8 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) {
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// TCHAR szTmp[20], szTmp2[20];
@ -420,17 +451,29 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
//
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop) { Value = Stop; }
// //if (Value < Start) { Value = Start; }
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) {
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; }
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// } else {
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0) { _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; }
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;

View File

@ -226,7 +226,9 @@ void CDebugMemorySearch::EnableUnknownOptions( bool Enable )
{
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
}
} else {
}
else
{
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false );
if (Enable)
{
@ -249,8 +251,14 @@ void CDebugMemorySearch::SearchForValue( void )
m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel());
LPCTSTR DisplayStr = "0x%08X";
if (Size == _16Bit) { DisplayStr = "0x%04X"; }
else if (Size == _8Bit) { DisplayStr = "0x%04X"; }
if (Size == _16Bit)
{
DisplayStr = "0x%04X";
}
else if (Size == _8Bit)
{
DisplayStr = "0x%04X";
}
if (!m_HaveResults)
{
@ -288,7 +296,9 @@ void CDebugMemorySearch::SearchForValue( void )
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false);
} else {
}
else
{
int ItemCount = m_SearchResults.GetItemCount();
for (int i = ItemCount - 1; i >= 0; i--)
{
@ -298,7 +308,8 @@ void CDebugMemorySearch::SearchForValue( void )
DWORD NewValue = 0;
BOOL valid = false;
switch (Size) {
switch (Size)
{
case _8Bit:
{
BYTE mem = 0;
@ -328,7 +339,9 @@ void CDebugMemorySearch::SearchForValue( void )
sprintf(LocationStr,DisplayStr,Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr);
Result.Value = NewValue;
} else {
}
else
{
m_SearchResults.DeleteItem(i);
}
}
@ -351,8 +364,14 @@ void CDebugMemorySearch::SearchForUnknown()
MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel());
m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel());
LPCTSTR DisplayStr = "0x%08X";
if (Size == _16Bit) { DisplayStr = "0x%04X"; }
else if (Size == _8Bit) { DisplayStr = "0x%04X"; }
if (Size == _16Bit)
{
DisplayStr = "0x%04X";
}
else if (Size == _8Bit)
{
DisplayStr = "0x%04X";
}
if (!m_HaveResults)
{
m_HaveResults = true;
@ -411,7 +430,9 @@ void CDebugMemorySearch::SearchForUnknown()
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false);
::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false);
} else {
}
else
{
int ItemCount = m_SearchResults.GetItemCount();
for (int i = ItemCount - 1; i >= 0; i--)
{
@ -422,7 +443,8 @@ void CDebugMemorySearch::SearchForUnknown()
DWORD NewValue = 0;
BOOL valid = false;
switch (Size) {
switch (Size)
{
case _8Bit:
{
BYTE mem = 0;
@ -482,7 +504,9 @@ void CDebugMemorySearch::SearchForUnknown()
sprintf(LocationStr,DisplayStr,Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr);
Result.Value = NewValue;
} else {
}
else
{
m_SearchResults.DeleteItem(i);
}
}
@ -652,8 +676,14 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
return false;
}
if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); }
if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); }
if (Size == _32Bit)
{
StartAddress = ((StartAddress + 3) & ~3);
}
if (Size == _16Bit)
{
StartAddress = ((StartAddress + 1) & ~1);
}
//search memory
if (StartAddress < g_MMU->RdramSize())
@ -757,4 +787,3 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
}
return false;
}

View File

@ -41,7 +41,8 @@ private:
SearchChangeState_Lessthan,
};
typedef struct {
typedef struct
{
DWORD PAddr;
DWORD Value;
} SearchResultItem;

View File

@ -115,7 +115,8 @@ void CDebugTlb::RefreshTLBWindow (void)
int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count ++) {
for (count = 0; count < 32; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
@ -128,66 +129,87 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) {
if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList,&item);
} else {
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (tlb[count].EntryDefined) {
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (tlb[count].EntryDefined) {
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryHi.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (tlb[count].EntryDefined) {
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (tlb[count].EntryDefined) {
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++) {
for (count = 0; count < 64; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
@ -200,49 +222,65 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) {
if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList,&item);
} else {
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (FastTlb[count].ValidEntry) {
if (FastTlb[count].ValidEntry)
{
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}

View File

@ -34,7 +34,8 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
memset(m_CompareValid,0,sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar) {
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
@ -121,7 +122,7 @@ LRESULT CDebugMemoryView::OnDestroy ( void )
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
{
switch(wID)
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
@ -162,7 +163,10 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8) { Finish = 8; }
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
@ -206,7 +210,9 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
} else {
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
@ -249,7 +255,9 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
m_MemoryList->SetItemText(LineNumber,i,"-");
}
}
} else {
}
else
{
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,0,Output);
@ -286,11 +294,15 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii,".");
} else {
}
else
{
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn);
}
} else {
}
else
{
m_MemoryList->SetItemText(LineNumber,col,"**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE );
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) );
@ -393,7 +405,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{
ValidData = false;
}
} else {
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
@ -428,7 +442,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{
ValidData = false;
}
} else {
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
@ -449,7 +465,8 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
}
}
for (int count = 0 ; count < 16;count ++ ){
for (int count = 0 ; count < 16;count ++)
{
Insert_MemoryLineDump ( count );
}
}

View File

@ -44,5 +44,3 @@
#include "Debugger - View Memory.h"
#include "Debugger - Memory Dump.h"
#include "Debugger - TLB.h"

View File

@ -17,18 +17,22 @@ void ExecuteInterpreterOps (DWORD /*Cycles*/)
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2)
{
OPCODE Command;
if (!g_MMU->LW_VAddr(PC + 4, Command.Hex)) {
if (!g_MMU->LW_VAddr(PC + 4, Command.Hex))
{
//g_Notify->DisplayError(L"Failed to load word 2");
//ExitThread(0);
return TRUE;
}
switch (Command.op) {
switch (Command.op)
{
case R4300i_SPECIAL:
switch (Command.funct) {
switch (Command.funct)
{
case R4300i_SPECIAL_SLL:
case R4300i_SPECIAL_SRL:
case R4300i_SPECIAL_SRA:
@ -62,9 +66,18 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
case R4300i_SPECIAL_DSLL32:
case R4300i_SPECIAL_DSRL32:
case R4300i_SPECIAL_DSRA32:
if (Command.rd == 0) { return FALSE; }
if (Command.rd == Reg1) { return TRUE; }
if (Command.rd == Reg2) { return TRUE; }
if (Command.rd == 0)
{
return FALSE;
}
if (Command.rd == Reg1)
{
return TRUE;
}
if (Command.rd == Reg2)
{
return TRUE;
}
break;
case R4300i_SPECIAL_MULT:
case R4300i_SPECIAL_MULTU:
@ -84,16 +97,28 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
}
break;
case R4300i_CP0:
switch (Command.rs) {
switch (Command.rs)
{
case R4300i_COP0_MT: break;
case R4300i_COP0_MF:
if (Command.rt == 0) { return FALSE; }
if (Command.rt == Reg1) { return TRUE; }
if (Command.rt == Reg2) { return TRUE; }
if (Command.rt == 0)
{
return FALSE;
}
if (Command.rt == Reg1)
{
return TRUE;
}
if (Command.rt == Reg2)
{
return TRUE;
}
break;
default:
if ( (Command.rs & 0x10 ) != 0 ) {
switch( Command.funct ) {
if ( (Command.rs & 0x10 ) != 0 )
{
switch ( Command.funct )
{
case R4300i_COP0_CO_TLBR: break;
case R4300i_COP0_CO_TLBWI: break;
case R4300i_COP0_CO_TLBWR: break;
@ -105,7 +130,9 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
}
return TRUE;
}
} else {
}
else
{
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(L"Does %s effect Delay slot at %X?\n7",R4300iOpcodeName(Command.Hex,PC+4), PC);
@ -115,11 +142,21 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
}
break;
case R4300i_CP1:
switch (Command.fmt) {
switch (Command.fmt)
{
case R4300i_COP1_MF:
if (Command.rt == 0) { return FALSE; }
if (Command.rt == Reg1) { return TRUE; }
if (Command.rt == Reg2) { return TRUE; }
if (Command.rt == 0)
{
return FALSE;
}
if (Command.rt == Reg1)
{
return TRUE;
}
if (Command.rt == Reg2)
{
return TRUE;
}
break;
case R4300i_COP1_CF: break;
case R4300i_COP1_MT: break;
@ -158,9 +195,18 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
case R4300i_LD:
case R4300i_LWC1:
case R4300i_LDC1:
if (Command.rt == 0) { return FALSE; }
if (Command.rt == Reg1) { return TRUE; }
if (Command.rt == Reg2) { return TRUE; }
if (Command.rt == 0)
{
return FALSE;
}
if (Command.rt == Reg1)
{
return TRUE;
}
if (Command.rt == Reg2)
{
return TRUE;
}
break;
case R4300i_CACHE: break;
case R4300i_SB: break;
@ -181,7 +227,7 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
return FALSE;
}
void CInterpreterCPU::BuildCPU (void )
void CInterpreterCPU::BuildCPU (void)
{
R4300iOp::m_TestTimer = FALSE;
R4300iOp::m_NextInstruction = NORMAL;
@ -190,14 +236,20 @@ void CInterpreterCPU::BuildCPU (void )
if (g_Settings->LoadBool(Game_32Bit))
{
m_R4300i_Opcode = R4300iOp32::BuildInterpreter();
} else {
}
else
{
m_R4300i_Opcode = R4300iOp::BuildInterpreter();
}
}
void CInterpreterCPU::InPermLoop (void) {
void CInterpreterCPU::InPermLoop (void)
{
// *** Changed ***/
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] +=5; }
//if (CPU_Type == CPU_SyncCores)
//{
// SyncRegisters.CP0[9] +=5;
//}
/* Interrupts enabled */
if (( g_Reg->STATUS_REGISTER & STATUS_IE ) == 0 ||
@ -205,21 +257,27 @@ void CInterpreterCPU::InPermLoop (void) {
( g_Reg->STATUS_REGISTER & STATUS_ERL ) != 0 ||
( g_Reg->STATUS_REGISTER & 0xFF00) == 0)
{
if (g_Plugins->Gfx()->UpdateScreen != NULL) { g_Plugins->Gfx()->UpdateScreen(); }
if (g_Plugins->Gfx()->UpdateScreen != NULL)
{
g_Plugins->Gfx()->UpdateScreen();
}
//CurrentFrame = 0;
//CurrentPercent = 0;
//DisplayFPS();
g_Notify->DisplayError(GS(MSG_PERM_LOOP));
g_System->CloseCpu();
} else {
if (*g_NextTimer > 0) {
}
else
{
if (*g_NextTimer > 0)
{
*g_NextTimer = 0 - g_System->CountPerOp();
g_SystemTimer->UpdateTimers();
}
}
}
void CInterpreterCPU::ExecuteCPU (void )
void CInterpreterCPU::ExecuteCPU (void)
{
bool & Done = g_System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
@ -232,7 +290,7 @@ void CInterpreterCPU::ExecuteCPU (void )
__try
{
while(!Done)
while (!Done)
{
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
@ -290,12 +348,15 @@ void CInterpreterCPU::ExecuteCPU (void )
default:
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
} else {
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) {
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
}
@ -314,7 +375,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
__try
{
while(!Done)
while (!Done)
{
if (Cycles <= 0)
{
@ -397,12 +458,15 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
default:
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
} else {
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) {
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
}

View File

@ -628,7 +628,8 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter (void )
/************************* Opcode functions *************************/
void R4300iOp32::JAL (void) {
void R4300iOp32::JAL (void)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2);
_GPR[31].UW[0] = (*_PROGRAM_COUNTER) + 8;
@ -639,9 +640,11 @@ void R4300iOp32::JAL (void) {
}
}
void R4300iOp32::BEQ (void) {
void R4300iOp32::BEQ (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) {
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0])
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -650,14 +653,18 @@ void R4300iOp32::BEQ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BNE (void) {
void R4300iOp32::BNE (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) {
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0])
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -666,14 +673,17 @@ void R4300iOp32::BNE (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BLEZ (void) {
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] <= 0) {
if (_GPR[m_Opcode.rs].W[0] <= 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -682,14 +692,18 @@ void R4300iOp32::BLEZ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BGTZ (void) {
void R4300iOp32::BGTZ (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] > 0) {
if (_GPR[m_Opcode.rs].W[0] > 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -698,48 +712,61 @@ void R4300iOp32::BGTZ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::ADDI (void) {
void R4300iOp32::ADDI (void)
{
#ifdef Interpreter_StackTest
if (m_Opcode.rs == 29 && m_Opcode.rt == 29) {
if (m_Opcode.rs == 29 && m_Opcode.rt == 29)
{
StackValue += (short)m_Opcode.immediate;
}
#endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate));
#ifdef Interpreter_StackTest
if (m_Opcode.rt == 29 && m_Opcode.rs != 29) {
if (m_Opcode.rt == 29 && m_Opcode.rs != 29)
{
StackValue = _GPR[m_Opcode.rt].W[0];
}
#endif
}
void R4300iOp32::ADDIU (void) {
void R4300iOp32::ADDIU (void)
{
#ifdef Interpreter_StackTest
if (m_Opcode.rs == 29 && m_Opcode.rt == 29) {
if (m_Opcode.rs == 29 && m_Opcode.rt == 29)
{
StackValue += (short)m_Opcode.immediate;
}
#endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate));
#ifdef Interpreter_StackTest
if (m_Opcode.rt == 29 && m_Opcode.rs != 29) {
if (m_Opcode.rt == 29 && m_Opcode.rs != 29)
{
StackValue = _GPR[m_Opcode.rt].W[0];
}
#endif
}
void R4300iOp32::SLTI (void) {
if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate)) {
void R4300iOp32::SLTI (void)
{
if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate))
{
_GPR[m_Opcode.rt].W[0] = 1;
} else {
}
else
{
_GPR[m_Opcode.rt].W[0] = 0;
}
}
void R4300iOp32::SLTIU (void) {
void R4300iOp32::SLTIU (void)
{
int imm32 = (short)m_Opcode.immediate;
__int64 imm64;
@ -747,29 +774,36 @@ void R4300iOp32::SLTIU (void) {
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (unsigned __int64)imm64?1:0;
}
void R4300iOp32::ANDI (void) {
void R4300iOp32::ANDI (void)
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] & m_Opcode.immediate;
}
void R4300iOp32::ORI (void) {
void R4300iOp32::ORI (void)
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] | m_Opcode.immediate;
}
void R4300iOp32::XORI (void) {
void R4300iOp32::XORI (void)
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] ^ m_Opcode.immediate;
}
void R4300iOp32::LUI (void) {
void R4300iOp32::LUI (void)
{
_GPR[m_Opcode.rt].W[0] = (long)((short)m_Opcode.offset << 16);
#ifdef Interpreter_StackTest
if (m_Opcode.rt == 29) {
if (m_Opcode.rt == 29)
{
StackValue = _GPR[m_Opcode.rt].W[0];
}
#endif
}
void R4300iOp32::BEQL (void) {
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) {
void R4300iOp32::BEQL (void)
{
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0])
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -779,14 +813,18 @@ void R4300iOp32::BEQL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BNEL (void) {
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) {
void R4300iOp32::BNEL (void)
{
if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0])
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -796,14 +834,18 @@ void R4300iOp32::BNEL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BLEZL (void) {
if (_GPR[m_Opcode.rs].W[0] <= 0) {
void R4300iOp32::BLEZL (void)
{
if (_GPR[m_Opcode.rs].W[0] <= 0)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -813,14 +855,18 @@ void R4300iOp32::BLEZL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::BGTZL (void) {
if (_GPR[m_Opcode.rs].W[0] > 0) {
void R4300iOp32::BGTZL (void)
{
if (_GPR[m_Opcode.rs].W[0] > 0)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -830,38 +876,54 @@ void R4300iOp32::BGTZL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY;
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::LB (void) {
void R4300iOp32::LB (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) {
if (bShowTLBMisses()) {
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LB TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].B[0];
}
}
void R4300iOp32::LH (void) {
void R4300iOp32::LH (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); }
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) {
if (bShowTLBMisses()) {
if ((Address & 1) != 0)
{
ADDRESS_ERROR_EXCEPTION(Address,TRUE);
}
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LH TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].HW[0];
}
}
void R4300iOp32::LWL (void) {
void R4300iOp32::LWL (void)
{
DWORD Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
@ -869,7 +931,8 @@ void R4300iOp32::LWL (void) {
if (!g_MMU->LW_VAddr((Address & ~3),Value))
{
if (bShowTLBMisses()) {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LWL TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
@ -880,51 +943,73 @@ void R4300iOp32::LWL (void) {
_GPR[m_Opcode.rt].W[0] += (int)(Value << LWL_SHIFT[Offset]);
}
void R4300iOp32::LW (void) {
void R4300iOp32::LW (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); }
if ((Address & 3) != 0)
{
ADDRESS_ERROR_EXCEPTION(Address,TRUE);
}
if (LogOptions.GenerateLog)
{
Log_LW((*_PROGRAM_COUNTER),Address);
}
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) {
if (bShowTLBMisses()) {
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LW TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0];
}
}
void R4300iOp32::LBU (void) {
void R4300iOp32::LBU (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) {
if (bShowTLBMisses()) {
if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LBU TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UB[0];
}
}
void R4300iOp32::LHU (void) {
void R4300iOp32::LHU (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); }
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) {
if (bShowTLBMisses()) {
if ((Address & 1) != 0)
{
ADDRESS_ERROR_EXCEPTION(Address,TRUE);
}
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LHU TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UHW[0];
}
}
void R4300iOp32::LWR (void) {
void R4300iOp32::LWR (void)
{
DWORD Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
@ -944,118 +1029,158 @@ void R4300iOp32::LWR (void) {
_GPR[m_Opcode.rt].W[0] += (int)(Value >> LWR_SHIFT[Offset]);
}
void R4300iOp32::LWU (void) {
void R4300iOp32::LWU (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); }
if ((Address & 3) != 0)
{
ADDRESS_ERROR_EXCEPTION(Address,TRUE);
}
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) {
if (bShowTLBMisses()) {
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LWU TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UW[0];
}
}
void R4300iOp32::LL (void) {
void R4300iOp32::LL (void)
{
DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); }
if ((Address & 3) != 0)
{
ADDRESS_ERROR_EXCEPTION(Address,TRUE);
}
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) {
if (bShowTLBMisses()) {
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
{
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LL TLB: %X",Address);
}
TLB_READ_EXCEPTION(Address);
} else {
}
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0];
(*_LLBit) = 1;
}
}
/********************** R4300i OpCodes: Special **********************/
void R4300iOp32::SPECIAL_SLL (void) {
void R4300iOp32::SPECIAL_SLL (void)
{
_GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa);
}
void R4300iOp32::SPECIAL_SRL (void) {
void R4300iOp32::SPECIAL_SRL (void)
{
_GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa);
}
void R4300iOp32::SPECIAL_SRA (void) {
void R4300iOp32::SPECIAL_SRA (void)
{
_GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> m_Opcode.sa);
}
void R4300iOp32::SPECIAL_SLLV (void) {
void R4300iOp32::SPECIAL_SLLV (void)
{
_GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << (_GPR[m_Opcode.rs].UW[0] & 0x1F));
}
void R4300iOp32::SPECIAL_SRLV (void) {
void R4300iOp32::SPECIAL_SRLV (void)
{
_GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F));
}
void R4300iOp32::SPECIAL_SRAV (void) {
void R4300iOp32::SPECIAL_SRAV (void)
{
_GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F));
}
void R4300iOp32::SPECIAL_JALR (void) {
void R4300iOp32::SPECIAL_JALR (void)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = _GPR[m_Opcode.rs].UW[0];
_GPR[m_Opcode.rd].W[0] = (long)((*_PROGRAM_COUNTER) + 8);
m_TestTimer = TRUE;
}
void R4300iOp32::SPECIAL_ADD (void) {
void R4300iOp32::SPECIAL_ADD (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0];
}
void R4300iOp32::SPECIAL_ADDU (void) {
void R4300iOp32::SPECIAL_ADDU (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0];
}
void R4300iOp32::SPECIAL_SUB (void) {
void R4300iOp32::SPECIAL_SUB (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0];
}
void R4300iOp32::SPECIAL_SUBU (void) {
void R4300iOp32::SPECIAL_SUBU (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0];
}
void R4300iOp32::SPECIAL_AND (void) {
void R4300iOp32::SPECIAL_AND (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] & _GPR[m_Opcode.rt].W[0];
}
void R4300iOp32::SPECIAL_OR (void) {
void R4300iOp32::SPECIAL_OR (void)
{
_GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0];
#ifdef Interpreter_StackTest
if (m_Opcode.rd == 29) {
if (m_Opcode.rd == 29)
{
StackValue = _GPR[m_Opcode.rd].W[0];
}
#endif
}
void R4300iOp32::SPECIAL_NOR (void) {
void R4300iOp32::SPECIAL_NOR (void)
{
_GPR[m_Opcode.rd].W[0] = ~(_GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]);
}
void R4300iOp32::SPECIAL_SLT (void) {
if (_GPR[m_Opcode.rs].W[0] < _GPR[m_Opcode.rt].W[0]) {
void R4300iOp32::SPECIAL_SLT (void)
{
if (_GPR[m_Opcode.rs].W[0] < _GPR[m_Opcode.rt].W[0])
{
_GPR[m_Opcode.rd].W[0] = 1;
} else {
}
else
{
_GPR[m_Opcode.rd].W[0] = 0;
}
}
void R4300iOp32::SPECIAL_SLTU (void) {
if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0]) {
void R4300iOp32::SPECIAL_SLTU (void)
{
if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0])
{
_GPR[m_Opcode.rd].W[0] = 1;
} else {
}
else
{
_GPR[m_Opcode.rd].W[0] = 0;
}
}
void R4300iOp32::SPECIAL_TEQ (void) {
void R4300iOp32::SPECIAL_TEQ (void)
{
if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0] && g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(L"Should trap this ???");
@ -1073,9 +1198,11 @@ void R4300iOp32::SPECIAL_DSRA32 (void)
}
/********************** R4300i OpCodes: RegImm **********************/
void R4300iOp32::REGIMM_BLTZ (void) {
void R4300iOp32::REGIMM_BLTZ (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] < 0) {
if (_GPR[m_Opcode.rs].W[0] < 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -1084,14 +1211,18 @@ void R4300iOp32::REGIMM_BLTZ (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::REGIMM_BGEZ (void) {
void R4300iOp32::REGIMM_BGEZ (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] >= 0) {
if (_GPR[m_Opcode.rs].W[0] >= 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -1100,13 +1231,17 @@ void R4300iOp32::REGIMM_BGEZ (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::REGIMM_BLTZL (void) {
if (_GPR[m_Opcode.rs].W[0] < 0) {
void R4300iOp32::REGIMM_BLTZL (void)
{
if (_GPR[m_Opcode.rs].W[0] < 0)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -1116,14 +1251,18 @@ void R4300iOp32::REGIMM_BLTZL (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::REGIMM_BGEZL (void) {
if (_GPR[m_Opcode.rs].W[0] >= 0) {
void R4300iOp32::REGIMM_BGEZL (void)
{
if (_GPR[m_Opcode.rs].W[0] >= 0)
{
m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -1133,15 +1272,19 @@ void R4300iOp32::REGIMM_BGEZL (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
}
void R4300iOp32::REGIMM_BLTZAL (void) {
void R4300iOp32::REGIMM_BLTZAL (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] < 0) {
if (_GPR[m_Opcode.rs].W[0] < 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -1150,15 +1293,19 @@ void R4300iOp32::REGIMM_BLTZAL (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
_GPR[31].W[0]= (long)((*_PROGRAM_COUNTER) + 8);
}
void R4300iOp32::REGIMM_BGEZAL (void) {
void R4300iOp32::REGIMM_BGEZAL (void)
{
m_NextInstruction = DELAY_SLOT;
if (_GPR[m_Opcode.rs].W[0] >= 0) {
if (_GPR[m_Opcode.rs].W[0] >= 0)
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{
@ -1167,7 +1314,9 @@ void R4300iOp32::REGIMM_BGEZAL (void) {
CInterpreterCPU::InPermLoop();
}
}
} else {
}
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
}
_GPR[31].W[0] = (long)((*_PROGRAM_COUNTER) + 8);
@ -1186,16 +1335,19 @@ void R4300iOp32::COP0_MF (void) {
_GPR[m_Opcode.rt].W[0] = (int)_CP0[m_Opcode.rd];
}
void R4300iOp32::COP0_MT (void) {
void R4300iOp32::COP0_MT (void)
{
if (LogOptions.LogCP0changes)
{
LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]);
if (m_Opcode.rd == 11) { //Compare
if (m_Opcode.rd == 11) //Compare
{
LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7));
}
}
switch (m_Opcode.rd) {
switch (m_Opcode.rd)
{
case 0: //Index
case 2: //EntryLo0
case 3: //EntryLo1
@ -1229,10 +1381,13 @@ void R4300iOp32::COP0_MT (void) {
g_SystemTimer->UpdateCompareTimer();
break;
case 12: //Status
if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) {
if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR))
{
_CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0];
g_Reg->FixFpuLocations();
} else {
}
else
{
_CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0];
}
if ((_CP0[m_Opcode.rd] & 0x18) != 0 && g_Settings->LoadBool(Debugger_Enabled))
@ -1254,12 +1409,14 @@ void R4300iOp32::COP0_MT (void) {
}
/************************** COP1 functions **************************/
void R4300iOp32::COP1_MF (void) {
void R4300iOp32::COP1_MF (void)
{
TEST_COP1_USABLE_EXCEPTION
_GPR[m_Opcode.rt].W[0] = *(int *)_FPR_S[m_Opcode.fs];
}
void R4300iOp32::COP1_CF (void) {
void R4300iOp32::COP1_CF (void)
{
TEST_COP1_USABLE_EXCEPTION
if (m_Opcode.fs != 31 && m_Opcode.fs != 0)
{
@ -1269,8 +1426,8 @@ void R4300iOp32::COP1_CF (void) {
_GPR[m_Opcode.rt].W[0] = (int)_FPCR[m_Opcode.fs];
}
void R4300iOp32::COP1_DMT (void) {
void R4300iOp32::COP1_DMT (void)
{
TEST_COP1_USABLE_EXCEPTION
*(__int64 *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0];
}

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@ CAudio::CAudio (void)
CAudio::~CAudio (void)
{
}
void CAudio::Reset ( void )
@ -65,12 +66,16 @@ void CAudio::LenChanged ( void )
}
WriteTraceF(TraceAudio,__FUNCTION__ ": Set Timer AI_LEN_REG: %d m_CountsPerByte: %d",g_Reg->AI_LEN_REG,m_CountsPerByte);
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,g_Reg->AI_LEN_REG * m_CountsPerByte,false);
} else {
}
else
{
WriteTraceF(TraceAudio,__FUNCTION__ ": Increasing Second Buffer (m_SecondBuff %d Increase: %d)",m_SecondBuff,g_Reg->AI_LEN_REG);
m_SecondBuff += g_Reg->AI_LEN_REG;
}
}
} else {
}
else
{
WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0");
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
@ -92,7 +97,9 @@ void CAudio::InterruptTimerDone ( void )
{
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false);
m_SecondBuff = 0;
} else {
}
else
{
if (g_Reg->m_AudioIntrReg == 0)
{
g_System->SyncToAudio();
@ -128,7 +135,8 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,g_Reg->AI_BITRATE_REG);
DWORD Frequency;
switch (System) {
switch (System)
{
case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break;
default: Frequency = 48681812 / (Dacrate + 1); break;
@ -141,4 +149,3 @@ void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
}

View File

@ -12,7 +12,8 @@
class CAudio
{
enum {
enum
{
ai_full = 0x80000000,
ai_busy = 0x40000000,
};

View File

@ -14,10 +14,13 @@ CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
m_FlashRam(FlashRam),
m_Sram(Sram)
{
}
void CDMA::OnFirstDMA (void) {
switch (g_Rom->CicChipID()) {
void CDMA::OnFirstDMA (void)
{
switch (g_Rom->CicChipID())
{
case CIC_NUS_6101: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case CIC_UNKNOWN:
case CIC_NUS_6102: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
@ -28,21 +31,30 @@ void CDMA::OnFirstDMA (void) {
}
}
void CDMA::PI_DMA_READ (void) {
void CDMA::PI_DMA_READ (void)
{
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
if ( g_Reg->PI_DRAM_ADDR_REG + g_Reg->PI_RD_LEN_REG + 1 > g_MMU->RdramSize())
{
if (bHaveDebugger()) { g_Notify->DisplayError(L"PI_DMA_READ not in Memory"); }
if (bHaveDebugger())
{
g_Notify->DisplayError(L"PI_DMA_READ not in Memory");
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) {
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Sram; }
if (g_System->m_SaveUsing == SaveChip_Sram) {
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaToSram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
@ -53,7 +65,8 @@ void CDMA::PI_DMA_READ (void) {
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam) {
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaToFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
@ -102,9 +115,14 @@ void CDMA::PI_DMA_WRITE (void)
return;
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) {
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Sram; }
if (g_System->m_SaveUsing == SaveChip_Sram) {
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaFromSram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
@ -115,7 +133,8 @@ void CDMA::PI_DMA_WRITE (void)
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam) {
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaFromFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
@ -133,7 +152,8 @@ void CDMA::PI_DMA_WRITE (void)
DWORD i;
#ifdef tofix
#ifdef ROM_IN_MAPSPACE
if (WrittenToRom) {
if (WrittenToRom)
{
DWORD OldProtect;
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
}
@ -142,17 +162,23 @@ void CDMA::PI_DMA_WRITE (void)
BYTE * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize()) {
for (i = 0; i < PI_WR_LEN_REG; i ++) {
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
{
for (i = 0; i < PI_WR_LEN_REG; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
} else {
}
else
{
DWORD Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i ++) {
for (i = 0; i < Len; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
for (i = Len; i < PI_WR_LEN_REG - Len; i ++) {
for (i = Len; i < PI_WR_LEN_REG - Len; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
}
}
@ -182,7 +208,8 @@ void CDMA::PI_DMA_WRITE (void)
}
void CDMA::SP_DMA_READ (void) {
void CDMA::SP_DMA_READ (void)
{
g_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF;
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
@ -205,9 +232,18 @@ void CDMA::SP_DMA_READ (void) {
return;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
memcpy( g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF), g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG,
g_Reg->SP_RD_LEN_REG + 1 );
@ -236,9 +272,19 @@ void CDMA::SP_DMA_WRITE (void)
return;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0) { g_Notify->BreakPoint(__FILEW__,__LINE__); }
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
memcpy( g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
g_Reg->SP_WR_LEN_REG + 1);
@ -246,4 +292,3 @@ void CDMA::SP_DMA_WRITE (void)
g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}

View File

@ -33,5 +33,3 @@ private:
void OnFirstDMA ( void );
};

View File

@ -18,8 +18,10 @@ CEeprom::CEeprom (bool ReadOnly):
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
}
CEeprom::~CEeprom (void) {
if (m_hFile) {
CEeprom::~CEeprom (void)
{
if (m_hFile)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
@ -31,15 +33,21 @@ unsigned char byte2bcd(int n)
return (unsigned char)(((n / 10) << 4) | (n % 10));
}
void CEeprom::EepromCommand ( BYTE * Command) {
void CEeprom::EepromCommand ( BYTE * Command)
{
time_t curtime_time;
struct tm curtime;
if (g_System->m_SaveUsing == SaveChip_Auto) { g_System->m_SaveUsing = SaveChip_Eeprom_4K; }
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Eeprom_4K;
}
switch (Command[2]) {
switch (Command[2])
{
case 0: // check
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) {
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K)
{
Command[1] |= 0x80;
break;
}
@ -52,20 +60,34 @@ void CEeprom::EepromCommand ( BYTE * Command) {
Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
if ((Command[1] & 3) > 2)
Command[5] = 0x00;
} else {
}
else
{
Command[3] = 0x00;
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[5] = 0x00;
}
break;
case 4: // Read from Eeprom
if (Command[0] != 2 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
if (Command[1] != 8 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
if (Command[0] != 2 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 8 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
ReadFrom(&Command[4],Command[3]);
break;
case 5: //Write to Eeprom
if (Command[0] != 10 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
if (Command[1] != 1 && bHaveDebugger()) { g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command"); }
if (Command[0] != 10 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 1 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
WriteTo(&Command[4],Command[3]);
break;
case 6: //RTC Status query
@ -74,7 +96,7 @@ void CEeprom::EepromCommand ( BYTE * Command) {
Command[5] = 0x00;
break;
case 7: //Read RTC block
switch(Command[3])
switch (Command[3])
{
case 0: //Block number
Command[4] = 0x00;
@ -101,14 +123,21 @@ void CEeprom::EepromCommand ( BYTE * Command) {
break;
case 8:
//Write RTC, unimplemented
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) { g_Notify->DisplayError(L"Write RTC, unimplemented"); }
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(L"Write RTC, unimplemented");
}
break;
default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) { g_Notify->DisplayError(L"Unknown EepromCommand %d",Command[2]); }
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(L"Unknown EepromCommand %d",Command[2]);
}
}
}
void CEeprom::LoadEeprom (void) {
void CEeprom::LoadEeprom (void)
{
CPath FileName;
DWORD dwRead;
@ -135,7 +164,8 @@ void CEeprom::LoadEeprom (void) {
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL);
}
void CEeprom::ReadFrom(BYTE * Buffer, int line) {
void CEeprom::ReadFrom(BYTE * Buffer, int line)
{
int i;
if (m_hFile == NULL)
@ -143,13 +173,14 @@ void CEeprom::ReadFrom(BYTE * Buffer, int line) {
LoadEeprom();
}
for(i=0; i < 8; i++)
for (i=0; i < 8; i++)
{
Buffer[i] = m_EEPROM[line*8+i];
}
}
void CEeprom::WriteTo(BYTE * Buffer, int line) {
void CEeprom::WriteTo(BYTE * Buffer, int line)
{
DWORD dwWritten;
int i;
@ -157,7 +188,10 @@ void CEeprom::WriteTo(BYTE * Buffer, int line) {
{
LoadEeprom();
}
for(i=0;i<8;i++) { m_EEPROM[line*8+i]=Buffer[i]; }
for (i=0;i<8;i++)
{
m_EEPROM[line*8+i]=Buffer[i];
}
SetFilePointer(m_hFile,line*8,NULL,FILE_BEGIN);
WriteFile( m_hFile,Buffer,8,&dwWritten,NULL );
FlushFileBuffers(m_hFile);

View File

@ -18,10 +18,13 @@ CFlashram::CFlashram (bool ReadOnly):
m_ReadOnly(ReadOnly),
m_hFile(NULL)
{
}
CFlashram::~CFlashram (void) {
if (m_hFile) {
CFlashram::~CFlashram (void)
{
if (m_hFile)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
@ -32,10 +35,15 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
BYTE FlipBuffer[0x10000];
DWORD dwRead, count;
switch (m_FlashFlag) {
switch (m_FlashFlag)
{
case FLASHRAM_MODE_READ:
if (m_hFile == NULL) {
if (!LoadFlashram()) { return; }
if (m_hFile == NULL)
{
if (!LoadFlashram())
{
return;
}
}
if (len > 0x10000)
{
@ -57,10 +65,12 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
StartOffset = StartOffset << 1;
SetFilePointer(m_hFile,StartOffset,NULL,FILE_BEGIN);
ReadFile(m_hFile,FlipBuffer,len,&dwRead,NULL);
for (count = dwRead; (int)count < len; count ++) {
for (count = dwRead; (int)count < len; count ++)
{
FlipBuffer[count] = 0xFF;
}
_asm {
_asm
{
mov edi, dest
lea ecx, [FlipBuffer]
mov edx, 0
@ -94,8 +104,10 @@ void CFlashram::DmaFromFlashram ( BYTE * dest, int StartOffset, int len)
}
}
void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) {
switch (m_FlashFlag) {
void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len)
{
switch (m_FlashFlag)
{
case FLASHRAM_MODE_WRITE:
m_FlashRamPointer = Source;
break;
@ -110,7 +122,8 @@ void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) {
DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr)
{
switch (PAddr) {
switch (PAddr)
{
case 0x08000000: return (DWORD)(m_FlashStatus >> 32);
default:
if (bHaveDebugger())
@ -122,7 +135,8 @@ DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr)
return (DWORD)(m_FlashStatus >> 32);
}
bool CFlashram::LoadFlashram (void) {
bool CFlashram::LoadFlashram (void)
{
CPath FileName;
FileName.SetDriveDirectory( g_Settings->LoadString(Directory_NativeSave).c_str());
@ -146,27 +160,36 @@ bool CFlashram::LoadFlashram (void) {
return true;
}
void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) {
void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command)
{
BYTE EmptyBlock[128];
DWORD dwWritten;
switch (FlashRAM_Command & 0xFF000000) {
switch (FlashRAM_Command & 0xFF000000)
{
case 0xD2000000:
switch (m_FlashFlag) {
switch (m_FlashFlag)
{
case FLASHRAM_MODE_NOPES: break;
case FLASHRAM_MODE_READ: break;
case FLASHRAM_MODE_STATUS: break;
case FLASHRAM_MODE_ERASE:
memset(EmptyBlock,0xFF,sizeof(EmptyBlock));
if (m_hFile == NULL) {
if (!LoadFlashram()) { return; }
if (!LoadFlashram())
{
return;
}
}
SetFilePointer(m_hFile,m_FlashRAM_Offset,NULL,FILE_BEGIN);
WriteFile(m_hFile,EmptyBlock,128,&dwWritten,NULL);
break;
case FLASHRAM_MODE_WRITE:
if (m_hFile == NULL) {
if (!LoadFlashram()) { return; }
if (!LoadFlashram())
{
return;
}
}
{
BYTE FlipBuffer[128];
@ -174,7 +197,8 @@ void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) {
BYTE * FlashRamPointer = m_FlashRamPointer;
memset(FlipBuffer,0,sizeof(FlipBuffer));
_asm {
_asm
{
lea edi, [FlipBuffer]
mov ecx, FlashRamPointer
mov edx, 0

View File

@ -13,7 +13,8 @@
class CFlashram :
private CDebugSettings
{
enum Modes {
enum Modes
{
FLASHRAM_MODE_NOPES = 0,
FLASHRAM_MODE_ERASE = 1,
FLASHRAM_MODE_WRITE = 2,

View File

@ -10,15 +10,21 @@
****************************************************************************/
#include "stdafx.h"
DWORD CMemoryLabel::AsciiToHex (char * HexValue) {
DWORD CMemoryLabel::AsciiToHex (char * HexValue)
{
DWORD Count, Finish, Value = 0;
Finish = strlen(HexValue);
if (Finish > 8 ) { Finish = 8; }
if (Finish > 8 )
{
Finish = 8;
}
for (Count = 0; Count < Finish; Count++){
for (Count = 0; Count < Finish; Count++)
{
Value = (Value << 4);
switch( HexValue[Count] ) {
switch ( HexValue[Count] )
{
case '0': break;
case '1': Value += 1; break;
case '2': Value += 2; break;
@ -49,9 +55,11 @@ DWORD CMemoryLabel::AsciiToHex (char * HexValue) {
return Value;
}
void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... ) {
void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... )
{
StringMap::iterator Item = m_LabelList.find(Address);
if (Item == m_LabelList.end()) {
if (Item == m_LabelList.end())
{
char Msg[1000];
va_list ap;
@ -65,9 +73,11 @@ void CMemoryLabel::AddMemoryLabel ( DWORD Address, const char * Message, ... ) {
}
}
stdstr CMemoryLabel::LabelName ( DWORD Address ) const {
stdstr CMemoryLabel::LabelName ( DWORD Address ) const
{
//StringMap::iterator theIterator = m_LabelList.find(Address);
//if (theIterator != m_LabelList.end()) {
//if (theIterator != m_LabelList.end())
//{
// return (*theIterator).second;
//}
@ -76,36 +86,47 @@ stdstr CMemoryLabel::LabelName ( DWORD Address ) const {
return stdstr(strLabelName);
}
stdstr CMemoryLabel::StoredLabelName ( DWORD Address ) {
stdstr CMemoryLabel::StoredLabelName ( DWORD Address )
{
StringMap::iterator theIterator = m_LabelList.find(Address);
if (theIterator != m_LabelList.end()) {
if (theIterator != m_LabelList.end())
{
return (*theIterator).second;
}
return stdstr("");
}
void CMemoryLabel::LoadLabelList ( char * file ) {
void CMemoryLabel::LoadLabelList ( char * file )
{
m_LabelList.clear();
CurrentLabelFile = file;
HANDLE hFile = CreateFile(file,GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hFile == INVALID_HANDLE_VALUE) { return; }
if (hFile == INVALID_HANDLE_VALUE)
{
return;
}
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
DWORD FileSize = GetFileSize(hFile,NULL);
void * FileContents = VirtualAlloc(NULL,FileSize,MEM_COMMIT,PAGE_READWRITE );
if (FileContents) {
if (FileContents)
{
DWORD dwRead;
if (!ReadFile(hFile,FileContents,FileSize,&dwRead,NULL)) {
if (!ReadFile(hFile,FileContents,FileSize,&dwRead,NULL))
{
VirtualFree(FileContents, 0, MEM_RELEASE);
FileContents = NULL;
}
}
if (FileContents) { ProcessCODFile((BYTE *)FileContents, FileSize); }
if (FileContents)
{
ProcessCODFile((BYTE *)FileContents, FileSize);
}
VirtualFree(FileContents, 0, MEM_RELEASE);
CloseHandle(hFile);
@ -113,21 +134,27 @@ void CMemoryLabel::LoadLabelList ( char * file ) {
m_NewLabels = 0;
}
// How many new labels been added since loading/saveing label file
int CMemoryLabel::NewLabels ( void ) {
// How many new labels been added since loading/saving label file
int CMemoryLabel::NewLabels ( void )
{
return m_NewLabels;
}
void CMemoryLabel::SaveLabelList ( void ) {
void CMemoryLabel::SaveLabelList ( void )
{
m_NewLabels = 0;
if (CurrentLabelFile.length() == 0) { return; }
if (CurrentLabelFile.length() == 0)
{
return;
}
HANDLE hFile = CreateFile(CurrentLabelFile.c_str(),GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
for (StringMap::iterator Item = m_LabelList.begin(); Item != m_LabelList.end(); Item++) {
for (StringMap::iterator Item = m_LabelList.begin(); Item != m_LabelList.end(); Item++)
{
char Text[300];
DWORD dwWritten;
@ -140,33 +167,51 @@ void CMemoryLabel::SaveLabelList ( void ) {
}
void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen) {
void CMemoryLabel::ProcessCODFile(BYTE * File, DWORD FileLen)
{
char * CurrentPos = (char *)File;
char Label[40];
DWORD Address;
int Length;
while ( CurrentPos < (char *)File + FileLen ) {
if (*CurrentPos != '0') { return; }
while ( CurrentPos < (char *)File + FileLen )
{
if (*CurrentPos != '0')
{
return;
}
CurrentPos += 1;
if (*CurrentPos != 'x') { return; }
if (*CurrentPos != 'x')
{
return;
}
CurrentPos += 1;
if (strchr(CurrentPos,',') - CurrentPos != 8) { return; }
if (strchr(CurrentPos,',') - CurrentPos != 8)
{
return;
}
Address = AsciiToHex (CurrentPos);
CurrentPos += 9;
if (strchr(CurrentPos,'\r') == NULL) {
if (strchr(CurrentPos,'\r') == NULL)
{
Length = strchr(CurrentPos,'\n') - CurrentPos;
} else {
}
else
{
Length = strchr(CurrentPos,'\r') - CurrentPos;
if (Length > (strchr(CurrentPos,'\n') - CurrentPos)) {
if (Length > (strchr(CurrentPos,'\n') - CurrentPos))
{
Length = strchr(CurrentPos,'\n') - CurrentPos;
}
}
if (Length > 40) { Length = 40; }
if (Length > 40)
{
Length = 40;
}
memcpy(Label,CurrentPos,Length);
Label[Length] = '\0';

View File

@ -12,7 +12,8 @@
typedef std::map<DWORD, stdstr> StringMap;
class CMemoryLabel {
class CMemoryLabel
{
// Variable dealing with Labels
StringMap m_LabelList;
int m_NewLabels;

File diff suppressed because it is too large Load Diff

View File

@ -160,7 +160,7 @@ private:
DWORD m_FieldSerration;
DWORD m_TempValue;
//Initilizing and reseting information about the memory system
//Initializing and resetting information about the memory system
void FreeMemory ( void );
mutable char m_strLabelName[100];

View File

@ -12,7 +12,8 @@
static BYTE Mempaks[4][0x8000];
HANDLE hMempakFile[4];
void Mempak::Close(void) {
void Mempak::Close(void)
{
for (int i = 0; i < 4; i++)
{
if (hMempakFile[i])
@ -23,7 +24,8 @@ void Mempak::Close(void) {
}
}
void LoadMempak (int Control) {
void LoadMempak (int Control)
{
CPath FileName;
DWORD dwRead;
stdstr MempakName;
@ -92,21 +94,28 @@ void LoadMempak (int Control) {
}
}
BYTE Mempak::CalculateCrc(BYTE * DataToCrc) {
BYTE Mempak::CalculateCrc(BYTE * DataToCrc)
{
DWORD Count;
DWORD XorTap;
int Length;
BYTE CRC = 0;
for (Count = 0; Count < 0x21; Count++) {
for (Length = 0x80; Length >= 1; Length >>= 1) {
for (Count = 0; Count < 0x21; Count++)
{
for (Length = 0x80; Length >= 1; Length >>= 1)
{
XorTap = (CRC & 0x80) ? 0x85 : 0;
CRC <<= 1;
if (Count == 0x20) {
if (Count == 0x20)
{
CRC &= 0xFF;
} else {
if ((*DataToCrc & Length) != 0) {
}
else
{
if ((*DataToCrc & Length) != 0)
{
CRC |= 1;
}
}
@ -118,13 +127,18 @@ BYTE Mempak::CalculateCrc(BYTE * DataToCrc) {
return CRC;
}
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer) {
if (Address < 0x8000) {
if (hMempakFile[Control] == NULL) {
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer)
{
if (Address < 0x8000)
{
if (hMempakFile[Control] == NULL)
{
LoadMempak(Control);
}
memcpy(Buffer, &Mempaks[Control][Address], 0x20);
} else {
}
else
{
memset(Buffer, 0, 0x20);
/* Rumble pack area */
}
@ -132,18 +146,23 @@ void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer) {
Buffer[0x20] = CalculateCrc(Buffer);
}
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer) {
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer)
{
DWORD dwWritten;
if (Address < 0x8000) {
if (hMempakFile[Control] == NULL) {
if (Address < 0x8000)
{
if (hMempakFile[Control] == NULL)
{
LoadMempak(Control);
}
memcpy(&Mempaks[Control][Address], Buffer, 0x20);
SetFilePointer(hMempakFile[Control], 0,NULL,FILE_BEGIN);
WriteFile(hMempakFile[Control], &Mempaks[Control][0], 0x8000, &dwWritten, NULL);
} else {
}
else
{
/* Rumble pack area */
}
Buffer[0x20] = CalculateCrc(Buffer);

View File

@ -10,30 +10,35 @@
****************************************************************************/
#pragma once
typedef union {
typedef union
{
unsigned long Hex;
unsigned char Ascii[4];
struct {
struct
{
unsigned offset : 16;
unsigned rt : 5;
unsigned rs : 5;
unsigned op : 6;
};
struct {
struct
{
unsigned immediate : 16;
unsigned : 5;
unsigned base : 5;
unsigned : 6;
};
struct {
struct
{
unsigned target : 26;
unsigned : 6;
};
struct {
struct
{
unsigned funct : 6;
unsigned sa : 5;
unsigned rd : 5;
@ -42,7 +47,8 @@ typedef union {
unsigned : 6;
};
struct {
struct
{
unsigned : 6;
unsigned fd : 5;
unsigned fs : 5;

View File

@ -45,6 +45,7 @@ CPifRam::CPifRam( bool SavesReadOnly ) :
CPifRam::~CPifRam( void )
{
}
void CPifRam::Reset ( void )
@ -66,16 +67,21 @@ void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length)
char key, *lut;
int i, sgn, mag, mod;
for (key = 0xB, lut = lut0, i = 0; i < length; i++) {
for (key = 0xB, lut = lut0, i = 0; i < length; i++)
{
respone[i] = (key + 5 * challenge[i]) & 0xF;
key = lut[respone[i]];
sgn = (respone[i] >> 3) & 0x1;
mag = ((sgn == 1) ? ~respone[i] : respone[i]) & 0x7;
mod = (mag % 3 == 1) ? sgn : 1 - sgn;
if (lut == lut1 && (respone[i] == 0x1 || respone[i] == 0x9))
{
mod = 1;
}
if (lut == lut1 && (respone[i] == 0xB || respone[i] == 0xE))
{
mod = 0;
}
lut = (mod == 1) ? lut1 : lut0;
}
}
@ -93,7 +99,8 @@ void CPifRam::PifRamRead (void)
int Channel = 0;
for (int CurPos = 0; CurPos < 0x40; CurPos ++)
{
switch(m_PifRam[CurPos]) {
switch (m_PifRam[CurPos])
{
case 0x00:
Channel += 1;
if (Channel > 6)
@ -107,31 +114,49 @@ void CPifRam::PifRamRead (void)
default:
if ((m_PifRam[CurPos] & 0xC0) == 0)
{
if (Channel < 4) {
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Channel,&m_PifRam[CurPos]); }
} else {
if (Channel < 4)
{
if (Controllers[Channel].Present && Controllers[Channel].RawData)
{
if (g_Plugins->Control()->ReadController)
{
g_Plugins->Control()->ReadController(Channel,&m_PifRam[CurPos]);
}
}
else
{
ReadControllerCommand(Channel,&m_PifRam[CurPos]);
}
}
CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1;
Channel += 1;
} else {
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]); }
}
else
{
if (bShowPifRamErrors())
{
g_Notify->DisplayError(L"Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]);
}
CurPos = 0x40;
}
break;
}
}
if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(-1,NULL); }
if (g_Plugins->Control()->ReadController)
{
g_Plugins->Control()->ReadController(-1,NULL);
}
}
void CPifRam::PifRamWrite (void) {
void CPifRam::PifRamWrite (void)
{
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
int Channel = 0, CurPos;
if( m_PifRam[0x3F] > 0x1) {
switch (m_PifRam[0x3F]) {
if ( m_PifRam[0x3F] > 0x1)
{
switch (m_PifRam[0x3F])
{
case 0x02:
// format the 'challenge' message into 30 nibbles for X-Scale's CIC code
{
@ -173,31 +198,51 @@ void CPifRam::PifRamWrite (void) {
memset(m_PifRam,0,0x40);
break;
default:
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unkown PifRam control: %d",m_PifRam[0x3F]); }
if (bShowPifRamErrors())
{
g_Notify->DisplayError(L"Unkown PifRam control: %d",m_PifRam[0x3F]);
}
}
return;
}
for (CurPos = 0; CurPos < 0x40; CurPos++){
switch(m_PifRam[CurPos]) {
for (CurPos = 0; CurPos < 0x40; CurPos++)
{
switch (m_PifRam[CurPos])
{
case 0x00:
Channel += 1;
if (Channel > 6) { CurPos = 0x40; }
if (Channel > 6)
{
CurPos = 0x40;
}
break;
case 0xFE: CurPos = 0x40; break;
case 0xFF: break;
case 0xB4: case 0x56: case 0xB8: break; /* ??? */
default:
if ((m_PifRam[CurPos] & 0xC0) == 0) {
if (Channel < 4) {
if (Controllers[Channel].Present && Controllers[Channel].RawData) {
if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]); }
} else {
if ((m_PifRam[CurPos] & 0xC0) == 0)
{
if (Channel < 4)
{
if (Controllers[Channel].Present && Controllers[Channel].RawData)
{
if (g_Plugins->Control()->ControllerCommand)
{
g_Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]);
}
}
else
{
ProcessControllerCommand(Channel,&m_PifRam[CurPos]);
}
} else if (Channel == 4) {
}
else if (Channel == 4)
{
EepromCommand(&m_PifRam[CurPos]);
} else {
}
else
{
if (bShowPifRamErrors())
{
g_Notify->DisplayError(L"Command on channel 5?");
@ -205,15 +250,23 @@ void CPifRam::PifRamWrite (void) {
}
CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1;
Channel += 1;
} else {
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]); }
}
else
{
if (bShowPifRamErrors())
{
g_Notify->DisplayError(L"Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]);
}
CurPos = 0x40;
}
break;
}
}
m_PifRam[0x3F] = 0;
if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(-1,NULL); }
if (g_Plugins->Control()->ControllerCommand)
{
g_Plugins->Control()->ControllerCommand(-1,NULL);
}
}
void CPifRam::SI_DMA_READ (void)
@ -233,16 +286,24 @@ void CPifRam::SI_DMA_READ (void)
PifRamRead();
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
if ((int)SI_DRAM_ADDR_REG < 0) {
if ((int)SI_DRAM_ADDR_REG < 0)
{
int count, RdramPos;
RdramPos = (int)SI_DRAM_ADDR_REG;
for (count = 0; count < 0x40; count++, RdramPos++) {
if (RdramPos < 0) { continue; }
for (count = 0; count < 0x40; count++, RdramPos++)
{
if (RdramPos < 0)
{
continue;
}
RDRAM[RdramPos ^3] = m_PifRam[count];
}
} else {
_asm {
}
else
{
_asm
{
mov edi, dword ptr [SI_DRAM_ADDR_REG]
mov edi, dword ptr [edi]
add edi, RDRAM
@ -267,13 +328,16 @@ void CPifRam::SI_DMA_READ (void)
}
}
if (LogOptions.LogPRDMAMemStores) {
if (LogOptions.LogPRDMAMemStores)
{
int count;
char HexData[100], AsciiData[100], Addon[20];
LogMessage("\tData DMAed to RDRAM:");
LogMessage("\t--------------------");
for (count = 0; count < 16; count ++ ) {
if ((count % 4) == 0) {
for (count = 0; count < 16; count ++ )
{
if ((count % 4) == 0)
{
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
@ -281,7 +345,8 @@ void CPifRam::SI_DMA_READ (void)
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(HexData,Addon);
if (((count + 1) % 4) != 0) {
if (((count + 1) % 4) != 0)
{
sprintf(Addon,"-");
strcat(HexData,Addon);
}
@ -291,16 +356,20 @@ void CPifRam::SI_DMA_READ (void)
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
if (((count + 1) % 4) == 0)
{
LogMessage("\t%s %s",HexData, AsciiData);
}
}
LogMessage("");
}
if (g_System->bDelaySI()) {
if (g_System->bDelaySI())
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
}
else
{
g_Reg->MI_INTR_REG |= MI_INTR_SI;
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
g_Reg->CheckInterrupts();
@ -324,16 +393,24 @@ void CPifRam::SI_DMA_WRITE (void)
SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
BYTE * RDRAM = g_MMU->Rdram();
if ((int)SI_DRAM_ADDR_REG < 0) {
if ((int)SI_DRAM_ADDR_REG < 0)
{
int count, RdramPos;
RdramPos = (int)SI_DRAM_ADDR_REG;
for (count = 0; count < 0x40; count++, RdramPos++) {
if (RdramPos < 0) { m_PifRam[count] = 0; continue; }
for (count = 0; count < 0x40; count++, RdramPos++)
{
if (RdramPos < 0)
{
m_PifRam[count] = 0; continue;
}
m_PifRam[count] = RDRAM[RdramPos ^3];
}
} else {
_asm {
}
else
{
_asm
{
mov ecx, dword ptr [SI_DRAM_ADDR_REG]
mov ecx, dword ptr [ecx]
add ecx, RDRAM
@ -358,14 +435,17 @@ void CPifRam::SI_DMA_WRITE (void)
}
}
if (LogOptions.LogPRDMAMemLoads) {
if (LogOptions.LogPRDMAMemLoads)
{
int count;
char HexData[100], AsciiData[100], Addon[20];
LogMessage("");
LogMessage("\tData DMAed to the Pif Ram:");
LogMessage("\t--------------------------");
for (count = 0; count < 16; count ++ ) {
if ((count % 4) == 0) {
for (count = 0; count < 16; count ++ )
{
if ((count % 4) == 0)
{
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
@ -373,7 +453,8 @@ void CPifRam::SI_DMA_WRITE (void)
m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1],
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(HexData,Addon);
if (((count + 1) % 4) != 0) {
if (((count + 1) % 4) != 0)
{
sprintf(Addon,"-");
strcat(HexData,Addon);
}
@ -383,7 +464,8 @@ void CPifRam::SI_DMA_WRITE (void)
m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] );
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
if (((count + 1) % 4) == 0)
{
LogMessage("\t%s %s",HexData, AsciiData);
}
}
@ -392,9 +474,12 @@ void CPifRam::SI_DMA_WRITE (void)
PifRamWrite();
if (g_System->bDelaySI()) {
if (g_System->bDelaySI())
{
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else {
}
else
{
g_Reg->MI_INTR_REG |= MI_INTR_SI;
g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT;
g_Reg->CheckInterrupts();
@ -405,48 +490,80 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
{
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
switch (Command[2]) {
switch (Command[2])
{
case 0x00: // check
case 0xFF: // reset & check ?
if ((Command[1] & 0x80) != 0) { break; }
if ((Command[1] & 0x80) != 0)
{
break;
}
if (bShowPifRamErrors())
{
if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[1] != 3) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[0] != 1)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
if (Controllers[Control].Present == TRUE) {
if (Command[1] != 3)
{
g_Notify->DisplayError(L"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) {
switch ( Controllers[Control].Plugin)
{
case PLUGIN_RUMBLE_PAK: Command[5] = 1; break;
case PLUGIN_MEMPAK: Command[5] = 1; break;
case PLUGIN_RAW: Command[5] = 1; break;
default: Command[5] = 0; break;
}
} else {
}
else
{
Command[1] |= 0x80;
}
break;
case 0x01: // read controller
if (bShowPifRamErrors())
{
if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[1] != 4) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[0] != 1)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
if (Controllers[Control].Present == FALSE) {
if (Command[1] != 4)
{
g_Notify->DisplayError(L"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 (LogOptions.LogControllerPak)
{
LogControllerPakData("Read: Before Gettting Results");
}
if (bShowPifRamErrors())
{
if (Command[0] != 3) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[1] != 33) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[0] != 3)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
if (Controllers[Control].Present == TRUE) {
if (Command[1] != 33)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
}
if (Controllers[Control].Present == TRUE)
{
DWORD address = ((Command[3] << 8) | Command[4] & 0xE0);
switch (Controllers[Control].Plugin) {
switch (Controllers[Control].Plugin)
{
case PLUGIN_RUMBLE_PAK:
memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20);
@ -458,44 +575,70 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
memset(&Command[5], 0, 0x20);
Command[0x25] = 0;
}
} else {
}
else
{
Command[1] |= 0x80;
}
if (LogOptions.LogControllerPak) { LogControllerPakData("Read: After Gettting Results"); }
if (LogOptions.LogControllerPak)
{
LogControllerPakData("Read: After Gettting Results");
}
break;
case 0x03: //write controller pak
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: Before Processing"); }
if (LogOptions.LogControllerPak)
{
LogControllerPakData("Write: Before Processing");
}
if (bShowPifRamErrors())
{
if (Command[0] != 35) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[1] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); }
if (Command[0] != 35)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
if (Controllers[Control].Present == TRUE) {
if (Command[1] != 1)
{
g_Notify->DisplayError(L"What am I meant to do with this Controller Command");
}
}
if (Controllers[Control].Present == TRUE)
{
DWORD address = ((Command[3] << 8) | Command[4] & 0xE0 );
switch (Controllers[Control].Plugin) {
switch (Controllers[Control].Plugin)
{
case PLUGIN_MEMPAK: Mempak::WriteTo(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break;
case PLUGIN_RUMBLE_PAK:
if ((address & 0xFFE0) == 0xC000 && g_Plugins->Control()->RumbleCommand != NULL) {
if ((address & 0xFFE0) == 0xC000 && g_Plugins->Control()->RumbleCommand != NULL)
{
g_Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5]));
}
default:
Command[0x25] = Mempak::CalculateCrc(&Command[5]);
}
} else {
}
else
{
Command[1] |= 0x80;
}
if (LogOptions.LogControllerPak) { LogControllerPakData("Write: After Processing"); }
if (LogOptions.LogControllerPak)
{
LogControllerPakData("Write: After Processing");
}
break;
default:
if (bShowPifRamErrors()) { g_Notify->DisplayError(L"Unknown ControllerCommand %d",Command[2]); }
if (bShowPifRamErrors())
{
g_Notify->DisplayError(L"Unknown ControllerCommand %d",Command[2]);
}
}
}
void CPifRam::ReadControllerCommand (int Control, BYTE * Command) {
CONTROL * Controllers = g_Plugins->Control()->PluginControllers();
switch (Command[2]) {
switch (Command[2])
{
case 0x01: // read controller
if (Controllers[Control].Present == TRUE)
{
@ -508,15 +651,19 @@ void CPifRam::ReadControllerCommand (int Control, BYTE * Command) {
}
break;
case 0x02: //read from controller pack
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
if (Controllers[Control].Present == TRUE)
{
switch (Controllers[Control].Plugin)
{
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
}
}
break;
case 0x03: //write controller pak
if (Controllers[Control].Present == TRUE) {
switch (Controllers[Control].Plugin) {
if (Controllers[Control].Present == TRUE)
{
switch (Controllers[Control].Plugin)
{
case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break;
}
}
@ -532,8 +679,10 @@ void CPifRam::LogControllerPakData (char * Description)
char HexData[100], AsciiData[100], Addon[20];
LogMessage("\t%s:",Description);
LogMessage("\t------------------------------");
for (count = 0; count < 16; count ++ ) {
if ((count % 4) == 0) {
for (count = 0; count < 16; count ++ )
{
if ((count % 4) == 0)
{
sprintf(HexData,"\0");
sprintf(AsciiData,"\0");
}
@ -541,22 +690,28 @@ void CPifRam::LogControllerPakData (char * Description)
PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1],
PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3] );
strcat(HexData,Addon);
if (((count + 1) % 4) != 0) {
if (((count + 1) % 4) != 0)
{
sprintf(Addon,"-");
strcat(HexData,Addon);
}
Addon[0] = 0;
for (count2 = 0; count2 < 4; count2++) {
if (PIF_Ram[(count << 2) + count2] < 30) {
for (count2 = 0; count2 < 4; count2++)
{
if (PIF_Ram[(count << 2) + count2] < 30)
{
strcat(Addon,".");
} else {
}
else
{
sprintf(Addon,"%s%c",Addon,PIF_Ram[(count << 2) + count2]);
}
}
strcat(AsciiData,Addon);
if (((count + 1) % 4) == 0) {
if (((count + 1) % 4) == 0)
{
LogMessage("\t%s %s",HexData, AsciiData);
}
}

View File

@ -16,7 +16,10 @@ protected:
CPifRamSettings();
virtual ~CPifRamSettings();
inline bool bShowPifRamErrors ( void ) const { return m_bShowPifRamErrors; }
inline bool bShowPifRamErrors ( void ) const
{
return m_bShowPifRamErrors;
}
private:
static void RefreshSettings ( void * );

View File

@ -80,6 +80,7 @@ CP0registers::CP0registers(DWORD * _CP0) :
ERROREPC_REGISTER(_CP0[30]),
FAKE_CAUSE_REGISTER(_CP0[32])
{
}
Rdram_InterfaceReg::Rdram_InterfaceReg(DWORD * _RdramInterface) :
@ -95,6 +96,7 @@ Rdram_InterfaceReg::Rdram_InterfaceReg(DWORD * _RdramInterface) :
RDRAM_ADDR_SELECT_REG(_RdramInterface[8]),
RDRAM_DEVICE_MANUF_REG(_RdramInterface[9])
{
}
Mips_InterfaceReg::Mips_InterfaceReg(DWORD * _MipsInterface) :
@ -105,6 +107,7 @@ Mips_InterfaceReg::Mips_InterfaceReg(DWORD * _MipsInterface) :
MI_INTR_REG(_MipsInterface[2]),
MI_INTR_MASK_REG(_MipsInterface[3])
{
}
Video_InterfaceReg::Video_InterfaceReg(DWORD * _VideoInterface) :
@ -132,6 +135,7 @@ Video_InterfaceReg::Video_InterfaceReg(DWORD * _VideoInterface) :
VI_X_SCALE_REG(_VideoInterface[12]),
VI_Y_SCALE_REG(_VideoInterface[13])
{
}
AudioInterfaceReg::AudioInterfaceReg(DWORD * _AudioInterface) :
@ -142,6 +146,7 @@ AudioInterfaceReg::AudioInterfaceReg(DWORD * _AudioInterface) :
AI_DACRATE_REG(_AudioInterface[4]),
AI_BITRATE_REG(_AudioInterface[5])
{
}
PeripheralInterfaceReg::PeripheralInterfaceReg(DWORD * PeripheralInterface) :
@ -161,6 +166,7 @@ PeripheralInterfaceReg::PeripheralInterfaceReg(DWORD * PeripheralInterface) :
PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]),
PI_BSD_DOM2_RLS_REG(PeripheralInterface[12])
{
}
RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(DWORD * RdramInterface) :
@ -174,6 +180,7 @@ RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(DWORD * RdramInterface) :
RI_RERROR_REG(RdramInterface[6]),
RI_WERROR_REG(RdramInterface[7])
{
}
DisplayControlReg::DisplayControlReg(DWORD * _DisplayProcessor) :
@ -186,6 +193,7 @@ DisplayControlReg::DisplayControlReg(DWORD * _DisplayProcessor) :
DPC_PIPEBUSY_REG(_DisplayProcessor[6]),
DPC_TMEM_REG(_DisplayProcessor[7])
{
}
SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInterface) :
@ -200,6 +208,7 @@ SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInt
SP_PC_REG(_SignalProcessorInterface[8]),
SP_IBIST_REG(_SignalProcessorInterface[9])
{
}
Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) :
@ -208,6 +217,7 @@ Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) :
SI_PIF_ADDR_WR64B_REG(SerialInterface[2]),
SI_STATUS_REG(SerialInterface[3])
{
}
CRegisters::CRegisters(CN64System * System, CSystemEvents * SystemEvents) :
@ -276,23 +286,37 @@ void CRegisters::SetAsCurrentSystem ( void )
void CRegisters::CheckInterrupts ( void )
{
if (!m_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores) {
if (!m_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores)
{
MI_INTR_REG &= ~MI_INTR_AI;
MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI);
}
MI_INTR_REG |= (m_RspIntrReg & MI_INTR_SP);
MI_INTR_REG |= (m_GfxIntrReg & MI_INTR_DP);
if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) {
if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0)
{
FAKE_CAUSE_REGISTER |= CAUSE_IP2;
} else {
}
else
{
FAKE_CAUSE_REGISTER &= ~CAUSE_IP2;
}
if (( STATUS_REGISTER & STATUS_IE ) == 0 ) { return; }
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) { return; }
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return; }
if (( STATUS_REGISTER & STATUS_IE ) == 0 )
{
return;
}
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
return;
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
return;
}
if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) {
if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0)
{
if (m_FirstInterupt)
{
m_FirstInterupt = false;
@ -310,37 +334,50 @@ void CRegisters::DoAddressError ( BOOL DelaySlot, DWORD BadVaddr, BOOL FromRead)
if (bHaveDebugger())
{
g_Notify->DisplayError(L"AddressError");
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
g_Notify->DisplayError(L"EXL set in AddressError Exception");
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
g_Notify->DisplayError(L"ERL set in AddressError Exception");
}
}
if (FromRead) {
if (FromRead)
{
CAUSE_REGISTER = EXC_RADE;
} else {
}
else
{
CAUSE_REGISTER = EXC_WADE;
}
BAD_VADDR_REGISTER = BadVaddr;
if (DelaySlot) {
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
STATUS_REGISTER |= STATUS_EXL;
m_PROGRAM_COUNTER = 0x80000180;
}
void CRegisters::FixFpuLocations ( void ) {
if ((STATUS_REGISTER & STATUS_FR) == 0) {
for (int count = 0; count < 32; count ++) {
void CRegisters::FixFpuLocations ( void )
{
if ((STATUS_REGISTER & STATUS_FR) == 0)
{
for (int count = 0; count < 32; count ++)
{
m_FPR_S[count] = &m_FPR[count >> 1].F[count & 1];
m_FPR_D[count] = &m_FPR[count >> 1].D;
}
} else {
}
else
{
for (int count = 0; count < 32; count ++) {
m_FPR_S[count] = &m_FPR[count].F[1];
m_FPR_D[count] = &m_FPR[count].D;
@ -352,19 +389,24 @@ void CRegisters::DoBreakException ( BOOL DelaySlot)
{
if (bHaveDebugger())
{
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
g_Notify->DisplayError(L"EXL set in Break Exception");
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
g_Notify->DisplayError(L"ERL set in Break Exception");
}
}
CAUSE_REGISTER = EXC_BREAK;
if (DelaySlot) {
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
STATUS_REGISTER |= STATUS_EXL;
@ -375,20 +417,28 @@ void CRegisters::DoCopUnusableException ( BOOL DelaySlot, int Coprocessor )
{
if (bHaveDebugger())
{
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
g_Notify->DisplayError(L"EXL set in Break Exception");
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
g_Notify->DisplayError(L"ERL set in Break Exception");
}
}
CAUSE_REGISTER = EXC_CPU;
if (Coprocessor == 1) { CAUSE_REGISTER |= 0x10000000; }
if (DelaySlot) {
if (Coprocessor == 1)
{
CAUSE_REGISTER |= 0x10000000;
}
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
STATUS_REGISTER |= STATUS_EXL;
@ -398,18 +448,31 @@ void CRegisters::DoCopUnusableException ( BOOL DelaySlot, int Coprocessor )
BOOL CRegisters::DoIntrException ( BOOL DelaySlot )
{
if (( STATUS_REGISTER & STATUS_IE ) == 0 ) { return FALSE; }
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) { return FALSE; }
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) { return FALSE; }
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
LogMessage("%08X: Interupt Generated", m_PROGRAM_COUNTER );
if (( STATUS_REGISTER & STATUS_IE ) == 0 )
{
return FALSE;
}
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
return FALSE;
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
return FALSE;
}
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts)
{
LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER );
}
CAUSE_REGISTER = FAKE_CAUSE_REGISTER;
CAUSE_REGISTER |= EXC_INT;
if (DelaySlot) {
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
STATUS_REGISTER |= STATUS_EXL;
@ -424,21 +487,29 @@ void CRegisters::DoTLBReadMiss ( BOOL DelaySlot, DWORD BadVaddr )
CONTEXT_REGISTER &= 0xFF80000F;
CONTEXT_REGISTER |= (BadVaddr >> 9) & 0x007FFFF0;
ENTRYHI_REGISTER = (BadVaddr & 0xFFFFE000);
if ((STATUS_REGISTER & STATUS_EXL) == 0) {
if (DelaySlot) {
if ((STATUS_REGISTER & STATUS_EXL) == 0)
{
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
if (g_TLB->AddressDefined(BadVaddr))
{
m_PROGRAM_COUNTER = 0x80000180;
} else {
}
else
{
m_PROGRAM_COUNTER = 0x80000000;
}
STATUS_REGISTER |= STATUS_EXL;
} else {
}
else
{
if (bHaveDebugger())
{
g_Notify->DisplayError(L"TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,g_TLB->AddressDefined(BadVaddr)?"TRUE":"FALSE");
@ -451,22 +522,26 @@ void CRegisters::DoSysCallException ( BOOL DelaySlot)
{
if (bHaveDebugger())
{
if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_EXL ) != 0 )
{
g_Notify->DisplayError(L"EXL set in SysCall Exception");
}
if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) {
if (( STATUS_REGISTER & STATUS_ERL ) != 0 )
{
g_Notify->DisplayError(L"ERL set in SysCall Exception");
}
}
CAUSE_REGISTER = EXC_SYSCALL;
if (DelaySlot) {
if (DelaySlot)
{
CAUSE_REGISTER |= CAUSE_BD;
EPC_REGISTER = m_PROGRAM_COUNTER - 4;
} else {
}
else
{
EPC_REGISTER = m_PROGRAM_COUNTER;
}
STATUS_REGISTER |= STATUS_EXL;
m_PROGRAM_COUNTER = 0x80000180;
}

View File

@ -41,7 +41,8 @@ public:
};
//CPO register flags
enum {
enum
{
//Status Register
STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004,
STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400,
@ -83,7 +84,8 @@ enum {
};
//Float point control status register flags
enum {
enum
{
FPCSR_FS = 0x01000000, /* flush denorm to zero */
FPCSR_C = 0x00800000, /* condition bit */
FPCSR_CE = 0x00020000, /* cause: unimplemented operation */
@ -149,7 +151,8 @@ public:
};
//Mips interface flags
enum {
enum
{
MI_MODE_INIT = 0x0080, /* Bit 7: init mode */
MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */
MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */
@ -245,7 +248,8 @@ public:
DWORD & DPC_TMEM_REG;
};
enum {
enum
{
DPC_CLR_XBUS_DMEM_DMA = 0x0001, /* Bit 0: clear xbus_dmem_dma */
DPC_SET_XBUS_DMEM_DMA = 0x0002, /* Bit 1: set xbus_dmem_dma */
DPC_CLR_FREEZE = 0x0004, /* Bit 2: clear freeze */
@ -289,7 +293,8 @@ public:
DWORD & AI_BITRATE_REG;
};
enum {
enum
{
AI_STATUS_FIFO_FULL = 0x80000000, /* Bit 31: full */
AI_STATUS_DMA_BUSY = 0x40000000, /* Bit 30: busy */
};
@ -360,7 +365,8 @@ public:
};
//Signal Processor interface flags
enum {
enum
{
SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */
SP_SET_HALT = 0x00002, /* Bit 1: set halt */
SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */
@ -405,7 +411,8 @@ enum {
};
//Peripheral Interface flags
enum {
enum
{
PI_STATUS_DMA_BUSY = 0x01,
PI_STATUS_IO_BUSY = 0x02,
PI_STATUS_ERROR = 0x04,
@ -430,7 +437,8 @@ public:
};
//Serial Interface flags
enum {
enum
{
SI_STATUS_DMA_BUSY = 0x0001,
SI_STATUS_RD_BUSY = 0x0002,
SI_STATUS_DMA_ERROR = 0x0008,
@ -438,7 +446,8 @@ enum {
};
enum ROUNDING_MODE {
enum ROUNDING_MODE
{
ROUND_NEAR = _RC_NEAR,
ROUND_DOWN = _RC_DOWN,
ROUND_UP = _RC_UP,

View File

@ -14,17 +14,20 @@ CSram::CSram ( bool ReadOnly ) :
m_hFile(NULL),
m_ReadOnly(ReadOnly)
{
}
CSram::~CSram (void)
{
if (m_hFile) {
if (m_hFile)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
}
BOOL CSram::LoadSram (void) {
BOOL CSram::LoadSram (void)
{
CPath FileName;
FileName.SetDriveDirectory( g_Settings->LoadString(Directory_NativeSave).c_str());
@ -47,11 +50,14 @@ BOOL CSram::LoadSram (void) {
return true;
}
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) {
void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len)
{
DWORD dwRead;
if (m_hFile == NULL) {
if (!LoadSram()) {
if (m_hFile == NULL)
{
if (!LoadSram())
{
return;
}
}
@ -60,14 +66,17 @@ void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) {
}
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len) {
void CSram::DmaToSram(BYTE * Source, int StartOffset, int len)
{
if (m_ReadOnly)
{
return;
}
if (m_hFile == NULL) {
if (!LoadSram()) {
if (m_hFile == NULL)
{
if (!LoadSram())
{
return;
}
}

View File

@ -15,10 +15,12 @@ CSystemEvents::CSystemEvents(CN64System * System, CPlugins * Plugins) :
m_System(System),
m_Plugins(Plugins)
{
}
CSystemEvents::~CSystemEvents()
{
}
void CSystemEvents::QueueEvent(SystemEvent action)

View File

@ -10,7 +10,8 @@
****************************************************************************/
#pragma once
enum SystemEvent {
enum SystemEvent
{
SysEvent_ExecuteInterrupt,
SysEvent_GSButtonPressed,
SysEvent_ResetCPU_Soft,
@ -61,7 +62,10 @@ public:
void ExecuteEvents ( void );
void QueueEvent ( SystemEvent action);
inline const BOOL & DoSomething ( void ) const { return m_bDoSomething; }
inline const BOOL & DoSomething ( void ) const
{
return m_bDoSomething;
}
private:
CSystemEvents(void); // Disable default constructor

View File

@ -14,6 +14,7 @@ CSystemTimer::CSystemTimer( int & NextTimer ) :
m_NextTimer(NextTimer),
m_inFixTimer(false)
{
}
void CSystemTimer::Reset ( void )
@ -47,10 +48,14 @@ void CSystemTimer::SetTimer ( TimerType Type, DWORD Cycles, bool bRelative )
if (m_TimerDetatils[Type].Active)
{
m_TimerDetatils[Type].CyclesToTimer += Cycles; //Add to the timer
} else {
}
else
{
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
}
} else {
}
else
{
m_TimerDetatils[Type].CyclesToTimer = (__int64)Cycles - (__int64)m_NextTimer; //replace the new cycles
}
FixTimers();
@ -168,14 +173,17 @@ void CSystemTimer::TimerDone (void)
UpdateTimers();
/* DWORD LastTimer;
if (Profiling) {
if (Profiling)
{
LastTimer = StartTimer(Timer_Done);
}
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) {
if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts)
{
LogMessage("%08X: Timer Done (Type: %d CurrentTimer: %d)", *_PROGRAM_COUNTER, m_Current, *_Timer );
}
*/
switch (m_Current) {
switch (m_Current)
{
case CSystemTimer::CompareTimer:
g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP7;
g_Reg->CheckInterrupts();
@ -211,9 +219,12 @@ void CSystemTimer::TimerDone (void)
break;
case CSystemTimer::RspTimer:
g_SystemTimer->StopTimer(CSystemTimer::RspTimer);
try {
try
{
g_System->RunRSP();
} catch (...) {
}
catch (...)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
break;
@ -234,7 +245,8 @@ void CSystemTimer::TimerDone (void)
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
//CheckTimer();
/*if (Profiling) {
/*if (Profiling)
{
StartTimer(LastTimer);
}*/
}
@ -266,8 +278,14 @@ bool CSystemTimer::SaveAllowed ( void )
}
for (int i = 0; i < MaxTimer; i++)
{
if (i == CompareTimer) { continue; }
if (i == ViTimer) { continue; }
if (i == CompareTimer)
{
continue;
}
if (i == ViTimer)
{
continue;
}
if (m_TimerDetatils[i].Active)
{
return false;
@ -295,8 +313,16 @@ void CSystemTimer::LoadData ( void * file )
unzReadCurrentFile( file,&TimerDetailsSize,sizeof(TimerDetailsSize));
unzReadCurrentFile( file,&Entries,sizeof(Entries));
if (TimerDetailsSize != sizeof(TIMER_DETAILS)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return; }
if (Entries != sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0])) { g_Notify->BreakPoint(__FILEW__,__LINE__); return; }
if (TimerDetailsSize != sizeof(TIMER_DETAILS))
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
return;
}
if (Entries != sizeof(m_TimerDetatils)/sizeof(m_TimerDetatils[0]))
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
return;
}
unzReadCurrentFile(file,(void *)&m_TimerDetatils,sizeof(m_TimerDetatils));
unzReadCurrentFile(file,(void *)&m_LastUpdate,sizeof(m_LastUpdate));
@ -338,15 +364,33 @@ void CSystemTimer::RecordDifference( CLog &LogFile, const CSystemTimer& rSystemT
bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const
{
if (m_LastUpdate != rSystemTimer.m_LastUpdate) { return false; }
if (m_NextTimer != rSystemTimer.m_NextTimer) { return false; }
if (m_Current != rSystemTimer.m_Current) { return false; }
if (m_inFixTimer != rSystemTimer.m_inFixTimer) { return false; }
if (m_LastUpdate != rSystemTimer.m_LastUpdate)
{
return false;
}
if (m_NextTimer != rSystemTimer.m_NextTimer)
{
return false;
}
if (m_Current != rSystemTimer.m_Current)
{
return false;
}
if (m_inFixTimer != rSystemTimer.m_inFixTimer)
{
return false;
}
for (int i = 0; i < MaxTimer; i++)
{
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active) { return false; }
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer) { return false; }
if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
{
return false;
}
if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
{
return false;
}
}
return true;
}

View File

@ -15,7 +15,8 @@
class CSystemTimer
{
public:
enum TimerType {
enum TimerType
{
UnknownTimer,
CompareTimer,
SoftResetTimer,
@ -30,7 +31,8 @@ public:
MaxTimer
};
typedef struct {
typedef struct
{
bool Active;
__int64 CyclesToTimer;
} TIMER_DETAILS;

View File

@ -24,13 +24,16 @@ class CTLB :
protected CSystemRegisters
{
public:
typedef struct {
typedef struct
{
bool EntryDefined;
union {
union
{
unsigned long Value;
unsigned char A[4];
struct {
struct
{
unsigned zero : 13;
unsigned Mask : 12;
unsigned zero2 : 7;
@ -38,11 +41,13 @@ public:
} PageMask;
union {
union
{
unsigned long Value;
unsigned char A[4];
struct {
struct
{
unsigned ASID : 8;
unsigned Zero : 4;
unsigned G : 1;
@ -51,11 +56,13 @@ public:
} EntryHi;
union {
union
{
unsigned long Value;
unsigned char A[4];
struct {
struct
{
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
@ -66,11 +73,13 @@ public:
} EntryLo0;
union {
union
{
unsigned long Value;
unsigned char A[4];
struct {
struct
{
unsigned GLOBAL: 1;
unsigned V : 1;
unsigned D : 1;
@ -96,7 +105,10 @@ public:
//See if a VAddr has an entry to translate to a PAddr
bool AddressDefined ( DWORD VAddr );
const TLB_ENTRY & TlbEntry ( int Entry) const { return m_tlb[Entry]; }
const TLB_ENTRY & TlbEntry ( int Entry) const
{
return m_tlb[Entry];
}
bool PAddrToVAddr ( DWORD PAddr, DWORD & VAddr, DWORD & Index );
@ -106,7 +118,8 @@ public:
bool operator != (const CTLB& rTLB) const;
private:
typedef struct {
typedef struct
{
DWORD VSTART;
DWORD VEND;
DWORD PHYSSTART;

View File

@ -20,12 +20,14 @@ CTLB::CTLB(CTLB_CB * CallBack ):
WriteTrace(TraceTLB,__FUNCTION__ ": Done");
}
CTLB::~CTLB (void) {
CTLB::~CTLB (void)
{
WriteTrace(TraceTLB,__FUNCTION__ ": Start");
WriteTrace(TraceTLB,__FUNCTION__ ": Done");
}
void CTLB::Reset (bool InvalidateTLB) {
void CTLB::Reset (bool InvalidateTLB)
{
DWORD count;
for (count = 0; count < 64; count++)
@ -39,7 +41,9 @@ void CTLB::Reset (bool InvalidateTLB) {
{
m_tlb[count].EntryDefined = false;
}
} else {
}
else
{
for (count = 0; count < 32; count ++)
{
SetupTLB_Entry(count,false);
@ -47,10 +51,12 @@ void CTLB::Reset (bool InvalidateTLB) {
}
}
bool CTLB::AddressDefined ( DWORD VAddr) {
bool CTLB::AddressDefined ( DWORD VAddr)
{
DWORD i;
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) {
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF)
{
return true;
}
@ -66,7 +72,8 @@ bool CTLB::AddressDefined ( DWORD VAddr) {
return false;
}
void CTLB::Probe (void) {
void CTLB::Probe (void)
{
int Counter;
WriteTrace(TraceTLB,__FUNCTION__ ": Start");
@ -83,7 +90,8 @@ void CTLB::Probe (void) {
DWORD TlbValueMasked = TlbEntryHiValue & Mask;
DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask;
if (TlbValueMasked == EntryHiMasked) {
if (TlbValueMasked == EntryHiMasked)
{
if ((TlbEntryHiValue & 0x100) != 0 || //Global
((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid
{
@ -107,13 +115,15 @@ void CTLB::ReadEntry (void) {
g_Reg->ENTRYLO1_REGISTER = m_tlb[index].EntryLo1.Value;
}
void CTLB::WriteEntry (int index, bool Random) {
void CTLB::WriteEntry (int index, bool Random)
{
int FastIndx;
WriteTraceF(TraceTLB,__FUNCTION__ ": %02d %d %08X %08X %08X %08X ",index,Random,g_Reg->PAGE_MASK_REGISTER,g_Reg->ENTRYHI_REGISTER,g_Reg->ENTRYLO0_REGISTER,g_Reg->ENTRYLO1_REGISTER);
//Check to see if entry is unmapping it self
if (m_tlb[index].EntryDefined) {
if (m_tlb[index].EntryDefined)
{
FastIndx = index << 1;
if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART &&
*_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND &&
@ -134,16 +144,25 @@ void CTLB::WriteEntry (int index, bool Random) {
//Reset old addresses
if (m_tlb[index].EntryDefined)
{
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
if (!m_FastTlb[FastIndx].ValidEntry) { continue; }
if (!m_FastTlb[FastIndx].VALID) { continue; }
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
{
if (!m_FastTlb[FastIndx].ValidEntry)
{
continue;
}
if (!m_FastTlb[FastIndx].VALID)
{
continue;
}
if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER &&
m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_REGISTER)
{
if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER) {
if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER)
{
continue;
}
if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER) {
if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER)
{
continue;
}
}
@ -161,9 +180,13 @@ void CTLB::WriteEntry (int index, bool Random) {
m_CB->TLB_Changed();
}
void CTLB::SetupTLB_Entry (int index, bool Random) {
void CTLB::SetupTLB_Entry (int index, bool Random)
{
//Fix up Fast TLB entries
if (!m_tlb[index].EntryDefined) { return; }
if (!m_tlb[index].EntryDefined)
{
return;
}
int FastIndx = index << 1;
if (m_FastTlb[FastIndx].VALID)
@ -201,19 +224,24 @@ void CTLB::SetupTLB_Entry (int index, bool Random) {
m_FastTlb[FastIndx].Probed = false;
//Test both entries to see if they are valid
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) {
if (!m_FastTlb[FastIndx].VALID) {
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
{
if (!m_FastTlb[FastIndx].VALID)
{
m_FastTlb[FastIndx].ValidEntry = true;
continue;
}
if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) {
if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART)
{
continue;
}
if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) {
if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF)
{
continue;
}
if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) {
if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF)
{
continue;
}
@ -227,7 +255,10 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
{
for (int i = Index; i < 64; i++)
{
if (m_FastTlb[i].ValidEntry == false) { continue; }
if (m_FastTlb[i].ValidEntry == false)
{
continue;
}
if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND)
{
VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART);
@ -248,7 +279,10 @@ void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB)
LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No");
continue;
}
if (!m_tlb[i].EntryDefined) { continue; }
if (!m_tlb[i].EntryDefined)
{
continue;
}
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value)
{
LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value);
@ -272,8 +306,14 @@ bool CTLB::operator == (const CTLB& rTLB) const
{
for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++)
{
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) { return false; }
if (!m_tlb[i].EntryDefined) { continue; }
if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined)
{
return false;
}
if (!m_tlb[i].EntryDefined)
{
continue;
}
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value ||
m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value ||
m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value ||

View File

@ -48,7 +48,9 @@ CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) :
m_MemLocation[1] = m_MemLocation[0] + 1;
m_MemContents[0] = *m_MemLocation[0];
m_MemContents[1] = *m_MemLocation[1];
} else {
}
else
{
memset(m_MemLocation,0,sizeof(m_MemLocation));
memset(m_MemContents,0,sizeof(m_MemContents));
}
@ -189,7 +191,9 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
}
}
}
} else {
}
else
{
CurrentSection->m_EndSection = true;
break;
}
@ -265,12 +269,16 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
CPU_Message(__FUNCTION__ ": Jump End Block");
JumpSection->m_EndSection = true;
TargetPC = (DWORD)-1;
} else {
}
else
{
JumpSection->SetJumpAddress(TestPC, TargetPC,false);
}
JumpSection->SetDelaySlot();
SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC);
} else {
}
else
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
}
@ -331,7 +339,10 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
{
continue;
}
if (!CreateBlockLinkage(Section)) { return false; }
if (!CreateBlockLinkage(Section))
{
return false;
}
break;
}
if (CurrentSection->m_EndPC == (DWORD)-1)
@ -363,8 +374,14 @@ void CCodeBlock::LogSectionInfo ( void )
bool CCodeBlock::AnalyseBlock ( void )
{
if (!g_System->bLinkBlocks()) { return true; }
if (!CreateBlockLinkage(m_EnterSection)) { return false; }
if (!g_System->bLinkBlocks())
{
return true;
}
if (!CreateBlockLinkage(m_EnterSection))
{
return false;
}
DetermineLoops();
LogSectionInfo();
return true;
@ -380,7 +397,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
PermLoop = false;
OPCODE Command;
if (!g_MMU->LW_VAddr(PC, Command.Hex)) {
if (!g_MMU->LW_VAddr(PC, Command.Hex))
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
return false;
}
@ -432,7 +450,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8)
{
TargetPC = (DWORD)-1;
} else {
}
else
{
if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0))
{
PermLoop = true;
@ -447,14 +467,18 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8)
{
TargetPC = (DWORD)-1;
} else {
}
else
{
if (TargetPC == PC)
{
if (Command.rs == 0)
{
TargetPC = (DWORD)-1;
EndBlock = true;
} else {
}
else
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
{
PermLoop = true;
@ -509,7 +533,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8)
{
TargetPC = (DWORD)-1;
} else {
}
else
{
if (Command.rs != 0 || Command.rt != 0)
{
ContinuePC = PC + 8;
@ -529,7 +555,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8)
{
TargetPC = (DWORD)-1;
} else {
}
else
{
if (TargetPC == PC)
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
@ -549,7 +577,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
default:
if ( (Command.rs & 0x10 ) != 0 )
{
switch( Command.funct ) {
switch ( Command.funct )
{
case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI:
case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP:
break;
@ -560,7 +589,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
g_Notify->BreakPoint(__FILEW__,__LINE__);
return false;
}
} else {
}
else
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
return false;
}
@ -568,7 +599,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
}
break;
case R4300i_CP1:
switch (Command.fmt) {
switch (Command.fmt)
{
case R4300i_COP1_MF: case R4300i_COP1_DMF: case R4300i_COP1_CF: case R4300i_COP1_MT:
case R4300i_COP1_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D:
case R4300i_COP1_W: case R4300i_COP1_L:
@ -581,7 +613,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8)
{
TargetPC = (DWORD)-1;
} else {
}
else
{
if (TargetPC == PC)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
@ -674,14 +708,21 @@ bool CCodeBlock::Compile()
EnterCodeBlock();
if (g_SyncSystem) {
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B) { X86BreakPoint(__FILEW__,__LINE__); }
if (g_SyncSystem)
{
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B)
//{
// X86BreakPoint(__FILEW__,__LINE__);
//}
//MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
}
if (g_System->bLinkBlocks()) {
if (g_System->bLinkBlocks())
{
while (m_EnterSection->GenerateX86Code(NextTest()));
} else {
}
else
{
if (!m_EnterSection->GenerateX86Code(NextTest()))
{
return false;