Make the mic button respect which slot it's plugged into.

*You need to open the Gamecube config page and reselect the devices in slot A and B after this commit*

Just jitil left...
This commit is contained in:
Shawn Hoffman 2011-10-09 03:18:15 -07:00
parent ceef98b882
commit 41424d98e8
12 changed files with 46 additions and 60 deletions

View File

@ -355,7 +355,7 @@ void SConfig::LoadSettings()
ini.Get("Core", "MemcardA", &m_strMemoryCardA);
ini.Get("Core", "MemcardB", &m_strMemoryCardB);
ini.Get("Core", "ReloadMemcardOnState", &b_reloadMCOnState, true);
ini.Get("Core", "SlotA", (int*)&m_EXIDevice[0], EXIDEVICE_MEMORYCARD_A);
ini.Get("Core", "SlotA", (int*)&m_EXIDevice[0], EXIDEVICE_MEMORYCARD);
ini.Get("Core", "SlotB", (int*)&m_EXIDevice[1], EXIDEVICE_NONE);
ini.Get("Core", "SerialPort1", (int*)&m_EXIDevice[2], EXIDEVICE_NONE);
ini.Get("Core", "BBA_MAC", &m_bba_mac);

View File

@ -75,18 +75,18 @@ void DoState(PointerWrap &p)
void ChangeDeviceCallback(u64 userdata, int cyclesLate)
{
u8 channel = (u8)(userdata >> 32);
u8 device = (u8)(userdata >> 16);
u8 slot = (u8)userdata;
u8 type = (u8)(userdata >> 16);
u8 num = (u8)userdata;
g_Channels[channel]->AddDevice((TEXIDevices)device, slot);
g_Channels[channel]->AddDevice((TEXIDevices)type, num);
}
void ChangeDevice(u8 channel, TEXIDevices device, u8 slot)
void ChangeDevice(const u8 channel, const TEXIDevices device_type, const u8 device_num)
{
// Called from GUI, so we need to make it thread safe.
// Let the hardware see no device for .5b cycles
CoreTiming::ScheduleEvent_Threadsafe(0, changeDevice, ((u64)channel << 32) | ((u64)EXIDEVICE_NONE << 16) | slot);
CoreTiming::ScheduleEvent_Threadsafe(500000000, changeDevice, ((u64)channel << 32) | ((u64)device << 16) | slot);
CoreTiming::ScheduleEvent_Threadsafe(0, changeDevice, ((u64)channel << 32) | ((u64)EXIDEVICE_NONE << 16) | device_num);
CoreTiming::ScheduleEvent_Threadsafe(500000000, changeDevice, ((u64)channel << 32) | ((u64)device_type << 16) | device_num);
}
// Unused (?!)

View File

@ -33,7 +33,7 @@ void Update();
void UpdateInterrupts();
void ChangeDeviceCallback(u64 userdata, int cyclesLate);
void ChangeDevice(u8 channel, TEXIDevices device, u8 slot);
void ChangeDevice(const u8 channel, const TEXIDevices device_type, const u8 device_num);
void Read32(u32& _uReturnValue, const u32 _iAddress);
void Write32(const u32 _iValue, const u32 _iAddress);

View File

