This commit is contained in:
MELERIX 2015-11-17 01:34:39 -03:00
commit 6edfcbd77b
353 changed files with 47146 additions and 44311 deletions

8
.gitignore vendored
View File

@ -4,6 +4,14 @@
*.sdf
*.suo
*.user
# compiler-generated sources (MSVC, GCC)
*.asm
*.s
# assembled linker objects (GCC)
*.o
Thumbs.db
/Bin/Debug
/Bin/Debug64

BIN
Artwork/publisherlogo.psd Normal file

Binary file not shown.

View File

@ -1430,6 +1430,7 @@ Plugin Note=[video] unsupported
Good Name=Dezaemon 3D (J)
Internal Name=DEZAEMON3D
Status=Compatible
Save Type=Sram
[FD73F775-9724755A-C:50]
Good Name=Diddy Kong Racing (E) (M3) (V1.0)

View File

@ -318,7 +318,7 @@
#620# "Usar o Primeiro Tipo de Salvamento Usado"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -266,7 +266,7 @@
#620# "* открий първият използван тип"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Intergration Tab

View File

@ -318,7 +318,7 @@
#620# "Primer tipus de desat usat"
#621# "EEPROM de 4 kbits"
#622# "EEPROM de 16 kbits"
#623# "SRAM de 32kbytes"
#623# "SRAM"
#624# "FlashRAM de 128kbytes"
//Shell Integration Tab

View File

@ -88,6 +88,7 @@
#198# "插槽 8"
#199# "插槽 9"
#200# "插槽 10"
#201# "插槽 (%ws) 被选"
//Pop up Menu
#210# "运行游戏"
@ -224,7 +225,7 @@
#452# " 选择材质包目录"
//Options Dialog
#460# "当窗口处于非活动状态时暂停模拟器"
#460# "当模拟器窗口不是处于屏幕最上方,暂停模拟器"
#461# "载入ROM后切换为全屏模式"
#462# "隐藏高级设置"
#463# "记住已选择的金手指"
@ -255,7 +256,7 @@
#503# "自我修改码方案:"
#504# "默认存档容量:"
#505# "高级模块连接"
#506# "当ROM加载后,开始模拟"
#506# "当读取完ROM后开始模拟"
#507# "总是从 RDB 中覆盖默认设置"
#508# "自动压缩即时存档文件"
#509# "开启调试器"
@ -318,7 +319,7 @@
#620# "使用最初的存档类型"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -270,7 +270,7 @@
#620# "使用最初使用的存檔類型"
#621# "4-Kbit EEPROM"
#622# "16-Kbit EEPROM"
#623# "32-KByte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -266,7 +266,7 @@ RDB není pøítomno nebo volba dole 'pøepsat' je nezaškrtnutá"
#620# "* detek. první užívaný typ"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbajtù SRAM"
#623# "SRAM"
#624# "128-kbajtù flash RAM"
//Shell Intergration Tab

View File

@ -265,7 +265,7 @@
#620# "* Find den først anvendte type"
#621# "4kbit EEPROM"
#622# "16kbit EEPROM"
#623# "32kbyte SRAM"
#623# "SRAM"
#624# "128kbyte FlashRAM"
//Shell Intergration Tab

View File

@ -265,7 +265,7 @@
#620# "Gebruik de eerst gebruikte save"
#621# "4kbit EEPROM"
#622# "16kbit EEPROM"
#623# "32kbytes SRAM"
#623# "SRAM"
#624# "Flashram"
//Shell Integration Tab

View File

@ -88,6 +88,7 @@
#198# "Slot 8"
#199# "Slot 9"
#200# "Slot 10"
#201# "Save Slot (%ws) selected"
//Pop up Menu
#210# "Play Game"

View File

@ -277,7 +277,7 @@ no RDB is present, or 'overwrite' option below is unchecked"
#620# "* detect first-used type"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Intergration Tab

View File

@ -269,7 +269,7 @@
#620# "Käytä 1. tallennustyyppiä"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -318,7 +318,7 @@
#620# "Par défaut"
#621# "4 kbit EEPROM"
#622# "16 kbit EEPROM"
#623# "32 ko SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -269,7 +269,7 @@
#620# "Automatisch"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Intergration Tab

View File

@ -265,7 +265,7 @@
#620# "Automatisch"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Intergration Tab

View File

@ -266,7 +266,7 @@
#620# "Αυτόματος"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Integration Tab

View File

@ -269,7 +269,7 @@
#620# "Elõszöri mentés fajta használata"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -269,7 +269,7 @@
#620# "Riconosci automaticamente"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-ko SRAM"
#623# "SRAM"
#624# "128-ko flash RAM"
//Shell Intergration Tab

View File

@ -265,7 +265,7 @@
#620# "Riconosci il salvataggio automaticamente"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-ko SRAM"
#623# "SRAM"
#624# "128-ko flash RAM"
//Shell Intergration Tab

View File

@ -5,7 +5,7 @@
#1 # "Japanese" // LANGUAGE ID
#2 # "Nekokabu" // Author
#3 # "2.2" // Version
#4 # "2015/3/5" // Date
#4 # "2015/11/6" // Date
//About DLL Dialog
#5 # "現在の言語"
@ -317,7 +317,7 @@
#620# "自動検出"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -269,7 +269,7 @@
#620# "Naudoti pirmà naudotà tipà"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Intergration Tab

View File

@ -271,7 +271,7 @@ De vil ta effekt når ROM'en er resatt eller en ny er startet."
#620# "bruk den første brukte lagrings typen"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Integration Tab
@ -430,4 +430,4 @@ Skift plugin og restart spill nå?"
#2043# "Det kode navnet er allerede i bruk"
#2044# "Du har nådd det maksimumme antall koder for denne ROM'en"
//The End
//The End

View File

@ -269,7 +269,7 @@
#620# "Pierwszy u¿yty format"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -267,7 +267,7 @@
#620# "По умолчанию"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Integration Tab

View File

@ -318,7 +318,7 @@
#620# "Usar primer tipo de guardado usado"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab

View File

@ -269,7 +269,7 @@
#620# "Använd Första sparnings typ"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbytes SRAM"
#623# "SRAM"
#624# "Flash RAM"
//Shell Integration Tab
@ -422,5 +422,5 @@ Byta plugin och starta om nu?"
#2040# "Kan inte öppna filen på grund av att grafik pluginen inte är helt OK"
#2041# "Är du säker på att du vill ta bort det?"
#2042# "Borttagna fusk"
#2043# "Fuskets namn används redan"
#2043# "Fuskets namn används redan"
#2044# "Du har nåt max antalet av fusk för detta spelet"

View File

@ -267,7 +267,7 @@
#620# "Обирає програма"
#621# "4-kbit EEPROM"
#622# "16-kbit EEPROM"
#623# "32-kbyte SRAM"
#623# "SRAM"
#624# "128-kbyte flash RAM"
//Shell Integration Tab

Binary file not shown.

View File

@ -2,13 +2,13 @@
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration">
<PlatformToolset>v140_xp</PlatformToolset>
<PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<!-- All platforms settings -->
<PropertyGroup>
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
@ -192,15 +192,18 @@
</Xdcmake>
</ItemDefinitionGroup>
<!-- END common platform settings -->
<!-- Win32 -->
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<Lib>
<TargetMachine>MachineX86</TargetMachine>
</Lib>
<Link>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<!-- END Win32 -->
<!-- x64 -->
<PropertyGroup Condition="'$(Platform)'=='x64'">
<OutDir>$(SolutionDir)bin\$(Configuration)64\</OutDir>
@ -212,6 +215,9 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<Lib>
<TargetMachine>MachineX64</TargetMachine>
</Lib>
<Link>
<TargetMachine>MachineX64</TargetMachine>
</Link>

View File

@ -0,0 +1,145 @@
/***************************************************************************
* *
* XInput.h -- This module defines XBOX controller APIs *
* and constansts for the Windows platform. *
* *
* Copyright (c) Microsoft Corp. All rights reserved. *
* *
***************************************************************************/
#ifndef _XINPUT_H_
#define _XINPUT_H_
#include <windef.h>
// Current name of the DLL shipped in the same SDK as this header.
// The name reflects the current version
#define XINPUT_DLL_A "xinput9_1_0.dll"
#define XINPUT_DLL_W L"xinput9_1_0.dll"
#ifdef UNICODE
#define XINPUT_DLL XINPUT_DLL_W
#else
#define XINPUT_DLL XINPUT_DLL_A
#endif
//
// Device types available in XINPUT_CAPABILITIES
//
#define XINPUT_DEVTYPE_GAMEPAD 0x01
//
// Device subtypes available in XINPUT_CAPABILITIES
//
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
//
// Flags for XINPUT_CAPABILITIES
//
#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
//
// Constants for gamepad buttons
//
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
#define XINPUT_GAMEPAD_START 0x0010
#define XINPUT_GAMEPAD_BACK 0x0020
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
#define XINPUT_GAMEPAD_A 0x1000
#define XINPUT_GAMEPAD_B 0x2000
#define XINPUT_GAMEPAD_X 0x4000
#define XINPUT_GAMEPAD_Y 0x8000
//
// Gamepad thresholds
//
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
//
// Flags to pass to XInputGetCapabilities
//
#define XINPUT_FLAG_GAMEPAD 0x00000001
//
// Structures used by XInput APIs
//
typedef struct _XINPUT_GAMEPAD
{
WORD wButtons;
BYTE bLeftTrigger;
BYTE bRightTrigger;
SHORT sThumbLX;
SHORT sThumbLY;
SHORT sThumbRX;
SHORT sThumbRY;
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
typedef struct _XINPUT_STATE
{
DWORD dwPacketNumber;
XINPUT_GAMEPAD Gamepad;
} XINPUT_STATE, *PXINPUT_STATE;
typedef struct _XINPUT_VIBRATION
{
WORD wLeftMotorSpeed;
WORD wRightMotorSpeed;
} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
typedef struct _XINPUT_CAPABILITIES
{
BYTE Type;
BYTE SubType;
WORD Flags;
XINPUT_GAMEPAD Gamepad;
XINPUT_VIBRATION Vibration;
} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
//
// XInput APIs
//
#ifdef __cplusplus
extern "C" {
#endif
DWORD WINAPI XInputGetState
(
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
XINPUT_STATE* pState // [out] Receives the current state
);
DWORD WINAPI XInputSetState
(
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller
);
DWORD WINAPI XInputGetCapabilities
(
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
DWORD dwFlags, // [in] Input flags that identify the device type
XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities
);
DWORD WINAPI XInputGetDSoundAudioDeviceGuids
(
DWORD dwUserIndex, // [in] Index of the gamer associated with the device
GUID* pDSoundRenderGuid, // [out] DSound device ID for render
GUID* pDSoundCaptureGuid // [out] DSound device ID for capture
);
#ifdef __cplusplus
}
#endif
#endif //_XINPUT_H_

View File

@ -0,0 +1,127 @@
/*
Name: wx/msw/gccpriv.h
Purpose: MinGW/Cygwin definitions
Author: Vadim Zeitlin
Modified by:
Created:
RCS-ID: $Id: gccpriv.h 36155 2005-11-10 16:16:05Z ABX $
Copyright: (c) Vadim Zeitlin
Licence: wxWindows Licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_MSW_GCCPRIV_H_
#define _WX_MSW_GCCPRIV_H_
#if defined(__MINGW32__) && !defined(__GNUWIN32__)
#define __GNUWIN32__
#endif
#if defined(__MINGW32__) && ( ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) ) )
#include <_mingw.h>
#endif
#if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H )
#if __MINGW32_MAJOR_VERSION >= 1
#define HAVE_W32API_H
#endif
#elif defined( __CYGWIN__ ) && !defined( HAVE_W32API_H )
#if ( __GNUC__ > 2 )
#define HAVE_W32API_H
#endif
#endif
#if wxCHECK_WATCOM_VERSION(1,0)
#define HAVE_W32API_H
#endif
/* check for MinGW/Cygwin w32api version ( releases >= 0.5, only ) */
#if defined( HAVE_W32API_H )
#include <w32api.h>
#endif
/* Watcom can't handle defined(xxx) here: */
#if defined(__W32API_MAJOR_VERSION) && defined(__W32API_MINOR_VERSION)
#define wxCHECK_W32API_VERSION( major, minor ) \
( ( ( __W32API_MAJOR_VERSION > (major) ) \
|| ( __W32API_MAJOR_VERSION == (major) && __W32API_MINOR_VERSION >= (minor) ) ) )
#else
#define wxCHECK_W32API_VERSION( major, minor ) (0)
#endif
/* Cygwin / Mingw32 with gcc >= 2.95 use new windows headers which
are more ms-like (header author is Anders Norlander, hence the name) */
#if (defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE__)) && ((__GNUC__>2) || ((__GNUC__==2) && (__GNUC_MINOR__>=95)))
#ifndef wxUSE_NORLANDER_HEADERS
#define wxUSE_NORLANDER_HEADERS 1
#endif
#else
#ifndef wxUSE_NORLANDER_HEADERS
#define wxUSE_NORLANDER_HEADERS 0
#endif
#endif
/* "old" GNUWIN32 is the one without Norlander's headers: it lacks the
standard Win32 headers and we define the used stuff ourselves for it
in wx/msw/gnuwin32/extra.h */
#if defined(__GNUC__) && !wxUSE_NORLANDER_HEADERS
#define __GNUWIN32_OLD__
#endif
/* Cygwin 1.0 */
#if defined(__CYGWIN__) && ((__GNUC__==2) && (__GNUC_MINOR__==9))
#define __CYGWIN10__
#endif
/* Check for Mingw runtime version: */
#if defined(__MINGW32_MAJOR_VERSION) && defined(__MINGW32_MINOR_VERSION)
#define wxCHECK_MINGW32_VERSION( major, minor ) \
( ( ( __MINGW32_MAJOR_VERSION > (major) ) \
|| ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) )
#else
#define wxCHECK_MINGW32_VERSION( major, minor ) (0)
#endif
/* Mingw runtime 1.0-20010604 has some missing _tXXXX functions,
so let's define them ourselves: */
#if defined(__GNUWIN32__) && wxCHECK_W32API_VERSION( 1, 0 ) \
&& !wxCHECK_W32API_VERSION( 1, 1 )
#ifndef _tsetlocale
#if wxUSE_UNICODE
#define _tsetlocale _wsetlocale
#else
#define _tsetlocale setlocale
#endif
#endif
#ifndef _tgetenv
#if wxUSE_UNICODE
#define _tgetenv _wgetenv
#else
#define _tgetenv getenv
#endif
#endif
#ifndef _tfopen
#if wxUSE_UNICODE
#define _tfopen _wfopen
#else
#define _tfopen fopen
#endif
#endif
#endif
/* current (= before mingw-runtime 3.3) mingw32 headers forget to
define _puttchar, this will probably be fixed in the next versions but
for now do it ourselves
*/
#if defined( __MINGW32__ ) && \
!wxCHECK_MINGW32_VERSION(3,3) && !defined( _puttchar )
#ifdef wxUSE_UNICODE
#define _puttchar putwchar
#else
#define _puttchar puttchar
#endif
#endif
#endif
/* _WX_MSW_GCCPRIV_H_ */

View File

@ -94,7 +94,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(Root)Source\3rd Party\wx\lib\vc_lib\mswd&quot;;&quot;$(Root)Source\3rd Party\wx\include&quot;;&quot;$(Root)Source\3rd Party\wx\src\tiff\libtiff&quot;;&quot;$(Root)Source\3rd Party\wx\src\jpeg&quot;;&quot;$(Root)Source\3rd Party\wx\src\png&quot;;&quot;$(Root)Source\3rd Party\wx\src\zlib&quot;"
AdditionalIncludeDirectories="&quot;$(Root)Source\3rd Party\wx\lib\vc_lib\msw&quot;;&quot;$(Root)Source\3rd Party\wx\include&quot;;&quot;$(Root)Source\3rd Party\wx\src\tiff\libtiff&quot;;&quot;$(Root)Source\3rd Party\wx\src\jpeg&quot;;&quot;$(Root)Source\3rd Party\wx\src\png&quot;;&quot;$(Root)Source\3rd Party\wx\src\zlib&quot;"
PreprocessorDefinitions="_LIB;__WXMSW__;WXBUILDING;wxUSE_BASE=0"
PrecompiledHeaderThrough="wx/wxprec.h"
DisableSpecificWarnings="4005"
@ -2172,9 +2172,9 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Creating lib\vc_lib\mswu\wx\setup.h"
CommandLine="copy &quot;$(InputPath)&quot; lib\vc_lib\mswu\wx\setup.h&#x0D;&#x0A;"
Outputs="lib\vc_lib\mswu\wx\setup.h"
Description="Creating lib\vc_lib\msw\wx\setup.h"
CommandLine="copy &quot;$(InputPath)&quot; lib\vc_lib\msw\wx\setup.h&#x0D;&#x0A;"
Outputs="lib\vc_lib\msw\wx\setup.h"
/>
</FileConfiguration>
</File>
@ -2394,9 +2394,9 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Creating lib\vc_lib\mswud\wx\msw\rcdefs.h"
CommandLine="cl /EP /nologo &quot;$(InputPath)&quot; &gt; &quot;lib\vc_lib\mswud\wx\msw\rcdefs.h&quot;&#x0D;&#x0A;"
Outputs="lib\vc_lib\mswud\wx\msw\rcdefs.h"
Description="Creating lib\vc_lib\mswd\wx\msw\rcdefs.h"
CommandLine="cl /EP /nologo &quot;$(InputPath)&quot; &gt; &quot;lib\vc_lib\mswd\wx\msw\rcdefs.h&quot;&#x0D;&#x0A;"
Outputs="lib\vc_lib\mswd\wx\msw\rcdefs.h"
/>
</FileConfiguration>
<FileConfiguration
@ -2404,8 +2404,8 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Creating lib\vc_lib\mswu\wx\msw\rcdefs.h"
CommandLine="cl /EP /nologo &quot;$(InputPath)&quot; &gt; &quot;lib\vc_lib\mswu\wx\msw\rcdefs.h&quot;&#x0D;&#x0A;"
Description="Creating lib\vc_lib\msw\wx\msw\rcdefs.h"
CommandLine="cl /EP /nologo &quot;$(InputPath)&quot; &gt; &quot;lib\vc_lib\msw\wx\msw\rcdefs.h&quot;&#x0D;&#x0A;"
Outputs="lib\vc_lib\mswu\wx\msw\rcdefs.h"
/>
</FileConfiguration>
@ -3763,11 +3763,11 @@
>
</File>
<File
RelativePath="include\wx\splitter.h"
RelativePath="include\wx\persist\splitter.h"
>
</File>
<File
RelativePath="include\wx\persist\splitter.h"
RelativePath="include\wx\splitter.h"
>
</File>
<File
@ -3851,11 +3851,11 @@
>
</File>
<File
RelativePath="include\wx\toolbar.h"
RelativePath="include\wx\ribbon\toolbar.h"
>
</File>
<File
RelativePath="include\wx\ribbon\toolbar.h"
RelativePath="include\wx\toolbar.h"
>
</File>
<File
@ -3867,11 +3867,11 @@
>
</File>
<File
RelativePath="include\wx\toplevel.h"
RelativePath="include\wx\persist\toplevel.h"
>
</File>
<File
RelativePath="include\wx\persist\toplevel.h"
RelativePath="include\wx\toplevel.h"
>
</File>
<File
@ -3879,11 +3879,11 @@
>
</File>
<File
RelativePath="include\wx\treebook.h"
RelativePath="include\wx\persist\treebook.h"
>
</File>
<File
RelativePath="include\wx\persist\treebook.h"
RelativePath="include\wx\treebook.h"
>
</File>
<File

View File

@ -148,7 +148,19 @@
>
</File>
<File
RelativePath="src\zlib\gzio.c"
RelativePath=".\src\zlib\gzclose.c"
>
</File>
<File
RelativePath=".\src\zlib\gzlib.c"
>
</File>
<File
RelativePath=".\src\zlib\gzread.c"
>
</File>
<File
RelativePath=".\src\zlib\gzwrite.c"
>
</File>
<File

View File

@ -177,10 +177,18 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\SyncEvent.cpp"
>
</File>
<File
RelativePath="Trace.cpp"
>
</File>
<File
RelativePath=".\Util.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
@ -230,6 +238,10 @@
RelativePath=".\stdtypes.h"
>
</File>
<File
RelativePath=".\SyncEvent.h"
>
</File>
<File
RelativePath="Trace.h"
>
@ -238,6 +250,10 @@
RelativePath="TraceDefs.h"
>
</File>
<File
RelativePath=".\Util.h"
>
</File>
</Filter>
</Files>
<Globals>

View File

@ -43,7 +43,9 @@
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="SyncEvent.cpp" />
<ClCompile Include="Trace.cpp" />
<ClCompile Include="Util.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CriticalSection.h" />
@ -57,7 +59,9 @@
<ClInclude Include="std string.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="stdtypes.h" />
<ClInclude Include="SyncEvent.h" />
<ClInclude Include="Trace.h" />
<ClInclude Include="TraceDefs.h" />
<ClInclude Include="Util.h" />
</ItemGroup>
</Project>

View File

@ -41,6 +41,12 @@
<ClCompile Include="CriticalSection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SyncEvent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CriticalSection.h">
@ -82,5 +88,11 @@
<ClInclude Include="stdtypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SyncEvent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Util.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -79,20 +79,14 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags)
sa.bInheritHandle = (nOpenFlags & modeNoInherit) == 0;
// map creation flags
ULONG dwCreateFlag = 0;
ULONG dwCreateFlag = OPEN_EXISTING;
if (nOpenFlags & modeCreate)
{
if (nOpenFlags & modeNoTruncate)
dwCreateFlag = OPEN_ALWAYS;
else
dwCreateFlag = CREATE_ALWAYS;
dwCreateFlag = ((nOpenFlags & modeNoTruncate) != 0) ? OPEN_ALWAYS : CREATE_ALWAYS;
}
else
dwCreateFlag = OPEN_EXISTING;
// attempt file creation
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa,
dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{ //#define ERROR_PATH_NOT_FOUND 3L
//ULONG err = GetLastError();
@ -169,12 +163,12 @@ uint32_t CFile::Read(void* lpBuf, uint32_t nCount)
return 0; // avoid Win32 "null-read"
}
ULONG dwRead = 0;
DWORD dwRead = 0;
if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
{
return 0;
}
return (UINT)dwRead;
return (uint32_t)dwRead;
}
long CFile::Seek(long lOff, SeekPosition nFrom)

View File

@ -5,7 +5,8 @@
class CFileBase
{
public:
enum OpenFlags {
enum OpenFlags
{
modeRead = 0x0000,
modeWrite = 0x0001,
modeReadWrite = 0x0002,
@ -19,7 +20,8 @@ public:
modeNoTruncate = 0x2000,
};
enum Attribute {
enum Attribute
{
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,

View File

@ -2,7 +2,6 @@
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <TChar.h>
CLog::CLog (void ) :
m_FlushOnWrite(false),
@ -16,7 +15,7 @@ CLog::~CLog (void)
{
}
bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */)
bool CLog::Open( const char * FileName, LOG_OPEN_MODE mode /* = Log_New */)
{
if (FileName == NULL)
{
@ -34,14 +33,14 @@ bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */)
m_hLogFile.Close();
}
ULONG nOpenFlags = CFile::modeReadWrite | CFile::modeCreate;
uint32_t nOpenFlags = CFile::modeReadWrite | CFile::modeCreate;
if (mode == Log_Append) { nOpenFlags |= CFile::modeNoTruncate; }
if (!m_hLogFile.Open(File, nOpenFlags))
{
return false;
}
m_FileName = (LPCTSTR)File;
m_FileName = (const char *)File;
m_hLogFile.Seek(0,mode == Log_Append ? CFile::end : CFile::begin);
#ifdef _UNICODE
@ -64,7 +63,7 @@ void CLog::Close ( void )
}
}
void CLog::LogF(LPCTSTR Message, ...)
void CLog::LogF(const char * Message, ...)
{
va_list ap;
va_start( ap, Message );
@ -72,7 +71,7 @@ void CLog::LogF(LPCTSTR Message, ...)
va_end( ap );
}
void CLog::LogArgs(LPCTSTR Message, va_list & args )
void CLog::LogArgs(const char * Message, va_list & args )
{
if (!m_hLogFile.IsOpen()) { return; }
@ -112,14 +111,16 @@ void CLog::LogArgs(LPCTSTR Message, va_list & args )
}
if (buffer)
{
delete [] buffer;
}
#endif
}
void CLog::Log( LPCTSTR Message )
void CLog::Log( const char * Message )
{
if (!m_hLogFile.IsOpen()) { return; }
m_hLogFile.Write(Message,(ULONG)_tcslen(Message)*sizeof(TCHAR));
m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR));
if (m_FlushOnWrite)
{
m_hLogFile.Flush();
@ -128,7 +129,7 @@ void CLog::Log( LPCTSTR Message )
if (m_TruncateFileLog)
{
// check file size
ULONG FileSize = m_hLogFile.GetLength();
uint32_t FileSize = m_hLogFile.GetLength();
// if larger then max size then
if (FileSize > m_MaxFileSize)
{
@ -138,16 +139,17 @@ void CLog::Log( LPCTSTR Message )
FileSize = m_hLogFile.GetLength();
}
DWORD end = m_hLogFile.SeekToEnd();
uint32_t end = m_hLogFile.SeekToEnd();
// move to reduce size
m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin);
// Find next end of line
DWORD NextEnter = 0, dwRead = 0;
do {
uint32_t NextEnter = 0, dwRead = 0;
do
{
BYTE Data[300];
DWORD dwRead;
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,sizeof(Data));
if (dwRead == 0)
@ -168,9 +170,10 @@ void CLog::Log( LPCTSTR Message )
} while(dwRead != 0);
// copy content of log to the new file
DWORD ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter;
DWORD SizeToRead, WritePos = 0;
do {
uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter;
uint32_t SizeToRead, WritePos = 0;
do
{
enum { fIS_MvSize = 0x5000 };
unsigned char Data[fIS_MvSize + 1];
@ -179,7 +182,7 @@ void CLog::Log( LPCTSTR Message )
m_hLogFile.Seek(ReadPos,CFile::begin);
DWORD dwRead;
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,SizeToRead);
m_hLogFile.Seek(WritePos,CFile::begin);

View File

@ -1,11 +1,13 @@
#ifndef __LOG_CLASS__H__
#define __LOG_CLASS__H__
#pragma once
#include "File Class.h"
enum LOG_OPEN_MODE {
enum LOG_OPEN_MODE
{
Log_New, Log_Append
};
class CLog {
class CLog
{
enum { MB = 1024 * 1024 };
enum { MAX_FILE_SIZE = 10 * MB };
@ -13,24 +15,24 @@ class CLog {
bool m_FlushOnWrite;
stdstr m_FileName;
bool m_TruncateFileLog;
ULONG m_MaxFileSize;
ULONG m_FileChangeSize;
uint32_t m_MaxFileSize;
uint32_t m_FileChangeSize;
public:
CLog ( void );
~CLog ( void );
bool Open ( LPCTSTR FileName, LOG_OPEN_MODE mode = Log_New );
void Log ( LPCTSTR Message );
void LogF ( LPCTSTR Message, ... );
void LogArgs ( LPCTSTR Message, va_list & args );
bool Open ( const char * FileName, LOG_OPEN_MODE mode = Log_New );
void Log ( const char * Message );
void LogF ( const char * Message, ... );
void LogArgs ( const char * Message, va_list & args );
bool Empty ( void );
void Close ( void );
inline void SetMaxFileSize ( ULONG Size )
inline void SetMaxFileSize ( uint32_t Size )
{
m_MaxFileSize = Size;
m_FileChangeSize = (ULONG)(Size * 0.1);
m_FileChangeSize = (uint32_t)(Size * 0.1);
}
inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; }
inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; }
@ -38,5 +40,3 @@ public:
inline bool Flush ( void ) { return m_hLogFile.Flush(); }
inline const stdstr & FileName ( void ) const { return m_FileName; }
};
#endif

View File

@ -0,0 +1,31 @@
#include "stdafx.h"
SyncEvent::SyncEvent(bool bManualReset)
{
m_Event = CreateEvent(NULL, bManualReset, FALSE, NULL);
}
SyncEvent::~SyncEvent()
{
CloseHandle(m_Event);
}
void SyncEvent::Trigger()
{
SetEvent(m_Event);
}
bool SyncEvent::IsTriggered(int32_t iWaitTime)
{
return (WAIT_OBJECT_0 == WaitForSingleObject(m_Event,iWaitTime));
}
void SyncEvent::Reset()
{
ResetEvent(m_Event);
}
void * SyncEvent::GetHandle()
{
return m_Event;
}

21
Source/Common/SyncEvent.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
class SyncEvent
{
public:
enum { INFINITE_TIMEOUT = 0xFFFFFFFF };
SyncEvent(bool bManualReset = true);
~SyncEvent(void);
void Trigger (void);
bool IsTriggered (int32_t iWaitTime = 0);
void Reset();
void * GetHandle();
protected:
SyncEvent(const SyncEvent&); // Disable copy constructor
SyncEvent& operator=(const SyncEvent&); // Disable assignment
void * m_Event;
};

View File

@ -12,20 +12,20 @@ public:
CTraceLog()
{
}
~CTraceLog() { CloseTrace (); }
~CTraceLog() { CloseTrace(); }
CTraceModule * AddTraceModule ( CTraceModule * TraceModule );
CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule );
void CloseTrace ( void );
void WriteTrace ( TraceType Type, LPCTSTR Message );
void WriteTraceF ( TraceType Type, LPCTSTR strFormat, va_list args);
CTraceModule * AddTraceModule(CTraceModule * TraceModule);
CTraceModule * RemoveTraceModule(CTraceModule * TraceModule);
void CloseTrace(void);
void WriteTrace(TraceType Type, LPCTSTR Message);
void WriteTraceF(TraceType Type, LPCTSTR strFormat, va_list args);
};
CTraceModule * CTraceLog::AddTraceModule ( CTraceModule * TraceModule )
CTraceModule * CTraceLog::AddTraceModule(CTraceModule * TraceModule)
{
CGuard Guard(m_CS);
for (int i = 0; i < (int)m_Modules.size(); i++ )
for (int i = 0; i < (int)m_Modules.size(); i++)
{
if (m_Modules[i] == TraceModule)
{
@ -36,7 +36,7 @@ CTraceModule * CTraceLog::AddTraceModule ( CTraceModule * TraceModule )
return TraceModule;
}
CTraceModule * CTraceLog::RemoveTraceModule ( CTraceModule * TraceModule )
CTraceModule * CTraceLog::RemoveTraceModule(CTraceModule * TraceModule)
{
CGuard Guard(m_CS);
@ -51,38 +51,38 @@ CTraceModule * CTraceLog::RemoveTraceModule ( CTraceModule * TraceModule )
return NULL;
}
void CTraceLog::CloseTrace ( void)
void CTraceLog::CloseTrace(void)
{
CGuard Guard(m_CS);
for (int i = 0; i < (int)m_Modules.size(); i++ )
for (int i = 0; i < (int)m_Modules.size(); i++)
{
if(m_Modules[i])
if (m_Modules[i])
delete m_Modules[i];
}
m_Modules.clear();
}
void CTraceLog::WriteTraceF ( TraceType Type, LPCTSTR strFormat, va_list args)
void CTraceLog::WriteTraceF(TraceType Type, LPCTSTR strFormat, va_list args)
{
const int nMaxSize = 32*1024;
const int nMaxSize = 32 * 1024;
TCHAR pBuffer[nMaxSize];
_vsntprintf(pBuffer,nMaxSize,strFormat,args);
_vsntprintf(pBuffer, nMaxSize, strFormat, args);
pBuffer[nMaxSize - 1] = 0;
WriteTrace(Type,pBuffer);
WriteTrace(Type, pBuffer);
}
void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message)
void CTraceLog::WriteTrace(TraceType Type, LPCTSTR Message)
{
CGuard Guard(m_CS);
if (Type != TraceNone)
{
bool WriteToLog = false;
for (int i = 0; i < (int)m_Modules.size(); i++ )
for (int i = 0; i < (int)m_Modules.size(); i++)
{
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
{
WriteToLog = true;
break;
@ -99,58 +99,57 @@ void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message)
SYSTEMTIME sysTime;
::GetLocalTime(&sysTime);
nPos = _stprintf( pBuffer, _T("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d: "), sysTime.wYear,
sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds,
nPos = _stprintf(pBuffer, _T("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d: "), sysTime.wYear,
sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds,
::GetCurrentThreadId()
);
);
// show the debug level
if (Type == TraceNone) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("None : ")); }
else if ((Type & TraceError) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Error : ")); }
else if ((Type & TraceSettings) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Setting: ")); }
else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Gfx : ")); }
else if ((Type & TraceDebug) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Debug : ")); }
else if ((Type & TraceRecompiler)!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Recomp : ")); }
else if ((Type & TraceRSP )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("RSP : ")); }
else if ((Type & TraceTLB )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("TLB : ")); }
else if ((Type & TraceValidate )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Valid : ")); }
else if ((Type & TraceAudio )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Audio : ")); }
else { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Unknown: ")); }
if (Type == TraceNone) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("None : ")); }
else if ((Type & TraceError) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Error : ")); }
else if ((Type & TraceSettings) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Setting: ")); }
else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Gfx : ")); }
else if ((Type & TraceDebug) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Debug : ")); }
else if ((Type & TraceRecompiler) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Recomp : ")); }
else if ((Type & TraceRSP) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("RSP : ")); }
else if ((Type & TraceTLB) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("TLB : ")); }
else if ((Type & TraceValidate) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Valid : ")); }
else if ((Type & TraceAudio) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Audio : ")); }
else { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Unknown: ")); }
for (int i = 0; i < (int)m_Modules.size(); i++ )
for (int i = 0; i < (int)m_Modules.size(); i++)
{
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
{
m_Modules[i]->Write(pBuffer, false);
}
}
}
for (int i = 0; i < (int)m_Modules.size(); i++ )
for (int i = 0; i < (int)m_Modules.size(); i++)
{
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
if ((m_Modules[i]->GetTraceLevel() & Type) != 0)
{
m_Modules[i]->Write(Message, true);
}
}
}
CTraceLog & GetTraceObjet ( void )
CTraceLog & GetTraceObjet(void)
{
static CTraceLog TraceLog;
return TraceLog;
}
void WriteTrace (TraceType Type, LPCTSTR Message )
void WriteTrace(TraceType Type, LPCTSTR Message)
{
if (TraceClosed)
{
return;
}
GetTraceObjet().WriteTrace(Type,Message);
GetTraceObjet().WriteTrace(Type, Message);
}
void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... )
void WriteTraceF(TraceType Type, LPCTSTR strFormat, ...)
{
if (TraceClosed)
{
@ -158,11 +157,11 @@ void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... )
}
va_list args;
va_start(args, strFormat);
GetTraceObjet().WriteTraceF(Type,strFormat,args);
GetTraceObjet().WriteTraceF(Type, strFormat, args);
va_end(args);
}
CTraceModule * AddTraceModule ( CTraceModule * TraceModule )
CTraceModule * AddTraceModule(CTraceModule * TraceModule)
{
if (TraceClosed)
{
@ -172,52 +171,52 @@ CTraceModule * AddTraceModule ( CTraceModule * TraceModule )
return TraceModule;
}
CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule )
CTraceModule * RemoveTraceModule(CTraceModule * TraceModule)
{
return GetTraceObjet().RemoveTraceModule(TraceModule);
}
void CloseTrace ( void )
void CloseTrace(void)
{
TraceClosed = true;
GetTraceObjet().CloseTrace();
}
CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile ) :
m_FlushFile(FlushFile)
CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile) :
m_FlushFile(FlushFile)
{
m_hLogFile.SetFlush(false);
m_hLogFile.SetTruncateFile(true);
m_hLogFile.SetMaxFileSize(5 * MB);
m_hLogFile.Open(FileName,Log_Append);
m_hLogFile.Open(FileName, Log_Append);
}
CTraceFileLog::CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize) :
m_FlushFile(FlushFile)
CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize) :
m_FlushFile(FlushFile)
{
enum { MB = 1024 * 1024 };
enum { MB = 1024 * 1024 };
m_hLogFile.SetFlush(false);
m_hLogFile.SetTruncateFile(true);
if(dwMaxFileSize < 2048 && dwMaxFileSize > 2)
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
else
m_hLogFile.SetMaxFileSize(5 * MB);
if (dwMaxFileSize < 3 || dwMaxFileSize > 2047)
{ /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */
dwMaxFileSize = 5;
}
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
m_hLogFile.Open(FileName,eMode);
m_hLogFile.Open(FileName, eMode);
}
CTraceFileLog::~CTraceFileLog()
{
TraceClosed = true;
}
void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine )
void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine)
{
if (!m_hLogFile.IsOpen()) { return; }
CGuard Section(m_CriticalSection);
m_hLogFile.Log(Message);
if (EndOfLine)
@ -230,7 +229,16 @@ void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine )
}
}
void CTraceFileLog::SetFlushFile( bool bFlushFile )
void CTraceFileLog::SetFlushFile(bool bFlushFile)
{
m_FlushFile = bFlushFile;
}
void CDebugTraceLog::Write(const char * Message, bool EndOfLine)
{
OutputDebugString(Message);
if (EndOfLine)
{
OutputDebugString("\n");
}
}

