all repos — mgba @ 85a85672e434fc4df288828d26fe5a1beb9c7ed2

mGBA Game Boy Advance Emulator

GBA Peripherals: Start implementing Progress Gate
Vicki Pfau vi@endrift.com
Fri, 15 Feb 2019 21:41:04 -0800
commit

85a85672e434fc4df288828d26fe5a1beb9c7ed2

parent

c82f9f0efcd8c8e1f000902773504cfa667c3ab7

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

@@ -60,12 +60,19 @@

void GBASIOJOYCreate(struct GBASIODriver* sio); int GBASIOJOYSendCommand(struct GBASIODriver* sio, enum GBASIOJOYCommand command, uint8_t* data); +enum GBASIOBattleChipGateFlavor { + GBA_FLAVOR_BATTLECHIP_GATE = 4, + GBA_FLAVOR_PROGRESS_GATE = 5, + GBA_FLAVOR_BEAST_LINK_GATE = 6, +}; + struct GBASIOBattlechipGate { struct GBASIODriver d; struct mTimingEvent event; uint16_t chipId; uint16_t data[2]; int state; + int flavor; }; void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate*);
A res/chip-names-5.txt

@@ -0,0 +1,379 @@

+Cannon +Hi Cannon +Mega Cannon +Air Shot +Air Hockey + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Fanfare + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +ProtoMan Navi +NumberMan Navi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
M src/gba/extra/battlechip.csrc/gba/extra/battlechip.c

@@ -26,6 +26,8 @@ };

enum { BATTLECHIP_OK = 0xFFC6, + PROGRESS_GATE_OK = 0xFFC7, + BEAST_LINK_GATE_OK = 0xFFC8, BATTLECHIP_CONTINUE = 0xFFFF, };

@@ -46,11 +48,13 @@

gate->event.context = gate; gate->event.callback = _battlechipTransferEvent; gate->event.priority = 0x80; + + gate->chipId = 0; + gate->flavor = GBA_FLAVOR_BATTLECHIP_GATE; } bool GBASIOBattlechipGateInit(struct GBASIODriver* driver) { struct GBASIOBattlechipGate* gate = (struct GBASIOBattlechipGate*) driver; - gate->chipId = 0; return true; }

@@ -100,6 +104,20 @@ gate->d.p->multiplayerControl.id = 0;

mLOG(GBA_BATTLECHIP, DEBUG, "> %04X", cmd); + uint16_t ok; + switch (gate->flavor) { + case GBA_FLAVOR_BATTLECHIP_GATE: + default: + ok = BATTLECHIP_OK; + break; + case GBA_FLAVOR_PROGRESS_GATE: + ok = PROGRESS_GATE_OK; + break; + case GBA_FLAVOR_BEAST_LINK_GATE: + ok = BEAST_LINK_GATE_OK; + break; + } + switch (gate->state) { case BATTLECHIP_STATE_COMMAND: mLOG(GBA_BATTLECHIP, DEBUG, "C %04X", cmd);

@@ -112,6 +130,7 @@ case 0xA3A0:

case 0xA3B0: case 0xA3C0: case 0xA3D0: + case 0xA6C0: gate->state = -1; // Fall through case 0x5379:

@@ -120,14 +139,22 @@ case 0x537B:

case 0x537C: case 0x537D: case 0x537E: + case 0xC4D8: case 0xD979: case 0xD97A: case 0xD97B: case 0xD97C: case 0xD97D: case 0xD97E: - reply = BATTLECHIP_OK; + reply = ok; break; + case 0x424A: + case 0x424B: + case 0x424C: + case 0x424D: + case 0x424E: + case 0x424F: + case 0x4250: case 0x5745: case 0x5746: case 0x5747:

@@ -150,12 +177,12 @@ break;

case BATTLECHIP_STATE_DATA_0: reply = gate->data[0]; gate->data[0] += 3; - gate->data[0] &= 0xF0FF; + gate->data[0] &= 0x00FF; break; case BATTLECHIP_STATE_DATA_1: reply = gate->data[1]; gate->data[1] -= 3; - gate->data[1] |= 0xFE00; + gate->data[1] |= 0xFC00; break; case BATTLECHIP_STATE_ID: reply = gate->chipId;

@@ -165,7 +192,7 @@ case BATTLECHIP_STATE_UNK_3:

reply = 0; break; case BATTLECHIP_STATE_END: - reply = BATTLECHIP_OK; + reply = ok; gate->state = -1; break; }
M src/platform/qt/BattleChipView.cppsrc/platform/qt/BattleChipView.cpp

@@ -27,6 +27,24 @@

connect(m_ui.inserted, &QAbstractButton::toggled, this, &BattleChipView::insertChip); connect(controller.get(), &CoreController::stopping, this, &QWidget::close); + connect(m_ui.gateBattleChip, &QAbstractButton::toggled, this, [this](bool on) { + if (on) { + setFlavor(4); + } + }); + connect(m_ui.gateProgress, &QAbstractButton::toggled, this, [this](bool on) { + if (on) { + setFlavor(5); + } + }); + connect(m_ui.gateBeastLink, &QAbstractButton::toggled, this, [this](bool on) { + if (on) { + setFlavor(6); + } + }); + + + m_controller->attachBattleChipGate(); setFlavor(4); }

@@ -35,6 +53,7 @@ m_controller->detachBattleChipGate();

} void BattleChipView::setFlavor(int flavor) { + m_controller->setBattleChipFlavor(flavor); loadChipNames(flavor); }
M src/platform/qt/BattleChipView.uisrc/platform/qt/BattleChipView.ui

@@ -7,46 +7,92 @@ <rect>

<x>0</x> <y>0</y> <width>426</width> - <height>152</height> + <height>278</height> </rect> </property> <property name="windowTitle"> <string>BattleChip Gate</string> </property> <layout class="QFormLayout" name="formLayout"> - <item row="2" column="1"> + <item row="5" column="1"> <widget class="QCheckBox" name="inserted"> <property name="text"> <string>Inserted</string> </property> </widget> </item> - <item row="1" column="0"> + <item row="4" column="0"> <widget class="QLabel" name="label"> <property name="text"> <string>Chip ID</string> </property> </widget> </item> - <item row="0" column="0"> + <item row="3" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>Chip Name</string> + <string>Chip name</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="4" column="1"> <widget class="QSpinBox" name="chipId"> <property name="maximum"> <number>65535</number> </property> </widget> </item> - <item row="0" column="1"> + <item row="3" column="1"> <widget class="QComboBox" name="chipName"/> </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Gate type</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QRadioButton" name="gateProgress"> + <property name="text"> + <string>Progress &amp;Gate</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">gate</string> + </attribute> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="gateBattleChip"> + <property name="text"> + <string>Ba&amp;ttleChip Gate</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">gate</string> + </attribute> + </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> + <attribute name="buttonGroup"> + <string notr="true">gate</string> + </attribute> + </widget> + </item> </layout> </widget> <resources/> <connections/> + <buttongroups> + <buttongroup name="gate"/> + </buttongroups> </ui>
M src/platform/qt/CoreController.cppsrc/platform/qt/CoreController.cpp

@@ -750,6 +750,14 @@ }

Interrupter interrupter(this); m_battlechip.chipId = id; } + +void CoreController::setBattleChipFlavor(int flavor) { + if (platform() != PLATFORM_GBA) { + return; + } + Interrupter interrupter(this); + m_battlechip.flavor = flavor; +} #endif void CoreController::setAVStream(mAVStream* stream) {
M src/platform/qt/CoreController.hsrc/platform/qt/CoreController.h

@@ -143,6 +143,7 @@ #ifdef M_CORE_GBA

void attachBattleChipGate(); void detachBattleChipGate(); void setBattleChipId(uint16_t id); + void setBattleChipFlavor(int flavor); #endif void setAVStream(mAVStream*);
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -1365,12 +1365,7 @@ #endif

#ifdef M_CORE_GBA QAction* bcGate = new QAction(tr("BattleChip Gate..."), emulationMenu); - connect(bcGate, &QAction::triggered, [this]() { - BattleChipView* view = new BattleChipView(m_controller); - openView(view); - m_controller->attachBattleChipGate(); - - }); + connect(bcGate, &QAction::triggered, openControllerTView<BattleChipView>()); addControlledAction(emulationMenu, bcGate, "bcGate"); m_gbaActions.append(bcGate); m_gameActions.append(bcGate);
M src/platform/qt/resources.qrcsrc/platform/qt/resources.qrc

@@ -5,5 +5,6 @@ <file>../../../res/keymap.qpic</file>

<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> </qresource> </RCC>