| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
. |
| 6 |
|
| 7 |
|
| 8 |
#include <ctype.h> |
| 9 |
#include <stdbool.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <string.h> |
| 12 |
|
| 13 |
#include "hulk.h" |
| 14 |
#include "saga.h" |
| 15 |
#include "sagagraphics.h" |
| 16 |
#include "scott.h" |
| 17 |
#include "scottdefines.h" |
| 18 |
|
| 19 |
#include "atari8c64draw.h" |
| 20 |
#include "atari8detect.h" |
| 21 |
#include "scottgameinfo.h" |
| 22 |
|
| 23 |
static const pairrec a8companionlist[][2] = { |
| 24 |
{ { 0x16810, 0xa972, "S.A.G.A. 01 - Adventureland v5.0-416 (1982)(Adventure International)(US)(Side A)[!].atr", 87 }, { 0x16810, 0x8be3, "S.A.G.A. 01 - Adventureland v5.0-416 (1982)(Adventure International)(US)(Side B)[!][cr CSS].atr", 95 } }, |
| 25 |
{ { 0x16810, 0x65a1, "S.A.G.A. 02 - Pirate Adventure v5.0-408 (1982)(Adventure International)(US)(Side A)[f][m].atr", 93 }, { 0x16810, 0x5750, "S.A.G.A. 02 - Pirate Adventure v5.0-408 (1982)(Adventure International)(US)(Side B)[cr CSS].atr", 95 } }, |
| 26 |
{ { 0x16810, 0x3074, "S.A.G.A. 02 - Pirate Adventure v5.0-408 (1982)(Adventure International)(US)(Side A)[f][a].atr", 93 }, { 0x16810, 0x2429, "S.A.G.A. 02 - Pirate Adventure v5.0-408 (1982)(Adventure International)(US)(Side B)[a][cr CSS].atr", 98 } }, |
| 27 |
{ { 0x16810, 0x4389, "S.A.G.A. 04 - Voodoo Castle v5.1-119 (1983)(Adventure International)(US)(Disk 1 of 2)[!].atr", 92 }, { 0x16810, 0x234f, "S.A.G.A. 04 - Voodoo Castle v5.1-119 (1983)(Adventure International)(US)(Disk 2 of 2)[!][cr CSS].atr", 100 } }, |
| 28 |
{ { 0x16810, 0xc2f5, "S.A.G.A. 05 - The Count v5.1-115 (1983)(Adventure International)(US)(Side A)[!].atr", 83 }, { 0x16810, 0x3ebb, "S.A.G.A. 05 - The Count v5.1-115 (1983)(Adventure International)(US)(Side B)[!][cr CSS].atr", 91 } }, |
| 29 |
{ { 0x16810, 0x6ee8, "S.A.G.A. 13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 1 of 2)[!][cr CSS].atr", 120 }, { 0x16810, 0xac42, "S.A.G.A. 13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 2 of 2)[f][!].atr", 115 } }, |
| 30 |
{ { 0x16810, 0x1de8, "S.A.G.A. 13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 1 of 2)[a][cr CSS].atr", 120 }, { 0x16810, 0x7c32, "S.A.G.A. 13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 2 of 2)[a].atr", 112 } }, |
| 31 |
{ { 0x16810, 0x1de8, "S.A.G.A. #13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 1 of 2)[a][cr CSS].atr", 121 }, { 0x16810, 0x7c32, "S.A.G.A. #13 - The Sorcerer of Claymorgue Castle v5.1-125 (1983)(Adventure International)(US)(Disk 2 of 2)[a].atr", 113 } }, |
| 32 |
|
| 33 |
{ { 0, 0, NULL }, { 0, 0, NULL } } |
| 34 |
|
| 35 |
}; |
| 36 |
|
| 37 |
typedef struct imglist { |
| 38 |
USImageType usage; |
| 39 |
int index; |
| 40 |
size_t offset; |
| 41 |
} imglist; |
| 42 |
|
| 43 |
static const struct imglist listHulk[] = { |
| 44 |
{ IMG_ROOM, 0, 0x297 }, |
| 45 |
{ IMG_ROOM, 1, 0x2479 }, |
| 46 |
{ IMG_ROOM, 2, 0x71e }, |
| 47 |
{ IMG_ROOM, 3, 0x2a6b }, |
| 48 |
{ IMG_ROOM, 4, 0xd17 }, |
| 49 |
{ IMG_ROOM, 9, 0x2ef2 }, |
| 50 |
{ IMG_ROOM, 12, 0x1325 }, |
| 51 |
{ IMG_ROOM, 15, 0x381e }, |
| 52 |
{ IMG_ROOM, 16, 0x4064 }, |
| 53 |
{ IMG_ROOM, 19, 0x4bac }, |
| 54 |
{ IMG_ROOM, 20, 0x5256 }, |
| 55 |
{ IMG_ROOM, 81, 0x5ee4 }, |
| 56 |
{ IMG_ROOM, 82, 0x695d }, |
| 57 |
{ IMG_ROOM, 83, 0x7207 }, |
| 58 |
{ IMG_ROOM, 84, 0x8deb }, |
| 59 |
{ IMG_ROOM, 85, 0x7a8e }, |
| 60 |
{ IMG_ROOM, 86, 0x9deb }, |
| 61 |
{ IMG_ROOM, 87, 0x8717 }, |
| 62 |
{ IMG_ROOM, 88, 0xac90 }, |
| 63 |
{ IMG_ROOM, 89, 0xba2c }, |
| 64 |
{ IMG_ROOM, 90, 0xcb00 }, |
| 65 |
{ IMG_ROOM, 91, 0xd497 }, |
| 66 |
{ IMG_ROOM, 92, 0xdea5 }, |
| 67 |
{ IMG_ROOM, 93, 0x10479 }, |
| 68 |
{ IMG_ROOM, 94, 0xe7c1 }, |
| 69 |
{ IMG_ROOM, 95, 0x10df2 }, |
| 70 |
{ IMG_ROOM, 96, 0xf5a5 }, |
| 71 |
{ IMG_ROOM, 97, 0x1146b }, |
| 72 |
{ IMG_ROOM, 99, 0x11a33 }, |
| 73 |
{ IMG_ROOM_OBJ, 13, 0x12700 }, |
| 74 |
{ IMG_ROOM_OBJ, 20, 0x127ba }, |
| 75 |
{ IMG_ROOM_OBJ, 24, 0x12e0e }, |
| 76 |
{ IMG_ROOM_OBJ, 53, 0x12ea5 }, |
| 77 |
{ IMG_ROOM_OBJ, 26, 0x12f0e }, |
| 78 |
{ IMG_ROOM_OBJ, 17, 0x13b8e }, |
| 79 |
{ IMG_ROOM_OBJ, 22, 0x13d17 }, |
| 80 |
{ IMG_ROOM_OBJ, 25, 0x13fdd }, |
| 81 |
{ IMG_ROOM_OBJ, 33, 0x14100 }, |
| 82 |
{ IMG_ROOM_OBJ, 36, 0x141a5 }, |
| 83 |
{ IMG_ROOM_OBJ, 34, 0x1420e }, |
| 84 |
{ IMG_ROOM_OBJ, 39, 0x1440e }, |
| 85 |
{ IMG_ROOM_OBJ, 40, 0x145c1 }, |
| 86 |
{ IMG_ROOM_OBJ, 45, 0x1469e }, |
| 87 |
{ IMG_ROOM_OBJ, 70, 0x1508e }, |
| 88 |
{ IMG_ROOM_OBJ, 72, 0x15307 }, |
| 89 |
{ IMG_INV_OBJ, 4, 0x15356 }, |
| 90 |
{ IMG_INV_OBJ, 12, 0x15397 }, |
| 91 |
{ IMG_INV_OBJ, 16, 0x153dd }, |
| 92 |
{ IMG_INV_OBJ, 19, 0x1541e }, |
| 93 |
{ IMG_INV_OBJ, 29, 0x15464 }, |
| 94 |
{ IMG_INV_OBJ, 30, 0x154a5 }, |
| 95 |
{ IMG_INV_OBJ, 31, 0x154eb }, |
| 96 |
{ IMG_INV_OBJ, 32, 0x1552c }, |
| 97 |
{ IMG_INV_OBJ, 35, 0x15572 }, |
| 98 |
{ IMG_INV_OBJ, 37, 0x155b3 }, |
| 99 |
{ IMG_INV_OBJ, 42, 0x155f9 }, |
| 100 |
{ IMG_INV_OBJ, 44, 0x1563a }, |
| 101 |
{ IMG_INV_OBJ, 46, 0x15680 }, |
| 102 |
{ IMG_INV_OBJ, 48, 0x156c1 }, |
| 103 |
{ IMG_INV_OBJ, 50, 0x15707 }, |
| 104 |
{ IMG_INV_OBJ, 2, 0x15748 }, |
| 105 |
{ IMG_INV_OBJ, 21, 0x157ba }, |
| 106 |
{ IMG_INV_OBJ, 1, 0x15807 }, |
| 107 |
{ IMG_INV_OBJ, 18, 0x15cc8 }, |
| 108 |
{ IMG_INV_OBJ, 3, 0x15da5 }, |
| 109 |
{ IMG_INV_OBJ, 23, 0x15ea5 }, |
| 110 |
{ IMG_ROOM_OBJ, 250, 0x15f3a }, |
| 111 |
{ IMG_INV_OBJ, 51, 0x15f79 }, |
| 112 |
{ IMG_ROOM_OBJ, 47, 0x15fba }, |
| 113 |
{ 0, 0, 0, } |
| 114 |
}; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
static const struct imglist listClaymorgue[] = { |
| 119 |
{ IMG_INV_OBJ, 5, 0x297 }, |
| 120 |
{ IMG_INV_OBJ, 6, 0x2c1 }, |
| 121 |
{ IMG_INV_OBJ, 7, 0x2e4 }, |
| 122 |
{ IMG_INV_OBJ, 8, 0x307 }, |
| 123 |
{ IMG_INV_OBJ, 9, 0x32c }, |
| 124 |
{ IMG_INV_OBJ, 10, 0x3b3 }, |
| 125 |
{ IMG_INV_OBJ, 11, 0x3d6 }, |
| 126 |
{ IMG_INV_OBJ, 12, 0x400 }, |
| 127 |
{ IMG_INV_OBJ, 13, 0x42c }, |
| 128 |
{ IMG_INV_OBJ, 14, 0x456 }, |
| 129 |
{ IMG_INV_OBJ, 15, 0x479 }, |
| 130 |
{ IMG_INV_OBJ, 16, 0x49e }, |
| 131 |
{ IMG_INV_OBJ, 17, 0x4c1 }, |
| 132 |
{ IMG_INV_OBJ, 20, 0x4eb }, |
| 133 |
{ IMG_INV_OBJ, 24, 0x52c }, |
| 134 |
{ IMG_INV_OBJ, 33, 0x580 }, |
| 135 |
{ IMG_INV_OBJ, 34, 0x5cf }, |
| 136 |
{ IMG_INV_OBJ, 35, 0x61e }, |
| 137 |
{ IMG_INV_OBJ, 36, 0x66b }, |
| 138 |
{ IMG_INV_OBJ, 40, 0x6b3 }, |
| 139 |
{ IMG_INV_OBJ, 41, 0x707 }, |
| 140 |
{ IMG_INV_OBJ, 42, 0x74f }, |
| 141 |
{ IMG_INV_OBJ, 45, 0x7ac }, |
| 142 |
{ IMG_INV_OBJ, 48, 0x800 }, |
| 143 |
{ IMG_INV_OBJ, 50, 0x864 }, |
| 144 |
{ IMG_INV_OBJ, 57, 0x8c1 }, |
| 145 |
{ IMG_INV_OBJ, 59, 0x910 }, |
| 146 |
{ IMG_INV_OBJ, 61, 0x93a }, |
| 147 |
{ IMG_INV_OBJ, 62, 0x98e }, |
| 148 |
{ IMG_INV_OBJ, 63, 0x9f2 }, |
| 149 |
{ IMG_INV_OBJ, 64, 0xa33 }, |
| 150 |
{ IMG_INV_OBJ, 68, 0xa87 }, |
| 151 |
{ IMG_INV_OBJ, 70, 0xac8 }, |
| 152 |
{ IMG_INV_OBJ, 71, 0xb17 }, |
| 153 |
{ IMG_INV_OBJ, 73, 0xb56 }, |
| 154 |
{ IMG_INV_OBJ, 28, 0xba5 }, |
| 155 |
{ IMG_INV_OBJ, 51, 0xbf2 }, |
| 156 |
{ IMG_INV_OBJ, 52, 0xc97 }, |
| 157 |
{ IMG_INV_OBJ, 65, 0xe80 }, |
| 158 |
{ IMG_INV_OBJ, 66, 0xee4 }, |
| 159 |
{ IMG_INV_OBJ, 69, 0xf33 }, |
| 160 |
{ IMG_ROOM_OBJ, 26, 0xf87 }, |
| 161 |
{ IMG_ROOM_OBJ, 38, 0x12b3 }, |
| 162 |
{ IMG_ROOM_OBJ, 30, 0x1e17 }, |
| 163 |
{ IMG_ROOM_OBJ, 32, 0x1fba }, |
| 164 |
{ IMG_ROOM_OBJ, 75, 0x211e }, |
| 165 |
{ IMG_ROOM_OBJ, 39, 0x232c }, |
| 166 |
{ IMG_ROOM_OBJ, 54, 0x28eb }, |
| 167 |
{ IMG_ROOM_OBJ, 55, 0x2bc1 }, |
| 168 |
{ IMG_ROOM_OBJ, 4, 0x2f0e }, |
| 169 |
{ IMG_ROOM_OBJ, 60, 0x3000 }, |
| 170 |
{ IMG_ROOM, 29, 0x3641 }, |
| 171 |
{ IMG_ROOM, 99, 0x4797 }, |
| 172 |
{ IMG_ROOM_OBJ, 49, 0x51c8 }, |
| 173 |
{ IMG_ROOM_OBJ, 47, 0x549e }, |
| 174 |
{ IMG_ROOM_OBJ, 250, 0x5580 }, |
| 175 |
{ IMG_INV_OBJ, 0, 0x55c1 }, |
| 176 |
{ IMG_ROOM_OBJ, 74, 0x55eb }, |
| 177 |
{ IMG_ROOM, 0, 0x5617 }, |
| 178 |
{ IMG_ROOM, 1, 0x57ba }, |
| 179 |
{ IMG_ROOM, 2, 0x628e }, |
| 180 |
{ IMG_ROOM, 3, 0x68cf }, |
| 181 |
{ IMG_ROOM, 4, 0x7864 }, |
| 182 |
{ IMG_ROOM, 5, 0x8297 }, |
| 183 |
{ IMG_ROOM, 6, 0x8c33 }, |
| 184 |
{ IMG_ROOM, 7, 0x95dd }, |
| 185 |
{ IMG_ROOM, 8, 0x9cb3 }, |
| 186 |
{ IMG_ROOM, 9, 0xa61e }, |
| 187 |
{ IMG_ROOM, 10, 0xa95d }, |
| 188 |
{ IMG_ROOM, 11, 0xad72 }, |
| 189 |
{ IMG_ROOM, 12, 0xb4ac }, |
| 190 |
{ IMG_ROOM, 13, 0xbd33 }, |
| 191 |
{ IMG_ROOM, 14, 0xc39e }, |
| 192 |
{ IMG_ROOM, 15, 0xc8d6 }, |
| 193 |
{ IMG_ROOM, 16, 0xcf4f }, |
| 194 |
{ IMG_ROOM, 17, 0xdbf2 }, |
| 195 |
{ IMG_ROOM, 18, 0xdc48 }, |
| 196 |
{ IMG_ROOM, 19, 0xeaba }, |
| 197 |
{ IMG_ROOM, 20, 0xfd17 }, |
| 198 |
{ IMG_ROOM, 21, 0x1029e }, |
| 199 |
{ IMG_ROOM, 22, 0x10aa5 }, |
| 200 |
{ IMG_ROOM, 23, 0x10f3a }, |
| 201 |
{ IMG_ROOM, 24, 0x116ac }, |
| 202 |
{ IMG_ROOM, 25, 0x1228e }, |
| 203 |
{ IMG_ROOM, 26, 0x1260e }, |
| 204 |
{ IMG_ROOM, 27, 0x135f2 }, |
| 205 |
{ IMG_ROOM, 28, 0x14048 }, |
| 206 |
{ IMG_ROOM, 30, 0x14c97 }, |
| 207 |
{ IMG_ROOM, 31, 0x158b3 }, |
| 208 |
{ IMG_ROOM, 32, 0x15ccf }, |
| 209 |
{ 0, 0, 0 } |
| 210 |
}; |
| 211 |
|
| 212 |
static const struct imglist listCount[] = { |
| 213 |
{ IMG_INV_OBJ, 0, 0x297 }, |
| 214 |
{ IMG_INV_OBJ, 16, 0x310 }, |
| 215 |
{ IMG_INV_OBJ, 26, 0x36b }, |
| 216 |
{ IMG_INV_OBJ, 19, 0x3e4 }, |
| 217 |
{ IMG_INV_OBJ, 45, 0x425 }, |
| 218 |
{ IMG_INV_OBJ, 42, 0x49e }, |
| 219 |
{ IMG_INV_OBJ, 47, 0x4c8 }, |
| 220 |
{ IMG_INV_OBJ, 3, 0x4f9 }, |
| 221 |
{ IMG_INV_OBJ, 17, 0x58e }, |
| 222 |
{ IMG_INV_OBJ, 27, 0x5dd }, |
| 223 |
{ IMG_INV_OBJ, 31, 0x656 }, |
| 224 |
{ IMG_INV_OBJ, 5, 0x697 }, |
| 225 |
{ IMG_INV_OBJ, 18, 0x6f2 }, |
| 226 |
{ IMG_INV_OBJ, 46, 0x73a }, |
| 227 |
{ IMG_INV_OBJ, 33, 0x7a5 }, |
| 228 |
{ IMG_INV_OBJ, 8, 0x7eb }, |
| 229 |
{ IMG_INV_OBJ, 21, 0x848 }, |
| 230 |
{ IMG_INV_OBJ, 20, 0x8a5 }, |
| 231 |
{ IMG_INV_OBJ, 51, 0x900 }, |
| 232 |
{ IMG_INV_OBJ, 61, 0x997 }, |
| 233 |
{ IMG_INV_OBJ, 9, 0xa4f }, |
| 234 |
{ IMG_INV_OBJ, 24, 0xadd }, |
| 235 |
{ IMG_INV_OBJ, 37, 0xb56 }, |
| 236 |
{ IMG_INV_OBJ, 15, 0xbc8 }, |
| 237 |
{ IMG_INV_OBJ, 23, 0xc2c }, |
| 238 |
{ IMG_INV_OBJ, 41, 0xceb }, |
| 239 |
{ IMG_INV_OBJ, 53, 0xd72 }, |
| 240 |
{ IMG_INV_OBJ, 65, 0xdf9 }, |
| 241 |
{ IMG_INV_OBJ, 58, 0xe90 }, |
| 242 |
{ IMG_INV_OBJ, 70, 0xf2c }, |
| 243 |
{ IMG_INV_OBJ, 35, 0xfac }, |
| 244 |
{ IMG_ROOM_OBJ, 6, 0x10c8 }, |
| 245 |
{ IMG_ROOM_OBJ, 7, 0x116b }, |
| 246 |
{ IMG_ROOM_OBJ, 13, 0x12ba }, |
| 247 |
{ IMG_ROOM_OBJ, 82, 0x13f9 }, |
| 248 |
{ IMG_ROOM_OBJ, 40, 0x168e }, |
| 249 |
{ IMG_ROOM_OBJ, 52, 0x16b3 }, |
| 250 |
{ IMG_ROOM_OBJ, 55, 0x1b48 }, |
| 251 |
{ IMG_ROOM, 90, 0x1ccf }, |
| 252 |
{ IMG_ROOM_OBJ, 63, 0x261e }, |
| 253 |
{ IMG_ROOM_OBJ, 67, 0x2733 }, |
| 254 |
{ IMG_ROOM_OBJ, 80, 0x2cdd }, |
| 255 |
{ IMG_ROOM_OBJ, 81, 0x2ecf }, |
| 256 |
{ IMG_ROOM, 250, 0x3000 }, |
| 257 |
{ IMG_ROOM_OBJ, 29, 0x302c }, |
| 258 |
{ IMG_ROOM_OBJ, 30, 0x334f }, |
| 259 |
{ IMG_ROOM, 91, 0x3580 }, |
| 260 |
{ IMG_ROOM_OBJ, 1, 0x4072 }, |
| 261 |
{ IMG_ROOM_OBJ, 36, 0x408e }, |
| 262 |
{ IMG_ROOM, 2, 0x413a }, |
| 263 |
{ IMG_ROOM, 0, 0x4a25 }, |
| 264 |
{ IMG_ROOM, 1, 0x5580 }, |
| 265 |
{ IMG_ROOM, 3, 0x5e48 }, |
| 266 |
{ IMG_ROOM, 4, 0x6a17 }, |
| 267 |
{ IMG_ROOM, 5, 0x74c1 }, |
| 268 |
{ IMG_ROOM, 6, 0x7cba }, |
| 269 |
{ IMG_ROOM, 7, 0x8f41 }, |
| 270 |
{ IMG_ROOM, 8, 0x984f }, |
| 271 |
{ IMG_ROOM, 9, 0xa10e }, |
| 272 |
{ IMG_ROOM, 10, 0xad79 }, |
| 273 |
{ IMG_ROOM, 11, 0xb687 }, |
| 274 |
{ IMG_ROOM, 12, 0xc0d6 }, |
| 275 |
{ IMG_ROOM, 13, 0xcc56 }, |
| 276 |
{ IMG_ROOM, 14, 0xdf5d }, |
| 277 |
{ IMG_ROOM, 15, 0xe872 }, |
| 278 |
{ IMG_ROOM, 16, 0xf72c }, |
| 279 |
{ IMG_ROOM, 17, 0x10441 }, |
| 280 |
{ IMG_ROOM, 18, 0x1159e }, |
| 281 |
{ IMG_ROOM, 19, 0x12872 }, |
| 282 |
{ IMG_ROOM, 20, 0x12f5d }, |
| 283 |
{ IMG_ROOM, 21, 0x136b3 }, |
| 284 |
{ IMG_ROOM, 22, 0x1400e }, |
| 285 |
{ IMG_ROOM, 99, 0x14f97 }, |
| 286 |
{ IMG_ROOM_OBJ, 56, 0x16156 }, |
| 287 |
{ 0, 0, 0 } |
| 288 |
}; |
| 289 |
|
| 290 |
static const struct imglist listVoodoo[] = { |
| 291 |
{ IMG_ROOM, 1, 0x297 }, |
| 292 |
{ IMG_ROOM, 14, 0xac1 }, |
| 293 |
{ IMG_ROOM, 2, 0x1a79 }, |
| 294 |
{ IMG_ROOM, 3, 0x1e2c }, |
| 295 |
{ IMG_ROOM, 4, 0x28a5 }, |
| 296 |
{ IMG_ROOM, 5, 0x3817 }, |
| 297 |
{ IMG_ROOM, 6, 0x3f87 }, |
| 298 |
{ IMG_ROOM, 7, 0x4664 }, |
| 299 |
{ IMG_ROOM, 8, 0x4f0e }, |
| 300 |
{ IMG_ROOM, 9, 0x52ac }, |
| 301 |
{ IMG_ROOM, 10, 0x5b48 }, |
| 302 |
{ IMG_ROOM, 11, 0x6264 }, |
| 303 |
{ IMG_ROOM, 12, 0x67dd }, |
| 304 |
{ IMG_ROOM, 13, 0x740e }, |
| 305 |
{ IMG_ROOM, 15, 0x7d4f }, |
| 306 |
{ IMG_ROOM, 16, 0x8af2 }, |
| 307 |
{ IMG_ROOM, 17, 0x954f }, |
| 308 |
{ IMG_ROOM, 18, 0xa19e }, |
| 309 |
{ IMG_ROOM, 19, 0xab17 }, |
| 310 |
{ IMG_ROOM, 20, 0xbe1e }, |
| 311 |
{ IMG_ROOM, 21, 0xc579 }, |
| 312 |
{ IMG_ROOM, 22, 0xcf9e }, |
| 313 |
{ IMG_ROOM, 23, 0xd533 }, |
| 314 |
{ IMG_ROOM, 24, 0xe5e4 }, |
| 315 |
{ IMG_ROOM, 25, 0xeb3a }, |
| 316 |
{ IMG_ROOM, 90, 0xf856 }, |
| 317 |
{ IMG_ROOM, 96, 0xfd87 }, |
| 318 |
{ IMG_ROOM, 101, 0x1068e }, |
| 319 |
{ IMG_ROOM, 100, 0x114e4 }, |
| 320 |
{ IMG_ROOM, 99, 0x11956 }, |
| 321 |
{ IMG_ROOM, 0, 0x12879 }, |
| 322 |
{ IMG_ROOM_OBJ, 17, 0x131cf }, |
| 323 |
{ IMG_INV_OBJ, 26, 0x13325 }, |
| 324 |
{ IMG_INV_OBJ, 43, 0x13407 }, |
| 325 |
{ IMG_INV_OBJ, 14, 0x134ba }, |
| 326 |
{ IMG_INV_OBJ, 60, 0x1355d }, |
| 327 |
{ IMG_INV_OBJ, 16, 0x1359e }, |
| 328 |
{ IMG_INV_OBJ, 44, 0x1360e }, |
| 329 |
{ IMG_INV_OBJ, 25, 0x136ba }, |
| 330 |
{ IMG_INV_OBJ, 39, 0x13733 }, |
| 331 |
{ IMG_INV_OBJ, 38, 0x1378e }, |
| 332 |
{ IMG_INV_OBJ, 54, 0x13817 }, |
| 333 |
{ IMG_INV_OBJ, 33, 0x13879 }, |
| 334 |
{ IMG_INV_OBJ, 0, 0x138dd }, |
| 335 |
{ IMG_INV_OBJ, 64, 0x1392c }, |
| 336 |
{ IMG_INV_OBJ, 47, 0x13972 }, |
| 337 |
{ IMG_INV_OBJ, 2, 0x139c1 }, |
| 338 |
{ IMG_INV_OBJ, 52, 0x13a2c }, |
| 339 |
{ IMG_INV_OBJ, 21, 0x13aa5 }, |
| 340 |
{ IMG_INV_OBJ, 49, 0x13b0e }, |
| 341 |
{ IMG_INV_OBJ, 7, 0x13b64 }, |
| 342 |
{ IMG_INV_OBJ, 4, 0x13c56 }, |
| 343 |
{ IMG_INV_OBJ, 3, 0x13cac }, |
| 344 |
{ IMG_INV_OBJ, 36, 0x13d6b }, |
| 345 |
{ IMG_INV_OBJ, 53, 0x13db3 }, |
| 346 |
{ IMG_INV_OBJ, 9, 0x13e97 }, |
| 347 |
{ IMG_INV_OBJ, 40, 0x13f72 }, |
| 348 |
{ IMG_INV_OBJ, 42, 0x13ff9 }, |
| 349 |
{ IMG_INV_OBJ, 51, 0x1405d }, |
| 350 |
{ IMG_INV_OBJ, 63, 0x140d6 }, |
| 351 |
{ IMG_INV_OBJ, 45, 0x1415d }, |
| 352 |
{ IMG_INV_OBJ, 59, 0x14217 }, |
| 353 |
{ IMG_INV_OBJ, 29, 0x14279 }, |
| 354 |
{ IMG_ROOM_OBJ, 19, 0x14333 }, |
| 355 |
{ IMG_ROOM_OBJ, 23, 0x144c1 }, |
| 356 |
{ IMG_ROOM_OBJ, 28, 0x147f2 }, |
| 357 |
{ IMG_ROOM_OBJ, 35, 0x14e1e }, |
| 358 |
{ IMG_ROOM_OBJ, 6, 0x15710 }, |
| 359 |
{ IMG_ROOM_OBJ, 41, 0x158c8 }, |
| 360 |
{ IMG_ROOM_OBJ, 65, 0x15972 }, |
| 361 |
{ IMG_ROOM_OBJ, 13, 0x15cf9 }, |
| 362 |
{ IMG_ROOM_OBJ, 31, 0x15eb3 }, |
| 363 |
{ IMG_ROOM_OBJ, 34, 0x16025 }, |
| 364 |
{ IMG_ROOM_OBJ, 37, 0x1625d }, |
| 365 |
{ IMG_ROOM_OBJ, 46, 0x16348 }, |
| 366 |
{ IMG_ROOM_OBJ, 48, 0x16472 }, |
| 367 |
{ IMG_INV_OBJ, 32, 0x164f2 }, |
| 368 |
{ IMG_ROOM, 250, 0x16490 }, |
| 369 |
{ IMG_ROOM_OBJ, 80, 0x165c1 }, |
| 370 |
{ 0, 0, 0, } |
| 371 |
}; |
| 372 |
|
| 373 |
static const CropList a8croplist[] = { |
| 374 |
{ VOODOO_CASTLE_US, IMG_ROOM, 10, 8, 8 }, |
| 375 |
{ VOODOO_CASTLE_US, IMG_ROOM, 11, 8, 8 }, |
| 376 |
{ VOODOO_CASTLE_US, IMG_ROOM, 14, 8, 8 }, |
| 377 |
{ VOODOO_CASTLE_US, IMG_ROOM, 19, 8, 8 }, |
| 378 |
{ VOODOO_CASTLE_US, IMG_ROOM, 20, 8, 8 }, |
| 379 |
{ HULK_US, IMG_ROOM, 0, 0, 32 }, |
| 380 |
{ COUNT_US, IMG_ROOM, 0, 8, 0 }, |
| 381 |
|
| 382 |
{ 0, 0, 0, 0, 0 } |
| 383 |
}; |
| 384 |
|
| 385 |
static int StripBrackets(char sideB[], size_t length) |
| 386 |
{ |
| 387 |
int left_bracket = 0; |
| 388 |
int right_bracket = 0; |
| 389 |
size_t ppos = length - 1; |
| 390 |
while (sideB[ppos] != '.' && ppos > 0) |
| 391 |
ppos--; |
| 392 |
size_t extlen = length - ppos; |
| 393 |
if (length > 4) { |
| 394 |
for (int i = (int)ppos; i > 0; i--) { |
| 395 |
char c = sideB[i]; |
| 396 |
if (c == ']') { |
| 397 |
if (right_bracket == 0) { |
| 398 |
right_bracket = i; |
| 399 |
} else { |
| 400 |
return 0; |
| 401 |
} |
| 402 |
} else if (c == '[') { |
| 403 |
if (right_bracket > 0) { |
| 404 |
left_bracket = i; |
| 405 |
break; |
| 406 |
} else { |
| 407 |
return 0; |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
if (right_bracket && left_bracket && length > right_bracket + extlen) { |
| 412 |
right_bracket++; |
| 413 |
for (int i = 0; i < extlen; i++) { |
| 414 |
sideB[left_bracket++] = sideB[right_bracket++]; |
| 415 |
} |
| 416 |
sideB[left_bracket] = '\0'; |
| 417 |
return 1; |
| 418 |
} |
| 419 |
} |
| 420 |
return 0; |
| 421 |
} |
| 422 |
|
| 423 |
static uint8_t *LookForAtari8CompanionFilename(int index, CompanionNameType type, size_t stringlen, size_t *filesize) |
| 424 |
{ |
| 425 |
|
| 426 |
char *sideB = MemAlloc(stringlen + 10); |
| 427 |
uint8_t *result = NULL; |
| 428 |
|
| 429 |
memcpy(sideB, game_file, stringlen + 1); |
| 430 |
switch (type) { |
| 431 |
case TYPE_A: |
| 432 |
sideB[index] = 'A'; |
| 433 |
break; |
| 434 |
case TYPE_B: |
| 435 |
sideB[index] = 'B'; |
| 436 |
break; |
| 437 |
case TYPE_1: |
| 438 |
sideB[index] = '1'; |
| 439 |
break; |
| 440 |
case TYPE_2: |
| 441 |
sideB[index] = '2'; |
| 442 |
break; |
| 443 |
case TYPE_ONE: |
| 444 |
sideB[index] = 'o'; |
| 445 |
sideB[index + 1] = 'n'; |
| 446 |
sideB[index + 2] = 'e'; |
| 447 |
break; |
| 448 |
case TYPE_TWO: |
| 449 |
sideB[index] = 't'; |
| 450 |
sideB[index + 1] = 'w'; |
| 451 |
sideB[index + 2] = 'o'; |
| 452 |
break; |
| 453 |
case TYPE_NONE: |
| 454 |
break; |
| 455 |
} |
| 456 |
|
| 457 |
debug_print("looking for companion file \"%s\"\n", sideB); |
| 458 |
result = ReadFileIfExists(sideB, filesize); |
| 459 |
if (!result) { |
| 460 |
if (type == TYPE_B) { |
| 461 |
if (StripBrackets(sideB, stringlen)) { |
| 462 |
debug_print("looking for companion file \"%s\"\n", sideB); |
| 463 |
result = ReadFileIfExists(sideB, filesize); |
| 464 |
} |
| 465 |
} else if (type == TYPE_A) { |
| 466 |
|
| 467 |
size_t ppos = stringlen - 1; |
| 468 |
while (sideB[ppos] != '.' && ppos > 0) |
| 469 |
ppos--; |
| 470 |
if (ppos < 1) { |
| 471 |
free(sideB); |
| 472 |
return NULL; |
| 473 |
} |
| 474 |
|
| 475 |
for (size_t i = ppos; i <= stringlen; i++) { |
| 476 |
sideB[i + 8] = sideB[i]; |
| 477 |
} |
| 478 |
sideB[ppos++] = '['; |
| 479 |
sideB[ppos++] = 'c'; |
| 480 |
sideB[ppos++] = 'r'; |
| 481 |
sideB[ppos++] = ' '; |
| 482 |
sideB[ppos++] = 'C'; |
| 483 |
sideB[ppos++] = 'S'; |
| 484 |
sideB[ppos++] = 'S'; |
| 485 |
sideB[ppos] = ']'; |
| 486 |
debug_print("looking for companion file \"%s\"\n", sideB); |
| 487 |
result = ReadFileIfExists(sideB, filesize); |
| 488 |
} |
| 489 |
} |
| 490 |
free(sideB); |
| 491 |
return result; |
| 492 |
} |
| 493 |
|
| 494 |
static uint8_t *GetAtari8CompanionFile(size_t *size) |
| 495 |
{ |
| 496 |
|
| 497 |
size_t gamefilelen = strlen(game_file); |
| 498 |
char *foundname = LookInDatabase(a8companionlist, gamefilelen); |
| 499 |
uint8_t *result = NULL; |
| 500 |
if (foundname) { |
| 501 |
result = ReadFileIfExists(foundname, size); |
| 502 |
free((void *)foundname); |
| 503 |
if (result) |
| 504 |
return result; |
| 505 |
} |
| 506 |
|
| 507 |
char c; |
| 508 |
for (int i = (int)gamefilelen - 1; i >= 0 && game_file[i] != '/' && game_file[i] != '\\'; i--) { |
| 509 |
c = tolower(game_file[i]); |
| 510 |
if (i > 3 && ((c == 'e' && game_file[i - 1] == 'd' && game_file[i - 2] == 'i' && tolower(game_file[i - 3]) == 's') || (c == 'k' && game_file[i - 1] == 's' && game_file[i - 2] == 'i' && tolower(game_file[i - 3]) == 'd'))) { |
| 511 |
if (gamefilelen > i + 2) { |
| 512 |
c = game_file[i + 1]; |
| 513 |
if (c == ' ' || c == '_') { |
| 514 |
c = tolower(game_file[i + 2]); |
| 515 |
CompanionNameType type = TYPE_NONE; |
| 516 |
switch (c) { |
| 517 |
case 'a': |
| 518 |
type = TYPE_B; |
| 519 |
break; |
| 520 |
case 'b': |
| 521 |
type = TYPE_A; |
| 522 |
break; |
| 523 |
case 't': |
| 524 |
if (gamefilelen > i + 4 && game_file[i + 3] == 'w' && game_file[i + 4] == 'o') { |
| 525 |
type = TYPE_ONE; |
| 526 |
} |
| 527 |
break; |
| 528 |
case 'o': |
| 529 |
if (gamefilelen > i + 4 && game_file[i + 3] == 'n' && game_file[i + 4] == 'e') { |
| 530 |
type = TYPE_TWO; |
| 531 |
} |
| 532 |
break; |
| 533 |
case '2': |
| 534 |
type = TYPE_1; |
| 535 |
break; |
| 536 |
case '1': |
| 537 |
type = TYPE_2; |
| 538 |
break; |
| 539 |
} |
| 540 |
if (type != TYPE_NONE) |
| 541 |
result = LookForAtari8CompanionFilename(i + 2, type, gamefilelen, size); |
| 542 |
if (result) |
| 543 |
return result; |
| 544 |
} |
| 545 |
} |
| 546 |
} |
| 547 |
} |
| 548 |
return NULL; |
| 549 |
} |
| 550 |
|
| 551 |
static int ExtractImagesFromAtariCompanionFile(uint8_t *data, size_t datasize, uint8_t *otherdisk, size_t othersize) |
| 552 |
{ |
| 553 |
size_t size; |
| 554 |
|
| 555 |
int outpic; |
| 556 |
|
| 557 |
const struct imglist *list; |
| 558 |
|
| 559 |
switch (CurrentGame) { |
| 560 |
case CLAYMORGUE_US: |
| 561 |
list = listClaymorgue; |
| 562 |
break; |
| 563 |
case COUNT_US: |
| 564 |
list = listCount; |
| 565 |
break; |
| 566 |
case VOODOO_CASTLE_US: |
| 567 |
list = listVoodoo; |
| 568 |
break; |
| 569 |
case HULK_US: |
| 570 |
list = listHulk; |
| 571 |
break; |
| 572 |
default: |
| 573 |
return 0; |
| 574 |
} |
| 575 |
|
| 576 |
USImages = new_image(); |
| 577 |
struct USImage *image = USImages; |
| 578 |
|
| 579 |
|
| 580 |
for (outpic = 0; list[outpic].offset != 0; outpic++) { |
| 581 |
uint8_t *ptr = data + list[outpic].offset; |
| 582 |
|
| 583 |
size = *ptr++; |
| 584 |
size += *ptr * 256 + 2; |
| 585 |
|
| 586 |
image->usage = list[outpic].usage; |
| 587 |
image->index = list[outpic].index; |
| 588 |
image->imagedata = MemAlloc(size); |
| 589 |
image->datasize = size; |
| 590 |
image->systype = SYS_ATARI8; |
| 591 |
memcpy(image->imagedata, data + list[outpic].offset - 2, size); |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
if (list[outpic].offset < 0xb390 && list[outpic].offset + image->datasize > 0xb390) { |
| 596 |
memcpy(image->imagedata + 0xb390 - list[outpic].offset + 2, data + 0xb410, size - 0xb390 + list[outpic].offset - 2); |
| 597 |
} |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
if (CurrentGame == VOODOO_CASTLE_US && image->usage == IMG_ROOM) |
| 603 |
image->cropleft = 8; |
| 604 |
|
| 605 |
if ((CurrentGame == CLAYMORGUE_US || CurrentGame == COUNT_US) && image->usage == IMG_ROOM && image->imagedata[7] == 126) |
| 606 |
image->cropright = 8; |
| 607 |
|
| 608 |
for (int i = 0; a8croplist[i].game != 0; i++) { |
| 609 |
CropList crop = a8croplist[i]; |
| 610 |
if (crop.game == CurrentGame && crop.index == image->index && crop.usage == image->usage) { |
| 611 |
image->cropleft = crop.cropleft; |
| 612 |
image->cropright = crop.cropright; |
| 613 |
} |
| 614 |
} |
| 615 |
|
| 616 |
image->next = new_image(); |
| 617 |
image->next->previous = image; |
| 618 |
image = image->next; |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
if (otherdisk && othersize > 0x988e + 0x5fd) { |
| 623 |
image->usage = IMG_ROOM; |
| 624 |
image->index = 98; |
| 625 |
image->datasize = 0x5fd; |
| 626 |
image->imagedata = MemAlloc(image->datasize); |
| 627 |
image->systype = SYS_ATARI8; |
| 628 |
memcpy(image->imagedata, otherdisk + 0x988e, image->datasize); |
| 629 |
} else if (image->imagedata == NULL) { |
| 630 |
|
| 631 |
if (image != USImages) { |
| 632 |
image->previous->next = NULL; |
| 633 |
free(image); |
| 634 |
image = NULL; |
| 635 |
} else { |
| 636 |
free(USImages); |
| 637 |
USImages = NULL; |
| 638 |
} |
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
if (USImages != NULL && USImages->next == NULL && USImages->imagedata == NULL) { |
| 643 |
free(USImages); |
| 644 |
USImages = NULL; |
| 645 |
} |
| 646 |
|
| 647 |
return 1; |
| 648 |
} |
| 649 |
|
| 650 |
static const uint8_t atrheader[6] = { 0x96, 0x02, 0x80, 0x16, 0x80, 0x00 }; |
| 651 |
|
| 652 |
GameIDType DetectAtari8(uint8_t **sf, size_t *extent) |
| 653 |
{ |
| 654 |
GameIDType result = UNKNOWN_GAME; |
| 655 |
size_t data_start = 0x04c1; |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
if (*extent > MAX_LENGTH || *extent < data_start) |
| 660 |
return UNKNOWN_GAME; |
| 661 |
|
| 662 |
for (int i = 0; i < 6; i++) |
| 663 |
if ((*sf)[i] != atrheader[i]) |
| 664 |
return UNKNOWN_GAME; |
| 665 |
|
| 666 |
size_t companionsize; |
| 667 |
uint8_t *companionfile = GetAtari8CompanionFile(&companionsize); |
| 668 |
|
| 669 |
ImageWidth = 280; |
| 670 |
ImageHeight = 158; |
| 671 |
result = LoadBinaryDatabase(*sf + data_start, *extent - data_start, *Game, 0); |
| 672 |
if (result == UNKNOWN_GAME && companionfile != NULL && companionsize > data_start) { |
| 673 |
debug_print("Could not find database in this file, trying the companion file\n"); |
| 674 |
result = LoadBinaryDatabase(companionfile + data_start, companionsize - data_start, *Game, 0); |
| 675 |
if (result != UNKNOWN_GAME) { |
| 676 |
debug_print("Found database in companion file. Switching files.\n"); |
| 677 |
uint8_t *temp = companionfile; |
| 678 |
size_t tempsize = companionsize; |
| 679 |
companionfile = *sf; |
| 680 |
companionsize = *extent; |
| 681 |
*sf = temp; |
| 682 |
*extent = tempsize; |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
if (result != UNKNOWN_GAME) { |
| 687 |
CurrentSys = SYS_ATARI8; |
| 688 |
if (companionfile) { |
| 689 |
ExtractImagesFromAtariCompanionFile(companionfile, companionsize, *sf, *extent); |
| 690 |
free(companionfile); |
| 691 |
} |
| 692 |
} else |
| 693 |
debug_print("Failed loading database\n"); |
| 694 |
|
| 695 |
return result; |
| 696 |
} |