src/mess/machine/ataricrt.c
| r10297 | r10298 | |
| 224 | 224 | switch (type) |
| 225 | 225 | { |
| 226 | 226 | case A800_4K: |
| 227 | case A800_RIGHT_4K: |
| 228 | case A800_12K: |
| 227 | 229 | case A800_8K: |
| 228 | | case A800_12K: |
| 229 | 230 | case A800_16K: |
| 230 | | case A800_RIGHT_4K: |
| 231 | 231 | case A800_RIGHT_8K: |
| 232 | 232 | case OSS_034M: |
| 233 | 233 | case OSS_M091: |
| r10297 | r10298 | |
| 247 | 247 | { |
| 248 | 248 | UINT8 header[16]; |
| 249 | 249 | image.fread(header, 0x10); |
| 250 | int hdr_type, cart_type; |
| 250 | 251 | |
| 251 | 252 | // add check of CART format |
| 252 | 253 | if (strncmp((const char *)header, "CART", 4)) |
| 253 | 254 | fatalerror("Invalid header detected!\n"); |
| 254 | 255 | |
| 255 | | int cart_type = (header[4] << 24) + (header[5] << 16) + (header[6] << 8) + (header[7] << 0); |
| 256 | | printf("cart type: %x\n", cart_type); |
| 256 | hdr_type = (header[4] << 24) + (header[5] << 16) + (header[6] << 8) + (header[7] << 0); |
| 257 | switch (hdr_type) |
| 258 | { |
| 259 | case 1: |
| 260 | cart_type = A800_8K; |
| 261 | break; |
| 262 | case 2: |
| 263 | cart_type = A800_16K; |
| 264 | break; |
| 265 | case 3: |
| 266 | cart_type = OSS_034M; |
| 267 | break; |
| 268 | case 8: |
| 269 | cart_type = WILLIAMS_64K; |
| 270 | break; |
| 271 | case 9: |
| 272 | cart_type = DIAMOND_64K; |
| 273 | break; |
| 274 | case 10: |
| 275 | cart_type = EXPRESS_64; |
| 276 | break; |
| 277 | case 11: |
| 278 | cart_type = SPARTADOS_X; |
| 279 | break; |
| 280 | case 12: |
| 281 | cart_type = XEGS_32K; |
| 282 | break; |
| 283 | case 15: |
| 284 | cart_type = OSS_M091; |
| 285 | break; |
| 286 | case 18: |
| 287 | cart_type = BBSB; |
| 288 | break; |
| 289 | case 21: |
| 290 | cart_type = A800_RIGHT_8K; |
| 291 | break; |
| 292 | case 39: |
| 293 | cart_type = PHOENIX_8K; |
| 294 | break; |
| 295 | case 4: |
| 296 | case 6: |
| 297 | case 7: |
| 298 | case 16: |
| 299 | case 19: |
| 300 | case 20: |
| 301 | fatalerror("Cart type \"%d\" means this is an Atari 5200 cart.\n", hdr_type); |
| 302 | break; |
| 303 | default: |
| 304 | mame_printf_info("Cart type \"%d\" is currently unsupported.\n", hdr_type); |
| 305 | break; |
| 306 | } |
| 257 | 307 | return cart_type; |
| 258 | 308 | } |
| 259 | 309 | |
| r10297 | r10298 | |
| 261 | 311 | { |
| 262 | 312 | UINT8 *mem = image.device().machine->region("maincpu")->base(); |
| 263 | 313 | const char *pcb_name; |
| 264 | | int cart_type = 0; |
| 314 | int cart_type = A800_UNKNOWN; |
| 265 | 315 | UINT32 size; |
| 266 | 316 | |
| 267 | 317 | if (image.software_entry() == NULL) |
| 268 | 318 | { |
| 269 | 319 | size = image.length(); |
| 270 | | // check if there is an header, if so extract cart_type from it (after a800_get_type, we point at the start of the data) |
| 320 | |
| 321 | // check if there is an header, if so extract cart_type from it, otherwise |
| 322 | // try to guess the cart_type from the file size (notice that after the |
| 323 | // a800_get_type call, we point at the start of the data) |
| 271 | 324 | if ((size % 0x1000) == 0x10) |
| 272 | 325 | cart_type = a800_get_type(image); |
| 273 | | //else check size to decide type (assuming base type of cart only!) |
| 326 | else if (size == 0x4000) |
| 327 | cart_type = A800_16K; |
| 328 | else if (size == 0x2000) |
| 329 | { |
| 330 | if (strcmp(image.device().tag(),"cart2") == 0) |
| 331 | cart_type = A800_RIGHT_8K; |
| 332 | else |
| 333 | cart_type = A800_8K; |
| 334 | } |
| 274 | 335 | } |
| 275 | 336 | else |
| 276 | 337 | { |
| 277 | 338 | size = image.get_software_region_length("rom"); |
| 278 | | if ((pcb_name = image.get_feature("cart_type")) == NULL) |
| 279 | | cart_type = A800_UNKNOWN; |
| 280 | | else |
| 339 | if ((pcb_name = image.get_feature("cart_type")) != NULL) |
| 281 | 340 | cart_type = a800_get_pcb_id(pcb_name); |
| 341 | |
| 282 | 342 | switch (cart_type) |
| 283 | 343 | { |
| 344 | case A800_UNKNOWN: |
| 284 | 345 | case A800_4K: |
| 346 | case A800_RIGHT_4K: |
| 347 | case A800_12K: |
| 285 | 348 | case A800_8K: |
| 286 | | case A800_12K: |
| 287 | 349 | case A800_16K: |
| 288 | | case A800_RIGHT_4K: |
| 289 | 350 | case A800_RIGHT_8K: |
| 290 | 351 | break; |
| 291 | 352 | default: |
| 292 | 353 | mame_printf_info("Cart type \"%s\" currently unsupported.\n", pcb_name); |
| 293 | 354 | break; |
| 294 | 355 | } |
| 295 | | a800_setup_mappers(image.device().machine, cart_type); |
| 296 | 356 | } |
| 297 | 357 | |
| 358 | a800_setup_mappers(image.device().machine, cart_type); |
| 359 | |
| 298 | 360 | /* load an optional (dual) cartridge (e.g. basic.rom) */ |
| 299 | | if( strcmp(image.device().tag(),"cart2") == 0 ) |
| 361 | if (strcmp(image.device().tag(),"cart2") == 0) |
| 300 | 362 | { |
| 301 | 363 | a800_cart_is_16k = (size >= 0x2000) ? 1 : 0; |
| 302 | 364 | |