diff options
Diffstat (limited to 'arm9/source/devices/memory.h')
-rw-r--r-- | arm9/source/devices/memory.h | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/arm9/source/devices/memory.h b/arm9/source/devices/memory.h index 0abff16..814f47d 100644 --- a/arm9/source/devices/memory.h +++ b/arm9/source/devices/memory.h @@ -1,42 +1,34 @@ #ifndef MEMORY_H_ #define MEMORY_H_ - #define HEAP_SIZE (4096*3) + #include "../bang.h" - 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); + // Read-write head for memory device. + typedef struct { + u16 offset; // Index of base page. + u8 page; // Index of current page from offset. + u8 byte; // Index of current byte in page. + u8 *point; // Pointer to current page. + u8 *cache[256]; // Pointers to all pages for the current offset. + } MemoryHead; + // Bedrock memory device. + typedef struct { + u8 id; // Non-zero ID of this Bedrock instance. + u16 allocated; // Number of pages allocated to this instance + u16 count; // Write cache for allocation count + u16 copy; // Write cache for copy length + MemoryHead head1; + MemoryHead head2; + } MemoryDevice; + // Methods. + void memory_reset(MemoryDevice *mem); + u8 memory_read(MemoryHead *head); + void memory_write(MemoryHead *head, u8 value); + void memory_refresh_page(MemoryHead *head); + void memory_refresh_cache(MemoryDevice *mem, MemoryHead *head); + void memory_allocate(MemoryDevice *mem); + void memory_copy(MemoryDevice *mem); #endif |