NESe (pronounced "Nessie") is a NES emulator based on the e6502 emulator, also written in C with a focus on speed and portability for use on embedded platforms, especially ARM.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

59 řádky
1.0KB

  1. #ifndef NESE_MEMORY_H_
  2. #define NESE_MEMORY_H_
  3. #include <stdint.h>
  4. #include "apu.h"
  5. #include "input.h"
  6. #include "mapper.h"
  7. #include "ppu.h"
  8. #include "serdes.h"
  9. #define NES_RAM_SIZE (0x2000U)
  10. #define NES_SRAM_SIZE (0x2000U)
  11. #define NES_PRG_ROM_PAGE_SIZE (0x2000U)
  12. typedef enum {
  13. nes_Mem_SRAM_Used = 0b00000001,
  14. } nes_Memory_Flag;
  15. struct nes_Memory {
  16. #ifdef F6502_FLAT
  17. uint8_t ram[65536];
  18. #else
  19. // Dynamic (set on init/reload)
  20. uint8_t* sram_bank; // Mapped to 0x6000 - 0x7FFF
  21. uint8_t* rom;
  22. uint8_t* rom_bank[4];
  23. // Dynamic (specific init/reload)
  24. nes_Mapper mapper;
  25. nes_PPU_Memory ppu;
  26. // Static
  27. nes_Input input;
  28. nes_APU_Memory apu;
  29. uint8_t ram[NES_RAM_SIZE / 4]; // Mirrored 3x
  30. uint8_t sram[NES_SRAM_SIZE];
  31. nes_Memory_Flag flags;
  32. int n_rom_banks;
  33. #endif
  34. };
  35. typedef struct nes_Memory nes_Memory;
  36. static inline uint8_t* prg_rom_page(nes_Memory* mem, int page) {
  37. return &mem->rom[page * NES_PRG_ROM_PAGE_SIZE];
  38. }
  39. extern const Serdes_Item nes_memory_serdes[];
  40. #endif // NESE_MEMORY_H_