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/devices/memory.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 arm9/source/devices/memory.h (limited to 'arm9/source/devices/memory.h') diff --git a/arm9/source/devices/memory.h b/arm9/source/devices/memory.h new file mode 100644 index 0000000..0abff16 --- /dev/null +++ b/arm9/source/devices/memory.h @@ -0,0 +1,42 @@ +#ifndef MEMORY_H_ + #define MEMORY_H_ + + #define HEAP_SIZE (4096*3) + + typedef struct { + u8 id; // Unique non-zero identifier for this memory device. + + u16 offset1; // Bedrock offset value for head 1 + u8 page1; // Bedrock address value for head 1 + u8 byte1; // Bedrock address value for head 1 + u16 offset2; // Bedrock offset value for head 2 + u8 page2; // Bedrock address value for head 2 + u8 byte2; // Bedrock address value for head 2 + + u16 count_write; // write cache for page count + u16 count; // number of pages allocated for this bedrock + u16 copy_write; // write cache for page copy length + + u8 *point1; // pointer to current page for head 1 + u8 *point2; // pointer to current page for head 2 + + u8* cache1[256]; + u8* cache2[256]; + } MemoryDevice ; + + u8 mem_read1(MemoryDevice *mem); + u8 mem_read2(MemoryDevice *mem); + void mem_write1(MemoryDevice *mem, u8 value); + void mem_write2(MemoryDevice *mem, u8 value); + + void mem_load_cache1(MemoryDevice *mem); + void mem_load_cache2(MemoryDevice *mem); + void mem_get_page1(MemoryDevice *mem); + void mem_get_page2(MemoryDevice *mem); + + + void mem_allocate(MemoryDevice *mem); + void mem_do_copy(MemoryDevice *mem); + + +#endif -- cgit v1.2.3-70-g09d2