NESEmulator/NES Emulator/cartridge.h

55 lines
1.1 KiB
C
Raw Normal View History

2021-10-20 20:39:29 +00:00
#ifndef _CARTRIDGE_H_
#define _CARTRIDGE_H_
#include "types.h"
2021-10-28 14:57:37 +00:00
#include "SDL.h"
2021-10-20 20:39:29 +00:00
struct Bus;
2021-10-28 14:57:37 +00:00
struct Mapper;
2021-10-20 20:39:29 +00:00
struct Cartridge
{
2021-10-24 11:47:11 +00:00
struct
{
Byte nestext[4];
Byte prg_rom_size;
Byte chr_rom_size;
struct
{
Byte mirror : 1;
Byte battery : 1;
Byte trainer : 1;
Byte ignore_mirror : 1;
Byte mapper_lower_nibble : 4;
} Flags6;
struct
{
Byte vs : 1;
Byte playchoice : 1;
Byte nes20 : 2;
Byte mapper_upper_nibble : 4;
} Flags7;
Byte prg_ram_size;
Byte unused[7];
} header;
2021-10-28 14:57:37 +00:00
struct Mapper* mapper;
2021-10-20 20:39:29 +00:00
struct Bus* bus;
};
struct Cartridge* createCartridge(struct Bus* parent, const char* filepath);
void destroyCartridge(struct Cartridge* cartridge);
2021-10-20 21:23:16 +00:00
// readCartridge/writeCartridge to and from the cartridge
2021-10-28 14:57:37 +00:00
Byte readCartridgeCPU(struct Cartridge* cartridge, Word addr);
Byte readCartridgePPU(struct Cartridge* cartridge, Word addr);
void writeCartridgeCPU(struct Cartridge* cartridge, Word addr, Byte val);
void writeCartridgePPU(struct Cartridge* cartridge, Word addr, Byte val);
void getPatternTableTexture(struct Cartridge* cartridge, SDL_Texture* texture, int index);
2021-10-20 21:23:16 +00:00
2021-10-20 20:39:29 +00:00
#endif //_CARTRIDGE_H_