|
- #ifndef NESE_MEMORY_H_
- #define NESE_MEMORY_H_
-
- #include <stdint.h>
-
- #include "apu.h"
- #include "input.h"
- #include "mapper.h"
- #include "ppu.h"
-
- #include "serdes.h"
-
-
- #define NES_RAM_SIZE (0x2000U)
- #define NES_SRAM_SIZE (0x2000U)
-
- #define NES_PRG_ROM_PAGE_SIZE (0x2000U)
-
-
- typedef enum {
- nes_Mem_SRAM_Used = 0b00000001,
- } nes_Memory_Flag;
-
- struct nes_Memory {
- #ifdef F6502_FLAT
- uint8_t ram[65536];
- #else
- // Dynamic (set on init/reload)
- uint8_t* sram_bank; // Mapped to 0x6000 - 0x7FFF
- uint8_t* rom;
- uint8_t* rom_bank[4];
-
- // Dynamic (specific init/reload)
- nes_Mapper mapper;
- nes_PPU_Memory ppu;
-
- // Static
- nes_Input input;
- nes_APU_Memory apu;
-
- uint8_t ram[NES_RAM_SIZE / 4]; // Mirrored 3x
- uint8_t sram[NES_SRAM_SIZE];
- nes_Memory_Flag flags;
- int n_rom_banks;
- #endif
- };
- typedef struct nes_Memory nes_Memory;
-
-
- static inline uint8_t* prg_rom_page(nes_Memory* mem, int page) {
- return &mem->rom[page * NES_PRG_ROM_PAGE_SIZE];
- }
-
-
- extern const Serdes_Item nes_memory_serdes[];
-
-
- #endif // NESE_MEMORY_H_
|