DSP: build fixin', more movin', some comments.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3564 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-06-28 10:24:44 +00:00
parent 895b02f410
commit 5c7fc8ed7b
26 changed files with 201 additions and 259 deletions

View File

@ -413,6 +413,14 @@
RelativePath=".\Src\DspIntBranch.cpp"
>
</File>
<File
RelativePath=".\Src\DSPIntCCUtil.cpp"
>
</File>
<File
RelativePath=".\Src\DSPIntCCUtil.h"
>
</File>
<File
RelativePath=".\Src\DSPIntExtOps.cpp"
>
@ -494,6 +502,18 @@
RelativePath=".\Src\DSPHost.h"
>
</File>
<File
RelativePath=".\Src\DSPHWInterface.cpp"
>
</File>
<File
RelativePath=".\Src\DSPHWInterface.h"
>
</File>
<File
RelativePath=".\Src\DSPInterpreter.cpp"
>
</File>
<File
RelativePath=".\Src\DSPInterpreter.h"
>
@ -514,6 +534,14 @@
RelativePath=".\Src\DSPMemoryMap.h"
>
</File>
<File
RelativePath=".\Src\DSPStacks.cpp"
>
</File>
<File
RelativePath=".\Src\DSPStacks.h"
>
</File>
<File
RelativePath=".\Src\DSPTables.cpp"
>
@ -522,38 +550,6 @@
RelativePath=".\Src\DSPTables.h"
>
</File>
<File
RelativePath=".\Src\gdsp_condition_codes.cpp"
>
</File>
<File
RelativePath=".\Src\gdsp_condition_codes.h"
>
</File>
<File
RelativePath=".\Src\gdsp_interface.cpp"
>
</File>
<File
RelativePath=".\Src\gdsp_interface.h"
>
</File>
<File
RelativePath=".\Src\gdsp_interpreter.cpp"
>
</File>
<File
RelativePath=".\Src\gdsp_interpreter.h"
>
</File>
<File
RelativePath=".\Src\gdsp_registers.cpp"
>
</File>
<File
RelativePath=".\Src\gdsp_registers.h"
>
</File>
<File
RelativePath=".\Src\LabelMap.cpp"
>

View File