View File

@ -1,5 +1,8 @@
#pragma once
#include "CriticalSection.h"
#include "Log Class.h"
class CTraceModule
{
TraceLevel m_Type;
@ -10,7 +13,7 @@ public:
inline void SetTraceLevel ( TraceLevel Type ) { m_Type = Type; }
inline TraceLevel GetTraceLevel ( void ) const { return m_Type; }
virtual void Write ( LPCTSTR Message, bool EndOfLine ) = 0;
virtual void Write ( const char * Message, bool EndOfLine ) = 0;
};
class CTraceFileLog : public CTraceModule
@ -22,25 +25,18 @@ class CTraceFileLog : public CTraceModule
bool m_FlushFile;
public:
CTraceFileLog (LPCTSTR FileName, bool FlushFile = true);
CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize = 5);
CTraceFileLog (const char * FileName, bool FlushFile = true);
CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5);
virtual ~CTraceFileLog ();
void Write ( LPCTSTR Message, bool EndOfLine );
void Write ( const char * Message, bool EndOfLine );
void SetFlushFile ( bool bFlushFile );
};
class CDebugTraceLog : public CTraceModule
{
public:
void Write ( LPCTSTR Message, bool EndOfLine )
{
OutputDebugString(Message);
if (EndOfLine)
{
OutputDebugString("\n");
}
}
void Write ( const char * Message, bool EndOfLine );
};
CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new

61
Source/Common/Util.cpp Normal file
View File

@ -0,0 +1,61 @@
#include "stdafx.h"
#include "Util.h"
#include <Tlhelp32.h>
void pjutil::Sleep(uint32_t timeout)
{
::Sleep(timeout);
}
bool pjutil::TerminatedExistingExe()
{
bool bTerminated = false;
bool AskedUser = false;
DWORD pid = GetCurrentProcessId();
HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (nSearch != INVALID_HANDLE_VALUE)
{
PROCESSENTRY32 lppe;
memset(&lppe, 0, sizeof(PROCESSENTRY32));
lppe.dwSize = sizeof(PROCESSENTRY32);
stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension();
if (Process32First(nSearch, &lppe))
{
do
{
if (_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 ||
lppe.th32ProcessID == pid)
{
continue;
}
if (!AskedUser)
{
AskedUser = true;
int res = MessageBox(NULL, stdstr_f("%s currently running\n\nTerminate pid %d now?", ModuleName.c_str(), lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION);
if (res != IDYES)
{
break;
}
}
HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID);
if (hHandle != NULL)
{
if (TerminateProcess(hHandle, 0))
{
bTerminated = true;
}
else
{
MessageBox(NULL, stdstr_f("Failed to terminate pid %d", lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s failed!",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION);
}
CloseHandle(hHandle);
}
} while (Process32Next(nSearch, &lppe));
}
CloseHandle(nSearch);
}
return bTerminated;
}

14
Source/Common/Util.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include "stdtypes.h"
class pjutil
{
public:
static void Sleep(uint32_t timeout);
static bool TerminatedExistingExe();
private:
pjutil(void); // Disable default constructor
pjutil(const pjutil&); // Disable copy constructor
pjutil& operator=(const pjutil&); // Disable assignment
};

View File

@ -1,22 +1,22 @@
// MD5.CC - source code for the C++/object oriented translation and
// MD5.CC - source code for the C++/object oriented translation and
// modification of MD5.
// Translation and modification (c) 1995 by Mordechai T. Abzug
// Translation and modification (c) 1995 by Mordechai T. Abzug
// This translation/ modification is provided "as is," without express or
// This translation/ modification is provided "as is," without express or
// implied warranty of any kind.
// The translator/ modifier does not claim (1) that MD5 will do what you think
// it does; (2) that this translation/ modification is accurate; or (3) that
// this software is "merchantible." (Language for this disclaimer partially
// The translator/ modifier does not claim (1) that MD5 will do what you think
// it does; (2) that this translation/ modification is accurate; or (3) that
// this software is "merchantible." (Language for this disclaimer partially
// copied from the disclaimer below).
/* based on:
MD5.H - header file for MD5C.C
MDDRIVER.C - test driver for MD2, MD4 and MD5
MD5.H - header file for MD5C.C
MDDRIVER.C - test driver for MD2, MD4 and MD5
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
@ -39,11 +39,7 @@ documentation and/or software.
*/
#if !defined(AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_)
#define AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_
/* sprintf() */
#include <stdio.h>
#pragma once
#include <string>
#include <functional>
@ -51,106 +47,102 @@ documentation and/or software.
struct MD5Digest
{
MD5Digest() { Reset(); }
unsigned char digest[16];
MD5Digest() { Reset(); }
unsigned char digest[16];
void Reset() { ::memset(digest, 0, sizeof(digest)); }
BOOL IsClear()
{
int isClear = 0;
for (int i=0; i < 16; i++)
isClear += digest[i];
return (isClear == 0);
}
std::string String ( void )
{
char s[33];
void Reset() { ::memset(digest, 0, sizeof(digest)); }
bool IsClear()
{
int isClear = 0;
for (int i=0; i < 16; i++)
{
isClear += digest[i];
}
return (isClear == 0);
}
std::string String ( void )
{
char s[33];
::memset(s, 0, sizeof(s));
::memset(s, 0, sizeof(s));
for (int i = 0; i < 16; i++)
{
sprintf(s+i*2, "%02X", digest[i]);
}
s[32]='\0';
return s;
}
for (int i = 0; i < 16; i++)
{
sprintf(s+i*2, "%02X", digest[i]);
}
s[32]='\0';
return s;
}
};
struct MD5Digest_less : std::binary_function<MD5Digest, MD5Digest, bool>
struct MD5Digest_less : std::binary_function<MD5Digest, MD5Digest, bool>
{
bool operator()(const MD5Digest& x, const MD5Digest& y) const
{
return (memcmp(x.digest, y.digest, sizeof(x.digest)) < 0);
}
bool operator()(const MD5Digest& x, const MD5Digest& y) const
{
return (memcmp(x.digest, y.digest, sizeof(x.digest)) < 0);
}
};
class MD5
class MD5
{
public:
// methods for controlled operation:
MD5 (); // simple initializer
~MD5 ();
void update (const unsigned char *input, unsigned int input_length);
void update (FILE *file);
void finalize ();
// methods for controlled operation:
MD5 (); // simple initializer
~MD5 ();
void update (const unsigned char *input, unsigned int input_length);
void update (FILE *file);
void finalize ();
// constructors for special circumstances. All these constructors finalize
// the MD5 context.
MD5 (CPath File); // digest File, finalize
MD5 (const unsigned char *string); // digest string, finalize
MD5 (FILE *file); // digest file, close, finalize
MD5 (const unsigned char *input, unsigned int input_length);
MD5 (const stdstr & string);
// constructors for special circumstances. All these constructors finalize
// the MD5 context.
MD5 (CPath File); // digest File, finalize
MD5 (const unsigned char *string); // digest string, finalize
MD5 (FILE *file); // digest file, close, finalize
MD5 (const unsigned char *input, unsigned int input_length);
MD5 (const stdstr & string);
// methods to acquire finalized result
void get_digest(MD5Digest& extdigest); //Digest into a digest structure
const unsigned char *raw_digest (); // digest as a 16-byte binary array
const char * hex_digest (); // digest as a 33-byte ascii-hex string
// methods to acquire finalized result
void get_digest(MD5Digest& extdigest); //Digest into a digest structure
const unsigned char *raw_digest (); // digest as a 16-byte binary array
const char * hex_digest (); // digest as a 33-byte ascii-hex string
private:
// first, some types:
typedef unsigned int uint4; // assumes integer is 4 words long
typedef unsigned short int uint2; // assumes short integer is 2 words long
typedef unsigned char uint1; // assumes char is 1 word long
// first, some types:
typedef unsigned int uint4; // assumes integer is 4 words long
typedef unsigned short int uint2; // assumes short integer is 2 words long
typedef unsigned char uint1; // assumes char is 1 word long
// next, the private data:
uint4 state[4];
uint4 count[2]; // number of *bits*, mod 2^64
uint1 buffer[64]; // input buffer
uint1 digest[16];
uint1 finalized;
stdstr m_hex_digest;
// next, the private data:
uint4 state[4];
uint4 count[2]; // number of *bits*, mod 2^64
uint1 buffer[64]; // input buffer
uint1 digest[16];
uint1 finalized;
stdstr m_hex_digest;
// last, the private methods, mostly static:
void init (); // called by all constructors
void transform (uint1 *buffer); // does the real update work. Note
// that length is implied to be 64.
// last, the private methods, mostly static:
void init (); // called by all constructors
void transform (uint1 *buffer); // does the real update work. Note
// that length is implied to be 64.
static void encode (uint1 *dest, uint4 *src, uint4 length);
static void decode (uint4 *dest, uint1 *src, uint4 length);
static void memcpy (uint1 *dest, uint1 *src, uint4 length);
static void memset (uint1 *start, uint1 val, uint4 length);
static inline uint4 rotate_left (uint4 x, uint4 n);
static inline uint4 F (uint4 x, uint4 y, uint4 z);
static inline uint4 G (uint4 x, uint4 y, uint4 z);
static inline uint4 H (uint4 x, uint4 y, uint4 z);
static inline uint4 I (uint4 x, uint4 y, uint4 z);
static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static void encode (uint1 *dest, uint4 *src, uint4 length);
static void decode (uint4 *dest, uint1 *src, uint4 length);
static void memcpy (uint1 *dest, uint1 *src, uint4 length);
static void memset (uint1 *start, uint1 val, uint4 length);
static inline uint4 rotate_left (uint4 x, uint4 n);
static inline uint4 F (uint4 x, uint4 y, uint4 z);
static inline uint4 G (uint4 x, uint4 y, uint4 z);
static inline uint4 H (uint4 x, uint4 y, uint4 z);
static inline uint4 I (uint4 x, uint4 y, uint4 z);
static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x,
uint4 s, uint4 ac);
};
#endif // !defined(AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_)

View File

@ -1,4 +1,5 @@
#include "stdafx.h"
#include <malloc.h>
#include <algorithm>
stdstr::stdstr()

View File

@ -51,5 +51,22 @@ public:
}
};
class stdwstr_f : public std::wstring
{
public:
stdwstr_f(const wchar_t * strFormat, ...)
{
va_list args;
va_start(args, strFormat);
wchar_t Msg[1000];
_vsnwprintf(Msg, sizeof(Msg) - 1, strFormat, args);
va_end(args);
this->assign(Msg);
}
};
typedef std::list<stdstr> strlist;
typedef strlist::iterator strlist_iter;

View File

@ -16,3 +16,4 @@
#include "Trace.h"
#include "md5.h"
#include "Smart Pointer.h"
#include "SyncEvent.h"

View File

@ -87,41 +87,17 @@ static int left_z, left_dzdy;
__inline int imul16(int x, int y) // (x * y) >> 16
{
return (((long long)x) * ((long long)y)) >> 16;
return ((int64_t)x * (int64_t)y) >> 16;
}
__inline int imul14(int x, int y) // (x * y) >> 14
{
return (((long long)x) * ((long long)y)) >> 14;
return ((int64_t)x * (int64_t)y) >> 14;
}
__inline int idiv16(int x, int y) // (x << 16) / y
{
//x = (((long long)x) << 16) / ((long long)y);
/*
eax = x;
ebx = y;
edx = x;
(x << 16) | ()
*/
#if !defined(__GNUC__) && !defined(NO_ASM)
__asm {
mov eax, x
mov ebx, y
mov edx,eax
sar edx,16
shl eax,16
idiv ebx
mov x, eax
}
#elif !defined(NO_ASM)
int reminder;
asm ("idivl %[divisor]"
: "=a" (x), "=d" (reminder)
: [divisor] "g" (y), "d" (x >> 16), "a" (x << 16));
#else
x = (((long long)x) << 16) / ((long long)y);
#endif
x = ((int64_t)x << 16) / (int64_t)y;
return x;
}

View File

@ -37,9 +37,9 @@
//
//****************************************************************
#include <Common/std string.h>
#include "Gfx_1.3.h"
#include "Version.h"
#include <Common/std string.h>
#include <Settings/Settings.h>
#include <wx/fileconf.h>
@ -1197,7 +1197,7 @@ int DllUnload(void)
void wxSetInstance(HINSTANCE hInstance);
extern "C" int WINAPI DllMain (HINSTANCE hinst,
wxUint32 fdwReason,
DWORD fdwReason,
LPVOID /*lpReserved*/)
{
sprintf (out_buf, "DllMain (%0p - %d)\n", hinst, fdwReason);

View File

@ -830,12 +830,20 @@ extern const char *CIStatus[];
#define FBL_D_1 2
#define FBL_D_0 3
/*
* taken straight from MSVC <windef.h> in case of other compilers
*
* Careful! These macros can sabotage std::max and std::min from <vector>.
* The only solution is to include <vector> first, before <windef.h> or
* before defining the below macros (or just don't use <windows.h>).
*/
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef TRUE
#define TRUE 1
#endif

View File

@ -3,7 +3,7 @@
[Setup]
AppId={{BEB5FB69-4080-466F-96C4-F15DF271718B}
AppName=Project 64
AppName=Project64
AppVersion={#AppVersion}
DefaultDirName={pf}\Project64 2.2
VersionInfoVersion={#AppVersion}
@ -19,7 +19,7 @@ UninstallDisplayIcon={uninstallexe}
SetupIconFile={#BaseDir}\Source\Project64\User Interface\Icons\pj64.ico
[Run]
Filename: "{app}\Project64.exe"; Description: "{cm:LaunchProgram,{#StringChange('Project 64', '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\Project64.exe"; Description: "{cm:LaunchProgram,{#StringChange('Project64', '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Files]
Source: "{#BaseDir}\Bin\{#Configuration}\Project64.exe"; DestDir: "{app}"; Flags: ignoreversion
@ -42,9 +42,9 @@ Name: "{app}\Screenshots"; Permissions: users-modify
Name: "{app}\Textures"; Permissions: users-modify
[Icons]
Name: "{commonprograms}\Project 64 2.2\Project 64"; Filename: "{app}\Project64.exe"
Name: "{commonprograms}\Project 64 2.2\Uninstall Project64 2.2"; Filename: "{uninstallexe}"; Parameters: "/LOG"
Name: "{commonprograms}\Project 64 2.2\Support"; Filename: "http://forum.pj64-emu.com"
Name: "{commonprograms}\Project64 2.2\Project64"; Filename: "{app}\Project64.exe"
Name: "{commonprograms}\Project64 2.2\Uninstall Project64 2.2"; Filename: "{uninstallexe}"; Parameters: "/LOG"
Name: "{commonprograms}\Project64 2.2\Support"; Filename: "http://forum.pj64-emu.com"
[Code]
function HaveCommandlineParam (inParam: String): Boolean;

View File

@ -0,0 +1,139 @@
#include "stdafx.h"
#include <Common\Util.h>
void FixDirectories(void);
void FixLocale(void);
static void IncreaseThreadPriority(void);
static CTraceFileLog * g_LogFile = NULL;
void LogLevelChanged(CTraceFileLog * LogFile)
{
LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel));
}
void LogFlushChanged(CTraceFileLog * LogFile)
{
LogFile->SetFlushFile(g_Settings->LoadDword(Debugger_AppLogFlush) != 0);
}
void InitializeLog(void)
{
CPath LogFilePath(CPath::MODULE_DIRECTORY);
LogFilePath.AppendDirectory("Logs");
if (!LogFilePath.DirectoryExists())
{
LogFilePath.DirectoryCreate();
}
LogFilePath.SetNameExtension("Project64.log");
g_LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New, 500);
#ifdef VALIDATE_DEBUG
g_LogFile->SetTraceLevel((TraceLevel)(g_Settings->LoadDword(Debugger_AppLogLevel) | TraceValidate | TraceDebug));
#else
g_LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel));
#endif
AddTraceModule(g_LogFile);
g_Settings->RegisterChangeCB(Debugger_AppLogLevel, g_LogFile, (CSettings::SettingChangedFunc)LogLevelChanged);
g_Settings->RegisterChangeCB(Debugger_AppLogFlush, g_LogFile, (CSettings::SettingChangedFunc)LogFlushChanged);
}
void AppInit(CNotification * Notify)
{
try
{
g_Notify = Notify;
FixDirectories();
FixLocale();
stdstr_f AppName("Project64 %s", VER_FILE_VERSION_STR);
IncreaseThreadPriority();
g_Settings = new CSettings;
g_Settings->Initialize(AppName.c_str());
if (g_Settings->LoadBool(Setting_CheckEmuRunning) &&
pjutil::TerminatedExistingExe())
{
delete g_Settings;
g_Settings = new CSettings;
g_Settings->Initialize(AppName.c_str());
}
InitializeLog();
WriteTrace(TraceDebug, __FUNCTION__ ": Application Starting");
CMipsMemoryVM::ReserveMemory();
//Create the plugin container
WriteTrace(TraceDebug, __FUNCTION__ ": Create Plugins");
g_Plugins = new CPlugins(g_Settings->LoadStringVal(Directory_Plugin));
g_Lang = new CLanguage();
g_Lang->LoadCurrentStrings();
g_Notify->AppInitDone();
}
catch (...)
{
g_Notify->DisplayError(stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str());
}
}
void AppCleanup(void)
{
g_Settings->UnregisterChangeCB(Debugger_AppLogLevel, g_LogFile, (CSettings::SettingChangedFunc)LogLevelChanged);
g_Settings->UnregisterChangeCB(Debugger_AppLogFlush, g_LogFile, (CSettings::SettingChangedFunc)LogFlushChanged);
WriteTrace(TraceDebug, __FUNCTION__ ": cleaning up global objects");
if (g_Rom) { delete g_Rom; g_Rom = NULL; }
if (g_Plugins) { delete g_Plugins; g_Plugins = NULL; }
if (g_Settings) { delete g_Settings; g_Settings = NULL; }
if (g_Lang) { delete g_Lang; g_Lang = NULL; }
CMipsMemoryVM::FreeReservedMemory();
WriteTrace(TraceDebug, __FUNCTION__ ": Done");
CloseTrace();
}
void FixDirectories(void)
{
CPath Directory(CPath::MODULE_DIRECTORY);
Directory.AppendDirectory("Config");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Logs");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Save");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("Screenshots");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory();
Directory.AppendDirectory("textures");
if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
}
#include <windows.h>
void FixLocale(void)
{
char *lbuffer = new char[10];
if (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, lbuffer, 10))
{
setlocale(LC_ALL, lbuffer);
}
delete[] lbuffer;
}
void IncreaseThreadPriority(void)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
}

View File

@ -0,0 +1,6 @@
#pragma once
#include <Project64\User Interface\Notification Class.h>
void AppInit(CNotification * Notify);
void AppCleanup(void);

View File

@ -1,29 +1,16 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
class CDelaySlotFunctionMap
{
typedef std::map<DWORD,CCompiledFunc *> FUNCTION_MAP;
FUNCTION_MAP FunctionMap;
public:
CDelaySlotFunctionMap();
~CDelaySlotFunctionMap();
CCompiledFunc* AddFunctionInfo(DWORD vAddr, DWORD pAddr);
CCompiledFunc* FindFunction(DWORD vAddr, int Length);
CCompiledFunc* FindFunction(DWORD vAddr) const;
void Remove(CCompiledFunc* info);
void Reset();
};
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
__interface CDebugger
{
virtual void TLBChanged(void) = 0;
};

View File

