mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
DSP HLE: Break out the ADPCM decoder, add a few comments.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3504 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -593,14 +593,6 @@
|
||||
RelativePath=".\Src\UCodes\UCode_ROM.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCodes.cpp"
|
||||
>
|
||||
@@ -673,6 +665,26 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="UCode Zelda"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda_ADPCM.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\UCodes\UCode_Zelda_ADPCM.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ConfigDialog"
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
#include "UCodes.h"
|
||||
|
||||
// This uCode should be deleted and replaced with a small modification of the Zelda uCode.
|
||||
// The big difference is that games using this one won't send "message counts"
|
||||
// before sending the command data.
|
||||
|
||||
class CUCode_Jac : public IUCode
|
||||
{
|
||||
private:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,6 @@
|
||||
#include "Common.h"
|
||||
#include "UCodes.h"
|
||||
|
||||
|
||||
|
||||
struct ZPB
|
||||
{
|
||||
// R/W data =============
|
||||
@@ -35,17 +33,18 @@ struct ZPB
|
||||
u16 unk5;
|
||||
u16 unk6;
|
||||
|
||||
u16 unk7[0x2C]; // 0x033
|
||||
u16 SampleData[0x4D];
|
||||
u16 unk7[0x2C]; // 0x033
|
||||
u16 SampleData[0x4D]; // 0x4D = 9 * 8
|
||||
|
||||
// Read only data(0x80 to the end)
|
||||
u16 type; // 0x5, 0x9 = AFC.
|
||||
// From here, "read only" data (0x80 to the end)
|
||||
// 0x88, 0x89 could be volume
|
||||
u16 type; // 0x5, 0x9 = AFC. There are more types but we've only seen AFC so far.
|
||||
u16 r_unknown1;
|
||||
|
||||
u16 r_unknown2[0x14 / 2];
|
||||
|
||||
// Not sure what addresses this is, hopefully to sample data in ARAM.
|
||||
// These are the only things in the param blocks that look a lot like pointers.
|
||||
// Pointer to sample data in ARAM.
|
||||
// These are the only things in the param blocks that look a lot like pointers.
|
||||
u16 addr_high; // at 0x18 = 0xC * 2
|
||||
u16 addr_low;
|
||||
|
||||
@@ -60,6 +59,28 @@ namespace {
|
||||
|
||||
class CUCode_Zelda : public IUCode
|
||||
{
|
||||
public:
|
||||
CUCode_Zelda(CMailHandler& _rMailHandler);
|
||||
virtual ~CUCode_Zelda();
|
||||
|
||||
void HandleMail(u32 _uMail);
|
||||
void Update(int cycles);
|
||||
void MixAdd(short* buffer, int size);
|
||||
|
||||
void UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _Size);
|
||||
|
||||
void CopyPBsFromRAM();
|
||||
void CopyPBsToRAM();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
int *templbuffer;
|
||||
int *temprbuffer;
|
||||
|
||||
// simple dump ...
|
||||
void DumpPB(const ZPB& _rPB);
|
||||
int DumpAFC(u8* pIn, const int size, const int srate);
|
||||
|
||||
private:
|
||||
enum EDSP_Codes
|
||||
{
|
||||
@@ -72,7 +93,7 @@ private:
|
||||
};
|
||||
|
||||
// AFC CoefTable
|
||||
short m_AFCCoefTable[16][2];
|
||||
s16 m_AFCCoefTable[32];
|
||||
|
||||
// Command 0x2: SyncFrame
|
||||
int m_NumberOfFramesToRender;
|
||||
@@ -86,7 +107,6 @@ private:
|
||||
|
||||
u32 m_readOffset;
|
||||
|
||||
|
||||
enum EMailState
|
||||
{
|
||||
WaitForMail,
|
||||
@@ -94,63 +114,28 @@ private:
|
||||
ReadingMessage,
|
||||
ReadingSystemMsg
|
||||
};
|
||||
|
||||
EMailState m_MailState;
|
||||
u16 m_PBMask[0x10];
|
||||
|
||||
|
||||
u32 m_NumPBs;
|
||||
u32 m_PBAddress;
|
||||
u32 m_PBAddress; // The main param block array
|
||||
u32 m_PBAddress2; // 4 smaller param blocks
|
||||
|
||||
u32 m_MixingBufferLeft;
|
||||
u32 m_MixingBufferRight;
|
||||
|
||||
u32 m_MaxSyncedPB;
|
||||
|
||||
ZPB m_PBs[0x40];
|
||||
|
||||
|
||||
|
||||
u8 Read8()
|
||||
{
|
||||
return m_Buffer[m_readOffset++];
|
||||
}
|
||||
|
||||
u16 Read16()
|
||||
{
|
||||
u16 res = *(u16*)&m_Buffer[m_readOffset];
|
||||
m_readOffset += 2;
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 Read32()
|
||||
{
|
||||
u32 res = *(u32*)&m_Buffer[m_readOffset];
|
||||
m_readOffset += 4;
|
||||
return res;
|
||||
}
|
||||
public:
|
||||
|
||||
CUCode_Zelda(CMailHandler& _rMailHandler);
|
||||
virtual ~CUCode_Zelda();
|
||||
|
||||
void HandleMail(u32 _uMail);
|
||||
void Update(int cycles);
|
||||
void MixAdd(short* buffer, int size);
|
||||
|
||||
|
||||
void UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _Size);
|
||||
|
||||
void CopyPBsFromRAM();
|
||||
void CopyPBsToRAM();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
int AFCdecodebuffer(char *input, signed short *out, short * histp, short * hist2p, int type = 9);
|
||||
|
||||
|
||||
int *templbuffer;
|
||||
int *temprbuffer;
|
||||
|
||||
// simple dump ...
|
||||
void DumpPB(const ZPB& _rPB);
|
||||
int DumpAFC(u8* pIn, const int size, const int srate);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// Copyright (C) 2003-2008 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/
|
||||
|
||||
#include "Common.h"
|
||||
#include "UCode_Zelda_ADPCM.h"
|
||||
|
||||
void AFCdecodebuffer(const s16 *coef, const char *input, signed short *out, short *histp, short *hist2p, int type)
|
||||
{
|
||||
short nibbles[16];
|
||||
short hist = *histp;
|
||||
short hist2 = *hist2p;
|
||||
|
||||
const char *src = input;
|
||||
char *dst = (char*)out;
|
||||
|
||||
// First 2 nibbles are ADPCM scale etc.
|
||||
short delta = 1 << (((*src) >> 4) & 0xf);
|
||||
short idx = (*src) & 0xf;
|
||||
|
||||
src++;
|
||||
|
||||
if (type == 9)
|
||||
{
|
||||
for (int i = 0; i < 16; i = i + 2) {
|
||||
int j = (*src & 255) >> 4;
|
||||
nibbles[i] = j;
|
||||
j = *src & 255 & 15;
|
||||
nibbles[i+1] = j;
|
||||
src++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i = i + 1) {
|
||||
if (nibbles[i] >= 8)
|
||||
nibbles[i] = nibbles[i] - 16;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// untested !!! i havnt seen such a sample yet :)
|
||||
for (int i = 0; i < 16; i += 4)
|
||||
{
|
||||
int j = (*src >> 0) & 0x02;
|
||||
nibbles[i] = j;
|
||||
|
||||
j = (*src >> 2) & 0x02;
|
||||
nibbles[i+1] = j;
|
||||
|
||||
j = (*src >> 4) & 0x02;
|
||||
nibbles[i+2] = j;
|
||||
|
||||
j = (*src >> 6) & 0x02;
|
||||
nibbles[i+3] = j;
|
||||
|
||||
src++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (nibbles[i] >= 2)
|
||||
nibbles[i] = nibbles[i] - 4;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
int sample = (delta * nibbles[i]) << 11;
|
||||
sample += ((long)hist * coef[idx * 2]) + ((long)hist2 * coef[idx * 2 + 1]);
|
||||
sample = sample >> 11;
|
||||
if (sample > 32767) {
|
||||
sample = 32767;
|
||||
}
|
||||
if (sample < -32768) {
|
||||
sample = -32768;
|
||||
}
|
||||
*(short*)dst = (short)sample;
|
||||
dst = dst + 2;
|
||||
hist2 = hist;
|
||||
hist = (short)sample;
|
||||
}
|
||||
|
||||
*histp=hist;
|
||||
*hist2p=hist2;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2003-2008 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/
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
void AFCdecodebuffer(const s16 *coef, const char *input, signed short *out, short *histp, short *hist2p, int type);
|
||||
@@ -56,13 +56,14 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler)
|
||||
case 0xd73338cf: // IPL
|
||||
case 0x42f64ac4: // Luigi (after fix)
|
||||
case 0x4be6a5cb: // AC, Pikmin (after fix)
|
||||
INFO_LOG(CONSOLE, "JAC ucode chosen\n");
|
||||
INFO_LOG(CONSOLE, "JAC (early Zelda) ucode chosen\n");
|
||||
return new CUCode_Jac(_rMailHandler);
|
||||
// return new CUCode_Zelda(_rMailHandler, false);
|
||||
|
||||
case 0x6CA33A6D: // DK Jungle Beat
|
||||
case 0x86840740: // zelda
|
||||
case 0x56d36052: // mario
|
||||
case 0x2fcdf1ec: // mariokart, zelda 4 swords
|
||||
case 0x86840740: // Zelda WW
|
||||
case 0x56d36052: // Mario Sunshine
|
||||
case 0x2fcdf1ec: // Mario Kart, zelda 4 swords
|
||||
INFO_LOG(CONSOLE, "Zelda ucode chosen\n");
|
||||
return new CUCode_Zelda(_rMailHandler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user