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

This commit is contained in:
zilmar 2010-05-25 09:15:19 +00:00
parent 4200b4b6af
commit 142187aafb
52 changed files with 11396 additions and 6263 deletions

View File

@ -4,6 +4,9 @@
#include "Support.h"
#include <string> //needed for stl string (std::string)
#include <float.h>
#include <math.h>
#include "User Interface.h"
#include "N64 System/Types.h"
@ -16,6 +19,7 @@ class CNotification;
#include "N64 System/Speed Limitor Class.h"
#include "N64 System/Mips/OpCode.h"
#include "N64 System/Mips/Register Class.h"
#include "N64 System/Mips/TranslateVaddr.h"
#include "N64 System/Mips/TLB Class.h"
#include "N64 System/Mips/Memory Labels Class.h"
#include "N64 System/Mips/Memory Class.h"
@ -23,7 +27,18 @@ class CNotification;
#include "N64 System/Mips/Audio.h"
#include "N64 System/Mips/System Timing.h"
//C Core - to be upgrdaded and removed
#include "N64 System/C Core/CPU Log.h"
#include "N64 System/C Core/r4300i Commands.h"
//Interpter
#include "N64 System/Interpreter/Interpreter Ops.h"
#include "N64 System/Interpreter/Interpreter Ops 32.h"
#include "N64 System/Interpreter/Interpreter CPU.h"
//Recompiler
#include "N64 System/Recompiler/Recompiler Memory.h"
#include "N64 System/Recompiler/Recompiler Ops.h"
#include "N64 System/Recompiler/Section Info.h"
#include "N64 System/Recompiler/Function Info.h"
#include "N64 System/Recompiler/Function Map Class.h"

View File

@ -39,7 +39,7 @@ int * _Timer = NULL;
//settings
BOOL g_ShowUnhandledMemory = false, g_ShowCPUPer = false, g_ShowTLBMisses = false, g_UseTlb = true,
g_HaveDebugger = false, g_AudioSignal = false, g_ShowDListAListCount = false,
g_ShowPifRamErrors = false, g_GenerateLog = false, g_DelaySI = false, g_SPHack = false,
g_ShowPifRamErrors = false, g_GenerateLog = false, g_DelaySI = false,
g_DisableRegCaching = false, g_ShowCompMem = false, g_UseLinking = false,
g_FixedAudio = false, g_LogX86Code = false;
DWORD g_RomFileSize = 0, g_CountPerOp = 2, g_ViRefreshRate = 1500;
@ -120,9 +120,7 @@ void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble );
//Memory
DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize;
BYTE *g_RDRAM, *g_DMEM, *g_IMEM, *g_Rom;
OPCODE g_Opcode;
BOOL g_IndvidualBlock, g_Profiling;
DWORD g_CurrentFrame;
QWORD g_Frequency, g_Frames[NoOfFrames], g_LastFrame;
@ -194,7 +192,6 @@ void CC_Core::SetSettings ( )
g_CountPerOp = _Settings->LoadDword(Game_CounterFactor);
g_GenerateLog = _Settings->LoadDword(Debugger_GenerateDebugLog);
g_DelaySI = _Settings->LoadBool(Game_DelaySI);
g_SPHack = _Settings->LoadBool(Game_SPHack);
g_FixedAudio = _Settings->LoadBool(Game_FixedAudio);
g_LogX86Code = _Settings->LoadBool(Debugger_GenerateLogFiles);
g_LookUpMode = (FUNC_LOOKUP_METHOD)_Settings->LoadDword(Game_FuncLookupMode);
@ -326,11 +323,6 @@ void CC_Core::SetCurrentSystem (CN64System * System )
// AiUpdate = _Plugins->Audio()->Update;
// InitiateAudio = _Plugins->Audio()->InitiateAudio;
#endif
g_RDRAM = _MMU->Rdram();
g_DMEM = _MMU->Dmem();
g_IMEM = _MMU->Imem();
g_Rom = _Rom->GetRomAddress();
g_TLB_ReadMap = NULL; //System->m_TLB.TLB_ReadMap;
g_TLB_WriteMap = NULL; //System->m_TLB.TLB_WriteMap;
#ifdef tofix
@ -500,7 +492,8 @@ void RefreshScreen( void )
void ExecuteCycles(DWORD Cycles)
{
ExecuteInterpreterOps(Cycles);
_Notify->BreakPoint(__FILE__,__LINE__);
//ExecuteInterpreterOps(Cycles);
}
void SyncSystem (void)

View File

@ -66,6 +66,7 @@ void ChangeFullScreenFunc ( void );
BOOL Close_C_CPU ( void );
void StopEmulation ( void );
void __stdcall UpdateSyncCPU ( DWORD const Cycles );
void StartInterpreterCPU ( void );
void ExecuteCycles ( DWORD Cycles );
void SyncSystem ( void );
BOOL Machine_LoadState ( void );
@ -112,7 +113,7 @@ extern int * g_Timer;
//settings
extern BOOL g_ShowUnhandledMemory, g_ShowCPUPer, g_ShowTLBMisses, g_UseTlb,
g_HaveDebugger, g_AudioSignal, g_ShowDListAListCount, g_ShowPifRamErrors,
g_GenerateLog, g_DelaySI, g_SPHack, g_DisableRegCaching, g_ShowCompMem,
g_GenerateLog, g_DelaySI, g_DisableRegCaching, g_ShowCompMem,
g_UseLinking, g_FixedAudio, g_LogX86Code;
extern DWORD g_RomFileSize, g_CountPerOp;
extern enum CPU_TYPE g_CPU_Type;
@ -128,7 +129,6 @@ extern enum SystemType g_SystemType;
//Memory
extern DWORD * g_TLB_ReadMap, * g_TLB_WriteMap, g_RdramSize, g_SystemRdramSize;
extern BYTE *g_RDRAM, *g_DMEM, *g_IMEM;
//Misc
enum { NoOfFrames = 7 };

View File

@ -1,5 +1,4 @@
#define CPU_Type g_CPU_Type
#define Opcode g_Opcode
#define CPU_Action (*g_CPU_Action)
#define IndvidualBlock g_IndvidualBlock
#define Profiling g_Profiling
@ -40,7 +39,6 @@
#define ShowPifRamErrors g_ShowPifRamErrors
#define CountPerOp g_CountPerOp
#define DelaySI g_DelaySI
#define SPHack g_SPHack
#define DisableRegCaching g_DisableRegCaching
#define ShowCompMem g_ShowCompMem
#define UseLinking g_UseLinking
@ -52,9 +50,6 @@
//Misc
#define AppName GetAppName()
#define RDRAM g_RDRAM
#define DMEM g_DMEM
#define IMEM g_IMEM
#define TLB_WriteMap g_TLB_WriteMap
#define TLB_ReadMap g_TLB_ReadMap
#define RdramSize g_RdramSize

View File

@ -34,7 +34,7 @@
#include "debugger.h"
void ** JumpTable, ** DelaySlotTable;
BYTE *RecompCode, *RecompPos;
BYTE *RecompPos;
BOOL WrittenToRom;
DWORD WroteToRom;

View File

@ -25,14 +25,14 @@
*/
#ifdef toremove
extern void ** JumpTable;
extern BYTE *RecompCode, *RecompPos;
extern BYTE *RecompPos;
#include <Windows.h>
#define ROM_IN_MAPSPACE
extern void ** JumpTable;
extern BYTE *RecompCode, *RecompPos;
extern BYTE *RecompPos;
extern BOOL WrittenToRom;
/* Memory Control */
@ -71,9 +71,9 @@ void Compile_SW_Const ( DWORD Value, DWORD Addr );
#ifdef __cplusplus
void Compile_LW ( CBlockSection * Section, int Reg, DWORD Addr );
void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Addr );
void ResetMemoryStack ( CBlockSection * Section );
void Compile_LW ( CCodeSection * Section, int Reg, DWORD Addr );
void Compile_SW_Register ( CCodeSection * Section, int x86Reg, DWORD Addr );
void ResetMemoryStack ( CCodeSection * Section );
#endif
#endif

View File

