rustzx_core/emulator/
poke.rs

1//! Pokes are used to modify internal emulator state such as memory, registers, etc.
2
3/// Action to perform on emulator state
4#[derive(Clone, Copy)]
5pub enum PokeAction {
6    Mem { addr: u16, value: u8 },
7}
8
9impl PokeAction {
10    /// Creates new memory poke action
11    pub const fn mem(addr: u16, value: u8) -> Self {
12        Self::Mem { addr, value }
13    }
14}
15
16pub trait Poke {
17    /// Returns list of actions to perform on emulator state
18    fn actions(&self) -> &[PokeAction];
19}
20
21/// Poke which disables message and enter key prompt in 48K ROM when scrolling screen in BASIC mode
22pub struct DisableScrollMessageRom48;
23impl Poke for DisableScrollMessageRom48 {
24    fn actions(&self) -> &[PokeAction] {
25        // Injects `JP 0x0CD2` at 0x0C88
26        // https://skoolkid.github.io/rom/asm/0C55.html
27        const ACTIONS: &[PokeAction] = &[
28            PokeAction::mem(0x0C88, 0xC3),
29            PokeAction::mem(0x0C89, 0xD2),
30            PokeAction::mem(0x0C8A, 0x0C),
31        ];
32
33        ACTIONS
34    }
35}