An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
1.2 KiB

  1. /* Copyright (C) 2014-2017 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <stdbool.h>
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. #include "save.h"
  8. #define MMU_NUM_SLOTS (3)
  9. #define MMU_NUM_ROM_BANKS (64)
  10. #define MMU_ROM_BANK_SIZE (16 * 1024)
  11. #define MMU_SYSTEM_RAM_SIZE ( 8 * 1024)
  12. #define MMU_CART_RAM_SIZE (32 * 1024)
  13. /* Structs */
  14. typedef struct {
  15. uint8_t *system_ram;
  16. uint8_t *cart_ram;
  17. const uint8_t *rom_slots[MMU_NUM_SLOTS];
  18. const uint8_t *rom_banks[MMU_NUM_ROM_BANKS];
  19. uint8_t *cart_ram_slot;
  20. const uint8_t *bios_rom;
  21. bool cart_ram_mapped, cart_ram_external;
  22. bool bios_enabled;
  23. Save *save;
  24. } MMU;
  25. /* Functions */
  26. void mmu_init(MMU*);
  27. void mmu_free(MMU*);
  28. void mmu_load_rom(MMU*, const uint8_t*, size_t);
  29. void mmu_load_bios(MMU*, const uint8_t*);
  30. void mmu_load_save(MMU*, Save*);
  31. void mmu_power(MMU*);
  32. uint8_t mmu_read_byte(const MMU*, uint16_t);
  33. uint16_t mmu_read_double(const MMU*, uint16_t);
  34. uint32_t mmu_read_quad(const MMU*, uint16_t);
  35. bool mmu_write_byte(MMU*, uint16_t, uint8_t);
  36. bool mmu_write_double(MMU*, uint16_t, uint16_t);