Module spectrusty::memory
source · Expand description
Memory API.
Memory banks and pages.
- ZxMemory ROM and RAM is a continuous slice of memory divided into logical banks.
- 16-bit memory addresses are mapped to memory banks depending on the implementation.
- Each page can have any fitting bank of ROM or RAM switched in.
- Some implementations allow attaching an external ROM bank to any of the pages.
Below are examples of continuous memory: all ROM banks followed by RAM banks. ZxMemory::mem_ref and ZxMemory::mem_mut both give access to the whole area.
|00000h |04000h |8000h |0c000h |10000h |14000h |18000h |1c000h |20000h | 24000h
Memory16k
|ROM_SIZE|
+--------+--------+
| | Screen |
| | Bank 0 |
| ROM | RAM |
| Bank 0 | Bank 0 |
+--------+--------+
Memory48k
|ROM_SIZE|
+--------+--------+--------+--------+
| | Screen Bank 0 |
| | |
| ROM | RAM Bank 0 |
| Bank 0 | |
+--------+--------+--------+--------+
Memory128k
|<- ROM_SIZE ->|
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
| | | | | | | | Screen | | Screen |
| | | | | | | | Bank 0 | | Bank 1 |
| ROM | ROM | RAM | RAM | RAM | RAM | RAM | RAM | RAM | RAM |
| Bank 0 | Bank 1 | Bank 0 | Bank 1 | Bank 2 | Bank 3 | Bank 4 | Bank 5 | Bank 6 | Bank 7 |
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
Below are examples of memory pages mappings.
A constant memory map of Memory16k and Memory48k:
Memory48k Memory16k
Page 0 +--------+ +--------+ Page 0 0x0000
| | | |
| | | |
| ROM | | ROM |
| Bank 0 | | Bank 0 |
Page 1 +--------+ +--------+ Page 1 0x4000
| Screen | | Screen |
| Bank 0 | | Bank 0 |
| RAM | | RAM |
| Bank 0 | | Bank 0 | RAMTOP 0x7fff
+ + +--------+ 0x8000
| |
| |
| |
| |
+ + 0xc000
| |
| |
| |
RAMTOP | | 0xffff
+--------+
A memory map with example banks switched in for Memory128k or Memory128kPlus:
Page 0 +--------+ 0x1000
| |
| |
| ROM |
| Bank 0 |
Page 1 +--------+ 0x4000
| Screen |
| Bank 0 |
| RAM |
| Bank 5 |
Page 2 +--------+ 0x8000
| |
| |
| RAM |
| Bank 2 |
Page 3 +--------+ 0xc000
| |
| |
| RAM |
RAMTOP | Bank 0 | 0xffff
+--------+
Modules
Utilities for serializing arrays as tuples.
Utilities for serializing memory as base64 strings or just bytes in binary serializers.
Structs
A type returned by ZxMemory::page_index_at.
A placeholder memory extension. Useful as a default.
Enums
Constants
Traits
An interface for memory paging extensions of ZxMemory.
A trait for interfacing ZX Spectrum’s various memory types.
Type Definitions
Represents an external ROM as a shared pointer to a slice of bytes.
A single page memory type with 16kb RAM.
An EX-ROM attachable, paged (16k) memory type with 16kb RAM and 16kb ROM.
A single page memory type with 48kb RAM.
An EX-ROM attachable, paged (8k) memory type with 48kb RAM and 96kb ROM (64kb DOCK, 8kB EX-ROM, 16kB ROM).
An EX-ROM attachable, paged (16k) memory type with 48kb RAM and 16kb ROM.
A single page memory type with 64kb RAM.
An EX-ROM attachable, paged (16k) memory type with 128kb RAM and 32kb ROM.
An EX-ROM attachable, paged (16k) memory type with 128kb RAM and 64kb ROM.
An EX-ROM attachable, paged (8k) memory type with 272kb RAM and 32kb ROM.
Represents a single screen memory.