tool to upload data to a SuperCharger cartridge
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.

375 lines
11KB

  1. #define BSM_2K 0
  2. #define BSM_CV 1
  3. #define BSM_4K 2
  4. #define BSM_28SC 3
  5. #define BSM_F8SC 4
  6. #define BSM_28 5
  7. #define BSM_F8 6
  8. #define BSM_FE 7
  9. #define BSM_3F 8
  10. #define BSM_E0 9
  11. #define BSM_FA 10
  12. #define BSM_2A 11
  13. #define BSM_3A 12
  14. #define BSM_FANR 13
  15. #define BSM_2ANR 14
  16. #define BSM_3ANR 15
  17. #define BSM_46SC 16
  18. #define BSM_F6SC 17
  19. #define BSM_26SC 18
  20. #define BSM_36SC 19
  21. #define BSM_46 20
  22. #define BSM_F6 21
  23. #define BSM_26 22
  24. #define BSM_36 23
  25. #define BSM_E7 24
  26. #define BSM_E7NR 25
  27. #define BSM_F4SC 26
  28. #define BSM_24SC 27
  29. #define BSM_34SC 28
  30. #define BSM_44SC 29
  31. #define BSM_F4 30
  32. #define BSM_24 31
  33. #define BSM_34 32
  34. #define BSM_44 33
  35. #define BSM_MB 34
  36. #define FMT_22KHZ_8BIT_MONO 0
  37. #define FMT_44KHZ_8BIT_MONO 1
  38. #define FMT_44KHZ_16BIT_STEREO 2
  39. #define METER_LENGTH 32
  40. #define DISPLAY_NOTHING 0
  41. #define DISPLAY_FILENAME 1
  42. #define DISPLAY_SUMMARY 2
  43. #define DISPLAY_DETAILS 3
  44. #define _MAX_FNAME 256
  45. #ifndef _MAX_PATH
  46. #define _MAX_PATH 256
  47. #endif
  48. #define _MAX_DIR 256
  49. #ifndef _MAX_DRIVE
  50. #define _MAX_DRIVE 256
  51. #endif
  52. #define _MAX_EXT 256
  53. typedef unsigned long int dd;
  54. typedef unsigned short int dw;
  55. typedef int db;
  56. struct parmFlags
  57. {
  58. int aflag;
  59. int dflag;
  60. int fflag;
  61. int kflag;
  62. int wflag;
  63. int stereoFlag;
  64. int mflag;
  65. int pflag;
  66. int sflag;
  67. int vflag;
  68. char tflag;
  69. int zeroBitLength;
  70. int oneBitLength;
  71. int control;
  72. int createMode;
  73. int binFileCount;
  74. int bankSwitchMode;
  75. float headerSeconds;
  76. float clearingSeconds;
  77. float hlength;
  78. char wavFileName[_MAX_FNAME+5];
  79. char fullPath[_MAX_PATH+5];
  80. char *audioDevName;
  81. struct qnode *binFileQ;
  82. unsigned int multi;
  83. unsigned int volume;
  84. unsigned char startHi;
  85. unsigned char startLo;
  86. };
  87. char bankSwitchList[][5] =
  88. {"2K", "CV", "4K", "28SC", "F8SC", "28", "F8", "FE",
  89. "3F", "E0", "FA", "2A", "3A", "FANR", "2ANR", "3ANR",
  90. "46SC", "F6SC", "26SC", "36SC", "46", "F6", "26", "36",
  91. "E7", "E7NR", "F4SC", "24SC", "34SC", "44SC", "F4", "24",
  92. "34", "44", "MB", ""};
  93. unsigned int controlByteList[] =
  94. {0xCA, 0xEA, 0xC8, 0xF6, 0xE6, 0xD6, 0xC6, 0xCC,
  95. 0xCE, 0xC1, 0xE0, 0xF0, 0x60, 0xC0, 0xD0, 0x40,
  96. 0x74, 0xE4, 0xF4, 0x64, 0x54, 0xC4, 0xD4, 0x44,
  97. 0xE3, 0xC3, 0xE2, 0xF2, 0x62, 0x72, 0xC2, 0xD2,
  98. 0x42, 0x52, 0xC9, 0x00};
  99. int fileSizeList[] =
  100. { 2048, 2048, 4096, 8192, 8192, 8192, 8192, 8192,
  101. 8192, 8192, 12288, 12288, 12288, 12288, 12288, 12288,
  102. 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
  103. 16384, 16384, 32768, 32768, 32768, 32768, 32768, 32768,
  104. 32768, 32768, 65536, 0};
  105. int startPageList[] =
  106. { 7, 7, 15, 31, 15, 31, 15, 15,
  107. 31, 31, 15, 31, 47, 15, 31, 47,
  108. 63, 15, 31, 47, 63, 15, 31, 47,
  109. 63, 63, 15, 31, 47, 63, 15, 31,
  110. 47, 63, 15, 0};
  111. unsigned char clearingToneLength[2] = {26, 51};
  112. unsigned char clearingTone[256];
  113. unsigned char zeroBitLength,
  114. oneBitLength;
  115. unsigned char zeroBit[256],
  116. oneBit[256];
  117. /* speed, khz, bit */
  118. int bitLength[5][2][2] =
  119. {
  120. {{5,9},{15,21}},
  121. {{3,7},{ 6,10}},
  122. {{3,5},{ 5, 8}},
  123. {{3,5},{ 4, 8}},
  124. {{3,5},{ 4, 7}}
  125. };
  126. unsigned char header[3][80]=
  127. {
  128. {'R','I','F','F',0x80,0x80,0x80,0x80, /* RIFF TAG */
  129. 'W','A','V','E', /* WAV TAG */
  130. 'f','m','t',' ',0x10,0,0,0, /* FMT TAG */
  131. 1,0, /* format (WAVE_FORMAT_PCM) */
  132. 1,0, /* CHANNELS */
  133. 0x22,0x56,0,0, /* SamplesPerSec */
  134. 0x22,0x56,0,0, /* BytesPerSec */
  135. 1,0, /* Block align */
  136. 8,0, /* Bits per sample */
  137. 'd','a','t','a',0,0,0,0,'\0'/* DATA TAG */
  138. },
  139. {'R','I','F','F',0x80,0x80,0x80,0x80, /* RIFF TAG */
  140. 'W','A','V','E', /* WAV TAG */
  141. 'f','m','t',' ',0x10,0,0,0, /* FMT TAG */
  142. 1,0, /* format (WAVE_FORMAT_PCM) */
  143. 1,0, /* CHANNELS */
  144. 0x44,0xac,0,0, /* SamplesPerSec */
  145. 0x44,0xac,0,0, /* BytesPerSec */
  146. 1,0, /* Block align */
  147. 8,0, /* Bits per sample */
  148. 'd','a','t','a',0,0,0,0,'\0'/* DATA TAG */
  149. },
  150. {'R','I','F','F',0x80,0x80,0x80,0x80, /* RIFF TAG */
  151. 'W','A','V','E', /* WAV TAG */
  152. 'f','m','t',' ',0x10,0,0,0, /* FMT TAG */
  153. 1,0, /* format (WAVE_FORMAT_PCM) */
  154. 2,0, /* CHANNELS */
  155. 0x44,0xac,0,0, /* SamplesPerSec */
  156. 0x10,0xb1,2,0, /* BytesPerSec */
  157. 4,0, /* Block align */
  158. 0x10,0, /* Bits per sample */
  159. 'd','a','t','a',0,0,0,0,'\0'/* DATA TAG */
  160. }
  161. };
  162. dd BS_1[] = {
  163. 0x34ae2945, /* Magicard (CommaVid).bin */
  164. /* 0x30eb4f7a, Video Life (4K).BIN */
  165. /* 0x9afa761f, Magicard (Life).bin */
  166. 0x266bd1b6, /* Video Life (CommaVid).bin */
  167. 0xa0899305, /* Video Life (alternative 2K) */
  168. -1
  169. };
  170. const char *BS_1_DESC[] = {
  171. "Magicard (CommaVid)",
  172. "Video Life (CommaVid)",
  173. "Video Life (CommaVid)",
  174. 0
  175. };
  176. dd BS_3[] = {
  177. 0x2843d776, /* Frogger II - Threedeep!.bin */
  178. 0x690ada72, /* Gyruss [b].bin */
  179. 0x525ee7e9, /* Gyruss.bin */
  180. 0x95da4070, /* James Bond 007 [b].bin */
  181. 0x3216c1bb, /* James Bond 007.bin */
  182. 0xae4114d8, /* Montezuma's Revenge.bin */
  183. 0x00e44527, /* Mr. Do!'s Castle.bin */
  184. 0xf723b8a6, /* Popeye.bin */
  185. 0xe44c244e, /* Q-bert's Qubes [a].bin */
  186. 0xb8f2dca6, /* Q-bert's Qubes.bin */
  187. 0xe77f6742, /* Star Wars - Death Star Battle (Parker Bros).bin */
  188. 0xce09fcd4, /* Star Wars - The Arcade Game (Parker Bros).bin */
  189. 0xdd85f0e7, /* Super Cobra [b].bin */
  190. 0x8d372730, /* Super Cobra.bin */
  191. 0xd9088807, /* Tooth Protectors (DSD-Camelot).bin */
  192. 0x7eed7362, /* Tutankham.bin */
  193. 0xc87fc312, /* Popeye_(eks).bin */
  194. 0xef3ec01e, /* Super Cobra_(eks).bin */
  195. 0x84a101d4, /* Star Wars - Death Star Battle_(eks).bin */
  196. 0x2fc06cb0, /* Tutankham_(eks).bin */
  197. 0xab50bf11, /* Star Wars - The Arcade Game (proto).BIN */
  198. 0x549a1b6b, /* Star Wars - The Arcade Game (PAL) */
  199. 0x36910e4d, /* Frogger II - Threedeep! (PAL) */
  200. 0xb8bb2361, /* Gyruss (PAL) */
  201. 0xd3669372, /* Star Wars: Ewok Adventure (PAL) (proto) */
  202. 0x70db5cca, /* Star Wars: Ewok Adventure (T Jentzsch PAL to NTSC Conversion) */
  203. 0x6400d110, /* Lord of the Rings (proto) */
  204. -1
  205. };
  206. const char *BS_3_DESC[] = {
  207. "Frogger II - Threedeep!",
  208. "Gyruss [b]",
  209. "Gyruss",
  210. "James Bond 007 [b]",
  211. "James Bond 007",
  212. "Montezuma's Revenge",
  213. "Mr. Do!'s Castle",
  214. "Popeye",
  215. "Q-bert's Qubes [a]",
  216. "Q-bert's Qubes",
  217. "Star Wars - Death Star Battle (Parker Bros)",
  218. "Star Wars - The Arcade Game (Parker Bros)",
  219. "Super Cobra [b]",
  220. "Super Cobra",
  221. "Tooth Protectors (DSD-Camelot)",
  222. "Tutankham",
  223. "Popeye_(eks)",
  224. "Super Cobra_(eks)",
  225. "Star Wars - Death Star Battle_(eks)",
  226. "Tutankham_(eks)",
  227. "Star Wars - The Arcade Game (proto)",
  228. "Star Wars - The Arcade Game (PAL)",
  229. "Frogger II - Threedeep! (PAL)",
  230. "Gyruss (PAL)",
  231. "Star Wars - Ewok Adventure (proto) (PAL)",
  232. "Star Wars - Ewok Adv. T Jentzsch PAL->NTSC (proto)",
  233. "Lord of the Rings (proto)",
  234. ""
  235. };
  236. dd BS_4[] = {
  237. 0x584f6777, /* Espial [b].bin */
  238. 0x8d70fa42, /* Espial.bin */
  239. 0x8beb03d4, /* Miner 2049er [b1].bin */
  240. 0x33f2856f, /* Miner 2049er [b2].bin */
  241. 0xf859122e, /* Miner 2049er Vol. 2 [b1].bin */
  242. 0x281a1ca1, /* Miner 2049er Vol. 2 [b2].bin */
  243. 0x350c63ba, /* Miner 2049er Vol. 2.bin */
  244. 0x728b941c, /* Miner 2049er.bin */
  245. 0x13bf2da3, /* Polaris [b].bin */
  246. 0x7ce5312e, /* Polaris.bin */
  247. 0x40706361, /* River Patrol (Tigervision).bin */
  248. 0x2c34898f, /* Springer.bin */
  249. 0x09a71583, /* Miner 2049er PAL */
  250. 0xd5645294, /* Miner Volume 2 NTSC */
  251. 0x52630ec9, /* Polaris T. Jentzsch PAL to NTSC conversion*/
  252. -1
  253. };
  254. const char *BS_4_DESC[] = {
  255. "Espial [b]",
  256. "Espial",
  257. "Miner 2049er [b1]",
  258. "Miner 2049er [b2]",
  259. "Miner 2049er Vol. 2 (PAL)[b1]",
  260. "Miner 2049er Vol. 2 (PAL)[b2]",
  261. "Miner 2049er Vol. 2 (PAL)",
  262. "Miner 2049er",
  263. "Polaris [b] (PAL)",
  264. "Polaris (PAL)",
  265. "River Patrol (Tigervision)",
  266. "Springer",
  267. "Miner 2049er PAL",
  268. "Miner 2049er Vol. 2",
  269. "Polaris (T Jentzsch NTSC->PAL)",
  270. ""
  271. };
  272. dd BS_5[] = {
  273. 0x7d23e780, /* Decathlon.bin */
  274. 0xa51c0236, /* Robot Tank.bin */
  275. 0xd8ecf576, /* Decathlon (PAL) */
  276. 0x0e8757b0, /* Robot Tank (PAL) */
  277. 0x94e8df6b, /* Space Shuttle (PAL) */
  278. 0xf3a4363c, /* Thwocker prototype */
  279. -1
  280. };
  281. const char *BS_5_DESC[] = {
  282. "Decathlon",
  283. "Robot Tank",
  284. "Decathlon (PAL)",
  285. "Robot Tank (PAL)",
  286. "Space Shuttle (PAL)",
  287. "Thwocker (proto)",
  288. ""
  289. };
  290. dd BS_9[] = {
  291. 0x6a31beac, /* Private Eye (CCE).bin */
  292. 0x3fa749c0, /* Private Eye [b].bin */
  293. 0x33242242, /* Private Eye.bin */
  294. -1
  295. };
  296. const char *BS_9_DESC[] = {
  297. "Private Eye (CCE)",
  298. "Private Eye [b]",
  299. "Private Eye",
  300. ""
  301. };
  302. dd BS_6[] = {
  303. 0xa972c32b, /* Dig Dug.bin */
  304. 0x66cdb94b, /* Off the Wall [o].bin */
  305. 0xbd75d92b, /* Off the Wall.bin */
  306. -1
  307. };
  308. const char *BS_6_DESC[] = {
  309. "Dig Dug.bin",
  310. "Off the Wall [o]",
  311. "Off the Wall",
  312. ""
  313. };
  314. dd BS_7[] = {
  315. 0x8eed6b02, /* Bump n Jump [b].bin */
  316. 0xd523e776, /* Bump n Jump.bin */
  317. 0x24c35820, /* Burgertime.bin */
  318. 0x5c161fe4, /* Masters of the Universe - The Power of He-Man.bin */
  319. -1
  320. };
  321. const char *BS_7_DESC[] = {
  322. "Bump n Jump [b].bin",
  323. "Bump n Jump.bin",
  324. "Burgertime.bin",
  325. "Masters of the Universe - The Power of He-Man",
  326. ""
  327. };
  328. /*
  329. dd BS_8[] = {
  330. 0xbe1047cf, Fatal Run (PAL).bin
  331. -1
  332. };
  333. */
  334. dd crc; /* holds accumulated CRC */
  335. dd crctab[256]; /* table to help CRC calculation */
  336. #define CRC16_REV 0xA001 /* CRC-16 polynomial reversed */
  337. #define CRC32_REV 0xA0000001 /* CRC-32 polynomial reversed */
  338. #define SQUARE_WAVE 0
  339. #define SINE_WAVE 1
  340. void make16BitStereo(unsigned char *sineWave, unsigned char *sineWaveLength);