An emulator, assembler, and disassembler for the Sega Game Gear
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

rom.h 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2014-2015 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. /* Header info */
  9. #define HEADER_SIZE 16
  10. #define HEADER_MAGIC_LEN 8
  11. static const char rom_header_magic[HEADER_MAGIC_LEN + 1] = "TMR SEGA";
  12. /* Error strings */
  13. static const char* rom_err_isdir = "Is a directory";
  14. static const char* rom_err_notfile = "Is not a regular file";
  15. static const char* rom_err_badsize = "Invalid size";
  16. static const char* rom_err_badread = "Couldn't read the entire file";
  17. static const char* rom_err_badheader = "Invalid header";
  18. static const char* rom_err_sms = "Master System ROMs are not supported";
  19. /* Structs */
  20. typedef struct {
  21. char *name;
  22. uint8_t *data;
  23. size_t size;
  24. uint16_t reported_checksum;
  25. uint16_t expected_checksum;
  26. uint32_t product_code;
  27. uint8_t version;
  28. uint8_t region_code;
  29. } ROM;
  30. /* Functions */
  31. const char* rom_open(ROM**, const char*);
  32. void rom_close(ROM*);
  33. const char* rom_product(const ROM*);
  34. const char* rom_region(const ROM*);