mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-08-07 05:29:33 -06:00
lay base for AAC ucode
This commit is contained in:
@ -59,6 +59,7 @@ add_library(core STATIC
|
||||
WifiAP.cpp
|
||||
|
||||
DSP_HLE/UcodeBase.cpp
|
||||
DSP_HLE/AACUcode.cpp
|
||||
DSP_HLE/GraphicsUcode.cpp
|
||||
|
||||
fatfs/ff.c
|
||||
|
130
src/DSP_HLE/AACUcode.cpp
Normal file
130
src/DSP_HLE/AACUcode.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
Copyright 2016-2025 melonDS team
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS 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, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "../DSi.h"
|
||||
#include "AACUcode.h"
|
||||
#include "../Platform.h"
|
||||
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
using Platform::Log;
|
||||
using Platform::LogLevel;
|
||||
|
||||
namespace DSP_HLE
|
||||
{
|
||||
|
||||
|
||||
AACUcode::AACUcode(melonDS::DSi& dsi, int version) : UcodeBase(dsi)
|
||||
{
|
||||
DSi.RegisterEventFuncs(Event_DSi_DSPHLE, this, {MakeEventThunk(AACUcode, FinishCmd)});
|
||||
|
||||
if (version == -1)
|
||||
Log(LogLevel::Info, "DSP_HLE: initializing AAC decoder ucode (DSi sound app)\n");
|
||||
else
|
||||
Log(LogLevel::Info, "DSP_HLE: initializing AAC SDK ucode version %02X\n", version);
|
||||
}
|
||||
|
||||
AACUcode::~AACUcode()
|
||||
{
|
||||
DSi.UnregisterEventFuncs(Event_DSi_DSPHLE);
|
||||
}
|
||||
|
||||
void AACUcode::Reset()
|
||||
{
|
||||
UcodeBase::Reset();
|
||||
|
||||
CmdState = 0;
|
||||
CmdIndex = 0;
|
||||
CmdParamCount = 0;
|
||||
memset(CmdParams, 0, sizeof(CmdParams));
|
||||
}
|
||||
|
||||
void AACUcode::DoSavestate(Savestate *file)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
void AACUcode::SendData(u8 index, u16 val)
|
||||
{
|
||||
UcodeBase::SendData(index, val);
|
||||
|
||||
// CMD1 is used to send commands and parameters
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
printf("-- CMD1 = %04X, state=%d cmd=%d count=%d\n", val, CmdState,CmdIndex, CmdParamCount);
|
||||
RecvCmdWord();
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
CmdWritten[2] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AACUcode::RecvCmdWord()
|
||||
{
|
||||
u16 val = CmdReg[1];
|
||||
|
||||
if (CmdState == 0)
|
||||
{
|
||||
if (val == 1)
|
||||
{
|
||||
CmdState = 1;
|
||||
CmdIndex = val;
|
||||
CmdParamCount = 0;
|
||||
}
|
||||
}
|
||||
else if (CmdState == 1)
|
||||
{
|
||||
CmdParams[CmdParamCount] = val;
|
||||
CmdParamCount++;
|
||||
|
||||
if (CmdParamCount == 10)
|
||||
{
|
||||
// we received all the parameter words, schedule the command
|
||||
// 115000 cycles is the average of the time it takes on hardware
|
||||
// might be different depending on sample rate etc
|
||||
|
||||
CmdState = 2;
|
||||
|
||||
// TODO actually decode shit
|
||||
|
||||
DSi.ScheduleEvent(Event_DSi_DSPHLE, false, 115000, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
CmdWritten[1] = false;
|
||||
}
|
||||
|
||||
void AACUcode::FinishCmd(u32 param)
|
||||
{
|
||||
CmdState = 0;
|
||||
CmdParamCount = 0;
|
||||
|
||||
SendReply(0, param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
52
src/DSP_HLE/AACUcode.h
Normal file
52
src/DSP_HLE/AACUcode.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2016-2025 melonDS team
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS 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, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS 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 for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef AACUCODE_H
|
||||
#define AACUCODE_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "UcodeBase.h"
|
||||
#include "../Savestate.h"
|
||||
|
||||
namespace melonDS::DSP_HLE
|
||||
{
|
||||
|
||||
class AACUcode : public UcodeBase
|
||||
{
|
||||
public:
|
||||
AACUcode(melonDS::DSi& dsi, int version);
|
||||
~AACUcode();
|
||||
void Reset() override;
|
||||
void DoSavestate(Savestate* file) override;
|
||||
|
||||
void SendData(u8 index, u16 val) override;
|
||||
|
||||
protected:
|
||||
u8 CmdState;
|
||||
u16 CmdIndex;
|
||||
u8 CmdParamCount;
|
||||
u16 CmdParams[10];
|
||||
|
||||
void RecvCmdWord();
|
||||
void FinishCmd(u32 param);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // AACUCODE_H
|
@ -182,8 +182,7 @@ void GraphicsUcode::FinishCmd(u32 param)
|
||||
{
|
||||
case 2: CmdScalingBilinear(); break;
|
||||
case 3: CmdScalingBicubic(); break;
|
||||
case 10:
|
||||
CmdScalingOneThird(); break;
|
||||
case 10: CmdScalingOneThird(); break;
|
||||
default: CmdScalingNearest(); break;
|
||||
}
|
||||
break;
|
||||
@ -451,8 +450,6 @@ void GraphicsUcode::CmdScalingBicubic()
|
||||
wy[1] = CalcBicubicWeight(fy);
|
||||
wy[2] = CalcBicubicWeight(0x400 - fy);
|
||||
wy[3] = CalcBicubicWeight(0x800 - fy);
|
||||
//for (int i = 0; i < 4; i++)
|
||||
// printf("weight x%d = %08X y%d = %08X\n", i, wx[i], i, wy[i]);
|
||||
|
||||
s64 tr = 0, tg = 0, tb = 0;
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
#include "UcodeBase.h"
|
||||
#include "../Savestate.h"
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
namespace DSP_HLE
|
||||
namespace melonDS::DSP_HLE
|
||||
{
|
||||
|
||||
class GraphicsUcode : public UcodeBase
|
||||
@ -56,7 +54,6 @@ protected:
|
||||
void CmdYuvToRgb();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GRAPHICSUCODE_H
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "teakra/include/teakra/teakra.h"
|
||||
#include "DSP_HLE/AACUcode.h"
|
||||
#include "DSP_HLE/GraphicsUcode.h"
|
||||
|
||||
#include "DSi.h"
|
||||
@ -136,6 +137,10 @@ void DSi_DSP::StartDSPHLE()
|
||||
|
||||
switch (crc)
|
||||
{
|
||||
case 0x7867C94B: // DSi sound app AAC ucode
|
||||
DSPCore = new DSP_HLE::AACUcode(DSi, -1);
|
||||
break;
|
||||
|
||||
case 0xCD2A8B1B: // Graphics SDK ucode v0
|
||||
DSPCore = new DSP_HLE::GraphicsUcode(DSi, 0x00);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user