/* * sprinter_mem.h — banking-aware page allocator and bank-data accessors. * * For data that doesn't fit in window 2's heap, allocate physical pages * directly through ESTEX EMM and access them via bank_read / bank_write * (which swap window 3 internally). * * mem_alloc_pages(N) — reserve N contiguous 16 KB pages, return block id. * mem_free_block(id) — release a previously-allocated block. * mem_get_page(id, i) — translate (block, page-index) to physical page. * mem_info(&total, &free) — query EMM about total/free 16 KB pages. * * bank_load_byte / bank_store_byte — single-byte access via W3. * bank_read / bank_write — bulk copy between far page and a near buffer. * * The bank_* helpers live in HOME so they are always reachable; they save * the previous W3 page, swap to the target, do the work, restore W3. */ #ifndef SPRINTER_MEM_H #define SPRINTER_MEM_H #include /* ESTEX EMM allocator wrappers. */ uint8_t mem_alloc_pages(uint8_t n); /* 0 = failure */ void mem_free_block (uint8_t blk_id); uint8_t mem_get_page (uint8_t blk_id, uint8_t idx); void mem_info (uint16_t *total, uint16_t *free_pages); /* Far-page accessors (always-mapped HOME, swap W3 internally). */ uint8_t bank_load_byte (uint8_t phys_page, uint16_t off_in_window); void bank_store_byte(uint8_t phys_page, uint16_t off_in_window, uint8_t v); void bank_read (uint8_t phys_page, uint16_t off, void *dst, uint16_t n); void bank_write(uint8_t phys_page, uint16_t off, const void *src, uint16_t n); #endif