From a1b95e9ccf9bd7b316adf21952e43e03f2bf3746 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 19 Nov 2024 17:52:36 +1300 Subject: Implement memory device The memory device is fully implemented, with 3MB of heap memory. This commit is a bit messy, additional changes are: - The program memory and program counter in each Bedrock struct have been moved to a dedicated struct to prevent a name collision with the memory device - The run_bg and debug functions have been moved to core.c and debug.c - The blank screen colour has been changed back to black - No second program runs on the sub screen by default - The number of Bedrock instances to run has been parameterized --- arm9/source/core.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'arm9/source/core.h') diff --git a/arm9/source/core.h b/arm9/source/core.h index e5494ca..916806c 100644 --- a/arm9/source/core.h +++ b/arm9/source/core.h @@ -6,11 +6,12 @@ #include "devices/math.h" #include "devices/screen.h" #include "devices/system.h" + #include "devices/memory.h" #define WST br->wst #define RST br->rst - #define MEM br->mem - #define PC br->pc + #define MEM br->prg.mem + #define PC br->prg.p #define WSTV(i) WST.mem[WST.p+(i)] #define RSTV(i) RST.mem[RST.p+(i)] @@ -57,18 +58,24 @@ SIG_DB6, } Signal; + typedef struct { + u8 mem [65536]; + u16 p; + } ProgramMemory; + typedef struct { u8 mem[256]; // stack memory u8 p; // stack pointer - } Stack; + } StackMemory; typedef struct { bool alive; // true when program is loaded bool awake; // true when program is not asleep - u8 mem[65536]; // program memory - u16 pc; // program counter - Stack wst, rst; // working and return stacks + ProgramMemory prg; // program memory + StackMemory wst, rst; // working and return stacks + SystemDevice sys; + MemoryDevice mem; MathDevice math; ClockDevice clk; InputDevice inp; @@ -77,6 +84,7 @@ void reset_br(Bedrock *br); void start_br(Bedrock *br, u8 program[], int size); + void run_br(Bedrock *br); void rouse_br(Bedrock *br); u8 dev_read(Bedrock *br, u8 port); Signal dev_write(Bedrock *br, u8 port, u8 val); -- cgit v1.2.3-70-g09d2