@ -0,0 +1,28 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#include <Project64\Settings\Logging Settings.h>
#include <Common\File Class.h>
class CLogging :
public CLogSettings
{
public:
static void StartLog(void);
static void StopLog(void);
static void Log_LW(uint32_t PC, uint32_t VAddr);
static void Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value);
static void LogMessage(const char * Message, ...);
private:
static CFile * m_hLogFile;
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,520 +11,521 @@
#pragma once
enum LanguageStringID{
EMPTY_STRING = 0,
EMPTY_STRING = 0,
/*********************************************************************************
* Meta Information *
*********************************************************************************/
//About DLL
LANGUAGE_NAME = 1,
LANGUAGE_AUTHOR =2,
LANGUAGE_VERSION =3,
LANGUAGE_DATE =4,
/*********************************************************************************
* Meta Information *
*********************************************************************************/
//About DLL
LANGUAGE_NAME = 1,
LANGUAGE_AUTHOR = 2,
LANGUAGE_VERSION = 3,
LANGUAGE_DATE = 4,
//About DLL Dialog
INI_CURRENT_LANG =5,
INI_AUTHOR =6,
INI_VERSION =7,
INI_DATE =8,
INI_HOMEPAGE =9,
INI_CURRENT_RDB =10,
INI_CURRENT_CHT =11,
INI_CURRENT_RDX =12,
//About DLL Dialog
INI_CURRENT_LANG = 5,
INI_AUTHOR = 6,
INI_VERSION = 7,
INI_DATE = 8,
INI_HOMEPAGE = 9,
INI_CURRENT_RDB = 10,
INI_CURRENT_CHT = 11,
INI_CURRENT_RDX = 12,
//About INI title
INI_TITLE =20,
//About INI title
INI_TITLE = 20,
/*********************************************************************************
* Numbers *
*********************************************************************************/
NUMBER_0 =50,
NUMBER_1 = 51,
NUMBER_2 = 52,
NUMBER_3 = 53,
NUMBER_4 = 54,
NUMBER_5 = 55,
NUMBER_6 = 56,
NUMBER_7 = 57,
NUMBER_8 = 58,
NUMBER_9 = 59,
/*********************************************************************************
* Numbers *
*********************************************************************************/
NUMBER_0 = 50,
NUMBER_1 = 51,
NUMBER_2 = 52,
NUMBER_3 = 53,
NUMBER_4 = 54,
NUMBER_5 = 55,
NUMBER_6 = 56,
NUMBER_7 = 57,
NUMBER_8 = 58,
NUMBER_9 = 59,
/*********************************************************************************
* Menu *
*********************************************************************************/
//File Menu
MENU_FILE =100,
MENU_OPEN =101,
MENU_ROM_INFO =102,
MENU_START =103,
MENU_END =104,
MENU_CHOOSE_ROM =105,
MENU_REFRESH =106,
MENU_RECENT_ROM =107,
MENU_RECENT_DIR =108,
MENU_EXIT =109,
/*********************************************************************************
* Menu *
*********************************************************************************/
//File Menu
MENU_FILE = 100,
MENU_OPEN = 101,
MENU_ROM_INFO = 102,
MENU_START = 103,
MENU_END = 104,
MENU_CHOOSE_ROM = 105,
MENU_REFRESH = 106,
MENU_RECENT_ROM = 107,
MENU_RECENT_DIR = 108,
MENU_EXIT = 109,
//System Menu
MENU_SYSTEM =120,
MENU_RESET =121,
MENU_PAUSE =122,
MENU_BITMAP =123,
MENU_LIMIT_FPS =124,
MENU_SAVE =125,
MENU_SAVE_AS =126,
MENU_RESTORE =127,
MENU_LOAD =128,
MENU_CURRENT_SAVE =129,
MENU_CHEAT =130,
MENU_GS_BUTTON =131,
MENU_RESUME =132,
MENU_RESET_SOFT =133, //added in build 1.7.50
MENU_RESET_HARD =134, //added in build 1.7.50
//System Menu
MENU_SYSTEM = 120,
MENU_RESET = 121,
MENU_PAUSE = 122,
MENU_BITMAP = 123,
MENU_LIMIT_FPS = 124,
MENU_SAVE = 125,
MENU_SAVE_AS = 126,
MENU_RESTORE = 127,
MENU_LOAD = 128,
MENU_CURRENT_SAVE = 129,
MENU_CHEAT = 130,
MENU_GS_BUTTON = 131,
MENU_RESUME = 132,
MENU_RESET_SOFT = 133, //added in build 1.7.50
MENU_RESET_HARD = 134, //added in build 1.7.50
//Options Menu
MENU_OPTIONS = 140,
MENU_FULL_SCREEN= 141,
MENU_ON_TOP = 142,
MENU_CONFG_GFX = 143,
MENU_CONFG_AUDIO= 144,
MENU_CONFG_CTRL = 145,
MENU_CONFG_RSP = 146,
MENU_SHOW_CPU = 147,
MENU_SETTINGS = 148,
//Options Menu
MENU_OPTIONS = 140,
MENU_FULL_SCREEN = 141,
MENU_ON_TOP = 142,
MENU_CONFG_GFX = 143,
MENU_CONFG_AUDIO = 144,
MENU_CONFG_CTRL = 145,
MENU_CONFG_RSP = 146,
MENU_SHOW_CPU = 147,
MENU_SETTINGS = 148,
//Debugger Menu
MENU_DEBUGGER = 160,
//Debugger Menu
MENU_DEBUGGER = 160,
//Language Menu
MENU_LANGUAGE = 175,
//Language Menu
MENU_LANGUAGE = 175,
//Help Menu
MENU_HELP = 180,
MENU_ABOUT_INI = 181,
MENU_ABOUT_PJ64 = 182,
MENU_FORUM = 183,
MENU_HOMEPAGE = 184,
//Help Menu
MENU_HELP = 180,
MENU_ABOUT_INI = 181,
MENU_ABOUT_PJ64 = 182,
MENU_FORUM = 183,
MENU_HOMEPAGE = 184,
//Current Save Slot menu
MENU_SLOT_DEFAULT = 190,
MENU_SLOT_1 = 191,
MENU_SLOT_2 = 192,
MENU_SLOT_3 = 193,
MENU_SLOT_4 = 194,
MENU_SLOT_5 = 195,
MENU_SLOT_6 = 196,
MENU_SLOT_7 = 197,
MENU_SLOT_8 = 198,
MENU_SLOT_9 = 199,
MENU_SLOT_10 = 200,
//Current Save Slot menu
MENU_SLOT_DEFAULT = 190,
MENU_SLOT_1 = 191,
MENU_SLOT_2 = 192,
MENU_SLOT_3 = 193,
MENU_SLOT_4 = 194,
MENU_SLOT_5 = 195,
MENU_SLOT_6 = 196,
MENU_SLOT_7 = 197,
MENU_SLOT_8 = 198,
MENU_SLOT_9 = 199,
MENU_SLOT_10 = 200,
MENU_SLOT_SAVE = 201,
//Pop up Menu
POPUP_PLAY = 210,
POPUP_INFO = 211,
POPUP_SETTINGS = 212,
POPUP_CHEATS = 213,
POPUP_GFX_PLUGIN = 214,
//Pop up Menu
POPUP_PLAY = 210,
POPUP_INFO = 211,
POPUP_SETTINGS = 212,
POPUP_CHEATS = 213,
POPUP_GFX_PLUGIN = 214,
//selecting save slot
SAVE_SLOT_DEFAULT = 220,
SAVE_SLOT_1 = 221,
SAVE_SLOT_2 = 222,
SAVE_SLOT_3 = 223,
SAVE_SLOT_4 = 224,
SAVE_SLOT_5 = 225,
SAVE_SLOT_6 = 226,
SAVE_SLOT_7 = 227,
SAVE_SLOT_8 = 228,
SAVE_SLOT_9 = 229,
SAVE_SLOT_10 = 230,
//selecting save slot
SAVE_SLOT_DEFAULT = 220,
SAVE_SLOT_1 = 221,
SAVE_SLOT_2 = 222,
SAVE_SLOT_3 = 223,
SAVE_SLOT_4 = 224,
SAVE_SLOT_5 = 225,
SAVE_SLOT_6 = 226,
SAVE_SLOT_7 = 227,
SAVE_SLOT_8 = 228,
SAVE_SLOT_9 = 229,
SAVE_SLOT_10 = 230,
// Menu Descriptions (TODO: unused ? implement or remove)
MENUDES_OPEN = 250,
MENUDES_ROM_INFO = 251,
MENUDES_START = 252,
MENUDES_END = 253,
MENUDES_CHOOSE_ROM = 254,
MENUDES_REFRESH = 255,
MENUDES_EXIT = 256,
MENUDES_RESET = 257,
MENUDES_PAUSE = 258,
MENUDES_BITMAP = 259,
MENUDES_LIMIT_FPS = 260,
MENUDES_SAVE = 261,
MENUDES_SAVE_AS = 262,
MENUDES_RESTORE = 263,
MENUDES_LOAD = 264,
MENUDES_CHEAT = 265,
MENUDES_GS_BUTTON = 266,
MENUDES_FULL_SCREEN = 267,
MENUDES_ON_TOP = 268,
MENUDES_CONFG_GFX = 269,
MENUDES_CONFG_AUDIO = 270,
MENUDES_CONFG_CTRL = 271,
MENUDES_CONFG_RSP = 272,
MENUDES_SHOW_CPU = 273,
MENUDES_SETTINGS = 274,
MENUDES_USER_MAN = 275,
MENUDES_GAME_FAQ = 276,
MENUDES_ABOUT_INI = 277,
MENUDES_ABOUT_PJ64 = 278,
MENUDES_RECENT_ROM = 279,
MENUDES_RECENT_DIR = 280,
MENUDES_LANGUAGES = 281,
MENUDES_GAME_SLOT = 282,
MENUDES_PLAY_GAME = 283,
MENUDES_GAME_INFO = 284,
MENUDES_GAME_SETTINGS= 285,
MENUDES_GAME_CHEATS = 286,
// Menu Descriptions (TODO: unused ? implement or remove)
MENUDES_OPEN = 250,
MENUDES_ROM_INFO = 251,
MENUDES_START = 252,
MENUDES_END = 253,
MENUDES_CHOOSE_ROM = 254,
MENUDES_REFRESH = 255,
MENUDES_EXIT = 256,
MENUDES_RESET = 257,
MENUDES_PAUSE = 258,
MENUDES_BITMAP = 259,
MENUDES_LIMIT_FPS = 260,
MENUDES_SAVE = 261,
MENUDES_SAVE_AS = 262,
MENUDES_RESTORE = 263,
MENUDES_LOAD = 264,
MENUDES_CHEAT = 265,
MENUDES_GS_BUTTON = 266,
MENUDES_FULL_SCREEN = 267,
MENUDES_ON_TOP = 268,
MENUDES_CONFG_GFX = 269,
MENUDES_CONFG_AUDIO = 270,
MENUDES_CONFG_CTRL = 271,
MENUDES_CONFG_RSP = 272,
MENUDES_SHOW_CPU = 273,
MENUDES_SETTINGS = 274,
MENUDES_USER_MAN = 275,
MENUDES_GAME_FAQ = 276,
MENUDES_ABOUT_INI = 277,
MENUDES_ABOUT_PJ64 = 278,
MENUDES_RECENT_ROM = 279,
MENUDES_RECENT_DIR = 280,
MENUDES_LANGUAGES = 281,
MENUDES_GAME_SLOT = 282,
MENUDES_PLAY_GAME = 283,
MENUDES_GAME_INFO = 284,
MENUDES_GAME_SETTINGS = 285,
MENUDES_GAME_CHEATS = 286,
/*********************************************************************************
* Rom Browser *
*********************************************************************************/
//Rom Browser Fields
RB_FILENAME = 300,
RB_INTERNALNAME = 301,
RB_GOODNAME = 302,
RB_STATUS = 303,
RB_ROMSIZE = 304,
RB_NOTES_CORE = 305,
RB_NOTES_PLUGIN = 306,
RB_NOTES_USER = 307,
RB_CART_ID = 308,
RB_MANUFACTUER = 309,
RB_COUNTRY = 310,
RB_DEVELOPER = 311,
RB_CRC1 = 312,
RB_CRC2 = 313,
RB_CICCHIP = 314,
RB_RELEASE_DATE = 315,
RB_GENRE = 316,
RB_PLAYERS = 317,
RB_FORCE_FEEDBACK = 318,
RB_FILE_FORMAT = 319,
/*********************************************************************************
* Rom Browser *
*********************************************************************************/
//Rom Browser Fields
RB_FILENAME = 300,
RB_INTERNALNAME = 301,
RB_GOODNAME = 302,
RB_STATUS = 303,
RB_ROMSIZE = 304,
RB_NOTES_CORE = 305,
RB_NOTES_PLUGIN = 306,
RB_NOTES_USER = 307,
RB_CART_ID = 308,
RB_MANUFACTUER = 309,
RB_COUNTRY = 310,
RB_DEVELOPER = 311,
RB_CRC1 = 312,
RB_CRC2 = 313,
RB_CICCHIP = 314,
RB_RELEASE_DATE = 315,
RB_GENRE = 316,
RB_PLAYERS = 317,
RB_FORCE_FEEDBACK = 318,
RB_FILE_FORMAT = 319,
//Select Rom
SELECT_ROM_DIR = 320,
//Select Rom
SELECT_ROM_DIR = 320,
//Messages
RB_NOT_GOOD_FILE = 340,
//Messages
RB_NOT_GOOD_FILE = 340,
/*********************************************************************************
* Options *
*********************************************************************************/
//Options Title
OPTIONS_TITLE = 400,
/*********************************************************************************
* Options *
*********************************************************************************/
//Options Title
OPTIONS_TITLE = 400,
//Tabs
TAB_PLUGIN = 401,
TAB_DIRECTORY = 402,
TAB_OPTIONS = 403,
TAB_ROMSELECTION = 404,
TAB_ADVANCED = 405,
TAB_ROMSETTINGS = 406,
TAB_SHELLINTERGATION= 407,
TAB_ROMNOTES = 408,
TAB_SHORTCUTS = 409,
TAB_ROMSTATUS = 410,
TAB_RECOMPILER = 411, //Added in 1.7.0.50
//Tabs
TAB_PLUGIN = 401,
TAB_DIRECTORY = 402,
TAB_OPTIONS = 403,
TAB_ROMSELECTION = 404,
TAB_ADVANCED = 405,
TAB_ROMSETTINGS = 406,
TAB_SHELLINTERGATION = 407,
TAB_ROMNOTES = 408,
TAB_SHORTCUTS = 409,
TAB_ROMSTATUS = 410,
TAB_RECOMPILER = 411, //Added in 1.7.0.50
//Plugin Dialog
PLUG_ABOUT = 420,
PLUG_RSP = 421,
PLUG_GFX = 422,
PLUG_AUDIO = 423,
PLUG_CTRL = 424,
PLUG_HLE_GFX = 425,
PLUG_HLE_AUDIO = 426,
PLUG_DEFAULT = 427,
//Plugin Dialog
PLUG_ABOUT = 420,
PLUG_RSP = 421,
PLUG_GFX = 422,
PLUG_AUDIO = 423,
PLUG_CTRL = 424,
PLUG_HLE_GFX = 425,
PLUG_HLE_AUDIO = 426,
PLUG_DEFAULT = 427,
//Directory Dialog
DIR_PLUGIN = 440,
DIR_ROM = 441,
DIR_AUTO_SAVE = 442,
DIR_INSTANT_SAVE = 443,
DIR_SCREEN_SHOT = 444,
DIR_ROM_DEFAULT = 445,
DIR_SELECT_PLUGIN = 446,
DIR_SELECT_ROM = 447,
DIR_SELECT_AUTO = 448,
DIR_SELECT_INSTANT = 449,
DIR_SELECT_SCREEN = 450,
DIR_TEXTURE = 451,
DIR_SELECT_TEXTURE = 452,
//Directory Dialog
DIR_PLUGIN = 440,
DIR_ROM = 441,
DIR_AUTO_SAVE = 442,
DIR_INSTANT_SAVE = 443,
DIR_SCREEN_SHOT = 444,
DIR_ROM_DEFAULT = 445,
DIR_SELECT_PLUGIN = 446,
DIR_SELECT_ROM = 447,
DIR_SELECT_AUTO = 448,
DIR_SELECT_INSTANT = 449,
DIR_SELECT_SCREEN = 450,
DIR_TEXTURE = 451,
DIR_SELECT_TEXTURE = 452,
//Options (general) Tab
OPTION_AUTO_SLEEP =460,
OPTION_AUTO_FULLSCREEN =461,
OPTION_BASIC_MODE =462,
OPTION_REMEMBER_CHEAT =463,
OPTION_DISABLE_SS =464,
OPTION_DISPLAY_FR =465,
OPTION_CHANGE_FR =466,
OPTION_CHECK_RUNNING =467,
//Options (general) Tab
OPTION_AUTO_SLEEP = 460,
OPTION_AUTO_FULLSCREEN = 461,
OPTION_BASIC_MODE = 462,
OPTION_REMEMBER_CHEAT = 463,
OPTION_DISABLE_SS = 464,
OPTION_DISPLAY_FR = 465,
OPTION_CHANGE_FR = 466,
OPTION_CHECK_RUNNING = 467,
//Rom Browser Tab
RB_MAX_ROMS = 480,
RB_ROMS = 481,
RB_MAX_DIRS = 482,
RB_DIRS = 483,
RB_USE = 484,
RB_DIR_RECURSION = 485,
RB_AVALIABLE_FIELDS = 486,
RB_SHOW_FIELDS = 487,
RB_ADD = 488,
RB_REMOVE = 489,
RB_UP = 490,
RB_DOWN = 491,
RB_REFRESH = 492,
//Rom Browser Tab
RB_MAX_ROMS = 480,
RB_ROMS = 481,
RB_MAX_DIRS = 482,
RB_DIRS = 483,
RB_USE = 484,
RB_DIR_RECURSION = 485,
RB_AVALIABLE_FIELDS = 486,
RB_SHOW_FIELDS = 487,
RB_ADD = 488,
RB_REMOVE = 489,
RB_UP = 490,
RB_DOWN = 491,
RB_REFRESH = 492,
//Advanced Options
ADVANCE_INFO = 500,
ADVANCE_DEFAULTS = 501,
ADVANCE_CPU_STYLE = 502,
ADVANCE_SMCM = 503,
ADVANCE_MEM_SIZE = 504,
ADVANCE_ABL = 505,
ADVANCE_AUTO_START = 506,
ADVANCE_OVERWRITE = 507,
ADVANCE_COMPRESS = 508,
ADVANCE_DEBUGGER = 509,
ADVANCE_SMM_CACHE = 510,
ADVANCE_SMM_PIDMA = 511,
ADVANCE_SMM_VALIDATE= 512,
ADVANCE_SMM_PROTECT = 513,
ADVANCE_SMM_TLB = 514,
//Advanced Options
ADVANCE_INFO = 500,
ADVANCE_DEFAULTS = 501,
ADVANCE_CPU_STYLE = 502,
ADVANCE_SMCM = 503,
ADVANCE_MEM_SIZE = 504,
ADVANCE_ABL = 505,
ADVANCE_AUTO_START = 506,
ADVANCE_OVERWRITE = 507,
ADVANCE_COMPRESS = 508,
ADVANCE_DEBUGGER = 509,
ADVANCE_SMM_CACHE = 510,
ADVANCE_SMM_PIDMA = 511,
ADVANCE_SMM_VALIDATE = 512,
ADVANCE_SMM_PROTECT = 513,
ADVANCE_SMM_TLB = 514,
//Rom Options
ROM_CPU_STYLE = 520,
ROM_VIREFRESH = 521,
ROM_MEM_SIZE = 522,
ROM_ABL = 523,
ROM_SAVE_TYPE = 524,
ROM_COUNTER_FACTOR = 525,
ROM_LARGE_BUFFER = 526,
ROM_USE_TLB = 527,
ROM_REG_CACHE = 528,
ROM_DELAY_SI = 529,
ROM_FAST_SP = 530,
ROM_DEFAULT = 531,
ROM_AUDIO_SIGNAL = 532,
ROM_FIXED_AUDIO = 533,
ROM_FUNC_FIND = 534,
ROM_CUSTOM_SMM = 535,
ROM_SYNC_AUDIO = 536,
ROM_COUNTPERBYTE = 537,
ROM_32BIT = 538,
ROM_DELAY_DP = 539,
//Rom Options
ROM_CPU_STYLE = 520,
ROM_VIREFRESH = 521,
ROM_MEM_SIZE = 522,
ROM_ABL = 523,
ROM_SAVE_TYPE = 524,
ROM_COUNTER_FACTOR = 525,
ROM_LARGE_BUFFER = 526,
ROM_USE_TLB = 527,
ROM_REG_CACHE = 528,
ROM_DELAY_SI = 529,
ROM_FAST_SP = 530,
ROM_DEFAULT = 531,
ROM_AUDIO_SIGNAL = 532,
ROM_FIXED_AUDIO = 533,
ROM_FUNC_FIND = 534,
ROM_CUSTOM_SMM = 535,
ROM_SYNC_AUDIO = 536,
ROM_COUNTPERBYTE = 537,
ROM_32BIT = 538,
ROM_DELAY_DP = 539,
//Core Styles
CORE_INTERPTER = 540,
CORE_RECOMPILER = 541,
CORE_SYNC = 542,
//Core Styles
CORE_INTERPTER = 540,
CORE_RECOMPILER = 541,
CORE_SYNC = 542,
//Self Mod Methods
SMCM_NONE = 560,
SMCM_CACHE = 561,
SMCM_PROECTED = 562,
SMCM_CHECK_MEM = 563,
SMCM_CHANGE_MEM = 564,
SMCM_CHECK_ADV = 565,
SMCM_CACHE2 = 566,
//Self Mod Methods
SMCM_NONE = 560,
SMCM_CACHE = 561,
SMCM_PROECTED = 562,
SMCM_CHECK_MEM = 563,
SMCM_CHANGE_MEM = 564,
SMCM_CHECK_ADV = 565,
SMCM_CACHE2 = 566,
//Function Lookup memthod
FLM_PLOOKUP = 570,
FLM_VLOOKUP = 571,
FLM_CHANGEMEM = 572,
//Function Lookup memthod
FLM_PLOOKUP = 570,
FLM_VLOOKUP = 571,
FLM_CHANGEMEM = 572,
//RDRAM Size
RDRAM_4MB = 580,
RDRAM_8MB = 581,
//RDRAM Size
RDRAM_4MB = 580,
RDRAM_8MB = 581,
//Advanced Block Linking
ABL_ON = 600,
ABL_OFF = 601,
//Advanced Block Linking
ABL_ON = 600,
ABL_OFF = 601,
//Save Type
SAVE_FIRST_USED = 620,
SAVE_4K_EEPROM = 621,
SAVE_16K_EEPROM = 622,
SAVE_SRAM = 623,
SAVE_FLASHRAM = 624,
//Save Type
SAVE_FIRST_USED = 620,
SAVE_4K_EEPROM = 621,
SAVE_16K_EEPROM = 622,
SAVE_SRAM = 623,
SAVE_FLASHRAM = 624,
//Shell Integration Tab
SHELL_TEXT = 640,
//Shell Integration Tab
SHELL_TEXT = 640,
//Rom Notes
NOTE_STATUS = 660,
NOTE_CORE = 661,
NOTE_PLUGIN = 662,
//Rom Notes
NOTE_STATUS = 660,
NOTE_CORE = 661,
NOTE_PLUGIN = 662,
// Accelerator Selector
ACCEL_CPUSTATE_TITLE = 680,
ACCEL_MENUITEM_TITLE = 681,
ACCEL_CURRENTKEYS_TITLE = 682,
ACCEL_SELKEY_TITLE = 683,
ACCEL_ASSIGNEDTO_TITLE = 684,
ACCEL_ASSIGN_BTN = 685,
ACCEL_REMOVE_BTN = 686,
ACCEL_RESETALL_BTN = 687,
ACCEL_CPUSTATE_1 = 688,
ACCEL_CPUSTATE_2 = 689,
ACCEL_CPUSTATE_3 = 690,
ACCEL_CPUSTATE_4 = 691,
ACCEL_DETECTKEY = 692,
// Accelerator Selector
ACCEL_CPUSTATE_TITLE = 680,
ACCEL_MENUITEM_TITLE = 681,
ACCEL_CURRENTKEYS_TITLE = 682,
ACCEL_SELKEY_TITLE = 683,
ACCEL_ASSIGNEDTO_TITLE = 684,
ACCEL_ASSIGN_BTN = 685,
ACCEL_REMOVE_BTN = 686,
ACCEL_RESETALL_BTN = 687,
ACCEL_CPUSTATE_1 = 688,
ACCEL_CPUSTATE_2 = 689,
ACCEL_CPUSTATE_3 = 690,
ACCEL_CPUSTATE_4 = 691,
ACCEL_DETECTKEY = 692,
// Frame Rate Option
STR_FR_VIS = 700,
STR_FR_DLS = 701,
STR_FR_PERCENT = 702,
// Frame Rate Option
STR_FR_VIS = 700,
STR_FR_DLS = 701,
STR_FR_PERCENT = 702,
// Increase speed
STR_INSREASE_SPEED = 710,
STR_DECREASE_SPEED = 711,
// Increase speed
STR_INSREASE_SPEED = 710,
STR_DECREASE_SPEED = 711,
//Bottom page buttons
BOTTOM_RESET_PAGE = 720,
BOTTOM_RESET_ALL = 721,
BOTTOM_APPLY = 722,
BOTTOM_CLOSE = 723,
//Bottom page buttons
BOTTOM_RESET_PAGE = 720,
BOTTOM_RESET_ALL = 721,
BOTTOM_APPLY = 722,
BOTTOM_CLOSE = 723,
/*********************************************************************************
* ROM Information *
*********************************************************************************/
//Rom Info Title Title
INFO_TITLE = 800,
/*********************************************************************************
* ROM Information *
*********************************************************************************/
//Rom Info Title Title
INFO_TITLE = 800,
//Rom Info Text
INFO_ROM_NAME_TEXT = 801,
INFO_FILE_NAME_TEXT = 802,
INFO_LOCATION_TEXT = 803,
INFO_SIZE_TEXT = 804,
INFO_CART_ID_TEXT = 805,
INFO_MANUFACTURER_TEXT= 806,
INFO_COUNTRY_TEXT = 807,
INFO_CRC1_TEXT = 808,
INFO_CRC2_TEXT = 809,
INFO_CIC_CHIP_TEXT = 810,
INFO_MD5_TEXT = 811,
//Rom Info Text
INFO_ROM_NAME_TEXT = 801,
INFO_FILE_NAME_TEXT = 802,
INFO_LOCATION_TEXT = 803,
INFO_SIZE_TEXT = 804,
INFO_CART_ID_TEXT = 805,
INFO_MANUFACTURER_TEXT = 806,
INFO_COUNTRY_TEXT = 807,
INFO_CRC1_TEXT = 808,
INFO_CRC2_TEXT = 809,
INFO_CIC_CHIP_TEXT = 810,
INFO_MD5_TEXT = 811,
/*********************************************************************************
* Cheats *
*********************************************************************************/
//Cheat List
CHEAT_TITLE = 1000,
CHEAT_LIST_FRAME = 1001,
CHEAT_NOTES_FRAME = 1002,
CHEAT_MARK_ALL = 1003,
CHEAT_MARK_NONE = 1004,
/*********************************************************************************
* Cheats *
*********************************************************************************/
//Cheat List
CHEAT_TITLE = 1000,
CHEAT_LIST_FRAME = 1001,
CHEAT_NOTES_FRAME = 1002,
CHEAT_MARK_ALL = 1003,
CHEAT_MARK_NONE = 1004,
//Add Cheat
CHEAT_ADDCHEAT_FRAME =1005,
CHEAT_ADDCHEAT_NAME =1006,
CHEAT_ADDCHEAT_CODE = 1007,
CHEAT_ADDCHEAT_INSERT= 1008,
CHEAT_ADDCHEAT_CLEAR= 1009,
CHEAT_ADDCHEAT_NOTES= 1010,
CHEAT_ADD_TO_DB = 1011,
//Add Cheat
CHEAT_ADDCHEAT_FRAME = 1005,
CHEAT_ADDCHEAT_NAME = 1006,
CHEAT_ADDCHEAT_CODE = 1007,
CHEAT_ADDCHEAT_INSERT = 1008,
CHEAT_ADDCHEAT_CLEAR = 1009,
CHEAT_ADDCHEAT_NOTES = 1010,
CHEAT_ADD_TO_DB = 1011,
//Code extension
CHEAT_CODE_EXT_TITLE =1012,
CHEAT_CODE_EXT_TXT =1013,
CHEAT_OK =1014,
CHEAT_CANCEL =1015,
//Code extension
CHEAT_CODE_EXT_TITLE = 1012,
CHEAT_CODE_EXT_TXT = 1013,
CHEAT_OK = 1014,
CHEAT_CANCEL = 1015,
//Digital Value
CHEAT_QUANTITY_TITLE =1016,
CHEAT_CHOOSE_VALUE =1017,
CHEAT_VALUE =1018,
CHEAT_FROM =1019,
CHEAT_TO =1020,
CHEAT_NOTES =1021,
CHEAT_ADDCHEAT_ADD = 1022,
CHEAT_ADDCHEAT_NEW = 1023,
CHEAT_ADDCHEAT_CODEDES =1024,
CHEAT_ADDCHEAT_OPT =1025,
CHEAT_ADDCHEAT_OPTDES =1026,
//Digital Value
CHEAT_QUANTITY_TITLE = 1016,
CHEAT_CHOOSE_VALUE = 1017,
CHEAT_VALUE = 1018,
CHEAT_FROM = 1019,
CHEAT_TO = 1020,
CHEAT_NOTES = 1021,
CHEAT_ADDCHEAT_ADD = 1022,
CHEAT_ADDCHEAT_NEW = 1023,
CHEAT_ADDCHEAT_CODEDES = 1024,
CHEAT_ADDCHEAT_OPT = 1025,
CHEAT_ADDCHEAT_OPTDES = 1026,
//Edit Cheat
CHEAT_EDITCHEAT_WINDOW =1027,
CHEAT_EDITCHEAT_UPDATE =1028,
CHEAT_CHANGED_MSG =1029,
CHEAT_CHANGED_TITLE =1030,
//Edit Cheat
CHEAT_EDITCHEAT_WINDOW = 1027,
CHEAT_EDITCHEAT_UPDATE = 1028,
CHEAT_CHANGED_MSG = 1029,
CHEAT_CHANGED_TITLE = 1030,
//Cheat Popup Menu
CHEAT_ADDNEW =1040,
CHEAT_EDIT = 1041,
CHEAT_DELETE = 1042,
//Cheat Popup Menu
CHEAT_ADDNEW = 1040,
CHEAT_EDIT = 1041,
CHEAT_DELETE = 1042,
// short cut editor
STR_SHORTCUT_RESET_TITLE = 1100,
STR_SHORTCUT_RESET_TEXT = 1101,
STR_SHORTCUT_FILEMENU = 1102,
STR_SHORTCUT_SYSTEMMENU = 1103,
STR_SHORTCUT_OPTIONS = 1104,
STR_SHORTCUT_SAVESLOT = 1105,
// short cut editor
STR_SHORTCUT_RESET_TITLE = 1100,
STR_SHORTCUT_RESET_TEXT = 1101,
STR_SHORTCUT_FILEMENU = 1102,
STR_SHORTCUT_SYSTEMMENU = 1103,
STR_SHORTCUT_OPTIONS = 1104,
STR_SHORTCUT_SAVESLOT = 1105,
/*********************************************************************************
* Messages *
*********************************************************************************/
MSG_CPU_PAUSED = 2000,
MSG_CPU_RESUMED = 2001,
MSG_PERM_LOOP = 2002,
MSG_MEM_ALLOC_ERROR = 2003,
MSG_FAIL_INIT_GFX = 2004,
MSG_FAIL_INIT_AUDIO = 2005,
MSG_FAIL_INIT_RSP = 2006,
MSG_FAIL_INIT_CONTROL = 2007,
MSG_FAIL_LOAD_PLUGIN = 2008,
MSG_FAIL_LOAD_WORD = 2009,
MSG_FAIL_OPEN_SAVE = 2010,
MSG_FAIL_OPEN_EEPROM = 2011,
MSG_FAIL_OPEN_FLASH = 2012,
MSG_FAIL_OPEN_MEMPAK = 2013,
MSG_FAIL_OPEN_ZIP = 2014,
MSG_FAIL_OPEN_IMAGE = 2015,
MSG_FAIL_ZIP = 2016,
MSG_FAIL_IMAGE = 2017,
MSG_UNKNOWN_COUNTRY = 2018,
MSG_UNKNOWN_CIC_CHIP = 2019,
MSG_UNKNOWN_FILE_FORMAT= 2020,
MSG_UNKNOWN_MEM_ACTION = 2021,
MSG_UNHANDLED_OP = 2022,
MSG_NONMAPPED_SPACE = 2023,
MSG_SAVE_STATE_HEADER = 2024,
MSG_MSGBOX_TITLE =2025,
MSG_PIF2_ERROR = 2026,
MSG_PIF2_TITLE = 2027,
MSG_PLUGIN_CHANGE = 2028,
MSG_PLUGIN_CHANGE_TITLE= 2029,
MSG_EMULATION_ENDED = 2030,
MSG_EMULATION_STARTED = 2031,
MSG_UNABLED_LOAD_STATE = 2032,
MSG_LOADED_STATE = 2033,
MSG_SAVED_STATE = 2034,
MSG_SAVE_SLOT = 2035,
MSG_BYTESWAP =2036,
MSG_CHOOSE_IMAGE = 2037,
MSG_LOADED = 2038,
MSG_LOADING = 2039,
MSG_PLUGIN_NOT_INIT = 2040,
MSG_DEL_SURE = 2041,
MSG_DEL_TITLE = 2042,
MSG_CHEAT_NAME_IN_USE = 2043,
MSG_MAX_CHEATS = 2044,
MSG_PLUGIN_INIT = 2045, //Added in pj64 1.6
MSG_NO_SHORTCUT_SEL = 2046, //Added in pj64 1.6
MSG_NO_MENUITEM_SEL = 2047, //Added in pj64 1.6
MSG_MENUITEM_ASSIGNED = 2048, //Added in pj64 1.6
MSG_NO_SEL_SHORTCUT = 2049, //Added in pj64 1.6
MSG_WAITING_FOR_START = 2050, //Added in pj64 1.7
MSG_INVALID_EXE = 2051, //Added in pj64 1.7
MSG_INVALID_EXE_TITLE = 2052, //Added in pj64 1.7
MSG_7Z_FILE_NOT_FOUND = 2053, //Added in pj64 1.7
MSG_SET_LLE_GFX_TITLE = 2054, //Added in pj64 1.7
MSG_SET_LLE_GFX_MSG = 2055, //Added in pj64 1.7
MSG_SET_HLE_AUD_TITLE = 2056, //Added in pj64 1.7
MSG_SET_HLE_AUD_MSG = 2057, //Added in pj64 1.7
/*********************************************************************************
* Messages *
*********************************************************************************/
MSG_CPU_PAUSED = 2000,
MSG_CPU_RESUMED = 2001,
MSG_PERM_LOOP = 2002,
MSG_MEM_ALLOC_ERROR = 2003,
MSG_FAIL_INIT_GFX = 2004,
MSG_FAIL_INIT_AUDIO = 2005,
MSG_FAIL_INIT_RSP = 2006,
MSG_FAIL_INIT_CONTROL = 2007,
MSG_FAIL_LOAD_PLUGIN = 2008,
MSG_FAIL_LOAD_WORD = 2009,
MSG_FAIL_OPEN_SAVE = 2010,
MSG_FAIL_OPEN_EEPROM = 2011,
MSG_FAIL_OPEN_FLASH = 2012,
MSG_FAIL_OPEN_MEMPAK = 2013,
MSG_FAIL_OPEN_ZIP = 2014,
MSG_FAIL_OPEN_IMAGE = 2015,
MSG_FAIL_ZIP = 2016,
MSG_FAIL_IMAGE = 2017,
MSG_UNKNOWN_COUNTRY = 2018,
MSG_UNKNOWN_CIC_CHIP = 2019,
MSG_UNKNOWN_FILE_FORMAT = 2020,
MSG_UNKNOWN_MEM_ACTION = 2021,
MSG_UNHANDLED_OP = 2022,
MSG_NONMAPPED_SPACE = 2023,
MSG_SAVE_STATE_HEADER = 2024,
MSG_MSGBOX_TITLE = 2025,
MSG_PIF2_ERROR = 2026,
MSG_PIF2_TITLE = 2027,
MSG_PLUGIN_CHANGE = 2028,
MSG_PLUGIN_CHANGE_TITLE = 2029,
MSG_EMULATION_ENDED = 2030,
MSG_EMULATION_STARTED = 2031,
MSG_UNABLED_LOAD_STATE = 2032,
MSG_LOADED_STATE = 2033,
MSG_SAVED_STATE = 2034,
MSG_SAVE_SLOT = 2035,
MSG_BYTESWAP = 2036,
MSG_CHOOSE_IMAGE = 2037,
MSG_LOADED = 2038,
MSG_LOADING = 2039,
MSG_PLUGIN_NOT_INIT = 2040,
MSG_DEL_SURE = 2041,
MSG_DEL_TITLE = 2042,
MSG_CHEAT_NAME_IN_USE = 2043,
MSG_MAX_CHEATS = 2044,
MSG_PLUGIN_INIT = 2045, //Added in pj64 1.6
MSG_NO_SHORTCUT_SEL = 2046, //Added in pj64 1.6
MSG_NO_MENUITEM_SEL = 2047, //Added in pj64 1.6
MSG_MENUITEM_ASSIGNED = 2048, //Added in pj64 1.6
MSG_NO_SEL_SHORTCUT = 2049, //Added in pj64 1.6
MSG_WAITING_FOR_START = 2050, //Added in pj64 1.7
MSG_INVALID_EXE = 2051, //Added in pj64 1.7
MSG_INVALID_EXE_TITLE = 2052, //Added in pj64 1.7
MSG_7Z_FILE_NOT_FOUND = 2053, //Added in pj64 1.7
MSG_SET_LLE_GFX_TITLE = 2054, //Added in pj64 1.7
MSG_SET_LLE_GFX_MSG = 2055, //Added in pj64 1.7
MSG_SET_HLE_AUD_TITLE = 2056, //Added in pj64 1.7
MSG_SET_HLE_AUD_MSG = 2057, //Added in pj64 1.7
};
#include ".\\Multilanguage\Language Class.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -14,8 +14,9 @@
#include <string> //stl string
#include <map> //stl map
#include <list> //stl list
#include <common/stdtypes.h>
typedef std::map<int, std::wstring, std::less<int> > LANG_STRINGS;
typedef std::map<int32_t, std::wstring, std::less<int32_t> > LANG_STRINGS;
typedef LANG_STRINGS::value_type LANG_STR;
struct LanguageFile
@ -29,14 +30,14 @@ typedef std::list<LanguageFile> LanguageList;
class CLanguage
{
public:
CLanguage ();
CLanguage();
const std::wstring & GetString ( LanguageStringID StringID );
LanguageList & GetLangList ( void );
void SetLanguage ( const wchar_t * LanguageName );
bool LoadCurrentStrings ( void );
bool IsCurrentLang ( LanguageFile & File );
bool IsLanguageLoaded ( void ) const { return m_LanguageLoaded; }
const std::wstring & GetString(LanguageStringID StringID);
LanguageList & GetLangList(void);
void SetLanguage(const wchar_t * LanguageName);
bool LoadCurrentStrings(void);
bool IsCurrentLang(LanguageFile & File);
bool IsLanguageLoaded(void) const { return m_LanguageLoaded; }
private:
CLanguage(const CLanguage&); // Disable copy constructor
@ -48,16 +49,16 @@ private:
LANG_STRINGS m_CurrentStrings, m_DefaultStrings;
LanguageList m_LanguageList;
std::wstring GetLangString ( const char * FileName, LanguageStringID ID );
LANG_STR GetNextLangString ( void * OpenFile );
void LoadDefaultStrings ( void );
std::wstring GetLangString(const char * FileName, LanguageStringID ID);
LANG_STR GetNextLangString(void * OpenFile);
void LoadDefaultStrings(void);
bool m_LanguageLoaded;
bool m_LanguageLoaded;
};
extern CLanguage * g_Lang;
inline const wchar_t * GS (LanguageStringID StringID)
inline const wchar_t * GS(LanguageStringID StringID)
{
return g_Lang->GetString(StringID).c_str();
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -15,299 +15,114 @@ CLanguageSelector::CLanguageSelector()
{
}
void CLanguageSelector::Select ( void )
void CLanguageSelector::Select(void)
{
DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this);
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this);
}
static WNDPROC pfnWndLangSelectOkProc = NULL;
static HBITMAP hOkButton = NULL;
DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
static bool m_fPressed = false;
static HBITMAP hOkButtonDown = NULL;
switch (uMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hWnd,&ps))
{
if (m_fPressed)
{
if (hOkButtonDown == NULL)
{
hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN));
}
if (hOkButtonDown)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButtonDown);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
else
{
if (hOkButton)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
BITMAP bmTL1;
GetObject(hOkButton, sizeof(BITMAP), &bmTL1);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hOkButton);
BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
}
}
EndPaint(hWnd,&ps);
}
}
break;
case WM_MOUSEMOVE:
if (::GetCapture() == hWnd)
{
POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) };
ClientToScreen(hWnd, &ptCursor);
RECT rect;
GetWindowRect(hWnd, &rect);
bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE;
if ( m_fPressed != uPressed )
{
m_fPressed = uPressed;
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
break;
case WM_LBUTTONDOWN:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
SetCapture(hWnd);
if ( ::GetCapture()==hWnd )
{
m_fPressed = true;
if (m_fPressed)
{
::InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
}
}
return lRet;
}
break;
case WM_LBUTTONUP:
{
LRESULT lRet = 0;
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
if ( ::GetCapture() == hWnd )
{
::ReleaseCapture();
if ( m_fPressed )
{
::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
}
}
m_fPressed = false;
return lRet;
}
break;
}
return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam);
}
LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hbmpBackgroundTop = NULL;
static HBITMAP hbmpBackgroundBottom = NULL;
static HBITMAP hbmpBackgroundMiddle = NULL;
static HFONT hTextFont = NULL;
static CLanguageSelector * lngClass;
switch (uMsg)
{
case WM_INITDIALOG:
SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE);
{
lngClass = (CLanguageSelector *)lParam;
LanguageList LangList = g_Lang->GetLangList();
if (LangList.size() == 0)
{
lngClass = (CLanguageSelector *)lParam;
LanguageList LangList = g_Lang->GetLangList();
if (LangList.size() == 0)
EndDialog(hDlg, 0);
}
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
{
int index = SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_ADDSTRING, 0, (WPARAM)Language->LanguageName.c_str());
if (_wcsicmp(Language->LanguageName.c_str(), L"English") == 0)
{
EndDialog(hDlg,0);
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, index, 0);
}
for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++)
{
int index = SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_ADDSTRING,0,(WPARAM)Language->LanguageName.c_str());
if (_wcsicmp(Language->LanguageName.c_str(),L"English") == 0)
{
SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,index,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);
}
enum { ROUND_EDGE = 15 };
DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE);
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
SetWindowLong(hDlg, GWL_STYLE, dwStyle);
// Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP));
hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM));
hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE));
BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
if (hbmpBackgroundTop)
{
// int iHeight = bmTL.bmHeight;
int iWidth = bmTL.bmWidth;
RECT rect;
GetWindowRect(hDlg, &rect);
rect.left -= rect.left;
rect.bottom -= rect.top;
rect.top -= rect.top;
// Tweaked
HRGN hWindowRegion= CreateRoundRectRgn
(
rect.left,
rect.top,
rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1,
rect.bottom+GetSystemMetrics(SM_CYEDGE)-1,
ROUND_EDGE,
ROUND_EDGE
);
if (hWindowRegion)
{
SetWindowRgn(hDlg, hWindowRegion, TRUE);
DeleteObject(hWindowRegion);
}
}
hTextFont = ::CreateFont
(
18,
0,
0,
0,
FW_NORMAL,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial"
);
SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE);
}
hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK));
pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC);
::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc);
break;
case WM_NCHITTEST:
int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0);
if (Index < 0)
{
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
RECT client, a;
GetClientRect(hDlg,&a);
GetClientRect(hDlg,&client);
ClientToScreen(hDlg,(LPPOINT)&client);
client.right += client.left;
client.bottom += client.top;
int nCaption = GetSystemMetrics(SM_CYCAPTION)*4;
LRESULT lResult = HTCLIENT;
//check caption
if (xPos <= client.right && xPos >= client.left &&
(yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption))
{
lResult = HTCAPTION;
}
SetWindowLong(hDlg, DWLP_MSGRESULT, lResult);
return TRUE;
SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0);
}
break;
// Use the size of the image
hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO));
BITMAP bmTL;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL);
hTextFont = ::CreateFont
(
18,
0,
0,
0,
FW_NORMAL,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"Arial"
);
SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE);
}
break;
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(0, 0, 0));
SetBkMode(hdcStatic, TRANSPARENT);
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
}
break;
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(0, 0, 0));
SetBkMode(hdcStatic, TRANSPARENT);
return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH));
}
break;
case WM_ERASEBKGND:
{
HPEN outline;
HBRUSH fill;
RECT rect;
outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF);
fill = CreateSolidBrush(0x00FFFFFF);
SelectObject((HDC)wParam, outline);
SelectObject((HDC)wParam, fill);
GetClientRect(hDlg, &rect);
Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom);
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hDlg, &ps))
{
PAINTSTRUCT ps;
RECT rcClient;
GetClientRect(hDlg, &rcClient);
if (BeginPaint(hDlg,&ps))
{
RECT rcClient;
GetClientRect(hDlg, &rcClient);
BITMAP bmTL_top;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
BITMAP bmTL_top, bmTL_bottom, bmTL_Middle;
GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top);
GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom);
GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
HDC memdc = CreateCompatibleDC(ps.hdc);
HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop);
BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundMiddle);
for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight)
{
//BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY);
BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY);
}
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
memdc = CreateCompatibleDC(ps.hdc);
save = SelectObject(memdc, hbmpBackgroundBottom);
BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY);
SelectObject(memdc, save);
DeleteDC(memdc);
BITMAP ;
EndPaint(hDlg,&ps);
}
EndPaint(hDlg, &ps);
}
break;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
@ -316,14 +131,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
{
DeleteObject(hbmpBackgroundTop);
}
if (hbmpBackgroundBottom)
{
DeleteObject(hbmpBackgroundBottom);
}
if (hbmpBackgroundMiddle)
{
DeleteObject(hbmpBackgroundMiddle);
}
if (hTextFont)
{
@ -331,17 +138,17 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM
}
{
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)
{
wchar_t String[255];
SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETLBTEXT,Index,(LPARAM)String);
SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETLBTEXT, Index, (LPARAM)String);
g_Lang->SetLanguage(String);
}
}
EndDialog(hDlg,0);
EndDialog(hDlg, 0);
break;
}
default:

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -13,13 +13,13 @@
class CLanguageSelector
{
public:
CLanguageSelector ();
CLanguageSelector();
void Select ( void );
void Select(void);
private:
CLanguageSelector(const CLanguageSelector&); // Disable copy constructor
CLanguageSelector& operator=(const CLanguageSelector&); // Disable assignment
static LRESULT CALLBACK LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -16,7 +16,6 @@
#include <math.h>
#include "User Interface.h"
#include "N64 System/Types.h"
class CNotification;
#include "N64 System/Profiling Class.h"
@ -45,7 +44,6 @@ class CNotification;
//C Core - to be upgrdaded and removed
#include "N64 System/C Core/r4300i Commands.h"
#include "N64 System/C Core/Logging.h"
//Interpter
#include "N64 System/Interpreter/Interpreter Ops.h"
@ -65,7 +63,6 @@ class CNotification;
#include "N64 System/Recompiler/Section Info.h"
#include "N64 System/Recompiler/Function Info.h"
#include "N64 System/Recompiler/Function Map Class.h"
#include "N64 System/Recompiler/Delay Slot Map Class.h"
#include "N64 System/Recompiler/Recompiler Class.h"
#include "N64 System/Recompiler/x86CodeLog.h"
@ -78,4 +75,3 @@ class CNotification;
//Main Files
#include "N64 System/N64 Class.h"
#include "N64 System/System Globals.h"

View File

@ -1,920 +0,0 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include <prsht.h>
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value);
void SaveLogOptions (void);
LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM );
LOG_OPTIONS LogOptions,TempOptions;
HANDLE hLogFile = NULL;
void EnterLogOptions(HWND hwndOwner)
{
PROPSHEETPAGE psp[3];
PROPSHEETHEADER psh;
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = GetModuleHandle(NULL);
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_Logging_Registers);
psp[0].pfnDlgProc = (DLGPROC)LogRegProc;
psp[0].pszTitle = "Registers";
psp[0].lParam = 0;
psp[0].pfnCallback = NULL;
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = GetModuleHandle(NULL);
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_Logging_PifRam);
psp[1].pfnDlgProc = (DLGPROC)LogPifProc;
psp[1].pszTitle = "Pif Ram";
psp[1].lParam = 0;
psp[1].pfnCallback = NULL;
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = GetModuleHandle(NULL);
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_Logging_General);
psp[2].pfnDlgProc = (DLGPROC)LogGeneralProc;
psp[2].pszTitle = "General";
psp[2].lParam = 0;
psp[2].pfnCallback = NULL;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = hwndOwner;
psh.hInstance = GetModuleHandle(NULL);
psh.pszCaption = (LPSTR) "Log Options";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = NULL;
LoadLogOptions(&TempOptions,TRUE);
#if defined(WINDOWS_UI)
PropertySheet(&psh);
#else
g_Notify -> BreakPoint(__FILEW__, __LINE__);
#endif
SaveLogOptions();
LoadLogOptions(&LogOptions, FALSE);
return;
}
void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill)
{
long lResult;
HKEY hKeyResults = 0;
char String[200];
sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str());
lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS,
&hKeyResults);
if (lResult == ERROR_SUCCESS)
{
//LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog);
if (LogOptions->GenerateLog || AlwaysFill)
{
LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters);
LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters);
LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters);
LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters);
LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface);
LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface);
LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface);
LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface);
LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface);
LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface);
LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations);
LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads);
LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads);
LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores);
LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores);
LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak);
LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes);
LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads);
LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions);
LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts);
LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB);
LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache);
LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader);
LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown);
return;
}
}
LogOptions->GenerateLog = FALSE;
LogOptions->LogRDRamRegisters = FALSE;
LogOptions->LogSPRegisters = FALSE;
LogOptions->LogDPCRegisters = FALSE;
LogOptions->LogDPSRegisters = FALSE;
LogOptions->LogMIPSInterface = FALSE;
LogOptions->LogVideoInterface = FALSE;
LogOptions->LogAudioInterface = FALSE;
LogOptions->LogPerInterface = FALSE;
LogOptions->LogRDRAMInterface = FALSE;
LogOptions->LogSerialInterface = FALSE;
LogOptions->LogPRDMAOperations = FALSE;
LogOptions->LogPRDirectMemLoads = FALSE;
LogOptions->LogPRDMAMemLoads = FALSE;
LogOptions->LogPRDirectMemStores = FALSE;
LogOptions->LogPRDMAMemStores = FALSE;
LogOptions->LogControllerPak = FALSE;
LogOptions->LogCP0changes = FALSE;
LogOptions->LogCP0reads = FALSE;
LogOptions->LogCache = FALSE;
LogOptions->LogExceptions = FALSE;
LogOptions->NoInterrupts = FALSE;
LogOptions->LogTLB = FALSE;
LogOptions->LogRomHeader = FALSE;
LogOptions->LogUnknown = FALSE;
}
void LoadLogSetting (HKEY hKey,char * String, BOOL * Value)
{
DWORD Type, dwResult, Bytes = 4;
long lResult;
lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes);
if (Type == REG_DWORD && lResult == ERROR_SUCCESS)
{
*Value = (BOOL)dwResult;
}
else
{
*Value = FALSE;
}
}
LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); }
if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg,IDC_CP0_READ,BST_CHECKED); }
if (TempOptions.LogCache) { CheckDlgButton(hDlg,IDC_CACHE,BST_CHECKED); }
if (TempOptions.LogExceptions) { CheckDlgButton(hDlg,IDC_EXCEPTIONS,BST_CHECKED); }
if (TempOptions.NoInterrupts) { CheckDlgButton(hDlg,IDC_INTERRUPTS,BST_CHECKED); }
if (TempOptions.LogTLB) { CheckDlgButton(hDlg,IDC_TLB,BST_CHECKED); }
if (TempOptions.LogRomHeader) { CheckDlgButton(hDlg,IDC_ROM_HEADER,BST_CHECKED); }
if (TempOptions.LogUnknown) { CheckDlgButton(hDlg,IDC_UNKOWN,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; }
TempOptions.LogCP0changes = IsDlgButtonChecked(hDlg,IDC_CP0_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogCP0reads = IsDlgButtonChecked(hDlg,IDC_CP0_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogCache = IsDlgButtonChecked(hDlg,IDC_CACHE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogExceptions = IsDlgButtonChecked(hDlg,IDC_EXCEPTIONS) == BST_CHECKED?TRUE:FALSE;
TempOptions.NoInterrupts = IsDlgButtonChecked(hDlg,IDC_INTERRUPTS) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogTLB = IsDlgButtonChecked(hDlg,IDC_TLB) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogRomHeader = IsDlgButtonChecked(hDlg,IDC_ROM_HEADER) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogUnknown = IsDlgButtonChecked(hDlg,IDC_UNKOWN) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
void Log_LW (DWORD PC, DWORD VAddr)
{
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
DWORD PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
{
if (LogOptions.LogUnknown)
{
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
}
return;
}
VAddr = PAddr + 0xA0000000;
}
DWORD Value;
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!LogOptions.LogRDRamRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return;
case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return;
case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return;
case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return;
case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return;
case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return;
case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return;
case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return;
}
}
if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC )
{
return;
}
if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C )
{
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break;
case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break;
case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break;
case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break;
case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break;
case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break;
case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break;
}
return;
}
if ( VAddr == 0xA4080000)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SP_PC (%08X)",PC, Value);
return;
}
if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!LogOptions.LogDPCRegisters)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return;
case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return;
case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return;
case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return;
case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return;
case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return;
case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return;
case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!LogOptions.LogMIPSInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return;
case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return;
case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return;
case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!LogOptions.LogVideoInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return;
case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return;
case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return;
case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return;
case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return;
case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return;
case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return;
case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return;
case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return;
case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return;
case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return;
case 0xA4400030: LogMessage("%08X: read from VI_X_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 (!LogOptions.LogAudioInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return;
case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return;
case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return;
case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return;
case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return;
}
}
if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!LogOptions.LogPerInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return;
case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return;
case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return;
case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return;
case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return;
case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return;
case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return;
case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return;
case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return;
case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return;
case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_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 (!LogOptions.LogRDRAMInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return;
case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return;
case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return;
case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return;
case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return;
case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return;
case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return;
case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return;
}
}
if ( VAddr == 0xA4800000)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800004)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800010)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value);
return;
}
if ( VAddr == 0xA4800018)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value);
return;
}
if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 )
{
return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!LogOptions.LogPRDirectMemLoads)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value);
return;
}
if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize()))
{
return;
}
if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040)
{
if (!LogOptions.LogRomHeader)
{
return;
}
g_MMU->LW_VAddr(VAddr,Value);
switch (VAddr)
{
case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break;
case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break;
case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break;
case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break;
case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break;
default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break;
}
return;
}
if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr);
}
void __cdecl LogMessage (char * Message, ...)
{
DWORD dwWritten;
char Msg[400];
va_list ap;
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
if (hLogFile == NULL)
{
return;
}
va_start( ap, Message );
vsprintf( Msg, Message, ap );
va_end( ap );
strcat(Msg,"\r\n");
WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL );
}
void Log_SW (DWORD PC, DWORD VAddr, DWORD Value)
{
if (!LogOptions.GenerateLog)
{
return;
}
if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 )
{
DWORD PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr))
{
if (LogOptions.LogUnknown)
{
LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr );
}
return;
}
VAddr = PAddr + 0xA0000000;
}
if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize()))
{
return;
}
if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024)
{
if (!LogOptions.LogRDRamRegisters)
{
return;
}
switch (VAddr)
{
case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return;
case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return;
case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return;
case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return;
case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return;
case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return;
case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return;
case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return;
case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_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 >= 0xA4040000 && VAddr <= 0xA404001C)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return;
case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return;
case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return;
case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return;
case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return;
case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return;
case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4080000)
{
if (!LogOptions.LogSPRegisters)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return;
}
if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C)
{
if (!LogOptions.LogDPCRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return;
case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return;
case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return;
case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return;
case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return;
case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return;
case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return;
case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C)
{
if (!LogOptions.LogDPSRegisters)
{
return;
}
switch (VAddr)
{
case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return;
case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return;
case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return;
case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C)
{
if (!LogOptions.LogMIPSInterface)
{
return;
}
switch (VAddr)
{
case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return;
case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return;
case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return;
case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034)
{
if (!LogOptions.LogVideoInterface)
{
return;
}
switch (VAddr)
{
case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return;
case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return;
case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return;
case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return;
case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return;
case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return;
case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return;
case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return;
case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return;
case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return;
case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return;
case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return;
case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014)
{
if (!LogOptions.LogAudioInterface)
{
return;
}
switch (VAddr)
{
case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return;
case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return;
case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return;
case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return;
case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return;
}
}
if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030)
{
if (!LogOptions.LogPerInterface)
{
return;
}
switch (VAddr)
{
case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return;
case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return;
case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return;
case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return;
case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return;
case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return;
case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return;
case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return;
case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return;
case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return;
case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return;
case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_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 (!LogOptions.LogRDRAMInterface)
{
return;
}
switch (VAddr)
{
case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return;
case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return;
case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return;
case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return;
case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return;
case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return;
case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return;
case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return;
}
}
if ( VAddr == 0xA4800000)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800004)
{
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC );
}
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800010)
{
if (LogOptions.LogPRDMAOperations)
{
LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC );
}
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return;
}
if ( VAddr == 0xA4800018)
{
if (!LogOptions.LogSerialInterface)
{
return;
}
LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return;
}
if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC )
{
if (!LogOptions.LogPRDirectMemStores)
{
return;
}
LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0);
return;
}
if (!LogOptions.LogUnknown)
{
return;
}
LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr );
}
LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); }
if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg,IDC_DIRECT_WRITE,BST_CHECKED); }
if (TempOptions.LogPRDMAMemLoads) { CheckDlgButton(hDlg,IDC_DMA_WRITE,BST_CHECKED); }
if (TempOptions.LogPRDirectMemStores) { CheckDlgButton(hDlg,IDC_DIRECT_READ,BST_CHECKED); }
if (TempOptions.LogPRDMAMemStores) { CheckDlgButton(hDlg,IDC_DMA_READ,BST_CHECKED); }
if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg,IDC_CONT_PAK,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg,IDC_SI_DMA) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg,IDC_DIRECT_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg,IDC_DMA_WRITE) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDirectMemStores = IsDlgButtonChecked(hDlg,IDC_DIRECT_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPRDMAMemStores = IsDlgButtonChecked(hDlg,IDC_DMA_READ) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogControllerPak = IsDlgButtonChecked(hDlg,IDC_CONT_PAK) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); }
if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg,IDC_SP_REG,BST_CHECKED); }
if (TempOptions.LogDPCRegisters) { CheckDlgButton(hDlg,IDC_DPC_REG,BST_CHECKED); }
if (TempOptions.LogDPSRegisters) { CheckDlgButton(hDlg,IDC_DPS_REG,BST_CHECKED); }
if (TempOptions.LogMIPSInterface) { CheckDlgButton(hDlg,IDC_MI_REG,BST_CHECKED); }
if (TempOptions.LogVideoInterface) { CheckDlgButton(hDlg,IDC_VI_REG,BST_CHECKED); }
if (TempOptions.LogAudioInterface) { CheckDlgButton(hDlg,IDC_AI_REG,BST_CHECKED); }
if (TempOptions.LogPerInterface) { CheckDlgButton(hDlg,IDC_PI_REG,BST_CHECKED); }
if (TempOptions.LogRDRAMInterface) { CheckDlgButton(hDlg,IDC_RI_REG,BST_CHECKED); }
if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg,IDC_SI_REG,BST_CHECKED); }
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY)
{
break;
}
TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg,IDC_RDRAM) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg,IDC_SP_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg,IDC_DPC_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogDPSRegisters = IsDlgButtonChecked(hDlg,IDC_DPS_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogMIPSInterface = IsDlgButtonChecked(hDlg,IDC_MI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogVideoInterface = IsDlgButtonChecked(hDlg,IDC_VI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogAudioInterface = IsDlgButtonChecked(hDlg,IDC_AI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogPerInterface = IsDlgButtonChecked(hDlg,IDC_PI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogRDRAMInterface = IsDlgButtonChecked(hDlg,IDC_RI_REG) == BST_CHECKED?TRUE:FALSE;
TempOptions.LogSerialInterface = IsDlgButtonChecked(hDlg,IDC_SI_REG) == BST_CHECKED?TRUE:FALSE;
break;
default:
return FALSE;
}
return TRUE;
}
void SaveLogSetting (HKEY hKey,char * String, BOOL Value)
{
DWORD StoreValue = Value;
RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD));
}
void SaveLogOptions (void)
{
long lResult;
HKEY hKeyResults = 0;
DWORD Disposition = 0;
char String[200];
sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str());
lResult = RegCreateKeyEx( HKEY_CURRENT_USER,String,0,"", REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,NULL,&hKeyResults,&Disposition);
SaveLogSetting(hKeyResults,"Log RDRAM",TempOptions.LogRDRamRegisters);
SaveLogSetting(hKeyResults,"Log SP",TempOptions.LogSPRegisters);
SaveLogSetting(hKeyResults,"Log DP Command",TempOptions.LogDPCRegisters);
SaveLogSetting(hKeyResults,"Log DP Span",TempOptions.LogDPSRegisters);
SaveLogSetting(hKeyResults,"Log MIPS Interface (MI)",TempOptions.LogMIPSInterface);
SaveLogSetting(hKeyResults,"Log Video Interface (VI)",TempOptions.LogVideoInterface);
SaveLogSetting(hKeyResults,"Log Audio Interface (AI)",TempOptions.LogAudioInterface);
SaveLogSetting(hKeyResults,"Log Peripheral Interface (PI)",TempOptions.LogPerInterface);
SaveLogSetting(hKeyResults,"Log RDRAM Interface (RI)",TempOptions.LogRDRAMInterface);
SaveLogSetting(hKeyResults,"Log Serial Interface (SI)",TempOptions.LogSerialInterface);
SaveLogSetting(hKeyResults,"Log PifRam DMA Operations",TempOptions.LogPRDMAOperations);
SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",TempOptions.LogPRDirectMemLoads);
SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",TempOptions.LogPRDMAMemLoads);
SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",TempOptions.LogPRDirectMemStores);
SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",TempOptions.LogPRDMAMemStores);
SaveLogSetting(hKeyResults,"Log Controller Pak",TempOptions.LogControllerPak);
SaveLogSetting(hKeyResults,"Log CP0 changes",TempOptions.LogCP0changes);
SaveLogSetting(hKeyResults,"Log CP0 reads",TempOptions.LogCP0reads);
SaveLogSetting(hKeyResults,"Log Exceptions",TempOptions.LogExceptions);
SaveLogSetting(hKeyResults,"No Interrupts",TempOptions.NoInterrupts);
SaveLogSetting(hKeyResults,"Log TLB",TempOptions.LogTLB);
SaveLogSetting(hKeyResults,"Log Cache Operations",TempOptions.LogCache);
SaveLogSetting(hKeyResults,"Log Rom Header",TempOptions.LogRomHeader);
SaveLogSetting(hKeyResults,"Log Unknown access",TempOptions.LogUnknown);
RegCloseKey(hKeyResults);
}
void StartLog (void)
{
if (!LogOptions.GenerateLog)
{
StopLog();
return;
}
if (hLogFile)
{
return;
}
CPath LogFile(CPath::MODULE_DIRECTORY);
LogFile.AppendDirectory("Logs");
LogFile.SetNameExtension("cpudebug.log");
hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
SetFilePointer(hLogFile,0,NULL,FILE_BEGIN);
}
void StopLog (void)
{
if (hLogFile)
{
CloseHandle(hLogFile);
}
hLogFile = NULL;
}

