Let us start here, from square one. No, from Zero!
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#include "bc.h"
|
||||
|
||||
#include "hooks/setupapihook.h"
|
||||
#include "util/libutils.h"
|
||||
#include "acio2emu/handle.h"
|
||||
#include "acioemu/handle.h"
|
||||
#include "node.h"
|
||||
|
||||
namespace games::bc {
|
||||
void BCGame::attach() {
|
||||
Game::attach();
|
||||
|
||||
setupapihook_init(libutils::load_library("libaio.dll"));
|
||||
setupapihook_add({
|
||||
{ 0, 0, 0, 0, },
|
||||
"",
|
||||
"USB\\VID_1CCF&PID_8050\\0000",
|
||||
{},
|
||||
"COM3",
|
||||
});
|
||||
|
||||
auto iob = new acio2emu::IOBHandle(L"COM3");
|
||||
iob->register_node(std::make_unique<TBSNode>());
|
||||
|
||||
devicehook_init();
|
||||
devicehook_add(iob);
|
||||
devicehook_add(new acioemu::ACIOHandle(L"COM1"));
|
||||
}
|
||||
|
||||
void BCGame::detach() {
|
||||
Game::detach();
|
||||
|
||||
devicehook_dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "games/game.h"
|
||||
|
||||
namespace games::bc {
|
||||
class BCGame : public games::Game {
|
||||
public:
|
||||
BCGame() : Game("Busou Shinki: Armored Princess Battle Conductor") {}
|
||||
|
||||
virtual void attach() override;
|
||||
virtual void detach() override;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "io.h"
|
||||
|
||||
std::vector<Button> &games::bc::get_buttons() {
|
||||
static std::vector<Button> buttons;
|
||||
|
||||
if (buttons.empty()) {
|
||||
buttons = GameAPI::Buttons::getButtons("Busou Shinki: Armored Princess Battle Conductor");
|
||||
|
||||
GameAPI::Buttons::sortButtons(
|
||||
&buttons,
|
||||
"Service",
|
||||
"Test",
|
||||
"Up",
|
||||
"Down",
|
||||
"Left",
|
||||
"Right",
|
||||
"Joystick Button",
|
||||
"Trigger 1",
|
||||
"Trigger 2",
|
||||
"Button 1",
|
||||
"Button 2",
|
||||
"Button 3",
|
||||
"Button 4"
|
||||
);
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cfg/api.h"
|
||||
|
||||
namespace games::bc {
|
||||
namespace Buttons {
|
||||
enum {
|
||||
Service,
|
||||
Test,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
JoystickButton,
|
||||
Trigger1,
|
||||
Trigger2,
|
||||
Button1,
|
||||
Button2,
|
||||
Button3,
|
||||
Button4,
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<Button> &get_buttons();
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "io.h"
|
||||
|
||||
#include "acio2emu/firmware/bi2x.h"
|
||||
|
||||
#include "misc/eamuse.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
namespace games::bc {
|
||||
class TBSNode : public acio2emu::firmware::BI2XNode {
|
||||
private:
|
||||
uint8_t coins_ = 0;
|
||||
|
||||
public:
|
||||
void read_firmware_version(std::vector<uint8_t> &buffer) {
|
||||
static constexpr uint8_t ver[] = {
|
||||
0x0D, 0x06, 0x00, 0x01,
|
||||
0x00, 0x01, 0x02, 0x08,
|
||||
0x42, 0x49, 0x32, 0x58,
|
||||
0x01, 0x94, 0xF1, 0x8E,
|
||||
0x00, 0x00, 0x01, 0x0B,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xA8, 0x24, 0x8E, 0xE2,
|
||||
};
|
||||
|
||||
buffer.insert(buffer.end(), ver, &ver[sizeof(ver)]);
|
||||
}
|
||||
|
||||
bool read_input(std::vector<uint8_t> &buffer) {
|
||||
auto &buttons = get_buttons();
|
||||
coins_ += eamuse_coin_consume_stock();
|
||||
|
||||
buffer.reserve(buffer.size() + 10);
|
||||
buffer.push_back(0);
|
||||
buffer.push_back(0);
|
||||
buffer.push_back(coins_);
|
||||
|
||||
uint8_t b = 0;
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Test])) {
|
||||
b |= 1;
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Service])) {
|
||||
b |= (1 << 2);
|
||||
}
|
||||
buffer.push_back(b);
|
||||
|
||||
buffer.push_back(0);
|
||||
|
||||
int16_t joy = INT16_MAX;
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Left])) {
|
||||
joy += INT16_MAX;
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Right])) {
|
||||
joy -= INT16_MAX;
|
||||
}
|
||||
buffer.push_back(static_cast<uint8_t>(joy >> 8));
|
||||
buffer.push_back(static_cast<uint8_t>(joy));
|
||||
|
||||
joy = INT16_MAX;
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Down])) {
|
||||
joy += INT16_MAX;
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Up])) {
|
||||
joy -= INT16_MAX;
|
||||
}
|
||||
buffer.push_back(static_cast<uint8_t>(joy >> 8));
|
||||
buffer.push_back(static_cast<uint8_t>(joy));
|
||||
|
||||
b = 0;
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::JoystickButton])) {
|
||||
b |= 1;
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Trigger1])) {
|
||||
b |= (1 << 1);
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Trigger2])) {
|
||||
b |= (1 << 2);
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Button1])) {
|
||||
b |= (1 << 3);
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Button2])) {
|
||||
b |= (1 << 4);
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Button3])) {
|
||||
b |= (1 << 5);
|
||||
}
|
||||
if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::Button4])) {
|
||||
b |= (1 << 6);
|
||||
}
|
||||
buffer.push_back(b);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int write_output(std::span<const uint8_t> buffer) {
|
||||
return 8;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user