An emulator, assembler, and disassembler for the Sega Game Gear
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <stdint.h>
  5. #include <stdlib.h>
  6. #define ROM_SIZE_MIN (32 << 10) // 32 KB
  7. #define ROM_SIZE_MAX ( 1 << 20) // 1 MB
  8. #define BIOS_SIZE 1024
  9. /* Header info */
  10. #define HEADER_SIZE 16
  11. #define HEADER_MAGIC_LEN 8
  12. static const char rom_header_magic[HEADER_MAGIC_LEN + 1] = "TMR SEGA";
  13. /* Error strings */
  14. static const char* rom_err_isdir = "Is a directory";
  15. static const char* rom_err_notfile = "Is not a regular file";
  16. static const char* rom_err_badsize = "Invalid size";
  17. static const char* rom_err_badread = "Couldn't read the entire file";
  18. static const char* rom_err_badheader = "Invalid header";
  19. static const char* rom_err_sms = "Master System ROMs are not supported";
  20. /* Structs */
  21. typedef struct {
  22. char *name;
  23. uint8_t *data;
  24. size_t size;
  25. uint16_t header_location;
  26. uint16_t reported_checksum;
  27. uint16_t expected_checksum;
  28. uint32_t product_code;
  29. uint8_t version;
  30. uint8_t region_code;
  31. uint8_t declared_size;
  32. } ROM;
  33. typedef struct {
  34. uint8_t data[BIOS_SIZE];
  35. } BIOS;
  36. /* Functions */
  37. const char* rom_open(ROM*, const char*);
  38. void rom_close(ROM*);
  39. const char* rom_product(const ROM*);
  40. const char* rom_region(const ROM*);
  41. BIOS* bios_open(const char*);
  42. void bios_close(BIOS*);