mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
DSP LLE Jit, joined work with XK and skidu.
VERY EXPERIMENTAL DON'T EXPECT HIGH PERFORMANCE!. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5288 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -157,8 +157,7 @@ void AICallback(u64 userdata, int cyclesLate)
|
||||
// DSP/CPU timeslicing.
|
||||
void DSPCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
// ~1/6th as many cycles as the period PPC-side.
|
||||
CPluginManager::GetInstance().GetDSP()->DSP_Update(DSP_PERIOD / 6);
|
||||
CPluginManager::GetInstance().GetDSP()->DSP_Update(DSP_PERIOD + cyclesLate);
|
||||
CoreTiming::ScheduleEvent(DSP_PERIOD - cyclesLate, et_DSP);
|
||||
}
|
||||
|
||||
|
||||
@@ -523,11 +523,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\DSPJit.cpp"
|
||||
RelativePath=".\Src\DSPEmitter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\DSPJit.h"
|
||||
RelativePath=".\Src\DSPEmitter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __DSPCOMMON_H
|
||||
#define __DSPCOMMON_H
|
||||
#include "CommonTypes.h"
|
||||
typedef u16 UDSPInstruction;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Common.h"
|
||||
#include "Thread.h"
|
||||
#include "DSPCore.h"
|
||||
#include "DSPEmitter.h"
|
||||
#include "DSPHost.h"
|
||||
#include "DSPAnalyzer.h"
|
||||
#include "MemoryUtil.h"
|
||||
@@ -36,6 +37,7 @@
|
||||
SDSP g_dsp;
|
||||
DSPBreakpoints dsp_breakpoints;
|
||||
DSPCoreState core_state = DSPCORE_RUNNING;
|
||||
DSPEmitter *jit = NULL;
|
||||
Common::Event step_event;
|
||||
|
||||
static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
|
||||
@@ -65,10 +67,12 @@ static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DSPCore_Init(const char *irom_filename, const char *coef_filename)
|
||||
bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
|
||||
bool bUsingJIT)
|
||||
{
|
||||
g_dsp.step_counter = 0;
|
||||
|
||||
jit = NULL;
|
||||
|
||||
g_dsp.irom = (u16*)AllocateMemoryPages(DSP_IROM_BYTE_SIZE);
|
||||
g_dsp.iram = (u16*)AllocateMemoryPages(DSP_IRAM_BYTE_SIZE);
|
||||
g_dsp.dram = (u16*)AllocateMemoryPages(DSP_DRAM_BYTE_SIZE);
|
||||
@@ -124,7 +128,13 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename)
|
||||
// Mostly keep IRAM write protected. We unprotect only when DMA-ing
|
||||
// in new ucodes.
|
||||
WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
|
||||
// Initialize JIT, if necessary
|
||||
if(bUsingJIT)
|
||||
jit = new DSPEmitter();
|
||||
|
||||
DSPAnalyzer::Analyze();
|
||||
|
||||
step_event.Init();
|
||||
|
||||
return true;
|
||||
@@ -132,6 +142,10 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename)
|
||||
|
||||
void DSPCore_Shutdown()
|
||||
{
|
||||
if(jit) {
|
||||
delete jit;
|
||||
jit = NULL;
|
||||
}
|
||||
step_event.Shutdown();
|
||||
FreeMemoryPages(g_dsp.irom, DSP_IROM_BYTE_SIZE);
|
||||
FreeMemoryPages(g_dsp.iram, DSP_IRAM_BYTE_SIZE);
|
||||
@@ -214,10 +228,14 @@ void DSPCore_CheckExceptions()
|
||||
}
|
||||
}
|
||||
|
||||
// Delegate to JIT (when it is written) or interpreter as appropriate.
|
||||
// Delegate to JIT or interpreter as appropriate.
|
||||
// Handle state changes and stepping.
|
||||
int DSPCore_RunCycles(int cycles)
|
||||
{
|
||||
if(jit) {
|
||||
jit->RunBlock(cycles);
|
||||
return 0;
|
||||
}
|
||||
while (cycles > 0) {
|
||||
reswitch:
|
||||
switch (core_state)
|
||||
@@ -266,3 +284,8 @@ void DSPCore_Step()
|
||||
if (core_state == DSPCORE_STEPPING)
|
||||
step_event.Set();
|
||||
}
|
||||
|
||||
void CompileCurrent() {
|
||||
jit->Compile(g_dsp.pc);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Thread.h"
|
||||
|
||||
#include "DSPBreakpoints.h"
|
||||
#include "DSPEmitter.h"
|
||||
|
||||
#define DSP_IRAM_BYTE_SIZE 0x2000
|
||||
#define DSP_IRAM_SIZE 0x1000
|
||||
@@ -233,8 +234,10 @@ struct SDSP
|
||||
|
||||
extern SDSP g_dsp;
|
||||
extern DSPBreakpoints dsp_breakpoints;
|
||||
extern DSPEmitter *jit;
|
||||
|
||||
bool DSPCore_Init(const char *irom_filename, const char *coef_filename);
|
||||
bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
|
||||
bool bUsingJIT);
|
||||
|
||||
void DSPCore_Reset();
|
||||
void DSPCore_Shutdown(); // Frees all allocated memory.
|
||||
@@ -245,6 +248,8 @@ void DSPCore_CheckExceptions();
|
||||
// sets a flag in the pending exception register.
|
||||
void DSPCore_SetException(u8 level);
|
||||
|
||||
void CompileCurrent();
|
||||
|
||||
enum DSPCoreState
|
||||
{
|
||||
DSPCORE_RUNNING = 0,
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
// Copyright (C) 2010 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "DSPEmitter.h"
|
||||
#include "DSPMemoryMap.h"
|
||||
#include "DSPCore.h"
|
||||
#include "DSPInterpreter.h"
|
||||
#include "DSPAnalyzer.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
|
||||
#define BLOCK_SIZE 250
|
||||
|
||||
using namespace Gen;
|
||||
|
||||
DSPEmitter::DSPEmitter()
|
||||
{
|
||||
m_compiledCode = NULL;
|
||||
|
||||
AllocCodeSpace(COMPILED_CODE_SIZE);
|
||||
|
||||
blocks = new CompiledCode[MAX_BLOCKS];
|
||||
endBlock = new bool[MAX_BLOCKS];
|
||||
|
||||
for(int i = 0x0000; i < MAX_BLOCKS; i++)
|
||||
{
|
||||
blocks[i] = CompileCurrent;
|
||||
blockSize[i] = 0;
|
||||
endBlock[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
DSPEmitter::~DSPEmitter()
|
||||
{
|
||||
delete[] blocks;
|
||||
delete[] endBlock;
|
||||
FreeCodeSpace();
|
||||
}
|
||||
|
||||
void DSPEmitter::ClearIRAM() {
|
||||
// TODO: Does not clear codespace
|
||||
for(int i = 0x0000; i < 0x1000; i++)
|
||||
{
|
||||
blocks[i] = CompileCurrent;
|
||||
blockSize[i] = 0;
|
||||
endBlock[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEmitter::WriteCallInterpreter(UDSPInstruction inst)
|
||||
{
|
||||
const DSPOPCTemplate *tinst = GetOpTemplate(inst);
|
||||
|
||||
// Call extended
|
||||
if (tinst->extended) {
|
||||
if ((inst >> 12) == 0x3) {
|
||||
if (! extOpTable[inst & 0x7F]->jitFunc) {
|
||||
ABI_CallFunctionC16((void*)extOpTable[inst & 0x7F]->intFunc, inst);
|
||||
} else {
|
||||
(this->*extOpTable[inst & 0x7F]->jitFunc)(inst);
|
||||
}
|
||||
} else {
|
||||
if (!extOpTable[inst & 0xFF]->jitFunc) {
|
||||
ABI_CallFunctionC16((void*)extOpTable[inst & 0xFF]->intFunc, inst);
|
||||
} else {
|
||||
(this->*extOpTable[inst & 0xFF]->jitFunc)(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main instruction
|
||||
if (!opTable[inst]->jitFunc)
|
||||
ABI_CallFunctionC16((void*)opTable[inst]->intFunc, inst);
|
||||
else
|
||||
(this->*opTable[inst]->jitFunc)(inst);
|
||||
|
||||
// Backlog
|
||||
// TODO if for jit
|
||||
if (tinst->extended) {
|
||||
ABI_CallFunction((void*)applyWriteBackLog);
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEmitter::unknown_instruction(UDSPInstruction inst)
|
||||
{
|
||||
PanicAlert("unknown_instruction %04x - Fix me ;)", inst);
|
||||
}
|
||||
|
||||
void DSPEmitter::Default(UDSPInstruction _inst)
|
||||
{
|
||||
WriteCallInterpreter(_inst);
|
||||
}
|
||||
|
||||
const u8 *DSPEmitter::Compile(int start_addr) {
|
||||
AlignCode16();
|
||||
const u8 *entryPoint = GetCodePtr();
|
||||
ABI_PushAllCalleeSavedRegsAndAdjustStack();
|
||||
|
||||
int addr = start_addr;
|
||||
|
||||
while (addr < start_addr + BLOCK_SIZE)
|
||||
{
|
||||
UDSPInstruction inst = dsp_imem_read(addr);
|
||||
const DSPOPCTemplate *opcode = GetOpTemplate(inst);
|
||||
|
||||
// Check for interrupts and exceptions
|
||||
TEST(8, M(&g_dsp.exceptions), Imm8(0xff));
|
||||
FixupBranch skipCheck = J_CC(CC_Z);
|
||||
|
||||
ABI_CallFunction((void *)&DSPCore_CheckExceptions);
|
||||
|
||||
MOV(32, R(EAX), M(&g_dsp.exception_in_progress));
|
||||
CMP(32, R(EAX), Imm32(0));
|
||||
FixupBranch noExceptionOccurred = J_CC(CC_L);
|
||||
|
||||
ABI_CallFunction((void *)DSPInterpreter::HandleLoop);
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
RET();
|
||||
|
||||
SetJumpTarget(skipCheck);
|
||||
SetJumpTarget(noExceptionOccurred);
|
||||
|
||||
// Increment PC
|
||||
ADD(16, M(&(g_dsp.pc)), Imm16(1));
|
||||
|
||||
WriteCallInterpreter(inst);
|
||||
|
||||
blockSize[start_addr]++;
|
||||
|
||||
// Handle loop condition. Change to TEST
|
||||
MOVZX(32, 16, EAX, M(&(g_dsp.r[DSP_REG_ST2])));
|
||||
CMP(32, R(EAX), Imm32(0));
|
||||
FixupBranch rLoopAddressExit = J_CC(CC_LE);
|
||||
|
||||
MOVZX(32, 16, EAX, M(&(g_dsp.r[DSP_REG_ST3])));
|
||||
CMP(32, R(EAX), Imm32(0));
|
||||
FixupBranch rLoopCounterExit = J_CC(CC_LE);
|
||||
|
||||
// These functions branch and therefore only need to be called in the end
|
||||
// of each block and in this order
|
||||
ABI_CallFunction((void *)&DSPInterpreter::HandleLoop);
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
RET();
|
||||
|
||||
SetJumpTarget(rLoopAddressExit);
|
||||
SetJumpTarget(rLoopCounterExit);
|
||||
|
||||
// End the block where the loop ends
|
||||
if ((inst & 0xffe0) == 0x0060 || (inst & 0xff00) == 0x1100) {
|
||||
// BLOOP, BLOOPI
|
||||
endBlock[dsp_imem_read(addr + 1)] = true;
|
||||
} else if ((inst & 0xffe0) == 0x0040 || (inst & 0xff00) == 0x1000) {
|
||||
// LOOP, LOOPI
|
||||
endBlock[addr + 1] = true;
|
||||
}
|
||||
|
||||
if (opcode->branch || endBlock[addr]
|
||||
|| DSPAnalyzer::code_flags[addr] & DSPAnalyzer::CODE_IDLE_SKIP)
|
||||
break;
|
||||
|
||||
addr += opcode->size;
|
||||
}
|
||||
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
RET();
|
||||
|
||||
blocks[start_addr] = (CompiledCode)entryPoint;
|
||||
|
||||
return entryPoint;
|
||||
}
|
||||
|
||||
void STACKALIGN DSPEmitter::RunBlock(int cycles)
|
||||
{
|
||||
static int idleskip = 0;
|
||||
// Trigger an external interrupt at the start of the cycle
|
||||
u16 block_cycles = 501;
|
||||
|
||||
while (!(g_dsp.cr & CR_HALT))
|
||||
{
|
||||
if (block_cycles > 500)
|
||||
{
|
||||
if(g_dsp.cr & CR_EXTERNAL_INT)
|
||||
DSPCore_CheckExternalInterrupt();
|
||||
block_cycles = 0;
|
||||
}
|
||||
|
||||
// Compile the block if needed
|
||||
if (blocks[g_dsp.pc] == CompileCurrent)
|
||||
{
|
||||
blockSize[g_dsp.pc] = 0;
|
||||
blocks[g_dsp.pc]();
|
||||
}
|
||||
|
||||
// Execute the block if we have enough cycles
|
||||
if (cycles > blockSize[g_dsp.pc])
|
||||
{
|
||||
u16 start_addr = g_dsp.pc;
|
||||
if (idleskip % 100 > 95 && (DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)) {
|
||||
block_cycles = 0;
|
||||
} else
|
||||
blocks[g_dsp.pc]();
|
||||
|
||||
idleskip++;
|
||||
|
||||
if (idleskip % 500 == 0)
|
||||
idleskip = 0;
|
||||
|
||||
block_cycles += blockSize[start_addr];
|
||||
cycles -= blockSize[start_addr];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _DSPEMITTER_H
|
||||
#define _DSPEMITTER_H
|
||||
|
||||
#include "DSPCommon.h"
|
||||
#include "x64Emitter.h"
|
||||
|
||||
#define COMPILED_CODE_SIZE sizeof(void *) * 0x200000
|
||||
|
||||
#define MAX_BLOCKS 0x10000
|
||||
|
||||
typedef void (*CompiledCode)();
|
||||
|
||||
class DSPEmitter : public Gen::XCodeBlock
|
||||
{
|
||||
CompiledCode *blocks;
|
||||
u16 blockSize[0x10000];
|
||||
bool *endBlock;
|
||||
public:
|
||||
DSPEmitter();
|
||||
~DSPEmitter();
|
||||
|
||||
const u8 *m_compiledCode;
|
||||
|
||||
void WriteCallInterpreter(UDSPInstruction inst);
|
||||
void unknown_instruction(UDSPInstruction inst);
|
||||
void Default(UDSPInstruction _inst);
|
||||
void ClearIRAM();
|
||||
const u8 *Compile(int start_addr);
|
||||
|
||||
void STACKALIGN RunBlock(int cycles);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DSPEmitter);
|
||||
|
||||
// Memory helper functions
|
||||
void increment_addr_reg(int reg);
|
||||
void decrement_addr_reg(int reg);
|
||||
void increase_addr_reg(int reg);
|
||||
void decrease_addr_reg(int reg);
|
||||
void ext_dmem_write(u32 src, u32 dest);
|
||||
u16 ext_dmem_read(u16 addr);
|
||||
void writeAxAcc(const UDSPInstruction opc);
|
||||
|
||||
// Ext commands
|
||||
void l(const UDSPInstruction opc);
|
||||
void ln(const UDSPInstruction opc);
|
||||
void ls(const UDSPInstruction opc);
|
||||
void lsn(const UDSPInstruction opc);
|
||||
void lsm(const UDSPInstruction opc);
|
||||
void lsnm(const UDSPInstruction opc);
|
||||
void sl(const UDSPInstruction opc);
|
||||
void sln(const UDSPInstruction opc);
|
||||
void slm(const UDSPInstruction opc);
|
||||
void slnm(const UDSPInstruction opc);
|
||||
void s(const UDSPInstruction opc);
|
||||
void sn(const UDSPInstruction opc);
|
||||
void ld(const UDSPInstruction opc);
|
||||
void ldn(const UDSPInstruction opc);
|
||||
void ldm(const UDSPInstruction opc);
|
||||
void ldnm(const UDSPInstruction opc);
|
||||
void mv(const UDSPInstruction opc);
|
||||
void dr(const UDSPInstruction opc);
|
||||
void ir(const UDSPInstruction opc);
|
||||
void nr(const UDSPInstruction opc);
|
||||
void nop(const UDSPInstruction opc) {}
|
||||
};
|
||||
|
||||
|
||||
#endif // _DSPEMITTER_H
|
||||
|
||||
@@ -133,7 +133,7 @@ void gdsp_ifx_write(u16 addr, u16 val)
|
||||
if (val & 0x1)
|
||||
DSPHost_InterruptRequest();
|
||||
else
|
||||
INFO_LOG(DSPLLE, "Unknown Interrupt Request pc=%04x (%04x)", g_dsp.pc, val);
|
||||
WARN_LOG(DSPLLE, "Unknown Interrupt Request pc=%04x (%04x)", g_dsp.pc, val);
|
||||
break;
|
||||
|
||||
case DSP_DMBH:
|
||||
@@ -254,6 +254,9 @@ void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
|
||||
|
||||
NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, g_dsp.iram_crc);
|
||||
|
||||
if (jit)
|
||||
jit->ClearIRAM();
|
||||
|
||||
DSPAnalyzer::Analyze();
|
||||
}
|
||||
|
||||
|
||||
@@ -103,19 +103,23 @@ void Run()
|
||||
int checkInterrupt = 0;
|
||||
gdsp_running = true;
|
||||
while (!(g_dsp.cr & CR_HALT) && gdsp_running)
|
||||
{
|
||||
// Automatically let the other threads work if we're idle skipping
|
||||
if(DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)
|
||||
Common::YieldCPU();
|
||||
|
||||
Step();
|
||||
|
||||
// Turns out the less you check for external interrupts, the more
|
||||
// sound you hear, and it becomes slower
|
||||
checkInterrupt++;
|
||||
if(checkInterrupt == 500) { // <-- A completely arbitrary number. TODO: tweak
|
||||
DSPCore_CheckExternalInterrupt();
|
||||
checkInterrupt = 0;
|
||||
{
|
||||
if(jit)
|
||||
jit->RunBlock(1);
|
||||
else {
|
||||
// Automatically let the other threads work if we're idle skipping
|
||||
if(DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)
|
||||
Common::YieldCPU();
|
||||
|
||||
Step();
|
||||
|
||||
// Turns out the less you check for external interrupts, the more
|
||||
// sound you hear, and it becomes slower
|
||||
checkInterrupt++;
|
||||
if(checkInterrupt == 500) { // <-- Arbitrary number. TODO: tweak
|
||||
DSPCore_CheckExternalInterrupt();
|
||||
checkInterrupt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
gdsp_running = false;
|
||||
@@ -185,7 +189,8 @@ int RunCyclesDebug(int cycles)
|
||||
// Used by non-thread mode. Meant to be efficient.
|
||||
int RunCycles(int cycles)
|
||||
{
|
||||
// First, let's run a few cycles with no idle skipping so that things can progress a bit.
|
||||
// First, let's run a few cycles with no idle skipping so that things can
|
||||
// progress a bit.
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (g_dsp.cr & CR_HALT)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "DSPJit.h"
|
||||
|
||||
namespace DSPJit {
|
||||
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _DSPJIT_H
|
||||
#define _DSPJIT_H
|
||||
|
||||
namespace DSPJit {
|
||||
|
||||
// TODO(XK): Fill
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // _DSPJIT_H
|
||||
@@ -37,6 +37,7 @@ u16 dsp_dmem_read(u16 addr);
|
||||
inline u16 dsp_fetch_code()
|
||||
{
|
||||
u16 opc = dsp_imem_read(g_dsp.pc);
|
||||
|
||||
g_dsp.pc++;
|
||||
return opc;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,9 @@
|
||||
#ifndef _DSPTABLES_H
|
||||
#define _DSPTABLES_H
|
||||
|
||||
#include "Common.h"
|
||||
//nclude "Common.h"
|
||||
#include "DSPEmitter.h"
|
||||
#include "DSPCommon.h"
|
||||
|
||||
// The non-ADDR ones that end with _D are the opposite one - if the bit specify
|
||||
// ACC0, then ACC_D will be ACC1.
|
||||
@@ -67,9 +69,8 @@ enum partype_t
|
||||
#define OPTABLE_SIZE 0xffff + 1
|
||||
#define EXT_OPTABLE_SIZE 0xff + 1
|
||||
|
||||
typedef u16 UDSPInstruction;
|
||||
|
||||
typedef void (*dspInstFunc)(const UDSPInstruction);
|
||||
typedef void (*dspIntFunc)(const UDSPInstruction);
|
||||
typedef void (DSPEmitter::*dspJitFunc)(const UDSPInstruction);
|
||||
|
||||
struct param2_t
|
||||
{
|
||||
@@ -86,8 +87,8 @@ typedef struct
|
||||
u16 opcode;
|
||||
u16 opcode_mask;
|
||||
|
||||
dspInstFunc interpFunc;
|
||||
dspInstFunc jitFunc;
|
||||
dspIntFunc intFunc;
|
||||
dspJitFunc jitFunc;
|
||||
|
||||
u8 size;
|
||||
u8 param_count;
|
||||
@@ -141,11 +142,11 @@ inline void ExecuteInstruction(const UDSPInstruction inst)
|
||||
|
||||
if (tinst->extended) {
|
||||
if ((inst >> 12) == 0x3)
|
||||
extOpTable[inst & 0x7F]->interpFunc(inst);
|
||||
extOpTable[inst & 0x7F]->intFunc(inst);
|
||||
else
|
||||
extOpTable[inst & 0xFF]->interpFunc(inst);
|
||||
extOpTable[inst & 0xFF]->intFunc(inst);
|
||||
}
|
||||
tinst->interpFunc(inst);
|
||||
tinst->intFunc(inst);
|
||||
if (tinst->extended) {
|
||||
applyWriteBackLog();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
#include "../DSPMemoryMap.h"
|
||||
#include "../DSPEmitter.h"
|
||||
#include "../DSPIntExtOps.h" // remove when getting rid of writebacklog
|
||||
// See docs in the interpeter
|
||||
|
||||
inline bool IsSameMemArea(u16 a, u16 b)
|
||||
{
|
||||
//LM: tested on WII
|
||||
if ((a>>10)==(b>>10))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// DR $arR
|
||||
// xxxx xxxx 0000 01rr
|
||||
// Decrement addressing register $arR.
|
||||
void DSPEmitter::dr(const UDSPInstruction opc) {
|
||||
decrement_addr_reg(opc & 0x3);
|
||||
}
|
||||
|
||||
// IR $arR
|
||||
// xxxx xxxx 0000 10rr
|
||||
// Increment addressing register $arR.
|
||||
void DSPEmitter::ir(const UDSPInstruction opc) {
|
||||
increment_addr_reg(opc & 0x3);
|
||||
}
|
||||
|
||||
// NR $arR
|
||||
// xxxx xxxx 0000 11rr
|
||||
// Add corresponding indexing register $ixR to addressing register $arR.
|
||||
void DSPEmitter::nr(const UDSPInstruction opc) {
|
||||
u8 reg = opc & 0x3;
|
||||
|
||||
increase_addr_reg(reg);
|
||||
}
|
||||
|
||||
// MV $axD.D, $acS.S
|
||||
// xxxx xxxx 0001 ddss
|
||||
// Move value of $acS.S to the $axD.D.
|
||||
void DSPEmitter::mv(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x3) + DSP_REG_ACL0;
|
||||
u8 dreg = ((opc >> 2) & 0x3);
|
||||
|
||||
#if 0 //more tests
|
||||
if ((sreg >= DSP_REG_ACM0) && (g_dsp.r[DSP_REG_SR] & SR_40_MODE_BIT))
|
||||
writeToBackLog(0, dreg + DSP_REG_AXL0, ((u16)dsp_get_acc_h(sreg-DSP_REG_ACM0) & 0x0080) ? 0x8000 : 0x7fff);
|
||||
else
|
||||
#endif
|
||||
writeToBackLog(0, dreg + DSP_REG_AXL0, g_dsp.r[sreg]);
|
||||
}
|
||||
|
||||
// S @$arD, $acS.S
|
||||
// xxxx xxxx 001s s0dd
|
||||
// Store value of $acS.S in the memory pointed by register $arD.
|
||||
// Post increment register $arD.
|
||||
void DSPEmitter::s(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = opc & 0x3;
|
||||
u8 sreg = ((opc >> 3) & 0x3) + DSP_REG_ACL0;
|
||||
|
||||
ext_dmem_write(dreg, sreg);
|
||||
increment_addr_reg(dreg);
|
||||
}
|
||||
|
||||
// SN @$arD, $acS.S
|
||||
// xxxx xxxx 001s s1dd
|
||||
// Store value of register $acS.S in the memory pointed by register $arD.
|
||||
// Add indexing register $ixD to register $arD.
|
||||
void DSPEmitter::sn(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = opc & 0x3;
|
||||
u8 sreg = ((opc >> 3) & 0x3) + DSP_REG_ACL0;
|
||||
|
||||
ext_dmem_write(dreg, sreg);
|
||||
increase_addr_reg(dreg);
|
||||
}
|
||||
|
||||
// L $axD.D, @$arS
|
||||
// xxxx xxxx 01dd d0ss
|
||||
// Load $axD.D/$acD.D with value from memory pointed by register $arS.
|
||||
// Post increment register $arS.
|
||||
void DSPEmitter::l(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = opc & 0x3;
|
||||
u8 dreg = ((opc >> 3) & 0x7) + DSP_REG_AXL0;
|
||||
|
||||
if ((dreg >= DSP_REG_ACM0) && (g_dsp.r[DSP_REG_SR] & SR_40_MODE_BIT))
|
||||
{
|
||||
u16 val = ext_dmem_read(g_dsp.r[sreg]);
|
||||
writeToBackLog(0, dreg - DSP_REG_ACM0 + DSP_REG_ACH0, (val & 0x8000) ? 0xFFFF : 0x0000);
|
||||
writeToBackLog(1, dreg, val);
|
||||
writeToBackLog(2, dreg - DSP_REG_ACM0 + DSP_REG_ACL0, 0);
|
||||
increment_addr_reg(sreg);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[sreg]));
|
||||
increment_addr_reg(sreg);
|
||||
}
|
||||
}
|
||||
|
||||
// LN $axD.D, @$arS
|
||||
// xxxx xxxx 01dd d0ss
|
||||
// Load $axD.D/$acD.D with value from memory pointed by register $arS.
|
||||
// Add indexing register register $ixS to register $arS.
|
||||
void DSPEmitter::ln(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = opc & 0x3;
|
||||
u8 dreg = ((opc >> 3) & 0x7) + DSP_REG_AXL0;
|
||||
|
||||
if ((dreg >= DSP_REG_ACM0) && (g_dsp.r[DSP_REG_SR] & SR_40_MODE_BIT))
|
||||
{
|
||||
u16 val = ext_dmem_read(g_dsp.r[sreg]);
|
||||
writeToBackLog(0, dreg - DSP_REG_ACM0 + DSP_REG_ACH0, (val & 0x8000) ? 0xFFFF : 0x0000);
|
||||
writeToBackLog(1, dreg, val);
|
||||
writeToBackLog(2, dreg - DSP_REG_ACM0 + DSP_REG_ACL0, 0);
|
||||
increase_addr_reg(sreg);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[sreg]));
|
||||
increase_addr_reg(sreg);
|
||||
}
|
||||
}
|
||||
|
||||
// LS $axD.D, $acS.m
|
||||
// xxxx xxxx 10dd 000s
|
||||
// Load register $axD.D with value from memory pointed by register
|
||||
// $ar0. Store value from register $acS.m to memory location pointed by
|
||||
// register $ar3. Increment both $ar0 and $ar3.
|
||||
void DSPEmitter::ls(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR3, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR0]));
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
increment_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
|
||||
// LSN $axD.D, $acS.m
|
||||
// xxxx xxxx 10dd 010s
|
||||
// Load register $axD.D with value from memory pointed by register
|
||||
// $ar0. Store value from register $acS.m to memory location pointed by
|
||||
// register $ar3. Add corresponding indexing register $ix0 to addressing
|
||||
// register $ar0 and increment $ar3.
|
||||
void DSPEmitter::lsn(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR3, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR0]));
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
increase_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// LSM $axD.D, $acS.m
|
||||
// xxxx xxxx 10dd 100s
|
||||
// Load register $axD.D with value from memory pointed by register
|
||||
// $ar0. Store value from register $acS.m to memory location pointed by
|
||||
// register $ar3. Add corresponding indexing register $ix3 to addressing
|
||||
// register $ar3 and increment $ar0.
|
||||
void DSPEmitter::lsm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR3, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR0]));
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
increment_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// LSMN $axD.D, $acS.m
|
||||
// xxxx xxxx 10dd 110s
|
||||
// Load register $axD.D with value from memory pointed by register
|
||||
// $ar0. Store value from register $acS.m to memory location pointed by
|
||||
// register $ar3. Add corresponding indexing register $ix0 to addressing
|
||||
// register $ar0 and add corresponding indexing register $ix3 to addressing
|
||||
// register $ar3.
|
||||
void DSPEmitter::lsnm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR3, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR0]));
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
increase_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// SL $acS.m, $axD.D
|
||||
// xxxx xxxx 10dd 001s
|
||||
// Store value from register $acS.m to memory location pointed by register
|
||||
// $ar0. Load register $axD.D with value from memory pointed by register
|
||||
// $ar3. Increment both $ar0 and $ar3.
|
||||
void DSPEmitter::sl(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR0, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
increment_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// SLN $acS.m, $axD.D
|
||||
// xxxx xxxx 10dd 011s
|
||||
// Store value from register $acS.m to memory location pointed by register
|
||||
// $ar0. Load register $axD.D with value from memory pointed by register
|
||||
// $ar3. Add corresponding indexing register $ix0 to addressing register $ar0
|
||||
// and increment $ar3.
|
||||
void DSPEmitter::sln(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR0, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
increase_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// SLM $acS.m, $axD.D
|
||||
// xxxx xxxx 10dd 101s
|
||||
// Store value from register $acS.m to memory location pointed by register
|
||||
// $ar0. Load register $axD.D with value from memory pointed by register
|
||||
// $ar3. Add corresponding indexing register $ix3 to addressing register $ar3
|
||||
// and increment $ar0.
|
||||
void DSPEmitter::slm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR0, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
increment_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// SLMN $acS.m, $axD.D
|
||||
// xxxx xxxx 10dd 111s
|
||||
// Store value from register $acS.m to memory location pointed by register
|
||||
// $ar0. Load register $axD.D with value from memory pointed by register
|
||||
// $ar3. Add corresponding indexing register $ix0 to addressing register $ar0
|
||||
// and add corresponding indexing register $ix3 to addressing register $ar3.
|
||||
void DSPEmitter::slnm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 sreg = (opc & 0x1) + DSP_REG_ACM0;
|
||||
u8 dreg = ((opc >> 4) & 0x3) + DSP_REG_AXL0;
|
||||
|
||||
ext_dmem_write(DSP_REG_AR0, sreg);
|
||||
|
||||
writeToBackLog(0, dreg, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
increase_addr_reg(DSP_REG_AR0);
|
||||
}
|
||||
|
||||
// LD $ax0.d, $ax1.r, @$arS
|
||||
// xxxx xxxx 11dr 00ss
|
||||
// example for "nx'ld $AX0.L, $AX1.L, @$AR3"
|
||||
// Loads the word pointed by AR0 to AX0.H, then loads the word pointed by AR3
|
||||
// to AX0.L. Increments AR0 and AR3. If AR0 and AR3 point into the same
|
||||
// memory page (upper 6 bits of addr are the same -> games are not doing that!)
|
||||
// then the value pointed by AR0 is loaded to BOTH AX0.H and AX0.L. If AR0
|
||||
// points into an invalid memory page (ie 0x2000), then AX0.H keeps its old
|
||||
// value. (not implemented yet) If AR3 points into an invalid memory page, then
|
||||
// AX0.L gets the same value as AX0.H. (not implemented yet)
|
||||
void DSPEmitter::ld(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = (opc >> 5) & 0x1;
|
||||
u8 rreg = (opc >> 4) & 0x1;
|
||||
u8 sreg = opc & 0x3;
|
||||
|
||||
if (sreg != DSP_REG_AR3) {
|
||||
writeToBackLog(0, (dreg << 1) + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[sreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[sreg]));
|
||||
else
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increment_addr_reg(sreg);
|
||||
} else {
|
||||
writeToBackLog(0, rreg + DSP_REG_AXH0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[dreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
else
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increment_addr_reg(dreg);
|
||||
}
|
||||
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
}
|
||||
|
||||
// LDN $ax0.d, $ax1.r, @$arS
|
||||
// xxxx xxxx 11dr 01ss
|
||||
void DSPEmitter::ldn(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = (opc >> 5) & 0x1;
|
||||
u8 rreg = (opc >> 4) & 0x1;
|
||||
u8 sreg = opc & 0x3;
|
||||
|
||||
if (sreg != DSP_REG_AR3) {
|
||||
writeToBackLog(0, (dreg << 1) + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[sreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[sreg]));
|
||||
else
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increase_addr_reg(sreg);
|
||||
} else {
|
||||
writeToBackLog(0, rreg + DSP_REG_AXH0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[dreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
else
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increase_addr_reg(dreg);
|
||||
}
|
||||
|
||||
increment_addr_reg(DSP_REG_AR3);
|
||||
}
|
||||
|
||||
// LDM $ax0.d, $ax1.r, @$arS
|
||||
// xxxx xxxx 11dr 10ss
|
||||
void DSPEmitter::ldm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = (opc >> 5) & 0x1;
|
||||
u8 rreg = (opc >> 4) & 0x1;
|
||||
u8 sreg = opc & 0x3;
|
||||
|
||||
if (sreg != DSP_REG_AR3) {
|
||||
writeToBackLog(0, (dreg << 1) + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[sreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[sreg]));
|
||||
else
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increment_addr_reg(sreg);
|
||||
} else {
|
||||
writeToBackLog(0, rreg + DSP_REG_AXH0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[dreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
else
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increment_addr_reg(dreg);
|
||||
}
|
||||
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
}
|
||||
|
||||
// LDNM $ax0.d, $ax1.r, @$arS
|
||||
// xxxx xxxx 11dr 11ss
|
||||
void DSPEmitter::ldnm(const UDSPInstruction opc)
|
||||
{
|
||||
u8 dreg = (opc >> 5) & 0x1;
|
||||
u8 rreg = (opc >> 4) & 0x1;
|
||||
u8 sreg = opc & 0x3;
|
||||
|
||||
if (sreg != DSP_REG_AR3) {
|
||||
writeToBackLog(0, (dreg << 1) + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[sreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[sreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[sreg]));
|
||||
else
|
||||
writeToBackLog(1, (rreg << 1) + DSP_REG_AXL1, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increase_addr_reg(sreg);
|
||||
} else {
|
||||
writeToBackLog(0, rreg + DSP_REG_AXH0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
|
||||
if (IsSameMemArea(g_dsp.r[dreg], g_dsp.r[DSP_REG_AR3]))
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[dreg]));
|
||||
else
|
||||
writeToBackLog(1, rreg + DSP_REG_AXL0, ext_dmem_read(g_dsp.r[DSP_REG_AR3]));
|
||||
|
||||
increase_addr_reg(dreg);
|
||||
}
|
||||
|
||||
increase_addr_reg(DSP_REG_AR3);
|
||||
}
|
||||
|
||||
|
||||
void DSPEmitter::writeAxAcc(const UDSPInstruction opc) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
// Copyright (C) 2010 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _DSP_JIT_UTIL_H
|
||||
#define _DSP_JIT_UTIL_H
|
||||
|
||||
#include "../DSPMemoryMap.h"
|
||||
#include "../DSPEmitter.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
|
||||
using namespace Gen;
|
||||
|
||||
// HORRIBLE UGLINESS, someone please fix.
|
||||
// See http://code.google.com/p/dolphin-emu/source/detail?r=3125
|
||||
void DSPEmitter::increment_addr_reg(int reg)
|
||||
{
|
||||
ABI_PushAllCalleeSavedRegsAndAdjustStack();
|
||||
|
||||
// u16 tmb = g_dsp.r[DSP_REG_WR0 + reg];
|
||||
MOV(16, R(EAX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
|
||||
|
||||
// tmb = tmb | (tmb >> 8);
|
||||
MOV(16, R(EBX), R(EAX));
|
||||
SHR(16, R(EBX), Imm8(8));
|
||||
OR(16, R(EAX), R(EBX));
|
||||
|
||||
// tmb = tmb | (tmb >> 4);
|
||||
MOV(16, R(EBX), R(EAX));
|
||||
SHR(16, R(EBX), Imm8(4));
|
||||
OR(16, R(EAX), R(EBX));
|
||||
|
||||
// tmb = tmb | (tmb >> 2);
|
||||
MOV(16, R(EBX), R(EAX));
|
||||
SHR(16, R(EBX), Imm8(2));
|
||||
OR(16, R(EAX), R(EBX));
|
||||
|
||||
// tmb = tmb | (tmb >> 1);
|
||||
MOV(16, R(EBX), R(EAX));
|
||||
SHR(16, R(EBX), Imm8(1));
|
||||
OR(16, R(EAX), R(EBX));
|
||||
|
||||
// s16 tmp = g_dsp.r[reg];
|
||||
MOV(16, R(EBX), M(&g_dsp.r[reg]));
|
||||
|
||||
// if ((tmp & tmb) == tmb)
|
||||
AND(16, R(EAX), R(EBX));
|
||||
CMP(16, R(EAX), R(EBX));
|
||||
FixupBranch not_equal = J_CC(CC_NZ);
|
||||
|
||||
// tmp ^= g_dsp.r[DSP_REG_WR0 + reg];
|
||||
XOR(16, R(EBX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
|
||||
|
||||
FixupBranch end = J();
|
||||
SetJumpTarget(not_equal);
|
||||
// tmp++;
|
||||
ADD(16, R(EBX), Imm8(1));
|
||||
|
||||
SetJumpTarget(end);
|
||||
|
||||
// g_dsp.r[reg] = tmp;
|
||||
MOV(16, M(&g_dsp.r[reg]), R(EBX));
|
||||
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
|
||||
}
|
||||
|
||||
// See http://code.google.com/p/dolphin-emu/source/detail?r=3125
|
||||
void DSPEmitter::decrement_addr_reg(int reg)
|
||||
{
|
||||
ABI_PushAllCalleeSavedRegsAndAdjustStack();
|
||||
|
||||
// s16 tmp = g_dsp.r[reg];
|
||||
MOV(16, R(EAX), M(&g_dsp.r[reg]));
|
||||
|
||||
// if ((tmp & g_dsp.r[DSP_REG_WR0 + reg]) == 0)
|
||||
MOV(16, R(EBX), R(EAX));
|
||||
AND(16, R(EBX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
|
||||
CMP(16, R(EBX), Imm8(0));
|
||||
FixupBranch not_equal = J_CC(CC_NZ);
|
||||
|
||||
// tmp |= g_dsp.r[DSP_REG_WR0 + reg];
|
||||
OR(16, R(EAX), M(&g_dsp.r[DSP_REG_WR0 + reg]));
|
||||
|
||||
FixupBranch end = J();
|
||||
SetJumpTarget(not_equal);
|
||||
// tmp--;
|
||||
SUB(16, R(EAX), Imm8(1));
|
||||
|
||||
SetJumpTarget(end);
|
||||
|
||||
// g_dsp.r[reg] = tmp;
|
||||
MOV(16, M(&g_dsp.r[reg]), R(EAX));
|
||||
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
}
|
||||
|
||||
// Increase addr register according to the correspond ix register
|
||||
void DSPEmitter::increase_addr_reg(int reg)
|
||||
{
|
||||
|
||||
/*
|
||||
MOV(16, R(EAX), M(&g_dsp.r[DSP_REG_IX0 + reg]));
|
||||
|
||||
CMP(16, R(EAX), Imm16(0));
|
||||
FixupBranch end = J_CC(CC_Z);
|
||||
FixupBranch negValue = J_CC(CC_L);
|
||||
|
||||
ABI_CallFunctionC((void *)increment_addr_reg, reg);
|
||||
|
||||
FixupBranch posValue = J();
|
||||
|
||||
SetJumpTarget(negValue);
|
||||
ABI_CallFunctionC((void *)decrement_addr_reg, reg);
|
||||
|
||||
SetJumpTarget(posValue);
|
||||
SetJumpTarget(end);
|
||||
*/
|
||||
|
||||
// TODO: DO RIGHT!
|
||||
s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg];
|
||||
|
||||
if (value > 0) {
|
||||
for (int i = 0; i < value; i++) {
|
||||
increment_addr_reg(reg);
|
||||
}
|
||||
} else if (value < 0) {
|
||||
for (int i = 0; i < (int)(-value); i++) {
|
||||
decrement_addr_reg(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decrease addr register according to the correspond ix register
|
||||
void DSPEmitter::decrease_addr_reg(int reg)
|
||||
{
|
||||
// TODO: DO RIGHT!
|
||||
|
||||
s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg];
|
||||
|
||||
if (value > 0) {
|
||||
for (int i = 0; i < value; i++) {
|
||||
decrement_addr_reg(reg);
|
||||
}
|
||||
} else if (value < 0) {
|
||||
for (int i = 0; i < (int)(-value); i++) {
|
||||
increment_addr_reg(reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEmitter::ext_dmem_write(u32 dest, u32 src)
|
||||
{
|
||||
|
||||
u16 addr = g_dsp.r[dest];
|
||||
u16 val = g_dsp.r[src];
|
||||
switch (addr >> 12) {
|
||||
case 0x0: // 0xxx DRAM
|
||||
g_dsp.dram[addr & DSP_DRAM_MASK] = val;
|
||||
break;
|
||||
|
||||
case 0x1: // 1xxx COEF
|
||||
ERROR_LOG(DSPLLE, "Illegal write to COEF (pc = %02x)", g_dsp.pc);
|
||||
break;
|
||||
|
||||
case 0xf: // Fxxx HW regs
|
||||
// Can ext write to ifx?
|
||||
// gdsp_ifx_write(addr, val);
|
||||
ERROR_LOG(DSPLLE, "Illegal write to ifx (pc = %02x)", g_dsp.pc);
|
||||
break;
|
||||
|
||||
default: // Unmapped/non-existing memory
|
||||
ERROR_LOG(DSPLLE, "%04x DSP ERROR: Write to UNKNOWN (%04x) memory", g_dsp.pc, addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u16 DSPEmitter::ext_dmem_read(u16 addr)
|
||||
{
|
||||
switch (addr >> 12) {
|
||||
case 0x0: // 0xxx DRAM
|
||||
return g_dsp.dram[addr & DSP_DRAM_MASK];
|
||||
|
||||
case 0x1: // 1xxx COEF
|
||||
NOTICE_LOG(DSPLLE, "%04x : Coef Read @ %04x", g_dsp.pc, addr);
|
||||
return g_dsp.coef[addr & DSP_COEF_MASK];
|
||||
|
||||
case 0xf: // Fxxx HW regs
|
||||
// Can ext read from ifx?
|
||||
ERROR_LOG(DSPLLE, "Illegal read from ifx (pc = %02x)", g_dsp.pc);
|
||||
// return gdsp_ifx_read(addr);
|
||||
|
||||
default: // Unmapped/non-existing memory
|
||||
ERROR_LOG(DSPLLE, "%04x DSP ERROR: Read from UNKNOWN (%04x) memory", g_dsp.pc, addr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,12 +18,15 @@ files = [
|
||||
"DspIntLoadStore.cpp",
|
||||
"DspIntMisc.cpp",
|
||||
"DspIntMultiplier.cpp",
|
||||
"DSPJit.cpp",
|
||||
"DSPEmitter.cpp",
|
||||
"DSPCodeUtil.cpp",
|
||||
"LabelMap.cpp",
|
||||
"DSPInterpreter.cpp",
|
||||
"DSPCore.cpp",
|
||||
"DSPTables.cpp",
|
||||
"Jit/DSPJitExtOps.cpp",
|
||||
"Jit/DSPJitUtil.cpp",
|
||||
|
||||
]
|
||||
|
||||
acenv = env.Clone()
|
||||
|
||||
@@ -223,7 +223,7 @@ bool DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16
|
||||
break;
|
||||
}
|
||||
}
|
||||
const DSPOPCTemplate fake_op = {"CW", 0x0000, 0x0000, nop, nop, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, false};
|
||||
const DSPOPCTemplate fake_op = {"CW", 0x0000, 0x0000, nop, NULL, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, false};
|
||||
if (!opc)
|
||||
opc = &fake_op;
|
||||
|
||||
|
||||
@@ -303,7 +303,8 @@ unsigned short DSP_ReadControlRegister()
|
||||
void DSP_Update(int cycles)
|
||||
{
|
||||
// This is called OFTEN - better not do anything expensive!
|
||||
CDSPHandler::GetInstance().Update(cycles);
|
||||
// ~1/6th as many cycles as the period PPC-side.
|
||||
CDSPHandler::GetInstance().Update(cycles / 6);
|
||||
}
|
||||
|
||||
// The reason that we don't disable this entire
|
||||
|
||||
@@ -23,6 +23,7 @@ BEGIN_EVENT_TABLE(DSPConfigDialogLLE, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, DSPConfigDialogLLE::SettingsChanged)
|
||||
EVT_CHECKBOX(ID_ENABLE_DTK_MUSIC, DSPConfigDialogLLE::SettingsChanged)
|
||||
EVT_CHECKBOX(ID_ENABLE_THROTTLE, DSPConfigDialogLLE::SettingsChanged)
|
||||
EVT_CHECKBOX(ID_ENABLE_JIT, DSPConfigDialogLLE::SettingsChanged)
|
||||
EVT_CHOICE(ID_BACKEND, DSPConfigDialogLLE::BackendChanged)
|
||||
EVT_COMMAND_SCROLL(ID_VOLUME, DSPConfigDialogLLE::VolumeChanged)
|
||||
END_EVENT_TABLE()
|
||||
@@ -41,6 +42,7 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
|
||||
// Create items
|
||||
m_buttonEnableDTKMusic = new wxCheckBox(this, ID_ENABLE_DTK_MUSIC, wxT("Enable DTK Music"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_buttonEnableThrottle = new wxCheckBox(this, ID_ENABLE_THROTTLE, wxT("Enable Audio Throttle"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_buttonEnableJIT = new wxCheckBox(this, ID_ENABLE_JIT, wxT("Enable JIT Dynarec"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
wxStaticText *BackendText = new wxStaticText(this, wxID_ANY, wxT("Audio Backend"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_BackendSelection = new wxChoice(this, ID_BACKEND, wxDefaultPosition, wxSize(90, 20), wxArrayBackends, 0, wxDefaultValidator, wxEmptyString);
|
||||
|
||||
@@ -51,6 +53,7 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
|
||||
// Update values
|
||||
m_buttonEnableDTKMusic->SetValue(ac_Config.m_EnableDTKMusic ? true : false);
|
||||
m_buttonEnableThrottle->SetValue(ac_Config.m_EnableThrottle ? true : false);
|
||||
m_buttonEnableJIT->SetValue(ac_Config.m_EnableJIT ? true : false);
|
||||
|
||||
// Add tooltips
|
||||
m_buttonEnableDTKMusic->SetToolTip(wxT("This is used to play music tracks, like BGM."));
|
||||
@@ -58,6 +61,8 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
|
||||
wxT("Disabling this could cause abnormal game speed, such as too fast.\n")
|
||||
wxT("But sometimes enabling this could cause constant noise.\n")
|
||||
wxT("\nKeyboard Shortcut <TAB>: Hold down to instantly disable Throttle."));
|
||||
m_buttonEnableJIT->SetToolTip(wxT("Enables dynamic recompilation of DSP code.\n")
|
||||
wxT("Changing this will have no effect while the emulator is running!"));
|
||||
m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
|
||||
m_volumeSlider->SetToolTip(wxT("This setting only affects DSound and OpenAL."));
|
||||
|
||||
@@ -69,6 +74,7 @@ DSPConfigDialogLLE::DSPConfigDialogLLE(wxWindow *parent, wxWindowID id, const wx
|
||||
|
||||
sbSettings->Add(m_buttonEnableDTKMusic, 0, wxALL, 5);
|
||||
sbSettings->Add(m_buttonEnableThrottle, 0, wxALL, 5);
|
||||
sbSettings->Add(m_buttonEnableJIT, 0, wxALL, 5);
|
||||
|
||||
sBackend->Add(BackendText, 0, wxALIGN_CENTER|wxALL, 5);
|
||||
sBackend->Add(m_BackendSelection, 0, wxALL, 1);
|
||||
@@ -125,6 +131,7 @@ void DSPConfigDialogLLE::SettingsChanged(wxCommandEvent& event)
|
||||
{
|
||||
ac_Config.m_EnableDTKMusic = m_buttonEnableDTKMusic->GetValue();
|
||||
ac_Config.m_EnableThrottle = m_buttonEnableThrottle->GetValue();
|
||||
ac_Config.m_EnableJIT = m_buttonEnableJIT->GetValue();
|
||||
|
||||
#ifdef __APPLE__
|
||||
strncpy(ac_Config.sBackend, m_BackendSelection->GetStringSelection().mb_str(), 128);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user