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

View File

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

View File

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

View File

@ -20,7 +20,8 @@ LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
LOG_OPTIONS LogOptions,TempOptions; LOG_OPTIONS LogOptions,TempOptions;
HANDLE hLogFile = NULL; HANDLE hLogFile = NULL;
void EnterLogOptions(HWND hwndOwner) { void EnterLogOptions(HWND hwndOwner)
{
PROPSHEETPAGE psp[3]; PROPSHEETPAGE psp[3];
PROPSHEETHEADER psh; PROPSHEETHEADER psh;
@ -68,7 +69,8 @@ void EnterLogOptions(HWND hwndOwner) {
return; return;
} }
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) { void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
{
long lResult; long lResult;
HKEY hKeyResults = 0; HKEY hKeyResults = 0;
char String[200]; char String[200];
@ -77,9 +79,11 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) {
lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS,
&hKeyResults); &hKeyResults);
if (lResult == ERROR_SUCCESS) { if (lResult == ERROR_SUCCESS)
{
//LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog);
if (LogOptions->GenerateLog || AlwaysFill) { if (LogOptions->GenerateLog || AlwaysFill)
{
LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters);
LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters);
LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters);
@ -137,20 +141,26 @@ void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) {
LogOptions->LogUnknown = FALSE; LogOptions->LogUnknown = FALSE;
} }
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value) { void LoadLogSetting (HKEY hKey,char * String, BOOL * Value)
{
DWORD Type, dwResult, Bytes = 4; DWORD Type, dwResult, Bytes = 4;
long lResult; long lResult;
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); 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; *Value = (BOOL)dwResult;
} else { }
else
{
*Value = FALSE; *Value = FALSE;
} }
} }
LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) { LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
switch (uMsg) { {
switch (uMsg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); } if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); }
if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg,IDC_CP0_READ,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; return TRUE;
} }
void Log_LW (DWORD PC, DWORD VAddr) { void Log_LW (DWORD PC, DWORD VAddr)
if (!LogOptions.GenerateLog) { return; } {
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{ {
@ -196,12 +210,20 @@ void Log_LW (DWORD PC, DWORD VAddr) {
} }
DWORD Value; DWORD Value;
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) { return; } if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) { {
if (!LogOptions.LogRDRamRegisters) { return; } return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!LogOptions.LogRDRamRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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; 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 >= 0xA4000000 && VAddr <= 0xA4001FFC )
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) { {
if (!LogOptions.LogSPRegisters) { return; } return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
{
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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; 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; return;
} }
if ( VAddr == 0xA4080000) { if ( VAddr == 0xA4080000)
if (!LogOptions.LogSPRegisters) { return; } {
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value); LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return; return;
} }
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) { if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
if (!LogOptions.LogDPCRegisters) { return; } {
if (!LogOptions.LogDPCRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; 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 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; 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; case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return;
} }
} }
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) { if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
if (!LogOptions.LogMIPSInterface) { return; } {
if (!LogOptions.LogMIPSInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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 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; case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return;
} }
} }
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) { if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
if (!LogOptions.LogVideoInterface) { return; } {
if (!LogOptions.LogVideoInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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; 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; case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return;
} }
} }
if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) { if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
if (!LogOptions.LogAudioInterface) { return; } {
if (!LogOptions.LogAudioInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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; 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; case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return;
} }
} }
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) { if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
if (!LogOptions.LogPerInterface) { return; } {
if (!LogOptions.LogPerInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); 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 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 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; 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; case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return;
} }
} }
if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) { if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
if (!LogOptions.LogRDRAMInterface) { return; } {
if (!LogOptions.LogRDRAMInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; 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 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; 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; case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return;
} }
} }
if ( VAddr == 0xA4800000) { if ( VAddr == 0xA4800000)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800004) { if ( VAddr == 0xA4800004)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800010) { if ( VAddr == 0xA4800010)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr == 0xA4800018) { if ( VAddr == 0xA4800018)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return; return;
} }
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) { return; } if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 )
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) { {
if (!LogOptions.LogPRDirectMemLoads) { return; } return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!LogOptions.LogPRDirectMemLoads)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return; return;
} }
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) { return; } if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize()))
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) { {
if (!LogOptions.LogRomHeader) { return; } return;
}
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
{
if (!LogOptions.LogRomHeader)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value); g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr) { switch (VAddr)
{
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; 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 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; 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; return;
} }
if (!LogOptions.LogUnknown) { return; } if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
} }
void __cdecl LogMessage (char * Message, ...) { void __cdecl LogMessage (char * Message, ...)
{
DWORD dwWritten; DWORD dwWritten;
char Msg[400]; char Msg[400];
va_list ap; va_list ap;
if(!g_Settings->LoadBool(Debugger_Enabled)) { return; } if (!g_Settings->LoadBool(Debugger_Enabled))
if(hLogFile == NULL) { return; } {
return;
}
if (hLogFile == NULL)
{
return;
}
va_start( ap, Message ); va_start( ap, Message );
vsprintf( Msg, Message, ap ); vsprintf( Msg, Message, ap );
@ -400,8 +505,12 @@ void __cdecl LogMessage (char * Message, ...) {
WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL ); WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
} }
void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) { void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
if (!LogOptions.GenerateLog) { return; } {
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{ {
@ -417,10 +526,18 @@ void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) {
VAddr = PAddr + 0xA0000000; VAddr = PAddr + 0xA0000000;
} }
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) { return; } if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) { {
if (!LogOptions.LogRDRamRegisters) { return; } return;
switch (VAddr) { }
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 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 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; 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; 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 ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C)
if (!LogOptions.LogSPRegisters) { return; } {
switch (VAddr) { if (!LogOptions.LogSPRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; 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 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; 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; case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return;
} }
} }
if ( VAddr == 0xA4080000) { if ( VAddr == 0xA4080000)
if (!LogOptions.LogSPRegisters) { return; } {
if (!LogOptions.LogSPRegisters)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return;
} }
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) { if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
if (!LogOptions.LogDPCRegisters) { return; } {
switch (VAddr) { if (!LogOptions.LogDPCRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; 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 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; 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 ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
if (!LogOptions.LogDPSRegisters) { return; } {
switch (VAddr) { if (!LogOptions.LogDPSRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; 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 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; 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 ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
if (!LogOptions.LogMIPSInterface) { return; } {
switch (VAddr) { 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 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 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 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; case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return;
} }
} }
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) { if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
if (!LogOptions.LogVideoInterface) { return; } {
switch (VAddr) { if (!LogOptions.LogVideoInterface)
{
return;
}
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; 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 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; 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 ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
if (!LogOptions.LogAudioInterface) { return; } {
switch (VAddr) { if (!LogOptions.LogAudioInterface)
{
return;
}
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; 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 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; 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 ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
if (!LogOptions.LogPerInterface) { return; } {
switch (VAddr) { if (!LogOptions.LogPerInterface)
{
return;
}
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; 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 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; 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; case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return;
} }
} }
if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) { if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C)
if (!LogOptions.LogRDRAMInterface) { return; } {
switch (VAddr) { if (!LogOptions.LogRDRAMInterface)
{
return;
}
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; 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 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; 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; case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return;
} }
} }
if ( VAddr == 0xA4800000) { if ( VAddr == 0xA4800000)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return;
} }
if ( VAddr == 0xA4800004) { if ( VAddr == 0xA4800004)
if (LogOptions.LogPRDMAOperations) { {
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); 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; LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return;
} }
if ( VAddr == 0xA4800010) { if ( VAddr == 0xA4800010)
if (LogOptions.LogPRDMAOperations) { {
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); 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; LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return;
} }
if ( VAddr == 0xA4800018) { if ( VAddr == 0xA4800018)
if (!LogOptions.LogSerialInterface) { return; } {
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return;
} }
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) { if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
if (!LogOptions.LogPRDirectMemStores) { return; } {
if (!LogOptions.LogPRDirectMemStores)
{
return;
}
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
return; return;
} }
if (!LogOptions.LogUnknown) { return; } if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr );
} }
LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) { LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
switch (uMsg) { {
switch (uMsg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); } if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); }
if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg,IDC_DIRECT_WRITE,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); } if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg,IDC_CONT_PAK,BST_CHECKED); }
break; break;
case WM_NOTIFY: 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.LogPRDMAOperations = IsDlgButtonChecked(hDlg,IDC_SI_DMA) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg,IDC_DIRECT_WRITE) == 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; 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; return TRUE;
} }
LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) { LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
switch (uMsg) { {
switch (uMsg)
{
case WM_INITDIALOG: case WM_INITDIALOG:
if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); } if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); }
if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg,IDC_SP_REG,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); } if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg,IDC_SI_REG,BST_CHECKED); }
break; break;
case WM_NOTIFY: 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.LogRDRamRegisters = IsDlgButtonChecked(hDlg,IDC_RDRAM) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg,IDC_SP_REG) == 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; 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; return TRUE;
} }
void SaveLogSetting (HKEY hKey,char * String, BOOL Value) { void SaveLogSetting (HKEY hKey,char * String, BOOL Value)
{
DWORD StoreValue = Value; DWORD StoreValue = Value;
RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD)); RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD));
} }
void SaveLogOptions (void) { void SaveLogOptions (void)
{
long lResult; long lResult;
HKEY hKeyResults = 0; HKEY hKeyResults = 0;
DWORD Disposition = 0; DWORD Disposition = 0;
@ -684,11 +885,15 @@ void SaveLogOptions (void) {
void StartLog (void) void StartLog (void)
{ {
if (!LogOptions.GenerateLog) { if (!LogOptions.GenerateLog)
{
StopLog(); StopLog();
return; return;
} }
if (hLogFile) { return; } if (hLogFile)
{
return;
}
CPath LogFile(CPath::MODULE_DIRECTORY); CPath LogFile(CPath::MODULE_DIRECTORY);
LogFile.AppendDirectory(_T("Logs")); LogFile.AppendDirectory(_T("Logs"));
@ -699,8 +904,10 @@ void StartLog (void)
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN); SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
} }
void StopLog (void) { void StopLog (void)
if (hLogFile) { {
if (hLogFile)
{
CloseHandle(hLogFile); CloseHandle(hLogFile);
} }
hLogFile = NULL; hLogFile = NULL;

View File

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

View File

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

View File

@ -61,7 +61,9 @@ public:
if (m_hWnd) if (m_hWnd)
{ {
SetForegroundWindow((HWND)m_hWnd); SetForegroundWindow((HWND)m_hWnd);
} else { }
else
{
DWORD ThreadID; DWORD ThreadID;
ResetEvent(m_CreatedEvent); ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID); 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), // DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); // (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//} //}
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) { //DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0; // DWORD Count, Finish, Value = 0;
// Finish = strlen(HexValue); // Finish = strlen(HexValue);
// if (Finish > 8 ) { Finish = 8; } // if (Finish > 8 )
// for (Count = 0; Count < Finish; Count++){ // {
// Finish = 8;
// }
// for (Count = 0; Count < Finish; Count++
// {
// Value = (Value << 4); // Value = (Value << 4);
// switch( HexValue[Count] ) { // switch ( HexValue[Count] )
// {
// case '0': break; // case '0': break;
// case '1': Value += 1; break; // case '1': Value += 1; break;
// case '2': Value += 2; 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) //int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{ //{
// switch (uMsg) { // switch (uMsg)
// {
// case WM_INITDIALOG: // case WM_INITDIALOG:
// { // {
// CDumpMemory * _this = (CDumpMemory *)lParam; // 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_START_ADDR:
// case IDC_E_END_ADDR: // case IDC_E_END_ADDR:
// case IDC_E_ALT_PC: // case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) { // if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); // CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], szTmp2[20]; // TCHAR szTmp[20], szTmp2[20];
// DWORD Value; // DWORD Value;
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp)); // GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); // Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop) { Value = Stop; } // //if (Value > Stop)
// //if (Value < Start) { Value = Start; } // //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value); // sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) { // if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); // 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); // SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// } else { // }
// else
// {
// WORD NewSelStart, NewSelStop; // WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&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; // break;
@ -348,15 +371,21 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); // (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//} //}
// //
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) { //DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0; // DWORD Count, Finish, Value = 0;
// //
// Finish = strlen(HexValue); // 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); // Value = (Value << 4);
// switch( HexValue[Count] ) { // switch ( HexValue[Count] )
// {
// case '0': break; // case '0': break;
// case '1': Value += 1; break; // case '1': Value += 1; break;
// case '2': Value += 2; 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) //int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{ //{
// switch (uMsg) { // switch (uMsg)
// {
// case WM_INITDIALOG: // case WM_INITDIALOG:
// { // {
// CDumpMemory * _this = (CDumpMemory *)lParam; // 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_START_ADDR:
// case IDC_E_END_ADDR: // case IDC_E_END_ADDR:
// case IDC_E_ALT_PC: // case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) { // if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); // CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// //
// TCHAR szTmp[20], szTmp2[20]; // 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)); // GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); // Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop) { Value = Stop; } // //if (Value > Stop)
// //if (Value < Start) { Value = Start; } // //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value); // sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) { // if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); // 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); // SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// } else { // }
// else
// {
// WORD NewSelStart, NewSelStop; // WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&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; // break;

View File

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

View File

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

View File

@ -115,7 +115,8 @@ void CDebugTlb::RefreshTLBWindow (void)
int count; int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; 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); sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = count; item.iItem = count;
@ -128,66 +129,87 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1; OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0; OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) { if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList,&item); ListView_InsertItem(hList,&item);
} else { }
else
{
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
} }
if (tlb[count].EntryDefined) { if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].PageMask.Value); sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 1; item.iSubItem = 1;
OldItem.iSubItem = 1; OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
if (tlb[count].EntryDefined) { if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryHi.Value); sprintf(Output,"0x%08X",tlb[count].EntryHi.Value);
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 2; item.iSubItem = 2;
OldItem.iSubItem = 2; OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
if (tlb[count].EntryDefined) { if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value); sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value);
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 3; item.iSubItem = 3;
OldItem.iSubItem = 3; OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
if (tlb[count].EntryDefined) { if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value); sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value);
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 4; item.iSubItem = 4;
OldItem.iSubItem = 4; OldItem.iSubItem = 4;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
} }
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2); hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++) { for (count = 0; count < 64; count ++)
{
sprintf(Output,"0x%02X",count); sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = count; item.iItem = count;
@ -200,49 +222,65 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1; OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0; OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) { if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList,&item); item.iItem = ListView_InsertItem(hList,&item);
} else { }
else
{
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); ListView_SetItem(hList,&item);
} }
} }
if (FastTlb[count].ValidEntry) { if (FastTlb[count].ValidEntry)
{
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No"); sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 1; item.iSubItem = 1;
OldItem.iSubItem = 1; OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); 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"); sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 2; item.iSubItem = 2;
OldItem.iSubItem = 2; OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); 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, sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND); FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
} else { }
else
{
strcpy(Output,"................"); strcpy(Output,"................");
} }
item.iSubItem = 3; item.iSubItem = 3;
OldItem.iSubItem = 3; OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item); 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)); memset(m_CompareValid,0,sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar) { if (hScrlBar)
{
SCROLLINFO si; SCROLLINFO si;
si.cbSize = sizeof(si); si.cbSize = sizeof(si);
@ -121,7 +122,7 @@ LRESULT CDebugMemoryView::OnDestroy ( void )
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
{ {
switch(wID) switch (wID)
{ {
case IDC_REFRSH_MEM: case IDC_REFRSH_MEM:
RefreshMemory(true); RefreshMemory(true);
@ -162,7 +163,10 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem); LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem);
int Finish = strlen(strValue); int Finish = strlen(strValue);
if (Finish > 8) { Finish = 8; } if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0; DWORD Value = 0;
for (int i = 0; i < Finish; i++) 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); WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
} }
} else { }
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value)) if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value))
{ {
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); 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,"-"); m_MemoryList->SetItemText(LineNumber,i,"-");
} }
} }
} else { }
else
{
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 ) if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 )
{ {
m_MemoryList->SetItemText(LineNumber,0,Output); m_MemoryList->SetItemText(LineNumber,0,Output);
@ -286,11 +294,15 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
if (m_CurrentData[Pos] < 30) if (m_CurrentData[Pos] < 30)
{ {
strcat(Ascii,"."); strcat(Ascii,".");
} else { }
else
{
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]); sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn); strcat(Ascii,AsciiAddOn);
} }
} else { }
else
{
m_MemoryList->SetItemText(LineNumber,col,"**"); m_MemoryList->SetItemText(LineNumber,col,"**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE ); m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE );
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) ); m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) );
@ -393,7 +405,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{ {
ValidData = false; ValidData = false;
} }
} else { }
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{ {
ValidData = false; ValidData = false;
@ -428,7 +442,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{ {
ValidData = false; ValidData = false;
} }
} else { }
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW)) if (!g_MMU->LW_PAddr(Pos, word.UW))
{ {
ValidData = false; 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 ); Insert_MemoryLineDump ( count );
} }
} }

View File

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

View File

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

View File

@ -628,7 +628,8 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter (void )
/************************* Opcode functions *************************/ /************************* Opcode functions *************************/
void R4300iOp32::JAL (void) { void R4300iOp32::JAL (void)
{
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2);
_GPR[31].UW[0] = (*_PROGRAM_COUNTER) + 8; _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; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -650,14 +653,18 @@ void R4300iOp32::BEQ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BNE (void) { void R4300iOp32::BNE (void)
{
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -666,14 +673,17 @@ void R4300iOp32::BNE (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BLEZ (void) { void R4300iOp32::BLEZ (void) {
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -682,14 +692,18 @@ void R4300iOp32::BLEZ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BGTZ (void) { void R4300iOp32::BGTZ (void)
{
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -698,48 +712,61 @@ void R4300iOp32::BGTZ (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::ADDI (void) { void R4300iOp32::ADDI (void)
{
#ifdef Interpreter_StackTest #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; StackValue += (short)m_Opcode.immediate;
} }
#endif #endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate));
#ifdef Interpreter_StackTest #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]; StackValue = _GPR[m_Opcode.rt].W[0];
} }
#endif #endif
} }
void R4300iOp32::ADDIU (void) { void R4300iOp32::ADDIU (void)
{
#ifdef Interpreter_StackTest #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; StackValue += (short)m_Opcode.immediate;
} }
#endif #endif
_GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate));
#ifdef Interpreter_StackTest #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]; StackValue = _GPR[m_Opcode.rt].W[0];
} }
#endif #endif
} }
void R4300iOp32::SLTI (void) { void R4300iOp32::SLTI (void)
if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate)) { {
if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate))
{
_GPR[m_Opcode.rt].W[0] = 1; _GPR[m_Opcode.rt].W[0] = 1;
} else { }
else
{
_GPR[m_Opcode.rt].W[0] = 0; _GPR[m_Opcode.rt].W[0] = 0;
} }
} }
void R4300iOp32::SLTIU (void) { void R4300iOp32::SLTIU (void)
{
int imm32 = (short)m_Opcode.immediate; int imm32 = (short)m_Opcode.immediate;
__int64 imm64; __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; _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; _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; _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; _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); _GPR[m_Opcode.rt].W[0] = (long)((short)m_Opcode.offset << 16);
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rt == 29) { if (m_Opcode.rt == 29)
{
StackValue = _GPR[m_Opcode.rt].W[0]; StackValue = _GPR[m_Opcode.rt].W[0];
} }
#endif #endif
} }
void R4300iOp32::BEQL (void) { void R4300iOp32::BEQL (void)
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_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -779,14 +813,18 @@ void R4300iOp32::BEQL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BNEL (void) { void R4300iOp32::BNEL (void)
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_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -796,14 +834,18 @@ void R4300iOp32::BNEL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BLEZL (void) { void R4300iOp32::BLEZL (void)
if (_GPR[m_Opcode.rs].W[0] <= 0) { {
if (_GPR[m_Opcode.rs].W[0] <= 0)
{
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -813,14 +855,18 @@ void R4300iOp32::BLEZL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::BGTZL (void) { void R4300iOp32::BGTZL (void)
if (_GPR[m_Opcode.rs].W[0] > 0) { {
if (_GPR[m_Opcode.rs].W[0] > 0)
{
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -830,38 +876,54 @@ void R4300iOp32::BGTZL (void) {
m_NextInstruction = PERMLOOP_DO_DELAY; m_NextInstruction = PERMLOOP_DO_DELAY;
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; 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; 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 (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
if (bShowTLBMisses()) { {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LB TLB: %X",Address); g_Notify->DisplayError(L"LB TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].B[0]; _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; DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); } if ((Address & 1) != 0)
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) { {
if (bShowTLBMisses()) { 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); g_Notify->DisplayError(L"LH TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].HW[0]; _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].HW[0];
} }
} }
void R4300iOp32::LWL (void) { void R4300iOp32::LWL (void)
{
DWORD Offset, Address, Value; DWORD Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; 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 (!g_MMU->LW_VAddr((Address & ~3),Value))
{ {
if (bShowTLBMisses()) { if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LWL TLB: %X",Address); g_Notify->DisplayError(L"LWL TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
@ -880,51 +943,73 @@ void R4300iOp32::LWL (void) {
_GPR[m_Opcode.rt].W[0] += (int)(Value << LWL_SHIFT[Offset]); _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; 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) if (LogOptions.GenerateLog)
{ {
Log_LW((*_PROGRAM_COUNTER),Address); Log_LW((*_PROGRAM_COUNTER),Address);
} }
if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
if (bShowTLBMisses()) { {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LW TLB: %X",Address); g_Notify->DisplayError(L"LW TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; _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; 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 (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
if (bShowTLBMisses()) { {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LBU TLB: %X",Address); g_Notify->DisplayError(L"LBU TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UB[0]; _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; DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address,TRUE); } if ((Address & 1) != 0)
if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) { {
if (bShowTLBMisses()) { 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); g_Notify->DisplayError(L"LHU TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UHW[0]; _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UHW[0];
} }
} }
void R4300iOp32::LWR (void) { void R4300iOp32::LWR (void)
{
DWORD Offset, Address, Value; DWORD Offset, Address, Value;
Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; 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]); _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; 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 (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
if (bShowTLBMisses()) { {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LWU TLB: %X",Address); g_Notify->DisplayError(L"LWU TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UW[0]; _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; 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 (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
if (bShowTLBMisses()) { {
if (bShowTLBMisses())
{
g_Notify->DisplayError(L"LL TLB: %X",Address); g_Notify->DisplayError(L"LL TLB: %X",Address);
} }
TLB_READ_EXCEPTION(Address); TLB_READ_EXCEPTION(Address);
} else { }
else
{
_GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0];
(*_LLBit) = 1; (*_LLBit) = 1;
} }
} }
/********************** R4300i OpCodes: Special **********************/ /********************** 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); _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); _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); _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)); _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)); _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)); _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_NextInstruction = DELAY_SLOT;
m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; m_JumpToLocation = _GPR[m_Opcode.rs].UW[0];
_GPR[m_Opcode.rd].W[0] = (long)((*_PROGRAM_COUNTER) + 8); _GPR[m_Opcode.rd].W[0] = (long)((*_PROGRAM_COUNTER) + 8);
m_TestTimer = TRUE; 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]; _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]; _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]; _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]; _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]; _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]; _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0];
#ifdef Interpreter_StackTest #ifdef Interpreter_StackTest
if (m_Opcode.rd == 29) { if (m_Opcode.rd == 29)
{
StackValue = _GPR[m_Opcode.rd].W[0]; StackValue = _GPR[m_Opcode.rd].W[0];
} }
#endif #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]); _GPR[m_Opcode.rd].W[0] = ~(_GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]);
} }
void R4300iOp32::SPECIAL_SLT (void) { void R4300iOp32::SPECIAL_SLT (void)
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])
{
_GPR[m_Opcode.rd].W[0] = 1; _GPR[m_Opcode.rd].W[0] = 1;
} else { }
else
{
_GPR[m_Opcode.rd].W[0] = 0; _GPR[m_Opcode.rd].W[0] = 0;
} }
} }
void R4300iOp32::SPECIAL_SLTU (void) { void R4300iOp32::SPECIAL_SLTU (void)
if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0]) { {
if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0])
{
_GPR[m_Opcode.rd].W[0] = 1; _GPR[m_Opcode.rd].W[0] = 1;
} else { }
else
{
_GPR[m_Opcode.rd].W[0] = 0; _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)) 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 ???"); g_Notify->DisplayError(L"Should trap this ???");
@ -1073,9 +1198,11 @@ void R4300iOp32::SPECIAL_DSRA32 (void)
} }
/********************** R4300i OpCodes: RegImm **********************/ /********************** R4300i OpCodes: RegImm **********************/
void R4300iOp32::REGIMM_BLTZ (void) { void R4300iOp32::REGIMM_BLTZ (void)
{
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -1084,14 +1211,18 @@ void R4300iOp32::REGIMM_BLTZ (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::REGIMM_BGEZ (void) { void R4300iOp32::REGIMM_BGEZ (void)
{
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -1100,13 +1231,17 @@ void R4300iOp32::REGIMM_BGEZ (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::REGIMM_BLTZL (void) { void R4300iOp32::REGIMM_BLTZL (void)
if (_GPR[m_Opcode.rs].W[0] < 0) { {
if (_GPR[m_Opcode.rs].W[0] < 0)
{
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -1116,14 +1251,18 @@ void R4300iOp32::REGIMM_BLTZL (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::REGIMM_BGEZL (void) { void R4300iOp32::REGIMM_BGEZL (void)
if (_GPR[m_Opcode.rs].W[0] >= 0) { {
if (_GPR[m_Opcode.rs].W[0] >= 0)
{
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
@ -1133,15 +1272,19 @@ void R4300iOp32::REGIMM_BGEZL (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_NextInstruction = JUMP; m_NextInstruction = JUMP;
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
} }
void R4300iOp32::REGIMM_BLTZAL (void) { void R4300iOp32::REGIMM_BLTZAL (void)
{
m_NextInstruction = DELAY_SLOT; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -1150,15 +1293,19 @@ void R4300iOp32::REGIMM_BLTZAL (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
_GPR[31].W[0]= (long)((*_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; 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; m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4;
if ((*_PROGRAM_COUNTER) == m_JumpToLocation) if ((*_PROGRAM_COUNTER) == m_JumpToLocation)
{ {
@ -1167,7 +1314,9 @@ void R4300iOp32::REGIMM_BGEZAL (void) {
CInterpreterCPU::InPermLoop(); CInterpreterCPU::InPermLoop();
} }
} }
} else { }
else
{
m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; m_JumpToLocation = (*_PROGRAM_COUNTER) + 8;
} }
_GPR[31].W[0] = (long)((*_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]; _GPR[m_Opcode.rt].W[0] = (int)_CP0[m_Opcode.rd];
} }
void R4300iOp32::COP0_MT (void) { void R4300iOp32::COP0_MT (void)
{
if (LogOptions.LogCP0changes) 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]); 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)); 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 0: //Index
case 2: //EntryLo0 case 2: //EntryLo0
case 3: //EntryLo1 case 3: //EntryLo1
@ -1229,10 +1381,13 @@ void R4300iOp32::COP0_MT (void) {
g_SystemTimer->UpdateCompareTimer(); g_SystemTimer->UpdateCompareTimer();
break; break;
case 12: //Status 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]; _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0];
g_Reg->FixFpuLocations(); g_Reg->FixFpuLocations();
} else { }
else
{
_CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0];
} }
if ((_CP0[m_Opcode.rd] & 0x18) != 0 && g_Settings->LoadBool(Debugger_Enabled)) if ((_CP0[m_Opcode.rd] & 0x18) != 0 && g_Settings->LoadBool(Debugger_Enabled))
@ -1254,12 +1409,14 @@ void R4300iOp32::COP0_MT (void) {
} }
/************************** COP1 functions **************************/ /************************** COP1 functions **************************/
void R4300iOp32::COP1_MF (void) { void R4300iOp32::COP1_MF (void)
{
TEST_COP1_USABLE_EXCEPTION TEST_COP1_USABLE_EXCEPTION
_GPR[m_Opcode.rt].W[0] = *(int *)_FPR_S[m_Opcode.fs]; _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 TEST_COP1_USABLE_EXCEPTION
if (m_Opcode.fs != 31 && m_Opcode.fs != 0) 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]; _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 TEST_COP1_USABLE_EXCEPTION
*(__int64 *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; *(__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) CAudio::~CAudio (void)
{ {
} }
void CAudio::Reset ( 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); 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); 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); 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; m_SecondBuff += g_Reg->AI_LEN_REG;
} }
} }
} else { }
else
{
WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0"); WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0");
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy); g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt); g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
@ -92,7 +97,9 @@ void CAudio::InterruptTimerDone ( void )
{ {
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false); g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false);
m_SecondBuff = 0; m_SecondBuff = 0;
} else { }
else
{
if (g_Reg->m_AudioIntrReg == 0) if (g_Reg->m_AudioIntrReg == 0)
{ {
g_System->SyncToAudio(); 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); WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,g_Reg->AI_BITRATE_REG);
DWORD Frequency; DWORD Frequency;
switch (System) { switch (System)
{
case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break; case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break; case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break;
default: Frequency = 48681812 / (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; m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,8 @@
typedef std::map<DWORD, stdstr> StringMap; typedef std::map<DWORD, stdstr> StringMap;
class CMemoryLabel { class CMemoryLabel
{
// Variable dealing with Labels // Variable dealing with Labels
StringMap m_LabelList; StringMap m_LabelList;
int m_NewLabels; 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_FieldSerration;
DWORD m_TempValue; DWORD m_TempValue;
//Initilizing and reseting information about the memory system //Initializing and resetting information about the memory system
void FreeMemory ( void ); void FreeMemory ( void );
mutable char m_strLabelName[100]; mutable char m_strLabelName[100];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,12 +20,14 @@ CTLB::CTLB(CTLB_CB * CallBack ):
WriteTrace(TraceTLB,__FUNCTION__ ": Done"); WriteTrace(TraceTLB,__FUNCTION__ ": Done");
} }
CTLB::~CTLB (void) { CTLB::~CTLB (void)
{
WriteTrace(TraceTLB,__FUNCTION__ ": Start"); WriteTrace(TraceTLB,__FUNCTION__ ": Start");
WriteTrace(TraceTLB,__FUNCTION__ ": Done"); WriteTrace(TraceTLB,__FUNCTION__ ": Done");
} }
void CTLB::Reset (bool InvalidateTLB) { void CTLB::Reset (bool InvalidateTLB)
{
DWORD count; DWORD count;
for (count = 0; count < 64; count++) for (count = 0; count < 64; count++)
@ -39,7 +41,9 @@ void CTLB::Reset (bool InvalidateTLB) {
{ {
m_tlb[count].EntryDefined = false; m_tlb[count].EntryDefined = false;
} }
} else { }
else
{
for (count = 0; count < 32; count ++) for (count = 0; count < 32; count ++)
{ {
SetupTLB_Entry(count,false); 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; DWORD i;
if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) { if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF)
{
return true; return true;
} }
@ -66,7 +72,8 @@ bool CTLB::AddressDefined ( DWORD VAddr) {
return false; return false;
} }
void CTLB::Probe (void) { void CTLB::Probe (void)
{
int Counter; int Counter;
WriteTrace(TraceTLB,__FUNCTION__ ": Start"); WriteTrace(TraceTLB,__FUNCTION__ ": Start");
@ -83,7 +90,8 @@ void CTLB::Probe (void) {
DWORD TlbValueMasked = TlbEntryHiValue & Mask; DWORD TlbValueMasked = TlbEntryHiValue & Mask;
DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask; DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask;
if (TlbValueMasked == EntryHiMasked) { if (TlbValueMasked == EntryHiMasked)
{
if ((TlbEntryHiValue & 0x100) != 0 || //Global if ((TlbEntryHiValue & 0x100) != 0 || //Global
((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid ((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; 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; 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); 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 //Check to see if entry is unmapping it self
if (m_tlb[index].EntryDefined) { if (m_tlb[index].EntryDefined)
{
FastIndx = index << 1; FastIndx = index << 1;
if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART && if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART &&
*_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND && *_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND &&
@ -134,16 +144,25 @@ void CTLB::WriteEntry (int index, bool Random) {
//Reset old addresses //Reset old addresses
if (m_tlb[index].EntryDefined) if (m_tlb[index].EntryDefined)
{ {
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
if (!m_FastTlb[FastIndx].ValidEntry) { continue; } {
if (!m_FastTlb[FastIndx].VALID) { continue; } if (!m_FastTlb[FastIndx].ValidEntry)
{
continue;
}
if (!m_FastTlb[FastIndx].VALID)
{
continue;
}
if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER && if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER &&
m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_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; 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; continue;
} }
} }
@ -161,9 +180,13 @@ void CTLB::WriteEntry (int index, bool Random) {
m_CB->TLB_Changed(); 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 //Fix up Fast TLB entries
if (!m_tlb[index].EntryDefined) { return; } if (!m_tlb[index].EntryDefined)
{
return;
}
int FastIndx = index << 1; int FastIndx = index << 1;
if (m_FastTlb[FastIndx].VALID) if (m_FastTlb[FastIndx].VALID)
@ -201,19 +224,24 @@ void CTLB::SetupTLB_Entry (int index, bool Random) {
m_FastTlb[FastIndx].Probed = false; m_FastTlb[FastIndx].Probed = false;
//Test both entries to see if they are valid //Test both entries to see if they are valid
for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) { for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++)
if (!m_FastTlb[FastIndx].VALID) { {
if (!m_FastTlb[FastIndx].VALID)
{
m_FastTlb[FastIndx].ValidEntry = true; m_FastTlb[FastIndx].ValidEntry = true;
continue; continue;
} }
if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) { if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART)
{
continue; continue;
} }
if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) { if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF)
{
continue; continue;
} }
if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) { if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF)
{
continue; continue;
} }
@ -227,7 +255,10 @@ bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index )
{ {
for (int i = Index; i < 64; i++) 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) if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND)
{ {
VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART); 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"); LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No");
continue; 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) 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); 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++) 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 != rTLB.m_tlb[i].EntryDefined)
if (!m_tlb[i].EntryDefined) { continue; } {
return false;
}
if (!m_tlb[i].EntryDefined)
{
continue;
}
if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value || 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].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value ||
m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.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_MemLocation[1] = m_MemLocation[0] + 1;
m_MemContents[0] = *m_MemLocation[0]; m_MemContents[0] = *m_MemLocation[0];
m_MemContents[1] = *m_MemLocation[1]; m_MemContents[1] = *m_MemLocation[1];
} else { }
else
{
memset(m_MemLocation,0,sizeof(m_MemLocation)); memset(m_MemLocation,0,sizeof(m_MemLocation));
memset(m_MemContents,0,sizeof(m_MemContents)); memset(m_MemContents,0,sizeof(m_MemContents));
} }
@ -189,7 +191,9 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
} }
} }
} }
} else { }
else
{
CurrentSection->m_EndSection = true; CurrentSection->m_EndSection = true;
break; break;
} }
@ -265,12 +269,16 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
CPU_Message(__FUNCTION__ ": Jump End Block"); CPU_Message(__FUNCTION__ ": Jump End Block");
JumpSection->m_EndSection = true; JumpSection->m_EndSection = true;
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
JumpSection->SetJumpAddress(TestPC, TargetPC,false); JumpSection->SetJumpAddress(TestPC, TargetPC,false);
} }
JumpSection->SetDelaySlot(); JumpSection->SetDelaySlot();
SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC); SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC);
} else { }
else
{
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
} }
} }
@ -331,7 +339,10 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection )
{ {
continue; continue;
} }
if (!CreateBlockLinkage(Section)) { return false; } if (!CreateBlockLinkage(Section))
{
return false;
}
break; break;
} }
if (CurrentSection->m_EndPC == (DWORD)-1) if (CurrentSection->m_EndPC == (DWORD)-1)
@ -363,8 +374,14 @@ void CCodeBlock::LogSectionInfo ( void )
bool CCodeBlock::AnalyseBlock ( void ) bool CCodeBlock::AnalyseBlock ( void )
{ {
if (!g_System->bLinkBlocks()) { return true; } if (!g_System->bLinkBlocks())
if (!CreateBlockLinkage(m_EnterSection)) { return false; } {
return true;
}
if (!CreateBlockLinkage(m_EnterSection))
{
return false;
}
DetermineLoops(); DetermineLoops();
LogSectionInfo(); LogSectionInfo();
return true; return true;
@ -380,7 +397,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
PermLoop = false; PermLoop = false;
OPCODE Command; OPCODE Command;
if (!g_MMU->LW_VAddr(PC, Command.Hex)) { if (!g_MMU->LW_VAddr(PC, Command.Hex))
{
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
} }
@ -432,7 +450,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8) if (TargetPC == PC + 8)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0)) if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0))
{ {
PermLoop = true; PermLoop = true;
@ -447,14 +467,18 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8) if (TargetPC == PC + 8)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
if (TargetPC == PC) if (TargetPC == PC)
{ {
if (Command.rs == 0) if (Command.rs == 0)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
EndBlock = true; EndBlock = true;
} else { }
else
{
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
{ {
PermLoop = true; PermLoop = true;
@ -509,7 +533,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8) if (TargetPC == PC + 8)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
if (Command.rs != 0 || Command.rt != 0) if (Command.rs != 0 || Command.rt != 0)
{ {
ContinuePC = PC + 8; ContinuePC = PC + 8;
@ -529,7 +555,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
if (TargetPC == PC + 8) if (TargetPC == PC + 8)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
if (TargetPC == PC) if (TargetPC == PC)
{ {
if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt))
@ -549,7 +577,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
default: default:
if ( (Command.rs & 0x10 ) != 0 ) 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_TLBR: case R4300i_COP0_CO_TLBWI:
case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP: case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP:
break; break;
@ -560,7 +589,9 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
} }
} else { }
else
{
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
} }
@ -568,7 +599,8 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin
} }
break; break;
case R4300i_CP1: 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_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_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D:
case R4300i_COP1_W: case R4300i_COP1_L: 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) if (TargetPC == PC + 8)
{ {
TargetPC = (DWORD)-1; TargetPC = (DWORD)-1;
} else { }
else
{
if (TargetPC == PC) if (TargetPC == PC)
{ {
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
@ -674,14 +708,21 @@ bool CCodeBlock::Compile()
EnterCodeBlock(); EnterCodeBlock();
if (g_SyncSystem) { if (g_SyncSystem)
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B) { X86BreakPoint(__FILEW__,__LINE__); } {
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B)
//{
// X86BreakPoint(__FILEW__,__LINE__);
//}
//MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); //MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
} }
if (g_System->bLinkBlocks()) { if (g_System->bLinkBlocks())
{
while (m_EnterSection->GenerateX86Code(NextTest())); while (m_EnterSection->GenerateX86Code(NextTest()));
} else { }
else
{
if (!m_EnterSection->GenerateX86Code(NextTest())) if (!m_EnterSection->GenerateX86Code(NextTest()))
{ {
return false; return false;