From 1c52139d9432239b7aef4ee1555e013f62b7f6f7 Mon Sep 17 00:00:00 2001
From: nakeee <nakeee@gmail.com>
Date: Thu, 9 Jul 2009 00:07:08 +0000
Subject: [PATCH] DSPLLE: the reset exception is needed by zelda to init
 correctly, but it get stuck in the middle. If you wish to help debugging
 uncomment the SetException line.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3715 8ced0084-cf51-0410-be5f-012b33b47a6e
---
 Source/Core/DSPCore/Src/DSPCore.cpp        | 9 ++++++---
 Source/Core/DSPCore/Src/DSPHWInterface.cpp | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp
index 713c3f9111..1758c70bde 100644
--- a/Source/Core/DSPCore/Src/DSPCore.cpp
+++ b/Source/Core/DSPCore/Src/DSPCore.cpp
@@ -114,6 +114,9 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename)
 	g_dsp.r[DSP_REG_WR2] = 0xffff;
 	g_dsp.r[DSP_REG_WR3] = 0xffff;
 
+	g_dsp.r[DSP_REG_SR] |= SR_INT_ENABLE;
+	g_dsp.r[DSP_REG_SR] |= SR_EXT_INT_ENABLE;
+
 	g_dsp.cr = 0x804;
 	gdsp_ifx_init();
 
@@ -121,8 +124,8 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename)
 	// in new ucodes.
 	WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
 	DSPAnalyzer::Analyze();
-
 	step_event.Init();
+	
 	return true;
 }
 
@@ -188,9 +191,9 @@ void DSPCore_CheckExceptions()
 #endif
 		// check exceptions should it be 0..7 or 7..0?
 		for (int i = 0; i < 8; i++) {
-			// Seems exp int is not masked by sr_int_enable
+			// Seems exp int or reset are not masked by sr_int_enable 
 			if (g_dsp.exceptions & (1 << i)) {
-				if (dsp_SR_is_flag_set(SR_INT_ENABLE) || i == EXP_INT) {
+				if (dsp_SR_is_flag_set(SR_INT_ENABLE) || i == EXP_INT || i == EXP_RESET) {
 					_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception");
 					
 					// store pc and sr until RTI
diff --git a/Source/Core/DSPCore/Src/DSPHWInterface.cpp b/Source/Core/DSPCore/Src/DSPHWInterface.cpp
index 727fb8d54a..bd7f2b0cbd 100644
--- a/Source/Core/DSPCore/Src/DSPHWInterface.cpp
+++ b/Source/Core/DSPCore/Src/DSPHWInterface.cpp
@@ -247,6 +247,9 @@ void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
 	INFO_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc);
 	g_dsp.iram_crc = DSPHost_CodeLoaded(g_dsp.cpu_ram + (addr & 0x0fffffff), size);
 	DSPAnalyzer::Analyze();
+	// This calls the reset functions, but it get some games stuck
+	// uncomment it to help with debugging
+	//	DSPCore_SetException(EXP_RESET);
 }