// Extensive cleanups/rewrites by James L. Hammons
//
+#include "dsp.h"
+
#include <stdlib.h>
#include <SDL.h> // Used only for SDL_GetTicks...
-#include "dsp.h"
+#include "memory.h"
+#include "log.h"
+#include "jaguar.h"
+#include "jerry.h"
+#include "gpu.h"
+#include "jagdasm.h"
+#include "m68k.h"
//#define DSP_DEBUG
//#define DSP_DEBUG_IRQ
uint32 dsp_opcode_use[65];
-char * dsp_opcode_str[65]=
+const char * dsp_opcode_str[65]=
{
"add", "addc", "addq", "addqt",
"sub", "subc", "subq", "subqt",
uint32 dsp_control;
static uint32 dsp_div_control;
static uint8 dsp_flag_z, dsp_flag_n, dsp_flag_c;
-static uint32 * dsp_reg, * dsp_alternate_reg;
-static uint32 * dsp_reg_bank_0, * dsp_reg_bank_1;
+static uint32 * dsp_reg = NULL, * dsp_alternate_reg = NULL;
+static uint32 dsp_reg_bank_0[32], dsp_reg_bank_1[32];
static uint32 dsp_opcode_first_parameter;
static uint32 dsp_opcode_second_parameter;
uint32 dsp_convert_zero[32] = { 32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 };
uint8 * dsp_branch_condition_table = NULL;
static uint16 * mirror_table = NULL;
-static uint8 * dsp_ram_8 = NULL;
+static uint8 dsp_ram_8[0x2000];
#define BRANCH_CONDITION(x) dsp_branch_condition_table[(x) + ((jaguar_flags & 7) << 5)]
{
// Allocate the mirror table
if (!mirror_table)
- mirror_table = (uint16 *)malloc(65536 * sizeof(mirror_table[0]));
+ mirror_table = (uint16 *)memory_malloc(65536 * sizeof(uint16), "DSP mirror table");
// Fill in the mirror table
if (mirror_table)
if (!dsp_branch_condition_table)
{
- dsp_branch_condition_table = (uint8 *)malloc(32 * 8 * sizeof(dsp_branch_condition_table[0]));
+ dsp_branch_condition_table = (uint8 *)memory_malloc(32 * 8 * sizeof(uint8), "DSP branch condition table");
// Fill in the condition table
if (dsp_branch_condition_table)
if (offset==0xF1B2C2) return(0x0000);
}
*/
- // pour permettre à wolfenstein 3d de tourner sans le dsp
+ // pour permettre � wolfenstein 3d de tourner sans le dsp
/* if ((offset==0xF1B0D0)||(offset==0xF1B0D2))
return(0);
*/
- // pour permettre à nba jam de tourner sans le dsp
+ // pour permettre � nba jam de tourner sans le dsp
/* if (jaguar_mainRom_crc32==0x4faddb18)
{
if (offset==0xf1b2c0) return(0);
void DSPInit(void)
{
- memory_malloc_secure((void **)&dsp_ram_8, 0x2000, "DSP work RAM");
- memory_malloc_secure((void **)&dsp_reg_bank_0, 32 * sizeof(int32), "DSP bank 0 regs");
- memory_malloc_secure((void **)&dsp_reg_bank_1, 32 * sizeof(int32), "DSP bank 1 regs");
+// memory_malloc_secure((void **)&dsp_ram_8, 0x2000, "DSP work RAM");
+// memory_malloc_secure((void **)&dsp_reg_bank_0, 32 * sizeof(int32), "DSP bank 0 regs");
+// memory_malloc_secure((void **)&dsp_reg_bank_1, 32 * sizeof(int32), "DSP bank 1 regs");
dsp_build_branch_condition_table();
DSPReset();
WriteLog("\t%s %i\n", dsp_opcode_str[i], dsp_opcode_use[i]);
}//*/
- memory_free(dsp_ram_8);
- memory_free(dsp_reg_bank_0);
- memory_free(dsp_reg_bank_1);
+// memory_free(dsp_ram_8);
+// memory_free(dsp_reg_bank_0);
+// memory_free(dsp_reg_bank_1);
}
static void dsp_opcode_jump(void)
{
#ifdef DSP_DIS_JUMP
-char * condition[32] =
+const char * condition[32] =
{ "T", "nz", "z", "???", "nc", "nc nz", "nc z", "???", "c", "c nz",
"c z", "???", "???", "???", "???", "???", "???", "???", "???",
"???", "nn", "nn nz", "nn z", "???", "n", "n nz", "n z", "???",
static void dsp_opcode_jr(void)
{
#ifdef DSP_DIS_JR
-char * condition[32] =
+const char * condition[32] =
{ "T", "nz", "z", "???", "nc", "nc nz", "nc z", "???", "c", "c nz",
"c z", "???", "???", "???", "???", "???", "???", "???", "???",
"???", "nn", "nn nz", "nn z", "???", "n", "n nz", "n z", "???",
static void DSP_jr(void)
{
#ifdef DSP_DIS_JR
-char * condition[32] =
+const char * condition[32] =
{ "T", "nz", "z", "???", "nc", "nc nz", "nc z", "???", "c", "c nz",
"c z", "???", "???", "???", "???", "???", "???", "???", "???",
"???", "nn", "nn nz", "nn z", "???", "n", "n nz", "n z", "???",
static void DSP_jump(void)
{
#ifdef DSP_DIS_JUMP
-char * condition[32] =
+const char * condition[32] =
{ "T", "nz", "z", "???", "nc", "nc nz", "nc z", "???", "c", "c nz",
"c z", "???", "???", "???", "???", "???", "???", "???", "???",
"???", "nn", "nn nz", "nn z", "???", "n", "n nz", "n z", "???",