[−][src]Module spectrusty::memory
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
serde | Utilities for serializing memory as base64 strings or just bytes in binary serializers. |
Structs
MemPageOffset | A type returned by ZxMemory::page_index_at. |
MemPageRefIter | |
MemPageableRomRamExRom | |
Memory16k | A single page memory type with 16kb RAM. |
Memory48k | A single page memory type with 48kb RAM. |
Memory64k | A single page memory type with 64kb RAM. |
NoMemoryExtension | A placeholder memory extension. Useful as a default. |
Enums
MemoryKind | |
PageMutSlice | A type yielded by ZxMemory::for_each_page_mut. |
ZxMemoryError |
Constants
MEM8K_SIZE | |
MEM16K_SIZE | |
MEM32K_SIZE | |
MEM48K_SIZE | |
MEM64K_SIZE | |
MEM128K_SIZE | |
SCREEN_SIZE |
Traits
MemoryExtension | An interface for memory paging extensions of ZxMemory. |
PagedMemory8k | |
PagedMemory16k | |
ZxMemory | A trait for interfacing ZX Spectrum's various memory types. |
Type Definitions
ExRom | Represents an external ROM as a shared pointer to a slice of bytes. |
Memory16kEx | An EX-ROM attachable, paged (16k) memory type with 16kb RAM and 16kb ROM. |
Memory48kDock64kEx | An EX-ROM attachable, paged (8k) memory type with 48kb RAM and 96kb ROM (64kb DOCK, 8kB EX-ROM, 16kB ROM). |
Memory48kEx | An EX-ROM attachable, paged (16k) memory type with 48kb RAM and 16kb ROM. |
Memory128k | An EX-ROM attachable, paged (16k) memory type with 128kb RAM and 32kb ROM. |
Memory128kPlus | An EX-ROM attachable, paged (16k) memory type with 128kb RAM and 64kb ROM. |
Memory272k | An EX-ROM attachable, paged (8k) memory type with 272kb RAM and 32kb ROM. |
Result | A type returned by some of ZxMemory methods. |
ScreenArray | Represents a single screen memory. |