@ -1,7 +1,6 @@
#include "main.h"
#include "CPU.h"
#include "debugger.h"
#include "Interpreter Ops 32.h"
//int NextInstruction, ManualPaused;
//int DlistCount, AlistCount;
@ -9,14 +8,14 @@
//DWORD MemoryStack;
DWORD JumpToLocation;
extern R4300iOp_FUNC * R4300i_Opcode;
R4300iOp_FUNC * R4300i_Opcode;
void InitializeCPUCore ( void )
{
LARGE_INTEGER PerformanceFrequency;
R4300i_Opcode = R4300iOp::BuildInterpreter();
//R4300i_Opcode = R4300iOp32::BuildInterpreter();
//R4300i_Opcode = R4300iOp::BuildInterpreter();
R4300i_Opcode = R4300iOp32::BuildInterpreter();
CurrentFrame = 0;
QueryPerformanceFrequency(&PerformanceFrequency);
@ -326,7 +325,7 @@ int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
break;
default:
if ( (Command.rs & 0x10 ) != 0 ) {
switch( Opcode.funct ) {
switch( Command.funct ) {
case R4300i_COP0_CO_TLBR: break;
case R4300i_COP0_CO_TLBWI: break;
case R4300i_COP0_CO_TLBWR: break;

View File

@ -6,7 +6,6 @@
#include "..\\Types.h"
#include "Interpreter CPU.h"
#include "Interpreter Ops.h"
#include "Recompiler CPU.h"
#include "c memory.h"
#include "Registers.h"

View File

@ -1,4 +1,3 @@
#include "..\\Types.h"
extern OPCODE g_Opcode;
extern BOOL g_IndvidualBlock, g_Profiling;

View File

@ -31,11 +31,11 @@
void OnFirstDMA (void) {
switch (CicChip) {
case 1: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 2: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 3: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 5: *(DWORD *)&RDRAM[0x3F0] = RdramSize; break;
case 6: *(DWORD *)&RDRAM[0x318] = RdramSize; break;
case 1: *(DWORD *)&((_MMU->Rdram())[0x318]) = RdramSize; break;
case 2: *(DWORD *)&((_MMU->Rdram())[0x318]) = RdramSize; break;
case 3: *(DWORD *)&((_MMU->Rdram())[0x318]) = RdramSize; break;
case 5: *(DWORD *)&((_MMU->Rdram())[0x3F0]) = RdramSize; break;
case 6: *(DWORD *)&((_MMU->Rdram())[0x318]) = RdramSize; break;
default: DisplayError("Unhandled CicChip(%d) in first DMA",CicChip);
}
}
@ -57,7 +57,7 @@ void PI_DMA_READ (void) {
if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; }
if (SaveUsing == SaveChip_Sram) {
DmaToSram(
RDRAM+_Reg->PI_DRAM_ADDR_REG,
_MMU->Rdram() + _Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000,
_Reg->PI_RD_LEN_REG + 1
);
@ -68,7 +68,7 @@ void PI_DMA_READ (void) {
}
if (SaveUsing == SaveChip_FlashRam) {
DmaToFlashram(
RDRAM+_Reg->PI_DRAM_ADDR_REG,
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000,
_Reg->PI_WR_LEN_REG + 1
);
@ -112,7 +112,7 @@ void PI_DMA_WRITE (void) {
if (SaveUsing == SaveChip_Auto) { SaveUsing = SaveChip_Sram; }
if (SaveUsing == SaveChip_Sram) {
DmaFromSram(
RDRAM+_Reg->PI_DRAM_ADDR_REG,
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000,
_Reg->PI_WR_LEN_REG + 1
);
@ -123,7 +123,7 @@ void PI_DMA_WRITE (void) {
}
if (SaveUsing == SaveChip_FlashRam) {
DmaFromFlashram(
RDRAM+_Reg->PI_DRAM_ADDR_REG,
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000,
_Reg->PI_WR_LEN_REG + 1
);
@ -144,7 +144,8 @@ void PI_DMA_WRITE (void) {
}
#endif
#endif
BYTE * ROM = _Rom->GetRomAddress();
BYTE * ROM = _Rom->GetRomAddress();
BYTE * RDRAM = _MMU->Rdram();
_Reg->PI_CART_ADDR_REG -= 0x10000000;
if (_Reg->PI_CART_ADDR_REG + _Reg->PI_WR_LEN_REG + 1 < RomFileSize) {
for (i = 0; i < _Reg->PI_WR_LEN_REG + 1; i ++) {
@ -188,6 +189,7 @@ void PI_DMA_WRITE (void) {
void SI_DMA_READ (void) {
BYTE * PIF_Ram = _MMU->PifRam();
BYTE * PifRamPos = _MMU->PifRam();
BYTE * RDRAM = _MMU->Rdram();
if ((int)_Reg->SI_DRAM_ADDR_REG > (int)RdramSize) {
#ifndef EXTERNAL_RELEASE
@ -286,6 +288,8 @@ void SI_DMA_WRITE (void) {
}
_Reg->SI_DRAM_ADDR_REG &= 0xFFFFFFF8;
BYTE * RDRAM = _MMU->Rdram();
if ((int)_Reg->SI_DRAM_ADDR_REG < 0) {
int count, RdramPos;
@ -388,7 +392,7 @@ void SP_DMA_READ (void) {
if ((_Reg->SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
if (((_Reg->SP_RD_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
memcpy( DMEM + (_Reg->SP_MEM_ADDR_REG & 0x1FFF), RDRAM + _Reg->SP_DRAM_ADDR_REG,
memcpy( _MMU->Dmem() + (_Reg->SP_MEM_ADDR_REG & 0x1FFF), _MMU->Rdram() + _Reg->SP_DRAM_ADDR_REG,
_Reg->SP_RD_LEN_REG + 1 );
_Reg->SP_DMA_BUSY_REG = 0;
@ -414,7 +418,7 @@ void SP_DMA_WRITE (void) {
if ((_Reg->SP_DRAM_ADDR_REG & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
if (((_Reg->SP_WR_LEN_REG + 1) & 3) != 0) { BreakPoint(__FILE__,__LINE__); }
memcpy( RDRAM + _Reg->SP_DRAM_ADDR_REG, DMEM + (_Reg->SP_MEM_ADDR_REG & 0x1FFF),
memcpy( _MMU->Rdram() + _Reg->SP_DRAM_ADDR_REG, _MMU->Dmem() + (_Reg->SP_MEM_ADDR_REG & 0x1FFF),
_Reg->SP_WR_LEN_REG + 1);
_Reg->SP_DMA_BUSY_REG = 0;

View File

@ -106,7 +106,7 @@ void DmaFromFlashram(BYTE * dest, int StartOffset, int len) {
break;
#ifndef EXTERNAL_RELEASE
default:
DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - RDRAM,StartOffset,len);
DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - _MMU->Rdram(),StartOffset,len);
#endif
}
}
@ -118,7 +118,7 @@ void DmaToFlashram(BYTE * Source, int StartOffset, int len) {
break;
#ifndef EXTERNAL_RELEASE
default:
DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - RDRAM,StartOffset,len);
DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - _MMU->Rdram(),StartOffset,len);
#endif
}
}

View File

@ -109,16 +109,6 @@ BOOL ExecuteInterpreterOpCode (void)
}
return TRUE;
}
void StartInterpreterCPU (void ) {
//DWORD Value, Value2, Addr = 0x80031000;
CoInitialize(NULL);
TestTimer = FALSE;
NextInstruction = NORMAL;
//Add_R4300iBPoint(0x802000C8,FALSE);
ExecuteInterpreterOps(-1);
}
void ExecuteInterpreterOps (DWORD Cycles)
{

View File

@ -30,6 +30,7 @@ extern "C" {
BOOL ExecuteInterpreterOpCode ( void );
void StartInterpreterCPU ( void );
void TestInterpreterJump ( DWORD PC, DWORD TargetPC, int Reg1, int Reg2 );
void ExecuteInterpreterCPU ( void );
void ExecuteInterpreterOps ( DWORD Cycles );
#ifdef __cplusplus

View File

@ -166,9 +166,9 @@ R4300iOp_FUNC * R4300iOp32::BuildInterpreter (void )
Jump_Special[13] = UnknownOpcode;
Jump_Special[14] = UnknownOpcode;
Jump_Special[15] = SPECIAL_SYNC;
Jump_Special[16] = SPECIAL_MFHI;
Jump_Special[16] = R4300iOp::SPECIAL_MFHI;
Jump_Special[17] = SPECIAL_MTHI;
Jump_Special[18] = SPECIAL_MFLO;
Jump_Special[18] = R4300iOp::SPECIAL_MFLO;
Jump_Special[19] = SPECIAL_MTLO;
Jump_Special[20] = R4300iOp::SPECIAL_DSLLV;
Jump_Special[21] = UnknownOpcode;
@ -1204,18 +1204,10 @@ void _fastcall R4300iOp32::SPECIAL_BREAK (void) {
void _fastcall R4300iOp32::SPECIAL_SYNC (void) {
}
void _fastcall R4300iOp32::SPECIAL_MFHI (void) {
_GPR[Opcode.rd].W[0] = _RegHI->W[0];
}
void _fastcall R4300iOp32::SPECIAL_MTHI (void) {
_RegHI->W[0] = _GPR[Opcode.rs].W[0];
}
void _fastcall R4300iOp32::SPECIAL_MFLO (void) {
_GPR[Opcode.rd].W[0] = _RegLO->W[0];
}
void _fastcall R4300iOp32::SPECIAL_MTLO (void) {
_RegLO->W[0] = _GPR[Opcode.rs].W[0];
}

View File

@ -53,9 +53,7 @@ public:
static void _fastcall SPECIAL_SYSCALL ( void );
static void _fastcall SPECIAL_BREAK ( void );
static void _fastcall SPECIAL_SYNC ( void );
static void _fastcall SPECIAL_MFHI ( void );
static void _fastcall SPECIAL_MTHI ( void );
static void _fastcall SPECIAL_MFLO ( void );
static void _fastcall SPECIAL_MTLO ( void );
static void _fastcall SPECIAL_ADD ( void );
static void _fastcall SPECIAL_ADDU ( void );

View File

@ -950,9 +950,6 @@ void _fastcall R4300iOp::LH (void) {
}
}
DWORD LWL_MASK[4] = { 0,0xFF,0xFFFF,0xFFFFFF };
int LWL_SHIFT[4] = { 0, 8, 16, 24};
void _fastcall R4300iOp::LWL (void) {
DWORD Offset, Address, Value;
@ -1033,9 +1030,6 @@ void _fastcall R4300iOp::LHU (void) {
}
}
DWORD LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000, 0xFF000000, 0 };
int LWR_SHIFT[4] = { 24, 16 ,8, 0 };
void _fastcall R4300iOp::LWR (void) {
DWORD Offset, Address, Value;
@ -1087,9 +1081,6 @@ void _fastcall R4300iOp::SH (void) {
}
}
DWORD SWL_MASK[4] = { 0,0xFF000000,0xFFFF0000,0xFFFFFF00 };
int SWL_SHIFT[4] = { 0, 8, 16, 24 };
void _fastcall R4300iOp::SWL (void) {
DWORD Offset, Address, Value;
@ -1214,9 +1205,6 @@ void _fastcall R4300iOp::SDR (void) {
}
}
DWORD SWR_MASK[4] = { 0x00FFFFFF,0x0000FFFF,0x000000FF,0x00000000 };
int SWR_SHIFT[4] = { 24, 16 , 8, 0 };
void _fastcall R4300iOp::SWR (void) {
DWORD Offset, Address, Value;

View File

@ -24,8 +24,6 @@
*
*/
typedef void (_fastcall * R4300iOp_FUNC )();
class R4300iOp
{
public:

View File

@ -218,8 +218,8 @@ typedef struct {
#ifdef __cplusplus
//void CompileSystemCheck ( DWORD TargetPC, CRegInfo RegSet );
//void FreeSection ( CBlockSection * Section, CBlockSection * Parent);
void GenerateSectionLinkage ( CBlockSection * Section );
//void FreeSection ( CCodeSection * Section, CCodeSection * Parent);
void GenerateSectionLinkage ( CCodeSection * Section );
extern "C" {
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,179 +23,4 @@
* should be forwarded to them so if they want them.
*
*/
enum BRANCH_TYPE
{
BranchTypeCop1, BranchTypeRs, BranchTypeRsRt
};
void CompileReadTLBMiss (CBlockSection * Section, int AddressReg, int LookUpReg );
void CompileWriteTLBMiss (CBlockSection * Section, int AddressReg, int LookUpReg );
/************************** Branch functions ************************/
void Compile_R4300i_Branch ( CBlockSection * Section, void (*CompareFunc)(CBlockSection * Section), BRANCH_TYPE BranchType, BOOL Link);
void Compile_R4300i_BranchLikely ( CBlockSection * Section, void (*CompareFunc)(CBlockSection * Section), BOOL Link);
void BNE_Compare ( CBlockSection * Section );
void BEQ_Compare ( CBlockSection * Section );
void BGTZ_Compare ( CBlockSection * Section );
void BLEZ_Compare ( CBlockSection * Section );
void BLTZ_Compare ( CBlockSection * Section );
void BGEZ_Compare ( CBlockSection * Section );
void COP1_BCF_Compare ( CBlockSection * Section );
void COP1_BCT_Compare ( CBlockSection * Section );
/************************* OpCode functions *************************/
void Compile_R4300i_J ( CBlockSection * Section );
void Compile_R4300i_JAL ( CBlockSection * Section );
void Compile_R4300i_ADDI ( CBlockSection * Section );
void Compile_R4300i_ADDIU ( CBlockSection * Section );
void Compile_R4300i_SLTI ( CBlockSection * Section );
void Compile_R4300i_SLTIU ( CBlockSection * Section );
void Compile_R4300i_ANDI ( CBlockSection * Section );
void Compile_R4300i_ORI ( CBlockSection * Section );
void Compile_R4300i_XORI ( CBlockSection * Section );
void Compile_R4300i_LUI ( CBlockSection * Section );
void Compile_R4300i_DADDIU ( CBlockSection * Section );
void Compile_R4300i_LDL ( CBlockSection * Section );
void Compile_R4300i_LDR ( CBlockSection * Section );
void Compile_R4300i_LB ( CBlockSection * Section );
void Compile_R4300i_LH ( CBlockSection * Section );
void Compile_R4300i_LWL ( CBlockSection * Section );
void Compile_R4300i_LW ( CBlockSection * Section );
void Compile_R4300i_LBU ( CBlockSection * Section );
void Compile_R4300i_LHU ( CBlockSection * Section );
void Compile_R4300i_LWR ( CBlockSection * Section );
void Compile_R4300i_LWU ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_SB ( CBlockSection * Section );
void Compile_R4300i_SH ( CBlockSection * Section );
void Compile_R4300i_SWL ( CBlockSection * Section );
void Compile_R4300i_SW ( CBlockSection * Section );
void Compile_R4300i_SWR ( CBlockSection * Section );
void Compile_R4300i_SDL ( CBlockSection * Section );
void Compile_R4300i_SDR ( CBlockSection * Section );
void Compile_R4300i_CACHE ( CBlockSection * Section );
void Compile_R4300i_LL ( CBlockSection * Section );
void Compile_R4300i_LWC1 ( CBlockSection * Section );
void Compile_R4300i_LDC1 ( CBlockSection * Section );
void Compile_R4300i_LD ( CBlockSection * Section );
void Compile_R4300i_SC ( CBlockSection * Section );
void Compile_R4300i_SWC1 ( CBlockSection * Section );
void Compile_R4300i_SDC1 ( CBlockSection * Section );
void Compile_R4300i_SD ( CBlockSection * Section );
/********************** R4300i OpCodes: Special **********************/
void Compile_R4300i_SPECIAL_SLL ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SRL ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SRA ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SLLV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SRLV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SRAV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_JR ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_JALR ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SYSCALL( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MFLO ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MTLO ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MFHI ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MTHI ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSLLV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRLV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRAV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MULT ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_MULTU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DIV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DIVU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DMULT ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DMULTU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DDIV ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DDIVU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_ADD ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_ADDU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SUB ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SUBU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_AND ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_OR ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_XOR ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_NOR ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SLT ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_SLTU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DADD ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DADDU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSUB ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSUBU ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSLL ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRL ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRA ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSLL32 ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRL32 ( CBlockSection * Section );
void Compile_R4300i_SPECIAL_DSRA32 ( CBlockSection * Section );
/************************** COP0 functions **************************/
void Compile_R4300i_COP0_MF ( CBlockSection * Section );
void Compile_R4300i_COP0_MT ( CBlockSection * Section );
/************************** COP0 CO functions ***********************/
void Compile_R4300i_COP0_CO_TLBR ( CBlockSection * Section );
void Compile_R4300i_COP0_CO_TLBWI ( CBlockSection * Section );
void Compile_R4300i_COP0_CO_TLBWR ( CBlockSection * Section );
void Compile_R4300i_COP0_CO_TLBP ( CBlockSection * Section );
void Compile_R4300i_COP0_CO_ERET ( CBlockSection * Section );
/************************** COP1 functions **************************/
void Compile_R4300i_COP1_MF ( CBlockSection * Section );
void Compile_R4300i_COP1_DMF ( CBlockSection * Section );
void Compile_R4300i_COP1_CF ( CBlockSection * Section );
void Compile_R4300i_COP1_MT ( CBlockSection * Section );
void Compile_R4300i_COP1_DMT ( CBlockSection * Section );
void Compile_R4300i_COP1_CT ( CBlockSection * Section );
/************************** COP1: S functions ************************/
void Compile_R4300i_COP1_S_ADD ( CBlockSection * Section );
void Compile_R4300i_COP1_S_SUB ( CBlockSection * Section );
void Compile_R4300i_COP1_S_MUL ( CBlockSection * Section );
void Compile_R4300i_COP1_S_DIV ( CBlockSection * Section );
void Compile_R4300i_COP1_S_ABS ( CBlockSection * Section );
void Compile_R4300i_COP1_S_NEG ( CBlockSection * Section );
void Compile_R4300i_COP1_S_SQRT ( CBlockSection * Section );
void Compile_R4300i_COP1_S_MOV ( CBlockSection * Section );
void Compile_R4300i_COP1_S_TRUNC_L ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CEIL_L ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_S_FLOOR_L ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_S_ROUND_W ( CBlockSection * Section );
void Compile_R4300i_COP1_S_TRUNC_W ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CEIL_W ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_S_FLOOR_W ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CVT_D ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CVT_W ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CVT_L ( CBlockSection * Section );
void Compile_R4300i_COP1_S_CMP ( CBlockSection * Section );
/************************** COP1: D functions ************************/
void Compile_R4300i_COP1_D_ADD ( CBlockSection * Section );
void Compile_R4300i_COP1_D_SUB ( CBlockSection * Section );
void Compile_R4300i_COP1_D_MUL ( CBlockSection * Section );
void Compile_R4300i_COP1_D_DIV ( CBlockSection * Section );
void Compile_R4300i_COP1_D_ABS ( CBlockSection * Section );
void Compile_R4300i_COP1_D_NEG ( CBlockSection * Section );
void Compile_R4300i_COP1_D_SQRT ( CBlockSection * Section );
void Compile_R4300i_COP1_D_MOV ( CBlockSection * Section );
void Compile_R4300i_COP1_D_TRUNC_L ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_D_CEIL_L ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_D_FLOOR_L ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_D_ROUND_W ( CBlockSection * Section );
void Compile_R4300i_COP1_D_TRUNC_W ( CBlockSection * Section );
void Compile_R4300i_COP1_D_CEIL_W ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_D_FLOOR_W ( CBlockSection * Section ); //added by Witten
void Compile_R4300i_COP1_D_CVT_S ( CBlockSection * Section );
void Compile_R4300i_COP1_D_CVT_W ( CBlockSection * Section );
void Compile_R4300i_COP1_D_CVT_L ( CBlockSection * Section );
void Compile_R4300i_COP1_D_CMP ( CBlockSection * Section );
/************************** COP1: W functions ************************/
void Compile_R4300i_COP1_W_CVT_S ( CBlockSection * Section );
void Compile_R4300i_COP1_W_CVT_D ( CBlockSection * Section );
/************************** COP1: L functions ************************/
void Compile_R4300i_COP1_L_CVT_S ( CBlockSection * Section );
void Compile_R4300i_COP1_L_CVT_D ( CBlockSection * Section );
/************************** Other functions **************************/
void Compile_R4300i_UnknownOpcode ( CBlockSection * Section );

View File

@ -78,13 +78,13 @@ DWORD RegModValue;
int fpuControl;
int UnMap_8BitTempReg (CBlockSection * Section);
int UnMap_TempReg (CBlockSection * Section);
BOOL UnMap_X86reg (CBlockSection * Section, DWORD x86Reg);
int UnMap_8BitTempReg (CCodeSection * Section);
int UnMap_TempReg (CCodeSection * Section);
BOOL UnMap_X86reg (CCodeSection * Section, DWORD x86Reg);
char *Format_Name[] = {"Unkown","dword","qword","float","double"};
void ChangeFPURegFormat (CBlockSection * Section, int Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel) {
void ChangeFPURegFormat (CCodeSection * Section, int Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel) {
DWORD i;
for (i = 0; i < 8; i++) {
@ -179,7 +179,7 @@ void ChangeSpStatus (void) {
//}
}
int Free8BitX86Reg (CBlockSection * Section) {
int Free8BitX86Reg (CCodeSection * Section) {
int x86Reg, count, MapCount[10], MapReg[10];
if (Section->x86Mapped(x86_EBX) == CRegInfo::NotMapped && !Section->x86Protected(x86_EBX)) {return x86_EBX; }
@ -223,7 +223,7 @@ int Free8BitX86Reg (CBlockSection * Section) {
return -1;
}
int FreeX86Reg (CBlockSection * Section) {
int FreeX86Reg (CCodeSection * Section) {
int x86Reg, count, MapCount[10], MapReg[10], StackReg;
if (Section->x86Mapped(x86_EDI) == CRegInfo::NotMapped && !Section->x86Protected(x86_EDI)) {return x86_EDI; }
@ -503,7 +503,7 @@ BOOL Is8BitReg (int x86Reg) {
return FALSE;
}
void Load_FPR_ToTop (CBlockSection * Section, int Reg, int RegToLoad, CRegInfo::FPU_STATE Format) {
void Load_FPR_ToTop (CCodeSection * Section, int Reg, int RegToLoad, CRegInfo::FPU_STATE Format) {
int i;
if (RegToLoad < 0) { DisplayError("Load_FPR_ToTop\nRegToLoad < 0 ???"); return; }
@ -637,7 +637,7 @@ void Load_FPR_ToTop (CBlockSection * Section, int Reg, int RegToLoad, CRegInfo::
Section->CurrentRoundingModel(),Section->FpuRoundingModel(Section->StackTopPos()));
}
void Map_GPR_32bit (CBlockSection * Section, int Reg, BOOL SignValue, int MipsRegToLoad) {
void Map_GPR_32bit (CCodeSection * Section, int Reg, BOOL SignValue, int MipsRegToLoad) {
int x86Reg,count;
if (Reg == 0) {
@ -697,7 +697,7 @@ void Map_GPR_32bit (CBlockSection * Section, int Reg, BOOL SignValue, int MipsRe
Section->MipsRegState(Reg) = SignValue ? CRegInfo::STATE_MAPPED_32_SIGN : CRegInfo::STATE_MAPPED_32_ZERO;
}
void Map_GPR_64bit (CBlockSection * Section, int Reg, int MipsRegToLoad) {
void Map_GPR_64bit (CCodeSection * Section, int Reg, int MipsRegToLoad) {
int x86Hi, x86lo, count;
if (Reg == 0) {
@ -794,7 +794,7 @@ CPU_Message("Map_GPR_64bit 11");
Section->MipsRegState(Reg) = CRegInfo::STATE_MAPPED_64;
}
int Map_MemoryStack (CBlockSection * Section, int Reg, bool MapRegister)
int Map_MemoryStack (CCodeSection * Section, int Reg, bool MapRegister)
{
int CurrentMap = -1;
@ -854,7 +854,7 @@ int Map_MemoryStack (CBlockSection * Section, int Reg, bool MapRegister)
return Reg;
}
int Map_TempReg (CBlockSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWord) {
int Map_TempReg (CCodeSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWord) {
int count;
if (x86Reg == x86_Any) {
@ -998,7 +998,7 @@ int Map_TempReg (CBlockSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWo
return x86Reg;
}
void ProtectGPR(CBlockSection * Section, DWORD Reg) {
void ProtectGPR(CCodeSection * Section, DWORD Reg) {
if (Section->IsUnknown(Reg)) { return; }
if (Section->IsConst(Reg)) { return; }
if (Section->Is64Bit(Reg)) {
@ -1007,7 +1007,7 @@ void ProtectGPR(CBlockSection * Section, DWORD Reg) {
Section->x86Protected(Section->MipsRegLo(Reg)) = TRUE;
}
BOOL RegInStack(CBlockSection * Section,int Reg, int Format) {
BOOL RegInStack(CCodeSection * Section,int Reg, int Format) {
int i;
for (i = 0; i < 8; i++) {
@ -1062,7 +1062,7 @@ void SetupRegisters(N64_REGISTERS * n64_Registers) {
}
#endif
int StackPosition (CBlockSection * Section,int Reg) {
int StackPosition (CCodeSection * Section,int Reg) {
int i;
for (i = 0; i < 8; i++) {
@ -1073,7 +1073,7 @@ int StackPosition (CBlockSection * Section,int Reg) {
return -1;
}
int UnMap_8BitTempReg (CBlockSection * Section) {
int UnMap_8BitTempReg (CCodeSection * Section) {
int count;
for (count = 0; count < 10; count ++) {
@ -1089,7 +1089,7 @@ int UnMap_8BitTempReg (CBlockSection * Section) {
return -1;
}
void UnMap_AllFPRs ( CBlockSection * Section ) {
void UnMap_AllFPRs ( CCodeSection * Section ) {
DWORD StackPos;
for (;;) {
@ -1109,7 +1109,7 @@ void UnMap_AllFPRs ( CBlockSection * Section ) {
}
}
void FixRoundModel(CBlockSection * Section, CRegInfo::FPU_ROUND RoundMethod )
void FixRoundModel(CCodeSection * Section, CRegInfo::FPU_ROUND RoundMethod )
{
if (Section->CurrentRoundingModel() == RoundMethod)
{
@ -1136,7 +1136,7 @@ void FixRoundModel(CBlockSection * Section, CRegInfo::FPU_ROUND RoundMethod )
Section->CurrentRoundingModel() = RoundMethod;
}
void UnMap_FPR (CBlockSection * Section, int Reg, int WriteBackValue ) {
void UnMap_FPR (CCodeSection * Section, int Reg, int WriteBackValue ) {
char Name[50];
int TempReg;
int i;
@ -1208,7 +1208,7 @@ void UnMap_FPR (CBlockSection * Section, int Reg, int WriteBackValue ) {
}
}
void UnMap_GPR (CBlockSection * Section, DWORD Reg, int WriteBackValue) {
void UnMap_GPR (CCodeSection * Section, DWORD Reg, int WriteBackValue) {
if (Reg == 0) {
#ifndef EXTERNAL_RELEASE
DisplayError("UnMap_GPR\n\nWhy are you trying to unmap reg 0");
@ -1264,7 +1264,7 @@ void UnMap_GPR (CBlockSection * Section, DWORD Reg, int WriteBackValue) {
Section->MipsRegState(Reg) = CRegInfo::STATE_UNKNOWN;
}
int UnMap_TempReg (CBlockSection * Section) {
int UnMap_TempReg (CCodeSection * Section) {
int count;
for (count = 0; count < 10; count ++) {
@ -1279,7 +1279,7 @@ int UnMap_TempReg (CBlockSection * Section) {
return -1;
}
BOOL UnMap_X86reg (CBlockSection * Section, DWORD x86Reg) {
BOOL UnMap_X86reg (CCodeSection * Section, DWORD x86Reg) {
int count;
if (Section->x86Mapped(x86Reg) == CRegInfo::NotMapped && Section->x86Protected(x86Reg) == FALSE) { return TRUE; }
@ -1323,7 +1323,7 @@ BOOL UnMap_X86reg (CBlockSection * Section, DWORD x86Reg) {
return FALSE;
}
void UnProtectGPR(CBlockSection * Section, DWORD Reg) {
void UnProtectGPR(CCodeSection * Section, DWORD Reg) {
if (Section->IsUnknown(Reg)) { return; }
if (Section->IsConst(Reg)) { return; }
if (Section->Is64Bit(Reg)) {
@ -1332,7 +1332,7 @@ void UnProtectGPR(CBlockSection * Section, DWORD Reg) {
Section->x86Protected(Section->MipsRegLo(Reg)) = FALSE;
}
/*void WriteBackRegisters (CBlockSection * Section) {
/*void WriteBackRegisters (CCodeSection * Section) {
int count;
for (count = 1; count < 10; count ++) { Section->x86Protected(count) = FALSE; }
@ -1355,7 +1355,7 @@ void UnProtectGPR(CBlockSection * Section, DWORD Reg) {
}
UnMap_AllFPRs(Section);
}*/
void WriteBackRegisters (CBlockSection * Section) {
void WriteBackRegisters (CCodeSection * Section) {
int count;
BOOL bEdiZero = FALSE;
BOOL bEsiSign = FALSE;

View File

@ -229,19 +229,19 @@ void SetupRegisters ( N64_REGISTERS * n64_Registers );
#endif
BOOL Is8BitReg ( int x86Reg);
void ChangeFPURegFormat ( CBlockSection * Section, int Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel );
void Load_FPR_ToTop ( CBlockSection * Section, int Reg, int RegToLoad, CRegInfo::FPU_STATE Format);
void Map_GPR_32bit ( CBlockSection * Section, int Reg, BOOL SignValue, int MipsRegToLoad );
void Map_GPR_64bit ( CBlockSection * Section, int Reg, int MipsRegToLoad );
int Map_MemoryStack ( CBlockSection * Section, int Reg, bool MapRegister );
int Map_TempReg ( CBlockSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWord );
BOOL RegInStack ( CBlockSection * Section, int Reg, int Format );
void ProtectGPR ( CBlockSection * Section, DWORD Reg );
int StackPosition ( CBlockSection * Section, int Reg );
void UnMap_AllFPRs ( CBlockSection * Section );
void UnMap_FPR ( CBlockSection * Section, int Reg, int WriteBackValue );
void UnMap_GPR ( CBlockSection * Section, DWORD Reg, int WriteBackValue );
BOOL UnMap_X86reg ( CBlockSection * Section, DWORD x86Reg );
void UnProtectGPR ( CBlockSection * Section, DWORD Reg );
void WriteBackRegisters ( CBlockSection * Section );
void FixRoundModel ( CBlockSection * Section, CRegInfo::FPU_ROUND RoundMethod );
void ChangeFPURegFormat ( CCodeSection * Section, int Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel );
void Load_FPR_ToTop ( CCodeSection * Section, int Reg, int RegToLoad, CRegInfo::FPU_STATE Format);
void Map_GPR_32bit ( CCodeSection * Section, int Reg, BOOL SignValue, int MipsRegToLoad );
void Map_GPR_64bit ( CCodeSection * Section, int Reg, int MipsRegToLoad );
int Map_MemoryStack ( CCodeSection * Section, int Reg, bool MapRegister );
int Map_TempReg ( CCodeSection * Section, int x86Reg, int MipsReg, BOOL LoadHiWord );
BOOL RegInStack ( CCodeSection * Section, int Reg, int Format );
void ProtectGPR ( CCodeSection * Section, DWORD Reg );
int StackPosition ( CCodeSection * Section, int Reg );
void UnMap_AllFPRs ( CCodeSection * Section );
void UnMap_FPR ( CCodeSection * Section, int Reg, int WriteBackValue );
void UnMap_GPR ( CCodeSection * Section, DWORD Reg, int WriteBackValue );
BOOL UnMap_X86reg ( CCodeSection * Section, DWORD x86Reg );
void UnProtectGPR ( CCodeSection * Section, DWORD Reg );
void WriteBackRegisters ( CCodeSection * Section );
void FixRoundModel ( CCodeSection * Section, CRegInfo::FPU_ROUND RoundMethod );

View File

@ -873,7 +873,7 @@ void MoveConstByteToN64Mem(BYTE Const, int AddrReg) {
default:
DisplayError("MoveConstByteToN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
PUTDST8(RecompPos,Const);
}
@ -899,7 +899,7 @@ void MoveConstHalfToN64Mem(WORD Const, int AddrReg) {
default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
PUTDST16(RecompPos,Const);
}
@ -978,7 +978,7 @@ void MoveConstToN64Mem(DWORD Const, int AddrReg) {
default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
PUTDST32(RecompPos,Const);
}
@ -996,7 +996,7 @@ void MoveConstToN64MemDisp (DWORD Const, int AddrReg, BYTE Disp) {
default:
DisplayError("MoveConstToN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM + Disp);
PUTDST32(RecompPos,_MMU->Rdram() + Disp);
PUTDST32(RecompPos,Const);
}
@ -1136,7 +1136,7 @@ void MoveN64MemDispToX86reg(int x86reg, int AddrReg, BYTE Disp) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM + Disp);
PUTDST32(RecompPos,_MMU->Rdram() + Disp);
}
void MoveN64MemToX86reg(int x86reg, int AddrReg) {
@ -1165,7 +1165,7 @@ void MoveN64MemToX86reg(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveN64MemToX86regByte(int x86reg, int AddrReg) {
@ -1195,7 +1195,7 @@ void MoveN64MemToX86regByte(int x86reg, int AddrReg) {
break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveN64MemToX86regHalf(int x86reg, int AddrReg) {
@ -1225,7 +1225,7 @@ void MoveN64MemToX86regHalf(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveSxByteX86regPointerToX86reg(int AddrReg1, int AddrReg2, int x86reg) {
@ -1347,7 +1347,7 @@ void MoveSxN64MemToX86regByte(int x86reg, int AddrReg) {
}
PUTDST8(RecompPos,0x0f);
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) {
@ -1378,7 +1378,7 @@ void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) {
PUTDST8(RecompPos, 0x0f);
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveSxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) {
@ -1525,7 +1525,7 @@ void MoveX86regByteToN64Mem(int x86reg, int AddrReg) {
case x86_EDX: x86Command += 0x9000; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveX86regByteToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -1611,7 +1611,7 @@ void MoveX86regHalfToN64Mem(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -1874,7 +1874,7 @@ void MoveX86regToN64Mem(int x86reg, int AddrReg) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) {
@ -1902,7 +1902,7 @@ void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) {
case x86_EBP: x86Command += 0xA800; break;
}
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM+Disp);
PUTDST32(RecompPos,_MMU->Rdram()+Disp);
}
void MoveX86regToVariable(int x86reg, void * Variable, const char * VariableName) {
@ -2119,7 +2119,7 @@ void MoveZxHalfX86regPointerToX86reg(int AddrReg1, int AddrReg2, int x86reg) {
void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) {
WORD x86Command;
CPU_Message(" movzx %s, byte ptr [%s+RDRAM]",x86_Name(x86reg),x86_Name(AddrReg));
CPU_Message(" movzx %s, byte ptr [%s+_MMU->Rdram()]",x86_Name(x86reg),x86_Name(AddrReg));
switch (AddrReg) {
case x86_EAX: x86Command = 0x00B6; break;
case x86_EBX: x86Command = 0x03B6; break;
@ -2145,13 +2145,13 @@ void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) {
}
PUTDST8(RecompPos,0x0f);
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) {
WORD x86Command;
CPU_Message(" movzx %s, word ptr [%s+RDRAM]",x86_Name(x86reg),x86_Name(AddrReg));
CPU_Message(" movzx %s, word ptr [%s+_MMU->Rdram()]",x86_Name(x86reg),x86_Name(AddrReg));
switch (AddrReg) {
case x86_EAX: x86Command = 0x00B7; break;
@ -2176,7 +2176,7 @@ void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) {
PUTDST8(RecompPos, 0x0f);
PUTDST16(RecompPos,x86Command);
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void MoveZxVariableToX86regByte(void *Variable, const char * VariableName, int x86reg) {

View File

@ -354,7 +354,7 @@ void fpuLoadDwordFromN64Mem(int * StackPos,int x86reg) {
default:
DisplayError("fpuLoadDwordFromN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void fpuLoadInt32bFromN64Mem(int * StackPos,int x86reg) {
@ -371,7 +371,7 @@ void fpuLoadInt32bFromN64Mem(int * StackPos,int x86reg) {
default:
DisplayError("fpuLoadIntDwordFromN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void fpuLoadIntegerDword(int * StackPos,void *Variable, const char * VariableName) {
@ -457,7 +457,7 @@ void fpuLoadQwordFromN64Mem(int * StackPos,int x86reg) {
default:
DisplayError("fpuLoadQwordFromN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void fpuLoadReg(int * StackPos,int Reg) {
@ -619,7 +619,7 @@ void fpuStoreDwordToN64Mem(int * StackPos,int x86reg, BOOL Pop) {
default:
DisplayError("fpuStoreDwordToN64Mem\nUnknown x86 Register");
}
PUTDST32(RecompPos,RDRAM);
PUTDST32(RecompPos,_MMU->Rdram());
}
void fpuStoreIntegerDword(int * StackPos,void *Variable, const char * VariableName, BOOL pop) {

View File

@ -0,0 +1,371 @@
#include "stdafx.h"
void ExecuteInterpreterOps (DWORD Cycles)
{
_Notify->BreakPoint(__FILE__,__LINE__);
}
void DoSomething ( void ) {
if (g_CPU_Action->CloseCPU) {
return;
}
if (g_CPU_Action->SoftReset)
{
g_CPU_Action->SoftReset = false;
_SystemTimer->SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
ShowCFB();
_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP4;
CheckInterrupts();
_Plugins->Gfx()->SoftReset();
}
if (g_CPU_Action->GenerateInterrupt)
{
g_CPU_Action->GenerateInterrupt = FALSE;
_Reg->MI_INTR_REG |= g_CPU_Action->InterruptFlag;
g_CPU_Action->InterruptFlag = 0;
CheckInterrupts();
}
if (g_CPU_Action->CheckInterrupts) {
g_CPU_Action->CheckInterrupts = FALSE;
CheckInterrupts();
}
if (g_CPU_Action->ProfileStartStop) {
g_CPU_Action->ProfileStartStop = FALSE;
ResetTimer();
}
if (g_CPU_Action->ProfileResetStats) {
g_CPU_Action->ProfileResetStats = FALSE;
ResetTimer();
}
if (g_CPU_Action->ProfileGenerateLogs) {
g_CPU_Action->ProfileGenerateLogs = FALSE;
GenerateProfileLog();
}
if (g_CPU_Action->DoInterrupt) {
g_CPU_Action->DoInterrupt = FALSE;
if (DoIntrException(FALSE) && !g_CPU_Action->InterruptExecuted)
{
g_CPU_Action->InterruptExecuted = TRUE;
ClearRecompCodeInitialCode();
}
}
if (g_CPU_Action->ChangeWindow) {
g_CPU_Action->ChangeWindow = FALSE;
ChangeFullScreenFunc();
}
if (g_CPU_Action->Pause) {
PauseExecution();
g_CPU_Action->Pause = FALSE;
}
if (g_CPU_Action->ChangePlugin) {
ChangePluginFunc();
g_CPU_Action->ChangePlugin = FALSE;
}
if (g_CPU_Action->GSButton) {
ApplyGSButtonCheats();
g_CPU_Action->GSButton = FALSE;
}
g_CPU_Action->DoSomething = FALSE;
if (g_CPU_Action->SaveState) {
//test if allowed
g_CPU_Action->SaveState = FALSE;
if (!Machine_SaveState()) {
g_CPU_Action->SaveState = TRUE;
g_CPU_Action->DoSomething = TRUE;
}
}
if (g_CPU_Action->RestoreState) {
g_CPU_Action->RestoreState = FALSE;
Machine_LoadState();
}
if (g_CPU_Action->DoInterrupt == TRUE) { g_CPU_Action->DoSomething = TRUE; }
}
int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) {
OPCODE Command;
if (!_MMU->LW_VAddr(PC + 4, Command.Hex)) {
//DisplayError("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) { return TRUE; }
if (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:
#ifndef EXTERNAL_RELEASE
DisplayError("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC);
#endif
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) { return TRUE; }
if (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:
#ifndef EXTERNAL_RELEASE
DisplayError("Does %s effect Delay slot at %X?\n6",R4300iOpcodeName(Command.Hex,PC+4), PC);
#endif
return TRUE;
}
} else {
#ifndef EXTERNAL_RELEASE
DisplayError("Does %s effect Delay slot at %X?\n7",R4300iOpcodeName(Command.Hex,PC+4), PC);
#endif
return TRUE;
}
}
break;
case R4300i_CP1:
switch (Command.fmt) {
case R4300i_COP1_MF:
if (Command.rt == 0) { return FALSE; }
if (Command.rt == Reg1) { return TRUE; }
if (Command.rt == Reg2) { return TRUE; }
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;
#ifndef EXTERNAL_RELEASE
default:
DisplayError("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC);
#endif
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) { return TRUE; }
if (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:
#ifndef EXTERNAL_RELEASE
DisplayError("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC);
#endif
return TRUE;
}
return FALSE;
}
void InPermLoop (void) {
// *** Changed ***/
if (g_CPU_Action->DoInterrupt)
{
g_CPU_Action->DoSomething = TRUE;
return;
}
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] +=5; }
/* Interrupts enabled */
if (( _Reg->STATUS_REGISTER & STATUS_IE ) == 0 ) { goto InterruptsDisabled; }
if (( _Reg->STATUS_REGISTER & STATUS_EXL ) != 0 ) { goto InterruptsDisabled; }
if (( _Reg->STATUS_REGISTER & STATUS_ERL ) != 0 ) { goto InterruptsDisabled; }
if (( _Reg->STATUS_REGISTER & 0xFF00) == 0) { goto InterruptsDisabled; }
/* check sound playing */
_N64System->SyncToAudio();
/* check RSP running */
/* check RDP running */
if (*_NextTimer > 0) {
//_Reg->COUNT_REGISTER += *_Timer + 1;
//if (CPU_Type == CPU_SyncCores) { SyncRegisters.CP0[9] += Timers.Timer + 1; }
*_NextTimer = -1;
}
return;
InterruptsDisabled:
if (UpdateScreen != NULL) { UpdateScreen(); }
//CurrentFrame = 0;
//CurrentPercent = 0;
//DisplayFPS();
DisplayError(GS(MSG_PERM_LOOP));
StopEmulation();
}
void TestInterpreterJump (DWORD PC, DWORD TargetPC, int Reg1, int Reg2) {
if (PC != TargetPC) { return; }
if (DelaySlotEffectsCompare(PC,Reg1,Reg2)) { return; }
InPermLoop();
R4300iOp::m_NextInstruction = DELAY_SLOT;
R4300iOp::m_TestTimer = TRUE;
}
CInterpreterCPU::CInterpreterCPU () :
m_R4300i_Opcode(NULL)
{
}
CInterpreterCPU::~CInterpreterCPU()
{
}
void CInterpreterCPU::StartInterpreterCPU (void )
{
R4300iOp::m_TestTimer = FALSE;
R4300iOp::m_NextInstruction = NORMAL;
DWORD CountPerOp = _Settings->LoadDword(Game_CounterFactor);
bool & Done = _N64System->m_EndEmulation;
DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
OPCODE & Opcode = R4300iOp::m_Opcode;
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
BOOL & TestTimer = R4300iOp::m_TestTimer;
R4300iOp::Func * R4300i_Opcode = R4300iOp::BuildInterpreter();
__try
{
while(!Done)
{
if (_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{
/*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,*_NextTimer,_SystemTimer->CurrentType());
}*/
*_NextTimer -= CountPerOp;
((void (_fastcall *)()) R4300i_Opcode[ Opcode.op ])();
switch (R4300iOp::m_NextInstruction) {
case NORMAL:
PROGRAM_COUNTER += 4;
break;
case DELAY_SLOT:
R4300iOp::m_NextInstruction = JUMP;
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)
{
_SystemTimer->TimerDone();
}
if (g_CPU_Action->DoSomething) { DoSomething(); }
}
}
}
} else {
DoTLBMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER);
R4300iOp::m_NextInstruction = NORMAL;
}
}
} __except( _MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) {
DisplayError(GS(MSG_UNKNOWN_MEM_ACTION));
ExitThread(0);
}
}

View File

@ -0,0 +1,12 @@
class CInterpreterCPU
{
public:
CInterpreterCPU();
~CInterpreterCPU();
void StartInterpreterCPU (void );
R4300iOp::Func * m_R4300i_Opcode;
private:
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,171 @@
typedef void ( * R4300iOp_FUNC )();
class R4300iOp32 :
public R4300iOp
{
public:
/************************* OpCode functions *************************/
static void J ( void );
static void JAL ( void );
static void BNE ( void );
static void BEQ ( void );
static void BLEZ ( void );
static void BGTZ ( void );
static void ADDI ( void );
static void ADDIU ( void );
static void SLTI ( void );
static void SLTIU ( void );
static void ANDI ( void );
static void ORI ( void );
static void XORI ( void );
static void LUI ( void );
static void BEQL ( void );
static void BNEL ( void );
static void BLEZL ( void );
static void BGTZL ( void );
static void LB ( void );
static void LH ( void );
static void LWL ( void );
static void LW ( void );
static void LBU ( void );
static void LHU ( void );
static void LWR ( void );
static void LWU ( void );
static void SB ( void );
static void SH ( void );
static void SWL ( void );
static void SW ( void );
static void SWR ( void );
static void CACHE ( void );
static void LL ( void );
static void LWC1 ( void );
static void SC ( void );
static void SWC1 ( void );
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL ( void );
static void SPECIAL_SRL ( void );
static void SPECIAL_SRA ( void );
static void SPECIAL_SLLV ( void );
static void SPECIAL_SRLV ( void );
static void SPECIAL_SRAV ( void );
static void SPECIAL_JR ( void );
static void SPECIAL_JALR ( void );
static void SPECIAL_SYSCALL ( void );
static void SPECIAL_BREAK ( void );
static void SPECIAL_SYNC ( void );
static void SPECIAL_MTHI ( void );
static void SPECIAL_MTLO ( void );
static void SPECIAL_ADD ( void );
static void SPECIAL_ADDU ( void );
static void SPECIAL_SUB ( void );
static void SPECIAL_SUBU ( void );
static void SPECIAL_AND ( void );
static void SPECIAL_OR ( void );
static void SPECIAL_XOR ( void );
static void SPECIAL_NOR ( void );
static void SPECIAL_SLT ( void );
static void SPECIAL_SLTU ( void );
static void SPECIAL_TEQ ( void );
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ ( void );
static void REGIMM_BGEZ ( void );
static void REGIMM_BLTZL ( void );
static void REGIMM_BGEZL ( void );
static void REGIMM_BLTZAL ( void );
static void REGIMM_BGEZAL ( void );
/************************** COP0 functions **************************/
static void COP0_MF ( void );
static void COP0_MT ( void );
/************************** COP0 CO functions ***********************/
static void COP0_CO_TLBR ( void );
static void COP0_CO_TLBWI ( void );
static void COP0_CO_TLBWR ( void );
static void COP0_CO_TLBP ( void );
static void COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
static void COP1_MF ( void );
static void COP1_DMF ( void );
static void COP1_CF ( void );
static void COP1_MT ( void );
static void COP1_DMT ( void );
static void COP1_CT ( void );
/************************* COP1: BC1 functions ***********************/
static void COP1_BCF ( void );
static void COP1_BCT ( void );
static void COP1_BCFL ( void );
static void COP1_BCTL ( void );
/************************** COP1: S functions ************************/
static void COP1_S_ADD ( void );
static void COP1_S_SUB ( void );
static void COP1_S_MUL ( void );
static void COP1_S_DIV ( void );
static void COP1_S_SQRT ( void );
static void COP1_S_ABS ( void );
static void COP1_S_MOV ( void );
static void COP1_S_NEG ( void );
static void COP1_S_TRUNC_L ( void );
static void COP1_S_CEIL_L ( void ); //added by Witten
static void COP1_S_FLOOR_L ( void ); //added by Witten
static void COP1_S_ROUND_W ( void );
static void COP1_S_TRUNC_W ( void );
static void COP1_S_CEIL_W ( void ); //added by Witten
static void COP1_S_FLOOR_W ( void );
static void COP1_S_CVT_D ( void );
static void COP1_S_CVT_W ( void );
static void COP1_S_CVT_L ( void );
static void COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
static void COP1_D_ADD ( void );
static void COP1_D_SUB ( void );
static void COP1_D_MUL ( void );
static void COP1_D_DIV ( void );
static void COP1_D_SQRT ( void );
static void COP1_D_ABS ( void );
static void COP1_D_MOV ( void );
static void COP1_D_NEG ( void );
static void COP1_D_TRUNC_L ( void ); //added by Witten
static void COP1_D_CEIL_L ( void ); //added by Witten
static void COP1_D_FLOOR_L ( void ); //added by Witten
static void COP1_D_ROUND_W ( void );
static void COP1_D_TRUNC_W ( void );
static void COP1_D_CEIL_W ( void ); //added by Witten
static void COP1_D_FLOOR_W ( void ); //added by Witten
static void COP1_D_CVT_S ( void );
static void COP1_D_CVT_W ( void );
static void COP1_D_CVT_L ( void );
static void COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
static void COP1_W_CVT_S ( void );
static void COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
static void COP1_L_CVT_S ( void );
static void COP1_L_CVT_D ( void );
/************************** Other functions **************************/
static void UnknownOpcode ( void );
static R4300iOp_FUNC * BuildInterpreter (void );
private:
static void SPECIAL (void);
static void REGIMM (void);
static void COP0 (void);
static void COP0_CO (void);
static void COP1 (void);
static void COP1_BC (void);
static void COP1_S (void);
static void COP1_D (void);
static void COP1_W (void);
static void COP1_L (void);
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,234 @@
class R4300iOp
{
public:
typedef void ( * Func )();
/************************* OpCode functions *************************/
static void J ( void );
static void JAL ( void );
static void BNE ( void );
static void BEQ ( void );
static void BLEZ ( void );
static void BGTZ ( void );
static void ADDI ( void );
static void ADDIU ( void );
static void SLTI ( void );
static void SLTIU ( void );
static void ANDI ( void );
static void ORI ( void );
static void XORI ( void );
static void LUI ( void );
static void BEQL ( void );
static void BNEL ( void );
static void BLEZL ( void );
static void BGTZL ( void );
static void DADDIU ( void );
static void LDL ( void );
static void LDR ( void );
static void LB ( void );
static void LH ( void );
static void LWL ( void );
static void LW ( void );
static void LBU ( void );
static void LHU ( void );
static void LWR ( void );
static void LWU ( void );
static void SB ( void );
static void SH ( void );
static void SWL ( void );
static void SW ( void );
static void SDL ( void );
static void SDR ( void );
static void SWR ( void );
static void CACHE ( void );
static void LL ( void );
static void LWC1 ( void );
static void LDC1 ( void );
static void LD ( void );
static void SC ( void );
static void SWC1 ( void );
static void SDC1 ( void );
static void SD ( void );
/********************** R4300i OpCodes: Special **********************/
static void SPECIAL_SLL ( void );
static void SPECIAL_SRL ( void );
static void SPECIAL_SRA ( void );
static void SPECIAL_SLLV ( void );
static void SPECIAL_SRLV ( void );
static void SPECIAL_SRAV ( void );
static void SPECIAL_JR ( void );
static void SPECIAL_JALR ( void );
static void SPECIAL_SYSCALL ( void );
static void SPECIAL_BREAK ( void );
static void SPECIAL_SYNC ( void );
static void SPECIAL_MFHI ( void );
static void SPECIAL_MTHI ( void );
static void SPECIAL_MFLO ( void );
static void SPECIAL_MTLO ( void );
static void SPECIAL_DSLLV ( void );
static void SPECIAL_DSRLV ( void );
static void SPECIAL_DSRAV ( void );
static void SPECIAL_MULT ( void );
static void SPECIAL_MULTU ( void );
static void SPECIAL_DIV ( void );
static void SPECIAL_DIVU ( void );
static void SPECIAL_DMULT ( void );
static void SPECIAL_DMULTU ( void );
static void SPECIAL_DDIV ( void );
static void SPECIAL_DDIVU ( void );
static void SPECIAL_ADD ( void );
static void SPECIAL_ADDU ( void );
static void SPECIAL_SUB ( void );
static void SPECIAL_SUBU ( void );
static void SPECIAL_AND ( void );
static void SPECIAL_OR ( void );
static void SPECIAL_XOR ( void );
static void SPECIAL_NOR ( void );
static void SPECIAL_SLT ( void );
static void SPECIAL_SLTU ( void );
static void SPECIAL_DADD ( void );
static void SPECIAL_DADDU ( void );
static void SPECIAL_DSUB ( void );
static void SPECIAL_DSUBU ( void );
static void SPECIAL_TEQ ( void );
static void SPECIAL_DSLL ( void );
static void SPECIAL_DSRL ( void );
static void SPECIAL_DSRA ( void );
static void SPECIAL_DSLL32 ( void );
static void SPECIAL_DSRL32 ( void );
static void SPECIAL_DSRA32 ( void );
/********************** R4300i OpCodes: RegImm **********************/
static void REGIMM_BLTZ ( void );
static void REGIMM_BGEZ ( void );
static void REGIMM_BLTZL ( void );
static void REGIMM_BGEZL ( void );
static void REGIMM_BLTZAL ( void );
static void REGIMM_BGEZAL ( void );
/************************** COP0 functions **************************/
static void COP0_MF ( void );
static void COP0_MT ( void );
/************************** COP0 CO functions ***********************/
static void COP0_CO_TLBR ( void );
static void COP0_CO_TLBWI ( void );
static void COP0_CO_TLBWR ( void );
static void COP0_CO_TLBP ( void );
static void COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
static void COP1_MF ( void );
static void COP1_DMF ( void );
static void COP1_CF ( void );
static void COP1_MT ( void );
static void COP1_DMT ( void );
static void COP1_CT ( void );
/************************* COP1: BC1 functions ***********************/
static void COP1_BCF ( void );
static void COP1_BCT ( void );
static void COP1_BCFL ( void );
static void COP1_BCTL ( void );
/************************** COP1: S functions ************************/
static void COP1_S_ADD ( void );
static void COP1_S_SUB ( void );
static void COP1_S_MUL ( void );
static void COP1_S_DIV ( void );
static void COP1_S_SQRT ( void );
static void COP1_S_ABS ( void );
static void COP1_S_MOV ( void );
static void COP1_S_NEG ( void );
static void COP1_S_TRUNC_L ( void );
static void COP1_S_CEIL_L ( void ); //added by Witten
static void COP1_S_FLOOR_L ( void ); //added by Witten
static void COP1_S_ROUND_W ( void );
static void COP1_S_TRUNC_W ( void );
static void COP1_S_CEIL_W ( void ); //added by Witten
static void COP1_S_FLOOR_W ( void );
static void COP1_S_CVT_D ( void );
static void COP1_S_CVT_W ( void );
static void COP1_S_CVT_L ( void );
static void COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
static void COP1_D_ADD ( void );
static void COP1_D_SUB ( void );
static void COP1_D_MUL ( void );
static void COP1_D_DIV ( void );
static void COP1_D_SQRT ( void );
static void COP1_D_ABS ( void );
static void COP1_D_MOV ( void );
static void COP1_D_NEG ( void );
static void COP1_D_TRUNC_L ( void ); //added by Witten
static void COP1_D_CEIL_L ( void ); //added by Witten
static void COP1_D_FLOOR_L ( void ); //added by Witten
static void COP1_D_ROUND_W ( void );
static void COP1_D_TRUNC_W ( void );
static void COP1_D_CEIL_W ( void ); //added by Witten
static void COP1_D_FLOOR_W ( void ); //added by Witten
static void COP1_D_CVT_S ( void );
static void COP1_D_CVT_W ( void );
static void COP1_D_CVT_L ( void );
static void COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
static void COP1_W_CVT_S ( void );
static void COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
static void COP1_L_CVT_S ( void );
static void COP1_L_CVT_D ( void );
/************************** Other functions **************************/
static void UnknownOpcode ( void );
static Func * BuildInterpreter (void );
static BOOL m_TestTimer;
static DWORD m_NextInstruction;
static OPCODE m_Opcode;
static DWORD m_JumpToLocation;
protected:
static void SPECIAL (void);
static void REGIMM (void);
static void COP0 (void);
static void COP0_CO (void);
static void COP1 (void);
static void COP1_BC (void);
static void COP1_S (void);
static void COP1_D (void);
static void COP1_W (void);
static void COP1_L (void);
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];
};
#ifdef __cplusplus
extern "C" {
#endif
extern int RoundingModel;
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1 @@
#include "../stdafx.h"

View File

@ -13,7 +13,7 @@ public:
virtual bool WriteToProtectedMemory (DWORD Address, int length) = 0;
};
class CBlockSection;
class CCodeSection;
class CMipsMemory
{
@ -43,23 +43,24 @@ public:
virtual void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0;
//Compilation Functions
virtual void ResetMemoryStack ( CBlockSection * Section ) = 0;
virtual void ResetMemoryStack ( CCodeSection * Section ) = 0;
virtual void Compile_LB ( int Reg, DWORD Addr, BOOL SignExtend ) = 0;
virtual void Compile_LH ( int Reg, DWORD Addr, BOOL SignExtend ) = 0;
virtual void Compile_LW ( CBlockSection * Section, int Reg, DWORD Addr ) = 0;
virtual void Compile_LW ( CCodeSection * Section, int Reg, DWORD Addr ) = 0;
virtual void Compile_SB_Const ( BYTE Value, DWORD Addr ) = 0;
virtual void Compile_SB_Register ( int x86Reg, DWORD Addr ) = 0;
virtual void Compile_SH_Const ( WORD Value, DWORD Addr ) = 0;
virtual void Compile_SH_Register ( int x86Reg, DWORD Addr ) = 0;
virtual void Compile_SW_Const ( DWORD Value, DWORD Addr ) = 0;
virtual void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Addr ) = 0;
virtual void Compile_SW_Register ( CCodeSection * Section, int x86Reg, DWORD Addr ) = 0;
};
class CRSP_Plugin;
class CMipsMemoryVM :
public CMipsMemory
public CMipsMemory,
public CTransVaddr
#ifdef toremove
,
@ -151,8 +152,6 @@ public:
BOOL SW_VAddr ( DWORD VAddr, DWORD Value );
BOOL SD_VAddr ( DWORD VAddr, QWORD Value );
bool ValidVaddr ( DWORD VAddr ) const;
int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer );
//Protect the Memory from being written to
@ -160,21 +159,24 @@ public:
void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
//Compilation Functions
void ResetMemoryStack ( CBlockSection * Section );
void ResetMemoryStack ( CCodeSection * Section );
void Compile_LB ( int Reg, DWORD Addr, BOOL SignExtend );
void Compile_LH ( int Reg, DWORD Addr, BOOL SignExtend );
void Compile_LW ( CBlockSection * Section, int Reg, DWORD Addr );
void Compile_LW ( CCodeSection * Section, int Reg, DWORD Addr );
void Compile_SB_Const ( BYTE Value, DWORD Addr );
void Compile_SB_Register ( int x86Reg, DWORD Addr );
void Compile_SH_Const ( WORD Value, DWORD Addr );
void Compile_SH_Register ( int x86Reg, DWORD Addr );
void Compile_SW_Const ( DWORD Value, DWORD Addr );
void Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD Addr );
void Compile_SW_Register ( CCodeSection * Section, int x86Reg, DWORD Addr );
//Functions for TLB notification
void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly );
void TLB_Unmaped ( DWORD Vaddr, DWORD Len );
// CTransVaddr interface
bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const;
bool ValidVaddr ( DWORD VAddr ) const;
@ -242,4 +244,4 @@ private:
};
extern void ** JumpTable;
extern BYTE *RecompCode, *RecompPos;
extern BYTE *RecompPos;

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
void ** JumpTable, ** DelaySlotTable;
BYTE *RecompCode, *RecompPos;
BYTE *RecompPos;
CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack ) :
m_CBClass(CallBack),
@ -444,13 +444,18 @@ BOOL CMipsMemoryVM::SD_VAddr ( DWORD VAddr, QWORD Value )
bool CMipsMemoryVM::ValidVaddr ( DWORD VAddr ) const
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
return CTLB::ValidVaddr(VAddr);
#endif
return false;
return m_TLB_ReadMap[VAddr >> 12] != 0;
}
bool CMipsMemoryVM::TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const
{
//Change the Virtual address to a Phyiscal Address
if (m_TLB_ReadMap[VAddr >> 12] == 0) { return false; }
PAddr = (DWORD)((BYTE *)(m_TLB_ReadMap[VAddr >> 12] + VAddr) - m_RDRAM);
return true;
}
#ifdef toremove
bool CMipsMemoryVM::Store64 ( DWORD VAddr, QWORD Value, MemorySize Size ) {
//__try {
@ -690,7 +695,7 @@ void CMipsMemoryVM::Compile_LH ( int Reg, DWORD VAddr, BOOL SignExtend) {
#endif
}
void CMipsMemoryVM::Compile_LW ( CBlockSection * Section, int Reg, DWORD VAddr ) {
void CMipsMemoryVM::Compile_LW ( CCodeSection * Section, int Reg, DWORD VAddr ) {
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
char VarName[100];
@ -1315,7 +1320,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
#endif
}
void CMipsMemoryVM::Compile_SW_Register ( CBlockSection * Section, int x86Reg, DWORD VAddr )
void CMipsMemoryVM::Compile_SW_Register ( CCodeSection * Section, int x86Reg, DWORD VAddr )
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
@ -1585,7 +1590,7 @@ void CMipsMemoryVM::Compile_SW_Register ( CBlockSection * Section, int x86Reg, D
#endif
}
void CMipsMemoryVM::ResetMemoryStack (CBlockSection * Section)
void CMipsMemoryVM::ResetMemoryStack (CCodeSection * Section)
{
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix

View File

@ -690,6 +690,7 @@ bool CN64System::SetActiveSystem( bool bActive )
_MMU = &m_MMU_VM;
_Reg = &m_Reg;
_SystemTimer = &m_SystemTimer;
_TransVaddr = &m_MMU_VM;
} else {
if (_N64System == this)
{
@ -901,16 +902,20 @@ void CN64System::ExecuteCPU ( void )
void CN64System::ExecuteInterpret (CC_Core & C_Core) {
C_Core.SetN64System(this);
InitializeCPUCore();
ExecuteCycles(-1);
CInterpreterCPU Interpreter;
Interpreter.StartInterpreterCPU();
//StartInterpreterCPU();
}
void CN64System::ExecuteRecompiler (CC_Core & C_Core) {
void CN64System::ExecuteRecompiler (CC_Core & C_Core)
{
//execute opcodes while no errors
CRecompiler Recompiler(m_Profile,m_EndEmulation,false);
m_Recomp = &Recompiler;
m_Recomp = new CRecompiler(m_Profile,m_EndEmulation,false);
C_Core.SetN64System(this);
InitializeCPUCore();
Recompiler.Run();
m_Recomp->Run();
}
void CN64System::ExecuteSyncCPU (CC_Core & C_Core)

View File

@ -10,14 +10,14 @@ CDelaySlotFunctionMap::~CDelaySlotFunctionMap()
Reset();
}
FUNCTION_INFO * CDelaySlotFunctionMap::AddFunctionInfo ( DWORD vAddr, DWORD pAddr )
CCompiledFunc * CDelaySlotFunctionMap::AddFunctionInfo ( DWORD vAddr, DWORD pAddr )
{
if (FunctionMap.find(vAddr) != FunctionMap.end())
{
Notify().BreakPoint(__FILE__,__LINE__);
}
FUNCTION_INFO * info = new FUNCTION_INFO(vAddr,pAddr);
CCompiledFunc * info = new CCompiledFunc(vAddr,pAddr);
FunctionMap.insert(FUNCTION_MAP::value_type(vAddr,info));
return info;
@ -25,13 +25,13 @@ FUNCTION_INFO * CDelaySlotFunctionMap::AddFunctionInfo ( DWORD vAddr, DWORD pAdd
return NULL;
}
FUNCTION_INFO * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr, int Length )
CCompiledFunc * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr, int Length )
{
DWORD Start = ((vAddr + 0xFFF) >> 0xC);
DWORD End = ((vAddr + Length) >> 0xC);
for (DWORD i = Start; i < End; i++)
{
FUNCTION_INFO * info = FindFunction(i << 0xC);
CCompiledFunc * info = FindFunction(i << 0xC);
if (info)
{
return info;
@ -40,7 +40,7 @@ FUNCTION_INFO * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr, int Length )
return NULL;
}
FUNCTION_INFO * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr ) const
CCompiledFunc * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr ) const
{
FUNCTION_MAP::const_iterator iter = FunctionMap.find(vAddr);
if (iter == FunctionMap.end())
@ -51,7 +51,7 @@ FUNCTION_INFO * CDelaySlotFunctionMap::FindFunction ( DWORD vAddr ) const
}
void CDelaySlotFunctionMap::Remove ( FUNCTION_INFO * info )
void CDelaySlotFunctionMap::Remove ( CCompiledFunc * info )
{
FUNCTION_MAP::iterator iter = FunctionMap.find(info->VStartPC());
if (iter != FunctionMap.end())

View File

@ -1,6 +1,6 @@
class CDelaySlotFunctionMap
{
typedef std::map<DWORD,FUNCTION_INFO *> FUNCTION_MAP;
typedef std::map<DWORD,CCompiledFunc *> FUNCTION_MAP;
FUNCTION_MAP FunctionMap;
@ -8,10 +8,10 @@ public:
CDelaySlotFunctionMap ( void );
~CDelaySlotFunctionMap ( void );
FUNCTION_INFO * AddFunctionInfo ( DWORD vAddr, DWORD pAddr );
FUNCTION_INFO * FindFunction ( DWORD vAddr, int Length );
FUNCTION_INFO * FindFunction ( DWORD vAddr ) const;
CCompiledFunc * AddFunctionInfo ( DWORD vAddr, DWORD pAddr );
CCompiledFunc * FindFunction ( DWORD vAddr, int Length );
CCompiledFunc * FindFunction ( DWORD vAddr ) const;
void Remove ( FUNCTION_INFO * info );
void Remove ( CCompiledFunc * info );
void Reset ( void );
};

View File

@ -1,6 +1,6 @@
#include "..\..\N64 System.h"
FUNCTION_INFO::FUNCTION_INFO(DWORD StartAddress, DWORD PhysicalStartAddress) :
CCompiledFunc::CCompiledFunc(DWORD StartAddress, DWORD PhysicalStartAddress) :
m_VStartPC(StartAddress),
m_PStartPC(PhysicalStartAddress),
m_VEndPC(0),
@ -12,4 +12,101 @@ FUNCTION_INFO::FUNCTION_INFO(DWORD StartAddress, DWORD PhysicalStartAddress) :
MemContents[i] = 0;
MemLocation[i] = NULL;
}
}
}
bool CCompiledFunc::CompilerCodeBlock(void)
{
DWORD StartTime = timeGetTime();
WriteTraceF(TraceRecompiler,"Compile Block-Start: VAddr: %X PAddr",m_VStartPC,m_PStartPC);
//if (bProfiling()) { m_Profile.StartTimer(Timer_GetBlockInfo); }
CBlockInfo BlockInfo(*_PROGRAM_COUNTER, RecompPos);
//if (bProfiling()) { m_Profile.StartTimer(Timer_AnalyseBlock); }
#ifdef tofix
if (bProfiling()) { m_Profile.StartTimer(Timer_CompileBlock); }
_Notify->BreakPoint(__FILE__,__LINE__);
DWORD StartAddress;
if (!_TLB->TranslateVaddr(BlockInfo.StartVAddr,StartAddress))
{
DisplayError("Ummm... Where does this block go\n%X",BlockInfo.StartVAddr);
return false;
}
MarkCodeBlock(StartAddress);
if (StartAddress < RdramSize()) {
CPU_Message("====== RDRAM: block (%X:%d) ======", StartAddress>>12,N64_Blocks.NoOfRDRamBlocks[StartAddress>>12]);
} else if (StartAddress >= 0x04000000 && StartAddress <= 0x04000FFC) {
CPU_Message("====== DMEM: block (%d) ======", N64_Blocks.NoOfDMEMBlocks);
} else if (StartAddress >= 0x04001000 && StartAddress <= 0x04001FFC) {
CPU_Message("====== IMEM: block (%d) ======", N64_Blocks.NoOfIMEMBlocks);
} else if (StartAddress >= 0x1FC00000 && StartAddress <= 0x1FC00800) {
CPU_Message("====== PIF ROM: block ======");
} else {
#ifndef ROM_IN_MAPSPACE
#ifndef EXTERNAL_RELEASE
DisplayError("Ummm... Where does this block go");
#endif
ExitThread(0);
#endif
}*/
#endif
CPU_Message("====== Code block ======");
CPU_Message("VAddress: %X",BlockInfo.StartVAddr );
CPU_Message("x86 code at: %X",BlockInfo.CompiledLocation);
CPU_Message("No of Sections: %d",BlockInfo.NoOfSections );
CPU_Message("====== recompiled code ======");
/*if (bLinkBlocks()) {
for (int count = 0; count < BlockInfo.NoOfSections; count ++) {
DisplaySectionInformation(&BlockInfo.ParentSection,count + 1,CBlockSection::GetNewTestValue());
}
}
if (m_SyncSystem) {
//if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B) { X86BreakPoint(__FILE__,__LINE__); }
//MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
}
BlockInfo.ParentSection.RegStart.Initilize();
BlockInfo.ParentSection.RegWorking = BlockInfo.ParentSection.RegStart;
if (bLinkBlocks()) {
while (GenerateX86Code(BlockInfo,&BlockInfo.ParentSection,CBlockSection::GetNewTestValue()));
} else {
GenerateX86Code(BlockInfo,&BlockInfo.ParentSection,CBlockSection::GetNewTestValue());
}
CompileExitCode(BlockInfo);
CPU_Message("====== End of recompiled code ======");
if (bProfiling()) { m_Profile.StartTimer(Timer_CompileDone); }
info->SetVEndPC(BlockInfo.EndVAddr);
// info->SetFunctionAddr(BlockInfo.CompiledLocation);
_Notify->BreakPoint(__FILE__,__LINE__);
#ifdef tofix
_TLB->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast<void **>(&info->MemLocation[0])));
info->MemLocation[1] = info->MemLocation[0] + 1;
info->MemContents[0] = *info->MemLocation[0];
info->MemContents[1] = *info->MemLocation[1];
if (bSMM_Protect())
{
_MMU->ProtectMemory(info->VStartPC(),info->VEndPC());
}
NextInstruction = NORMAL;
if (bShowRecompMemSize())
{
DWORD Size = RecompPos - RecompCode;
DWORD MB = Size / 0x100000;
Size -= MB * 0x100000;
DWORD KB = Size / 1024;
Size -= KB * 1024;
DWORD TotalAvaliable = _MMU->GetRecompBufferSize() / 0x100000;
DisplayMessage(0,"Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable);
}
if (bProfiling()) { m_Profile.StopTimer(); }
#endif
DWORD TimeTaken = timeGetTime() - StartTime;
WriteTraceF(TraceRecompiler,"Compile Block-Done: %X-%X - Taken: %d",info->VStartPC(),info->VEndPC(),TimeTaken);*/
return true;
}

View File

@ -1,29 +1,35 @@
typedef void (* RECOMP_FUNC)(void);
class FUNCTION_INFO {
class CCompiledFunc
{
//Information
DWORD m_VStartPC; //The Virtual Address that the jump is going to
DWORD m_PStartPC; //The Physical Address that the jump is going to
DWORD m_VEndPC;
//From querying the recompiler get information about the function
BYTE * m_Function;
RECOMP_FUNC m_Function;
public:
//constructor
FUNCTION_INFO (DWORD VirtualStartAddress, DWORD PhysicalStartAddress );
CCompiledFunc (DWORD VirtualStartAddress, DWORD PhysicalStartAddress );
//Get Private Information
inline const DWORD VStartPC ( void ) const { return m_VStartPC; }
inline const DWORD PStartPC ( void ) const { return m_PStartPC; }
inline const DWORD VEndPC ( void ) const { return m_VEndPC; }
inline const BYTE * FunctionAddr ( void ) const { return m_Function; }
inline const DWORD VStartPC ( void ) const { return m_VStartPC; }
inline const DWORD PStartPC ( void ) const { return m_PStartPC; }
inline const DWORD VEndPC ( void ) const { return m_VEndPC; }
inline const RECOMP_FUNC Function ( void ) const { return m_Function; }
//Set Private Information
inline void SetVEndPC ( DWORD VEndPC ) { m_VEndPC = VEndPC; }
inline void SetFunctionAddr ( BYTE * FunctionAddr ) { m_Function = FunctionAddr; }
inline void SetVEndPC ( DWORD VEndPC ) { m_VEndPC = VEndPC; }
inline void SetFunctionAddr ( RECOMP_FUNC FunctionAddr ) { m_Function = FunctionAddr; }
//Functions
bool CompilerCodeBlock ( void );
//Validation
QWORD MemContents[2], * MemLocation[2];
FUNCTION_INFO * Next;
CCompiledFunc * Next;
};

View File

@ -1,6 +1,26 @@
#include "..\..\N64 System.h"
CFunctionMap::CFunctionMap( void) :
CFunctionMap::CFunctionMap() :
m_FunctionTable(NULL)
{
}
CFunctionMap::~CFunctionMap()
{
}
bool CFunctionMap::AllocateMemory()
{
m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
if (m_FunctionTable == NULL) {
_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
return false;
}
memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *));
return true;
}
/*CFunctionMap::CFunctionMap( void) :
m_FunctionTable(NULL)
{
}
@ -15,12 +35,12 @@ void * CFunctionMap::CompilerFindFunction( CFunctionMap * _this, DWORD vAddr )
return _this->FindFunction(vAddr);
}
FUNCTION_INFO * CFunctionMap::FindFunction( DWORD vAddr, int Length )
CCompiledFunc * CFunctionMap::FindFunction( DWORD vAddr, int Length )
{
DWORD SectionEnd = (vAddr + Length + 0xFFF) >> 0xC;
for (DWORD Section = (vAddr >> 0x0C); Section < SectionEnd; Section++)
{
PFUNCTION_INFO_TABLE table = m_FunctionTable[Section];
CCompiledFunc table = m_FunctionTable[Section];
if (table == NULL)
{
continue;
@ -31,14 +51,14 @@ FUNCTION_INFO * CFunctionMap::FindFunction( DWORD vAddr, int Length )
{
Start = ((vAddr & 0xFFF) >> 2);
}*/
int SearchEnd = (Length - ((Section - (vAddr >> 0x0C)) * (0x1000 >> 2))) >> 2;
/*int SearchEnd = (Length - ((Section - (vAddr >> 0x0C)) * (0x1000 >> 2))) >> 2;
if (Start + SearchEnd > (0x1000 >> 2))
{
SearchEnd = (0x1000 >> 2);
}
for (int i = Start; i < SearchEnd; i++)
{
PFUNCTION_INFO & info = table[i];
PCCompiledFunc & info = table[i];
if (info)
{
if (info->VEndPC() < vAddr)
@ -64,17 +84,17 @@ void CFunctionMap::Reset( bool AllocateMemory )
continue;
}
PFUNCTION_INFO_TABLE table = m_FunctionTable[i];
CCompiledFunc table = m_FunctionTable[i];
for (int x = 0; x < (0x1000) >> 2; x++)
{
PFUNCTION_INFO info = table[x];
PCCompiledFunc info = table[x];
if (info == NULL)
{
continue;
}
while (info->Next)
{
PFUNCTION_INFO todelete = info;
PCCompiledFunc todelete = info;
info = info->Next;
delete todelete;
}
@ -95,7 +115,7 @@ void CFunctionMap::Reset( bool AllocateMemory )
{
if (m_FunctionTable == NULL)
{
m_FunctionTable = (PFUNCTION_INFO_TABLE *)VirtualAlloc(NULL,0xFFFFF * sizeof(PFUNCTION_INFO_TABLE *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
m_FunctionTable = (CCompiledFunc *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
if (m_FunctionTable == NULL) {
Notify().FatalError(MSG_MEM_ALLOC_ERROR);
}
@ -105,42 +125,42 @@ void CFunctionMap::Reset( bool AllocateMemory )
}
FUNCTION_INFO * CFunctionMap::AddFunctionInfo( DWORD vAddr, DWORD pAddr )
CCompiledFunc * CFunctionMap::AddFunctionInfo( DWORD vAddr, DWORD pAddr )
{
PFUNCTION_INFO_TABLE & table = m_FunctionTable[vAddr >> 0xC];
CCompiledFunc & table = m_FunctionTable[vAddr >> 0xC];
if (table == NULL)
{
table = new PFUNCTION_INFO[(0x1000 >> 2)];
table = new PCCompiledFunc[(0x1000 >> 2)];
if (table == NULL)
{
Notify().FatalError(MSG_MEM_ALLOC_ERROR);
}
memset(table,0,sizeof(PFUNCTION_INFO) * (0x1000 >> 2));
memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2));
}
PFUNCTION_INFO & info = table[(vAddr & 0xFFF) >> 2];
PCCompiledFunc & info = table[(vAddr & 0xFFF) >> 2];
if (info != NULL)
{
PFUNCTION_INFO old_info = info;
info = new FUNCTION_INFO(vAddr,pAddr);
PCCompiledFunc old_info = info;
info = new CCompiledFunc(vAddr,pAddr);
info->Next = old_info;
} else {
info = new FUNCTION_INFO(vAddr,pAddr);
info = new CCompiledFunc(vAddr,pAddr);
}
return info;
}
void CFunctionMap::Remove(FUNCTION_INFO * info)
void CFunctionMap::Remove(CCompiledFunc * info)
{
DWORD vAddr = info->VStartPC();
PFUNCTION_INFO_TABLE & table = m_FunctionTable[vAddr >> 0xC];
CCompiledFunc & table = m_FunctionTable[vAddr >> 0xC];
if (table == NULL)
{
return;
}
PFUNCTION_INFO & current_info = table[(vAddr & 0xFFF) >> 2];
PCCompiledFunc & current_info = table[(vAddr & 0xFFF) >> 2];
if (current_info == NULL)
{
return;
@ -154,3 +174,4 @@ void CFunctionMap::Remove(FUNCTION_INFO * info)
Notify().BreakPoint(__FILE__,__LINE__);
}
}
*/

View File

@ -1,28 +1,39 @@
class CFunctionMap
{
public:
typedef FUNCTION_INFO * PFUNCTION_INFO;
typedef PFUNCTION_INFO * PFUNCTION_INFO_TABLE;
protected:
typedef CCompiledFunc * PCCompiledFunc;
typedef PCCompiledFunc * PCCompiledFunc_TABLE;
CFunctionMap();
~CFunctionMap();
bool AllocateMemory ( void );
PCCompiledFunc_TABLE * m_FunctionTable;
/*public:
typedef CCompiledFunc * PCCompiledFunc;
typedef PCCompiledFunc * PCCompiledFunc_TABLE;
private:
void Reset ( bool AllocateMemory );
PFUNCTION_INFO_TABLE * m_FunctionTable;
PCCompiledFunc_TABLE * m_FunctionTable;
public:
CFunctionMap ( void );
~CFunctionMap ( void );
FUNCTION_INFO * AddFunctionInfo ( DWORD vAddr, DWORD pAddr );
FUNCTION_INFO * FindFunction ( DWORD vAddr, int Length );
CCompiledFunc * AddFunctionInfo ( DWORD vAddr, DWORD pAddr );
CCompiledFunc * FindFunction ( DWORD vAddr, int Length );
static void * __fastcall CFunctionMap::CompilerFindFunction( CFunctionMap * _this, DWORD vAddr );
inline FUNCTION_INFO * CFunctionMap::FindFunction( DWORD vAddr ) const
inline CCompiledFunc * CFunctionMap::FindFunction( DWORD vAddr ) const
{
PFUNCTION_INFO_TABLE table = m_FunctionTable[vAddr >> 0xC];
PCCompiledFunc_TABLE table = m_FunctionTable[vAddr >> 0xC];
if (table)
{
PFUNCTION_INFO & info = table[(vAddr & 0xFFF) >> 2];
PCCompiledFunc & info = table[(vAddr & 0xFFF) >> 2];
if (info != NULL)
{
return info;
@ -31,8 +42,8 @@ public:
return NULL;
}
PFUNCTION_INFO_TABLE * GetFunctionTable ( void ) { return m_FunctionTable; }
PCCompiledFunc_TABLE * GetFunctionTable ( void ) { return m_FunctionTable; }
inline void Reset (void) { Reset(true); }
void Remove (FUNCTION_INFO * info);
void Remove (CCompiledFunc * info);*/
};

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
class CRecompiler :
public CRecompilerSettings
public CRecompilerSettings,
private CRecompMemory,
private CFunctionMap
{
public:
@ -12,6 +14,23 @@ public:
Remove_DMA,
};
public:
CRecompiler (CProfiling & Profile, bool & EndEmulation, bool SyncSystem);
~CRecompiler (void);
void Run ( void );
void ResetRecompCode ( void );
void CompileSystemCheck (DWORD TargetPC, CRegInfo &RegSet);
void UpdateCounters ( DWORD * Cycles, DWORD * RandomMod, BOOL CheckTimer);
void CompileExit ( CCodeSection * Section, DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegSet, CExitInfo::EXIT_REASON reason, int CompileNow, void (*x86Jmp)(char * Label, DWORD Value));
bool GenerateX86Code (CBlockInfo & BlockInfo, CCodeSection * Section, DWORD Test );
void GenerateSectionLinkage (CCodeSection * Section);
//Self modifying code methods
bool ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason );
bool ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason );
private:
bool const m_SyncSystem;
CProfiling & m_Profile;
@ -22,25 +41,27 @@ private:
//Functions
CDelaySlotFunctionMap m_FunctionsDelaySlot;
CFunctionMap m_Functions;
//CFunctionMap m_Functions;
FUNCTION_INFO * CompilerCode ( void );
FUNCTION_INFO * CompileDelaySlot ( DWORD PC );
bool Compiler4300iBlock ( FUNCTION_INFO * info );
CCompiledFunc * CompilerCode ( void );
CCompiledFunc * CompileDelaySlot ( DWORD PC );
bool Compiler4300iBlock ( CCompiledFunc * info );
void CheckRecompMem ( void );
// Compiling code
bool AnalyseBlock ( CBlockInfo & BlockInfo );
bool CreateSectionLinkage ( CBlockSection * Section );
bool CreateSectionLinkage ( CCodeSection * Section );
void CompileExitCode ( CBlockInfo & BlockInfo );
void DetermineLoop ( CBlockSection * Section, DWORD Test, DWORD Test2, DWORD TestID);
bool DisplaySectionInformation (CBlockSection * Section, DWORD ID, DWORD Test);
bool FixConstants ( CBlockSection * Section, DWORD Test );
bool InheritParentInfo ( CBlockSection * Section );
void InheritConstants ( CBlockSection * Section );
// bool IsAllParentLoops ( CBlockSection * Section, CBlockSection * Parent, bool IgnoreIfCompiled, DWORD Test );
bool FillSectionInfo ( CBlockSection * Section, STEP_TYPE StartStepType );
void SyncRegState ( CBlockSection * Section, CRegInfo * SyncTo );
CBlockSection * ExistingSection( CBlockSection * StartSection, DWORD Addr, DWORD Test);
void DetermineLoop ( CCodeSection * Section, DWORD Test, DWORD Test2, DWORD TestID);
bool DisplaySectionInformation (CCodeSection * Section, DWORD ID, DWORD Test);
bool FixConstants ( CCodeSection * Section, DWORD Test );
bool InheritParentInfo ( CCodeSection * Section );
void InheritConstants ( CCodeSection * Section );
// bool IsAllParentLoops ( CCodeSection * Section, CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test );
bool FillSectionInfo ( CCodeSection * Section, STEP_TYPE StartStepType );
void SyncRegState ( CCodeSection * Section, CRegInfo * SyncTo );
CCodeSection * ExistingSection( CCodeSection * StartSection, DWORD Addr, DWORD Test);
// Main loops for the different look up methods
void RecompilerMain_VirtualTable ( void );
@ -48,23 +69,5 @@ private:
void RecompilerMain_ChangeMemory ( void );
void RecompilerMain_Lookup ( void );
void RemoveFunction (FUNCTION_INFO * FunInfo, bool DelaySlot, REMOVE_REASON Reason );
public:
CRecompiler (CProfiling & Profile, bool & EndEmulation, bool SyncSystem);
~CRecompiler (void);
void Run ( void );
void ResetRecompCode ( void );
void CompileSystemCheck (DWORD TargetPC, CRegInfo &RegSet);
void UpdateCounters ( DWORD * Cycles, DWORD * RandomMod, BOOL CheckTimer);
void CompileExit ( CBlockSection * Section, DWORD JumpPC, DWORD TargetPC, CRegInfo ExitRegSet, CExitInfo::EXIT_REASON reason, int CompileNow, void (*x86Jmp)(char * Label, DWORD Value));
bool GenerateX86Code (CBlockInfo & BlockInfo, CBlockSection * Section, DWORD Test );
void GenerateSectionLinkage (CBlockSection * Section);
//Self modifying code methods
bool ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason );
bool ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason );
void RemoveFunction (CCompiledFunc * FunInfo, bool DelaySlot, REMOVE_REASON Reason );
};

View File

@ -0,0 +1,36 @@
#include "stdafx.h"
CRecompMemory::CRecompMemory() :
m_RecompCode(0),
m_RecompSize(0)
{
}
CRecompMemory::~CRecompMemory()
{
if (m_RecompCode)
{
VirtualFree( m_RecompCode, 0 , MEM_RELEASE);
m_RecompCode = NULL;
}
}
bool CRecompMemory::AllocateMemory()
{
BYTE * RecompCodeBase = (BYTE *)VirtualAlloc( NULL, MaxCompileBufferSize + 4, MEM_RESERVE|MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE);
if(RecompCodeBase==NULL)
{
_Notify->DisplayError(MSG_MEM_ALLOC_ERROR);
return FALSE;
}
m_RecompCode = (BYTE *)VirtualAlloc( RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(m_RecompCode==NULL)
{
VirtualFree( RecompCodeBase, 0 , MEM_RELEASE);
_Notify->DisplayError(MSG_MEM_ALLOC_ERROR);
return FALSE;
}
m_RecompSize = InitialCompileBufferSize;
return true;
}

View File

@ -0,0 +1,15 @@
class CRecompMemory
{
protected:
CRecompMemory();
~CRecompMemory();
bool AllocateMemory ( void );
BYTE * m_RecompCode;
DWORD m_RecompSize;
enum { MaxCompileBufferSize = 0x03C00000 };
enum { InitialCompileBufferSize = 0x00500000 };
enum { IncreaseCompileBufferSize = 0x00100000 };
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,188 @@
class CRecompilerOps
{
CRecompilerOps();
protected:
enum BRANCH_TYPE
{
BranchTypeCop1, BranchTypeRs, BranchTypeRsRt
};
typedef void (CRecompilerOps::* BranchFunction) (void);
CRecompilerOps( CCodeSection * Section );
/************************** Branch functions ************************/
void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, BOOL Link);
void Compile_BranchLikely ( BranchFunction CompareFunc, BOOL Link);
void BNE_Compare ( void );
void BEQ_Compare ( void );
void BGTZ_Compare ( void );
void BLEZ_Compare ( void );
void BLTZ_Compare ( void );
void BGEZ_Compare ( void );
void COP1_BCF_Compare ( void );
void COP1_BCT_Compare ( void );
/************************* OpCode functions *************************/
void Compile_J ( void );
void Compile_JAL ( void );
void Compile_ADDI ( void );
void Compile_ADDIU ( void );
void Compile_SLTI ( void );
void Compile_SLTIU ( void );
void Compile_ANDI ( void );
void Compile_ORI ( void );
void Compile_XORI ( void );
void Compile_LUI ( void );
void Compile_DADDIU ( void );
void Compile_LDL ( void );
void Compile_LDR ( void );
void Compile_LB ( void );
void Compile_LH ( void );
void Compile_LWL ( void );
void Compile_LW ( void );
void Compile_LBU ( void );
void Compile_LHU ( void );
void Compile_LWR ( void );
void Compile_LWU ( void ); //added by Witten
void Compile_SB ( void );
void Compile_SH ( void );
void Compile_SWL ( void );
void Compile_SW ( void );
void Compile_SWR ( void );
void Compile_SDL ( void );
void Compile_SDR ( void );
void Compile_CACHE ( void );
void Compile_LL ( void );
void Compile_LWC1 ( void );
void Compile_LDC1 ( void );
void Compile_LD ( void );
void Compile_SC ( void );
void Compile_SWC1 ( void );
void Compile_SDC1 ( void );
void Compile_SD ( void );
/********************** R4300i OpCodes: Special **********************/
void Compile_SPECIAL_SLL ( void );
void Compile_SPECIAL_SRL ( void );
void Compile_SPECIAL_SRA ( void );
void Compile_SPECIAL_SLLV ( void );
void Compile_SPECIAL_SRLV ( void );
void Compile_SPECIAL_SRAV ( void );
void Compile_SPECIAL_JR ( void );
void Compile_SPECIAL_JALR ( void );
void Compile_SPECIAL_SYSCALL( void );
void Compile_SPECIAL_MFLO ( void );
void Compile_SPECIAL_MTLO ( void );
void Compile_SPECIAL_MFHI ( void );
void Compile_SPECIAL_MTHI ( void );
void Compile_SPECIAL_DSLLV ( void );
void Compile_SPECIAL_DSRLV ( void );
void Compile_SPECIAL_DSRAV ( void );
void Compile_SPECIAL_MULT ( void );
void Compile_SPECIAL_MULTU ( void );
void Compile_SPECIAL_DIV ( void );
void Compile_SPECIAL_DIVU ( void );
void Compile_SPECIAL_DMULT ( void );
void Compile_SPECIAL_DMULTU ( void );
void Compile_SPECIAL_DDIV ( void );
void Compile_SPECIAL_DDIVU ( void );
void Compile_SPECIAL_ADD ( void );
void Compile_SPECIAL_ADDU ( void );
void Compile_SPECIAL_SUB ( void );
void Compile_SPECIAL_SUBU ( void );
void Compile_SPECIAL_AND ( void );
void Compile_SPECIAL_OR ( void );
void Compile_SPECIAL_XOR ( void );
void Compile_SPECIAL_NOR ( void );
void Compile_SPECIAL_SLT ( void );
void Compile_SPECIAL_SLTU ( void );
void Compile_SPECIAL_DADD ( void );
void Compile_SPECIAL_DADDU ( void );
void Compile_SPECIAL_DSUB ( void );
void Compile_SPECIAL_DSUBU ( void );
void Compile_SPECIAL_DSLL ( void );
void Compile_SPECIAL_DSRL ( void );
void Compile_SPECIAL_DSRA ( void );
void Compile_SPECIAL_DSLL32 ( void );
void Compile_SPECIAL_DSRL32 ( void );
void Compile_SPECIAL_DSRA32 ( void );
/************************** COP0 functions **************************/
void Compile_COP0_MF ( void );
void Compile_COP0_MT ( void );
/************************** COP0 CO functions ***********************/
void Compile_COP0_CO_TLBR ( void );
void Compile_COP0_CO_TLBWI ( void );
void Compile_COP0_CO_TLBWR ( void );
void Compile_COP0_CO_TLBP ( void );
void Compile_COP0_CO_ERET ( void );
/************************** COP1 functions **************************/
void Compile_COP1_MF ( void );
void Compile_COP1_DMF ( void );
void Compile_COP1_CF ( void );
void Compile_COP1_MT ( void );
void Compile_COP1_DMT ( void );
void Compile_COP1_CT ( void );
/************************** COP1: S functions ************************/
void Compile_COP1_S_ADD ( void );
void Compile_COP1_S_SUB ( void );
void Compile_COP1_S_MUL ( void );
void Compile_COP1_S_DIV ( void );
void Compile_COP1_S_ABS ( void );
void Compile_COP1_S_NEG ( void );
void Compile_COP1_S_SQRT ( void );
void Compile_COP1_S_MOV ( void );
void Compile_COP1_S_TRUNC_L ( void );
void Compile_COP1_S_CEIL_L ( void ); //added by Witten
void Compile_COP1_S_FLOOR_L ( void ); //added by Witten
void Compile_COP1_S_ROUND_W ( void );
void Compile_COP1_S_TRUNC_W ( void );
void Compile_COP1_S_CEIL_W ( void ); //added by Witten
void Compile_COP1_S_FLOOR_W ( void );
void Compile_COP1_S_CVT_D ( void );
void Compile_COP1_S_CVT_W ( void );
void Compile_COP1_S_CVT_L ( void );
void Compile_COP1_S_CMP ( void );
/************************** COP1: D functions ************************/
void Compile_COP1_D_ADD ( void );
void Compile_COP1_D_SUB ( void );
void Compile_COP1_D_MUL ( void );
void Compile_COP1_D_DIV ( void );
void Compile_COP1_D_ABS ( void );
void Compile_COP1_D_NEG ( void );
void Compile_COP1_D_SQRT ( void );
void Compile_COP1_D_MOV ( void );
void Compile_COP1_D_TRUNC_L ( void ); //added by Witten
void Compile_COP1_D_CEIL_L ( void ); //added by Witten
void Compile_COP1_D_FLOOR_L ( void ); //added by Witten
void Compile_COP1_D_ROUND_W ( void );
void Compile_COP1_D_TRUNC_W ( void );
void Compile_COP1_D_CEIL_W ( void ); //added by Witten
void Compile_COP1_D_FLOOR_W ( void ); //added by Witten
void Compile_COP1_D_CVT_S ( void );
void Compile_COP1_D_CVT_W ( void );
void Compile_COP1_D_CVT_L ( void );
void Compile_COP1_D_CMP ( void );
/************************** COP1: W functions ************************/
void Compile_COP1_W_CVT_S ( void );
void Compile_COP1_W_CVT_D ( void );
/************************** COP1: L functions ************************/
void Compile_COP1_L_CVT_S ( void );
void Compile_COP1_L_CVT_D ( void );
/************************** Other functions **************************/
void Compile_UnknownOpcode ( void );
void CompileReadTLBMiss (CCodeSection * Section, int AddressReg, int LookUpReg );
void CompileWriteTLBMiss (CCodeSection * Section, int AddressReg, int LookUpReg );
private:
CCodeSection * m_Section;
};

View File

@ -10,6 +10,20 @@ CBlockInfo::CBlockInfo(DWORD VAddr, BYTE * RecompPos) :
{
ParentSection.AddParent(NULL);
ParentSection.LinkAllowed = false;
AnalyseBlock();
}
void CBlockInfo::AnalyseBlock ( void )
{
/*if (bLinkBlocks())
{
CCodeSection * Section = &ParentSection;
if (!CreateSectionLinkage (Section)) { return false; }
DetermineLoop(Section,CCodeSection::GetNewTestValue(),CCodeSection::GetNewTestValue(), Section->SectionID);
while (FixConstants(Section,CCodeSection::GetNewTestValue())) {}
}
return true;*/
}
CJumpInfo::CJumpInfo()
@ -23,7 +37,7 @@ CJumpInfo::CJumpInfo()
DoneDelaySlot = false;
}
CBlockSection::CBlockSection( CBlockInfo * _BlockInfo, DWORD StartAddr, DWORD ID) :
CCodeSection::CCodeSection( CBlockInfo * _BlockInfo, DWORD StartAddr, DWORD ID) :
BlockInfo(_BlockInfo)
{
JumpSection = NULL;
@ -38,10 +52,10 @@ CBlockSection::CBlockSection( CBlockInfo * _BlockInfo, DWORD StartAddr, DWORD ID
DelaySlotSection = false;
StartPC = StartAddr;
CompilePC = StartAddr;
m_CompilePC = StartAddr;
}
bool CBlockSection::IsAllParentLoops(CBlockSection * Parent, bool IgnoreIfCompiled, DWORD Test)
bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test)
{
if (IgnoreIfCompiled && Parent->CompiledLocation != NULL) { return true; }
if (!InLoop) { return false; }
@ -53,13 +67,13 @@ bool CBlockSection::IsAllParentLoops(CBlockSection * Parent, bool IgnoreIfCompil
for (SECTION_LIST::iterator iter = Parent->ParentSection.begin(); iter != Parent->ParentSection.end(); iter++)
{
CBlockSection * ParentSection = *iter;
CCodeSection * ParentSection = *iter;
if (!IsAllParentLoops(ParentSection,IgnoreIfCompiled,Test)) { return false; }
}
return true;
}
void CBlockSection::UnlinkParent( CBlockSection * Parent, bool AllowDelete, bool ContinueSection )
void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool ContinueSection )
{
if (this == NULL)
{
@ -69,7 +83,7 @@ void CBlockSection::UnlinkParent( CBlockSection * Parent, bool AllowDelete, bool
SECTION_LIST::iterator iter = ParentSection.begin();
while ( iter != ParentSection.end())
{
CBlockSection * ParentIter = *iter;
CCodeSection * ParentIter = *iter;
if (ParentIter == Parent && (Parent->ContinueSection != this || Parent->JumpSection != this))
{
ParentSection.erase(iter);
@ -119,11 +133,11 @@ void CBlockSection::UnlinkParent( CBlockSection * Parent, bool AllowDelete, bool
}
}
CBlockSection::~CBlockSection ( void )
CCodeSection::~CCodeSection ( void )
{
while (ParentSection.size() > 0)
{
CBlockSection * Parent = *ParentSection.begin();
CCodeSection * Parent = *ParentSection.begin();
if (Parent->ContinueSection == this) { UnlinkParent(Parent, false, true); }
if (Parent->JumpSection == this) { UnlinkParent(Parent, false, false); }
}
@ -148,7 +162,7 @@ CBlockSection::~CBlockSection ( void )
}
}
DWORD CBlockSection::GetNewTestValue(void)
DWORD CCodeSection::GetNewTestValue(void)
{
static DWORD LastTest = 0;
if (LastTest == 0xFFFFFFFF) { LastTest = 0; }
@ -156,7 +170,7 @@ DWORD CBlockSection::GetNewTestValue(void)
return LastTest;
}
void CBlockSection::TestRegConstantStates( CRegInfo & Base, CRegInfo & Reg )
void CCodeSection::TestRegConstantStates( CRegInfo & Base, CRegInfo & Reg )
{
for (int count = 0; count < 32; count++) {
if (Reg.MipsRegState(count) != Base.MipsRegState(count)) {
@ -179,7 +193,7 @@ void CBlockSection::TestRegConstantStates( CRegInfo & Base, CRegInfo & Reg )
}
}
void CBlockSection::AddParent(CBlockSection * Parent )
void CCodeSection::AddParent(CCodeSection * Parent )
{
if (this == NULL) { return; }
if (Parent == NULL)
@ -220,7 +234,7 @@ void CBlockSection::AddParent(CBlockSection * Parent )
}
}
void CBlockSection::ResetX86Protection (void)
void CCodeSection::ResetX86Protection (void)
{
for (int count = 1; count < 10; count ++)
{

View File

@ -1,5 +1,5 @@
class CBlockSection;
typedef std::list<CBlockSection *> SECTION_LIST;
class CCodeSection;
typedef std::list<CCodeSection *> SECTION_LIST;
class CRegInfo
{
@ -122,19 +122,19 @@ public:
};
class CBlockInfo;
class CBlockSection
class CCodeSection
{
public:
CBlockSection( CBlockInfo * _BlockInfo, DWORD StartAddr, DWORD ID);
~CBlockSection( void );
CCodeSection( CBlockInfo * _BlockInfo, DWORD StartAddr, DWORD ID);
~CCodeSection( void );
CBlockInfo * const BlockInfo;
/* Block Connection info */
SECTION_LIST ParentSection;
CBlockSection * ContinueSection;
CBlockSection * JumpSection;
BYTE * CompiledLocation;
CCodeSection * ContinueSection;
CCodeSection * JumpSection;
BYTE * CompiledLocation;
DWORD SectionID;
DWORD Test;
@ -144,7 +144,6 @@ public:
bool DelaySlotSection;
DWORD StartPC;
DWORD CompilePC;
/* Register Info */
CRegInfo RegStart;
@ -154,9 +153,13 @@ public:
CJumpInfo Jump;
CJumpInfo Cont;
void AddParent ( CBlockSection * Parent );
void UnlinkParent ( CBlockSection * Parent, bool AllowDelete, bool ContinueLink );
bool IsAllParentLoops ( CBlockSection * Parent, bool IgnoreIfCompiled, DWORD Test );
//Information about the opcode current being compiled
DWORD m_CompilePC;
OPCODE m_CompileOpcode;
void AddParent ( CCodeSection * Parent );
void UnlinkParent ( CCodeSection * Parent, bool AllowDelete, bool ContinueLink );
bool IsAllParentLoops ( CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test );
void ResetX86Protection ( void );
static DWORD GetNewTestValue ( void );
@ -234,12 +237,15 @@ public:
DWORD EndVAddr;
BYTE * CompiledLocation;
int NoOfSections;
CBlockSection ParentSection;
CCodeSection ParentSection;
EXIT_LIST ExitInfo;
private:
void AnalyseBlock ( void );
};
typedef struct {
CBlockSection * Parent;
CCodeSection * Parent;
CJumpInfo * JumpInfo;
} BLOCK_PARENT;

View File

@ -14,6 +14,8 @@ CN64Rom * _Rom; //The current rom that this system is executing.. it
CAudio * _Audio;
CMemoryLabel * _Labels;
CSystemTimer * _SystemTimer;
CTransVaddr * _TransVaddr;
MIPS_DWORD * _GPR, * _FPR, * _RegHI, * _RegLO;
DWORD * _PROGRAM_COUNTER, * _CP0, * _RegMI, * _LLBit,

View File

@ -11,6 +11,7 @@ extern CN64Rom * _Rom; //The current rom that this system is executin
extern CAudio * _Audio;
extern CMemoryLabel * _Labels;
extern CSystemTimer * _SystemTimer;
extern CTransVaddr * _TransVaddr;
extern MIPS_DWORD * _GPR, * _FPR, * _RegHI, * _RegLO;

View File

@ -434,22 +434,6 @@ SOURCE=".\N64 System\C Core\FlashRam.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter CPU.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter Ops 32.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter Ops 32.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Interpreter Ops.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\C Core\Logging.cpp"
# End Source File
# Begin Source File
@ -482,10 +466,6 @@ SOURCE="N64 System\C Core\Recompiler Fpu Ops.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Recompiler Ops.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Registers.cpp"
# End Source File
# Begin Source File
@ -534,9 +514,33 @@ SOURCE="N64 System\Recompiler\Recompiler Class.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Recompiler\Recompiler Memory.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Recompiler\Recompiler Ops.cpp"
# End Source File
# Begin Source File
SOURCE="N64 System\Recompiler\Section Info.cpp"
# End Source File
# End Group
# Begin Group "Interpreter Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter CPU.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter Ops 32.cpp"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter Ops.cpp"
# End Source File
# End Group
# Begin Source File
SOURCE="N64 System\Cheat Class.cpp"
@ -968,6 +972,10 @@ SOURCE="N64 System\Mips\System Timing.h"
SOURCE="N64 System\Mips\TLB Class.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Mips\TranslateVaddr.h"
# End Source File
# End Group
# Begin Group "C Core Headers"
@ -1026,14 +1034,6 @@ SOURCE="N64 System\C Core\Flashram.h"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Interpreter CPU.h"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Interpreter Ops.h"
# End Source File
# Begin Source File
SOURCE="N64 System\C Core\Logging.h"
# End Source File
# Begin Source File
@ -1146,9 +1146,33 @@ SOURCE="N64 System\Recompiler\Recompiler Class.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Recompiler\Recompiler Memory.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Recompiler\Recompiler Ops.h"
# End Source File
# Begin Source File
SOURCE="N64 System\Recompiler\Section Info.h"
# End Source File
# End Group
# Begin Group "Interpreter Headers"
# PROP Default_Filter ""
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter CPU.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter Ops 32.h"
# End Source File
# Begin Source File
SOURCE=".\N64 System\Interpreter\Interpreter Ops.h"
# End Source File
# End Group
# Begin Source File
SOURCE="N64 System\Cheat Class.h"