aboutsummaryrefslogtreecommitdiff
path: root/src/cartridge.rs
blob: f96c23475c1a4360064b4b81048e87cca439681e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use core::cell::RefCell;

#[derive(Copy, Clone)]
pub enum MirrorType {
    Horizontal = 0,
    Vertical = 1,
    Single0 = 2,
    Single1 = 3,
    Four = 4
}

pub enum BankType {
    PrgRom, /* program rom */
    ChrRom, /* pattern rom */
    Sram,    /* save ram */
}

pub struct Cartridge {
    chr_rom: [u8; 8192],
    prg_rom: RefCell<[u8; 8192]>,
    sram: [u8; 8192],
    pub mirror_type: MirrorType
}

impl Cartridge {
    pub fn get_bank_num(&self, kind: BankType) -> usize {0}
    pub fn get_bank(&self, idx: usize, kind: BankType) -> *mut [u8] {
        &mut *self.prg_rom.borrow_mut()
    }
    pub fn new() -> Self {
        Cartridge {
            chr_rom: [0; 8192],
            prg_rom: RefCell::new([0; 8192]),
            sram: [0; 8192],
            mirror_type: MirrorType::Horizontal
        }
    }
}