all repos — mgba @ fb473e5eb43fad9e4fa57345f64923c51b26071b

mGBA Game Boy Advance Emulator

GBA Peripherals: Partial Beast Link Gate support
Vicki Pfau vi@endrift.com
Sat, 16 Feb 2019 14:05:09 -0800
commit

fb473e5eb43fad9e4fa57345f64923c51b26071b

parent

bf996df244cc4fe322c16ffbe550d4b2f600dc37

M include/mgba/gba/interface.hinclude/mgba/gba/interface.h

@@ -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 {
A res/chip-names-6.txt

@@ -0,0 +1,399 @@

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
M src/gba/core.csrc/gba/core.c

@@ -535,6 +535,7 @@ gba->luminanceSource = periph;

break; case mPERIPH_GBA_BATTLECHIP_GATE: GBASIOSetDriver(&gba->sio, periph, SIO_MULTI); + GBASIOSetDriver(&gba->sio, periph, SIO_NORMAL_32); break; default: return;
M src/gba/extra/battlechip.csrc/gba/extra/battlechip.c

@@ -27,7 +27,8 @@

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,12 +88,28 @@ return value;

} 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;

@@ -116,6 +133,9 @@ break;

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 @@ case 0x537B:

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 @@ case 0xD97D:

case 0xD97E: reply = ok; break; + case 0x3545: + case 0x3546: + case 0x3547: + case 0x3548: + case 0x3549: + case 0x354A: case 0x424A: case 0x424B: case 0x424C:
M src/platform/qt/BattleChipView.cppsrc/platform/qt/BattleChipView.cpp

@@ -39,7 +39,16 @@ }

}); 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); + } } });

@@ -68,6 +77,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);
M src/platform/qt/BattleChipView.uisrc/platform/qt/BattleChipView.ui

@@ -77,9 +77,6 @@ </widget>

</item> <item row="2" column="1"> <widget class="QRadioButton" name="gateBeastLink"> - <property name="enabled"> - <bool>false</bool> - </property> <property name="text"> <string>Beast &amp;Link Gate</string> </property>
M src/platform/qt/resources.qrcsrc/platform/qt/resources.qrc

@@ -6,5 +6,6 @@ <file>../../../res/patrons.txt</file>

<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>