pcengine_rust/
hardware_page.rs

1//! The hardware page, bank $FF ($1FE000-$1FFFFF), as 32 pages of 256 bytes (`hardware_page.py`).
2//!
3//! [hw: pcetech 3]
4//!
5//! ```text
6//! $0000-$03FF  VDC   (4-byte mirror)       $0800-$0BFF  PSG   (in the CPU)
7//! $0400-$07FF  VCE   (8-byte mirror)       $0C00-$0FFF  timer (2-byte mirror)
8//! $1000-$13FF  I/O port                    $1400-$17FF  interrupt controller (4-byte mirror)
9//! $1800-$1FFF  unmapped, reads $FF
10//! ```
11//!
12//! The pages $1800-$1FFF are free for an add-on to claim (`CD` at $1800-$18FF, the Arcade Card at
13//! $1A00-$1AFF); the page table's claim replaces these handlers.
14//!
15//! Differences forced by Rust: the reference's three page objects (`VdcPage`, `VcePage`,
16//! `CpuIoPage`) are the names `Handler::Vdc`, `Handler::Vce` and `Handler::CpuIo`; the address
17//! masks they apply (`& 3`, `& 7`, `& 0x1FFF`) are in `Board::page_read` and `page_write`.
18
19use crate::machine::HARDWARE_FIRST_PAGE;
20use crate::pagetable::{Handler, PageTable};
21
22/// Install the board's own handlers on the 32 pages of bank $FF.
23pub fn map_hardware_page(pages: &mut PageTable) {
24    let first = HARDWARE_FIRST_PAGE;
25    pages.set_base(first, first + 0x03, Handler::Vdc);
26    pages.set_base(first + 0x04, first + 0x07, Handler::Vce);
27    pages.set_base(first + 0x08, first + 0x17, Handler::CpuIo);
28}