Merge branch 'master' into dynapand

This commit is contained in:
wheremyfoodat 2023-07-12 21:34:29 +03:00
commit 3a1a612e8b
27 changed files with 318 additions and 212 deletions

View file

@ -26,7 +26,7 @@ class GPU {
MAKE_LOG_FUNCTION(log, gpuLogger)
static constexpr u32 maxAttribCount = 12; // Up to 12 vertex attributes
static constexpr u32 vramSize = 6_MB;
static constexpr u32 vramSize = u32(6_MB);
Registers regs; // GPU internal registers
std::array<vec4f, 16> currentAttributes; // Vertex attributes before being passed to the shader

View file

@ -61,12 +61,18 @@ class Emulator {
std::optional<std::filesystem::path> romPath = std::nullopt;
public:
// Decides whether to reload or not reload the ROM when resetting. We use enum class over a plain bool for clarity.
// If NoReload is selected, the emulator will not reload its selected ROM. This is useful for things like booting up the emulator, or resetting to
// change ROMs. If Reload is selected, the emulator will reload its selected ROM. This is useful for eg a "reset" button that keeps the current ROM
// and just resets the emu
enum class ReloadOption { NoReload, Reload };
Emulator();
~Emulator();
void step();
void render();
void reset();
void reset(ReloadOption reload);
void run();
void runFrame();

View file

@ -113,9 +113,16 @@ namespace Helpers {
}
/// Extract bits from an integer-type
template <usize offset, usize bits, typename T>
static constexpr T getBits(T value) {
return (value >> offset) & ones<T, bits>();
template <usize offset, usize bits, typename ReturnT, typename ValueT>
static constexpr ReturnT getBits(ValueT value) {
static_assert((offset + bits) <= (CHAR_BIT * sizeof(ValueT)), "Invalid bit range");
static_assert(bits > 0, "Invalid bit size");
return ReturnT(ValueT(value >> offset) & ones<ValueT, bits>());
}
template <usize offset, usize bits, typename ValueT>
static constexpr ValueT getBits(ValueT value) {
return getBits<offset, bits, ValueT, ValueT>(value);
}
#ifdef HELPERS_APPLE_CLANG

View file

@ -1,7 +1,9 @@
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
#pragma once
#include <array>
#include <atomic>
#include <map>
#include <mutex>
#include "helpers.hpp"
@ -16,7 +18,19 @@ struct HttpServer {
std::mutex actionMutex = {};
u32 pendingKey = 0;
HttpServer();
void startHttpServer();
std::string status();
private:
std::map<std::string, std::pair<u32, bool>> keyMap;
std::array<bool, 12> pressedKeys = {};
bool paused = false;
u32 stringToKey(const std::string& key_name);
bool getKeyState(const std::string& key_name);
void setKeyState(const std::string& key_name, bool state);
};
#endif // PANDA3DS_ENABLE_HTTP_SERVER

View file

@ -11,20 +11,16 @@ namespace ConfigMem {
AppMemAlloc = 0x1FF80040,
HardwareType = 0x1FF81004,
Datetime0 = 0x1FF81020,
WifiMac = 0x1FF81060,
NetworkState = 0x1FF81067,
LedState3D = 0x1FF81084,
BatteryState = 0x1FF81085,
Unknown1086 = 0x1FF81086,
HeadphonesConnectedMaybe = 0x1FF810C0 // TODO: What is actually stored here?
HeadphonesConnectedMaybe = 0x1FF810C0 // TODO: What is actually stored here?
};
// Shows what type of hardware we're running on
namespace HardwareCodes {
enum : u8 {
Product = 1,
Devboard = 2,
Debugger = 3,
Capture = 4
};
enum : u8 { Product = 1, Devboard = 2, Debugger = 3, Capture = 4 };
}
}
} // namespace ConfigMem

View file

@ -110,7 +110,7 @@ class Memory {
std::vector<KernelMemoryTypes::MemoryInfo> memoryInfo;
std::array<SharedMemoryBlock, 3> sharedMemBlocks = {
SharedMemoryBlock(0, _shared_font_len, KernelHandles::FontSharedMemHandle), // Shared memory for the system font
SharedMemoryBlock(0, u32(_shared_font_len), KernelHandles::FontSharedMemHandle), // Shared memory for the system font
SharedMemoryBlock(0, 0x1000, KernelHandles::GSPSharedMemHandle), // GSP shared memory
SharedMemoryBlock(0, 0x1000, KernelHandles::HIDSharedMemHandle) // HID shared memory
};
@ -121,14 +121,14 @@ public:
static constexpr u32 pageMask = pageSize - 1;
static constexpr u32 totalPageCount = 1 << (32 - pageShift);
static constexpr u32 FCRAM_SIZE = 128_MB;
static constexpr u32 FCRAM_APPLICATION_SIZE = 64_MB;
static constexpr u32 FCRAM_SIZE = u32(128_MB);
static constexpr u32 FCRAM_APPLICATION_SIZE = u32(64_MB);
static constexpr u32 FCRAM_PAGE_COUNT = FCRAM_SIZE / pageSize;
static constexpr u32 FCRAM_APPLICATION_PAGE_COUNT = FCRAM_APPLICATION_SIZE / pageSize;
static constexpr u32 DSP_RAM_SIZE = 512_KB;
static constexpr u32 DSP_CODE_MEMORY_OFFSET = 0_KB;
static constexpr u32 DSP_DATA_MEMORY_OFFSET = 256_KB;
static constexpr u32 DSP_RAM_SIZE = u32(512_KB);
static constexpr u32 DSP_CODE_MEMORY_OFFSET = u32(0_KB);
static constexpr u32 DSP_DATA_MEMORY_OFFSET = u32(256_KB);
private:
std::bitset<FCRAM_PAGE_COUNT> usedFCRAMPages;
@ -141,8 +141,8 @@ private:
public:
u16 kernelVersion = 0;
u32 usedUserMemory = 0_MB; // How much of the APPLICATION FCRAM range is used (allocated to the appcore)
u32 usedSystemMemory = 0_MB; // Similar for the SYSTEM range (reserved for the syscore)
u32 usedUserMemory = u32(0_MB); // How much of the APPLICATION FCRAM range is used (allocated to the appcore)
u32 usedSystemMemory = u32(0_MB); // Similar for the SYSTEM range (reserved for the syscore)
Memory(u64& cpuTicks);
void reset();

View file

@ -34,6 +34,9 @@ class GPUService {
u32 privilegedProcess;
std::optional<Handle> interruptEvent;
// Number of threads registered via RegisterInterruptRelayQueue
u32 gspThreadCount = 0;
MAKE_LOG_FUNCTION(log, gspGPULogger)
void processCommandBuffer();