mirror of https://github.com/mgba-emu/mgba.git
GBA Peripherals: Partial Beast Link Gate support
This commit is contained in:
parent
bf996df244
commit
fb473e5eb4
|
@ -64,6 +64,7 @@ enum GBASIOBattleChipGateFlavor {
|
|||
GBA_FLAVOR_BATTLECHIP_GATE = 4,
|
||||
GBA_FLAVOR_PROGRESS_GATE = 5,
|
||||
GBA_FLAVOR_BEAST_LINK_GATE = 6,
|
||||
GBA_FLAVOR_BEAST_LINK_GATE_US = 7,
|
||||
};
|
||||
|
||||
struct GBASIOBattlechipGate {
|
||||
|
|
|
@ -0,0 +1,399 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -535,6 +535,7 @@ static void _GBACoreSetPeripheral(struct mCore* core, int type, void* periph) {
|
|||
break;
|
||||
case mPERIPH_GBA_BATTLECHIP_GATE:
|
||||
GBASIOSetDriver(&gba->sio, periph, SIO_MULTI);
|
||||
GBASIOSetDriver(&gba->sio, periph, SIO_NORMAL_32);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
|
|
@ -27,7 +27,8 @@ enum {
|
|||
enum {
|
||||
BATTLECHIP_OK = 0xFFC6,
|
||||
PROGRESS_GATE_OK = 0xFFC7,
|
||||
BEAST_LINK_GATE_OK = 0xFFC8,
|
||||
BEAST_LINK_GATE_OK = 0xFFC4,
|
||||
BEAST_LINK_GATE_US_OK = 0xFF00,
|
||||
BATTLECHIP_CONTINUE = 0xFFFF,
|
||||
};
|
||||
|
||||
|
@ -87,13 +88,29 @@ uint16_t GBASIOBattlechipGateWriteRegister(struct GBASIODriver* driver, uint32_t
|
|||
}
|
||||
|
||||
void _battlechipTransfer(struct GBASIOBattlechipGate* gate) {
|
||||
int32_t cycles = GBASIOCyclesPerTransfer[gate->d.p->multiplayerControl.baud][1];
|
||||
int32_t cycles;
|
||||
if (gate->d.p->mode == SIO_NORMAL_32) {
|
||||
cycles = GBA_ARM7TDMI_FREQUENCY / 0x40000;
|
||||
} else {
|
||||
cycles = GBASIOCyclesPerTransfer[gate->d.p->multiplayerControl.baud][1];
|
||||
}
|
||||
mTimingDeschedule(&gate->d.p->p->timing, &gate->event);
|
||||
mTimingSchedule(&gate->d.p->p->timing, &gate->event, cycles);
|
||||
}
|
||||
|
||||
void _battlechipTransferEvent(struct mTiming* timing, void* user, uint32_t cyclesLate) {
|
||||
struct GBASIOBattlechipGate* gate = user;
|
||||
|
||||
if (gate->d.p->mode == SIO_NORMAL_32) {
|
||||
gate->d.p->p->memory.io[REG_SIODATA32_LO >> 1] = 0;
|
||||
gate->d.p->p->memory.io[REG_SIODATA32_HI >> 1] = 0;
|
||||
gate->d.p->normalControl.start = 0;
|
||||
if (gate->d.p->normalControl.irq) {
|
||||
GBARaiseIRQ(gate->d.p->p, IRQ_SIO);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t cmd = gate->d.p->p->memory.io[REG_SIOMLT_SEND >> 1];
|
||||
uint16_t reply = 0xFFFF;
|
||||
gate->d.p->p->memory.io[REG_SIOMULTI0 >> 1] = cmd;
|
||||
|
@ -116,6 +133,9 @@ void _battlechipTransferEvent(struct mTiming* timing, void* user, uint32_t cycle
|
|||
case GBA_FLAVOR_BEAST_LINK_GATE:
|
||||
ok = BEAST_LINK_GATE_OK;
|
||||
break;
|
||||
case GBA_FLAVOR_BEAST_LINK_GATE_US:
|
||||
ok = BEAST_LINK_GATE_US_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (gate->state) {
|
||||
|
@ -139,7 +159,18 @@ void _battlechipTransferEvent(struct mTiming* timing, void* user, uint32_t cycle
|
|||
case 0x537C:
|
||||
case 0x537D:
|
||||
case 0x537E:
|
||||
case 0xB7D3:
|
||||
case 0xB7D4:
|
||||
case 0xB7D5:
|
||||
case 0xB7D6:
|
||||
case 0xB7D7:
|
||||
case 0xB7D8:
|
||||
case 0xC4D8:
|
||||
case 0xC4D9:
|
||||
case 0xC4DA:
|
||||
case 0xC4DB:
|
||||
case 0xC4DC:
|
||||
case 0xC4DD:
|
||||
case 0xD979:
|
||||
case 0xD97A:
|
||||
case 0xD97B:
|
||||
|
@ -148,6 +179,12 @@ void _battlechipTransferEvent(struct mTiming* timing, void* user, uint32_t cycle
|
|||
case 0xD97E:
|
||||
reply = ok;
|
||||
break;
|
||||
case 0x3545:
|
||||
case 0x3546:
|
||||
case 0x3547:
|
||||
case 0x3548:
|
||||
case 0x3549:
|
||||
case 0x354A:
|
||||
case 0x424A:
|
||||
case 0x424B:
|
||||
case 0x424C:
|
||||
|
|
|
@ -39,7 +39,16 @@ BattleChipView::BattleChipView(std::shared_ptr<CoreController> controller, QWidg
|
|||
});
|
||||
connect(m_ui.gateBeastLink, &QAbstractButton::toggled, this, [this](bool on) {
|
||||
if (on) {
|
||||
setFlavor(6);
|
||||
char title[9];
|
||||
CoreController::Interrupter interrupter(m_controller);
|
||||
mCore* core = m_controller->thread()->core;
|
||||
title[8] = '\0';
|
||||
core->getGameCode(core, title);
|
||||
if (title[7] == 'E' || title[7] == 'P') {
|
||||
setFlavor(7);
|
||||
} else {
|
||||
setFlavor(6);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -69,6 +78,10 @@ void BattleChipView::loadChipNames(int flavor) {
|
|||
QStringList chipNames;
|
||||
chipNames.append(tr("(None)"));
|
||||
|
||||
if (flavor == 7) {
|
||||
flavor = 6;
|
||||
}
|
||||
|
||||
QFile file(QString(":/res/chip-names-%1.txt").arg(flavor));
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
while (true) {
|
||||
|
|
|
@ -77,9 +77,6 @@
|
|||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="gateBeastLink">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Beast &Link Gate</string>
|
||||
</property>
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
<file>../../../res/no-cam.png</file>
|
||||
<file>../../../res/chip-names-4.txt</file>
|
||||
<file>../../../res/chip-names-5.txt</file>
|
||||
<file>../../../res/chip-names-6.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in New Issue