jaguar.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. jaguar.c - Atari Jaguar support for uCON64
  3. Copyright (c) 1999 - 2001 NoisyB <noisyb@gmx.net>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifdef HAVE_CONFIG_H
  17. #include "config.h"
  18. #endif
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #ifdef HAVE_UNISTD_H
  22. #include <unistd.h>
  23. #endif
  24. #include <string.h>
  25. #include "misc/misc.h"
  26. #include "misc/file.h"
  27. #ifdef USE_ZLIB
  28. #include "misc/archive.h"
  29. #endif
  30. #include "misc/getopt2.h" // st_getopt2_t
  31. #include "ucon64.h"
  32. #include "ucon64_misc.h"
  33. #include "jaguar.h"
  34. const st_getopt2_t jaguar_usage[] =
  35. {
  36. {
  37. NULL, 0, 0, 0,
  38. NULL, "Panther(32bit prototype)/Jaguar64/Jaguar64 CD"/*"1989 Flare2/1993 Atari/1995 Atari"*/,
  39. NULL
  40. },
  41. {
  42. "jag", 0, 0, UCON64_JAG,
  43. NULL, "force recognition",
  44. &ucon64_wf[WF_OBJ_JAG_SWITCH]
  45. },
  46. {NULL, 0, 0, 0, NULL, NULL, NULL}
  47. };
  48. typedef struct st_jaguar
  49. {
  50. char pad[16];
  51. } st_jaguar_t;
  52. #define JAGUAR_HEADER_START 0x400
  53. #define JAGUAR_HEADER_LEN (sizeof (st_jaguar_t))
  54. st_jaguar_t jaguar_header;
  55. int
  56. jaguar_init (st_rominfo_t *rominfo)
  57. {
  58. int result = -1, x, value;
  59. rominfo->buheader_len = UCON64_ISSET (ucon64.buheader_len) ?
  60. ucon64.buheader_len : 0;
  61. ucon64_fread (&jaguar_header, JAGUAR_HEADER_START +
  62. rominfo->buheader_len, JAGUAR_HEADER_LEN, ucon64.rom);
  63. value = 0;
  64. for (x = 0; x < 12; x++)
  65. value += OFFSET (jaguar_header, x);
  66. if (value == 0xb0)
  67. result = 0;
  68. else
  69. {
  70. rominfo->buheader_len = UCON64_ISSET (ucon64.buheader_len) ?
  71. ucon64.buheader_len : (int) UNKNOWN_HEADER_LEN;
  72. ucon64_fread (&jaguar_header, JAGUAR_HEADER_START +
  73. rominfo->buheader_len, JAGUAR_HEADER_LEN, ucon64.rom);
  74. value = 0;
  75. for (x = 0; x < 12; x++)
  76. value += OFFSET (jaguar_header, x);
  77. if (value == 0xb0)
  78. result = 0;
  79. else
  80. result = -1;
  81. }
  82. if (ucon64.console == UCON64_JAG)
  83. result = 0;
  84. rominfo->header_start = JAGUAR_HEADER_START;
  85. rominfo->header_len = JAGUAR_HEADER_LEN;
  86. rominfo->header = &jaguar_header;
  87. rominfo->console_usage = jaguar_usage[0].help;
  88. rominfo->copier_usage = unknown_usage[0].help;
  89. return result;
  90. }