diff options
author | Ben Bridle <ben@derelict.engineering> | 2024-11-19 17:52:36 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2024-11-19 17:52:36 +1300 |
commit | a1b95e9ccf9bd7b316adf21952e43e03f2bf3746 (patch) | |
tree | 7bcc8d28f3de0f222c23e23c79ce15d400bee8d0 /arm9/source/devices/memory.h | |
parent | 008b816edbd4e241975822f8b7d8765a869fa404 (diff) | |
download | bedrock-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/devices/memory.h')
-rw-r--r-- | arm9/source/devices/memory.h | 42 |
1 files changed, 42 insertions, 0 deletions
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 |