aboutsummaryrefslogtreecommitdiff
path: root/src/cartridge.rs
blob: ca9c31e113e90205d83b3418ef0959e70fcbabd9 (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
#![allow(dead_code)]
use utils::{Read, Write};

#[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 trait Cartridge {
    fn get_size(&self, kind: BankType) -> usize;
    fn get_bank<'a>(&self, base: usize, size: usize, kind: BankType) -> &'a [u8];
    fn get_bank_mut<'a>(&mut self, base: usize, size: usize, kind: BankType) -> &'a mut [u8];
    #[inline(always)] fn get_mirror_type(&self) -> MirrorType;
    #[inline(always)] fn set_mirror_type(&mut self, mt: MirrorType);
    fn load(&mut self, reader: &mut Read) -> bool;
    fn save(&self, writer: &mut Write) -> bool;
}