mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-20 14:01:44 +12:00
commit
52314c188c
7 changed files with 103 additions and 68 deletions
|
@ -1,12 +1,15 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "services/hid.hpp"
|
||||
|
||||
class ActionReplay {
|
||||
using Cheat = std::vector<u32>; // A cheat is really just a bunch of 64-bit opcodes neatly encoded into 32-bit chunks
|
||||
static constexpr size_t ifStackSize = 32; // TODO: How big is this, really?
|
||||
|
||||
u32 offset1, offset2; // Memory offset registers. Non-persistent.
|
||||
u32 data1, data2; // Data offset registers. Non-persistent.
|
||||
|
@ -15,10 +18,14 @@ class ActionReplay {
|
|||
// When an instruction does not specify which offset or data register to use, we use the "active" one
|
||||
// Which is by default #1 and may be changed by certain AR operations
|
||||
u32 *activeOffset, *activeData, *activeStorage;
|
||||
|
||||
u32 ifStackIndex; // Our index in the if stack. Shows how many entries we have at the moment.
|
||||
u32 loopStackIndex; // Same but for loops
|
||||
std::bitset<32> ifStack;
|
||||
|
||||
// Program counter
|
||||
u32 pc = 0;
|
||||
Memory& mem;
|
||||
HIDService& hid;
|
||||
|
||||
// Has the cheat ended?
|
||||
bool running = false;
|
||||
|
@ -36,8 +43,10 @@ class ActionReplay {
|
|||
void write16(u32 addr, u16 value);
|
||||
void write32(u32 addr, u32 value);
|
||||
|
||||
void pushConditionBlock(bool condition);
|
||||
|
||||
public:
|
||||
ActionReplay(Memory& mem);
|
||||
ActionReplay(Memory& mem, HIDService& hid);
|
||||
void runCheat(const Cheat& cheat);
|
||||
void reset();
|
||||
};
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "action_replay.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "services/hid.hpp"
|
||||
|
||||
// Forward-declare this since it's just passed and we don't want to include memory.hpp and increase compile time
|
||||
class Memory;
|
||||
|
@ -20,12 +21,12 @@ class Cheats {
|
|||
std::vector<u32> instructions;
|
||||
};
|
||||
|
||||
Cheats(Memory& mem);
|
||||
Cheats(Memory& mem, HIDService& hid);
|
||||
void addCheat(const Cheat& cheat);
|
||||
void reset();
|
||||
void run();
|
||||
|
||||
private:
|
||||
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||
std::vector<Cheat> cheats;
|
||||
};
|
|
@ -91,6 +91,7 @@ class HIDService {
|
|||
void pressKey(u32 mask) { newButtons |= mask; }
|
||||
void releaseKey(u32 mask) { newButtons &= ~mask; }
|
||||
|
||||
u32 getOldButtons() { return oldButtons; }
|
||||
s16 getCirclepadX() { return circlePadX; }
|
||||
s16 getCirclepadY() { return circlePadY; }
|
||||
|
||||
|
|
|
@ -90,17 +90,5 @@ class ServiceManager {
|
|||
void signalDSPEvents() { dsp.signalEvents(); }
|
||||
|
||||
// Input function wrappers
|
||||
void pressKey(u32 key) { hid.pressKey(key); }
|
||||
void releaseKey(u32 key) { hid.releaseKey(key); }
|
||||
s16 getCirclepadX() { return hid.getCirclepadX(); }
|
||||
s16 getCirclepadY() { return hid.getCirclepadY(); }
|
||||
void setCirclepadX(s16 x) { hid.setCirclepadX(x); }
|
||||
void setCirclepadY(s16 y) { hid.setCirclepadY(y); }
|
||||
void updateInputs(u64 currentTimestamp) { hid.updateInputs(currentTimestamp); }
|
||||
void setTouchScreenPress(u16 x, u16 y) { hid.setTouchScreenPress(x, y); }
|
||||
void releaseTouchScreen() { hid.releaseTouchScreen(); }
|
||||
|
||||
void setRoll(s16 roll) { hid.setRoll(roll); }
|
||||
void setPitch(s16 pitch) { hid.setPitch(pitch); }
|
||||
void setYaw(s16 yaw) { hid.setYaw(yaw); }
|
||||
HIDService& getHID() { return hid; }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue