src/mess/drivers/genesis.c
| r2170 | r2171 | |
| 244 | 244 | is_ssf2 = 1; |
| 245 | 245 | } |
| 246 | 246 | // detect the 'Romance of the Three Kingdoms - Red Cliff' rom, already decoded from useless .mdx format |
| 247 | | if (length == 0x200000) { |
| 247 | if (length == 0x200000) |
| 248 | { |
| 248 | 249 | static unsigned char redcliffsig[] = { 0x10, 0x39, 0x00, 0x40, 0x00, 0x04}; // move.b ($400004).l,d0 |
| 249 | | if (!memcmp(&ROM[0xce560+relocate],&redcliffsig[0],sizeof(redcliffsig))) { |
| 250 | if (!memcmp(&ROM[0xce560+relocate],&redcliffsig[0],sizeof(redcliffsig))) |
| 251 | { |
| 250 | 252 | is_redcliff = 1; |
| 251 | 253 | } |
| 252 | 254 | } |
| r2170 | r2171 | |
| 276 | 278 | } |
| 277 | 279 | |
| 278 | 280 | /* check if cart has battery save */ |
| 281 | genesis_sram_len = 0; |
| 282 | genesis_sram = NULL; |
| 279 | 283 | if (ROM[0x1b1] == 'R' && ROM[0x1b0] == 'A') |
| 280 | 284 | { |
| 281 | 285 | genesis_sram_start = (ROM[0x1b5] << 24 | ROM[0x1b4] << 16 | ROM[0x1b7] << 8 | ROM[0x1b6]); |
| r2170 | r2171 | |
| 291 | 295 | genesis_sram_len -= (genesis_sram_start - 1); |
| 292 | 296 | genesis_sram = auto_malloc (genesis_sram_len); |
| 293 | 297 | memset(genesis_sram, 0, genesis_sram_len); |
| 294 | | printf("Attempting to load SRM . . .\n"); |
| 295 | | image_battery_load(image, genesis_sram, genesis_sram_len); |
| 298 | image_battery_load(image_from_devtype_and_index(IO_CARTSLOT,0), genesis_sram, genesis_sram_len); |
| 296 | 299 | |
| 297 | 300 | if (length - 0x200 < genesis_sram_start) |
| 301 | { |
| 298 | 302 | genesis_sram_active = 1; |
| 303 | } |
| 299 | 304 | |
| 300 | 305 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, genesis_sram_start & 0x3fffff, (genesis_sram_start + genesis_sram_len - 1) & 0x3fffff, 0, 0, genesis_sram_read); |
| 301 | 306 | |
| r2170 | r2171 | |
| 331 | 336 | ROM_REGION( 0x10000, REGION_CPU2, ROMREGION_ERASEFF) |
| 332 | 337 | ROM_END |
| 333 | 338 | |
| 339 | static DEVICE_UNLOAD( genesis_cart ) |
| 340 | { |
| 341 | /* Write out the battery file if necessary */ |
| 342 | if ((genesis_sram != NULL) && (genesis_sram_len > 0)) |
| 343 | { |
| 344 | image_battery_save(image_from_devtype_and_index(IO_CARTSLOT, 0), genesis_sram, genesis_sram_len); |
| 345 | } |
| 346 | } |
| 347 | |
| 334 | 348 | static void genesis_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 335 | 349 | { |
| 336 | 350 | /* cartslot */ |
| r2170 | r2171 | |
| 342 | 356 | |
| 343 | 357 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 344 | 358 | case MESS_DEVINFO_PTR_LOAD: info->load = device_load_genesis_cart; break; |
| 345 | | case MESS_DEVINFO_PTR_PARTIAL_HASH: info->partialhash = NULL; /*genesis_partialhash*/ break; |
| 359 | case MESS_DEVINFO_PTR_PARTIAL_HASH: info->partialhash = NULL; |
| 360 | case MESS_DEVINFO_PTR_UNLOAD: info->unload = device_unload_genesis_cart; break; |
| 346 | 361 | |
| 347 | 362 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 348 | 363 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "smd,bin,md,gen"); break; |
| r2170 | r2171 | |
| 407 | 422 | |
| 408 | 423 | static void genesis_machine_stop(running_machine *machine) |
| 409 | 424 | { |
| 410 | | /* Write out the battery file if necessary */ |
| 411 | | if ((genesis_sram != NULL) && (genesis_sram_len > 0)) |
| 412 | | image_battery_save(image_from_devtype_and_index(IO_CARTSLOT, 0), genesis_sram, genesis_sram_len); |
| 413 | 425 | } |
| 414 | 426 | |
| 415 | 427 | |
| 416 | 428 | static DRIVER_INIT( gencommon ) |
| 417 | 429 | { |
| 418 | | genesis_sram_len = 0; |
| 419 | | |
| 420 | 430 | if (genesis_sram) |
| 421 | 431 | { |
| 422 | 432 | add_exit_callback(machine, genesis_machine_stop); |
| r2170 | r2171 | |
| 426 | 436 | { |
| 427 | 437 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0xA130F0, 0xA130FF, 0, 0, genesis_ssf2_bank_w); |
| 428 | 438 | } |
| 429 | | if (is_redcliff) { |
| 439 | |
| 440 | if (is_redcliff) |
| 441 | { |
| 430 | 442 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x400000, 0x400001, 0, 0, redclif_prot2_r ); |
| 431 | 443 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x400004, 0x400005, 0, 0, redclif_prot_r ); |
| 432 | 444 | } |
| 433 | 445 | |
| 434 | 446 | /* install NOP handler for TMSS */ |
| 435 | | |
| 436 | 447 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0xA14000, 0xA14003, 0, 0, genesis_TMSS_bank_w); |
| 437 | 448 | |
| 438 | 449 | } |