2023-08-31 23:53:20 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <misc/types.h>
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
enum CartridgeType : u8 {
|
2023-09-01 23:19:02 +02:00
|
|
|
CT_ROM_ONLY = 0x00,
|
|
|
|
CT_MBC1 = 0x01,
|
|
|
|
CT_MBC1_RAM = 0x02,
|
|
|
|
CT_MBC1_RAM_BATTERY = 0x03,
|
2023-08-31 23:53:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
2023-09-01 23:19:02 +02:00
|
|
|
const char* title() const
|
2023-08-31 23:53:20 +02:00
|
|
|
{ return _title; }
|
|
|
|
|
|
|
|
inline
|
2023-09-01 23:19:02 +02:00
|
|
|
CartridgeType type() const
|
|
|
|
{ return (CartridgeType)_data[0x147]; }
|
|
|
|
|
|
|
|
inline
|
|
|
|
size_t size() const
|
2023-08-31 23:53:20 +02:00
|
|
|
{ return _size; }
|
|
|
|
};
|