summaryrefslogtreecommitdiff
path: root/arm9/source/core.h
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2024-11-19 17:52:36 +1300
committerBen Bridle <ben@derelict.engineering>2024-11-19 17:52:36 +1300
commita1b95e9ccf9bd7b316adf21952e43e03f2bf3746 (patch)
tree7bcc8d28f3de0f222c23e23c79ce15d400bee8d0 /arm9/source/core.h
parent008b816edbd4e241975822f8b7d8765a869fa404 (diff)
downloadbedrock-nds-a1b95e9ccf9bd7b316adf21952e43e03f2bf3746.zip
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
Diffstat (limited to 'arm9/source/core.h')
-rw-r--r--arm9/source/core.h20
1 files changed, 14 insertions, 6 deletions
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)]
@@ -58,17 +59,23 @@
} 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);