View File

@ -1,63 +0,0 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
BOOL GenerateLog;
/* Registers Log */
BOOL LogRDRamRegisters;
BOOL LogSPRegisters;
BOOL LogDPCRegisters;
BOOL LogDPSRegisters;
BOOL LogMIPSInterface;
BOOL LogVideoInterface;
BOOL LogAudioInterface;
BOOL LogPerInterface;
BOOL LogRDRAMInterface;
BOOL LogSerialInterface;
/* Pif Ram Log */
BOOL LogPRDMAOperations;
BOOL LogPRDirectMemLoads;
BOOL LogPRDMAMemLoads;
BOOL LogPRDirectMemStores;
BOOL LogPRDMAMemStores;
BOOL LogControllerPak;
/* Special Log */
BOOL LogCP0changes;
BOOL LogCP0reads;
BOOL LogTLB;
BOOL LogExceptions;
BOOL NoInterrupts;
BOOL LogCache;
BOOL LogRomHeader;
BOOL LogUnknown;
} LOG_OPTIONS;
extern LOG_OPTIONS LogOptions;
void EnterLogOptions ( HWND hwndOwner );
void LoadLogOptions ( LOG_OPTIONS * LogOptions, BOOL AlwaysFill );
void Log_LW ( DWORD PC, DWORD VAddr );
void __cdecl LogMessage ( char * Message, ... );
void Log_SW ( DWORD PC, DWORD VAddr, DWORD Value );
void StartLog ( void );
void StopLog ( void );
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,82 +10,39 @@
****************************************************************************/
#pragma once
class CCheats
class CCheats
{
public:
CCheats ( const CN64Rom * Rom = NULL );
~CCheats ( void );
CCheats();
~CCheats(void);
bool IsCheatMessage ( MSG * msg );
void ApplyCheats ( CMipsMemory * MMU );
void ApplyGSButton ( CMipsMemory * MMU );
void LoadCheats ( bool DisableSelected, CPlugins * Plugins );
void SelectCheats ( HWND hParent, bool BlockExecution );
inline bool CheatsSlectionChanged ( void ) const { return m_CheatSelectionChanged; }
enum
{
MaxCheats = 50000,
MaxGSEntries = 100,
};
void ApplyCheats(CMipsMemory * MMU);
void ApplyGSButton(CMipsMemory * MMU);
void LoadCheats(bool DisableSelected, CPlugins * Plugins);
static bool IsValid16BitCode(const char * CheatString);
private:
struct GAMESHARK_CODE {
DWORD Command;
WORD Value;
};
struct GAMESHARK_CODE
{
uint32_t Command;
uint16_t Value;
};
typedef std::vector<GAMESHARK_CODE> CODES;
typedef std::vector<CODES> CODES_ARRAY;
typedef std::vector<GAMESHARK_CODE> CODES;
typedef std::vector<CODES> CODES_ARRAY;
enum { MaxCheats = 50000 };
void LoadPermCheats ( CPlugins * Plugins );
static int CALLBACK CheatAddProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatListProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK ManageCheatsProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatsCodeExProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
static int CALLBACK CheatsCodeQuantProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
//information about the gui for selecting cheats
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
const CN64Rom * m_Rom;
void * const m_rcList, * const m_rcAdd;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_EditCheat;
bool m_DeleteingEntries;
CODES_ARRAY m_Codes;
bool m_CheatSelectionChanged;
//Information about the current cheat we are editing
stdstr m_EditName;
stdstr m_EditCode;
stdstr m_EditOptions;
stdstr m_EditNotes;
void LoadPermCheats(CPlugins * Plugins);
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
enum { MaxGSEntries = 100, IDC_MYTREE = 0x500 };
const CN64Rom * m_Rom;
CODES_ARRAY m_Codes;
bool LoadCode ( int CheatNo, LPCSTR CheatString );
void AddCodeLayers ( int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive );
//Reload the cheats from the ini file to the select gui
void RefreshCheatManager ();
void ChangeChildrenStatus ( HWND hParent, bool Checked );
void CheckParentStatus ( HWND hParent );
static stdstr ReadCodeString ( HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat );
static stdstr ReadOptionsString( HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat );
int ApplyCheatEntry (CMipsMemory * MMU,const CODES & CodeEntry, int CurrentEntry, bool Execute );
void RecordCheatValues ( HWND hDlg );
bool CheatChanged ( HWND hDlg );
bool IsValid16BitCode ( LPCSTR CheatString ) const;
void DeleteCheat(int Index);
//Get Information about the Cheat
stdstr GetCheatName ( int CheatNo, bool AddExtension ) const;
static bool CheatUsesCodeExtensions ( const stdstr &LineEntry );
//Working with treeview
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
static DWORD AsciiToHex ( const char * HexValue );
static void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut );
//UI Functions
static stdstr GetDlgItemStr (HWND hDlg, int nIDDlgItem);
bool LoadCode(int32_t CheatNo, const char * CheatString);
int32_t ApplyCheatEntry(CMipsMemory * MMU, const CODES & CodeEntry, int32_t CurrentEntry, bool Execute);
};