@ -18,8 +18,8 @@
#include "Common.h"
#include "DSPCore.h"
#include "DSPHost.h"
#include "gdsp_interface.h"
#include "gdsp_interpreter.h"
#include "DSPHWInterface.h"
#include "DSPInterpreter.h"
// The hardware adpcm decoder :)
s16 ADPCM_Step(u32& _rSamplePos)
@ -106,7 +106,12 @@ u16 dsp_read_accelerator()
u16 val;
// lets the "hardware" decode
// let's do the "hardware" decode
// DSP_FORMAT is interesting - the Zelda ucode seems to indicate that the bottom
// two bits specify the "read size" and the address multiplier.
// The bits above that may be things like sign extention and do/do not use ADPCM.
// It also remains to be figured out whether there's a difference between the usual
// accelerator "read address" and 0xd3.
switch (gdsp_ifx_regs[DSP_FORMAT])
{
case 0x00: // ADPCM audio
@ -129,9 +134,9 @@ u16 dsp_read_accelerator()
break;
}
// TODO: Take ifx GAIN into account.
// TODO: Take GAIN into account, whatever it is.
// check for loop
// Check for loop.
if (Address >= EndAddress)
{
// Set address back to start address.

View File

@ -28,8 +28,7 @@
#include "DSPAnalyzer.h"
#include "MemoryUtil.h"
#include "gdsp_interface.h"
#include "gdsp_registers.h"
#include "DSPHWInterface.h"
#include "DSPIntUtil.h"
SDSP g_dsp;

View File

@ -52,6 +52,95 @@
#define DSP_CR_TO_CPU 1
#define DSP_CR_FROM_CPU 0
// Register table taken from libasnd
#define DSP_REG_AR0 0x00 // address registers
#define DSP_REG_AR1 0x01
#define DSP_REG_AR2 0x02
#define DSP_REG_AR3 0x03
#define DSP_REG_IX0 0x04 // indexing registers (actually, mostly used as increments)
#define DSP_REG_IX1 0x05
#define DSP_REG_IX2 0x06
#define DSP_REG_IX3 0x07
#define DSP_REG_WR0 0x08 // address wrapping registers. should be initialized to 0xFFFF if not used.
#define DSP_REG_WR1 0x09
#define DSP_REG_WR2 0x0a
#define DSP_REG_WR3 0x0b
#define DSP_REG_ST0 0x0c // stacks.
#define DSP_REG_ST1 0x0d
#define DSP_REG_ST2 0x0e
#define DSP_REG_ST3 0x0f
#define DSP_REG_CR 0x12 // Seems to be the top 8 bits of LRS/SRS.
#define DSP_REG_SR 0x13
#define DSP_REG_PRODL 0x14 // product.
#define DSP_REG_PRODM 0x15
#define DSP_REG_PRODH 0x16
#define DSP_REG_PRODM2 0x17
#define DSP_REG_AXL0 0x18
#define DSP_REG_AXL1 0x19
#define DSP_REG_AXH0 0x1a
#define DSP_REG_AXH1 0x1b
#define DSP_REG_ACC0 0x1c // accumulator (global)
#define DSP_REG_ACC1 0x1d
#define DSP_REG_ACL0 0x1c // Low accumulator
#define DSP_REG_ACL1 0x1d
#define DSP_REG_ACM0 0x1e // Mid accumulator
#define DSP_REG_ACM1 0x1f
#define DSP_REG_ACH0 0x10 // Sign extended 8 bit register 0
#define DSP_REG_ACH1 0x11 // Sign extended 8 bit register 1
// Hardware registers address
#define DSP_REG_DSCR 0xffc9 // DSP DMA Control Reg
#define DSP_REG_DSBL 0xffcb // DSP DMA Block Length
#define DSP_REG_DSPA 0xffcd // DSP DMA DMEM Address
#define DSP_REG_DSMAH 0xffce // DSP DMA Mem Address H
#define DSP_REG_DSMAL 0xffcf // DSP DMA Mem Address L
#define DSP_REG_DIRQ 0xfffb // DSP Irq Rest
#define DSP_REG_DMBH 0xfffc // DSP Mailbox H
#define DSP_REG_DMBL 0xfffd // DSP Mailbox L
#define DSP_REG_CMBH 0xfffe // CPU Mailbox H
#define DSP_REG_CMBL 0xffff // CPU Mailbox L
#define DMA_TO_DSP 0
#define DMA_TO_CPU 1
// Stacks
#define DSP_STACK_C 0
#define DSP_STACK_D 1
// cr (Not g_dsp.r[CR]) bits
// See HW/DSP.cpp.
#define CR_HALT 0x0004
#define CR_EXTERNAL_INT 0x0002
// SR bits
#define SR_CARRY 0x0001
#define SR_2 0x0002 // overflow???
#define SR_ARITH_ZERO 0x0004
#define SR_SIGN 0x0008
#define SR_10 0x0010 // seem to be set by tst
#define SR_TOP2BITS 0x0020 // this is an odd one. (set by tst)
#define SR_LOGIC_ZERO 0x0040
#define SR_INT_ENABLE 0x0200 // Not 100% sure but duddie says so. This should replace the hack, if so.
#define SR_800 0x0800 // Appears in zelda - what is it? where in the zelda ucode?
#define SR_MUL_MODIFY 0x2000 // 1 = normal. 0 = x2 (M0, M2)
#define SR_40_MODE_BIT 0x4000 // 0 = "16", 1 = "40" (SET16, SET40) Controls sign extension when loading mid accums.
#define SR_MUL_UNSIGNED 0x8000 // 0 = normal. 1 = unsigned (CLR15, SET15) If set, treats operands as unsigned. Tested with mulx only so far.
// This should be the bits affected by CMP. Does not include logic zero.
#define SR_CMP_MASK 0x3f
struct SDSP
{
u16 r[32];

View File

@ -33,8 +33,8 @@
#include "DSPTables.h"
#include "DSPAnalyzer.h"
#include "DSPAccelerator.h"
#include "gdsp_interpreter.h"
#include "gdsp_interface.h"
#include "DSPInterpreter.h"
#include "DSPHWInterface.h"
void gdsp_dma();

View File

@ -20,8 +20,7 @@
// HELPER FUNCTIONS
#include "gdsp_condition_codes.h"
#include "gdsp_interpreter.h"
#include "DSPIntCCUtil.h"
#include "DSPCore.h"
#include "DSPInterpreter.h"

View File

@ -24,13 +24,8 @@
#include "Common.h"
#include "gdsp_registers.h"
namespace DSPInterpreter {
// SR flag defines.
#define SR_CMP_MASK 0x3f // Shouldn't this include 0x40?
bool CheckCondition(u8 _Condition);
int GetMultiplyModifier();

View File

@ -31,9 +31,7 @@
#include "DSPInterpreter.h"
#include "DSPCore.h"
#include "DSPMemoryMap.h"
#include "gdsp_interpreter.h"
#include "gdsp_registers.h"
#include "DSPStacks.h"
// #include "DSPIntExtOps.h"
// ---------------------------------------------------------------------------------------

View File

@ -25,8 +25,18 @@
namespace DSPInterpreter {
void Step();
void Run();
void RunCycles(int cycles);
void Stop();
void WriteCR(u16 val);
u16 ReadCR();
typedef void (*DSPInterpreterFunc)(const UDSPInstruction& opc);
// All the opcode functions.
void unknown(const UDSPInstruction& opc);
void call(const UDSPInstruction& opc);
void callr(const UDSPInstruction& opc);
@ -143,12 +153,11 @@ void srbith(const UDSPInstruction& opc);
// END OF FIXMEs
// TODO: PENDING IMPLEMENTATION / UNIMPLEMENTED
void tstaxl(const UDSPInstruction& opc);
void tstaxl(const UDSPInstruction& opc);
// The mysterious a100
// END OF UNIMPLEMENTED
// Helpers
inline void tsta(int reg);

View File

@ -25,10 +25,9 @@
#include <stdio.h>
#include "gdsp_interpreter.h"
#include "gdsp_interface.h"
#include "DSPInterpreter.h"
#include "DSPMemoryMap.h"
#include "DSPHWInterface.h"
#include "DSPCore.h"
u16 dsp_imem_read(u16 addr)

View File

@ -27,7 +27,7 @@
#define _GDSP_MEMORY_H
#include "Common.h"
#include "gdsp_interpreter.h"
#include "DSPInterpreter.h"
#include "DSPCore.h"
u16 dsp_imem_read(u16 addr);

View File

@ -26,9 +26,8 @@
#include "Common.h"
#include "DSPCore.h"
#include "gdsp_registers.h"
#include "gdsp_interpreter.h"
// #include "DSPInterpreter.h"
#include "DSPStacks.h"
// Stacks. The stacks are outside the DSP RAM, in dedicated hardware.

View File

@ -0,0 +1,34 @@
/*====================================================================
filename: gdsp_registers.h
project: GCemu
created: 2004-6-18
mail: duddie@walla.com
Copyright (c) 2005 Duddie & Tratax
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; either version 2
of the License, or (at your option) any later version.
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 for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
====================================================================*/
#ifndef _DSP_STACKS_H
#define _DSP_STACKS_H
#include "Common.h"
void dsp_reg_store_stack(u8 stack_reg, u16 val);
u16 dsp_reg_load_stack(u8 stack_reg);
#endif

View File

@ -18,8 +18,7 @@
// Additional copyrights go to Duddie and Tratax (c) 2004
#include "DSPInterpreter.h"
#include "gdsp_condition_codes.h"
#include "DSPIntCCUtil.h"
#include "DSPIntUtil.h"
// Arithmetic and accumulator control.

View File

@ -19,10 +19,11 @@
#include "DSPInterpreter.h"
#include "DSPCore.h"
#include "gdsp_condition_codes.h"
#include "DSPIntUtil.h"
#include "DSPMemoryMap.h"
#include "DSPStacks.h"
#include "DSPIntCCUtil.h"
#include "DSPIntUtil.h"
namespace DSPInterpreter {

View File

@ -21,8 +21,6 @@
#include "DSPInterpreter.h"
#include "DSPCore.h"
#include "gdsp_registers.h"
#include "DSPIntUtil.h"
namespace DSPInterpreter {

View File

@ -22,9 +22,8 @@
#include "DSPInterpreter.h"
#include "gdsp_condition_codes.h"
#include "DSPIntCCUtil.h"
#include "DSPIntUtil.h"
#include "gdsp_registers.h"
namespace DSPInterpreter {

View File

@ -5,13 +5,14 @@ Import('env')
files = [
"assemble.cpp",
"disassemble.cpp",
"gdsp_aram.cpp",
"gdsp_condition_codes.cpp",
"gdsp_ext_op.cpp",
"gdsp_interface.cpp",
"gdsp_interpreter.cpp",
"gdsp_memory.cpp",
"gdsp_registers.cpp",
"DSPAccelerator.cpp",
"DSPIntUtil.cpp",
"DSPIntCCUtil.cpp",
"DSPIntExtOps.cpp",
"DSPHWInterface.cpp",
"DSPInterpreter.cpp",
"DSPMemoryMap.cpp",
"DSPStacks.cpp",
"DSPAnalyzer.cpp",
"DspIntArithmetic.cpp",
"DspIntBranch.cpp",

View File

@ -1,61 +0,0 @@
// Copyright (C) 2003-2009 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/
/*====================================================================
filename: gdsp_interpreter.h
project: GCemu
created: 2004-6-18
mail: duddie@walla.com
Copyright (c) 2005 Duddie & Tratax
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; either version 2
of the License, or (at your option) any later version.
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 for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
====================================================================*/
#ifndef _GDSP_INTERPRETER_H
#define _GDSP_INTERPRETER_H
#include "Common.h"
namespace DSPInterpreter {
// steps through DSP code, returns false if error occured
void Step();
void Run();
void RunCycles(int cycles);
void Stop();
void WriteCR(u16 val);
u16 ReadCR();
} // namespace
#endif

View File

@ -1,118 +0,0 @@
/*====================================================================
filename: gdsp_registers.h
project: GCemu
created: 2004-6-18
mail: duddie@walla.com
Copyright (c) 2005 Duddie & Tratax
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; either version 2
of the License, or (at your option) any later version.
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 for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
====================================================================*/
#ifndef _GDSP_REGISTERS_H
#define _GDSP_REGISTERS_H
#include "Common.h"
// Register table taken from libasnd
#define DSP_REG_AR0 0x00 // address registers
#define DSP_REG_AR1 0x01
#define DSP_REG_AR2 0x02
#define DSP_REG_AR3 0x03
#define DSP_REG_IX0 0x04 // indexing registers (actually, mostly used as increments)
#define DSP_REG_IX1 0x05
#define DSP_REG_IX2 0x06
#define DSP_REG_IX3 0x07
#define DSP_REG_WR0 0x08 // address wrapping registers. should be initialized to 0xFFFF if not used.
#define DSP_REG_WR1 0x09
#define DSP_REG_WR2 0x0a
#define DSP_REG_WR3 0x0b
#define DSP_REG_ST0 0x0c // stacks.
#define DSP_REG_ST1 0x0d
#define DSP_REG_ST2 0x0e
#define DSP_REG_ST3 0x0f
#define DSP_REG_CR 0x12 // Seems to be the top 8 bits of LRS/SRS.
#define DSP_REG_SR 0x13
#define DSP_REG_PRODL 0x14 // product.
#define DSP_REG_PRODM 0x15
#define DSP_REG_PRODH 0x16
#define DSP_REG_PRODM2 0x17
#define DSP_REG_AXL0 0x18
#define DSP_REG_AXL1 0x19
#define DSP_REG_AXH0 0x1a
#define DSP_REG_AXH1 0x1b
#define DSP_REG_ACC0 0x1c // accumulator (global)
#define DSP_REG_ACC1 0x1d
#define DSP_REG_ACL0 0x1c // Low accumulator
#define DSP_REG_ACL1 0x1d
#define DSP_REG_ACM0 0x1e // Mid accumulator
#define DSP_REG_ACM1 0x1f
#define DSP_REG_ACH0 0x10 // Sign extended 8 bit register 0
#define DSP_REG_ACH1 0x11 // Sign extended 8 bit register 1
// Hardware registers address
#define DSP_REG_DSCR 0xffc9 // DSP DMA Control Reg
#define DSP_REG_DSBL 0xffcb // DSP DMA Block Length
#define DSP_REG_DSPA 0xffcd // DSP DMA DMEM Address
#define DSP_REG_DSMAH 0xffce // DSP DMA Mem Address H
#define DSP_REG_DSMAL 0xffcf // DSP DMA Mem Address L
#define DSP_REG_DIRQ 0xfffb // DSP Irq Rest
#define DSP_REG_DMBH 0xfffc // DSP Mailbox H
#define DSP_REG_DMBL 0xfffd // DSP Mailbox L
#define DSP_REG_CMBH 0xfffe // CPU Mailbox H
#define DSP_REG_CMBL 0xffff // CPU Mailbox L
#define DMA_TO_DSP 0
#define DMA_TO_CPU 1
// Stacks
#define DSP_STACK_C 0
#define DSP_STACK_D 1
// cr (Not g_dsp.r[CR]) bits
// See HW/DSP.cpp.
#define CR_HALT 0x0004
#define CR_EXTERNAL_INT 0x0002
// SR bits
#define SR_CARRY 0x0001
#define SR_2 0x0002 // overflow???
#define SR_ARITH_ZERO 0x0004
#define SR_SIGN 0x0008
#define SR_10 0x0010 // seem to be set by tst
#define SR_TOP2BITS 0x0020 // this is an odd one. (set by tst)
#define SR_LOGIC_ZERO 0x0040
#define SR_INT_ENABLE 0x0200 // Not 100% sure but duddie says so. This should replace the hack, if so.
#define SR_800 0x0800 // Appears in zelda - what is it? where in the zelda ucode?
#define SR_MUL_MODIFY 0x2000 // 1 = normal. 0 = x2 (M0, M2)
#define SR_40_MODE_BIT 0x4000 // 0 = "16", 1 = "40" (SET16, SET40) Controls sign extension when loading mid accums.
#define SR_MUL_UNSIGNED 0x8000 // 0 = normal. 1 = unsigned (CLR15, SET15) If set, treats operands as unsigned. Tested with mulx only so far.
void dsp_reg_store_stack(u8 stack_reg, u16 val);
u16 dsp_reg_load_stack(u8 stack_reg);
#endif

View File

@ -35,7 +35,7 @@
#include <wx/statline.h>
#include "disassemble.h"
#include "gdsp_interpreter.h"
#include "DSPInterpreter.h"
#include "DSPMemoryMap.h"
#include "../DSPDebugInterface.h"

View File

@ -26,7 +26,7 @@
#include "DSPCodeUtil.h"
#include "Tools.h"
#include "disassemble.h"
#include "gdsp_interpreter.h"
#include "DSPInterpreter.h"
bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
{

View File

@ -21,8 +21,8 @@
#include "Mixer.h"
#include "Globals.h" // Local
#include "gdsp_interpreter.h"
#include "gdsp_interface.h"
#include "DSPInterpreter.h"
#include "DSPHWInterface.h"
#include "disassemble.h"
#include "DSPSymbols.h"
#include "Config.h"

View File

@ -91,6 +91,7 @@ void Config::Load()
}
void Config::GameIniLoad() {
return;
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
if (! iniFile)
return;