smc.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* sd2snes - SD card based universal cartridge for the SNES
  2. Copyright (C) 2009-2010 Maximilian Rehkopf <otakon@gmx.net>
  3. AVR firmware portion
  4. Inspired by and based on code from sd2iec, written by Ingo Korb et al.
  5. See sdcard.c|h, config.h.
  6. FAT file system access based on code by ChaN, Jim Brain, Ingo Korb,
  7. see ff.c|h.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; version 2 of the License only.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. smc.h: SMC file structures
  19. */
  20. #ifndef SMC_H
  21. #define SMC_H
  22. #define DSPFW_1 ((const uint8_t*)"/sd2snes/dsp1.bin")
  23. #define DSPFW_2 ((const uint8_t*)"/sd2snes/dsp2.bin")
  24. #define DSPFW_3 ((const uint8_t*)"/sd2snes/dsp3.bin")
  25. #define DSPFW_4 ((const uint8_t*)"/sd2snes/dsp4.bin")
  26. #define DSPFW_1B ((const uint8_t*)"/sd2snes/dsp1b.bin")
  27. #define DSPFW_ST0010 ((const uint8_t*)"/sd2snes/st0010.bin")
  28. #define CX4FW ((const uint8_t*)"/sd2snes/cx4.bin")
  29. #define FPGA_CX4 ((const uint8_t*)"/sd2snes/fpga_cx4.bit")
  30. typedef struct _snes_header
  31. {
  32. uint8_t maker[2]; /* 0xB0 */
  33. uint8_t gamecode[4]; /* 0xB2 */
  34. uint8_t fixed_00[7]; /* 0xB6 */
  35. uint8_t expramsize; /* 0xBD */
  36. uint8_t specver; /* 0xBE */
  37. uint8_t carttype2; /* 0xBF */
  38. uint8_t name[21]; /* 0xC0 */
  39. uint8_t map; /* 0xD5 */
  40. uint8_t carttype; /* 0xD6 */
  41. uint8_t romsize; /* 0xD7 */
  42. uint8_t ramsize; /* 0xD8 */
  43. uint8_t destcode; /* 0xD9 */
  44. uint8_t licensee; /* 0xDA */
  45. uint8_t ver; /* 0xDB */
  46. uint16_t cchk; /* 0xDC */
  47. uint16_t chk; /* 0xDE */
  48. uint32_t pad1; /* 0xE0 */
  49. uint16_t vect_cop16; /* 0xE4 */
  50. uint16_t vect_brk16; /* 0xE6 */
  51. uint16_t vect_abt16; /* 0xE8 */
  52. uint16_t vect_nmi16; /* 0xEA */
  53. uint16_t vect_irq16; /* 0xEE */
  54. uint16_t pad2; /* 0xF0 */
  55. uint16_t vect_cop8; /* 0xF4 */
  56. uint32_t pad3; /* 0xF6 */
  57. uint16_t vect_abt8; /* 0xF8 */
  58. uint16_t vect_nmi8; /* 0xFA */
  59. uint16_t vect_reset; /* 0xFC */
  60. uint16_t vect_brk8; /* 0xFE */
  61. } snes_header_t;
  62. typedef struct _snes_romprops
  63. {
  64. uint16_t offset; /* start of actual ROM image */
  65. uint8_t mapper_id; /* FPGA mapper */
  66. uint8_t pad1; /* for alignment */
  67. uint32_t expramsize_bytes; /* ExpRAM size in bytes */
  68. uint32_t ramsize_bytes; /* CartRAM size in bytes */
  69. uint32_t romsize_bytes; /* ROM size in bytes (rounded up) */
  70. const uint8_t *dsp_fw; /* DSP (NEC / Hitachi) ROM filename */
  71. const uint8_t *fpga_conf; /* FPGA config file to load (default: base) */
  72. uint8_t has_dspx; /* DSP[1-4] presence flag */
  73. uint8_t has_st0010; /* st0010 presence flag (additional to dspx) */
  74. uint8_t has_msu1; /* MSU1 presence flag */
  75. uint8_t has_cx4; /* CX4 presence flag */
  76. uint8_t fpga_features; /* feature/peripheral enable bits*/
  77. uint8_t region; /* game region (derived from destination code) */
  78. snes_header_t header; /* original header from ROM image */
  79. } snes_romprops_t;
  80. void smc_id( snes_romprops_t * );
  81. uint8_t smc_headerscore( uint32_t addr, snes_header_t *header );
  82. #endif