mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
DSP: Move the LLE core to a library. Added DSP assembler from gdtool, start cleaning it up. Create a new program called "DSPTool" which will become a more up to date replacement for gdtool from the devkitpro, automatically incorporating all our findings as we make them. This program depends on the new library. It can *ALMOST* roundtrip (asm->disasm->asm) hermes' DSP mixer at this point. Sorry about the unfinished Sconscript work - I'll fix it soon if nobody else does it first.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2955 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="Common"
|
||||
ProjectGUID="{C573CAF7-EE6A-458E-8049-16C0BF34C2E9}"
|
||||
RootNamespace="Common"
|
||||
@@ -142,7 +142,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
AdditionalDependencies="wsock32.lib"
|
||||
AdditionalDependencies="wsock32.lib winmm.lib"
|
||||
OutputFile="$(OutDir)/Common.lib"
|
||||
/>
|
||||
<Tool
|
||||
|
||||
@@ -154,7 +154,7 @@ void* DynamicLibrary::Get(const char* funcname) const
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
ERROR_LOG(COMMON, "DL: Symbol %s missing in %s (error: %s)\n",
|
||||
WARN_LOG(COMMON, "DL: Symbol %s missing in %s (error: %s)\n",
|
||||
funcname, library_file.c_str(),
|
||||
DllGetLastError());
|
||||
}
|
||||
|
||||
@@ -601,4 +601,35 @@ const char *GetUserDirectory()
|
||||
return path;
|
||||
}
|
||||
|
||||
bool WriteStringToFile(bool text_file, const char *str, const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename, text_file ? "w" : "wb");
|
||||
if (!f)
|
||||
return false;
|
||||
size_t len = strlen(str);
|
||||
if (len != fwrite(str, 1, strlen(str), f))
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadStringFromFile(bool text_file, const char *filename, std::string *str)
|
||||
{
|
||||
FILE *f = fopen(filename, text_file ? "r" : "rb");
|
||||
if (!f)
|
||||
return false;
|
||||
fseek(f, 0, SEEK_END);
|
||||
size_t len = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
char *buf = new char[len + 1];
|
||||
buf[fread(buf, 1, len, f)] = 0;
|
||||
*str = std::string(buf);
|
||||
fclose(f);
|
||||
delete [] buf;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -99,6 +99,9 @@ char *GetConfigDirectory();
|
||||
std::string GetBundleDirectory();
|
||||
#endif
|
||||
|
||||
bool WriteStringToFile(bool text_file, const char *str, const char *filename);
|
||||
bool ReadStringFromFile(bool text_file, const char *filename, std::string *str);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
// 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/
|
||||
|
||||
#ifndef _DSPHOST_H
|
||||
#define _DSPHOST_H
|
||||
|
||||
// The user of the DSPCore library must supply a few functions so that the
|
||||
// emulation core can access the environment it runs in. If the emulation
|
||||
// core isn't used, for example in an asm/disasm tool, then most of these
|
||||
// can be stubbed out.
|
||||
|
||||
u8 DSPHost_ReadHostMemory(u32 addr);
|
||||
bool DSPHost_OnThread();
|
||||
bool DSPHost_Running();
|
||||
u32 DSPHost_CodeLoaded(const u8 *ptr, int size);
|
||||
|
||||
#endif
|
||||
+20
-11
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "DSPInterpreter.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "gdsp_memory.h"
|
||||
#include "gdsp_interpreter.h"
|
||||
#include "gdsp_condition_codes.h"
|
||||
@@ -116,11 +116,9 @@ void jcc(const UDSPInstruction& opc)
|
||||
// Jump to address; set program counter to a value from register $R.
|
||||
void jmprcc(const UDSPInstruction& opc)
|
||||
{
|
||||
u8 reg;
|
||||
|
||||
if (CheckCondition(opc.hex & 0xf))
|
||||
{
|
||||
reg = (opc.hex >> 5) & 0x7;
|
||||
u8 reg = (opc.hex >> 5) & 0x7;
|
||||
g_dsp.pc = dsp_op_read_reg(reg);
|
||||
}
|
||||
}
|
||||
@@ -826,6 +824,16 @@ void andc(const UDSPInstruction& opc)
|
||||
Update_SR_Register64(dsp_get_long_acc(D));
|
||||
}
|
||||
|
||||
void orc(const UDSPInstruction& opc)
|
||||
{
|
||||
ERROR_LOG(DSPLLE, "orc not implemented");
|
||||
}
|
||||
|
||||
void orf(const UDSPInstruction& opc)
|
||||
{
|
||||
ERROR_LOG(DSPLLE, "orf not implemented");
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
@@ -1752,7 +1760,8 @@ void msubx(const UDSPInstruction& opc)
|
||||
// MADDC $acS.m, $axT.h
|
||||
// 1110 10st xxxx xxxx
|
||||
// Multiply middle part of accumulator $acS.m by high part of secondary
|
||||
// accumulator $axT.h (treat them both as signed) and add result to product register.
|
||||
// accumulator $axT.h (treat them both as signed) and add result to product
|
||||
// register.
|
||||
void maddc(const UDSPInstruction& opc)
|
||||
{
|
||||
u32 sreg = (opc.hex >> 9) & 0x1;
|
||||
@@ -1788,28 +1797,28 @@ void msubc(const UDSPInstruction& opc)
|
||||
Update_SR_Register64(prod);
|
||||
}
|
||||
|
||||
// SRS @M, $(DSP_REG_AXL0+S)
|
||||
// SRS @M, $(0x18+S)
|
||||
// 0010 1sss mmmm mmmm
|
||||
// Store value from register $(DSP_REG_AXL0+S) to a memory pointed by address M.
|
||||
// Store value from register $(0x18+S) to a memory pointed by address M.
|
||||
// (8-bit sign extended).
|
||||
// FIXME: Perform additional operation depending on destination register.
|
||||
// Note: pc+=2 in duddie's doc seems wrong
|
||||
void srs(const UDSPInstruction& opc)
|
||||
{
|
||||
u8 reg = ((opc.hex >> 8) & 0x7) + DSP_REG_AXL0;
|
||||
u8 reg = ((opc.hex >> 8) & 0x7) + 0x18;
|
||||
u16 addr = (u16)(s16)(s8)opc.hex;
|
||||
dsp_dmem_write(addr, g_dsp.r[reg]);
|
||||
}
|
||||
|
||||
// LRS $(DSP_REG_AXL0+D), @M
|
||||
// LRS $(0x18+D), @M
|
||||
// 0010 0ddd mmmm mmmm
|
||||
// Move value from data memory pointed by address M (8-bit sign
|
||||
// extended) to register $(DSP_REG_AXL0+D).
|
||||
// extended) to register $(0x18+D).
|
||||
// FIXME: Perform additional operation depending on destination register.
|
||||
// Note: pc+=2 in duddie's doc seems wrong
|
||||
void lrs(const UDSPInstruction& opc)
|
||||
{
|
||||
u8 reg = ((opc.hex >> 8) & 0x7) + DSP_REG_AXL0;
|
||||
u8 reg = ((opc.hex >> 8) & 0x7) + 0x18;
|
||||
u16 addr = (u16)(s16)(s8)opc.hex;
|
||||
g_dsp.r[reg] = dsp_dmem_read(addr);
|
||||
}
|
||||
+3
-1
@@ -68,8 +68,10 @@ void movr(const UDSPInstruction& opc);
|
||||
void movax(const UDSPInstruction& opc);
|
||||
void xorr(const UDSPInstruction& opc);
|
||||
void andr(const UDSPInstruction& opc);
|
||||
void orr(const UDSPInstruction& opc);
|
||||
void andc(const UDSPInstruction& opc);
|
||||
void orr(const UDSPInstruction& opc);
|
||||
void orc(const UDSPInstruction& opc);
|
||||
void orf(const UDSPInstruction& opc);
|
||||
void add(const UDSPInstruction& opc);
|
||||
void addp(const UDSPInstruction& opc);
|
||||
void cmpis(const UDSPInstruction& opc);
|
||||
+518
-405
File diff suppressed because it is too large
Load Diff
+37
-12
@@ -22,7 +22,9 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
enum parameterType
|
||||
// The ones that end with _D are the opposite one - if the bit specify
|
||||
// ACC0, then ACC_D will be ACC1.
|
||||
enum partype_t
|
||||
{
|
||||
P_NONE = 0x0000,
|
||||
P_VAL = 0x0001,
|
||||
@@ -31,7 +33,6 @@ enum parameterType
|
||||
P_STR = 0x0004,
|
||||
P_REG = 0x8000,
|
||||
P_REG08 = P_REG | 0x0800,
|
||||
P_REG10 = P_REG | 0x1000,
|
||||
P_REG18 = P_REG | 0x1800,
|
||||
P_REGM18 = P_REG | 0x1810, // used in multiply instructions
|
||||
P_REG19 = P_REG | 0x1900,
|
||||
@@ -39,17 +40,21 @@ enum parameterType
|
||||
P_REG1A = P_REG | 0x1a00,
|
||||
P_REG1C = P_REG | 0x1c00,
|
||||
// P_ACC = P_REG | 0x1c10, // used for global accum (gcdsptool's value)
|
||||
P_ACCD = P_REG | 0x1c80,
|
||||
P_ACC_D = P_REG | 0x1c80,
|
||||
P_ACCL = P_REG | 0x1c00, // used for mid accum
|
||||
P_ACCM = P_REG | 0x1e00, // used for mid accum
|
||||
// The following are not in gcdsptool
|
||||
P_ACCM_D = P_REG | 0x1e80,
|
||||
P_ACC = P_REG | 0x2000,
|
||||
P_ACC_D = P_REG | 0x2080,
|
||||
P_ACC = P_REG | 0x2000, // used for global accum.
|
||||
P_AX = P_REG | 0x2200,
|
||||
P_AX_D = P_REG | 0x2280,
|
||||
P_REGS_MASK = 0x03f80, // gcdsptool's value = 0x01f80
|
||||
P_REF = P_REG | 0x4000,
|
||||
P_PRG = P_REF | P_REG,
|
||||
|
||||
// The following seem like junk:
|
||||
// P_REG10 = P_REG | 0x1000,
|
||||
// P_AX_D = P_REG | 0x2280,
|
||||
|
||||
};
|
||||
|
||||
#define P_EXT 0x80
|
||||
@@ -81,14 +86,14 @@ union UDSPInstruction
|
||||
|
||||
typedef void (*dspInstFunc)(const UDSPInstruction&);
|
||||
|
||||
typedef struct
|
||||
struct param2_t
|
||||
{
|
||||
parameterType type;
|
||||
partype_t type;
|
||||
u8 size;
|
||||
u8 loc;
|
||||
s8 lshift;
|
||||
u16 mask;
|
||||
} DSPOParams;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -101,21 +106,41 @@ typedef struct
|
||||
|
||||
u8 size;
|
||||
u8 param_count;
|
||||
DSPOParams params[8];
|
||||
param2_t params[8];
|
||||
dspInstFunc prologue;
|
||||
dspInstFunc epilogue;
|
||||
} DSPOPCTemplate;
|
||||
|
||||
extern DSPOPCTemplate opcodes[];
|
||||
typedef DSPOPCTemplate opc_t;
|
||||
|
||||
// Opcodes
|
||||
extern const DSPOPCTemplate opcodes[];
|
||||
extern const u32 opcodes_size;
|
||||
extern DSPOPCTemplate opcodes_ext[];
|
||||
extern const DSPOPCTemplate opcodes_ext[];
|
||||
extern const u32 opcodes_ext_size;
|
||||
extern u8 opSize[OPTABLE_SIZE];
|
||||
extern const DSPOPCTemplate cw;
|
||||
|
||||
extern dspInstFunc opTable[];
|
||||
extern dspInstFunc prologueTable[OPTABLE_SIZE];
|
||||
extern dspInstFunc epilogueTable[OPTABLE_SIZE];
|
||||
|
||||
// Predefined labels
|
||||
struct pdlabel_t
|
||||
{
|
||||
u16 addr;
|
||||
const char* name;
|
||||
const char* description;
|
||||
};
|
||||
|
||||
extern const pdlabel_t regnames[];
|
||||
extern const pdlabel_t pdlabels[];
|
||||
extern const u32 pdlabels_size;
|
||||
|
||||
const char *pdname(u16 val);
|
||||
const char *pdregname(int val);
|
||||
const char *pdregnamelong(int val);
|
||||
|
||||
void InitInstructionTable();
|
||||
|
||||
inline void ExecuteInstruction(const UDSPInstruction& inst)
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- python -*-
|
||||
|
||||
Import('env')
|
||||
|
||||
files = [
|
||||
"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",
|
||||
"DSPAnalyzer.cpp",
|
||||
"DSPInterpreter.cpp",
|
||||
"DSPJit.cpp",
|
||||
"DSPHost.cpp",
|
||||
"DSPTables.cpp",
|
||||
]
|
||||
|
||||
acenv = env.Clone()
|
||||
acenv.Append(CXXFLAGS = [ '-fPIC' ])
|
||||
|
||||
acenv.StaticLibrary('dspcore', files)
|
||||
File diff suppressed because it is too large
Load Diff
+29
-142
@@ -23,15 +23,12 @@
|
||||
|
||||
====================================================================*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#include "disassemble.h"
|
||||
#include "DSPTables.h"
|
||||
// #include "gdsp_tool.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4996)
|
||||
@@ -39,117 +36,6 @@
|
||||
|
||||
u32 unk_opcodes[0x10000];
|
||||
|
||||
|
||||
// predefined labels
|
||||
typedef struct pdlabel_t
|
||||
{
|
||||
u16 addr;
|
||||
const char* name;
|
||||
const char* description;
|
||||
} pdlabels_t;
|
||||
|
||||
const pdlabel_t pdlabels[] =
|
||||
{
|
||||
{0xffa0, "COEF_A1_0", "COEF_A1_0",},
|
||||
{0xffa1, "COEF_A2_0", "COEF_A2_0",},
|
||||
{0xffa2, "COEF_A1_1", "COEF_A1_1",},
|
||||
{0xffa3, "COEF_A2_1", "COEF_A2_1",},
|
||||
{0xffa4, "COEF_A1_2", "COEF_A1_2",},
|
||||
{0xffa5, "COEF_A2_2", "COEF_A2_2",},
|
||||
{0xffa6, "COEF_A1_3", "COEF_A1_3",},
|
||||
{0xffa7, "COEF_A2_3", "COEF_A2_3",},
|
||||
{0xffa8, "COEF_A1_4", "COEF_A1_4",},
|
||||
{0xffa9, "COEF_A2_4", "COEF_A2_4",},
|
||||
{0xffaa, "COEF_A1_5", "COEF_A1_5",},
|
||||
{0xffab, "COEF_A2_5", "COEF_A2_5",},
|
||||
{0xffac, "COEF_A1_6", "COEF_A1_6",},
|
||||
{0xffad, "COEF_A2_6", "COEF_A2_6",},
|
||||
{0xffae, "COEF_A1_7", "COEF_A1_7",},
|
||||
{0xffaf, "COEF_A2_7", "COEF_A2_7",},
|
||||
{0xffc9, "DSCR", "DSP DMA Control Reg",},
|
||||
{0xffcb, "DSBL", "DSP DMA Block Length",},
|
||||
{0xffcd, "DSPA", "DSP DMA DMEM Address",},
|
||||
{0xffce, "DSMAH", "DSP DMA Mem Address H",},
|
||||
{0xffcf, "DSMAL", "DSP DMA Mem Address L",},
|
||||
{0xffd1, "SampleFormat", "SampleFormat",},
|
||||
|
||||
{0xffd3, "Unk Zelda", "Unk Zelda writes to it",},
|
||||
|
||||
{0xffd4, "ACSAH", "Accelerator start address H",},
|
||||
{0xffd5, "ACSAL", "Accelerator start address L",},
|
||||
{0xffd6, "ACEAH", "Accelerator end address H",},
|
||||
{0xffd7, "ACEAL", "Accelerator end address L",},
|
||||
{0xffd8, "ACCAH", "Accelerator current address H",},
|
||||
{0xffd9, "ACCAL", "Accelerator current address L",},
|
||||
{0xffda, "pred_scale", "pred_scale",},
|
||||
{0xffdb, "yn1", "yn1",},
|
||||
{0xffdc, "yn2", "yn2",},
|
||||
{0xffdd, "ARAM", "Direct Read from ARAM (uses ADPCM)",},
|
||||
{0xffde, "GAIN", "Gain",},
|
||||
{0xffef, "AMDM", "ARAM DMA Request Mask",},
|
||||
{0xfffb, "DIRQ", "DSP IRQ Request",},
|
||||
{0xfffc, "DMBH", "DSP Mailbox H",},
|
||||
{0xfffd, "DMBL", "DSP Mailbox L",},
|
||||
{0xfffe, "CMBH", "CPU Mailbox H",},
|
||||
{0xffff, "CMBL", "CPU Mailbox L",},
|
||||
};
|
||||
|
||||
pdlabel_t regnames[] =
|
||||
{
|
||||
{0x00, "AR0", "Register 00",},
|
||||
{0x01, "AR1", "Register 01",},
|
||||
{0x02, "AR2", "Register 02",},
|
||||
{0x03, "AR3", "Register 03",},
|
||||
{0x04, "IX0", "Register 04",},
|
||||
{0x05, "IX1", "Register 05",},
|
||||
{0x06, "IX2", "Register 06",},
|
||||
{0x07, "IX3", "Register 07",},
|
||||
{0x08, "R08", "Register 08",},
|
||||
{0x09, "R09", "Register 09",},
|
||||
{0x0a, "R10", "Register 10",},
|
||||
{0x0b, "R11", "Register 11",},
|
||||
{0x0c, "ST0", "Call stack",},
|
||||
{0x0d, "ST1", "Data stack",},
|
||||
{0x0e, "ST2", "Loop addr stack",},
|
||||
{0x0f, "ST3", "Loop counter",},
|
||||
{0x00, "AC0.H", "Accu High 0",},
|
||||
{0x11, "AC1.H", "Accu High 1",},
|
||||
{0x12, "CR", "Config Register",},
|
||||
{0x13, "SR", "Special Register",},
|
||||
{0x14, "PROD.L", "Prod L",},
|
||||
{0x15, "PROD.M1", "Prod M1",},
|
||||
{0x16, "PROD.H", "Prod H",},
|
||||
{0x17, "PROD.M2", "Prod M2",},
|
||||
{0x18, "AX0.L", "Extra Accu L 0",},
|
||||
{0x19, "AX1.L", "Extra Accu L 1",},
|
||||
{0x1a, "AX0.H", "Extra Accu H 0",},
|
||||
{0x1b, "AX1.H", "Extra Accu H 1",},
|
||||
{0x1c, "AC0.L", "Register 28",},
|
||||
{0x1d, "AC1.L", "Register 29",},
|
||||
{0x1e, "AC0.M", "Register 00",},
|
||||
{0x1f, "AC1.M", "Register 00",},
|
||||
|
||||
// To resolve special names.
|
||||
{0x20, "ACC0", "Accu Full 0",},
|
||||
{0x21, "ACC1", "Accu Full 1",},
|
||||
{0x22, "AX0", "Extra Accu 0",},
|
||||
{0x23, "AX1", "Extra Accu 1",},
|
||||
};
|
||||
|
||||
const char* pdname(u16 val)
|
||||
{
|
||||
static char tmpstr[12]; // nasty
|
||||
|
||||
for (int i = 0; i < (int)(sizeof(pdlabels) / sizeof(pdlabel_t)); i++)
|
||||
{
|
||||
if (pdlabels[i].addr == val)
|
||||
return pdlabels[i].name;
|
||||
}
|
||||
|
||||
sprintf(tmpstr, "0x%04x", val);
|
||||
return tmpstr;
|
||||
}
|
||||
|
||||
extern void nop(const UDSPInstruction& opc);
|
||||
|
||||
char* gd_dis_params(gd_globals_t* gdg, const DSPOPCTemplate* opc, u16 op1, u16 op2, char* strbuf)
|
||||
@@ -185,7 +71,7 @@ char* gd_dis_params(gd_globals_t* gdg, const DSPOPCTemplate* opc, u16 op1, u16 o
|
||||
|
||||
if (type & P_REG)
|
||||
{
|
||||
if (type == P_ACCD) // Used to be P_ACCM_D TODO verify
|
||||
if (type == P_ACC_D) // Used to be P_ACCM_D TODO verify
|
||||
val = (~val & 0x1) | ((type & P_REGS_MASK) >> 8);
|
||||
else
|
||||
val |= (type & P_REGS_MASK) >> 8;
|
||||
@@ -197,14 +83,14 @@ char* gd_dis_params(gd_globals_t* gdg, const DSPOPCTemplate* opc, u16 op1, u16 o
|
||||
{
|
||||
case P_REG:
|
||||
if (gdg->decode_registers)
|
||||
sprintf(buf, "$%s", regnames[val].name);
|
||||
sprintf(buf, "$%s", pdregname(val));
|
||||
else
|
||||
sprintf(buf, "$%d", val);
|
||||
break;
|
||||
|
||||
case P_PRG:
|
||||
if (gdg->decode_registers)
|
||||
sprintf(buf, "@$%s", regnames[val].name);
|
||||
sprintf(buf, "@$%s", pdregname(val));
|
||||
else
|
||||
sprintf(buf, "@$%d", val);
|
||||
break;
|
||||
@@ -252,10 +138,11 @@ char* gd_dis_params(gd_globals_t* gdg, const DSPOPCTemplate* opc, u16 op1, u16 o
|
||||
|
||||
u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
|
||||
{
|
||||
DSPOPCTemplate* opc = 0;
|
||||
DSPOPCTemplate* opc_ext = 0;
|
||||
const DSPOPCTemplate* opc = 0;
|
||||
const DSPOPCTemplate* opc_ext = 0;
|
||||
bool extended;
|
||||
|
||||
// Undefined memory.
|
||||
if ((gdg->pc & 0x7fff) >= 0x1000)
|
||||
return 1;
|
||||
|
||||
@@ -300,30 +187,28 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!opc_ext)
|
||||
{
|
||||
ERROR_LOG(DSPLLE, "get_opcode_size ext ARGH");
|
||||
}
|
||||
|
||||
return opc_ext->size;
|
||||
}
|
||||
|
||||
return(opc->size & ~P_EXT);
|
||||
return opc->size & ~P_EXT;
|
||||
}
|
||||
|
||||
|
||||
char* gd_dis_opcode(gd_globals_t* gdg)
|
||||
{
|
||||
u32 j;
|
||||
u32 op1, op2;
|
||||
const DSPOPCTemplate *opc = NULL;
|
||||
const DSPOPCTemplate *opc_ext = NULL;
|
||||
u16 pc;
|
||||
char* buf = gdg->buffer;
|
||||
bool extended;
|
||||
u32 op2;
|
||||
char *buf = gdg->buffer;
|
||||
|
||||
pc = gdg->pc;
|
||||
*buf = '\0';
|
||||
u16 pc = gdg->pc;
|
||||
|
||||
// Start with a space.
|
||||
buf[0] = ' ';
|
||||
buf[1] = '\0';
|
||||
buf++;
|
||||
|
||||
if ((pc & 0x7fff) >= 0x1000)
|
||||
{
|
||||
@@ -332,10 +217,12 @@ char* gd_dis_opcode(gd_globals_t* gdg)
|
||||
}
|
||||
|
||||
pc &= 0x0fff;
|
||||
op1 = gdg->binbuf[pc];
|
||||
u32 op1 = gdg->binbuf[pc];
|
||||
|
||||
const DSPOPCTemplate *opc = NULL;
|
||||
const DSPOPCTemplate *opc_ext = NULL;
|
||||
// find opcode
|
||||
for (j = 0; j < opcodes_size; j++)
|
||||
for (int j = 0; j < opcodes_size; j++)
|
||||
{
|
||||
u16 mask;
|
||||
|
||||
@@ -356,6 +243,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
|
||||
if (!opc)
|
||||
opc = &fake_op;
|
||||
|
||||
bool extended;
|
||||
if (opc->size & P_EXT && op1 & 0x00ff)
|
||||
extended = true;
|
||||
else
|
||||
@@ -365,7 +253,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
|
||||
{
|
||||
// opcode has an extension
|
||||
// find opcode
|
||||
for (j = 0; j < opcodes_ext_size; j++)
|
||||
for (int j = 0; j < opcodes_ext_size; j++)
|
||||
{
|
||||
if ((op1 & opcodes_ext[j].opcode_mask) == opcodes_ext[j].opcode)
|
||||
{
|
||||
@@ -446,10 +334,10 @@ char* gd_dis_opcode(gd_globals_t* gdg)
|
||||
else
|
||||
gdg->pc += opc->size & ~P_EXT;
|
||||
|
||||
return(gdg->buffer);
|
||||
return gdg->buffer;
|
||||
}
|
||||
|
||||
bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
|
||||
bool gd_dis_file(gd_globals_t* gdg, const char* name, FILE* output)
|
||||
{
|
||||
gd_dis_open_unkop();
|
||||
|
||||
@@ -457,9 +345,10 @@ bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
|
||||
u32 size;
|
||||
|
||||
in = fopen(name, "rb");
|
||||
|
||||
if (in == NULL)
|
||||
if (in == NULL) {
|
||||
printf("gd_dis_file: No input\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
size = (int)ftell(in);
|
||||
@@ -547,9 +436,7 @@ void gd_dis_open_unkop()
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 0x10000; i++)
|
||||
for (int i = 0; i < 0x10000; i++)
|
||||
{
|
||||
unk_opcodes[i] = 0;
|
||||
}
|
||||
+6
-3
@@ -1,6 +1,5 @@
|
||||
/*====================================================================
|
||||
|
||||
filename: opcodes.h
|
||||
project: GameCube DSP Tool (gcdsp)
|
||||
created: 2005.03.04
|
||||
mail: duddie@walla.com
|
||||
@@ -23,7 +22,8 @@
|
||||
|
||||
====================================================================*/
|
||||
|
||||
#pragma once
|
||||
#ifndef _DSP_DISASSEMBLE_H
|
||||
#define _DSP_DISASSEMBLE_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
@@ -44,7 +44,10 @@ struct gd_globals_t
|
||||
|
||||
|
||||
char* gd_dis_opcode(gd_globals_t* gdg);
|
||||
bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output);
|
||||
bool gd_dis_file(gd_globals_t* gdg, const char* name, FILE* output);
|
||||
|
||||
void gd_dis_close_unkop();
|
||||
void gd_dis_open_unkop();
|
||||
const char* gd_dis_get_reg_name(u16 reg);
|
||||
|
||||
#endif // _DSP_DISASSEMBLE_H
|
||||
+7
-6
@@ -15,7 +15,8 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Common.h"
|
||||
#include "DSPHost.h"
|
||||
#include "gdsp_interface.h"
|
||||
#include "gdsp_interpreter.h"
|
||||
|
||||
@@ -26,7 +27,7 @@ s16 ADPCM_Step(u32& _rSamplePos)
|
||||
|
||||
if (((_rSamplePos) & 15) == 0)
|
||||
{
|
||||
gdsp_ifx_regs[DSP_PRED_SCALE] = g_dspInitialize.pARAM_Read_U8((_rSamplePos & ~15) >> 1);
|
||||
gdsp_ifx_regs[DSP_PRED_SCALE] = DSPHost_ReadHostMemory((_rSamplePos & ~15) >> 1);
|
||||
_rSamplePos += 2;
|
||||
}
|
||||
|
||||
@@ -37,8 +38,8 @@ s16 ADPCM_Step(u32& _rSamplePos)
|
||||
s32 coef2 = pCoefTable[coef_idx * 2 + 1];
|
||||
|
||||
int temp = (_rSamplePos & 1) ?
|
||||
(g_dspInitialize.pARAM_Read_U8(_rSamplePos >> 1) & 0xF) :
|
||||
(g_dspInitialize.pARAM_Read_U8(_rSamplePos >> 1) >> 4);
|
||||
(DSPHost_ReadHostMemory(_rSamplePos >> 1) & 0xF) :
|
||||
(DSPHost_ReadHostMemory(_rSamplePos >> 1) >> 4);
|
||||
|
||||
if (temp >= 8)
|
||||
temp -= 16;
|
||||
@@ -77,7 +78,7 @@ u16 dsp_read_aram()
|
||||
break;
|
||||
|
||||
case 0x0A: // 16-bit PCM audio
|
||||
val = (g_dspInitialize.pARAM_Read_U8(Address) << 8) | g_dspInitialize.pARAM_Read_U8(Address + 1);
|
||||
val = (DSPHost_ReadHostMemory(Address) << 8) | DSPHost_ReadHostMemory(Address + 1);
|
||||
|
||||
gdsp_ifx_regs[DSP_YN2] = gdsp_ifx_regs[DSP_YN1];
|
||||
gdsp_ifx_regs[DSP_YN1] = val;
|
||||
@@ -86,7 +87,7 @@ u16 dsp_read_aram()
|
||||
break;
|
||||
|
||||
default:
|
||||
val = (g_dspInitialize.pARAM_Read_U8(Address) << 8) | g_dspInitialize.pARAM_Read_U8(Address + 1);
|
||||
val = (DSPHost_ReadHostMemory(Address) << 8) | DSPHost_ReadHostMemory(Address + 1);
|
||||
Address += 2;
|
||||
ERROR_LOG(DSPLLE, "Unknown DSP Format %i", gdsp_ifx_regs[DSP_FORMAT]);
|
||||
break;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user