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.
 
 
 
 
 

35 lines
822 B

  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. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "rom.h"
  7. /* Create and return a ROM object located at the given path. Return NULL if
  8. there was an error; errno will be set appropriately. */
  9. rom_type* open_rom(const char *path)
  10. {
  11. rom_type *rom;
  12. FILE* fp;
  13. if (!(fp = fopen(path, "r")))
  14. return NULL;
  15. if (!(rom = malloc(sizeof(rom_type))))
  16. return NULL;
  17. rom->name = malloc(sizeof(char) * (strlen(path) + 1));
  18. strcpy(rom->name, path);
  19. // load data from file into a buffer
  20. fclose(fp);
  21. return rom;
  22. }
  23. /* Free a ROM object previously created with open_rom(). */
  24. void close_rom(rom_type *rom)
  25. {
  26. free(rom);
  27. }