mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
Start adding memory stuff
This commit is contained in:
parent
2057e0c447
commit
905c7ed770
8 changed files with 77 additions and 10 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "dynarmic/interface/A32/a32.h"
|
||||
#include "dynarmic/interface/A32/config.h"
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
|
||||
public:
|
||||
|
@ -79,9 +80,11 @@ public:
|
|||
class CPU {
|
||||
MyEnvironment env;
|
||||
Dynarmic::A32::Jit jit{ {.callbacks = &env} };
|
||||
Memory& mem;
|
||||
|
||||
public:
|
||||
CPU();
|
||||
CPU(Memory& mem);
|
||||
void reset();
|
||||
|
||||
void setReg(int index, u32 value) {
|
||||
jit.Regs()[index] = value;
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
|
||||
class Emulator {
|
||||
CPU cpu;
|
||||
Memory memory;
|
||||
sf::RenderWindow window;
|
||||
static constexpr u32 width = 400;
|
||||
static constexpr u32 height = 240 * 2; // * 2 because 2 screens
|
||||
|
||||
public:
|
||||
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)) {
|
||||
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
|
||||
cpu(memory) {
|
||||
reset();
|
||||
window.setActive(true);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ using s16 = std::int16_t;
|
|||
using s32 = std::int32_t;
|
||||
using s64 = std::int64_t;
|
||||
|
||||
class Helpers {
|
||||
public:
|
||||
namespace Helpers {
|
||||
[[noreturn]] static void panic(const char* fmt, ...) {
|
||||
std::va_list args;
|
||||
va_start(args, fmt);
|
||||
|
@ -133,6 +132,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// UDLs for memory size values
|
||||
constexpr size_t operator""_KB(unsigned long long int x) {
|
||||
return 1024ULL * x;
|
||||
}
|
||||
|
||||
constexpr size_t operator""_MB(unsigned long long int x) {
|
||||
return 1024_KB * x;
|
||||
}
|
||||
|
||||
constexpr size_t operator""_GB(unsigned long long int x) {
|
||||
return 1024_MB * x;
|
||||
}
|
||||
|
||||
// useful macros
|
||||
// likely/unlikely
|
||||
#ifdef __GNUC__
|
||||
|
|
18
include/memory.hpp
Normal file
18
include/memory.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include "helpers.hpp"
|
||||
|
||||
class Memory {
|
||||
u8* fcram;
|
||||
|
||||
// Our dynarmic core uses page tables for reads and writes with 4096 byte pages
|
||||
std::vector<uintptr_t> readTable, writeTable;
|
||||
static constexpr u32 pageShift = 12;
|
||||
static constexpr u32 pageSize = 1 << pageShift;
|
||||
static constexpr u32 pageMask = pageSize - 1;
|
||||
|
||||
public:
|
||||
Memory();
|
||||
void* getReadPointer(u32 address);
|
||||
void* getWritePointer(u32 address);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue