GBA Peripherals: Add BattleChip Gate dummy interface

This commit is contained in:
Vicki Pfau 2019-02-11 21:40:45 -08:00
parent f7f8e38dc1
commit 22531a1315
8 changed files with 201 additions and 21 deletions

View File

@ -24,6 +24,7 @@ enum {
BATTLECHIP_CONTINUE = 0xFFFF,
};
static bool GBASIOBattlechipGateInit(struct GBASIODriver* driver);
static bool GBASIOBattlechipGateLoad(struct GBASIODriver* driver);
static uint16_t GBASIOBattlechipGateWriteRegister(struct GBASIODriver* driver, uint32_t address, uint16_t value);
@ -31,7 +32,7 @@ static void _battlechipTransfer(struct GBASIOBattlechipGate* gate);
static void _battlechipTransferEvent(struct mTiming* timing, void* user, uint32_t cyclesLate);
void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate* gate) {
gate->d.init = NULL;
gate->d.init = GBASIOBattlechipGateInit;
gate->d.deinit = NULL;
gate->d.load = GBASIOBattlechipGateLoad;
gate->d.unload = NULL;
@ -42,6 +43,12 @@ void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate* gate) {
gate->event.priority = 0x80;
}
bool GBASIOBattlechipGateInit(struct GBASIODriver* driver) {
struct GBASIOBattlechipGate* gate = (struct GBASIOBattlechipGate*) driver;
gate->chipId = 0;
return true;
}
bool GBASIOBattlechipGateLoad(struct GBASIODriver* driver) {
struct GBASIOBattlechipGate* gate = (struct GBASIOBattlechipGate*) driver;
gate->index = BATTLECHIP_INDEX_END;

View File

@ -0,0 +1,36 @@
/* Copyright (c) 2013-2019 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BattleChipView.h"
#include "CoreController.h"
using namespace QGBA;
BattleChipView::BattleChipView(std::shared_ptr<CoreController> controller, QWidget* parent)
: QDialog(parent)
, m_controller(controller)
{
m_ui.setupUi(this);
connect(m_ui.chipId, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), m_ui.inserted, [this]() {
m_ui.inserted->setChecked(Qt::Checked);
insertChip(true);
});
connect(m_ui.inserted, &QAbstractButton::toggled, this, &BattleChipView::insertChip);
connect(controller.get(), &CoreController::stopping, this, &QWidget::close);
}
BattleChipView::~BattleChipView() {
m_controller->detachBattleChipGate();
}
void BattleChipView::insertChip(bool inserted) {
if (inserted) {
m_controller->setBattleChipId(m_ui.chipId->value());
} else {
m_controller->setBattleChipId(0);
}
}

View File

@ -0,0 +1,36 @@
/* Copyright (c) 2013-2019 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#pragma once
#include <QDialog>
#include <memory>
#include <mgba/core/interface.h>
#include "ui_BattleChipView.h"
namespace QGBA {
class CoreController;
class BattleChipView : public QDialog {
Q_OBJECT
public:
BattleChipView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
~BattleChipView();
public slots:
void insertChip(bool);
private:
Ui::BattleChipView m_ui;
std::shared_ptr<CoreController> m_controller;
};
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BattleChipView</class>
<widget class="QDialog" name="BattleChipView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>217</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>BattleChip Gate</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="1">
<widget class="QCheckBox" name="inserted">
<property name="text">
<string>Inserted</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Chip ID</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="chipId">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -102,7 +102,6 @@ set(SOURCE_FILES
OverrideView.cpp
PaletteView.cpp
PlacementControl.cpp
PrinterView.cpp
RegisterView.cpp
ROMInfo.cpp
RotatedHeaderView.cpp
@ -124,6 +123,7 @@ set(UI_FILES
AboutScreen.ui
ArchiveInspector.ui
AssetTile.ui
BattleChipView.ui
CheatsView.ui
DebuggerConsole.ui
GIFView.ui
@ -147,10 +147,12 @@ set(UI_FILES
VideoView.ui)
set(GBA_SRC
BattleChipView.cpp
GBAOverride.cpp)
set(GB_SRC
GBOverride.cpp)
GBOverride.cpp
PrinterView.cpp)
set(QT_LIBRARIES)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5,libqt5opengl5")

View File

@ -672,8 +672,8 @@ void CoreController::exportSharkport(const QString& path) {
#endif
}
void CoreController::attachPrinter() {
#ifdef M_CORE_GB
void CoreController::attachPrinter() {
if (platform() != PLATFORM_GB) {
return;
}
@ -703,11 +703,9 @@ void CoreController::attachPrinter() {
};
Interrupter interrupter(this);
GBSIOSetDriver(&gb->sio, &m_printer.d.d);
#endif
}
void CoreController::detachPrinter() {
#ifdef M_CORE_GB
if (platform() != PLATFORM_GB) {
return;
}
@ -715,18 +713,44 @@ void CoreController::detachPrinter() {
GB* gb = static_cast<GB*>(m_threadContext.core->board);
GBPrinterDonePrinting(&m_printer.d);
GBSIOSetDriver(&gb->sio, nullptr);
#endif
}
void CoreController::endPrint() {
#ifdef M_CORE_GB
if (platform() != PLATFORM_GB) {
return;
}
Interrupter interrupter(this);
GBPrinterDonePrinting(&m_printer.d);
#endif
}
#endif
#ifdef M_CORE_GBA
void CoreController::attachBattleChipGate() {
if (platform() != PLATFORM_GBA) {
return;
}
Interrupter interrupter(this);
clearMultiplayerController();
GBASIOBattlechipGateCreate(&m_battlechip);
m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_BATTLECHIP_GATE, &m_battlechip);
}
void CoreController::detachBattleChipGate() {
if (platform() != PLATFORM_GBA) {
return;
}
Interrupter interrupter(this);
m_threadContext.core->setPeripheral(m_threadContext.core, mPERIPH_GBA_BATTLECHIP_GATE, nullptr);
}
void CoreController::setBattleChipId(uint16_t id) {
if (platform() != PLATFORM_GBA) {
return;
}
Interrupter interrupter(this);
m_battlechip.chipId = id;
}
#endif
void CoreController::setAVStream(mAVStream* stream) {
Interrupter interrupter(this);

View File

@ -25,6 +25,10 @@
#include <mgba/internal/gb/sio/printer.h>
#endif
#ifdef M_CORE_GBA
#include <mgba/gba/interface.h>
#endif
struct mCore;
namespace QGBA {
@ -129,9 +133,17 @@ public slots:
void importSharkport(const QString& path);
void exportSharkport(const QString& path);
#ifdef M_CORE_GB
void attachPrinter();
void detachPrinter();
void endPrint();
#endif
#ifdef M_CORE_GBA
void attachBattleChipGate();
void detachBattleChipGate();
void setBattleChipId(uint16_t id);
#endif
void setAVStream(mAVStream*);
void clearAVStream();
@ -222,6 +234,10 @@ private:
CoreController* parent;
} m_printer;
#endif
#ifdef M_CORE_GBA
GBASIOBattlechipGate m_battlechip;
#endif
};
}

View File

@ -21,6 +21,7 @@
#include "AboutScreen.h"
#include "AudioProcessor.h"
#include "BattleChipView.h"
#include "CheatsView.h"
#include "ConfigController.h"
#include "CoreController.h"
@ -1350,6 +1351,31 @@ void Window::setupMenu(QMenuBar* menubar) {
addControlledAction(solarMenu, setSolar, QString("luminanceLevel.%1").arg(QString::number(i)));
}
#ifdef M_CORE_GB
QAction* gbPrint = new QAction(tr("Game Boy Printer..."), emulationMenu);
connect(gbPrint, &QAction::triggered, [this]() {
PrinterView* view = new PrinterView(m_controller);
openView(view);
m_controller->attachPrinter();
});
addControlledAction(emulationMenu, gbPrint, "gbPrint");
m_gameActions.append(gbPrint);
#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();
});
addControlledAction(emulationMenu, bcGate, "bcGate");
m_gbaActions.append(bcGate);
m_gameActions.append(bcGate);
#endif
QMenu* avMenu = menubar->addMenu(tr("Audio/&Video"));
m_shortcutController->addMenu(avMenu);
QMenu* frameMenu = avMenu->addMenu(tr("Frame size"));
@ -1495,18 +1521,6 @@ void Window::setupMenu(QMenuBar* menubar) {
addControlledAction(avMenu, stopVL, "stopVL");
m_gameActions.append(stopVL);
#ifdef M_CORE_GB
QAction* gbPrint = new QAction(tr("Game Boy Printer..."), avMenu);
connect(gbPrint, &QAction::triggered, [this]() {
PrinterView* view = new PrinterView(m_controller);
openView(view);
m_controller->attachPrinter();
});
addControlledAction(avMenu, gbPrint, "gbPrint");
m_gameActions.append(gbPrint);
#endif
avMenu->addSeparator();
m_videoLayers = avMenu->addMenu(tr("Video layers"));
m_shortcutController->addMenu(m_videoLayers, avMenu);