#ifndef MEMORY_H_ #define MEMORY_H_ #include "../bang.h" // 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