@ -42,7 +42,7 @@ CEXIChannel::CEXIChannel(u32 ChannelId) :
m_Status.CHIP_SELECT = 1;
for (int i = 0; i < NUM_DEVICES; i++)
m_pDevices[i] = EXIDevice_Create(EXIDEVICE_NONE);
m_pDevices[i] = EXIDevice_Create(EXIDEVICE_NONE, i);
}
CEXIChannel::~CEXIChannel()
@ -59,19 +59,19 @@ void CEXIChannel::RemoveDevices()
}
}
void CEXIChannel::AddDevice(const TEXIDevices _device, const unsigned int _iSlot)
void CEXIChannel::AddDevice(const TEXIDevices device_type, const int device_num)
{
_dbg_assert_(EXPANSIONINTERFACE, _iSlot < NUM_DEVICES);
_dbg_assert_(EXPANSIONINTERFACE, device_num < NUM_DEVICES);
// delete the old device
if (m_pDevices[_iSlot] != NULL)
if (m_pDevices[device_num] != NULL)
{
delete m_pDevices[_iSlot];
m_pDevices[_iSlot] = NULL;
delete m_pDevices[device_num];
m_pDevices[device_num] = NULL;
}
// create the new one
m_pDevices[_iSlot] = EXIDevice_Create(_device);
m_pDevices[device_num] = EXIDevice_Create(device_type, device_num);
// This means "device presence changed", software has to check
// m_Status.EXT to see if it is now present or not
@ -107,9 +107,9 @@ bool CEXIChannel::IsCausingInterrupt()
}
}
IEXIDevice* CEXIChannel::GetDevice(u8 _CHIP_SELECT)
IEXIDevice* CEXIChannel::GetDevice(const u8 chip_select)
{
switch(_CHIP_SELECT)
switch (chip_select)
{
case 1: return m_pDevices[0];
case 2: return m_pDevices[1];

View File

@ -112,12 +112,12 @@ private:
public:
// get device
IEXIDevice* GetDevice(u8 _CHIP_SELECT);
IEXIDevice* GetDevice(const u8 _CHIP_SELECT);
CEXIChannel(u32 ChannelId);
~CEXIChannel();
void AddDevice(const TEXIDevices _device, const unsigned int _iSlot);
void AddDevice(const TEXIDevices device_type, const int device_num);
// Remove all devices
void RemoveDevices();

View File

@ -102,20 +102,16 @@ public:
// F A C T O R Y
IEXIDevice* EXIDevice_Create(TEXIDevices _EXIDevice)
IEXIDevice* EXIDevice_Create(TEXIDevices device_type, const int device_num)
{
switch(_EXIDevice)
switch (device_type)
{
case EXIDEVICE_DUMMY:
return new CEXIDummy("Dummy");
break;
case EXIDEVICE_MEMORYCARD_A:
return new CEXIMemoryCard("MemoryCardA", SConfig::GetInstance().m_strMemoryCardA, 0);
break;
case EXIDEVICE_MEMORYCARD_B:
return new CEXIMemoryCard("MemoryCardB", SConfig::GetInstance().m_strMemoryCardB, 1);
case EXIDEVICE_MEMORYCARD:
return new CEXIMemoryCard(device_num);
break;
case EXIDEVICE_MASKROM:
@ -127,7 +123,7 @@ IEXIDevice* EXIDevice_Create(TEXIDevices _EXIDevice)
break;
case EXIDEVICE_MIC:
return new CEXIMic();
return new CEXIMic(device_num);
break;
case EXIDEVICE_ETH:

View File

@ -53,8 +53,7 @@ public:
enum TEXIDevices
{
EXIDEVICE_DUMMY,
EXIDEVICE_MEMORYCARD_A,
EXIDEVICE_MEMORYCARD_B,
EXIDEVICE_MEMORYCARD,
EXIDEVICE_MASKROM,
EXIDEVICE_AD16,
EXIDEVICE_MIC,
@ -64,6 +63,6 @@ enum TEXIDevices
EXIDEVICE_NONE = (u8)-1
};
extern IEXIDevice* EXIDevice_Create(TEXIDevices _EXIDevice);
extern IEXIDevice* EXIDevice_Create(const TEXIDevices device_type, const int device_num);
#endif

View File

@ -43,13 +43,13 @@ void CEXIMemoryCard::FlushCallback(u64 userdata, int cyclesLate)
ptr->Flush();
}
CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rFilename, int _card_index) :
m_strFilename(_rFilename),
card_index(_card_index),
m_bDirty(false)
CEXIMemoryCard::CEXIMemoryCard(const int index)
: card_index(index)
, m_bDirty(false)
{
cards[_card_index] = this;
et_this_card = CoreTiming::RegisterEvent(_rName.c_str(), FlushCallback);
m_strFilename = (card_index == 0) ? SConfig::GetInstance().m_strMemoryCardA : SConfig::GetInstance().m_strMemoryCardB;
cards[card_index] = this;
et_this_card = CoreTiming::RegisterEvent((card_index == 0) ? "memcardA" : "memcardB", FlushCallback);
reloadOnState = SConfig::GetInstance().b_reloadMCOnState;
interruptSwitch = 0;
@ -426,9 +426,6 @@ void CEXIMemoryCard::DoState(PointerWrap &p)
{
if (reloadOnState)
{
int slot = 0;
if (GetFileName() == SConfig::GetInstance().m_strMemoryCardA)
slot = 1;
ExpansionInterface::ChangeDevice(slot, slot ? EXIDEVICE_MEMORYCARD_B : EXIDEVICE_MEMORYCARD_A, 0);
ExpansionInterface::ChangeDevice(card_index, EXIDEVICE_MEMORYCARD, 0);
}
}

View File

@ -32,7 +32,7 @@ struct FlushData
class CEXIMemoryCard : public IEXIDevice
{
public:
CEXIMemoryCard(const std::string& _rName, const std::string& _rFilename, int card_index);
CEXIMemoryCard(const int index);
virtual ~CEXIMemoryCard();
void SetCS(int cs);
void Update();
@ -40,8 +40,6 @@ public:
bool IsPresent();
void DoState(PointerWrap &p);
inline const std::string &GetFileName() const { return m_strFilename; };
private:
// This is scheduled whenever a page write is issued. The this pointer is passed
// through the userdata parameter, so that it can then call Flush on the right card.

View File

@ -19,9 +19,6 @@
#if HAVE_PORTAUDIO
#include "FileUtil.h"
#include "StringUtil.h"
#include "../Core.h"
#include "../CoreTiming.h"
#include "SystemTimers.h"
@ -30,7 +27,6 @@
#include <portaudio.h>
#include "GCPadStatus.h"
#include "GCPad.h"
static bool pa_init = false;
@ -128,7 +124,8 @@ void CEXIMic::StreamReadOne()
u8 const CEXIMic::exi_id[] = { 0, 0x0a, 0, 0, 0 };
int CEXIMic::mic_count = 0;
CEXIMic::CEXIMic()
CEXIMic::CEXIMic(int index)
: slot(index)
{
m_position = 0;
command = 0;
@ -207,13 +204,11 @@ void CEXIMic::TransferByte(u8 &byte)
case cmdGetStatus:
if (pos == 0)
{
status.button = Pad::GetMicButton(0); // TODO: slot A/B -> 0/1
}
status.button = Pad::GetMicButton(slot);
byte = status.U8[pos ^ 1];
if (pos == 1 && status.buff_ovrflw)
if (pos == 1)
status.buff_ovrflw = 0;
break;

View File

@ -23,7 +23,7 @@
class CEXIMic : public IEXIDevice
{
public:
CEXIMic();
CEXIMic(const int index);
virtual ~CEXIMic();
void SetCS(int cs);
bool IsInterruptSet();
@ -46,6 +46,8 @@ private:
};
// STATE_TO_SAVE
int slot;
u32 m_position;
int command;
union UStatus
@ -101,7 +103,7 @@ protected:
class CEXIMic : public IEXIDevice
{
public:
CEXIMic() {}
CEXIMic(const int) {}
};
#endif

View File

@ -406,8 +406,7 @@ void CConfigMain::InitializeGUIValues()
case EXIDEVICE_NONE:
GCEXIDevice[i]->SetStringSelection(SlotDevices[0]);
break;
case EXIDEVICE_MEMORYCARD_A:
case EXIDEVICE_MEMORYCARD_B:
case EXIDEVICE_MEMORYCARD:
isMemcard = GCEXIDevice[i]->SetStringSelection(SlotDevices[2]);
break;
case EXIDEVICE_MIC:
@ -1030,7 +1029,7 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
// Change memcard to the new file
ExpansionInterface::ChangeDevice(
isSlotA ? 0 : 1, // SlotA: channel 0, SlotB channel 1
isSlotA ? EXIDEVICE_MEMORYCARD_A : EXIDEVICE_MEMORYCARD_B,
EXIDEVICE_MEMORYCARD,
0); // SP1 is device 2, slots are device 0
}
}
@ -1068,7 +1067,7 @@ void CConfigMain::ChooseEXIDevice(std::string deviceName, int deviceNum)
TEXIDevices tempType;
if (!deviceName.compare(CSTR_TRANS(EXIDEV_MEMCARD_STR)))
tempType = deviceNum ? EXIDEVICE_MEMORYCARD_B : EXIDEVICE_MEMORYCARD_A;
tempType = EXIDEVICE_MEMORYCARD;
else if (!deviceName.compare(CSTR_TRANS(EXIDEV_MIC_STR)))
tempType = EXIDEVICE_MIC;
else if (!deviceName.compare(EXIDEV_BBA_STR))
@ -1083,7 +1082,7 @@ void CConfigMain::ChooseEXIDevice(std::string deviceName, int deviceNum)
tempType = EXIDEVICE_DUMMY;
// Gray out the memcard path button if we're not on a memcard
if (tempType == EXIDEVICE_MEMORYCARD_A || tempType == EXIDEVICE_MEMORYCARD_B)
if (tempType == EXIDEVICE_MEMORYCARD)
GCMemcardPath[deviceNum]->Enable();
else if (deviceNum == 0 || deviceNum == 1)
GCMemcardPath[deviceNum]->Disable();