Bug Summary

File:Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp
Location:line 518, column 8
Description:Value stored to 'tmp' during its initialization is never read

Annotated Source Code

1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5// Games that uses this UCode:
6// Zelda: The Windwaker, Mario Sunshine, Mario Kart, Twilight Princess,
7// Super Mario Galaxy
8
9#include "UCodes.h"
10#include "UCode_Zelda.h"
11#include "../MailHandler.h"
12
13#include "Mixer.h"
14
15#include "WaveFile.h"
16#include "../../DSP.h"
17#include "ConfigManager.h"
18
19
20CUCode_Zelda::CUCode_Zelda(DSPHLE *dsp_hle, u32 _CRC)
21 :
22 IUCode(dsp_hle, _CRC),
23
24 m_bSyncInProgress(false),
25 m_MaxVoice(0),
26
27 m_NumSyncMail(0),
28
29 m_NumVoices(0),
30
31 m_bSyncCmdPending(false),
32 m_CurVoice(0),
33 m_CurBuffer(0),
34 m_NumBuffers(0),
35
36 m_VoicePBsAddr(0),
37 m_UnkTableAddr(0),
38 m_ReverbPBsAddr(0),
39
40 m_RightBuffersAddr(0),
41 m_LeftBuffersAddr(0),
42 m_pos(0),
43
44 m_DMABaseAddr(0),
45
46 m_numSteps(0),
47 m_bListInProgress(false),
48 m_step(0),
49
50 m_readOffset(0),
51
52 m_MailState(WaitForMail),
53
54 m_NumPBs(0),
55 m_PBAddress(0),
56 m_PBAddress2(0)
57{
58 DEBUG_LOG(DSPHLE, "UCode_Zelda - add boot mails for handshake")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 58, "UCode_Zelda - add boot mails for handshake"); } } while
(0)
;
59
60 if (IsLightVersion())
61 {
62 NOTICE_LOG(DSPHLE, "Luigi Stylee!")do { { if (LogTypes::LNOTICE <= 3) GenericLog(LogTypes::LNOTICE
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 62, "Luigi Stylee!"); } } while (0)
;
63 m_rMailHandler.PushMail(0x88881111);
64 }
65 else
66 {
67 m_rMailHandler.PushMail(DSP_INIT);
68 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
69 m_rMailHandler.PushMail(0xF3551111); // handshake
70 }
71
72 m_VoiceBuffer = new s32[256 * 1024];
73 m_ResampleBuffer = new s16[256 * 1024];
74 m_LeftBuffer = new s32[256 * 1024];
75 m_RightBuffer = new s32[256 * 1024];
76
77 memset(m_Buffer, 0, sizeof(m_Buffer));
78 memset(m_SyncFlags, 0, sizeof(m_SyncFlags));
79 memset(m_AFCCoefTable, 0, sizeof(m_AFCCoefTable));
80 memset(m_PBMask, 0, sizeof(m_PBMask));
81}
82
83CUCode_Zelda::~CUCode_Zelda()
84{
85 m_rMailHandler.Clear();
86
87 delete [] m_VoiceBuffer;
88 delete [] m_ResampleBuffer;
89 delete [] m_LeftBuffer;
90 delete [] m_RightBuffer;
91}
92
93u8 *CUCode_Zelda::GetARAMPointer(u32 address)
94{
95 if (IsDMAVersion())
96 return (u8 *)(Memory::GetPointer(m_DMABaseAddr)) + address;
97 else
98 return (u8 *)(DSP::GetARAMPtr()) + address;
99}
100
101void CUCode_Zelda::Update(int cycles)
102{
103 if (!IsLightVersion())
104 {
105 if (m_rMailHandler.GetNextMail() == DSP_FRAME_END)
106 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
107 }
108
109 if (NeedsResumeMail())
110 {
111 m_rMailHandler.PushMail(DSP_RESUME);
112 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
113 }
114}
115
116void CUCode_Zelda::HandleMail(u32 _uMail)
117{
118 if (IsLightVersion())
119 HandleMail_LightVersion(_uMail);
120 else if (IsSMSVersion())
121 HandleMail_SMSVersion(_uMail);
122 else
123 HandleMail_NormalVersion(_uMail);
124}
125
126void CUCode_Zelda::HandleMail_LightVersion(u32 _uMail)
127{
128 //ERROR_LOG(DSPHLE, "Light version mail %08X, list in progress: %s, step: %i/%i",
129 // _uMail, m_bListInProgress ? "yes":"no", m_step, m_numSteps);
130
131 if (m_bSyncCmdPending)
132 {
133 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
134 m_CurBuffer++;
135
136 if (m_CurBuffer == m_NumBuffers)
137 {
138 soundStream->GetMixer()->SetHLEReady(true);
139 m_bSyncCmdPending = false;
140 DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 140, "Update the SoundThread to be in sync"); } } while (0)
;
141 }
142 return;
143 }
144
145 if (!m_bListInProgress)
146 {
147 switch ((_uMail >> 24) & 0x7F)
148 {
149 case 0x00: m_numSteps = 1; break; // dummy
150 case 0x01: m_numSteps = 5; break; // DsetupTable
151 case 0x02: m_numSteps = 3; break; // DsyncFrame
152
153 default:
154 {
155 m_numSteps = 0;
156 PanicAlert("Zelda uCode (light version): unknown/unsupported command %02X", (_uMail >> 24) & 0x7F)MsgAlert(false, WARNING, "Zelda uCode (light version): unknown/unsupported command %02X"
, (_uMail >> 24) & 0x7F)
;
157 }
158 return;
159 }
160
161 m_bListInProgress = true;
162 m_step = 0;
163 }
164
165 if (m_step >= sizeof(m_Buffer) / 4)
166 PanicAlert("m_step out of range")MsgAlert(false, WARNING, "m_step out of range");
167
168 ((u32*)m_Buffer)[m_step] = _uMail;
169 m_step++;
170
171 if (m_step >= m_numSteps)
172 {
173 ExecuteList();
174 m_bListInProgress = false;
175 }
176}
177
178void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
179{
180 if (m_bSyncInProgress)
181 {
182 if (m_bSyncCmdPending)
183 {
184 m_SyncFlags[(m_NumSyncMail << 1) ] = _uMail >> 16;
185 m_SyncFlags[(m_NumSyncMail << 1) + 1] = _uMail & 0xFFFF;
186
187 m_NumSyncMail++;
188 if (m_NumSyncMail == 2)
189 {
190 m_NumSyncMail = 0;
191 m_bSyncInProgress = false;
192
193 m_CurBuffer++;
194
195 m_rMailHandler.PushMail(DSP_SYNC);
196 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
197 m_rMailHandler.PushMail(0xF355FF00 | m_CurBuffer);
198
199 if (m_CurBuffer == m_NumBuffers)
200 {
201 m_rMailHandler.PushMail(DSP_FRAME_END);
202 // DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
203
204 soundStream->GetMixer()->SetHLEReady(true);
205 DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 205, "Update the SoundThread to be in sync"); } } while (0)
;
206// soundStream->Update(); //do it in this thread to avoid sync problems
207
208 m_bSyncCmdPending = false;
209 }
210 }
211 }
212 else
213 {
214 m_bSyncInProgress = false;
215 }
216
217 return;
218 }
219
220 if (m_bListInProgress)
221 {
222 if (m_step >= sizeof(m_Buffer) / 4)
223 PanicAlert("m_step out of range")MsgAlert(false, WARNING, "m_step out of range");
224
225 ((u32*)m_Buffer)[m_step] = _uMail;
226 m_step++;
227
228 if (m_step >= m_numSteps)
229 {
230 ExecuteList();
231 m_bListInProgress = false;
232 }
233
234 return;
235 }
236
237 // Here holds: m_bSyncInProgress == false && m_bListInProgress == false
238
239 if (_uMail == 0)
240 {
241 m_bSyncInProgress = true;
242 m_NumSyncMail = 0;
243 }
244 else if ((_uMail >> 16) == 0)
245 {
246 m_bListInProgress = true;
247 m_numSteps = _uMail;
248 m_step = 0;
249 }
250 else if ((_uMail >> 16) == 0xCDD1) // A 0xCDD1000X mail should come right after we send a DSP_SYNCEND mail
251 {
252 // The low part of the mail tells the operation to perform
253 // Seeing as every possible operation number halts the uCode,
254 // except 3, that thing seems to be intended for debugging
255 switch (_uMail & 0xFFFF)
256 {
257 case 0x0003: // Do nothing
258 return;
259
260 case 0x0000: // Halt
261 case 0x0001: // Dump memory? and halt
262 case 0x0002: // Do something and halt
263 WARN_LOG(DSPHLE, "Zelda uCode(SMS version): received halting operation %04X", _uMail & 0xFFFF)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 263, "Zelda uCode(SMS version): received halting operation %04X"
, _uMail & 0xFFFF); } } while (0)
;
264 return;
265
266 default: // Invalid (the real ucode would likely crash)
267 WARN_LOG(DSPHLE, "Zelda uCode(SMS version): received invalid operation %04X", _uMail & 0xFFFF)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 267, "Zelda uCode(SMS version): received invalid operation %04X"
, _uMail & 0xFFFF); } } while (0)
;
268 return;
269 }
270 }
271 else
272 {
273 WARN_LOG(DSPHLE, "Zelda uCode (SMS version): unknown mail %08X", _uMail)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 273, "Zelda uCode (SMS version): unknown mail %08X", _uMail
); } } while (0)
;
274 }
275}
276
277void CUCode_Zelda::HandleMail_NormalVersion(u32 _uMail)
278{
279 // WARN_LOG(DSPHLE, "Zelda uCode: Handle mail %08X", _uMail);
280
281 if (m_UploadSetupInProgress) // evaluated first!
282 {
283 PrepareBootUCode(_uMail);
284 return;
285 }
286
287 if (m_bSyncInProgress)
288 {
289 if (m_bSyncCmdPending)
290 {
291 u32 n = (_uMail >> 16) & 0xF;
292 m_MaxVoice = (n + 1) << 4;
293 m_SyncFlags[n] = _uMail & 0xFFFF;
294 m_bSyncInProgress = false;
295
296 // Normally, we should mix to the buffers used by the game.
297 // We don't do it currently for a simple reason:
298 // if the game runs fast all the time, then it's OK,
299 // but if it runs slow, sound can become choppy.
300 // This problem won't happen when mixing to the buffer
301 // provided by MixAdd(), because the size of this buffer
302 // is automatically adjusted if the game runs slow.
303#if 0
304 if (m_SyncFlags[n] & 0x8000)
305 {
306 for (; m_CurVoice < m_MaxVoice; m_CurVoice++)
307 {
308 if (m_CurVoice >= m_NumVoices)
309 break;
310
311 MixVoice(m_CurVoice);
312 }
313 }
314 else
315#endif
316 m_CurVoice = m_MaxVoice;
317
318 if (m_CurVoice >= m_NumVoices)
319 {
320 m_CurBuffer++;
321
322 m_rMailHandler.PushMail(DSP_SYNC);
323 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
324 m_rMailHandler.PushMail(0xF355FF00 | m_CurBuffer);
325
326 m_CurVoice = 0;
327
328 if (m_CurBuffer == m_NumBuffers)
329 {
330 if (!IsDMAVersion()) // this is a hack... without it Pikmin 1 Wii/ Zelda TP Wii mail-s stopped
331 m_rMailHandler.PushMail(DSP_FRAME_END);
332 //g_dspInitialize.pGenerateDSPInterrupt();
333
334 soundStream->GetMixer()->SetHLEReady(true);
335 DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 335, "Update the SoundThread to be in sync"); } } while (0)
;
336// soundStream->Update(); //do it in this thread to avoid sync problems
337
338 m_bSyncCmdPending = false;
339 }
340 }
341 }
342 else
343 {
344 m_bSyncInProgress = false;
345 }
346
347 return;
348 }
349
350 if (m_bListInProgress)
351 {
352 if (m_step >= sizeof(m_Buffer) / 4)
353 PanicAlert("m_step out of range")MsgAlert(false, WARNING, "m_step out of range");
354
355 ((u32*)m_Buffer)[m_step] = _uMail;
356 m_step++;
357
358 if (m_step >= m_numSteps)
359 {
360 ExecuteList();
361 m_bListInProgress = false;
362 }
363
364 return;
365 }
366
367 // Here holds: m_bSyncInProgress == false && m_bListInProgress == false
368
369 // Zelda-only mails:
370 // - 0000XXXX - Begin list
371 // - 00000000, 000X0000 - Sync mails
372 // - CDD1XXXX - comes after DsyncFrame completed, seems to be debugging stuff
373
374 if (_uMail == 0)
375 {
376 m_bSyncInProgress = true;
377 }
378 else if ((_uMail >> 16) == 0)
379 {
380 m_bListInProgress = true;
381 m_numSteps = _uMail;
382 m_step = 0;
383 }
384 else if ((_uMail >> 16) == 0xCDD1) // A 0xCDD1000X mail should come right after we send a DSP_FRAME_END mail
385 {
386 // The low part of the mail tells the operation to perform
387 // Seeing as every possible operation number halts the uCode,
388 // except 3, that thing seems to be intended for debugging
389 switch (_uMail & 0xFFFF)
390 {
391 case 0x0003: // Do nothing - continue normally
392 return;
393
394 case 0x0001: // accepts params to either dma to iram and/or dram (used for hotbooting a new ucode)
395 // TODO find a better way to protect from HLEMixer?
396 soundStream->GetMixer()->SetHLEReady(false);
397 m_UploadSetupInProgress = true;
398 return;
399
400 case 0x0002: // Let IROM play us off
401 m_DSPHLE->SetUCode(UCODE_ROM0x00000000);
402 return;
403
404 case 0x0000: // Halt
405 WARN_LOG(DSPHLE, "Zelda uCode: received halting operation %04X", _uMail & 0xFFFF)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 405, "Zelda uCode: received halting operation %04X", _uMail
& 0xFFFF); } } while (0)
;
406 return;
407
408 default: // Invalid (the real ucode would likely crash)
409 WARN_LOG(DSPHLE, "Zelda uCode: received invalid operation %04X", _uMail & 0xFFFF)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 409, "Zelda uCode: received invalid operation %04X", _uMail
& 0xFFFF); } } while (0)
;
410 return;
411 }
412 }
413 else
414 {
415 WARN_LOG(DSPHLE, "Zelda uCode: unknown mail %08X", _uMail)do { { if (LogTypes::LWARNING <= 3) GenericLog(LogTypes::LWARNING
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 415, "Zelda uCode: unknown mail %08X", _uMail); } } while (
0)
;
416 }
417}
418
419// zelda debug ..803F6418
420void CUCode_Zelda::ExecuteList()
421{
422 // begin with the list
423 m_readOffset = 0;
424
425 u32 CmdMail = Read32();
426 u32 Command = (CmdMail >> 24) & 0x7f;
427 u32 Sync;
428 u32 ExtraData = CmdMail & 0xFFFF;
429
430 if (IsLightVersion())
431 Sync = 0x62 + (Command << 1); // seen in DSP_UC_Luigi.txt
432 else
433 Sync = CmdMail >> 16;
434
435 DEBUG_LOG(DSPHLE, "==============================================================================")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 435, "=============================================================================="
); } } while (0)
;
436 DEBUG_LOG(DSPHLE, "Zelda UCode - execute dlist (command: 0x%04x : sync: 0x%04x)", Command, Sync)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 436, "Zelda UCode - execute dlist (command: 0x%04x : sync: 0x%04x)"
, Command, Sync); } } while (0)
;
437
438 switch (Command)
439 {
440 // dummy
441 case 0x00: break;
442
443 // DsetupTable ... zelda ww jumps to 0x0095
444 case 0x01:
445 {
446 m_NumVoices = ExtraData;
447 m_VoicePBsAddr = Read32() & 0x7FFFFFFF;
448 m_UnkTableAddr = Read32() & 0x7FFFFFFF;
449 m_AFCCoefTableAddr = Read32() & 0x7FFFFFFF;
450 m_ReverbPBsAddr = Read32() & 0x7FFFFFFF; // WARNING: reverb PBs are very different from voice PBs!
451
452 // Read the other table
453 u16 *TempPtr = (u16*)Memory::GetPointer(m_UnkTableAddr);
454 for (int i = 0; i < 0x280; i++)
455 m_MiscTable[i] = (s16)Common::swap16(TempPtr[i]);
456
457 // Read AFC coef table
458 TempPtr = (u16*)Memory::GetPointer(m_AFCCoefTableAddr);
459 for (int i = 0; i < 32; i++)
460 m_AFCCoefTable[i] = (s16)Common::swap16(TempPtr[i]);
461
462 DEBUG_LOG(DSPHLE, "DsetupTable")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 462, "DsetupTable"); } } while (0)
;
463 DEBUG_LOG(DSPHLE, "Num voice param blocks: %i", m_NumVoices)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 463, "Num voice param blocks: %i", m_NumVoices)
; } } while (0)
;
464 DEBUG_LOG(DSPHLE, "Voice param blocks address: 0x%08x", m_VoicePBsAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 464, "Voice param blocks address: 0x%08x", m_VoicePBsAddr
); } } while (0)
;
465
466 // This points to some strange data table. Don't know yet what it's for. Reverb coefs?
467 DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size: 0x40): 0x%08x", m_UnkTableAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 467, "DSPRES_FILTER (size: 0x40): 0x%08x", m_UnkTableAddr
); } } while (0)
;
468
469 // Zelda WW: This points to a 64-byte array of coefficients, which are EXACTLY the same
470 // as the AFC ADPCM coef array in decode.c of the in_cube winamp plugin,
471 // which can play Zelda audio. So, these should definitely be used when decoding AFC.
472 DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", m_AFCCoefTableAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 472, "DSPADPCM_FILTER (size: 0x500): 0x%08x", m_AFCCoefTableAddr
); } } while (0)
;
473 DEBUG_LOG(DSPHLE, "Reverb param blocks address: 0x%08x", m_ReverbPBsAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 473, "Reverb param blocks address: 0x%08x", m_ReverbPBsAddr
); } } while (0)
;
474 }
475 break;
476
477 // SyncFrame ... zelda ww jumps to 0x0243
478 case 0x02:
479 {
480 m_bSyncCmdPending = true;
481
482 m_CurBuffer = 0;
483 m_NumBuffers = (CmdMail >> 16) & 0xFF;
484
485 // Addresses for right & left buffers in main memory
486 // Each buffer is 160 bytes long. The number of (both left & right) buffers
487 // is set by the first mail of the list.
488 m_RightBuffersAddr = Read32() & 0x7FFFFFFF;
489 m_LeftBuffersAddr = Read32() & 0x7FFFFFFF;
490
491 DEBUG_LOG(DSPHLE, "DsyncFrame")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 491, "DsyncFrame"); } } while (0)
;
492 // These alternate between three sets of mixing buffers. They are all three fairly near,
493 // but not at, the ADMA read addresses.
494 DEBUG_LOG(DSPHLE, "Right buffer address: 0x%08x", m_RightBuffersAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 494, "Right buffer address: 0x%08x", m_RightBuffersAddr
); } } while (0)
;
495 DEBUG_LOG(DSPHLE, "Left buffer address: 0x%08x", m_LeftBuffersAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 495, "Left buffer address: 0x%08x", m_LeftBuffersAddr
); } } while (0)
;
496
497 if (IsLightVersion())
498 break;
499 else
500 return;
501 }
502
503
504 // Simply sends the sync messages
505 case 0x03: break;
506
507/* case 0x04: break; // dunno ... zelda ww jmps to 0x0580
508 case 0x05: break; // dunno ... zelda ww jmps to 0x0592
509 case 0x06: break; // dunno ... zelda ww jmps to 0x0469
510 case 0x07: break; // dunno ... zelda ww jmps to 0x044d
511 case 0x08: break; // Mixer ... zelda ww jmps to 0x0485
512 case 0x09: break; // dunno ... zelda ww jmps to 0x044d
513 */
514
515 // DsetDolbyDelay ... zelda ww jumps to 0x00b2
516 case 0x0d:
517 {
518 u32 tmp = Read32();
Value stored to 'tmp' during its initialization is never read
519 DEBUG_LOG(DSPHLE, "DSetDolbyDelay")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 519, "DSetDolbyDelay"); } } while (0)
;
520 DEBUG_LOG(DSPHLE, "DOLBY2_DELAY_BUF (size 0x960): 0x%08x", tmp)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 520, "DOLBY2_DELAY_BUF (size 0x960): 0x%08x", tmp); } }
while (0)
;
521 }
522 break;
523
524 // This opcode, in the SMG ucode, sets the base address for audio data transfers from main memory (using DMA).
525 // In the Zelda ucode, it is dummy, because this ucode uses accelerator for audio data transfers.
526 case 0x0e:
527 {
528 m_DMABaseAddr = Read32() & 0x7FFFFFFF;
529 DEBUG_LOG(DSPHLE, "DsetDMABaseAddr")do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 529, "DsetDMABaseAddr"); } } while (0)
;
530 DEBUG_LOG(DSPHLE, "DMA base address: 0x%08x", m_DMABaseAddr)do { { if (LogTypes::LDEBUG <= 3) GenericLog(LogTypes::LDEBUG
, LogTypes::DSPHLE, "/home/anal/dolphin-emu/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp"
, 530, "DMA base address: 0x%08x", m_DMABaseAddr
); } } while (0)
;
531 }
532 break;
533
534 // default ... zelda ww jumps to 0x0043
535 default:
536 PanicAlert("Zelda UCode - unknown command: %x (size %i)", Command, m_numSteps)MsgAlert(false, WARNING, "Zelda UCode - unknown command: %x (size %i)"
, Command, m_numSteps)
;
537 break;
538 }
539
540 // sync, we are ready
541 if (IsLightVersion())
542 {
543 if (m_bSyncCmdPending)
544 m_rMailHandler.PushMail(0x80000000 | m_NumBuffers); // after CMD_2
545 else
546 m_rMailHandler.PushMail(0x80000000 | Sync); // after CMD_0, CMD_1
547 }
548 else
549 {
550 m_rMailHandler.PushMail(DSP_SYNC);
551 DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
552 m_rMailHandler.PushMail(0xF3550000 | Sync);
553 }
554}
555
556u32 CUCode_Zelda::GetUpdateMs()
557{
558 return SConfig::GetInstance().m_LocalCoreStartupParameter.bWii ? 3 : 5;
559}
560
561void CUCode_Zelda::DoState(PointerWrap &p)
562{
563 // It's bad if we try to save during Mix()
564 std::lock_guard<std::mutex> lk(m_csMix);
565
566 p.Do(m_AFCCoefTable);
567 p.Do(m_MiscTable);
568
569 p.Do(m_bSyncInProgress);
570 p.Do(m_MaxVoice);
571 p.Do(m_SyncFlags);
572
573 p.Do(m_NumSyncMail);
574
575 p.Do(m_NumVoices);
576
577 p.Do(m_bSyncCmdPending);
578 p.Do(m_CurVoice);
579 p.Do(m_CurBuffer);
580 p.Do(m_NumBuffers);
581
582 p.Do(m_VoicePBsAddr);
583 p.Do(m_UnkTableAddr);
584 p.Do(m_AFCCoefTableAddr);
585 p.Do(m_ReverbPBsAddr);
586
587 p.Do(m_RightBuffersAddr);
588 p.Do(m_LeftBuffersAddr);
589 p.Do(m_pos);
590
591 p.Do(m_DMABaseAddr);
592
593 p.Do(m_numSteps);
594 p.Do(m_bListInProgress);
595 p.Do(m_step);
596 p.Do(m_Buffer);
597
598 p.Do(m_readOffset);
599
600 p.Do(m_MailState);
601 p.Do(m_PBMask);
602
603 p.Do(m_NumPBs);
604 p.Do(m_PBAddress);
605 p.Do(m_PBAddress2);
606
607 DoStateShared(p);
608}