src/mess/devices/aescart.c
| r0 | r4957 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | aescart.c |
| 4 | |
| 5 | Neo-Geo AES cartridge management |
| 6 | R. Belmont, 2009 |
| 7 | |
| 8 | Based on ti99cart.c by Michael Zapf |
| 9 | |
| 10 | We leave the support in place for multiple slots in case MAME |
| 11 | uses this at some future point for MVS multi-cart. |
| 12 | |
| 13 | *********************************************************************/ |
| 14 | #include "driver.h" |
| 15 | #include "aescart.h" |
| 16 | #include "cartslot.h" |
| 17 | #include "machine/ti99_4x.h" |
| 18 | #include "multcart.h" |
| 19 | |
| 20 | typedef int assmfct(running_machine *machine, const device_config *); |
| 21 | |
| 22 | enum |
| 23 | { |
| 24 | AESCART_FCT_ASSM = DEVINFO_FCT_DEVICE_SPECIFIC, |
| 25 | AESCART_FCT_DISASSM |
| 26 | }; |
| 27 | |
| 28 | struct _aes_multicart_t |
| 29 | { |
| 30 | /* Reserves space for all cartridges. This is also used in the legacy |
| 31 | cartridge system, but only for slot 0. */ |
| 32 | aescartridge_t cartridge[AES_NUMBER_OF_CARTRIDGE_SLOTS]; |
| 33 | |
| 34 | /* Determines which slot is currently active. This value is changed when there |
| 35 | are accesses to other GROM base addresses. */ |
| 36 | int active_slot; |
| 37 | |
| 38 | /* Used in order to enforce a special slot. This value is retrieved |
| 39 | from the dipswitch setting. A value of -1 means automatic, that is, |
| 40 | the grom base switch is used. Values 0 .. max refer to the |
| 41 | respective slot. */ |
| 42 | int fixed_slot; |
| 43 | |
| 44 | /* Holds the highest index of a cartridge being plugged in plus one. |
| 45 | If we only have one cartridge inserted, we don't want to get a |
| 46 | selection option, so we just mirror the memory contents. */ |
| 47 | int next_free_slot; |
| 48 | |
| 49 | /* Counts the number of slots which currently contain legacy format |
| 50 | cartridge images. */ |
| 51 | int legacy_slots; |
| 52 | |
| 53 | /* Counts the number of slots which currently contain new format |
| 54 | cartridge images. */ |
| 55 | int multi_slots; |
| 56 | }; |
| 57 | typedef struct _aes_multicart_t aes_multicart_t; |
| 58 | |
| 59 | #define AUTO -1 |
| 60 | |
| 61 | /* Access to the pcb. Contained in the token of the pcb instance. */ |
| 62 | struct _aes_pcb_t |
| 63 | { |
| 64 | /* Link up to the cartridge structure which contains this pcb. */ |
| 65 | aescartridge_t *cartridge; |
| 66 | |
| 67 | /* Function to assemble this cartridge. */ |
| 68 | assmfct *assemble; |
| 69 | |
| 70 | /* Function to disassemble this cartridge. */ |
| 71 | assmfct *disassemble; |
| 72 | }; |
| 73 | typedef struct _aes_pcb_t aes_pcb_t; |
| 74 | |
| 75 | /* |
| 76 | Find the index of the cartridge name. We assume the format |
| 77 | <name><number>, i.e. the number is the longest string from the right |
| 78 | which can be interpreted as a number. |
| 79 | */ |
| 80 | static int get_index_from_tagname(const device_config *image) |
| 81 | { |
| 82 | const char *tag = image->tag; |
| 83 | int maxlen = strlen(tag); |
| 84 | int i; |
| 85 | for (i=maxlen-1; i >=0; i--) |
| 86 | if (tag[i] < 48 || tag[i] > 57) break; |
| 87 | |
| 88 | return atoi(tag+i+1); |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | Common routine to assemble cartridges from resources. |
| 93 | */ |
| 94 | static aescartridge_t *assemble_common(running_machine *machine, const device_config *cartslot) |
| 95 | { |
| 96 | /* Pointer to the cartridge structure. */ |
| 97 | aescartridge_t *cartridge; |
| 98 | const device_config *cartsys = cartslot->owner; |
| 99 | aes_multicart_t *cartslots = (aes_multicart_t *)cartsys->token; |
| 100 | UINT8 *socketcont, *romrgn; |
| 101 | int reslength, i, blockofs; |
| 102 | char sprname1[16], sprname2[16]; |
| 103 | |
| 104 | int slotnumber = get_index_from_tagname(cartslot)-1; |
| 105 | assert(slotnumber>=0 && slotnumber<AES_NUMBER_OF_CARTRIDGE_SLOTS); |
| 106 | |
| 107 | /* There is a cartridge in this slot, check the maximum slot number. */ |
| 108 | if (cartslots->next_free_slot <= slotnumber) |
| 109 | { |
| 110 | cartslots->next_free_slot = slotnumber+1; |
| 111 | } |
| 112 | cartridge = &cartslots->cartridge[slotnumber]; |
| 113 | |
| 114 | // check for up to 4 program ROMs |
| 115 | romrgn = (UINT8 *)memory_region(machine, "maincpu"); |
| 116 | blockofs = 0; |
| 117 | for (i = 0; i < 4; i++) |
| 118 | { |
| 119 | sprintf(sprname1, "p%d", i+1); |
| 120 | |
| 121 | socketcont = cartslot_get_socket(cartslot, sprname1); |
| 122 | reslength = cartslot_get_resource_length(cartslot, sprname1); |
| 123 | |
| 124 | if (socketcont != NULL) |
| 125 | { |
| 126 | memcpy(romrgn+blockofs, socketcont, reslength); |
| 127 | blockofs += reslength; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // 1 m1 ROM |
| 132 | socketcont = cartslot_get_socket(cartslot, "m1"); |
| 133 | reslength = cartslot_get_resource_length(cartslot, "m1"); |
| 134 | if (socketcont != NULL) |
| 135 | { |
| 136 | romrgn = (UINT8 *)memory_region(machine, "audiocpu"); |
| 137 | |
| 138 | memcpy(romrgn, socketcont, reslength); |
| 139 | // mirror (how does this really work?) |
| 140 | memcpy(romrgn+0x10000, socketcont, reslength); |
| 141 | } |
| 142 | |
| 143 | // up to 8 YM sample ROMs |
| 144 | romrgn = (UINT8 *)memory_region(machine, "ym"); |
| 145 | blockofs = 0; |
| 146 | for (i = 0; i < 8; i++) |
| 147 | { |
| 148 | sprintf(sprname1, "v1%d", i+1); |
| 149 | |
| 150 | socketcont = cartslot_get_socket(cartslot, sprname1); |
| 151 | reslength = cartslot_get_resource_length(cartslot, sprname1); |
| 152 | |
| 153 | if (socketcont != NULL) |
| 154 | { |
| 155 | memcpy(romrgn+blockofs, socketcont, reslength); |
| 156 | blockofs += reslength; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // up to 8 YM delta-T sample ROMs |
| 161 | romrgn = (UINT8 *)memory_region(machine, "ym.deltat"); |
| 162 | blockofs = 0; |
| 163 | for (i = 0; i < 8; i++) |
| 164 | { |
| 165 | sprintf(sprname1, "v2%d", i+1); |
| 166 | |
| 167 | socketcont = cartslot_get_socket(cartslot, sprname1); |
| 168 | reslength = cartslot_get_resource_length(cartslot, sprname1); |
| 169 | |
| 170 | if (socketcont != NULL) |
| 171 | { |
| 172 | memcpy(romrgn+blockofs, socketcont, reslength); |
| 173 | blockofs += reslength; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // 1 s1 ROM |
| 178 | socketcont = cartslot_get_socket(cartslot, "s1"); |
| 179 | reslength = cartslot_get_resource_length(cartslot, "s1"); |
| 180 | if (socketcont != NULL) |
| 181 | { |
| 182 | romrgn = (UINT8 *)memory_region(machine, "fixed"); |
| 183 | |
| 184 | memcpy(romrgn, socketcont, reslength); |
| 185 | } |
| 186 | |
| 187 | // up to 8 sprite ROMs in byte-interleaved pairs |
| 188 | romrgn = (UINT8 *)memory_region(machine, "sprites"); |
| 189 | blockofs = 0; |
| 190 | for (i = 0; i < 8; i+=2) |
| 191 | { |
| 192 | UINT8 *spr1, *spr2; |
| 193 | int j; |
| 194 | |
| 195 | sprintf(sprname1, "c%d", i+1); |
| 196 | sprintf(sprname2, "c%d", i+2); |
| 197 | |
| 198 | spr1 = cartslot_get_socket(cartslot, sprname1); |
| 199 | spr2 = cartslot_get_socket(cartslot, sprname2); |
| 200 | reslength = cartslot_get_resource_length(cartslot, sprname1); |
| 201 | |
| 202 | if ((spr1) && (spr2)) |
| 203 | { |
| 204 | for (j = 0; j < reslength; j++) |
| 205 | { |
| 206 | romrgn[blockofs + (j*2)] = spr1[j]; |
| 207 | romrgn[blockofs + (j*2) + 1] = spr2[j]; |
| 208 | } |
| 209 | |
| 210 | blockofs += reslength*2; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | return cartridge; |
| 215 | } |
| 216 | |
| 217 | static void set_pointers(const device_config *pcb, int index) |
| 218 | { |
| 219 | const device_config *cartsys = pcb->owner->owner; |
| 220 | aes_multicart_t *cartslots = (aes_multicart_t *)cartsys->token; |
| 221 | aes_pcb_t *pcb_def = (aes_pcb_t *)pcb->token; |
| 222 | |
| 223 | pcb_def->assemble = (assmfct *)device_get_info_fct(pcb, AESCART_FCT_ASSM); |
| 224 | pcb_def->disassemble = (assmfct *)device_get_info_fct(pcb, AESCART_FCT_DISASSM); |
| 225 | |
| 226 | pcb_def->cartridge = &cartslots->cartridge[index]; |
| 227 | pcb_def->cartridge->pcb = pcb; |
| 228 | } |
| 229 | |
| 230 | /***************************************************************************** |
| 231 | Cartridge type: None |
| 232 | This PCB device is just a pseudo device; the legacy mode is handled |
| 233 | by dedicated functions. |
| 234 | ******************************************************************************/ |
| 235 | static DEVICE_START(aes_pcb_none) |
| 236 | { |
| 237 | /* device is aes_cartslot:cartridge:pcb */ |
| 238 | // printf("DEVICE_START(aes_pcb_none), tag of device=%s\n", device->tag); |
| 239 | set_pointers(device, get_index_from_tagname(device->owner)-1); |
| 240 | } |
| 241 | |
| 242 | /***************************************************************************** |
| 243 | Cartridge type: Standard |
| 244 | Most cartridges are built in this type. This includes word-swapped program, |
| 245 | z80 program, YM samples, delta-T samples, sprites, and sfix. |
| 246 | ******************************************************************************/ |
| 247 | |
| 248 | static DEVICE_START(aes_pcb_std) |
| 249 | { |
| 250 | /* device is aes_cartslot:cartridge:pcb */ |
| 251 | // printf("DEVICE_START(aes_pcb_std), tag of device=%s\n", device->tag); |
| 252 | set_pointers(device, get_index_from_tagname(device->owner)-1); |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | The standard cartridge assemble routine. We just call the common |
| 257 | function here. |
| 258 | */ |
| 259 | static int assemble_std(running_machine *machine, const device_config *image) |
| 260 | { |
| 261 | aescartridge_t *cart; |
| 262 | // printf("assemble_std, %s\n", image->tag); |
| 263 | cart = assemble_common(machine, image); |
| 264 | |
| 265 | return INIT_PASS; |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | Removes pointers and restores the state before plugging in the |
| 270 | cartridge. |
| 271 | The pointer to the location after the last cartridge is adjusted. |
| 272 | As it seems, we can use the same function for the disassembling of all |
| 273 | cartridge types. |
| 274 | */ |
| 275 | static int disassemble_std(const device_config *image) |
| 276 | { |
| 277 | int slotnumber; |
| 278 | // int i; |
| 279 | aescartridge_t *cart; |
| 280 | const device_config *cartsys = image->owner; |
| 281 | aes_multicart_t *cartslots = (aes_multicart_t *)cartsys->token; |
| 282 | |
| 283 | slotnumber = get_index_from_tagname(image)-1; |
| 284 | // printf("Disassemble cartridge %d\n", slotnumber); |
| 285 | #if 0 |
| 286 | /* Search the highest remaining cartridge. */ |
| 287 | cartslots->next_free_slot = 0; |
| 288 | for (i=AES_NUMBER_OF_CARTRIDGE_SLOTS-1; i >= 0; i--) |
| 289 | { |
| 290 | if (i != slotnumber) |
| 291 | { |
| 292 | if (0) //!slot_is_empty(cartsys, i)) (for future use?) |
| 293 | { |
| 294 | cartslots->next_free_slot = i+1; |
| 295 | // printf("Setting new next_free_slot to %d\n", cartslots->next_free_slot); |
| 296 | break; |
| 297 | } |
| 298 | } |
| 299 | } |
| 300 | #endif |
| 301 | /* Do we have RAM? If so, swap the bytes (undo the BIG_ENDIANIZE) */ |
| 302 | cart = &cartslots->cartridge[slotnumber]; |
| 303 | |
| 304 | // clear_slot(cartsys, slotnumber); |
| 305 | |
| 306 | return INIT_PASS; |
| 307 | } |
| 308 | |
| 309 | /***************************************************************************** |
| 310 | Device metadata |
| 311 | ******************************************************************************/ |
| 312 | |
| 313 | static DEVICE_GET_INFO(aes_cart_common) |
| 314 | { |
| 315 | switch(state) |
| 316 | { |
| 317 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 318 | case DEVINFO_INT_TOKEN_BYTES: |
| 319 | info->i = sizeof(aes_pcb_t); |
| 320 | break; |
| 321 | case DEVINFO_INT_INLINE_CONFIG_BYTES: |
| 322 | info->i = 0; |
| 323 | break; |
| 324 | case DEVINFO_INT_CLASS: |
| 325 | info->i = DEVICE_CLASS_PERIPHERAL; |
| 326 | break; |
| 327 | |
| 328 | /* --- the following bits of info are returned as pointers to functions --- */ |
| 329 | case DEVINFO_FCT_START: |
| 330 | info->start = DEVICE_START_NAME(aes_pcb_std); |
| 331 | break; |
| 332 | case DEVINFO_FCT_STOP: |
| 333 | /* Nothing */ |
| 334 | break; |
| 335 | case DEVINFO_FCT_RESET: |
| 336 | /* Nothing */ |
| 337 | break; |
| 338 | |
| 339 | case AESCART_FCT_ASSM: |
| 340 | info->f = (genf *) assemble_std; |
| 341 | break; |
| 342 | |
| 343 | case AESCART_FCT_DISASSM: |
| 344 | info->f = (genf *) disassemble_std; |
| 345 | break; |
| 346 | |
| 347 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 348 | case DEVINFO_STR_NAME: |
| 349 | strcpy(info->s, "AES standard cartridge pcb"); |
| 350 | break; |
| 351 | case DEVINFO_STR_FAMILY: |
| 352 | strcpy(info->s, "AES cartridge pcb"); |
| 353 | break; |
| 354 | case DEVINFO_STR_VERSION: |
| 355 | strcpy(info->s, "1.0"); |
| 356 | break; |
| 357 | case DEVINFO_STR_SOURCE_FILE: |
| 358 | strcpy(info->s, __FILE__); |
| 359 | break; |
| 360 | case DEVINFO_STR_CREDITS: |
| 361 | /* Nothing */ |
| 362 | break; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | DEVICE_GET_INFO(aes_cartridge_pcb_none) |
| 367 | { |
| 368 | switch(state) |
| 369 | { |
| 370 | case DEVINFO_FCT_START: |
| 371 | info->start = DEVICE_START_NAME(aes_pcb_none); |
| 372 | break; |
| 373 | |
| 374 | case DEVINFO_STR_NAME: |
| 375 | strcpy(info->s, "AES empty cartridge"); |
| 376 | break; |
| 377 | |
| 378 | default: |
| 379 | DEVICE_GET_INFO_CALL(aes_cart_common); |
| 380 | break; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | DEVICE_GET_INFO(aes_cartridge_pcb_std) |
| 385 | { |
| 386 | DEVICE_GET_INFO_CALL(aes_cart_common); |
| 387 | } |
| 388 | |
| 389 | /***************************************************************************** |
| 390 | The cartridge handling of the multi-cartridge system. |
| 391 | Every cartridge contains a PCB device. The memory handlers delegate the calls |
| 392 | to the respective handlers of the cartridges. |
| 393 | ******************************************************************************/ |
| 394 | /* |
| 395 | Initialize a cartridge. Each cartridge contains a PCB device. |
| 396 | */ |
| 397 | static DEVICE_START( aes_cartridge ) |
| 398 | { |
| 399 | cartslot_t *cart = device->token; |
| 400 | astring *tempstring = astring_alloc(); |
| 401 | |
| 402 | /* find the PCB device */ |
| 403 | cart->pcb_device = devtag_get_device( |
| 404 | device->machine, |
| 405 | device_build_tag(tempstring, device, TAG_PCB)); |
| 406 | astring_free(tempstring); |
| 407 | } |
| 408 | |
| 409 | /* |
| 410 | Load the cartridge image files. Apart from reading, we set pointers |
| 411 | to the image files so that during runtime we do not need search |
| 412 | operations. |
| 413 | */ |
| 414 | static DEVICE_IMAGE_LOAD( aes_cartridge ) |
| 415 | { |
| 416 | const device_config *pcbdev = cartslot_get_pcb(image); |
| 417 | int result; |
| 418 | |
| 419 | if (pcbdev != NULL) |
| 420 | { |
| 421 | /* If we are here, we have a multicart. */ |
| 422 | aes_pcb_t *pcb = (aes_pcb_t *)pcbdev->token; |
| 423 | cartslot_t *cart = (cartslot_t *)image->token; |
| 424 | |
| 425 | /* try opening this as a multicart */ |
| 426 | /* This line requires that cartslot_t be included in cartslot.h, |
| 427 | otherwise one cannot make use of multicart handling within such a |
| 428 | custom LOAD function. */ |
| 429 | multicart_open_error me = multicart_open(image_filename(image), image->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc); |
| 430 | |
| 431 | /* Now that we have loaded the image files, let the PCB put them all |
| 432 | together. This means we put the images in a structure which allows |
| 433 | for a quick access by the memory handlers. Every PCB defines an |
| 434 | own assembly method. */ |
| 435 | if (me == MCERR_NONE) |
| 436 | result = pcb->assemble(pcbdev->machine, image); |
| 437 | else |
| 438 | fatalerror("Error loading multicart: %s\n", mc_error_text(me)); |
| 439 | } |
| 440 | else |
| 441 | { |
| 442 | fatalerror("Error loading multicart: no pcb found.\n"); |
| 443 | } |
| 444 | return result; |
| 445 | } |
| 446 | |
| 447 | /* |
| 448 | This is called when the cartridge is unplugged (or the emulator is |
| 449 | stopped). |
| 450 | */ |
| 451 | static DEVICE_IMAGE_UNLOAD( aes_cartridge ) |
| 452 | { |
| 453 | const device_config *pcbdev; |
| 454 | |
| 455 | if (image->token == NULL) |
| 456 | { |
| 457 | /* This means something went wrong during the pcb |
| 458 | identification (e.g. one of the cartridge files was not |
| 459 | found). We do not need to (and cannot) unload |
| 460 | the cartridge. */ |
| 461 | return; |
| 462 | } |
| 463 | pcbdev = cartslot_get_pcb(image); |
| 464 | |
| 465 | if (pcbdev != NULL) |
| 466 | { |
| 467 | aes_pcb_t *pcb = (aes_pcb_t *)pcbdev->token; |
| 468 | cartslot_t *cart = (cartslot_t *)image->token; |
| 469 | |
| 470 | // printf("unload\n"); |
| 471 | if (cart->mc != NULL) |
| 472 | { |
| 473 | /* Remove pointers and de-big-endianize RAM contents. */ |
| 474 | pcb->disassemble(pcbdev->machine, image); |
| 475 | |
| 476 | /* Close the multicart; all RAM resources will be |
| 477 | written to disk */ |
| 478 | multicart_close(cart->mc); |
| 479 | cart->mc = NULL; |
| 480 | } |
| 481 | // else |
| 482 | // fatalerror("Lost pointer to multicart in cartridge. Report bug.\n"); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | /***************************************************************************** |
| 487 | The overall multi-cartridge slot system. It contains instances of |
| 488 | cartridges which contain PCB devices. The memory handlers delegate the calls |
| 489 | to the respective handlers of the cartridges. |
| 490 | |
| 491 | Note that the term "multi-cartridge system" and "multicart" are not the same: |
| 492 | A "multicart" may contain multiple resources, organized on a PCB. The multi- |
| 493 | cart system may thus host multiple multicarts. |
| 494 | |
| 495 | Actually, the name of the device should be changed (however, the device name |
| 496 | length is limited) |
| 497 | ******************************************************************************/ |
| 498 | /* |
| 499 | Instantiation of a multicart system for the Neo Geo AES. |
| 500 | */ |
| 501 | static DEVICE_START(aes_multicart) |
| 502 | { |
| 503 | int i; |
| 504 | // printf("DEVICE_START(aes_multicart)\n"); |
| 505 | aes_multicart_t *cartslots = (aes_multicart_t *)device->token; |
| 506 | |
| 507 | /* Save this in the shortcut; we don't want to look for it each time |
| 508 | that we have a memory access. And currently we do not plan for |
| 509 | multiple multicart instances. */ |
| 510 | cartslots->active_slot = 0; |
| 511 | cartslots->next_free_slot = 0; |
| 512 | |
| 513 | for (i=0; i < AES_NUMBER_OF_CARTRIDGE_SLOTS; i++) |
| 514 | { |
| 515 | cartslots->cartridge[i].pcb = NULL; |
| 516 | } |
| 517 | |
| 518 | cartslots->multi_slots = 0; |
| 519 | |
| 520 | /* The cartslot system is initialized now. The cartridges themselves |
| 521 | need to check whether their parts are available. */ |
| 522 | } |
| 523 | |
| 524 | static DEVICE_STOP(aes_multicart) |
| 525 | { |
| 526 | // printf("DEVICE_STOP(aes_multicart)\n"); |
| 527 | } |
| 528 | |
| 529 | static MACHINE_DRIVER_START(aes_multicart) |
| 530 | MDRV_CARTSLOT_ADD("cartridge1") |
| 531 | MDRV_CARTSLOT_EXTENSION_LIST("rpk,bin") |
| 532 | MDRV_CARTSLOT_PCBTYPE(0, "none", AES_CARTRIDGE_PCB_NONE) |
| 533 | MDRV_CARTSLOT_PCBTYPE(1, "standard", AES_CARTRIDGE_PCB_STD) |
| 534 | |
| 535 | MDRV_CARTSLOT_START(aes_cartridge) |
| 536 | MDRV_CARTSLOT_LOAD(aes_cartridge) |
| 537 | MDRV_CARTSLOT_UNLOAD(aes_cartridge) |
| 538 | MDRV_CARTSLOT_MANDATORY |
| 539 | MACHINE_DRIVER_END |
| 540 | |
| 541 | |
| 542 | DEVICE_GET_INFO(aes_multicart) |
| 543 | { |
| 544 | switch (state) |
| 545 | { |
| 546 | /* --- the following bits of info are returned as pointers to data --- */ |
| 547 | case DEVINFO_PTR_MACHINE_CONFIG: |
| 548 | info->machine_config = MACHINE_DRIVER_NAME(aes_multicart); break; |
| 549 | |
| 550 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 551 | case DEVINFO_STR_NAME: |
| 552 | strcpy(info->s, "AES Cartridge handler"); |
| 553 | break; |
| 554 | |
| 555 | case DEVINFO_INT_TOKEN_BYTES: /* private storage, automatically allocated */ |
| 556 | info->i = sizeof(aes_multicart_t); |
| 557 | break; |
| 558 | case DEVINFO_INT_CLASS: |
| 559 | info->i = DEVICE_CLASS_PERIPHERAL; |
| 560 | break; |
| 561 | |
| 562 | case DEVINFO_STR_FAMILY: |
| 563 | strcpy(info->s, "Cartridge slot"); |
| 564 | break; |
| 565 | case DEVINFO_STR_VERSION: |
| 566 | strcpy(info->s, "1.0"); |
| 567 | break; |
| 568 | case DEVINFO_STR_SOURCE_FILE: |
| 569 | strcpy(info->s, __FILE__); |
| 570 | break; |
| 571 | /* --- the following bits of info are returned as pointers to functions --- */ |
| 572 | case DEVINFO_FCT_START: |
| 573 | info->start = DEVICE_START_NAME(aes_multicart); |
| 574 | break; |
| 575 | case DEVINFO_FCT_STOP: |
| 576 | info->stop = DEVICE_STOP_NAME(aes_multicart); |
| 577 | break; |
| 578 | case DEVINFO_FCT_RESET: |
| 579 | /* Nothing */ |
| 580 | break; |
| 581 | } |
| 582 | } |
| 583 | |
src/mess/drivers/ng_aes.c
| r4956 | r4957 | |
| 17 | 17 | Andrew Prime |
| 18 | 18 | Zsolt Vasvari |
| 19 | 19 | |
| 20 | MESS cartridge support by R. Belmont based on work by Michael Zapf |
| 21 | |
| 20 | 22 | Current status: |
| 21 | | - There is no cart support, hence it's not possible to play anything. |
| 22 | | ATM, this is simply the MAME driver stripped of the LED code |
| 23 | - Cartridges run. |
| 23 | 24 | |
| 24 | 25 | ToDo : |
| 25 | 26 | - Change input code to allow selection of the mahjong panel in PORT_CATEGORY. |
| 26 | | - Add xml support for carts (the system is useless without) |
| 27 | 27 | - Clean up code, to reduce duplication of MAME source |
| 28 | 28 | |
| 29 | 29 | ****************************************************************************/ |
| r4956 | r4957 | |
| 34 | 34 | #include "machine/pd4990a.h" |
| 35 | 35 | #include "cpu/z80/z80.h" |
| 36 | 36 | #include "sound/2610intf.h" |
| 37 | #include "devices/aescart.h" |
| 37 | 38 | |
| 38 | 39 | |
| 39 | 40 | #define LOG_VIDEO_SYSTEM (0) |
| r4956 | r4957 | |
| 778 | 779 | } |
| 779 | 780 | } |
| 780 | 781 | |
| 781 | | |
| 782 | | |
| 783 | 782 | /************************************* |
| 784 | 783 | * |
| 785 | | * Watchdog |
| 786 | | * |
| 787 | | * |
| 788 | | * - The watchdog timer will reset the system after ~0.13 seconds |
| 789 | | * On an MV-1F MVS system, the following code was used to test: |
| 790 | | * 000100 203C 0001 4F51 MOVE.L #0x14F51,D0 |
| 791 | | * 000106 13C0 0030 0001 MOVE.B D0,0x300001 |
| 792 | | * 00010C 5380 SUBQ.L #1,D0 |
| 793 | | * 00010E 64FC BCC.S *-0x2 [0x10C] |
| 794 | | * 000110 13C0 0030 0001 MOVE.B D0,0x300001 |
| 795 | | * 000116 60F8 BRA.S *-0x6 [0x110] |
| 796 | | * This code loops long enough to sometimes cause a reset, sometimes not. |
| 797 | | * The move takes 16 cycles, subq 8, bcc 10 if taken and 8 if not taken, so: |
| 798 | | * (0x14F51 * 18 + 14) cycles / 12000000 cycles per second = 0.128762 seconds |
| 799 | | * Newer games force a reset using the following code (this from kof99): |
| 800 | | * 009CDA 203C 0003 0D40 MOVE.L #0x30D40,D0 |
| 801 | | * 009CE0 5380 SUBQ.L #1,D0 |
| 802 | | * 009CE2 64FC BCC.S *-0x2 [0x9CE0] |
| 803 | | * Note however that there is a valid code path after this loop. |
| 804 | | * |
| 805 | | * The watchdog is used as a form of protecetion on a number of games, |
| 806 | | * previously this was implemented as a specific hack which locked a single |
| 807 | | * address of SRAM. |
| 808 | | * |
| 809 | | * What actually happens is if the game doesn't find valid data in the |
| 810 | | * backup ram it will initialize it, then sit in a loop. The watchdog |
| 811 | | * should then reset the system while it is in this loop. If the watchdog |
| 812 | | * fails to reset the system the code will continue and set a value in |
| 813 | | * backup ram to indiate that the protection check has failed. |
| 814 | | * |
| 815 | | *************************************/ |
| 816 | | |
| 817 | | static WRITE16_HANDLER( watchdog_w ) |
| 818 | | { |
| 819 | | /* only an LSB write resets the watchdog */ |
| 820 | | if (ACCESSING_BITS_0_7) |
| 821 | | { |
| 822 | | watchdog_reset16_w(space, offset, data, mem_mask); |
| 823 | | } |
| 824 | | } |
| 825 | | |
| 826 | | |
| 827 | | |
| 828 | | /************************************* |
| 829 | | * |
| 830 | 784 | * Machine initialization |
| 831 | 785 | * |
| 832 | 786 | *************************************/ |
| r4956 | r4957 | |
| 907 | 861 | |
| 908 | 862 | /* trigger the IRQ3 that was set by MACHINE_START */ |
| 909 | 863 | update_interrupts(machine); |
| 864 | |
| 865 | /* AES apparently always uses the cartridge's fixed bank mode */ |
| 866 | neogeo_set_fixed_layer_source(1); |
| 910 | 867 | } |
| 911 | 868 | |
| 912 | 869 | |
| r4956 | r4957 | |
| 926 | 883 | AM_RANGE(0x2ffff0, 0x2fffff) AM_WRITE(main_cpu_bank_select_w) |
| 927 | 884 | AM_RANGE(0x300000, 0x300001) AM_MIRROR(0x01ff7e) AM_READ_PORT("IN0") |
| 928 | 885 | AM_RANGE(0x300080, 0x300081) AM_MIRROR(0x01ff7e) AM_READ_PORT("IN4") |
| 929 | | AM_RANGE(0x300000, 0x300001) AM_MIRROR(0x01ffe0) AM_READWRITE(neogeo_unmapped_r, watchdog_w) |
| 886 | AM_RANGE(0x300000, 0x300001) AM_MIRROR(0x01ffe0) AM_READ(neogeo_unmapped_r) AM_WRITENOP // AES has no watchdog |
| 930 | 887 | AM_RANGE(0x320000, 0x320001) AM_MIRROR(0x01fffe) AM_READ_PORT("IN3") AM_WRITE(audio_command_w) |
| 931 | 888 | AM_RANGE(0x340000, 0x340001) AM_MIRROR(0x01fffe) AM_READ_PORT("IN1") |
| 932 | 889 | AM_RANGE(0x360000, 0x37ffff) AM_READ(neogeo_unmapped_r) |
| r4956 | r4957 | |
| 1247 | 1204 | MDRV_CPU_PROGRAM_MAP(audio_map) |
| 1248 | 1205 | MDRV_CPU_IO_MAP(auido_io_map) |
| 1249 | 1206 | |
| 1250 | | MDRV_WATCHDOG_TIME_INIT(USEC(128762)) |
| 1251 | | |
| 1252 | 1207 | MDRV_MACHINE_START(neogeo) |
| 1253 | 1208 | MDRV_MACHINE_RESET(neogeo) |
| 1254 | 1209 | MDRV_NVRAM_HANDLER(neogeo) |
| r4956 | r4957 | |
| 1276 | 1231 | /* NEC uPD4990A RTC */ |
| 1277 | 1232 | MDRV_UPD4990A_ADD("upd4990a") |
| 1278 | 1233 | |
| 1279 | | // MDRV_AES_CARTRIDGE_ADD("aes_multicart") |
| 1234 | MDRV_AES_CARTRIDGE_ADD("aes_multicart") |
| 1280 | 1235 | MACHINE_DRIVER_END |
| 1281 | 1236 | |
| 1282 | 1237 | /************************************* |
| 1283 | 1238 | * |
| 1284 | 1239 | * Driver initalization |
| 1285 | 1240 | * |
| 1286 | | *************************************/ |
| 1241 | *************************************/ |
| 1287 | 1242 | |
| 1288 | 1243 | static DRIVER_INIT( neogeo ) |
| 1289 | 1244 | { |
| r4956 | r4957 | |
| 1296 | 1251 | ROMX_LOAD("neo-po.bin", 0x00000, 0x020000, CRC(16d0c132) SHA1(4e4a440cae46f3889d20234aebd7f8d5f522e22c), ROM_GROUPWORD | ROM_REVERSE | ROM_BIOS(1)) /* AES Console (Japan) Bios */ |
| 1297 | 1252 | ROM_SYSTEM_BIOS( 1, "asia-aes", "Asia AES" ) |
| 1298 | 1253 | ROMX_LOAD("neo-epo.bin", 0x00000, 0x020000, CRC(d27a71f1) SHA1(1b3b22092f30c4d1b2c15f04d1670eb1e9fbea07), ROM_GROUPWORD | ROM_REVERSE | ROM_BIOS(2)) /* AES Console (Asia?) Bios */ |
| 1299 | | #if 0 |
| 1300 | | ROM_SYSTEM_BIOS( 2, "uni-bios_2_3","Universe Bios (Hack, Ver. 2.3)" ) |
| 1301 | | ROMX_LOAD("uni-bios_2_3.rom", 0x00000, 0x020000, CRC(27664eb5) SHA1(5b02900a3ccf3df168bdcfc98458136fd2b92ac0), ROM_GROUPWORD | ROM_REVERSE | ROM_BIOS(3)) /* Universe Bios v2.3 (hack) */ |
| 1302 | | #endif |
| 1303 | 1254 | |
| 1304 | | ROM_REGION( 0x100000, "maincpu", ROMREGION_ERASEFF ) |
| 1255 | ROM_REGION( 0x200000, "maincpu", ROMREGION_ERASEFF ) |
| 1305 | 1256 | |
| 1306 | 1257 | ROM_REGION( 0x20000, "audiobios", 0 ) |
| 1307 | 1258 | ROM_LOAD( "sm1.sm1", 0x00000, 0x20000, CRC(94416d67) SHA1(42f9d7ddd6c0931fd64226a60dc73602b2819dcf) ) |
| 1308 | 1259 | |
| 1309 | | ROM_REGION( 0x50000, "audiocpu", ROMREGION_ERASEFF ) |
| 1260 | ROM_REGION( 0x90000, "audiocpu", ROMREGION_ERASEFF ) |
| 1310 | 1261 | |
| 1311 | 1262 | ROM_REGION( 0x20000, "zoomy", 0 ) |
| 1312 | 1263 | ROM_LOAD( "000-lo.lo", 0x00000, 0x20000, CRC(5a86cff2) SHA1(5992277debadeb64d1c1c64b0a92d9293eaf7e4a) ) |
| r4956 | r4957 | |
| 1316 | 1267 | |
| 1317 | 1268 | ROM_REGION( 0x20000, "fixed", ROMREGION_ERASEFF ) |
| 1318 | 1269 | |
| 1319 | | ROM_REGION( 0x10000, "ym", ROMREGION_ERASEFF ) |
| 1270 | ROM_REGION( 0x400000, "ym", ROMREGION_ERASEFF ) |
| 1320 | 1271 | |
| 1321 | | // NO_DELTAT_REGION |
| 1272 | ROM_REGION( 0x200000, "ym.deltat", ROMREGION_ERASEFF ) |
| 1322 | 1273 | |
| 1323 | | ROM_REGION( 0x100000, "sprites", ROMREGION_DISPOSE | ROMREGION_ERASEFF ) |
| 1274 | ROM_REGION( 0x900000, "sprites", ROMREGION_ERASEFF ) |
| 1324 | 1275 | ROM_END |
| 1325 | 1276 | |
| 1326 | 1277 | ROM_START( neocd ) |
| r4956 | r4957 | |
| 1372 | 1323 | ROM_END |
| 1373 | 1324 | |
| 1374 | 1325 | |
| 1375 | | CONS( 1990, aes, 0, 0, neogeo, aes, neogeo, 0, "SNK", "Neo-Geo AES", GAME_NOT_WORKING ) |
| 1326 | CONS( 1990, aes, 0, 0, neogeo, aes, neogeo, 0, "SNK", "Neo-Geo AES", 0) |
| 1376 | 1327 | CONS( 1994, neocd, aes, 0, neogeo, aes, neogeo, 0, "SNK", "Neo-Geo CD", GAME_NOT_WORKING ) |
| 1377 | 1328 | CONS( 1996, neocdz, aes, 0, neogeo, aes, neogeo, 0, "SNK", "Neo-Geo CDZ", GAME_NOT_WORKING ) |