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.

rom.h 1.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 header_location;
  25. uint16_t reported_checksum;
  26. uint16_t expected_checksum;
  27. uint32_t product_code;
  28. uint8_t version;
  29. uint8_t region_code;
  30. uint8_t declared_size;
  31. } ROM;
  32. /* Functions */
  33. const char* rom_open(ROM*, const char*);
  34. void rom_close(ROM*);
  35. const char* rom_product(const ROM*);
  36. const char* rom_region(const ROM*);