Skip to content

Commit

Permalink
Basic infrastructure for the new AX HLE, currently not doing anything…
Browse files Browse the repository at this point in the history
… besides answering mails
  • Loading branch information
delroth committed Nov 14, 2012
1 parent e4d18e3 commit 3195916
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Core/Core/CMakeLists.txt
Expand Up @@ -74,6 +74,7 @@ set(SRCS Src/ActionReplay.cpp
Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp
Src/HW/DSPHLE/UCodes/UCode_CARD.cpp
Src/HW/DSPHLE/UCodes/UCode_InitAudioSystem.cpp
Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp
Src/HW/DSPHLE/UCodes/UCode_ROM.cpp
Src/HW/DSPHLE/UCodes/UCodes.cpp
Src/HW/DSPHLE/UCodes/UCode_GBA.cpp
Expand Down
106 changes: 106 additions & 0 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp
@@ -0,0 +1,106 @@
// Copyright (C) 2003 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 Git repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/

#include "UCode_NewAX.h"
#include "../../DSP.h"

CUCode_NewAX::CUCode_NewAX(DSPHLE* dsp_hle, u32 crc)
: IUCode(dsp_hle, crc)
{
m_rMailHandler.PushMail(DSP_INIT);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
}

CUCode_NewAX::~CUCode_NewAX()
{
m_rMailHandler.Clear();
}

void CUCode_NewAX::HandleCommandList(u32 addr)
{
// Signal end of processing
m_rMailHandler.PushMail(DSP_YIELD);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
}

void CUCode_NewAX::HandleMail(u32 mail)
{
// Indicates if the next message is a command list address.
static bool next_is_cmdlist = false;
bool set_next_is_cmdlist = false;

if (next_is_cmdlist)
{
HandleCommandList(mail);
}
else if (m_UploadSetupInProgress)
{
PrepareBootUCode(mail);
}
else if (mail == MAIL_RESUME)
{
// Acknowledge the resume request
m_rMailHandler.PushMail(DSP_RESUME);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
}
else if (mail == MAIL_NEWUCODE)
{
soundStream->GetMixer()->SetHLEReady(false);
m_UploadSetupInProgress = true;
}
else if (mail == MAIL_RESET)
{
m_DSPHLE->SetUCode(UCODE_ROM);
}
else if (mail == MAIL_CONTINUE)
{
// We don't have to do anything here - the CPU does not wait for a ACK
// and sends a cmdlist mail just after.
}
else if ((mail & MAIL_CMDLIST_MASK) == MAIL_CMDLIST)
{
// A command list address is going to be sent next.
set_next_is_cmdlist = true;
}
else
{
ERROR_LOG(DSPHLE, "Unknown mail sent to AX::HandleMail: %08x", mail);
}

next_is_cmdlist = set_next_is_cmdlist;
}

void CUCode_NewAX::MixAdd(short* out_buffer, int nsamples)
{
// nsamples * 2 for left and right audio channel
memset(out_buffer, 0, nsamples * 2 * sizeof (short));
}

void CUCode_NewAX::Update(int cycles)
{
// Used for UCode switching.
if (NeedsResumeMail())
{
m_rMailHandler.PushMail(DSP_RESUME);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
}
}

void CUCode_NewAX::DoState(PointerWrap& p)
{
DoStateShared(p);
}
51 changes: 51 additions & 0 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.h
@@ -0,0 +1,51 @@
// Copyright (C) 2003 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 Git repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/

#ifndef _UCODE_NEWAX_H
#define _UCODE_NEWAX_H

#include "UCodes.h"
#include "UCode_AXStructs.h"

class CUCode_NewAX : public IUCode
{
public:
CUCode_NewAX(DSPHLE* dsp_hle, u32 crc);
virtual ~CUCode_NewAX();

void HandleMail(u32 mail);
void MixAdd(short* out_buffer, int nsamples);
void Update(int cycles);
void DoState(PointerWrap& p);

private:
enum MailType
{
MAIL_RESUME = 0xCDD10000,
MAIL_NEWUCODE = 0xCDD10001,
MAIL_RESET = 0xCDD10002,
MAIL_CONTINUE = 0xCDD10003,

// CPU sends 0xBABE0000 | cmdlist_size to the DSP
MAIL_CMDLIST = 0xBABE0000,
MAIL_CMDLIST_MASK = 0xFFFF0000
};

void HandleCommandList(u32 addr);
};

#endif // !_UCODE_NEWAX_H
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp
Expand Up @@ -19,6 +19,7 @@

#include "UCode_AX.h"
#include "UCode_AXWii.h"
#include "UCode_NewAX.h"
#include "UCode_Zelda.h"
#include "UCode_ROM.h"
#include "UCode_CARD.h"
Expand Down Expand Up @@ -57,7 +58,7 @@ IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii)
case 0xe2136399: // billy hatcher, dragonballz, mario party 5, TMNT, ava1080
case 0x3389a79e: // MP1/MP2 Wii (Metroid Prime Trilogy)
INFO_LOG(DSPHLE, "CRC %08x: AX ucode chosen", _CRC);
return new CUCode_AX(dsp_hle, _CRC);
return new CUCode_NewAX(dsp_hle, _CRC);

case 0x6ba3b3ea: // IPL - PAL
case 0x24b22038: // IPL - NTSC/NTSC-JAP
Expand Down

0 comments on commit 3195916

Please sign in to comment.