From 4d4f0c8490f4c57d851ce73f0ccd6ee6dae91024 Mon Sep 17 00:00:00 2001 From: Xphalnos Date: Fri, 20 Jun 2025 20:33:57 +0200 Subject: [PATCH] Reorganization of source & Clang-Format --- 3rd_Party/rem | 2 +- README.md | 8 ++++-- assets/README.md | 5 ---- assets/fw/README.md | 5 ---- core/ARM/cpu.h | 8 ++++-- core/JIT/jit.cpp | 31 ++++++++++----------- core/JIT/jit.h | 5 ++-- {assets => resources}/Logo(1024x1024).webp | Bin {docs => resources/docs}/compguide.md | 0 9 files changed, 28 insertions(+), 36 deletions(-) delete mode 100644 assets/README.md delete mode 100644 assets/fw/README.md rename {assets => resources}/Logo(1024x1024).webp (100%) rename {docs => resources/docs}/compguide.md (100%) diff --git a/3rd_Party/rem b/3rd_Party/rem index cf9cff6..2db639e 160000 --- a/3rd_Party/rem +++ b/3rd_Party/rem @@ -1 +1 @@ -Subproject commit cf9cff6039b68239cec122b425eba04f9acfcd9c +Subproject commit 2db639ed5715224a42c0d4f3ec070e4c4d6d26ac diff --git a/README.md b/README.md index ef89fc1..b42c2ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

@@ -15,7 +15,9 @@ Join the [**Pound Discord Server**](https://discord.gg/aMmTmKsVC7)! -**Pound** is an early-stage emulator for the **Nintendo Switch 2**, targeting **Android**, **macOS** (Intel and ARM), **Windows**, and **Linux** (Intel and ARM). +**Pound** is an early-stage emulator for the **Nintendo Switch 2**, targeting **Windows**, **Linux** and **macOS** (Intel). + +Future Supports: **Android**, **macOS ARM** > [!IMPORTANT] > Pound is still in early development — don't expect miracles. @@ -25,7 +27,7 @@ Initial focus is on implementing the **CPU**, leveraging its architectural simil ## How to Compile Pound -See the [**compilation guide**](/docs/compguide.md) for detailed instructions. +See the [**compilation guide**](/resources/docs/compguide.md) for detailed instructions. ## Codebase diff --git a/assets/README.md b/assets/README.md deleted file mode 100644 index e6a3438..0000000 --- a/assets/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Assets folder - -dir: /assets/ - -This is where all of the assets for the repository and application belong (e.g branding, firmware dumps, images, demo videos) \ No newline at end of file diff --git a/assets/fw/README.md b/assets/fw/README.md deleted file mode 100644 index 3a21c5a..0000000 --- a/assets/fw/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Firmware dump folder - -dir: /assets/fw/ - -This is where your dumped firmware will go (will be used heavily during buildtime) \ No newline at end of file diff --git a/core/ARM/cpu.h b/core/ARM/cpu.h index 48eab5a..d94754e 100644 --- a/core/ARM/cpu.h +++ b/core/ARM/cpu.h @@ -12,9 +12,13 @@ struct CPU { static constexpr size_t MEM_SIZE = 64 * 1024; u8 memory[MEM_SIZE]; - CPU() { std::memset(memory, 0, MEM_SIZE); } + CPU() { + std::memset(memory, 0, MEM_SIZE); + } - u64 &x(int i) { return regs[i]; } + u64& x(int i) { + return regs[i]; + } u8 read_byte(u64 addr) { if (addr >= MEM_SIZE) { diff --git a/core/JIT/jit.cpp b/core/JIT/jit.cpp index 8222a14..2f00162 100644 --- a/core/JIT/jit.cpp +++ b/core/JIT/jit.cpp @@ -14,32 +14,30 @@ using JitFunc = void (*)(); -void JIT::translate_and_run(CPU &cpu) { +void JIT::translate_and_run(CPU& cpu) { -// TODO: Create REM Context -create_rem_context(nullptr, nullptr, nullptr, nullptr, nullptr); + // TODO: Create REM Context + create_rem_context(nullptr, nullptr, nullptr, nullptr, nullptr); #ifdef WIN32 - u8 *code = (u8 *)VirtualAlloc(NULL, 64, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + u8* code = (u8*)VirtualAlloc(NULL, 64, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); #else - u8 *code = (u8 *)mmap(nullptr, 64, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); + u8* code = (u8*)mmap(nullptr, 64, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); #endif size_t offset = 0; // Decode mock instructions from cpu.memory - if (cpu.memory[0] == 0x05) - { // MOVZ placeholder - code[offset++] = 0x48; // mov rax, imm64 + if (cpu.memory[0] == 0x05) { // MOVZ placeholder + code[offset++] = 0x48; // mov rax, imm64 code[offset++] = 0xB8; u64 imm = 5; std::memcpy(&code[offset], &imm, sizeof(imm)); offset += 8; } - if (cpu.memory[4] == 0x03) - { // ADD placeholder - code[offset++] = 0x48; // add rax, imm32 + if (cpu.memory[4] == 0x03) { // ADD placeholder + code[offset++] = 0x48; // add rax, imm32 code[offset++] = 0x05; u32 addval = 3; std::memcpy(&code[offset], &addval, sizeof(addval)); @@ -50,12 +48,11 @@ create_rem_context(nullptr, nullptr, nullptr, nullptr, nullptr); JitFunc fn = reinterpret_cast(code); u64 result; - asm volatile( - "call *%1\n" - "mov %%rax, %0\n" - : "=r"(result) - : "r"(fn) - : "%rax"); + asm volatile("call *%1\n" + "mov %%rax, %0\n" + : "=r"(result) + : "r"(fn) + : "%rax"); cpu.regs[0] = result; } diff --git a/core/JIT/jit.h b/core/JIT/jit.h index 46f1e7f..fb0aa1f 100644 --- a/core/JIT/jit.h +++ b/core/JIT/jit.h @@ -4,8 +4,7 @@ #include "ARM/cpu.h" -class JIT -{ +class JIT { public: - void translate_and_run(CPU &cpu); + void translate_and_run(CPU& cpu); }; diff --git a/assets/Logo(1024x1024).webp b/resources/Logo(1024x1024).webp similarity index 100% rename from assets/Logo(1024x1024).webp rename to resources/Logo(1024x1024).webp diff --git a/docs/compguide.md b/resources/docs/compguide.md similarity index 100% rename from docs/compguide.md rename to resources/docs/compguide.md