View File

@ -1,76 +1,76 @@
template <class T>
class CDebugDialog :
public CDialogImpl<T>
public CDialogImpl < T >
{
protected:
CDebugger * m_Debugger;
HANDLE m_CreatedEvent;
HANDLE m_DialogThread;
CDebuggerUI * m_Debugger;
HANDLE m_CreatedEvent;
HANDLE m_DialogThread;
static DWORD CreateDebuggerWindow (CDebugDialog<T> * pThis)
{
pThis->DoModal(NULL);
pThis->WindowCreated();
return 0;
}
static DWORD CreateDebuggerWindow(CDebugDialog<T> * pThis)
{
pThis->DoModal(NULL);
pThis->WindowCreated();
return 0;
}
void WindowCreated ( void )
{
SetEvent(m_CreatedEvent);
}
void WindowCreated(void)
{
SetEvent(m_CreatedEvent);
}
public:
CDebugDialog (CDebugger * debugger) :
m_Debugger(debugger),
m_CreatedEvent(CreateEvent(NULL,true,false,NULL)),
m_DialogThread(NULL)
{
}
virtual ~CDebugDialog (void)
{
HideWindow();
CloseHandle(m_CreatedEvent);
if (m_DialogThread)
{
CloseHandle(m_DialogThread);
m_DialogThread = NULL;
}
}
CDebugDialog(CDebuggerUI * debugger) :
m_Debugger(debugger),
m_CreatedEvent(CreateEvent(NULL, true, false, NULL)),
m_DialogThread(NULL)
{
}
virtual ~CDebugDialog(void)
{
HideWindow();
CloseHandle(m_CreatedEvent);
if (m_DialogThread)
{
CloseHandle(m_DialogThread);
m_DialogThread = NULL;
}
}
void HideWindow ( void )
{
if (m_hWnd && ::IsWindow(m_hWnd))
{
::EndDialog(m_hWnd, 0);
}
if (m_DialogThread)
{
if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT)
{
WriteTrace(TraceError,"CDebugDialog - time out on close");
void HideWindow(void)
{
if (m_hWnd && ::IsWindow(m_hWnd))
{
::EndDialog(m_hWnd, 0);
}
if (m_DialogThread)
{
if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT)
{
WriteTrace(TraceError, "CDebugDialog - time out on close");
TerminateThread(m_DialogThread, 1);
}
CloseHandle(m_DialogThread);
m_DialogThread = NULL;
}
}
TerminateThread(m_DialogThread, 1);
}
CloseHandle(m_DialogThread);
m_DialogThread = NULL;
}
}
void ShowWindow ( void )
{
if (m_hWnd)
{
SetForegroundWindow((HWND)m_hWnd);
}
else
{
DWORD ThreadID;
ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID);
if (WaitForSingleObject(m_CreatedEvent,20000) == WAIT_TIMEOUT)
{
WriteTrace(TraceError,"Failed to get window create notification");
}
}
}
void ShowWindow(void)
{
if (m_hWnd)
{
SetForegroundWindow((HWND)m_hWnd);
}
else
{
DWORD ThreadID;
ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateDebuggerWindow, (LPVOID)this, 0, &ThreadID);
if (WaitForSingleObject(m_CreatedEvent, 20000) == WAIT_TIMEOUT)
{
WriteTrace(TraceError, "Failed to get window create notification");
}
}
}
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,11 +10,10 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CDumpMemory::CDumpMemory(CDebugger * debugger) :
CDebugDialog<CDumpMemory>(debugger)
CDumpMemory::CDumpMemory(CDebuggerUI * debugger) :
CDebugDialog<CDumpMemory>(debugger)
{
}
@ -24,575 +23,135 @@ CDumpMemory::~CDumpMemory()
LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR));
m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR));
m_PC.Attach(GetDlgItem(IDC_E_ALT_PC));
m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR));
m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR));
m_PC.Attach(GetDlgItem(IDC_E_ALT_PC));
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetValue(0x80000000,true,true);
m_EndAddress.SetValue(0x803FFFF0,true,true);
m_PC.SetValue(0x80000000);
HWND hFormatList = GetDlgItem(IDC_FORMAT);
int pos = ::SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC");
::SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC);
::SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
m_StartAddress.SetValue(0x80000000, true, true);
m_EndAddress.SetValue(0x803FFFF0, true, true);
m_PC.SetValue(0x80000000);
HWND hFormatList = GetDlgItem(IDC_FORMAT);
int pos = ::SendMessage(hFormatList, CB_ADDSTRING, (WPARAM)0, (LPARAM)"TEXT - Disassembly + PC");
::SendMessage(hFormatList, CB_SETITEMDATA, (WPARAM)pos, (LPARAM)DisassemblyWithPC);
::SendMessage(hFormatList, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
WindowCreated();
return TRUE;
WindowCreated();
return TRUE;
}
LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
switch(wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_BTN_CHOOSE_FILE:
{
char FileName[_MAX_PATH],Directory[_MAX_PATH];
OPENFILENAME openfilename;
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_BTN_CHOOSE_FILE:
{
char FileName[_MAX_PATH], Directory[_MAX_PATH];
OPENFILENAME openfilename;
memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory,CPath(CPath::MODULE_DIRECTORY));
openfilename.lStructSize = sizeof( openfilename );
openfilename.hwndOwner = m_hWnd;
openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (GetOpenFileName (&openfilename))
{
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath( FileName, drive, dir, fname, ext );
if (strlen(ext) == 0)
{
strcat(FileName,".txt");
}
SetDlgItemText(IDC_FILENAME,FileName);
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
break;
case IDOK:
{
TCHAR FileName[MAX_PATH];
int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT,CB_GETCURSEL,0,0);
DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0);
DWORD StartPC =m_StartAddress.GetValue();
DWORD EndPC = m_EndAddress.GetValue();
DWORD DumpPC = m_PC.GetValue();
GetDlgItemText(IDC_FILENAME,FileName,sizeof(FileName));
if (strlen(FileName) == 0)
{
g_Notify->DisplayError(L"Please Choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME));
return false;
}
if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
{
DumpPC = g_Reg->m_PROGRAM_COUNTER;
}
//disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR),FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC),FALSE);
::EnableWindow(GetDlgItem(IDC_USE_ALT_PC),FALSE);
::EnableWindow(GetDlgItem(IDC_FILENAME),FALSE);
::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE),FALSE);
::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE);
::EnableWindow(GetDlgItem(IDOK),FALSE);
::EnableWindow(GetDlgItem(IDCANCEL),FALSE);
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
{
//enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false;
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
EndDialog(0);
break;
}
return FALSE;
memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory, CPath(CPath::MODULE_DIRECTORY));
openfilename.lStructSize = sizeof(openfilename);
openfilename.hwndOwner = m_hWnd;
openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (GetOpenFileName(&openfilename))
{
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath(FileName, drive, dir, fname, ext);
if (strlen(ext) == 0)
{
strcat(FileName, ".txt");
}
SetDlgItemText(IDC_FILENAME, FileName);
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
break;
case IDOK:
{
TCHAR FileName[MAX_PATH];
int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0);
DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0);
DWORD StartPC = m_StartAddress.GetValue();
DWORD EndPC = m_EndAddress.GetValue();
DWORD DumpPC = m_PC.GetValue();
GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName));
if (strlen(FileName) == 0)
{
g_Notify->DisplayError(L"Please Choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME));
return false;
}
if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED)
{
DumpPC = g_Reg->m_PROGRAM_COUNTER;
}
//disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE);
::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE);
::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE);
::EnableWindow(GetDlgItem(IDOK), FALSE);
::EnableWindow(GetDlgItem(IDCANCEL), FALSE);
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC))
{
//enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false;
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
EndDialog(0);
break;
}
return FALSE;
}
//#include "..\\..\\User Interface.h"
//#include "..\\..\\N64 System.h"
//#include <windows.h>
//
//DWORD CDumpMemory::m_StartAddress = 0x80000000;
//DWORD CDumpMemory::m_EndAddress = 0x803FFFF0;
//CDumpMemory::CDumpMemory(CMipsMemory * MMU) :
// m_Window(NULL), g_MMU(MMU)
//{
//}
//CDumpMemory::~CDumpMemory()
//{
//}
//void CDumpMemory::DisplayDump(HWND & hParent)
//{
// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
// Finish = strlen(HexValue);
// if (Finish > 8 )
// {
// Finish = 8;
// }
// for (Count = 0; Count < Finish; Count++
// {
// Value = (Value << 4);
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
// case '3': Value += 3; break;
// case '4': Value += 4; break;
// case '5': Value += 5; break;
// case '6': Value += 6; break;
// case '7': Value += 7; break;
// case '8': Value += 8; break;
// case '9': Value += 9; break;
// case 'A': Value += 10; break;
// case 'a': Value += 10; break;
// case 'B': Value += 11; break;
// case 'b': Value += 11; break;
// case 'C': Value += 12; break;
// case 'c': Value += 12; break;
// case 'D': Value += 13; break;
// case 'd': Value += 13; break;
// case 'E': Value += 14; break;
// case 'e': Value += 14; break;
// case 'F': Value += 15; break;
// case 'f': Value += 15; break;
// default:
// Value = (Value >> 4);
// Count = Finish;
// }
// }
// return Value;
//}
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
// SetProp(hDlg,"Class",_this);
// _this->m_Window = hDlg;
// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000");
// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT);
// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC");
// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC);
// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
// }
// break;
// case WM_COMMAND:
// switch (LOWORD(wParam))
// {
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], szTmp2[20];
// DWORD Value;
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0)
// {
// _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop;
// }
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;
// case IDC_BTN_CHOOSE_FILE:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// OPENFILENAME openfilename;
// char FileName[_MAX_PATH],Directory[_MAX_PATH];
// memset(&FileName, 0, sizeof(FileName));
// memset(&openfilename, 0, sizeof(openfilename));
// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str());
// openfilename.lStructSize = sizeof( openfilename );
// openfilename.hwndOwner = hDlg;
// openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
// openfilename.lpstrFile = FileName;
// openfilename.lpstrInitialDir = Directory;
// openfilename.nMaxFile = MAX_PATH;
// openfilename.Flags = OFN_HIDEREADONLY;
// if (GetOpenFileName (&openfilename))
// {
// char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
// _splitpath( FileName, drive, dir, fname, ext );
// if (strlen(ext) == 0)
// {
// strcat(FileName,".txt");
// }
// SetDlgItemText(hDlg,IDC_FILENAME,FileName);
// }
// }
// break;
// case IDCANCEL:
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// case IDOK:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], FileName[MAX_PATH];
// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0);
// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0);
// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp));
// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp));
// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp));
// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName));
// if (strlen(FileName) == 0)
// {
// g_Notify->DisplayError(L"Please Choose target file");
// SetFocus(GetDlgItem(hDlg,IDC_FILENAME));
// return false;
// }
// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
// {
// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER;
// }
// //disable buttons
// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE);
// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
// {
// //enable buttons
// return false;
// }
// }
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// }
// break;
// default:
// return false;
// }
// return true;
//}
bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/ )
bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/)
{
switch (Format)
{
case DisassemblyWithPC:
{
CLog LogFile;
if (!LogFile.Open(FileName))
{
g_Notify->DisplayError(stdstr_f("Failed to open\n%s",FileName).ToUTF16().c_str());
return false;
}
LogFile.SetFlush(false);
LogFile.SetTruncateFile(false);
g_Notify->BreakPoint(__FILEW__,__LINE__);
switch (Format)
{
case DisassemblyWithPC:
{
CLog LogFile;
if (!LogFile.Open(FileName))
{
g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str());
return false;
}
LogFile.SetFlush(false);
LogFile.SetTruncateFile(false);
g_Notify->BreakPoint(__FILEW__, __LINE__);
#ifdef tofix
char Command[200];
for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
{
const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command);
LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
}
char Command[200];
for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
{
const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command);
LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
}
#endif
m_StartAddress.SetValue(StartPC,true,true);
m_EndAddress.SetValue(EndPC,true,true);
return true;
}
break;
}
return false;
m_StartAddress.SetValue(StartPC, true, true);
m_EndAddress.SetValue(EndPC, true, true);
return true;
}
break;
}
return false;
}
//
//CDumpMemory::CDumpMemory(CMipsMemory * MMU) :
// m_Window(NULL), g_MMU(MMU)
//{
//}
//
//CDumpMemory::~CDumpMemory()
//{
//}
//
//void CDumpMemory::DisplayDump(HWND & hParent)
//{
// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
//
// Finish = strlen(HexValue);
// if (Finish > 8 )
// {
// Finish = 8;
// }
//
// for (Count = 0; Count < Finish; Count++)
// {
// Value = (Value << 4);
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
// case '3': Value += 3; break;
// case '4': Value += 4; break;
// case '5': Value += 5; break;
// case '6': Value += 6; break;
// case '7': Value += 7; break;
// case '8': Value += 8; break;
// case '9': Value += 9; break;
// case 'A': Value += 10; break;
// case 'a': Value += 10; break;
// case 'B': Value += 11; break;
// case 'b': Value += 11; break;
// case 'C': Value += 12; break;
// case 'c': Value += 12; break;
// case 'D': Value += 13; break;
// case 'd': Value += 13; break;
// case 'E': Value += 14; break;
// case 'e': Value += 14; break;
// case 'F': Value += 15; break;
// case 'f': Value += 15; break;
// default:
// Value = (Value >> 4);
// Count = Finish;
// }
// }
// return Value;
//}
//
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
// SetProp(hDlg,"Class",_this);
// _this->m_Window = hDlg;
// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000");
//
// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT);
// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC");
// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC);
// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
//
// }
// break;
// case WM_COMMAND:
// switch (LOWORD(wParam))
// {
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// TCHAR szTmp[20], szTmp2[20];
// DWORD Value;
//
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; }
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;
// case IDC_BTN_CHOOSE_FILE:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// OPENFILENAME openfilename;
// char FileName[_MAX_PATH],Directory[_MAX_PATH];
//
// memset(&FileName, 0, sizeof(FileName));
// memset(&openfilename, 0, sizeof(openfilename));
//
// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str());
//
// openfilename.lStructSize = sizeof( openfilename );
// openfilename.hwndOwner = hDlg;
// openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
// openfilename.lpstrFile = FileName;
// openfilename.lpstrInitialDir = Directory;
// openfilename.nMaxFile = MAX_PATH;
// openfilename.Flags = OFN_HIDEREADONLY;
//
// if (GetOpenFileName (&openfilename))
// {
// char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
//
// _splitpath( FileName, drive, dir, fname, ext );
// if (strlen(ext) == 0)
// {
// strcat(FileName,".txt");
// }
// SetDlgItemText(hDlg,IDC_FILENAME,FileName);
// }
// }
// break;
// case IDCANCEL:
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// case IDOK:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], FileName[MAX_PATH];
//
// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0);
// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0);
//
// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp));
// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp));
// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp));
// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName));
//
// if (strlen(FileName) == 0)
// {
// g_Notify->DisplayError(L"Please Choose target file");
// SetFocus(GetDlgItem(hDlg,IDC_FILENAME));
// return false;
// }
//
// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
// {
// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER;
// }
// //disable buttons
// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE);
// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
// {
// //enable buttons
// return false;
// }
// }
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// }
// break;
// default:
// return false;
// }
// return true;
//}
//
//bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC )
//{
// switch (Format)
// {
// case DisassemblyWithPC:
// {
// CLog LogFile(FileName);
// if (!LogFile.IsOpen())
// {
// g_Notify->DisplayError(L"Failed to open\n%s",FileName);
// return false;
// }
//
// for (COpcode OpCode(g_MMU,StartPC); OpCode.PC() < EndPC; OpCode.Next())
// {
// LogFile.Log("%X: %s",OpCode.PC(),OpCode.Name().c_str());
// }
// m_StartAddress = StartPC;
// m_EndAddress = EndPC;
// return true;
// }
// break;
// }
// return false;
//}
#endif

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,33 +11,33 @@
#pragma once
class CDumpMemory :
public CDebugDialog<CDumpMemory>
public CDebugDialog < CDumpMemory >
{
public:
enum { IDD = IDD_Cheats_DumpMemory };
public:
enum { IDD = IDD_Cheats_DumpMemory };
CDumpMemory(CDebugger * debugger);
virtual ~CDumpMemory(void);
CDumpMemory(CDebuggerUI * debugger);
virtual ~CDumpMemory(void);
private:
CDumpMemory(void); // Disable default constructor
CDumpMemory(const CDumpMemory&); // Disable copy constructor
CDumpMemory& operator=(const CDumpMemory&); // Disable assignment
CDumpMemory(void); // Disable default constructor
CDumpMemory(const CDumpMemory&); // Disable copy constructor
CDumpMemory& operator=(const CDumpMemory&); // Disable assignment
enum DumpFormat
{
DisassemblyWithPC
};
enum DumpFormat
{
DisassemblyWithPC
};
BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
END_MSG_MAP()
BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC );
bool DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC);
CEditNumber m_StartAddress, m_EndAddress, m_PC;
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,59 +11,59 @@
#pragma once
class CDebugMemorySearch :
public CDebugDialog<CDebugMemorySearch>
public CDebugDialog < CDebugMemorySearch >
{
public:
enum { IDD = IDD_Debugger_Search };
public:
enum { IDD = IDD_Debugger_Search };
CDebugMemorySearch(CDebugger * debugger);
virtual ~CDebugMemorySearch(void);
CDebugMemorySearch(CDebuggerUI * debugger);
virtual ~CDebugMemorySearch(void);
private:
CDebugMemorySearch(void); // Disable default constructor
CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor
CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment
CDebugMemorySearch(void); // Disable default constructor
CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor
CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment
enum MemorySize
{
_8Bit,
_16Bit,
_32Bit,
};
enum MemorySize
{
_8Bit,
_16Bit,
_32Bit,
};
//Searching for value
enum SearchMemChangeState
{
SearchChangeState_Reset,
SearchChangeState_Changed,
SearchChangeState_Unchanged,
SearchChangeState_Greater,
SearchChangeState_Lessthan,
};
//Searching for value
enum SearchMemChangeState
{
SearchChangeState_Reset,
SearchChangeState_Changed,
SearchChangeState_Unchanged,
SearchChangeState_Greater,
SearchChangeState_Lessthan,
};
struct SearchResultItem
{
DWORD PAddr;
DWORD Value;
};
struct SearchResultItem
{
DWORD PAddr;
DWORD Value;
};
typedef std::vector<SearchResultItem> SearchResult;
typedef std::vector<SearchResultItem> SearchResult;
BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS,NM_RCLICK,OnResultRClick)
BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnResultRClick ( LPNMHDR lpnmh );
LRESULT OnResultRClick(LPNMHDR lpnmh);
void EnableUnknownOptions ( bool Enable );
void EnableValueOptions ( bool Enable );
void EnableTextOptions ( bool Enable );
void EnableJalOptions ( bool Enable );
void AddAlignmentOptions ( CComboBox & ctrl );
void EnableUnknownOptions(bool Enable);
void EnableValueOptions(bool Enable);
void EnableTextOptions(bool Enable);
void EnableJalOptions(bool Enable);
void AddAlignmentOptions(CComboBox & ctrl);
CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch;
CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize;
@ -75,12 +75,12 @@ private:
BYTE * m_MemoryState;
DWORD m_MemoryStateSize;
void FixUnknownOptions ( bool Reset );
void SearchForUnknown ( void );
void SearchForValue ( void );
void SearchForText ( void );
void Reset ( void );
bool SearchSetBaseForChanges ( void );
bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue );
bool SearchForValue ( DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len );
void FixUnknownOptions(bool Reset);
void SearchForUnknown(void);
void SearchForValue(void);
void SearchForText(void);
void Reset(void);
bool SearchSetBaseForChanges(void);
bool SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue);
bool SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len);
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,11 +10,10 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CDebugTlb::CDebugTlb(CDebugger * debugger) :
CDebugDialog<CDebugTlb>(debugger)
CDebugTlb::CDebugTlb(CDebuggerUI * debugger) :
CDebugDialog<CDebugTlb>(debugger)
{
}
@ -24,267 +23,266 @@ CDebugTlb::~CDebugTlb()
LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
LV_COLUMN col;
LV_COLUMN col;
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt = LVCFMT_LEFT;
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt = LVCFMT_LEFT;
col.pszText = "Index";
col.cx = 40;
col.iSubItem = 0;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 0, &col);
col.pszText = "Index";
col.cx = 40;
col.iSubItem = 0;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col);
col.pszText = "Page Mask";
col.cx = 90;
col.iSubItem = 1;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 1, &col);
col.pszText = "Page Mask";
col.cx = 90;
col.iSubItem = 1;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col);
col.pszText = "Entry Hi";
col.cx = 90;
col.iSubItem = 2;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 2, &col);
col.pszText = "Entry Hi";
col.cx = 90;
col.iSubItem = 2;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 2, &col);
col.pszText = "Entry Lo0";
col.cx = 90;
col.iSubItem = 3;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 3, &col);
col.pszText = "Entry Lo0";
col.cx = 90;
col.iSubItem = 3;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 3, &col);
col.pszText = "Entry Lo1";
col.cx = 90;
col.iSubItem = 4;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 4, &col);
col.pszText = "Entry Lo1";
col.cx = 90;
col.iSubItem = 4;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 4, &col);
col.pszText = "Index";
col.cx = 40;
col.iSubItem = 0;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 0, &col);
col.pszText = "Index";
col.cx = 40;
col.iSubItem = 0;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 0, &col);
col.pszText = "Valid";
col.cx = 40;
col.iSubItem = 1;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 1, &col);
col.pszText = "Valid";
col.cx = 40;
col.iSubItem = 1;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 1, &col);
col.pszText = "Dirty";
col.cx = 40;
col.iSubItem = 2;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 2, &col);
col.pszText = "Dirty";
col.cx = 40;
col.iSubItem = 2;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 2, &col);
col.pszText = "Rule";
col.cx = 270;
col.iSubItem = 3;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 3, &col);
col.pszText = "Rule";
col.cx = 270;
col.iSubItem = 3;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 3, &col);
RefreshTLBWindow();
SendMessage(GetDlgItem(IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0);
// if (Settings().Load(TLBWindowLeft) <= 0)
// {
// SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
// }
WindowCreated();
return TRUE;
RefreshTLBWindow();
SendMessage(GetDlgItem(IDC_TLB_ENTRIES), BM_SETCHECK, BST_CHECKED, 0);
// if (Settings().Load(TLBWindowLeft) <= 0)
// {
// SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
// }
WindowCreated();
return TRUE;
}
LRESULT CDebugTlb::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{
switch(wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_TLB_ENTRIES:
::ShowWindow(GetDlgItem(IDC_LIST),SW_SHOW);
::ShowWindow(GetDlgItem(IDC_LIST2),SW_HIDE);
break;
case IDC_TLB_RULES:
::ShowWindow(GetDlgItem(IDC_LIST),SW_HIDE);
::ShowWindow(GetDlgItem(IDC_LIST2),SW_SHOW);
break;
}
return FALSE;
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_TLB_ENTRIES:
::ShowWindow(GetDlgItem(IDC_LIST), SW_SHOW);
::ShowWindow(GetDlgItem(IDC_LIST2), SW_HIDE);
break;
case IDC_TLB_RULES:
::ShowWindow(GetDlgItem(IDC_LIST), SW_HIDE);
::ShowWindow(GetDlgItem(IDC_LIST2), SW_SHOW);
break;
}
return FALSE;
}
void CDebugTlb::RefreshTLBWindow (void)
void CDebugTlb::RefreshTLBWindow(void)
{
if (m_hWnd == NULL)
{
return;
}
HWND hList = GetDlgItem(IDC_LIST);
char Output[100], OldText[100];
LV_ITEM item, OldItem;
int count;
if (m_hWnd == NULL)
{
return;
}
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
HWND hList = GetDlgItem(IDC_LIST);
char Output[100], OldText[100];
LV_ITEM item, OldItem;
int count;
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count++)
{
sprintf(Output, "0x%02X", count);
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList,&item);
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0;
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryHi.Value);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList, &item);
}
else
{
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
if (tlb[count].EntryDefined)
{
sprintf(Output, "0x%08X", tlb[count].PageMask.Value);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (tlb[count].EntryDefined)
{
sprintf(Output, "0x%08X", tlb[count].EntryHi.Value);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
if (tlb[count].EntryDefined)
{
sprintf(Output, "0x%08X", tlb[count].EntryLo0.Value);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
if (tlb[count].EntryDefined)
{
sprintf(Output, "0x%08X", tlb[count].EntryLo1.Value);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList,&item);
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count++)
{
sprintf(Output, "0x%02X", count);
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
if (FastTlb[count].ValidEntry)
{
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0;
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList, &item);
}
else
{
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (FastTlb[count].ValidEntry)
{
sprintf(Output, "%s", FastTlb[count].VALID ? "Yes" : "No");
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output, "%s", FastTlb[count].DIRTY ? "Yes" : "No");
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output, "%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND,
FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
}
#endif

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,22 +11,21 @@
#pragma once
class CDebugTlb :
public CDebugDialog<CDebugTlb>
public CDebugDialog < CDebugTlb >
{
BEGIN_MSG_MAP_EX(CDebugTlb)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
BEGIN_MSG_MAP_EX(CDebugTlb)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
public:
enum { IDD = IDD_Debugger_TLB };
public:
enum { IDD = IDD_Debugger_TLB };
CDebugTlb(CDebugger * debugger);
virtual ~CDebugTlb(void);
CDebugTlb(CDebuggerUI * debugger);
virtual ~CDebugTlb(void);
void RefreshTLBWindow ( void );
void RefreshTLBWindow(void);
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,18 +10,17 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) :
CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL)
CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL)
{
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
}
CDebugMemoryView::~CDebugMemoryView()
@ -30,446 +29,444 @@ CDebugMemoryView::~CDebugMemoryView()
LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_DataStartLoc = (DWORD)-1;
m_CompareStartLoc = (DWORD)-1;
memset(m_CompareData,0,sizeof(m_CompareData));
memset(m_CompareValid,0,sizeof(m_CompareValid));
m_DataStartLoc = (DWORD)-1;
m_CompareStartLoc = (DWORD)-1;
memset(m_CompareData, 0, sizeof(m_CompareData));
memset(m_CompareValid, 0, sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
si.nMax = 0xFFFF;
si.nPos = 0x8000;
si.nPage = 100;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
}
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
si.nMax = 0xFFFF;
si.nPos = 0x8000;
si.nPage = 100;
::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
}
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetValue(0x80000000,true,true);
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetValue(0x80000000, true, true);
SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED,0);
SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED, 0);
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) );
m_MemoryList->ShowHeader(false);
m_MemoryList->SetSortEnabled(FALSE);
m_MemoryList->AddColumn( _T( "Address" ), 90 );
m_MemoryList->AddColumn( _T( "1" ), 20 );
m_MemoryList->AddColumn( _T( "2" ), 20 );
m_MemoryList->AddColumn( _T( "3" ), 20 );
m_MemoryList->AddColumn( _T( "4" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "5" ), 20 );
m_MemoryList->AddColumn( _T( "6" ), 20 );
m_MemoryList->AddColumn( _T( "7" ), 20 );
m_MemoryList->AddColumn( _T( "8" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "9" ), 20 );
m_MemoryList->AddColumn( _T( "10" ), 20 );
m_MemoryList->AddColumn( _T( "11" ), 20 );
m_MemoryList->AddColumn( _T( "12" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "13" ), 20 );
m_MemoryList->AddColumn( _T( "14" ), 20 );
m_MemoryList->AddColumn( _T( "15" ), 20 );
m_MemoryList->AddColumn( _T( "16" ), 35 );
m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 );
::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
RefreshMemory(false);
int height = m_MemoryList->GetTotalHeight();
RECT MemoryListRect = {0};
::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect);
if (m_MemoryList == NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
m_MemoryList->SubclassWindow(GetDlgItem(IDC_MEM_DETAILS));
m_MemoryList->ShowHeader(false);
m_MemoryList->SetSortEnabled(FALSE);
m_MemoryList->AddColumn(_T("Address"), 90);
m_MemoryList->AddColumn(_T("1"), 20);
m_MemoryList->AddColumn(_T("2"), 20);
m_MemoryList->AddColumn(_T("3"), 20);
m_MemoryList->AddColumn(_T("4"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("5"), 20);
m_MemoryList->AddColumn(_T("6"), 20);
m_MemoryList->AddColumn(_T("7"), 20);
m_MemoryList->AddColumn(_T("8"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("9"), 20);
m_MemoryList->AddColumn(_T("10"), 20);
m_MemoryList->AddColumn(_T("11"), 20);
m_MemoryList->AddColumn(_T("12"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("13"), 20);
m_MemoryList->AddColumn(_T("14"), 20);
m_MemoryList->AddColumn(_T("15"), 20);
m_MemoryList->AddColumn(_T("16"), 35);
m_MemoryList->AddColumn(_T("Memory Ascii"), 140);
::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
RefreshMemory(false);
int height = m_MemoryList->GetTotalHeight();
if (height > MemoryListRect.bottom)
{
RECT MemoryListWindow = {0};
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
RECT MemoryListRect = { 0 };
::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect);
RECT DlgItemRect = {0};
::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_BORDER ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
if (height > MemoryListRect.bottom)
{
RECT MemoryListWindow = { 0 };
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
RECT DlgItemRect = { 0 };
::GetWindowRect(GetDlgItem(IDC_BORDER), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_SCRL_BAR ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated();
return TRUE;
::GetWindowRect(GetDlgItem(IDC_MEM_DETAILS), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_MEM_DETAILS), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem(IDC_SCRL_BAR), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated();
return TRUE;
}
LRESULT CDebugMemoryView::OnDestroy ( void )
LRESULT CDebugMemoryView::OnDestroy(void)
{
if (m_MemoryList)
{
m_MemoryList->UnsubclassWindow();
delete m_MemoryList;
m_MemoryList = NULL;
}
return 0;
if (m_MemoryList)
{
m_MemoryList->UnsubclassWindow();
delete m_MemoryList;
m_MemoryList = NULL;
}
return 0;
}
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
break;
case IDC_CHK_VADDR:
RefreshMemory(false);
break;
case IDC_DUMP_MEM:
m_Debugger->Debug_ShowMemoryDump();
break;
case IDC_SEARCH_MEM:
m_Debugger->Debug_ShowMemorySearch();
break;
case IDCANCEL:
EndDialog(0);
break;
}
return FALSE;
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
break;
case IDC_CHK_VADDR:
RefreshMemory(false);
break;
case IDC_DUMP_MEM:
m_Debugger->Debug_ShowMemoryDump();
break;
case IDC_SEARCH_MEM:
m_Debugger->Debug_ShowMemorySearch();
break;
case IDCANCEL:
EndDialog(0);
break;
}
return FALSE;
}
LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
{
CListNotify *pListNotify = reinterpret_cast<CListNotify *>( lpNMHDR );
int LineNumber = pListNotify->m_nItem;
int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1));
if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2));
}
if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3));
}
if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4));
}
CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
int LineNumber = pListNotify->m_nItem;
int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1));
if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2));
}
if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3));
}
if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4));
}
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
Value = (Value << 4);
if (strValue[i] <= '9' && strValue[i] >= '0')
{
Value |= strValue[i] - '0';
}
else if (strValue[i] <= 'f' && strValue[i] >= 'a')
{
Value |= strValue[i] - 'a' + 10;
}
else if (strValue[i] <= 'F' && strValue[i] >= 'A')
{
Value |= strValue[i] - 'A' + 10;
}
}
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
Value = (Value << 4);
if (strValue[i] <= '9' && strValue[i] >= '0')
{
Value |= strValue[i] - '0';
}
else if (strValue[i] <= 'f' && strValue[i] >= 'a')
{
Value |= strValue[i] - 'a' + 10;
}
else if (strValue[i] <= 'F' && strValue[i] >= 'A')
{
Value |= strValue[i] - 'A' + 10;
}
}
if (m_CurrentData[Pos] == Value)
{
return 0;
}
if (m_CurrentData[Pos] == Value)
{
return 0;
}
if (m_CompareStartLoc != m_DataStartLoc ||
m_CompareVAddrr != m_DataVAddrr)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid));
}
if (m_CompareStartLoc != m_DataStartLoc ||
m_CompareVAddrr != m_DataVAddrr)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
}
m_CompareData[Pos] = m_CurrentData[Pos];
m_CurrentData[Pos] = (BYTE)Value;
m_CompareData[Pos] = m_CurrentData[Pos];
m_CurrentData[Pos] = (BYTE)Value;
//sb
if ( m_DataVAddrr )
{
if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
}
Insert_MemoryLineDump(LineNumber);
//sb
if (m_DataVAddrr)
{
if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos, (BYTE)Value))
{
WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
}
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos, (BYTE)Value))
{
WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
}
}
Insert_MemoryLineDump(LineNumber);
return 0;
return 0;
}
void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr)
{
if (m_hWnd == NULL)
{
return;
}
if (m_hWnd == NULL)
{
return;
}
SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED,0);
m_MemAddr.SetValue(Address,true,true);
RefreshMemory (true);
SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED, 0);
m_MemAddr.SetValue(Address, true, true);
RefreshMemory(true);
}
void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber)
{
if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0)
{
return;
}
char Output[20], Hex[60], Ascii[20], AsciiAddOn[15];
sprintf(Output,"0x%08X",m_DataStartLoc + (LineNumber << 4));
if (m_MemoryList->GetItemCount() <= LineNumber)
{
HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
m_MemoryList->AddItemAt( LineNumber, Output);
for (int i = 0; i < m_MemoryList->GetColumnCount(); i++)
{
m_MemoryList->SetItemFont( LineNumber, i, hFont );
if (i == 5 || i == 10 || i == 15)
{
m_MemoryList->SetItemText(LineNumber,i,"-");
}
}
}
else
{
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,0,Output);
}
}
if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0)
{
return;
}
char Output[20], Hex[60], Ascii[20], AsciiAddOn[15];
sprintf(Output, "0x%08X", m_DataStartLoc + (LineNumber << 4));
if (m_MemoryList->GetItemCount() <= LineNumber)
{
HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
m_MemoryList->AddItemAt(LineNumber, Output);
for (int i = 0; i < m_MemoryList->GetColumnCount(); i++)
{
m_MemoryList->SetItemFont(LineNumber, i, hFont);
if (i == 5 || i == 10 || i == 15)
{
m_MemoryList->SetItemText(LineNumber, i, "-");
}
}
}
else
{
if (strcmp(Output, m_MemoryList->GetItemText(LineNumber, 0)) != 0)
{
m_MemoryList->SetItemText(LineNumber, 0, Output);
}
}
Hex[0] = 0;
Ascii[0] = 0;
int CompareStartPos = m_DataStartLoc - m_CompareStartLoc;
Hex[0] = 0;
Ascii[0] = 0;
int CompareStartPos = m_DataStartLoc - m_CompareStartLoc;
for (int i = 0, col = 1; i < 0x10; i ++, col ++)
{
int Pos = ((LineNumber << 4) + i);
if (m_DataValid[Pos])
{
int ComparePos = CompareStartPos + Pos;
bool Changed = false;
for (int i = 0, col = 1; i < 0x10; i++, col++)
{
int Pos = ((LineNumber << 4) + i);
if (m_DataValid[Pos])
{
int ComparePos = CompareStartPos + Pos;
bool Changed = false;
if (ComparePos >= 0 && ComparePos < MemoryToDisplay &&
m_DataVAddrr == m_CompareVAddrr &&
m_DataValid[ComparePos] &&
m_CurrentData[Pos] != m_CompareData[ComparePos])
{
Changed = true;
}
sprintf(Hex,"%02X",m_CurrentData[Pos]);
m_MemoryList->SetItemText(LineNumber,col,Hex);
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX );
m_MemoryList->SetItemMaxEditLen( LineNumber,col , 2);
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ),
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) );
m_MemoryList->SetItemHighlightColours( LineNumber, col,
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) );
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii,".");
}
else
{
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn);
}
}
else
{
m_MemoryList->SetItemText(LineNumber,col,"**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE );
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) );
strcat(Ascii,"*");
}
if (i != 0xF)
{
if ((i & 3) == 3)
{
col += 1;
}
}
}
if ( strcmp( Ascii, m_MemoryList->GetItemText(LineNumber, 20) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,20,Ascii);
}
if (ComparePos >= 0 && ComparePos < MemoryToDisplay &&
m_DataVAddrr == m_CompareVAddrr &&
m_DataValid[ComparePos] &&
m_CurrentData[Pos] != m_CompareData[ComparePos])
{
Changed = true;
}
sprintf(Hex, "%02X", m_CurrentData[Pos]);
m_MemoryList->SetItemText(LineNumber, col, Hex);
m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX);
m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2);
m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW),
Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT));
m_MemoryList->SetItemHighlightColours(LineNumber, col,
Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT));
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii, ".");
}
else
{
sprintf(AsciiAddOn, "%c", m_CurrentData[Pos]);
strcat(Ascii, AsciiAddOn);
}
}
else
{
m_MemoryList->SetItemText(LineNumber, col, "**");
m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE);
m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOWTEXT));
strcat(Ascii, "*");
}
if (i != 0xF)
{
if ((i & 3) == 3)
{
col += 1;
}
}
}
if (strcmp(Ascii, m_MemoryList->GetItemText(LineNumber, 20)) != 0)
{
m_MemoryList->SetItemText(LineNumber, 20, Ascii);
}
}
void CDebugMemoryView::OnAddrChanged( UINT /*Code*/, int /*id*/, HWND /*ctl*/ )
void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
{
RefreshMemory(false);
RefreshMemory(false);
}
void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl )
void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl)
{
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
{
return;
}
DWORD Location = m_MemAddr.GetValue();
switch (request)
{
case SB_LINEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF,true,true);
break;
case SB_LINEUP:
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0,true,true);
break;
case SB_PAGEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF,true,true);
break;
case SB_PAGEUP:
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0,true,true);
break;
case SB_THUMBPOSITION:
m_MemAddr.SetValue((DWORD)Pos << 0x10,true,true);
break;
default:
break;
}
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
{
return;
}
DWORD Location = m_MemAddr.GetValue();
switch (request)
{
case SB_LINEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, true, true);
break;
case SB_LINEUP:
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, true, true);
break;
case SB_PAGEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, true, true);
break;
case SB_PAGEUP:
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, true, true);
break;
case SB_THUMBPOSITION:
m_MemAddr.SetValue((DWORD)Pos << 0x10, true, true);
break;
default:
break;
}
}
void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
void CDebugMemoryView::RefreshMemory(bool ResetCompare)
{
if (m_MemoryList && m_MemoryList->GetHasEditItem())
{
m_MemoryList->SetFocus();
}
if (m_MemoryList && m_MemoryList->GetHasEditItem())
{
m_MemoryList->SetFocus();
}
DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc)
{
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc)
{
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = NewAddress >> 0x10;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
}
}
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = NewAddress >> 0x10;
::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
}
}
if (ResetCompare)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid));
}
m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
if (ResetCompare)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
}
m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0;
m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
if ((m_DataStartLoc & 3) != 0)
{
MIPS_WORD word;
bool ValidData = true;
if ( m_DataVAddrr )
{
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0;
int Offset = (m_DataStartLoc & 3);
for (int i = 0; i < (4 - Offset); i++)
{
if (WritePos >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
}
}
WritePos = 4 - Offset;
}
if ((m_DataStartLoc & 3) != 0)
{
MIPS_WORD word;
bool ValidData = true;
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
{
MIPS_WORD word;
bool ValidData = true;
if ( m_DataVAddrr )
{
if (!g_MMU->LW_VAddr(Pos, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
if (m_DataVAddrr)
{
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++)
{
if ((WritePos + i)>= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - i];
}
}
}
int Offset = (m_DataStartLoc & 3);
for (int i = 0; i < (4 - Offset); i++)
{
if (WritePos >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
}
}
WritePos = 4 - Offset;
}
for (int count = 0 ; count < 16;count ++)
{
Insert_MemoryLineDump ( count );
}
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
{
MIPS_WORD word;
bool ValidData = true;
if (m_DataVAddrr)
{
if (!g_MMU->LW_VAddr(Pos, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++)
{
if ((WritePos + i) >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - i];
}
}
}
for (int count = 0; count < 16; count++)
{
Insert_MemoryLineDump(count);
}
}
#endif

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,48 +11,48 @@
#pragma once
class CDebugMemoryView :
public CDebugDialog<CDebugMemoryView>
public CDebugDialog < CDebugMemoryView >
{
public:
enum { IDD = IDD_Debugger_Memory };
BEGIN_MSG_MAP_EX(CDebugMemoryView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT,EN_CHANGE,OnAddrChanged)
NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll)
END_MSG_MAP()
CDebugMemoryView(CDebuggerUI * debugger);
virtual ~CDebugMemoryView(void);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnAddrChanged( UINT Code, int id, HWND ctl );
void OnVScroll(int request, short Pos, HWND ctrl );
LRESULT OnMemoryModified ( LPNMHDR lpNMHDR );
LRESULT OnDestroy ( void );
void ShowAddress(DWORD Address, bool VAddr);
void Insert_MemoryLineDump ( int LineNumber );
void RefreshMemory ( bool ResetCompare );
enum { MemoryToDisplay = 0x100};
private:
BEGIN_MSG_MAP_EX(CDebugMemoryView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged)
NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll)
END_MSG_MAP()
CEditNumber m_MemAddr;
CListCtrl * m_MemoryList;
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnAddrChanged(UINT Code, int id, HWND ctl);
void OnVScroll(int request, short Pos, HWND ctrl);
LRESULT OnMemoryModified(LPNMHDR lpNMHDR);
LRESULT OnDestroy(void);
DWORD m_DataStartLoc;
bool m_DataVAddrr;
BYTE m_CurrentData[MemoryToDisplay];
bool m_DataValid[MemoryToDisplay];
void Insert_MemoryLineDump(int LineNumber);
void RefreshMemory(bool ResetCompare);
DWORD m_CompareStartLoc;
bool m_CompareVAddrr;
BYTE m_CompareData[MemoryToDisplay];
bool m_CompareValid[MemoryToDisplay];
public:
enum { IDD = IDD_Debugger_Memory };
enum { MemoryToDisplay = 0x100 };
CDebugMemoryView(CDebugger * debugger);
virtual ~CDebugMemoryView(void);
CEditNumber m_MemAddr;
CListCtrl * m_MemoryList;
void ShowAddress (DWORD Address, bool VAddr);
DWORD m_DataStartLoc;
bool m_DataVAddrr;
BYTE m_CurrentData[MemoryToDisplay];
bool m_DataValid[MemoryToDisplay];
DWORD m_CompareStartLoc;
bool m_CompareVAddrr;
BYTE m_CompareData[MemoryToDisplay];
bool m_CompareValid[MemoryToDisplay];
};

View File

@ -1,41 +1,4 @@
////#define _WIN32_WINNT 0x0500
//#include <atlbase.h>
//#include <wtl/atlapp.h>
////#include <atlbase.h>
////#include <atlapp.h>
//class CPj64Module :
// public CAppModule
//{
//public:
// CPj64Module(void)
// {
// Init(NULL, GetModuleHandle(NULL));
// }
// virtual ~CPj64Module(void)
// {
// Term();
// }
//};
//
//
//extern CPj64Module _Module;
//
//#define _WTL_NO_CSTRING
//
//#include <atlwin.h>
//#include <wtl/atlmisc.h>
//#include <wtl/atlcrack.h>
//
//#include <wtl/atlframe.h>
//#include <wtl/atlctrls.h>
//#include <wtl/atldlgs.h>
//
//#include "../../Support.h"
//#include "Control/numberctrl.h"
//#include "Control/ClistCtrl/ListCtrl.h"
#pragma once
#include "../../WTL App.h"
#include "../../N64 System.h"

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -9,127 +9,141 @@
* *
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CPj64Module _Module;
CDebugger::CDebugger () :
m_MemoryDump(NULL),
m_MemoryView(NULL),
m_MemorySearch(NULL),
m_DebugTLB(NULL)
CDebuggerUI::CDebuggerUI () :
m_MemoryDump(NULL),
m_MemoryView(NULL),
m_MemorySearch(NULL),
m_DebugTLB(NULL)
{
g_Settings->RegisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
g_Debugger = this;
}
CDebugger::~CDebugger (void)
CDebuggerUI::~CDebuggerUI (void)
{
Debug_Reset();
g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
Debug_Reset();
}
void CDebugger::Debug_Reset ( void )
void CDebuggerUI::GameReset ( CDebuggerUI * _this )
{
if (m_MemoryDump)
{
m_MemoryDump->HideWindow();
delete m_MemoryDump;
m_MemoryDump = NULL;
}
if (m_MemoryView)
{
m_MemoryView->HideWindow();
delete m_MemoryView;
m_MemoryView = NULL;
}
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
}
void CDebugger::Debug_ShowMemoryDump()
{
if (g_MMU == NULL)
if (!g_Settings->LoadBool(GameRunning_InReset))
{
return;
}
if (m_MemoryDump == NULL)
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
_this->Debug_Reset();
}
void CDebugger::Debug_ShowMemoryWindow ( void )
void CDebuggerUI::Debug_Reset ( void )
{
if (g_MMU == NULL)
{
return;
}
if (m_MemoryView == NULL)
{
m_MemoryView = new CDebugMemoryView(this);
}
if (m_MemoryView)
{
m_MemoryView->ShowWindow();
}
if (m_MemoryDump)
{
m_MemoryDump->HideWindow();
delete m_MemoryDump;
m_MemoryDump = NULL;
}
if (m_MemoryView)
{
m_MemoryView->HideWindow();
delete m_MemoryView;
m_MemoryView = NULL;
}
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
}
void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr )
void CDebuggerUI::Debug_ShowMemoryDump()
{
Debug_ShowMemoryWindow();
if (m_MemoryView)
{
m_MemoryView->ShowAddress(Address,VAddr);
}
if (g_MMU == NULL)
{
return;
}
if (m_MemoryDump == NULL)
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
}
void CDebugger::Debug_ShowTLBWindow (void)
void CDebuggerUI::Debug_ShowMemoryWindow ( void )
{
if (g_MMU == NULL)
{
return;
}
if (m_DebugTLB == NULL)
{
m_DebugTLB = new CDebugTlb(this);
}
if (m_DebugTLB)
{
m_DebugTLB->ShowWindow();
}
if (g_MMU == NULL)
{
return;
}
if (m_MemoryView == NULL)
{
m_MemoryView = new CDebugMemoryView(this);
}
if (m_MemoryView)
{
m_MemoryView->ShowWindow();
}
}
void CDebugger::Debug_RefreshTLBWindow(void)
void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr )
{
if (m_DebugTLB)
{
m_DebugTLB->RefreshTLBWindow();
}
Debug_ShowMemoryWindow();
if (m_MemoryView)
{
m_MemoryView->ShowAddress(Address,VAddr);
}
}
void CDebugger::Debug_ShowMemorySearch()
void CDebuggerUI::Debug_ShowTLBWindow (void)
{
if (m_MemorySearch == NULL)
{
m_MemorySearch = new CDebugMemorySearch(this);
}
if (m_MemorySearch)
{
m_MemorySearch->ShowWindow();
}
if (g_MMU == NULL)
{
return;
}
if (m_DebugTLB == NULL)
{
m_DebugTLB = new CDebugTlb(this);
}
if (m_DebugTLB)
{
m_DebugTLB->ShowWindow();
}
}
#endif
void CDebuggerUI::Debug_RefreshTLBWindow(void)
{
if (m_DebugTLB)
{
m_DebugTLB->RefreshTLBWindow();
}
}
void CDebuggerUI::Debug_ShowMemorySearch()
{
if (m_MemorySearch == NULL)
{
m_MemorySearch = new CDebugMemorySearch(this);
}
if (m_MemorySearch)
{
m_MemorySearch->ShowWindow();
}
}
void CDebuggerUI::TLBChanged()
{
Debug_RefreshTLBWindow();
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -13,25 +13,35 @@
class CDumpMemory;
class CDebugMemoryView;
class CDebugMemorySearch;
class CDebugTlb;
class CDebugger
__interface CDebugger
{
CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB;
virtual void TLBChanged ( void ) = 0;
};
class CDebuggerUI :
public CDebugger
{
CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB;
protected:
CDebugger();
virtual ~CDebugger();
public:
void Debug_Reset ( void );
void Debug_ShowMemoryDump ( void );
void Debug_ShowMemoryWindow ( void );
void Debug_ShowMemoryLocation ( DWORD Address, bool VAddr );
void Debug_ShowMemorySearch ( void );
void Debug_ShowTLBWindow ( void );
void Debug_RefreshTLBWindow ( void );
CDebuggerUI();
virtual ~CDebuggerUI();
void TLBChanged ( void );
public:
void Debug_Reset ( void );
void Debug_ShowMemoryDump ( void );
void Debug_ShowMemoryWindow ( void );
void Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr );
void Debug_ShowMemorySearch ( void );
void Debug_ShowTLBWindow ( void );
void Debug_RefreshTLBWindow ( void );
static void GameReset ( CDebuggerUI * _this );
};

View File

@ -0,0 +1,96 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include <Project64\N64 System\N64 Class.h>
#include <common/Util.h>
#include <Windows.h>
#include <Objbase.h>
void CN64System::StartEmulationThead()
{
ThreadInfo * Info = new ThreadInfo;
HANDLE * hThread = new HANDLE;
*hThread = NULL;
//create the needed info into a structure to pass as one parameter
//for creating a thread
Info->ThreadHandle = hThread;
*hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, (LPDWORD)&Info->ThreadID);
}
void CN64System::StartEmulationThread(ThreadInfo * Info)
{
if (g_Settings->LoadBool(Setting_CN64TimeCritical))
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
CoInitialize(NULL);
EmulationStarting(Info->ThreadHandle, Info->ThreadID);
delete ((HANDLE *)Info->ThreadHandle);
delete Info;
CoUninitialize();
}
void CN64System::CloseCpu()
{
if (m_CPU_Handle == NULL)
{
return;
}
m_EndEmulation = true;
if (g_Settings->LoadBool(GameRunning_CPU_Paused))
{
m_hPauseEvent.Trigger();
}
if (GetCurrentThreadId() == m_CPU_ThreadID)
{
ExternalEvent(SysEvent_CloseCPU);
return;
}
HANDLE hThread = m_CPU_Handle;
m_CPU_Handle = NULL;
for (int count = 0; count < 200; count++)
{
pjutil::Sleep(100);
if (g_Notify->ProcessGuiMessages())
{
return;
}
DWORD ExitCode;
if (GetExitCodeThread(hThread, &ExitCode))
{
if (ExitCode != STILL_ACTIVE)
{
break;
}
}
}
if (hThread)
{
DWORD ExitCode;
GetExitCodeThread(hThread, &ExitCode);
if (ExitCode == STILL_ACTIVE)
{
TerminateThread(hThread, 0);
}
}
CloseHandle(hThread);
CpuStopped();
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -12,446 +12,445 @@
R4300iOp::Func * CInterpreterCPU::m_R4300i_Opcode = NULL;
void ExecuteInterpreterOps (DWORD /*Cycles*/)
void ExecuteInterpreterOps(uint32_t /*Cycles*/)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2)
bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2)
{
OPCODE Command;
OPCODE Command;
if (!g_MMU->LW_VAddr(PC + 4, Command.Hex))
{
//g_Notify->DisplayError(L"Failed to load word 2");
//ExitThread(0);
return true;
}
if (!g_MMU->LW_VAddr(PC + 4, Command.Hex))
{
//g_Notify->DisplayError(L"Failed to load word 2");
//ExitThread(0);
return true;
}
switch (Command.op)
{
case R4300i_SPECIAL:
switch (Command.funct)
{
case R4300i_SPECIAL_SLL:
case R4300i_SPECIAL_SRL:
case R4300i_SPECIAL_SRA:
case R4300i_SPECIAL_SLLV:
case R4300i_SPECIAL_SRLV:
case R4300i_SPECIAL_SRAV:
case R4300i_SPECIAL_MFHI:
case R4300i_SPECIAL_MTHI:
case R4300i_SPECIAL_MFLO:
case R4300i_SPECIAL_MTLO:
case R4300i_SPECIAL_DSLLV:
case R4300i_SPECIAL_DSRLV:
case R4300i_SPECIAL_DSRAV:
case R4300i_SPECIAL_ADD:
case R4300i_SPECIAL_ADDU:
case R4300i_SPECIAL_SUB:
case R4300i_SPECIAL_SUBU:
case R4300i_SPECIAL_AND:
case R4300i_SPECIAL_OR:
case R4300i_SPECIAL_XOR:
case R4300i_SPECIAL_NOR:
case R4300i_SPECIAL_SLT:
case R4300i_SPECIAL_SLTU:
case R4300i_SPECIAL_DADD:
case R4300i_SPECIAL_DADDU:
case R4300i_SPECIAL_DSUB:
case R4300i_SPECIAL_DSUBU:
case R4300i_SPECIAL_DSLL:
case R4300i_SPECIAL_DSRL:
case R4300i_SPECIAL_DSRA:
case R4300i_SPECIAL_DSLL32:
case R4300i_SPECIAL_DSRL32:
case R4300i_SPECIAL_DSRA32:
if (Command.rd == 0)
{
return false;
}
if (Command.rd == Reg1 || Command.rd == Reg2)
{
return true;
}
break;
case R4300i_SPECIAL_MULT:
case R4300i_SPECIAL_MULTU:
case R4300i_SPECIAL_DIV:
case R4300i_SPECIAL_DIVU:
case R4300i_SPECIAL_DMULT:
case R4300i_SPECIAL_DMULTU:
case R4300i_SPECIAL_DDIV:
case R4300i_SPECIAL_DDIVU:
break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str());
}
return true;
}
break;
case R4300i_CP0:
switch (Command.rs)
{
case R4300i_COP0_MT: break;
case R4300i_COP0_MF:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
default:
if ( (Command.rs & 0x10 ) != 0 )
{
switch (Command.funct)
{
case R4300i_COP0_CO_TLBR: break;
case R4300i_COP0_CO_TLBWI: break;
case R4300i_COP0_CO_TLBWR: break;
case R4300i_COP0_CO_TLBP: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n6",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str());
}
return true;
}
}
else
{
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n7",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str());
}
return true;
}
}
break;
case R4300i_CP1:
switch (Command.fmt)
{
case R4300i_COP1_MF:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
case R4300i_COP1_CF: break;
case R4300i_COP1_MT: break;
case R4300i_COP1_CT: break;
case R4300i_COP1_S: break;
case R4300i_COP1_D: break;
case R4300i_COP1_W: break;
case R4300i_COP1_L: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str());
}
return true;
}
break;
case R4300i_ANDI:
case R4300i_ORI:
case R4300i_XORI:
case R4300i_LUI:
case R4300i_ADDI:
case R4300i_ADDIU:
case R4300i_SLTI:
case R4300i_SLTIU:
case R4300i_DADDI:
case R4300i_DADDIU:
case R4300i_LB:
case R4300i_LH:
case R4300i_LW:
case R4300i_LWL:
case R4300i_LWR:
case R4300i_LDL:
case R4300i_LDR:
case R4300i_LBU:
case R4300i_LHU:
case R4300i_LD:
case R4300i_LWC1:
case R4300i_LDC1:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
case R4300i_CACHE: break;
case R4300i_SB: break;
case R4300i_SH: break;
case R4300i_SW: break;
case R4300i_SWR: break;
case R4300i_SWL: break;
case R4300i_SWC1: break;
case R4300i_SDC1: break;
case R4300i_SD: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str());
}
return true;
}
return false;
switch (Command.op)
{
case R4300i_SPECIAL:
switch (Command.funct)
{
case R4300i_SPECIAL_SLL:
case R4300i_SPECIAL_SRL:
case R4300i_SPECIAL_SRA:
case R4300i_SPECIAL_SLLV:
case R4300i_SPECIAL_SRLV:
case R4300i_SPECIAL_SRAV:
case R4300i_SPECIAL_MFHI:
case R4300i_SPECIAL_MTHI:
case R4300i_SPECIAL_MFLO:
case R4300i_SPECIAL_MTLO:
case R4300i_SPECIAL_DSLLV:
case R4300i_SPECIAL_DSRLV:
case R4300i_SPECIAL_DSRAV:
case R4300i_SPECIAL_ADD:
case R4300i_SPECIAL_ADDU:
case R4300i_SPECIAL_SUB:
case R4300i_SPECIAL_SUBU:
case R4300i_SPECIAL_AND:
case R4300i_SPECIAL_OR:
case R4300i_SPECIAL_XOR:
case R4300i_SPECIAL_NOR:
case R4300i_SPECIAL_SLT:
case R4300i_SPECIAL_SLTU:
case R4300i_SPECIAL_DADD:
case R4300i_SPECIAL_DADDU:
case R4300i_SPECIAL_DSUB:
case R4300i_SPECIAL_DSUBU:
case R4300i_SPECIAL_DSLL:
case R4300i_SPECIAL_DSRL:
case R4300i_SPECIAL_DSRA:
case R4300i_SPECIAL_DSLL32:
case R4300i_SPECIAL_DSRL32:
case R4300i_SPECIAL_DSRA32:
if (Command.rd == 0)
{
return false;
}
if (Command.rd == Reg1 || Command.rd == Reg2)
{
return true;
}
break;
case R4300i_SPECIAL_MULT:
case R4300i_SPECIAL_MULTU:
case R4300i_SPECIAL_DIV:
case R4300i_SPECIAL_DIVU:
case R4300i_SPECIAL_DMULT:
case R4300i_SPECIAL_DMULTU:
case R4300i_SPECIAL_DDIV:
case R4300i_SPECIAL_DDIVU:
break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str());
}
return true;
}
break;
case R4300i_CP0:
switch (Command.rs)
{
case R4300i_COP0_MT: break;
case R4300i_COP0_MF:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
default:
if ((Command.rs & 0x10) != 0)
{
switch (Command.funct)
{
case R4300i_COP0_CO_TLBR: break;
case R4300i_COP0_CO_TLBWI: break;
case R4300i_COP0_CO_TLBWR: break;
case R4300i_COP0_CO_TLBP: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n6", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str());
}
return true;
}
}
else
{
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n7", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str());
}
return true;
}
}
break;
case R4300i_CP1:
switch (Command.fmt)
{
case R4300i_COP1_MF:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
case R4300i_COP1_CF: break;
case R4300i_COP1_MT: break;
case R4300i_COP1_CT: break;
case R4300i_COP1_S: break;
case R4300i_COP1_D: break;
case R4300i_COP1_W: break;
case R4300i_COP1_L: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str());
}
return true;
}
break;
case R4300i_ANDI:
case R4300i_ORI:
case R4300i_XORI:
case R4300i_LUI:
case R4300i_ADDI:
case R4300i_ADDIU:
case R4300i_SLTI:
case R4300i_SLTIU:
case R4300i_DADDI:
case R4300i_DADDIU:
case R4300i_LB:
case R4300i_LH:
case R4300i_LW:
case R4300i_LWL:
case R4300i_LWR:
case R4300i_LDL:
case R4300i_LDR:
case R4300i_LBU:
case R4300i_LHU:
case R4300i_LD:
case R4300i_LWC1:
case R4300i_LDC1:
if (Command.rt == 0)
{
return false;
}
if (Command.rt == Reg1 || Command.rt == Reg2)
{
return true;
}
break;
case R4300i_CACHE: break;
case R4300i_SB: break;
case R4300i_SH: break;
case R4300i_SW: break;
case R4300i_SWR: break;
case R4300i_SWL: break;
case R4300i_SWC1: break;
case R4300i_SDC1: break;
case R4300i_SD: break;
default:
if (g_Settings->LoadBool(Debugger_Enabled))
{
g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str());
}
return true;
}
return false;
}
void CInterpreterCPU::BuildCPU()
{
R4300iOp::m_TestTimer = false;
R4300iOp::m_NextInstruction = NORMAL;
R4300iOp::m_JumpToLocation = 0;
if (g_Settings->LoadBool(Game_32Bit))
{
m_R4300i_Opcode = R4300iOp32::BuildInterpreter();
}
else
{
m_R4300i_Opcode = R4300iOp::BuildInterpreter();
}
{
R4300iOp::m_TestTimer = false;
R4300iOp::m_NextInstruction = NORMAL;
R4300iOp::m_JumpToLocation = 0;
if (g_Settings->LoadBool(Game_32Bit))
{
m_R4300i_Opcode = R4300iOp32::BuildInterpreter();
}
else
{
m_R4300i_Opcode = R4300iOp::BuildInterpreter();
}
}
void CInterpreterCPU::InPermLoop()
{
// *** Changed ***/
//if (CPU_Type == CPU_SyncCores)
//{
// SyncRegisters.CP0[9] +=5;
//}
// *** Changed ***/
//if (CPU_Type == CPU_SyncCores)
//{
// SyncRegisters.CP0[9] +=5;
//}
/* Interrupts enabled */
if (( g_Reg->STATUS_REGISTER & STATUS_IE ) == 0 ||
( g_Reg->STATUS_REGISTER & STATUS_EXL ) != 0 ||
( g_Reg->STATUS_REGISTER & STATUS_ERL ) != 0 ||
( g_Reg->STATUS_REGISTER & 0xFF00) == 0)
{
if (g_Plugins->Gfx()->UpdateScreen != NULL)
{
g_Plugins->Gfx()->UpdateScreen();
}
//CurrentFrame = 0;
//CurrentPercent = 0;
//DisplayFPS();
g_Notify->DisplayError(GS(MSG_PERM_LOOP));
g_System->CloseCpu();
}
else
{
if (*g_NextTimer > 0)
{
*g_NextTimer = 0 - g_System->CountPerOp();
g_SystemTimer->UpdateTimers();
}
}
/* Interrupts enabled */
if ((g_Reg->STATUS_REGISTER & STATUS_IE) == 0 ||
(g_Reg->STATUS_REGISTER & STATUS_EXL) != 0 ||
(g_Reg->STATUS_REGISTER & STATUS_ERL) != 0 ||
(g_Reg->STATUS_REGISTER & 0xFF00) == 0)
{
if (g_Plugins->Gfx()->UpdateScreen != NULL)
{
g_Plugins->Gfx()->UpdateScreen();
}
//CurrentFrame = 0;
//CurrentPercent = 0;
//DisplayFPS();
g_Notify->DisplayError(GS(MSG_PERM_LOOP));
g_System->CloseCpu();
}
else
{
if (*g_NextTimer > 0)
{
*g_NextTimer = 0 - g_System->CountPerOp();
g_SystemTimer->UpdateTimers();
}
}
}
void CInterpreterCPU::ExecuteCPU()
{
bool & Done = g_System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer;
const BOOL & bDoSomething= g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp();
int & NextTimer = *g_NextTimer;
__try
{
while (!Done)
{
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
/*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[ Opcode.op ]();
NextTimer -= CountPerOp;
switch (R4300iOp::m_NextInstruction)
{
case NORMAL:
PROGRAM_COUNTER += 4;
break;
case DELAY_SLOT:
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
CInterpreterCPU::InPermLoop();
g_SystemTimer->TimerDone();
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
}
}
void CInterpreterCPU::ExecuteOps(int Cycles)
{
bool & Done = g_System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer;
const BOOL & DoSomething = g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp();
__try
{
while (!Done)
{
if (Cycles <= 0)
{
g_SystemTimer->UpdateTimers();
return;
}
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
/*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
/*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[ Opcode.op ]();
_GPR[0].DW = 0; /* MIPS $zero hard-wired to 0 */
bool & Done = g_System->m_EndEmulation;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode;
uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer;
const int32_t & bDoSomething = g_SystemEvents->DoSomething();
uint32_t CountPerOp = g_System->CountPerOp();
int32_t & NextTimer = *g_NextTimer;
Cycles -= CountPerOp;
*g_NextTimer -= CountPerOp;
/*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
if (g_MMU->LW_VAddr(TestAddress, TestValue))
{
if (TestValue != CurrentValue)
{
WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iOpcodeName(m_Opcode.Hex,PROGRAM_COUNTER) );
CurrentValue = TestValue;
}
}*/
switch (R4300iOp::m_NextInstruction)
{
case NORMAL:
PROGRAM_COUNTER += 4;
break;
case DELAY_SLOT:
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (*g_NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (DoSomething)
{
g_SystemEvents->ExecuteEvents();
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
CInterpreterCPU::InPermLoop();
g_SystemTimer->TimerDone();
if (DoSomething)
{
g_SystemEvents->ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
} __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) )
{
g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
}
__try
{
while (!Done)
{
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
/*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[Opcode.op]();
NextTimer -= CountPerOp;
switch (R4300iOp::m_NextInstruction)
{
case NORMAL:
PROGRAM_COUNTER += 4;
break;
case DELAY_SLOT:
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
CInterpreterCPU::InPermLoop();
g_SystemTimer->TimerDone();
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
}
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
}
}
void CInterpreterCPU::ExecuteOps(int32_t Cycles)
{
bool & Done = g_System->m_EndEmulation;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode;
uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer;
const int32_t & DoSomething = g_SystemEvents->DoSomething();
uint32_t CountPerOp = g_System->CountPerOp();
__try
{
while (!Done)
{
if (Cycles <= 0)
{
g_SystemTimer->UpdateTimers();
return;
}
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
/*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
/*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000)
{
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[Opcode.op]();
_GPR[0].DW = 0; /* MIPS $zero hard-wired to 0 */
Cycles -= CountPerOp;
*g_NextTimer -= CountPerOp;
/*static uint32_t TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
if (g_MMU->LW_VAddr(TestAddress, TestValue))
{
if (TestValue != CurrentValue)
{
WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iOpcodeName(m_Opcode.Hex,PROGRAM_COUNTER) );
CurrentValue = TestValue;
}
}*/
switch (R4300iOp::m_NextInstruction)
{
case NORMAL:
PROGRAM_COUNTER += 4;
break;
case DELAY_SLOT:
R4300iOp::m_NextInstruction = JUMP;
PROGRAM_COUNTER += 4;
break;
case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (*g_NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (DoSomething)
{
g_SystemEvents->ExecuteEvents();
}
}
}
break;
case PERMLOOP_DELAY_DONE:
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
CInterpreterCPU::InPermLoop();
g_SystemTimer->TimerDone();
if (DoSomething)
{
g_SystemEvents->ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
}
else
{
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
}
__except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation()))
{
g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION));
}
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,19 +10,21 @@
****************************************************************************/
#pragma once
#include <Project64\N64 System\Interpreter\Interpreter Ops.h>
class CInterpreterCPU :
private R4300iOp
private R4300iOp
{
public:
static void BuildCPU();
static void ExecuteCPU();
static void ExecuteOps(int Cycles);
static void InPermLoop();
static void BuildCPU();
static void ExecuteCPU();
static void ExecuteOps(int32_t Cycles);
static void InPermLoop();
private:
CInterpreterCPU(); // Disable default constructor
CInterpreterCPU(const CInterpreterCPU&); // Disable copy constructor
CInterpreterCPU& operator=(const CInterpreterCPU&); // Disable assignment
CInterpreterCPU(); // Disable default constructor
CInterpreterCPU(const CInterpreterCPU&); // Disable copy constructor
CInterpreterCPU& operator=(const CInterpreterCPU&); // Disable assignment
static R4300iOp::Func * m_R4300i_Opcode;
static R4300iOp::Func * m_R4300i_Opcode;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,75 +10,77 @@
****************************************************************************/
#pragma once
#include "Interpreter Ops.h"
class R4300iOp32 :
public R4300iOp
public R4300iOp
{
public:
/************************* OpCode functions *************************/
static void JAL();
static void BEQ();
static void BNE();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void LL();
/************************* OpCode functions *************************/
static void JAL();
static void BEQ();
static void BNE();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void LL();
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JALR();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_TEQ();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JALR();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_TEQ();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
/************************** COP0 functions **************************/
static void COP0_MF();
static void COP0_MT();
/************************** COP0 functions **************************/
static void COP0_MF();
static void COP0_MT();
/************************** COP1 functions **************************/
static void COP1_MF();
static void COP1_CF();
static void COP1_DMT();
/************************** COP1 functions **************************/
static void COP1_MF();
static void COP1_CF();
static void COP1_DMT();
static Func* BuildInterpreter();
static Func* BuildInterpreter();
};

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,229 +10,231 @@
****************************************************************************/
#pragma once
#include <Project64\Settings\Debug Settings.h>
#include <Project64\N64 System\Mips\Register Class.h>
#include <Project64\N64 System\Mips\OpCode.h>
class R4300iOp :
protected CDebugSettings,
protected CSystemRegisters
public CLogging,
protected CDebugSettings,
protected CSystemRegisters
{
public:
typedef void(*Func)();
typedef void(*Func)();
/************************* OpCode functions *************************/
static void J();
static void JAL();
static void BNE();
static void BEQ();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void DADDIU();
static void LDL();
static void LDR();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void SB();
static void SH();
static void SWL();
static void SW();
static void SDL();
static void SDR();
static void SWR();
static void CACHE();
static void LL();
static void LWC1();
static void LDC1();
static void LD();
static void SC();
static void SWC1();
static void SDC1();
static void SD();
/************************* OpCode functions *************************/
static void J();
static void JAL();
static void BNE();
static void BEQ();
static void BLEZ();
static void BGTZ();
static void ADDI();
static void ADDIU();
static void SLTI();
static void SLTIU();
static void ANDI();
static void ORI();
static void XORI();
static void LUI();
static void BEQL();
static void BNEL();
static void BLEZL();
static void BGTZL();
static void DADDIU();
static void LDL();
static void LDR();
static void LB();
static void LH();
static void LWL();
static void LW();
static void LBU();
static void LHU();
static void LWR();
static void LWU();
static void SB();
static void SH();
static void SWL();
static void SW();
static void SDL();
static void SDR();
static void SWR();
static void CACHE();
static void LL();
static void LWC1();
static void LDC1();
static void LD();
static void SC();
static void SWC1();
static void SDC1();
static void SD();
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JR();
static void SPECIAL_JALR();
static void SPECIAL_SYSCALL();
static void SPECIAL_BREAK();
static void SPECIAL_SYNC();
static void SPECIAL_MFHI();
static void SPECIAL_MTHI();
static void SPECIAL_MFLO();
static void SPECIAL_MTLO();
static void SPECIAL_DSLLV();
static void SPECIAL_DSRLV();
static void SPECIAL_DSRAV();
static void SPECIAL_MULT();
static void SPECIAL_MULTU();
static void SPECIAL_DIV();
static void SPECIAL_DIVU();
static void SPECIAL_DMULT();
static void SPECIAL_DMULTU();
static void SPECIAL_DDIV();
static void SPECIAL_DDIVU();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_XOR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_DADD();
static void SPECIAL_DADDU();
static void SPECIAL_DSUB();
static void SPECIAL_DSUBU();
static void SPECIAL_TEQ();
static void SPECIAL_DSLL();
static void SPECIAL_DSRL();
static void SPECIAL_DSRA();
static void SPECIAL_DSLL32();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL();
static void SPECIAL_SRL();
static void SPECIAL_SRA();
static void SPECIAL_SLLV();
static void SPECIAL_SRLV();
static void SPECIAL_SRAV();
static void SPECIAL_JR();
static void SPECIAL_JALR();
static void SPECIAL_SYSCALL();
static void SPECIAL_BREAK();
static void SPECIAL_SYNC();
static void SPECIAL_MFHI();
static void SPECIAL_MTHI();
static void SPECIAL_MFLO();
static void SPECIAL_MTLO();
static void SPECIAL_DSLLV();
static void SPECIAL_DSRLV();
static void SPECIAL_DSRAV();
static void SPECIAL_MULT();
static void SPECIAL_MULTU();
static void SPECIAL_DIV();
static void SPECIAL_DIVU();
static void SPECIAL_DMULT();
static void SPECIAL_DMULTU();
static void SPECIAL_DDIV();
static void SPECIAL_DDIVU();
static void SPECIAL_ADD();
static void SPECIAL_ADDU();
static void SPECIAL_SUB();
static void SPECIAL_SUBU();
static void SPECIAL_AND();
static void SPECIAL_OR();
static void SPECIAL_XOR();
static void SPECIAL_NOR();
static void SPECIAL_SLT();
static void SPECIAL_SLTU();
static void SPECIAL_DADD();
static void SPECIAL_DADDU();
static void SPECIAL_DSUB();
static void SPECIAL_DSUBU();
static void SPECIAL_TEQ();
static void SPECIAL_DSLL();
static void SPECIAL_DSRL();
static void SPECIAL_DSRA();
static void SPECIAL_DSLL32();
static void SPECIAL_DSRL32();
static void SPECIAL_DSRA32();
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ();
static void REGIMM_BGEZ();
static void REGIMM_BLTZL();
static void REGIMM_BGEZL();
static void REGIMM_BLTZAL();
static void REGIMM_BGEZAL();
/************************** COP0 functions **************************/
static void COP0_MF();
static void COP0_MT();
/************************** COP0 functions **************************/
static void COP0_MF();
static void COP0_MT();
/************************** COP0 CO functions ***********************/
static void COP0_CO_TLBR();
static void COP0_CO_TLBWI();
static void COP0_CO_TLBWR();
static void COP0_CO_TLBP();
static void COP0_CO_ERET();
/************************** COP0 CO functions ***********************/
static void COP0_CO_TLBR();
static void COP0_CO_TLBWI();
static void COP0_CO_TLBWR();
static void COP0_CO_TLBP();
static void COP0_CO_ERET();
/************************** COP1 functions **************************/
static void COP1_MF();
static void COP1_DMF();
static void COP1_CF();
static void COP1_MT();
static void COP1_DMT();
static void COP1_CT();
/************************** COP1 functions **************************/
static void COP1_MF();
static void COP1_DMF();
static void COP1_CF();
static void COP1_MT();
static void COP1_DMT();
static void COP1_CT();
/************************* COP1: BC1 functions ***********************/
static void COP1_BCF();
static void COP1_BCT();
static void COP1_BCFL();
static void COP1_BCTL();
/************************* COP1: BC1 functions ***********************/
static void COP1_BCF();
static void COP1_BCT();
static void COP1_BCFL();
static void COP1_BCTL();
/************************** COP1: S functions ************************/
static void COP1_S_ADD();
static void COP1_S_SUB();
static void COP1_S_MUL();
static void COP1_S_DIV();
static void COP1_S_SQRT();
static void COP1_S_ABS();
static void COP1_S_MOV();
static void COP1_S_NEG();
static void COP1_S_TRUNC_L();
static void COP1_S_CEIL_L(); //added by Witten
static void COP1_S_FLOOR_L(); //added by Witten
static void COP1_S_ROUND_W();
static void COP1_S_TRUNC_W();
static void COP1_S_CEIL_W(); //added by Witten
static void COP1_S_FLOOR_W();
static void COP1_S_CVT_D();
static void COP1_S_CVT_W();
static void COP1_S_CVT_L();
static void COP1_S_CMP();
/************************** COP1: S functions ************************/
static void COP1_S_ADD();
static void COP1_S_SUB();
static void COP1_S_MUL();
static void COP1_S_DIV();
static void COP1_S_SQRT();
static void COP1_S_ABS();
static void COP1_S_MOV();
static void COP1_S_NEG();
static void COP1_S_TRUNC_L();
static void COP1_S_CEIL_L(); //added by Witten
static void COP1_S_FLOOR_L(); //added by Witten
static void COP1_S_ROUND_W();
static void COP1_S_TRUNC_W();
static void COP1_S_CEIL_W(); //added by Witten
static void COP1_S_FLOOR_W();
static void COP1_S_CVT_D();
static void COP1_S_CVT_W();
static void COP1_S_CVT_L();
static void COP1_S_CMP();
/************************** COP1: D functions ************************/
static void COP1_D_ADD();
static void COP1_D_SUB();
static void COP1_D_MUL();
static void COP1_D_DIV();
static void COP1_D_SQRT();
static void COP1_D_ABS();
static void COP1_D_MOV();
static void COP1_D_NEG();
static void COP1_D_TRUNC_L(); //added by Witten
static void COP1_D_CEIL_L(); //added by Witten
static void COP1_D_FLOOR_L(); //added by Witten
static void COP1_D_ROUND_W();
static void COP1_D_TRUNC_W();
static void COP1_D_CEIL_W(); //added by Witten
static void COP1_D_FLOOR_W(); //added by Witten
static void COP1_D_CVT_S();
static void COP1_D_CVT_W();
static void COP1_D_CVT_L();
static void COP1_D_CMP();
/************************** COP1: D functions ************************/
static void COP1_D_ADD();
static void COP1_D_SUB();
static void COP1_D_MUL();
static void COP1_D_DIV();
static void COP1_D_SQRT();
static void COP1_D_ABS();
static void COP1_D_MOV();
static void COP1_D_NEG();
static void COP1_D_TRUNC_L(); //added by Witten
static void COP1_D_CEIL_L(); //added by Witten
static void COP1_D_FLOOR_L(); //added by Witten
static void COP1_D_ROUND_W();
static void COP1_D_TRUNC_W();
static void COP1_D_CEIL_W(); //added by Witten
static void COP1_D_FLOOR_W(); //added by Witten
static void COP1_D_CVT_S();
static void COP1_D_CVT_W();
static void COP1_D_CVT_L();
static void COP1_D_CMP();
/************************** COP1: W functions ************************/
static void COP1_W_CVT_S();
static void COP1_W_CVT_D();
/************************** COP1: W functions ************************/
static void COP1_W_CVT_S();
static void COP1_W_CVT_D();
/************************** COP1: L functions ************************/
static void COP1_L_CVT_S();
static void COP1_L_CVT_D();
/************************** COP1: L functions ************************/
static void COP1_L_CVT_S();
static void COP1_L_CVT_D();
/************************** Other functions **************************/
static void UnknownOpcode();
/************************** Other functions **************************/
static void UnknownOpcode();
static Func* BuildInterpreter();
static Func* BuildInterpreter();
static bool m_TestTimer;
static DWORD m_NextInstruction;
static OPCODE m_Opcode;
static DWORD m_JumpToLocation;
static bool m_TestTimer;
static uint32_t m_NextInstruction;
static OPCODE m_Opcode;
static uint32_t m_JumpToLocation;
protected:
static void SPECIAL();
static void REGIMM();
static void COP0();
static void COP0_CO();
static void COP1();
static void COP1_BC();
static void COP1_S();
static void COP1_D();
static void COP1_W();
static void COP1_L();
static void SPECIAL();
static void REGIMM();
static void COP0();
static void COP0_CO();
static void COP1();
static void COP1_BC();
static void COP1_S();
static void COP1_D();
static void COP1_W();
static void COP1_L();
static Func Jump_Opcode[64];
static Func Jump_Special[64];
static Func Jump_Regimm[32];
static Func Jump_CoP0[32];
static Func Jump_CoP0_Function[64];
static Func Jump_CoP1[32];
static Func Jump_CoP1_BC[32];
static Func Jump_CoP1_S[64];
static Func Jump_CoP1_D[64];
static Func Jump_CoP1_W[64];
static Func Jump_CoP1_L[64];
static const DWORD SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4];
static const int SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4];
static Func Jump_Opcode[64];
static Func Jump_Special[64];
static Func Jump_Regimm[32];
static Func Jump_CoP0[32];
static Func Jump_CoP0_Function[64];
static Func Jump_CoP1[32];
static Func Jump_CoP1_BC[32];
static Func Jump_CoP1_S[64];
static Func Jump_CoP1_D[64];
static Func Jump_CoP1_W[64];
static Func Jump_CoP1_L[64];
static const uint32_t SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4];
static const int32_t SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4];
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -9,147 +9,150 @@
* *
****************************************************************************/
#include "stdafx.h"
#include "Audio.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
CAudio::CAudio()
{
Reset();
Reset();
}
CAudio::~CAudio()
{
}
void CAudio::Reset()
{
m_SecondBuff = 0;
m_Status = 0;
m_BytesPerSecond = 0;
m_CountsPerByte = g_System->AiCountPerBytes(); // should be calculated ... see below, instead allow from user settings
if (m_CountsPerByte == 0) m_CountsPerByte = 500; // If the user has no defined value, grant a default and we will calculate
m_FramesPerSecond = 60;
m_SecondBuff = 0;
m_Status = 0;
m_BytesPerSecond = 0;
m_CountsPerByte = g_System->AiCountPerBytes(); // should be calculated ... see below, instead allow from user settings
if (m_CountsPerByte == 0) m_CountsPerByte = 500; // If the user has no defined value, grant a default and we will calculate
m_FramesPerSecond = 60;
}
DWORD CAudio::GetLength()
uint32_t CAudio::GetLength()
{
WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff);
DWORD TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0;
if (TimeLeft > 0)
{
Res = (TimeLeft / m_CountsPerByte);
}
WriteTraceF(TraceAudio,__FUNCTION__ ": Done (res = %d, TimeLeft = %d)",Res, TimeLeft);
return (Res+3)&~3;
WriteTraceF(TraceAudio, __FUNCTION__ ": Start (m_SecondBuff = %d)", m_SecondBuff);
uint32_t TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0;
if (TimeLeft > 0)
{
Res = (TimeLeft / m_CountsPerByte);
}
WriteTraceF(TraceAudio, __FUNCTION__ ": Done (res = %d, TimeLeft = %d)", Res, TimeLeft);
return (Res + 3)&~3;
}
DWORD CAudio::GetStatus()
uint32_t CAudio::GetStatus()
{
WriteTraceF(TraceAudio,__FUNCTION__ ": m_Status = %X",m_Status);
return m_Status;
WriteTraceF(TraceAudio, __FUNCTION__ ": m_Status = %X", m_Status);
return m_Status;
}
void CAudio::LenChanged()
{
WriteTraceF(TraceAudio,__FUNCTION__ ": Start (g_Reg->AI_LEN_REG = %d)",g_Reg->AI_LEN_REG);
if (g_Reg->AI_LEN_REG != 0)
{
if (g_Reg->AI_LEN_REG >= 0x40000)
{
WriteTraceF(TraceAudio,__FUNCTION__ ": *** Ignoring Write, To Large (%X)",g_Reg->AI_LEN_REG);
} else {
m_Status |= ai_busy;
DWORD AudioLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt);
if (m_SecondBuff == 0)
{
if (AudioLeft == 0)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Set Timer AI_LEN_REG: %d m_CountsPerByte: %d", g_Reg->AI_LEN_REG, m_CountsPerByte);
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt, g_Reg->AI_LEN_REG * m_CountsPerByte, false);
}
else
{
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_Status |= ai_full;
}
}
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
}
}
else
{
WriteTraceF(TraceAudio,__FUNCTION__ ": *** Reset Timer to 0");
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
m_SecondBuff = 0;
m_Status = 0;
}
WriteTraceF(TraceAudio, __FUNCTION__ ": Start (g_Reg->AI_LEN_REG = %d)", g_Reg->AI_LEN_REG);
if (g_Reg->AI_LEN_REG != 0)
{
if (g_Reg->AI_LEN_REG >= 0x40000)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": *** Ignoring Write, To Large (%X)", g_Reg->AI_LEN_REG);
}
else
{
m_Status |= ai_busy;
uint32_t AudioLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt);
if (m_SecondBuff == 0)
{
if (AudioLeft == 0)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Set Timer AI_LEN_REG: %d m_CountsPerByte: %d", g_Reg->AI_LEN_REG, m_CountsPerByte);
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt, g_Reg->AI_LEN_REG * m_CountsPerByte, false);
}
else
{
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_Status |= ai_full;
}
}
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
}
}
else
{
WriteTraceF(TraceAudio, __FUNCTION__ ": *** Reset Timer to 0");
g_SystemTimer->StopTimer(CSystemTimer::AiTimerBusy);
g_SystemTimer->StopTimer(CSystemTimer::AiTimerInterrupt);
m_SecondBuff = 0;
m_Status = 0;
}
if (g_Plugins->Audio()->AiLenChanged != NULL)
{
g_Plugins->Audio()->AiLenChanged();
}
WriteTraceF(TraceAudio,__FUNCTION__ ": Done");
if (g_Plugins->Audio()->AiLenChanged != NULL)
{
g_Plugins->Audio()->AiLenChanged();
}
WriteTraceF(TraceAudio, __FUNCTION__ ": Done");
}
void CAudio::InterruptTimerDone()
{
WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff);
m_Status &= ~ai_full;
g_Reg->MI_INTR_REG |= MI_INTR_AI;
g_Reg->CheckInterrupts();
if (m_SecondBuff != 0)
{
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt,m_SecondBuff * m_CountsPerByte,false);
m_SecondBuff = 0;
}
else
{
m_Status &= ~ai_busy;
}
if (g_Reg->m_AudioIntrReg == 0)
{
g_System->SyncToAudio();
}
WriteTrace(TraceAudio,__FUNCTION__ ": Done");
WriteTraceF(TraceAudio, __FUNCTION__ ": Start (m_SecondBuff = %d)", m_SecondBuff);
m_Status &= ~ai_full;
g_Reg->MI_INTR_REG |= MI_INTR_AI;
g_Reg->CheckInterrupts();
if (m_SecondBuff != 0)
{
g_SystemTimer->SetTimer(CSystemTimer::AiTimerInterrupt, m_SecondBuff * m_CountsPerByte, false);
m_SecondBuff = 0;
}
else
{
m_Status &= ~ai_busy;
}
if (g_Reg->m_AudioIntrReg == 0)
{
g_System->SyncToAudio();
}
WriteTrace(TraceAudio, __FUNCTION__ ": Done");
}
void CAudio::BusyTimerDone()
{
WriteTraceF(TraceAudio,__FUNCTION__ ": Start (m_SecondBuff = %d)",m_SecondBuff);
g_Notify->BreakPoint(__FILEW__,__LINE__);
m_Status &= ~ai_busy;
WriteTraceF(TraceAudio, __FUNCTION__ ": Start (m_SecondBuff = %d)", m_SecondBuff);
g_Notify->BreakPoint(__FILEW__, __LINE__);
m_Status &= ~ai_busy;
}
void CAudio::SetViIntr ( DWORD VI_INTR_TIME )
void CAudio::SetViIntr(uint32_t VI_INTR_TIME)
{
double CountsPerSecond = (DWORD)((double)VI_INTR_TIME * m_FramesPerSecond);
if (m_BytesPerSecond != 0 && (g_System->AiCountPerBytes() == 0))
{
m_CountsPerByte = (int)((double)CountsPerSecond / (double)m_BytesPerSecond);
}
double CountsPerSecond = (uint32_t)((double)VI_INTR_TIME * m_FramesPerSecond);
if (m_BytesPerSecond != 0 && (g_System->AiCountPerBytes() == 0))
{
m_CountsPerByte = (int32_t)((double)CountsPerSecond / (double)m_BytesPerSecond);
}
}
void CAudio::SetFrequency (DWORD Dacrate, DWORD System)
void CAudio::SetFrequency(uint32_t Dacrate, uint32_t System)
{
WriteTraceF(TraceAudio,__FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X",Dacrate,System,g_Reg->AI_BITRATE_REG);
DWORD Frequency;
WriteTraceF(TraceAudio, __FUNCTION__ "(Dacrate: %X System: %d): AI_BITRATE_REG = %X", Dacrate, System, g_Reg->AI_BITRATE_REG);
uint32_t Frequency;
switch (System)
{
case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break;
default: Frequency = 48681812 / (Dacrate + 1); break;
}
switch (System)
{
case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break;
case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break;
default: Frequency = 48681812 / (Dacrate + 1); break;
}
//nBlockAlign = 16 / 8 * 2;
m_BytesPerSecond = Frequency * 4;
//m_BytesPerSecond = 194532;
//m_BytesPerSecond = 128024;
//nBlockAlign = 16 / 8 * 2;
m_BytesPerSecond = Frequency * 4;
//m_BytesPerSecond = 194532;
//m_BytesPerSecond = 128024;
m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
}
m_FramesPerSecond = System == SYSTEM_PAL ? 50 : 60;
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,29 +11,32 @@
#pragma once
class CAudio
{
enum
{
ai_full = 0x80000000,
ai_busy = 0x40000000,
};
{
enum
{
ai_full = 0x80000000,
ai_busy = 0x40000000,
};
public:
CAudio();
~CAudio();
CAudio();
~CAudio();
DWORD GetLength ();
DWORD GetStatus ();
void LenChanged ();
void InterruptTimerDone();
void BusyTimerDone ();
void Reset ();
void SetViIntr ( DWORD VI_INTR_TIME );
void SetFrequency ( DWORD Dacrate, DWORD System );
uint32_t GetLength ();
uint32_t GetStatus ();
void LenChanged ();
void InterruptTimerDone();
void BusyTimerDone ();
void Reset ();
void SetViIntr ( uint32_t VI_INTR_TIME );
void SetFrequency ( uint32_t Dacrate, uint32_t System );
private:
DWORD m_SecondBuff;
DWORD m_Status;
DWORD m_BytesPerSecond;
int m_CountsPerByte;
int m_FramesPerSecond;
CAudio(const CAudio&); // Disable copy constructor
CAudio& operator=(const CAudio&); // Disable assignment
uint32_t m_SecondBuff;
uint32_t m_Status;
uint32_t m_BytesPerSecond;
int32_t m_CountsPerByte;
int32_t m_FramesPerSecond;
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,355 +11,362 @@
#include "stdafx.h"
CDMA::CDMA(CFlashram & FlashRam, CSram & Sram) :
m_FlashRam(FlashRam),
m_Sram(Sram)
m_FlashRam(FlashRam),
m_Sram(Sram)
{
}
void CDMA::OnFirstDMA()
{
switch (g_Rom->CicChipID())
{
case CIC_NUS_6101: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case CIC_NUS_5167: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case CIC_UNKNOWN:
case CIC_NUS_6102: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case CIC_NUS_6103: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
case CIC_NUS_6105: *(DWORD *)&((g_MMU->Rdram())[0x3F0]) = g_MMU->RdramSize(); break;
case CIC_NUS_6106: *(DWORD *)&((g_MMU->Rdram())[0x318]) = g_MMU->RdramSize(); break;
default: g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA",g_Rom->CicChipID()).ToUTF16().c_str());
}
int16_t offset;
const uint32_t base = 0x00000000;
const uint32_t rt = g_MMU->RdramSize();
switch (g_Rom->CicChipID())
{
case CIC_NUS_6101: offset = +0x0318; break;
case CIC_NUS_5167: offset = +0x0318; break;
case CIC_UNKNOWN:
case CIC_NUS_6102: offset = +0x0318; break;
case CIC_NUS_6103: offset = +0x0318; break;
case CIC_NUS_6105: offset = +0x03F0; break;
case CIC_NUS_6106: offset = +0x0318; break;
default:
g_Notify->DisplayError(
stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).ToUTF16().c_str()
);
return;
}
g_MMU->SW_PAddr(base + offset, rt);
}
void CDMA::PI_DMA_READ()
{
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
DWORD PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
// PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
uint32_t PI_RD_LEN_REG = ((g_Reg->PI_RD_LEN_REG) & 0x00FFFFFFul) + 1;
if ((PI_RD_LEN_REG & 1) != 0)
{
PI_RD_LEN_REG += 1;
}
if ( g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f("PI_DMA_READ not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if ((PI_RD_LEN_REG & 1) != 0)
{
PI_RD_LEN_REG += 1;
}
//Write ROM Area (for 64DD Convert)
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites))
{
DWORD i;
BYTE * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram();
if (g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f("PI_DMA_READ not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_RD_LEN_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
DWORD OldProtect;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect);
//Write ROM Area (for 64DD Convert)
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF && g_Settings->LoadBool(Game_AllowROMWrites))
{
uint32_t i;
uint8_t * ROM = g_Rom->GetRomAddress();
uint8_t * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_RD_LEN_REG < g_Rom->GetRomSize())
{
for (i = 0; i < PI_RD_LEN_REG; i++)
{
*(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
}
}
else
{
DWORD Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++)
{
*(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
}
}
g_Reg->PI_CART_ADDR_REG += 0x10000000;
DWORD OldProtect;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READWRITE, &OldProtect);
if (!g_System->DmaUsed())
{
g_System->SetDmaUsed(true);
OnFirstDMA();
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_RD_LEN_REG < g_Rom->GetRomSize())
{
for (i = 0; i < PI_RD_LEN_REG; i++)
{
*(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
}
}
else
{
uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++)
{
*(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3)) = *(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3));
}
}
g_Reg->PI_CART_ADDR_REG += 0x10000000;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (!g_System->DmaUsed())
{
g_System->SetDmaUsed(true);
OnFirstDMA();
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaToSram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaToFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
g_Notify->DisplayError(stdstr_f("**** FLashRam DMA Read address %08X *****",g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : 08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
VirtualProtect(ROM, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaToSram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaToFlashram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_RD_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
g_Notify->DisplayError(stdstr_f("**** FLashRam DMA Read address %08X *****", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
void CDMA::PI_DMA_WRITE()
{
DWORD PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1;
uint32_t PI_WR_LEN_REG = ((g_Reg->PI_WR_LEN_REG) & 0x00FFFFFFul) + 1;
if ((PI_WR_LEN_REG & 1) != 0)
{
PI_WR_LEN_REG += 1; /* fixes AI Shougi 3, Doraemon 3, etc. */
}
if ((PI_WR_LEN_REG & 1) != 0)
{
PI_WR_LEN_REG += 1; /* fixes AI Shougi 3, Doraemon 3, etc. */
}
g_Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
if ( g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG > g_MMU->RdramSize())
{
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG).ToUTF16().c_str()); }
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
g_Reg->PI_STATUS_REG |= PI_STATUS_DMA_BUSY;
if (g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG > g_MMU->RdramSize())
{
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in Memory: %08X", g_Reg->PI_DRAM_ADDR_REG + PI_WR_LEN_REG).ToUTF16().c_str()); }
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaFromSram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaFromFlashram(
g_MMU->Rdram()+g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
}
return;
}
if (g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000)
{
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Sram;
}
if (g_System->m_SaveUsing == SaveChip_Sram)
{
m_Sram.DmaFromSram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
return;
}
if (g_System->m_SaveUsing == SaveChip_FlashRam)
{
m_FlashRam.DmaFromFlashram(
g_MMU->Rdram() + g_Reg->PI_DRAM_ADDR_REG,
g_Reg->PI_CART_ADDR_REG - 0x08000000,
PI_WR_LEN_REG
);
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
}
return;
}
if ( g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF)
{
DWORD i;
if (g_Reg->PI_CART_ADDR_REG >= 0x10000000 && g_Reg->PI_CART_ADDR_REG <= 0x1FFFFFFF)
{
uint32_t i;
#ifdef tofix
#ifdef ROM_IN_MAPSPACE
if (WrittenToRom)
{
DWORD OldProtect;
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
}
if (WrittenToRom)
{
uint32_t OldProtect;
VirtualProtect(ROM,m_RomFileSize,PAGE_READONLY, &OldProtect);
}
#endif
#endif
BYTE * ROM = g_Rom->GetRomAddress();
BYTE * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
{
for (i = 0; i < PI_WR_LEN_REG; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
}
else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize())
{
DWORD cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize();
while (cart >= g_Rom->GetRomSize())
{
cart -= g_Rom->GetRomSize();
}
for (i = 0; i < PI_WR_LEN_REG; i++)
{
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((cart + i) ^ 3));
}
}
else
{
DWORD Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM+((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
for (i = Len; i < PI_WR_LEN_REG - Len; i ++)
{
*(RDRAM+((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
}
}
g_Reg->PI_CART_ADDR_REG += 0x10000000;
uint8_t * ROM = g_Rom->GetRomAddress();
uint8_t * RDRAM = g_MMU->Rdram();
g_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (g_Reg->PI_CART_ADDR_REG + PI_WR_LEN_REG < g_Rom->GetRomSize())
{
for (i = 0; i < PI_WR_LEN_REG; i++)
{
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
}
else if (g_Reg->PI_CART_ADDR_REG >= g_Rom->GetRomSize())
{
uint32_t cart = g_Reg->PI_CART_ADDR_REG - g_Rom->GetRomSize();
while (cart >= g_Rom->GetRomSize())
{
cart -= g_Rom->GetRomSize();
}
for (i = 0; i < PI_WR_LEN_REG; i++)
{
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((cart + i) ^ 3));
}
}
else
{
uint32_t Len;
Len = g_Rom->GetRomSize() - g_Reg->PI_CART_ADDR_REG;
for (i = 0; i < Len; i++)
{
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = *(ROM + ((g_Reg->PI_CART_ADDR_REG + i) ^ 3));
}
for (i = Len; i < PI_WR_LEN_REG - Len; i++)
{
*(RDRAM + ((g_Reg->PI_DRAM_ADDR_REG + i) ^ 3)) = 0;
}
}
g_Reg->PI_CART_ADDR_REG += 0x10000000;
if (!g_System->DmaUsed())
{
g_System->SetDmaUsed(true);
OnFirstDMA();
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG,CRecompiler::Remove_DMA);
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9) + 50);
//ChangeTimer(PiTimer,(int)(PI_WR_LEN_REG * 8.9));
return;
}
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory))
{
g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in ROM: %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
if (!g_System->DmaUsed())
{
g_System->SetDmaUsed(true);
OnFirstDMA();
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA);
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50);
//ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9));
return;
}
if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory))
{
g_Notify->DisplayError(stdstr_f("PI_DMA_WRITE not in ROM: %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str());
}
g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
g_Reg->MI_INTR_REG |= MI_INTR_PI;
g_Reg->CheckInterrupts();
}
void CDMA::SP_DMA_READ()
{
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 (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
}
g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
return;
}
if (g_Reg->SP_RD_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
if (bHaveDebugger())
{
g_Notify->DisplayError(__FUNCTIONW__ L"\nCould not fit copy in memory segment");
}
return;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
}
g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
return;
}
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_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
if (g_Reg->SP_RD_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
if (bHaveDebugger())
{
g_Notify->DisplayError(__FUNCTIONW__ L"\nCould not fit copy in memory segment");
}
return;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
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_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}
void CDMA::SP_DMA_WRITE()
{
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
}
return;
}
if (g_Reg->SP_WR_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
if (bHaveDebugger())
{
g_Notify->DisplayError(L"SP DMA WRITE\ncould not fit copy in memory segement");
}
return;
}
void CDMA::SP_DMA_WRITE()
{
if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
{
if (bHaveDebugger())
{
g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
}
return;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
if (g_Reg->SP_WR_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
{
if (bHaveDebugger())
{
g_Notify->DisplayError(L"SP DMA WRITE\ncould not fit copy in memory segement");
}
return;
}
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_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}
if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
memcpy(g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
g_Reg->SP_WR_LEN_REG + 1);
g_Reg->SP_DMA_BUSY_REG = 0;
g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -9,27 +9,30 @@
* *
****************************************************************************/
#pragma once
#include <Project64\Settings\Debug Settings.h>
#include <Project64\N64 System\Mips\FlashRam.h>
#include <Project64\N64 System\Mips\Sram.h>
class CDMA :
private CDebugSettings
private CDebugSettings
{
CDMA();
CDMA();
public:
void SP_DMA_READ();
void SP_DMA_WRITE();
void PI_DMA_READ();
void PI_DMA_WRITE();
void SP_DMA_READ();
void SP_DMA_WRITE();
void PI_DMA_READ();
void PI_DMA_WRITE();
protected:
CDMA (CFlashram & FlashRam, CSram & Sram);
//void SI_DMA_READ();
//void SI_DMA_WRITE();
CDMA(CFlashram & FlashRam, CSram & Sram);
private:
CFlashram & m_FlashRam;
CSram & m_Sram;
void OnFirstDMA();
CDMA(const CDMA&); // Disable copy constructor
CDMA& operator=(const CDMA&); // Disable assignment
CFlashram & m_FlashRam;
CSram & m_Sram;
void OnFirstDMA();
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -9,190 +9,193 @@
* *
****************************************************************************/
#include "stdafx.h"
#include "Eeprom.h"
#include <Project64\N64 System\System Globals.h>
#include <Project64\N64 System\N64 Class.h>
#include <time.h>
CEeprom::CEeprom(bool ReadOnly):
m_ReadOnly(ReadOnly),
m_hFile(NULL)
CEeprom::CEeprom(bool ReadOnly) :
m_ReadOnly(ReadOnly),
m_hFile(NULL)
{
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
memset(m_EEPROM, 0xFF, sizeof(m_EEPROM));
}
CEeprom::~CEeprom()
{
if (m_hFile)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
if (m_hFile)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
}
unsigned char byte2bcd(int n)
uint8_t byte2bcd(int32_t n)
{
n %= 100;
return (unsigned char)(((n / 10) << 4) | (n % 10));
n %= 100;
return (uint8_t)(((n / 10) << 4) | (n % 10));
}
void CEeprom::EepromCommand ( BYTE * Command)
void CEeprom::EepromCommand(uint8_t * Command)
{
time_t curtime_time;
struct tm curtime;
time_t curtime_time;
struct tm curtime;
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Eeprom_4K;
}
if (g_System->m_SaveUsing == SaveChip_Auto)
{
g_System->m_SaveUsing = SaveChip_Eeprom_4K;
}
switch (Command[2])
{
case 0: // check
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K)
{
Command[1] |= 0x80;
break;
}
if (Command[1] != 3)
{
Command[1] |= 0x40;
if ((Command[1] & 3) > 0)
Command[3] = 0x00;
if ((Command[1] & 3) > 1)
Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
if ((Command[1] & 3) > 2)
Command[5] = 0x00;
}
else
{
Command[3] = 0x00;
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[5] = 0x00;
}
break;
case 4: // Read from Eeprom
if (Command[0] != 2 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 8 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
ReadFrom(&Command[4],Command[3]);
break;
case 5: //Write to Eeprom
if (Command[0] != 10 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 1 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
WriteTo(&Command[4],Command[3]);
break;
case 6: //RTC Status query
Command[3] = 0x00;
Command[4] = 0x10;
Command[5] = 0x00;
break;
case 7: //Read RTC block
switch (Command[3])
{
case 0: //Block number
Command[4] = 0x00;
Command[5] = 0x02;
Command[12] = 0x00;
break;
case 1:
//read block, Command[2], Unimplemented
break;
case 2: //Set RTC Time
time(&curtime_time);
memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); // fd's fix
Command[4] = byte2bcd(curtime.tm_sec);
Command[5] = byte2bcd(curtime.tm_min);
Command[6] = 0x80 + byte2bcd(curtime.tm_hour);
Command[7] = byte2bcd(curtime.tm_mday);
Command[8] = byte2bcd(curtime.tm_wday);
Command[9] = byte2bcd(curtime.tm_mon + 1);
Command[10] = byte2bcd(curtime.tm_year);
Command[11] = byte2bcd(curtime.tm_year / 100);
Command[12] = 0x00; // status
break;
}
break;
case 8:
//Write RTC, unimplemented
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(L"Write RTC, unimplemented");
}
break;
default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d",Command[2]).ToUTF16().c_str());
}
}
switch (Command[2])
{
case 0: // check
if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K)
{
Command[1] |= 0x80;
break;
}
if (Command[1] != 3)
{
Command[1] |= 0x40;
if ((Command[1] & 3) > 0)
Command[3] = 0x00;
if ((Command[1] & 3) > 1)
Command[4] = (g_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
if ((Command[1] & 3) > 2)
Command[5] = 0x00;
}
else
{
Command[3] = 0x00;
Command[4] = g_System->m_SaveUsing == SaveChip_Eeprom_4K ? 0x80 : 0xC0;
Command[5] = 0x00;
}
break;
case 4: // Read from Eeprom
if (Command[0] != 2 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 8 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
ReadFrom(&Command[4], Command[3]);
break;
case 5: //Write to Eeprom
if (Command[0] != 10 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
if (Command[1] != 1 && bHaveDebugger())
{
g_Notify->DisplayError(L"What am I meant to do with this Eeprom Command");
}
WriteTo(&Command[4], Command[3]);
break;
case 6: //RTC Status query
Command[3] = 0x00;
Command[4] = 0x10;
Command[5] = 0x00;
break;
case 7: //Read RTC block
switch (Command[3])
{
case 0: //Block number
Command[4] = 0x00;
Command[5] = 0x02;
Command[12] = 0x00;
break;
case 1:
//read block, Command[2], Unimplemented
break;
case 2: //Set RTC Time
time(&curtime_time);
memcpy(&curtime, localtime(&curtime_time), sizeof(curtime)); // fd's fix
Command[4] = byte2bcd(curtime.tm_sec);
Command[5] = byte2bcd(curtime.tm_min);
Command[6] = 0x80 + byte2bcd(curtime.tm_hour);
Command[7] = byte2bcd(curtime.tm_mday);
Command[8] = byte2bcd(curtime.tm_wday);
Command[9] = byte2bcd(curtime.tm_mon + 1);
Command[10] = byte2bcd(curtime.tm_year);
Command[11] = byte2bcd(curtime.tm_year / 100);
Command[12] = 0x00; // status
break;
}
break;
case 8:
//Write RTC, unimplemented
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(L"Write RTC, unimplemented");
}
break;
default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors))
{
g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d", Command[2]).ToUTF16().c_str());
}
}
}
void CEeprom::LoadEeprom()
{
CPath FileName;
DWORD dwRead;
CPath FileName;
DWORD dwRead;
memset(m_EEPROM,0xFF,sizeof(m_EEPROM));
memset(m_EEPROM, 0xFF, sizeof(m_EEPROM));
FileName.SetDriveDirectory( g_Settings->LoadStringVal(Directory_NativeSave).c_str());
FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str());
FileName.SetExtension("eep");
FileName.SetDriveDirectory(g_Settings->LoadStringVal(Directory_NativeSave).c_str());
FileName.SetName(g_Settings->LoadStringVal(Game_GameName).c_str());
FileName.SetExtension("eep");
if (!FileName.DirectoryExists())
{
FileName.DirectoryCreate();
}
if (!FileName.DirectoryExists())
{
FileName.DirectoryCreate();
}
m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
WriteTraceF(TraceError,__FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X",(LPCTSTR)FileName, m_ReadOnly, GetLastError());
g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return;
}
SetFilePointer(m_hFile,0,NULL,FILE_BEGIN);
ReadFile(m_hFile,m_EEPROM,sizeof(m_EEPROM),&dwRead,NULL);
m_hFile = CreateFile(FileName, m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
WriteTraceF(TraceError, __FUNCTION__ ": Failed to open (%s), ReadOnly = %d, LastError = %X", (LPCTSTR)FileName, m_ReadOnly, GetLastError());
g_Notify->DisplayError(GS(MSG_FAIL_OPEN_EEPROM));
return;
}
SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN);
ReadFile(m_hFile, m_EEPROM, sizeof(m_EEPROM), &dwRead, NULL);
}
void CEeprom::ReadFrom(BYTE * Buffer, int line)
void CEeprom::ReadFrom(uint8_t * Buffer, int32_t line)
{
int i;
if (m_hFile == NULL)
{
LoadEeprom();
}
for (i=0; i < 8; i++)
{
Buffer[i] = m_EEPROM[line*8+i];
}
int32_t i;
if (m_hFile == NULL)
{
LoadEeprom();
}
for (i = 0; i < 8; i++)
{
Buffer[i] = m_EEPROM[line * 8 + i];
}
}
void CEeprom::WriteTo(BYTE * Buffer, int line)
void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
{
DWORD dwWritten;
int i;
DWORD dwWritten;
int32_t i;
if (m_hFile == NULL)
{
LoadEeprom();
}
for (i=0;i<8;i++)
{
m_EEPROM[line*8+i]=Buffer[i];
}
SetFilePointer(m_hFile,line*8,NULL,FILE_BEGIN);
WriteFile( m_hFile,Buffer,8,&dwWritten,NULL );
FlushFileBuffers(m_hFile);
}
if (m_hFile == NULL)
{
LoadEeprom();
}
for (i = 0; i < 8; i++)
{
m_EEPROM[line * 8 + i] = Buffer[i];
}
SetFilePointer(m_hFile, line * 8, NULL, FILE_BEGIN);
WriteFile(m_hFile, Buffer, 8, &dwWritten, NULL);
FlushFileBuffers(m_hFile);
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -11,20 +11,24 @@
#pragma once
class CEeprom :
private CDebugSettings
private CDebugSettings
{
public:
CEeprom ( bool ReadOnly );
~CEeprom();
CEeprom(bool ReadOnly);
~CEeprom();
void EepromCommand ( BYTE * Command );
void EepromCommand(uint8_t * Command);
private:
void LoadEeprom ();
void ReadFrom ( BYTE * Buffer, int line );
void WriteTo ( BYTE * Buffer, int line );
CEeprom(void); // Disable default constructor
CEeprom(const CEeprom&); // Disable copy constructor
CEeprom& operator=(const CEeprom&); // Disable assignment
BYTE m_EEPROM[0x800];
bool m_ReadOnly;
HANDLE m_hFile;
void LoadEeprom();
void ReadFrom(uint8_t * Buffer, int32_t line);
void WriteTo(uint8_t * Buffer, int32_t line);
uint8_t m_EEPROM[0x800];
bool m_ReadOnly;
void * m_hFile;
};

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *

View File

@ -1,6 +1,6 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
@ -10,78 +10,75 @@
****************************************************************************/
#pragma once
#include <objbase.h>
interface CMipsMemory_CallBack
__interface CMipsMemory_CallBack
{
//Protected memory has been written to, returns true if that memory has been unprotected
virtual bool WriteToProtectedMemory (DWORD Address, int length) = 0;
//Protected memory has been written to, returns true if that memory has been unprotected
virtual bool WriteToProtectedMemory (uint32_t Address, int32_t length) = 0;
};
class CMipsMemory
__interface CMipsMemory
{
public:
virtual BYTE * Rdram () = 0;
virtual DWORD RdramSize() = 0;
virtual BYTE * Dmem () = 0;
virtual BYTE * Imem () = 0;
virtual BYTE * PifRam () = 0;
virtual bool LB_VAddr ( DWORD VAddr, BYTE & Value ) = 0;
virtual bool LH_VAddr ( DWORD VAddr, WORD & Value ) = 0;
virtual bool LW_VAddr ( DWORD VAddr, DWORD & Value ) = 0;
virtual bool LD_VAddr ( DWORD VAddr, QWORD & Value ) = 0;
virtual uint8_t * Rdram () = 0;
virtual uint32_t RdramSize() = 0;
virtual uint8_t * Dmem () = 0;
virtual uint8_t * Imem () = 0;
virtual uint8_t * PifRam () = 0;
virtual bool LB_PAddr ( DWORD PAddr, BYTE & Value ) = 0;
virtual bool LH_PAddr ( DWORD PAddr, WORD & Value ) = 0;
virtual bool LW_PAddr ( DWORD PAddr, DWORD & Value ) = 0;
virtual bool LD_PAddr ( DWORD PAddr, QWORD & Value ) = 0;
virtual bool LB_VAddr ( uint32_t VAddr, uint8_t & Value ) = 0;
virtual bool LH_VAddr ( uint32_t VAddr, uint16_t & Value ) = 0;
virtual bool LW_VAddr ( uint32_t VAddr, uint32_t & Value ) = 0;
virtual bool LD_VAddr ( uint32_t VAddr, uint64_t & Value ) = 0;
virtual bool SB_VAddr ( DWORD VAddr, BYTE Value ) = 0;
virtual bool SH_VAddr ( DWORD VAddr, WORD Value ) = 0;
virtual bool SW_VAddr ( DWORD VAddr, DWORD Value ) = 0;
virtual bool SD_VAddr ( DWORD VAddr, QWORD Value ) = 0;
virtual bool LB_PAddr ( uint32_t PAddr, uint8_t & Value ) = 0;
virtual bool LH_PAddr ( uint32_t PAddr, uint16_t & Value ) = 0;
virtual bool LW_PAddr ( uint32_t PAddr, uint32_t & Value ) = 0;
virtual bool LD_PAddr ( uint32_t PAddr, uint64_t & Value ) = 0;
virtual bool SB_PAddr ( DWORD PAddr, BYTE Value ) = 0;
virtual bool SH_PAddr ( DWORD PAddr, WORD Value ) = 0;
virtual bool SW_PAddr ( DWORD PAddr, DWORD Value ) = 0;
virtual bool SD_PAddr ( DWORD PAddr, QWORD Value ) = 0;
virtual bool SB_VAddr ( uint32_t VAddr, uint8_t Value ) = 0;
virtual bool SH_VAddr ( uint32_t VAddr, uint16_t Value ) = 0;
virtual bool SW_VAddr ( uint32_t VAddr, uint32_t Value ) = 0;
virtual bool SD_VAddr ( uint32_t VAddr, uint64_t Value ) = 0;
virtual bool ValidVaddr ( DWORD VAddr ) const = 0;
virtual bool SB_PAddr ( uint32_t PAddr, uint8_t Value ) = 0;
virtual bool SH_PAddr ( uint32_t PAddr, uint16_t Value ) = 0;
virtual bool SW_PAddr ( uint32_t PAddr, uint32_t Value ) = 0;
virtual bool SD_PAddr ( uint32_t PAddr, uint64_t Value ) = 0;
virtual int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer ) = 0;
virtual void UpdateFieldSerration ( unsigned int interlaced ) = 0;
virtual bool ValidVaddr ( uint32_t VAddr ) const = 0;
//Protect the Memory from being written to
virtual void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0;
virtual void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0;
virtual int32_t MemoryFilter ( uint32_t dwExptCode, void * lpExceptionPointer ) = 0;
virtual void UpdateFieldSerration ( uint32_t interlaced ) = 0;
//Compilation Functions
virtual void ResetMemoryStack () = 0;
virtual void Compile_LB () = 0;
virtual void Compile_LBU () = 0;
virtual void Compile_LH () = 0;
virtual void Compile_LHU () = 0;
virtual void Compile_LW () = 0;
virtual void Compile_LL () = 0;
virtual void Compile_LWC1 () = 0;
virtual void Compile_LWU () = 0;
virtual void Compile_LWL () = 0;
virtual void Compile_LWR () = 0;
virtual void Compile_LD () = 0;
virtual void Compile_LDC1 () = 0;
virtual void Compile_LDL () = 0;
virtual void Compile_LDR () = 0;
virtual void Compile_SB () = 0;
virtual void Compile_SH () = 0;
virtual void Compile_SW () = 0;
virtual void Compile_SWL () = 0;
virtual void Compile_SWR () = 0;
virtual void Compile_SD () = 0;
virtual void Compile_SDL () = 0;
virtual void Compile_SDR () = 0;
virtual void Compile_SC () = 0;
virtual void Compile_SWC1 () = 0;
virtual void Compile_SDC1 () = 0;
//Protect the Memory from being written to
virtual void ProtectMemory ( uint32_t StartVaddr, uint32_t EndVaddr ) = 0;
virtual void UnProtectMemory ( uint32_t StartVaddr, uint32_t EndVaddr ) = 0;
//Compilation Functions
virtual void ResetMemoryStack () = 0;
virtual void Compile_LB () = 0;
virtual void Compile_LBU () = 0;
virtual void Compile_LH () = 0;
virtual void Compile_LHU () = 0;
virtual void Compile_LW () = 0;
virtual void Compile_LL () = 0;
virtual void Compile_LWC1 () = 0;
virtual void Compile_LWU () = 0;
virtual void Compile_LWL () = 0;
virtual void Compile_LWR () = 0;
virtual void Compile_LD () = 0;
virtual void Compile_LDC1 () = 0;
virtual void Compile_LDL () = 0;
virtual void Compile_LDR () = 0;
virtual void Compile_SB () = 0;
virtual void Compile_SH () = 0;
virtual void Compile_SW () = 0;
virtual void Compile_SWL () = 0;
virtual void Compile_SWR () = 0;
virtual void Compile_SD () = 0;
virtual void Compile_SDL () = 0;
virtual void Compile_SDR () = 0;
virtual void Compile_SC () = 0;
virtual void Compile_SWC1 () = 0;
virtual void Compile_SDC1 () = 0;
};

Some files were not shown because too many files have changed in this diff Show More