vgbc/cartridge/cartridge.h

42 lines
592 B
C
Raw Permalink Normal View History

#pragma once
#include <misc/types.h>
#include <fstream>
enum CartridgeType : u8 {
CT_ROM_ONLY = 0x00,
CT_MBC1 = 0x01,
CT_MBC1_RAM = 0x02,
CT_MBC1_RAM_BATTERY = 0x03,
};
class Cartridge {
private:
u8* _data;
size_t _size;
char _title[17];
enum Offsets {
TITLE = 0x0134,
MANU_CODE = 0x013F,
};
public:
Cartridge(std::ifstream& file);
u8 operator[](size_t addr);
inline
const char* title() const
{ return _title; }
inline
CartridgeType type() const
{ return (CartridgeType)_data[0x147]; }
inline
size_t size() const
{ return _size; }
};