trunk/src/emu/clifront.c
| r245621 | r245622 | |
| 153 | 153 | val.printf("%s:%s:%s", swlistdev->list_name(), m_options.software_name(), swpart->name()); |
| 154 | 154 | |
| 155 | 155 | // call this in order to set slot devices according to mounting |
| 156 | | m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.c_str()); |
| 156 | m_options.parse_slot_devices(argc, argv, option_errors, image->instance_name(), val.cstr()); |
| 157 | 157 | break; |
| 158 | 158 | } |
| 159 | 159 | } |
| r245621 | r245622 | |
| 184 | 184 | throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "Unknown system '%s'", m_options.system_name()); |
| 185 | 185 | |
| 186 | 186 | // otherwise, error on the options |
| 187 | | throw emu_fatalerror(MAMERR_INVALID_CONFIG, "%s", option_errors.trimspace().c_str()); |
| 187 | throw emu_fatalerror(MAMERR_INVALID_CONFIG, "%s", option_errors.trimspace().cstr()); |
| 188 | 188 | } |
| 189 | 189 | if (option_errors) |
| 190 | | osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().c_str()); |
| 190 | osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().cstr()); |
| 191 | 191 | |
| 192 | 192 | // determine the base name of the EXE |
| 193 | 193 | astring exename; |
| r245621 | r245622 | |
| 208 | 208 | m_options.parse_standard_inis(option_errors); |
| 209 | 209 | } |
| 210 | 210 | if (option_errors) |
| 211 | | osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().c_str()); |
| 211 | osd_printf_error("Error in command line:\n%s\n", option_errors.trimspace().cstr()); |
| 212 | 212 | |
| 213 | 213 | // if we can't find it, give an appropriate error |
| 214 | 214 | const game_driver *system = m_options.system(); |
| r245621 | r245622 | |
| 226 | 226 | catch (emu_fatalerror &fatal) |
| 227 | 227 | { |
| 228 | 228 | astring string(fatal.string()); |
| 229 | | osd_printf_error("%s\n", string.trimspace().c_str()); |
| 229 | osd_printf_error("%s\n", string.trimspace().cstr()); |
| 230 | 230 | m_result = (fatal.exitcode() != 0) ? fatal.exitcode() : MAMERR_FATALERROR; |
| 231 | 231 | |
| 232 | 232 | // if a game was specified, wasn't a wildcard, and our error indicates this was the |
| r245621 | r245622 | |
| 328 | 328 | // iterate through drivers and output the info |
| 329 | 329 | astring filename; |
| 330 | 330 | while (drivlist.next()) |
| 331 | | osd_printf_info("%-16s %s\n", drivlist.driver().name, core_filename_extract_base(filename, drivlist.driver().source_file).c_str()); |
| 331 | osd_printf_info("%-16s %s\n", drivlist.driver().name, core_filename_extract_base(filename, drivlist.driver().source_file).cstr()); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
| r245621 | r245622 | |
| 418 | 418 | while (drivlist.next()) |
| 419 | 419 | { |
| 420 | 420 | int clone_of = drivlist.clone(); |
| 421 | | osd_printf_info("%-16s %-16s %-16s\n", core_filename_extract_base(filename, drivlist.driver().source_file).c_str(), drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name)); |
| 421 | osd_printf_info("%-16s %-16s %-16s\n", core_filename_extract_base(filename, drivlist.driver().source_file).cstr(), drivlist.driver().name, (clone_of == -1 ? "" : drivlist.driver(clone_of).name)); |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| r245621 | r245622 | |
| 726 | 726 | paren_shortname.format("(%s)", imagedev->brief_instance_name()); |
| 727 | 727 | |
| 728 | 728 | // output the line, up to the list of extensions |
| 729 | | printf("%-13s%-12s%-8s ", first ? drivlist.driver().name : "", imagedev->instance_name(), paren_shortname.c_str()); |
| 729 | printf("%-13s%-12s%-8s ", first ? drivlist.driver().name : "", imagedev->instance_name(), paren_shortname.cstr()); |
| 730 | 730 | |
| 731 | 731 | // get the extensions and print them |
| 732 | 732 | astring extensions(imagedev->file_extensions()); |
| 733 | 733 | for (int start = 0, end = extensions.chr(0, ','); ; start = end + 1, end = extensions.chr(start, ',')) |
| 734 | 734 | { |
| 735 | 735 | astring curext(extensions, start, (end == -1) ? extensions.len() - start : end - start); |
| 736 | | printf(".%-5s", curext.c_str()); |
| 736 | printf(".%-5s", curext.cstr()); |
| 737 | 737 | if (end == -1) |
| 738 | 738 | break; |
| 739 | 739 | } |
| r245621 | r245622 | |
| 782 | 782 | // output the summary of the audit |
| 783 | 783 | astring summary_string; |
| 784 | 784 | auditor.summarize(drivlist.driver().name,&summary_string); |
| 785 | | osd_printf_info("%s", summary_string.c_str()); |
| 785 | osd_printf_info("%s", summary_string.cstr()); |
| 786 | 786 | |
| 787 | 787 | // output the name of the driver and its clone |
| 788 | 788 | osd_printf_info("romset %s ", drivlist.driver().name); |
| r245621 | r245622 | |
| 842 | 842 | // output the summary of the audit |
| 843 | 843 | astring summary_string; |
| 844 | 844 | auditor.summarize(dev->shortname(),&summary_string); |
| 845 | | osd_printf_info("%s", summary_string.c_str()); |
| 845 | osd_printf_info("%s", summary_string.cstr()); |
| 846 | 846 | |
| 847 | 847 | // display information about what we discovered |
| 848 | 848 | osd_printf_info("romset %s ", dev->shortname()); |
| r245621 | r245622 | |
| 880 | 880 | { |
| 881 | 881 | astring temptag("_"); |
| 882 | 882 | temptag.cat(option->name()); |
| 883 | | device_t *dev = const_cast<machine_config &>(config).device_add(&config.root_device(), temptag.c_str(), option->devtype(), 0); |
| 883 | device_t *dev = const_cast<machine_config &>(config).device_add(&config.root_device(), temptag.cstr(), option->devtype(), 0); |
| 884 | 884 | |
| 885 | 885 | // notify this device and all its subdevices that they are now configured |
| 886 | 886 | device_iterator subiter(*dev); |
| r245621 | r245622 | |
| 907 | 907 | // output the summary of the audit |
| 908 | 908 | astring summary_string; |
| 909 | 909 | auditor.summarize(dev->shortname(),&summary_string); |
| 910 | | osd_printf_info("%s", summary_string.c_str()); |
| 910 | osd_printf_info("%s", summary_string.cstr()); |
| 911 | 911 | |
| 912 | 912 | // display information about what we discovered |
| 913 | 913 | osd_printf_info("romset %s ", dev->shortname()); |
| r245621 | r245622 | |
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | | const_cast<machine_config &>(config).device_remove(&config.root_device(), temptag.c_str()); |
| 941 | const_cast<machine_config &>(config).device_remove(&config.root_device(), temptag.cstr()); |
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | } |
| r245621 | r245622 | |
| 1004 | 1004 | // output the summary of the audit |
| 1005 | 1005 | astring summary_string; |
| 1006 | 1006 | auditor.summarize(drivlist.driver().name,&summary_string); |
| 1007 | | osd_printf_info("%s", summary_string.c_str()); |
| 1007 | osd_printf_info("%s", summary_string.cstr()); |
| 1008 | 1008 | |
| 1009 | 1009 | // output the name of the driver and its clone |
| 1010 | 1010 | osd_printf_info("sampleset %s ", drivlist.driver().name); |
| r245621 | r245622 | |
| 1322 | 1322 | // output the summary of the audit |
| 1323 | 1323 | astring summary_string; |
| 1324 | 1324 | auditor.summarize(swinfo->shortname(), &summary_string); |
| 1325 | | osd_printf_info("%s", summary_string.c_str()); |
| 1325 | osd_printf_info("%s", summary_string.cstr()); |
| 1326 | 1326 | |
| 1327 | 1327 | // display information about what we discovered |
| 1328 | 1328 | osd_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo->shortname()); |
| r245621 | r245622 | |
| 1444 | 1444 | // output the summary of the audit |
| 1445 | 1445 | astring summary_string; |
| 1446 | 1446 | auditor.summarize(swinfo->shortname(), &summary_string); |
| 1447 | | osd_printf_info("%s", summary_string.c_str()); |
| 1447 | osd_printf_info("%s", summary_string.cstr()); |
| 1448 | 1448 | |
| 1449 | 1449 | // display information about what we discovered |
| 1450 | 1450 | osd_printf_info("romset %s:%s ", swlistdev->list_name(), swinfo->shortname()); |
| r245621 | r245622 | |
| 1556 | 1556 | astring option_errors; |
| 1557 | 1557 | m_options.parse_standard_inis(option_errors); |
| 1558 | 1558 | if (option_errors) |
| 1559 | | osd_printf_error("%s\n", option_errors.c_str()); |
| 1559 | osd_printf_error("%s\n", option_errors.cstr()); |
| 1560 | 1560 | |
| 1561 | 1561 | // createconfig? |
| 1562 | 1562 | if (strcmp(m_options.command(), CLICOMMAND_CREATECONFIG) == 0) |
| r245621 | r245622 | |
| 1779 | 1779 | { |
| 1780 | 1780 | // output the name |
| 1781 | 1781 | astring basename; |
| 1782 | | osd_printf_info("%-20s", core_filename_extract_base(basename, name).c_str()); |
| 1782 | osd_printf_info("%-20s", core_filename_extract_base(basename, name).cstr()); |
| 1783 | 1783 | m_total++; |
| 1784 | 1784 | |
| 1785 | 1785 | // attempt to open as a CHD; fail if not |
| r245621 | r245622 | |
| 1855 | 1855 | // output the name |
| 1856 | 1856 | m_total++; |
| 1857 | 1857 | astring basename; |
| 1858 | | osd_printf_info("%-20s", core_filename_extract_base(basename, name).c_str()); |
| 1858 | osd_printf_info("%-20s", core_filename_extract_base(basename, name).cstr()); |
| 1859 | 1859 | |
| 1860 | 1860 | // see if we can find a match in the ROMs |
| 1861 | 1861 | int found = find_by_hash(hashes, length); |
trunk/src/emu/cpu/dsp16/dsp16dis.c
| r245621 | r245622 | |
| 270 | 270 | const UINT8 F1 = (op & 0x01e0) >> 5; |
| 271 | 271 | astring yString = disasmYField(Y); |
| 272 | 272 | astring fString = disasmF1Field(F1, D, S); |
| 273 | | sprintf(buffer, "%s, %s", fString.c_str(), yString.c_str()); |
| 273 | sprintf(buffer, "%s, %s", fString.cstr(), yString.cstr()); |
| 274 | 274 | break; |
| 275 | 275 | } |
| 276 | 276 | case 0x04: case 0x1c: |
| r245621 | r245622 | |
| 285 | 285 | astring fString = disasmF1Field(F1, D, S); |
| 286 | 286 | astring aString = (opcode == 0x1c) ? "a0" : "a1"; |
| 287 | 287 | astring xString = (X) ? "" : "l"; |
| 288 | | sprintf(buffer, "%s = %s%s, %s", yString.c_str(), aString.c_str(), xString.c_str(), fString.c_str()); |
| 288 | sprintf(buffer, "%s = %s%s, %s", yString.cstr(), aString.cstr(), xString.cstr(), fString.cstr()); |
| 289 | 289 | break; |
| 290 | 290 | } |
| 291 | 291 | case 0x16: |
| r245621 | r245622 | |
| 297 | 297 | const UINT8 F1 = (op & 0x01e0) >> 5; |
| 298 | 298 | astring yString = disasmYField(Y); |
| 299 | 299 | astring fString = disasmF1Field(F1, D, S); |
| 300 | | sprintf(buffer, "%s, x = %s", fString.c_str(), yString.c_str()); |
| 300 | sprintf(buffer, "%s, x = %s", fString.cstr(), yString.cstr()); |
| 301 | 301 | break; |
| 302 | 302 | } |
| 303 | 303 | case 0x17: |
| r245621 | r245622 | |
| 311 | 311 | astring yString = disasmYField(Y); |
| 312 | 312 | astring fString = disasmF1Field(F1, D, S); |
| 313 | 313 | astring xString = (X ? "y" : "y1"); |
| 314 | | sprintf(buffer, "%s, %s = %s", fString.c_str(), xString.c_str(), yString.c_str()); |
| 314 | sprintf(buffer, "%s, %s = %s", fString.cstr(), xString.cstr(), yString.cstr()); |
| 315 | 315 | break; |
| 316 | 316 | } |
| 317 | 317 | case 0x1f: |
| r245621 | r245622 | |
| 325 | 325 | astring yString = disasmYField(Y); |
| 326 | 326 | astring fString = disasmF1Field(F1, D, S); |
| 327 | 327 | astring xString = (X ? "*pt++i" : "*pt++"); |
| 328 | | sprintf(buffer, "%s, y = %s, x = %s", fString.c_str(), yString.c_str(), xString.c_str()); |
| 328 | sprintf(buffer, "%s, y = %s, x = %s", fString.cstr(), yString.cstr(), xString.cstr()); |
| 329 | 329 | break; |
| 330 | 330 | } |
| 331 | 331 | case 0x19: case 0x1b: |
| r245621 | r245622 | |
| 339 | 339 | astring fString = disasmF1Field(F1, D, S); |
| 340 | 340 | astring xString = (X ? "*pt++i" : "*pt++"); |
| 341 | 341 | astring aString = (opcode == 0x19) ? "a0" : "a1"; |
| 342 | | sprintf(buffer, "%s, y = %s, x = %s", fString.c_str(), aString.c_str(), xString.c_str()); |
| 342 | sprintf(buffer, "%s, y = %s, x = %s", fString.cstr(), aString.cstr(), xString.cstr()); |
| 343 | 343 | if (Y != 0x00) sprintf(buffer, "UNKNOWN"); |
| 344 | 344 | break; |
| 345 | 345 | } |
| r245621 | r245622 | |
| 354 | 354 | astring yString = disasmYField(Y); |
| 355 | 355 | astring xString = (X ? "y" : "y1"); |
| 356 | 356 | astring fString = disasmF1Field(F1, D, S); |
| 357 | | sprintf(buffer, "%s, %s = %s", fString.c_str(), yString.c_str(), xString.c_str()); |
| 357 | sprintf(buffer, "%s, %s = %s", fString.cstr(), yString.cstr(), xString.cstr()); |
| 358 | 358 | break; |
| 359 | 359 | } |
| 360 | 360 | |
| r245621 | r245622 | |
| 369 | 369 | astring yString = disasmYField(Y); |
| 370 | 370 | astring atString = (aT ? "a0" : "a1"); |
| 371 | 371 | astring fString = disasmF1Field(F1, aT, S); |
| 372 | | sprintf(buffer, "%s, %s = %s", fString.c_str(), atString.c_str(), yString.c_str()); |
| 372 | sprintf(buffer, "%s, %s = %s", fString.cstr(), atString.cstr(), yString.cstr()); |
| 373 | 373 | break; |
| 374 | 374 | } |
| 375 | 375 | |
| r245621 | r245622 | |
| 385 | 385 | astring zString = disasmZField(Z); |
| 386 | 386 | astring xString = (X ? "y" : "y1"); |
| 387 | 387 | astring fString = disasmF1Field(F1, D, S); |
| 388 | | sprintf(buffer, "%s, %s <=> %s", fString.c_str(), xString.c_str(), zString.c_str()); |
| 388 | sprintf(buffer, "%s, %s <=> %s", fString.cstr(), xString.cstr(), zString.cstr()); |
| 389 | 389 | break; |
| 390 | 390 | } |
| 391 | 391 | case 0x1d: |
| r245621 | r245622 | |
| 399 | 399 | astring zString = disasmZField(Z); |
| 400 | 400 | astring xString = (X ? "*pt++i" : "*pt++"); |
| 401 | 401 | astring fString = disasmF1Field(F1, D, S); |
| 402 | | sprintf(buffer, "%s, %s <=> y, x = %s", fString.c_str(), zString.c_str(), xString.c_str()); |
| 402 | sprintf(buffer, "%s, %s <=> y, x = %s", fString.cstr(), zString.cstr(), xString.cstr()); |
| 403 | 403 | break; |
| 404 | 404 | } |
| 405 | 405 | |
| r245621 | r245622 | |
| 416 | 416 | astring atString = (aT ? "a0" : "a1"); |
| 417 | 417 | atString += X ? "" : "1"; // TODO: Figure out unclear wording. |
| 418 | 418 | astring fString = disasmF1Field(F1, aT, S); |
| 419 | | sprintf(buffer, "%s, %s <=> %s", fString.c_str(), zString.c_str(), atString.c_str()); |
| 419 | sprintf(buffer, "%s, %s <=> %s", fString.cstr(), zString.cstr(), atString.cstr()); |
| 420 | 420 | break; |
| 421 | 421 | } |
| 422 | 422 | |
| r245621 | r245622 | |
| 431 | 431 | const UINT8 F2 = (op & 0x01e0) >> 5; |
| 432 | 432 | astring fString = disasmF2Field(F2, D, S); |
| 433 | 433 | astring conString = disasmCONField(CON); |
| 434 | | if (op & 0x0800) sprintf(buffer, "if %s : %s", conString.c_str(), fString.c_str()); |
| 435 | | else sprintf(buffer, "ifc %s : %s", conString.c_str(), fString.c_str()); |
| 434 | if (op & 0x0800) sprintf(buffer, "if %s : %s", conString.cstr(), fString.cstr()); |
| 435 | else sprintf(buffer, "ifc %s : %s", conString.cstr(), fString.cstr()); |
| 436 | 436 | break; |
| 437 | 437 | } |
| 438 | 438 | |
| r245621 | r245622 | |
| 458 | 458 | // goto B |
| 459 | 459 | const UINT8 B = (op & 0x0700) >> 8; |
| 460 | 460 | astring bString = disasmBField(B); |
| 461 | | sprintf(buffer, "%s", bString.c_str()); |
| 461 | sprintf(buffer, "%s", bString.cstr()); |
| 462 | 462 | break; |
| 463 | 463 | } |
| 464 | 464 | |
| r245621 | r245622 | |
| 468 | 468 | // if CON [goto/call/return] |
| 469 | 469 | const UINT8 CON = (op & 0x001f); |
| 470 | 470 | astring conString = disasmCONField(CON); |
| 471 | | sprintf(buffer, "if %s:", conString.c_str()); |
| 471 | sprintf(buffer, "if %s:", conString.cstr()); |
| 472 | 472 | // TODO: Test for invalid ops |
| 473 | 473 | // icall |
| 474 | 474 | if (op == 0xd40e) sprintf(buffer, "icall"); |
| r245621 | r245622 | |
| 482 | 482 | const UINT8 R = (op & 0x03f0) >> 4; |
| 483 | 483 | const UINT8 S = (op & 0x1000) >> 12; |
| 484 | 484 | astring rString = disasmRField(R); |
| 485 | | sprintf(buffer, "%s = %s", rString.c_str(), (S ? "a1" : "a0")); |
| 485 | sprintf(buffer, "%s = %s", rString.cstr(), (S ? "a1" : "a0")); |
| 486 | 486 | break; |
| 487 | 487 | } |
| 488 | 488 | case 0x08: |
| r245621 | r245622 | |
| 491 | 491 | const UINT8 R = (op & 0x03f0) >> 4; |
| 492 | 492 | const UINT8 aT = (op & 0x0400) >> 10; |
| 493 | 493 | astring rString = disasmRField(R); |
| 494 | | sprintf(buffer, "%s = %s", (aT ? "a0" : "a1"), rString.c_str()); |
| 494 | sprintf(buffer, "%s = %s", (aT ? "a0" : "a1"), rString.cstr()); |
| 495 | 495 | break; |
| 496 | 496 | } |
| 497 | 497 | case 0x0f: |
| r245621 | r245622 | |
| 501 | 501 | const UINT8 R = (op & 0x03f0) >> 4; |
| 502 | 502 | astring yString = disasmYField(Y); |
| 503 | 503 | astring rString = disasmRField(R); |
| 504 | | sprintf(buffer, "%s = %s", rString.c_str(), yString.c_str()); |
| 504 | sprintf(buffer, "%s = %s", rString.cstr(), yString.cstr()); |
| 505 | 505 | // TODO: Special case the R == [y, y1, or x] case |
| 506 | 506 | break; |
| 507 | 507 | } |
| r245621 | r245622 | |
| 513 | 513 | astring yString = disasmYField(Y); |
| 514 | 514 | astring rString = disasmRField(R); |
| 515 | 515 | // TODO: page 3-31 "special function encoding" |
| 516 | | sprintf(buffer, "%s = %s", yString.c_str(), rString.c_str()); |
| 516 | sprintf(buffer, "%s = %s", yString.cstr(), rString.cstr()); |
| 517 | 517 | break; |
| 518 | 518 | } |
| 519 | 519 | case 0x0d: |
| r245621 | r245622 | |
| 523 | 523 | const UINT8 R = (op & 0x03f0) >> 4; |
| 524 | 524 | astring zString = disasmZField(Z); |
| 525 | 525 | astring rString = disasmRField(R); |
| 526 | | sprintf(buffer, "%s <=> %s", zString.c_str(), rString.c_str()); |
| 526 | sprintf(buffer, "%s <=> %s", zString.cstr(), rString.cstr()); |
| 527 | 527 | break; |
| 528 | 528 | } |
| 529 | 529 | |
| r245621 | r245622 | |
| 533 | 533 | // R = N |
| 534 | 534 | const UINT8 R = (op & 0x03f0) >> 4; |
| 535 | 535 | astring rString = disasmRField(R); |
| 536 | | sprintf(buffer, "%s = 0x%04x", rString.c_str(), op2); |
| 536 | sprintf(buffer, "%s = 0x%04x", rString.cstr(), op2); |
| 537 | 537 | opSize = 2; |
| 538 | 538 | break; |
| 539 | 539 | } |
| r245621 | r245622 | |
| 545 | 545 | const UINT16 M = (op & 0x01ff); |
| 546 | 546 | const UINT8 R = (op & 0x0e00) >> 9; |
| 547 | 547 | astring rString = disasmRImmediateField(R); |
| 548 | | sprintf(buffer, "%s = 0x%04x", rString.c_str(), M); |
| 548 | sprintf(buffer, "%s = 0x%04x", rString.cstr(), M); |
| 549 | 549 | break; |
| 550 | 550 | } |
| 551 | 551 | |
trunk/src/emu/cpu/mcs96/mcs96.c
| r245621 | r245622 | |
| 253 | 253 | int delta = oprom[2]; |
| 254 | 254 | if(delta & 0x80) |
| 255 | 255 | delta -= 0x100; |
| 256 | | sprintf(buffer, " %s, %04x", regname(oprom[1]).c_str(), (pc+3+delta) & 0xffff); |
| 256 | sprintf(buffer, " %s, %04x", regname(oprom[1]).cstr(), (pc+3+delta) & 0xffff); |
| 257 | 257 | flags |= 3; |
| 258 | 258 | break; |
| 259 | 259 | } |
| r245621 | r245622 | |
| 262 | 262 | int delta = oprom[2]; |
| 263 | 263 | if(delta & 0x80) |
| 264 | 264 | delta -= 0x100; |
| 265 | | sprintf(buffer, " %d, %s, %04x", oprom[0] & 7, regname(oprom[1]).c_str(), (pc+3+delta) & 0xffff); |
| 265 | sprintf(buffer, " %d, %s, %04x", oprom[0] & 7, regname(oprom[1]).cstr(), (pc+3+delta) & 0xffff); |
| 266 | 266 | flags |= 3; |
| 267 | 267 | break; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | case DASM_direct_1: |
| 271 | | sprintf(buffer, " %s", regname(oprom[1]).c_str()); |
| 271 | sprintf(buffer, " %s", regname(oprom[1]).cstr()); |
| 272 | 272 | flags |= 2; |
| 273 | 273 | break; |
| 274 | 274 | |
| 275 | 275 | case DASM_direct_2: |
| 276 | | sprintf(buffer, " %s, %s", regname(oprom[2]).c_str(), regname(oprom[1]).c_str()); |
| 276 | sprintf(buffer, " %s, %s", regname(oprom[2]).cstr(), regname(oprom[1]).cstr()); |
| 277 | 277 | flags |= 3; |
| 278 | 278 | break; |
| 279 | 279 | |
| 280 | 280 | case DASM_direct_3: |
| 281 | | sprintf(buffer, " %s, %s, %s", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]).c_str()); |
| 281 | sprintf(buffer, " %s, %s, %s", regname(oprom[3]).cstr(), regname(oprom[2]).cstr(), regname(oprom[1]).cstr()); |
| 282 | 282 | flags |= 4; |
| 283 | 283 | break; |
| 284 | 284 | |
| r245621 | r245622 | |
| 288 | 288 | break; |
| 289 | 289 | |
| 290 | 290 | case DASM_immed_2b: |
| 291 | | sprintf(buffer, " %s, #%02x", regname(oprom[2]).c_str(), oprom[1]); |
| 291 | sprintf(buffer, " %s, #%02x", regname(oprom[2]).cstr(), oprom[1]); |
| 292 | 292 | flags |= 3; |
| 293 | 293 | break; |
| 294 | 294 | |
| 295 | 295 | case DASM_immed_or_reg_2b: |
| 296 | 296 | if(oprom[1] >= 0x10) |
| 297 | | sprintf(buffer, " %s, %s", regname(oprom[2]).c_str(), regname(oprom[1]).c_str()); |
| 297 | sprintf(buffer, " %s, %s", regname(oprom[2]).cstr(), regname(oprom[1]).cstr()); |
| 298 | 298 | else |
| 299 | | sprintf(buffer, " %s, #%02x", regname(oprom[2]).c_str(), oprom[1]); |
| 299 | sprintf(buffer, " %s, #%02x", regname(oprom[2]).cstr(), oprom[1]); |
| 300 | 300 | flags |= 3; |
| 301 | 301 | break; |
| 302 | 302 | |
| 303 | 303 | case DASM_immed_3b: |
| 304 | | sprintf(buffer, " %s, %s, #%02x", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), oprom[1]); |
| 304 | sprintf(buffer, " %s, %s, #%02x", regname(oprom[3]).cstr(), regname(oprom[2]).cstr(), oprom[1]); |
| 305 | 305 | flags |= 4; |
| 306 | 306 | break; |
| 307 | 307 | |
| r245621 | r245622 | |
| 311 | 311 | break; |
| 312 | 312 | |
| 313 | 313 | case DASM_immed_2w: |
| 314 | | sprintf(buffer, " %s, #%02x%02x", regname(oprom[3]).c_str(), oprom[2], oprom[1]); |
| 314 | sprintf(buffer, " %s, #%02x%02x", regname(oprom[3]).cstr(), oprom[2], oprom[1]); |
| 315 | 315 | flags |= 4; |
| 316 | 316 | break; |
| 317 | 317 | |
| 318 | 318 | case DASM_immed_3w: |
| 319 | | sprintf(buffer, " %s, %s, #%02x%02x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), oprom[2], oprom[1]); |
| 319 | sprintf(buffer, " %s, %s, #%02x%02x", regname(oprom[4]).cstr(), regname(oprom[3]).cstr(), oprom[2], oprom[1]); |
| 320 | 320 | flags |= 5; |
| 321 | 321 | break; |
| 322 | 322 | |
| 323 | 323 | case DASM_indirect_1n: |
| 324 | | sprintf(buffer, " [%s]", regname(oprom[1]).c_str()); |
| 324 | sprintf(buffer, " [%s]", regname(oprom[1]).cstr()); |
| 325 | 325 | flags |= 2; |
| 326 | 326 | break; |
| 327 | 327 | |
| 328 | 328 | case DASM_indirect_1: |
| 329 | 329 | if(oprom[1] & 0x01) { |
| 330 | | sprintf(buffer, " [%s]+", regname(oprom[1]-1).c_str()); |
| 330 | sprintf(buffer, " [%s]+", regname(oprom[1]-1).cstr()); |
| 331 | 331 | flags |= 2; |
| 332 | 332 | } else { |
| 333 | | sprintf(buffer, " [%s]", regname(oprom[1]).c_str()); |
| 333 | sprintf(buffer, " [%s]", regname(oprom[1]).cstr()); |
| 334 | 334 | flags |= 2; |
| 335 | 335 | } |
| 336 | 336 | break; |
| 337 | 337 | |
| 338 | 338 | case DASM_indirect_2: |
| 339 | 339 | if(oprom[1] & 0x01) { |
| 340 | | sprintf(buffer, " %s, [%s]+", regname(oprom[2]).c_str(), regname(oprom[1]-1).c_str()); |
| 340 | sprintf(buffer, " %s, [%s]+", regname(oprom[2]).cstr(), regname(oprom[1]-1).cstr()); |
| 341 | 341 | flags |= 3; |
| 342 | 342 | } else { |
| 343 | | sprintf(buffer, " %s, [%s]", regname(oprom[2]).c_str(), regname(oprom[1]).c_str()); |
| 343 | sprintf(buffer, " %s, [%s]", regname(oprom[2]).cstr(), regname(oprom[1]).cstr()); |
| 344 | 344 | flags |= 3; |
| 345 | 345 | } |
| 346 | 346 | break; |
| 347 | 347 | |
| 348 | 348 | case DASM_indirect_3: |
| 349 | 349 | if(oprom[1] & 0x01) { |
| 350 | | sprintf(buffer, " %s, %s, [%s]+", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]-1).c_str()); |
| 350 | sprintf(buffer, " %s, %s, [%s]+", regname(oprom[3]).cstr(), regname(oprom[2]).cstr(), regname(oprom[1]-1).cstr()); |
| 351 | 351 | flags |= 4; |
| 352 | 352 | } else { |
| 353 | | sprintf(buffer, " %s, %s, [%s]", regname(oprom[3]).c_str(), regname(oprom[2]).c_str(), regname(oprom[1]).c_str()); |
| 353 | sprintf(buffer, " %s, %s, [%s]", regname(oprom[3]).cstr(), regname(oprom[2]).cstr(), regname(oprom[1]).cstr()); |
| 354 | 354 | flags |= 4; |
| 355 | 355 | } |
| 356 | 356 | break; |
| r245621 | r245622 | |
| 360 | 360 | if(oprom[1] == 0x01) |
| 361 | 361 | sprintf(buffer, " %02x%02x", oprom[3], oprom[2]); |
| 362 | 362 | else |
| 363 | | sprintf(buffer, " %02x%02x[%s]", oprom[3], oprom[2], regname(oprom[1]-1).c_str()); |
| 363 | sprintf(buffer, " %02x%02x[%s]", oprom[3], oprom[2], regname(oprom[1]-1).cstr()); |
| 364 | 364 | flags |= 4; |
| 365 | 365 | } else { |
| 366 | 366 | int delta = oprom[2]; |
| r245621 | r245622 | |
| 373 | 373 | sprintf(buffer, " %02x", delta); |
| 374 | 374 | } else { |
| 375 | 375 | if(delta < 0) |
| 376 | | sprintf(buffer, " -%02x[%s]", -delta, regname(oprom[1]).c_str()); |
| 376 | sprintf(buffer, " -%02x[%s]", -delta, regname(oprom[1]).cstr()); |
| 377 | 377 | else |
| 378 | | sprintf(buffer, " %02x[%s]", delta, regname(oprom[1]).c_str()); |
| 378 | sprintf(buffer, " %02x[%s]", delta, regname(oprom[1]).cstr()); |
| 379 | 379 | } |
| 380 | 380 | flags |= 3; |
| 381 | 381 | } |
| r245621 | r245622 | |
| 384 | 384 | case DASM_indexed_2: |
| 385 | 385 | if(oprom[1] & 0x01) { |
| 386 | 386 | if(oprom[1] == 0x01) |
| 387 | | sprintf(buffer, " %s, %02x%02x", regname(oprom[4]).c_str(), oprom[3], oprom[2]); |
| 387 | sprintf(buffer, " %s, %02x%02x", regname(oprom[4]).cstr(), oprom[3], oprom[2]); |
| 388 | 388 | else |
| 389 | | sprintf(buffer, " %s, %02x%02x[%s]", regname(oprom[4]).c_str(), oprom[3], oprom[2], regname(oprom[1]-1).c_str()); |
| 389 | sprintf(buffer, " %s, %02x%02x[%s]", regname(oprom[4]).cstr(), oprom[3], oprom[2], regname(oprom[1]-1).cstr()); |
| 390 | 390 | flags |= 5; |
| 391 | 391 | } else { |
| 392 | 392 | int delta = oprom[2]; |
| r245621 | r245622 | |
| 394 | 394 | delta -= 0x100; |
| 395 | 395 | if(oprom[1] == 0x00) { |
| 396 | 396 | if(delta < 0) |
| 397 | | sprintf(buffer, " %s, %04x", regname(oprom[3]).c_str(), delta & 0xffff); |
| 397 | sprintf(buffer, " %s, %04x", regname(oprom[3]).cstr(), delta & 0xffff); |
| 398 | 398 | else |
| 399 | | sprintf(buffer, " %s, %02x", regname(oprom[3]).c_str(), delta); |
| 399 | sprintf(buffer, " %s, %02x", regname(oprom[3]).cstr(), delta); |
| 400 | 400 | } else { |
| 401 | 401 | if(delta < 0) |
| 402 | | sprintf(buffer, " %s, -%02x[%s]", regname(oprom[3]).c_str(), -delta, regname(oprom[1]).c_str()); |
| 402 | sprintf(buffer, " %s, -%02x[%s]", regname(oprom[3]).cstr(), -delta, regname(oprom[1]).cstr()); |
| 403 | 403 | else |
| 404 | | sprintf(buffer, " %s, %02x[%s]", regname(oprom[3]).c_str(), delta, regname(oprom[1]).c_str()); |
| 404 | sprintf(buffer, " %s, %02x[%s]", regname(oprom[3]).cstr(), delta, regname(oprom[1]).cstr()); |
| 405 | 405 | } |
| 406 | 406 | flags |= 4; |
| 407 | 407 | } |
| r245621 | r245622 | |
| 410 | 410 | case DASM_indexed_3: |
| 411 | 411 | if(oprom[1] & 0x01) { |
| 412 | 412 | if(oprom[1] == 0x01) |
| 413 | | sprintf(buffer, " %s, %s, %02x%02x", regname(oprom[5]).c_str(), regname(oprom[4]).c_str(), oprom[3], oprom[2]); |
| 413 | sprintf(buffer, " %s, %s, %02x%02x", regname(oprom[5]).cstr(), regname(oprom[4]).cstr(), oprom[3], oprom[2]); |
| 414 | 414 | else |
| 415 | | sprintf(buffer, " %s, %s, %02x%02x[%s]", regname(oprom[5]).c_str(), regname(oprom[4]).c_str(), oprom[3], oprom[2], regname(oprom[1]-1).c_str()); |
| 415 | sprintf(buffer, " %s, %s, %02x%02x[%s]", regname(oprom[5]).cstr(), regname(oprom[4]).cstr(), oprom[3], oprom[2], regname(oprom[1]-1).cstr()); |
| 416 | 416 | flags |= 6; |
| 417 | 417 | } else { |
| 418 | 418 | int delta = oprom[2]; |
| r245621 | r245622 | |
| 420 | 420 | delta -= 0x100; |
| 421 | 421 | if(oprom[1] == 0x00) { |
| 422 | 422 | if(delta < 0) |
| 423 | | sprintf(buffer, " %s, %s, %04x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta & 0xffff); |
| 423 | sprintf(buffer, " %s, %s, %04x", regname(oprom[4]).cstr(), regname(oprom[3]).cstr(), delta & 0xffff); |
| 424 | 424 | else |
| 425 | | sprintf(buffer, " %s, %s, %02x", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta); |
| 425 | sprintf(buffer, " %s, %s, %02x", regname(oprom[4]).cstr(), regname(oprom[3]).cstr(), delta); |
| 426 | 426 | } else { |
| 427 | 427 | if(delta < 0) |
| 428 | | sprintf(buffer, " %s, %s, -%02x[%s]", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), -delta, regname(oprom[1]).c_str()); |
| 428 | sprintf(buffer, " %s, %s, -%02x[%s]", regname(oprom[4]).cstr(), regname(oprom[3]).cstr(), -delta, regname(oprom[1]).cstr()); |
| 429 | 429 | else |
| 430 | | sprintf(buffer, " %s, %s, %02x[%s]", regname(oprom[4]).c_str(), regname(oprom[3]).c_str(), delta, regname(oprom[1]).c_str()); |
| 430 | sprintf(buffer, " %s, %s, %02x[%s]", regname(oprom[4]).cstr(), regname(oprom[3]).cstr(), delta, regname(oprom[1]).cstr()); |
| 431 | 431 | } |
| 432 | 432 | flags |= 5; |
| 433 | 433 | } |
trunk/src/emu/machine/hdc9234.c
| r245621 | r245622 | |
| 572 | 572 | |
| 573 | 573 | void hdc9234_device::wait_time(emu_timer *tm, const attotime &delay, int param) |
| 574 | 574 | { |
| 575 | | if (TRACE_DELAY) logerror("%s: [%s] Delaying by %4.2f microsecs\n", tag(), ttsn().c_str(), delay.as_double()*1000000); |
| 575 | if (TRACE_DELAY) logerror("%s: [%s] Delaying by %4.2f microsecs\n", tag(), ttsn().cstr(), delay.as_double()*1000000); |
| 576 | 576 | tm->adjust(delay); |
| 577 | 577 | m_substate = param; |
| 578 | 578 | } |
| r245621 | r245622 | |
| 1784 | 1784 | */ |
| 1785 | 1785 | void hdc9234_device::live_start(int state) |
| 1786 | 1786 | { |
| 1787 | | if (TRACE_LIVE) logerror("%s: [%s] Live start substate=%d\n", tag(), ttsn().c_str(), state); |
| 1787 | if (TRACE_LIVE) logerror("%s: [%s] Live start substate=%d\n", tag(), ttsn().cstr(), state); |
| 1788 | 1788 | m_live_state.time = machine().time(); |
| 1789 | 1789 | m_live_state.state = state; |
| 1790 | 1790 | m_live_state.next_state = -1; |
| r245621 | r245622 | |
| 1828 | 1828 | if (TRACE_LIVE) |
| 1829 | 1829 | { |
| 1830 | 1830 | if (limit == attotime::never) |
| 1831 | | logerror("%s: [%s] live_run, live_state=%d, mode=%s\n", tag(), tts(m_live_state.time).c_str(), m_live_state.state, fm_mode()? "FM":"MFM"); |
| 1831 | logerror("%s: [%s] live_run, live_state=%d, mode=%s\n", tag(), tts(m_live_state.time).cstr(), m_live_state.state, fm_mode()? "FM":"MFM"); |
| 1832 | 1832 | else |
| 1833 | | logerror("%s: [%s] live_run until %s, live_state=%d, mode=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str(), m_live_state.state, fm_mode()? "FM":"MFM"); |
| 1833 | logerror("%s: [%s] live_run until %s, live_state=%d, mode=%s\n", tag(), tts(m_live_state.time).cstr(), tts(limit).cstr(), m_live_state.state, fm_mode()? "FM":"MFM"); |
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | if (limit == attotime::never) |
| r245621 | r245622 | |
| 1862 | 1862 | |
| 1863 | 1863 | if (TRACE_LIVE && m_last_live_state != SEARCH_IDAM) |
| 1864 | 1864 | { |
| 1865 | | logerror("%s: [%s] SEARCH_IDAM [limit %s]\n", tag(),tts(m_live_state.time).c_str(), tts(limit).c_str()); |
| 1865 | logerror("%s: [%s] SEARCH_IDAM [limit %s]\n", tag(),tts(m_live_state.time).cstr(), tts(limit).cstr()); |
| 1866 | 1866 | m_last_live_state = m_live_state.state; |
| 1867 | 1867 | } |
| 1868 | 1868 | |
| r245621 | r245622 | |
| 1871 | 1871 | |
| 1872 | 1872 | if (read_one_bit(limit)) |
| 1873 | 1873 | { |
| 1874 | | if (TRACE_LIVE) logerror("%s: [%s] SEARCH_IDAM limit reached\n", tag(), tts(m_live_state.time).c_str()); |
| 1874 | if (TRACE_LIVE) logerror("%s: [%s] SEARCH_IDAM limit reached\n", tag(), tts(m_live_state.time).cstr()); |
| 1875 | 1875 | return; |
| 1876 | 1876 | } |
| 1877 | | // logerror("%s: SEARCH_IDAM\n", tts(m_live_state.time).c_str()); |
| 1878 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).c_str(), m_live_state.shift_reg, |
| 1877 | // logerror("%s: SEARCH_IDAM\n", tts(m_live_state.time).cstr()); |
| 1878 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).cstr(), m_live_state.shift_reg, |
| 1879 | 1879 | get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter); |
| 1880 | 1880 | |
| 1881 | 1881 | // [1] p. 9: The ID field sync mark must be found within 33,792 byte times |
| r245621 | r245622 | |
| 1890 | 1890 | // MFM case |
| 1891 | 1891 | if (m_live_state.shift_reg == 0x4489) |
| 1892 | 1892 | { |
| 1893 | | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str()); |
| 1893 | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).cstr()); |
| 1894 | 1894 | m_live_state.crc = 0x443b; |
| 1895 | 1895 | m_live_state.data_separator_phase = false; |
| 1896 | 1896 | m_live_state.bit_counter = 0; |
| r245621 | r245622 | |
| 1921 | 1921 | |
| 1922 | 1922 | if (TRACE_LIVE && m_last_live_state != READ_TWO_MORE_A1_IDAM) |
| 1923 | 1923 | { |
| 1924 | | logerror("%s: [%s] READ_TWO_MORE_A1\n", tag(),tts(m_live_state.time).c_str()); |
| 1924 | logerror("%s: [%s] READ_TWO_MORE_A1\n", tag(),tts(m_live_state.time).cstr()); |
| 1925 | 1925 | m_last_live_state = m_live_state.state; |
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | // Beyond time limit? |
| 1929 | 1929 | if (read_one_bit(limit)) return; |
| 1930 | 1930 | |
| 1931 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).c_str(), m_live_state.shift_reg, |
| 1931 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).cstr(), m_live_state.shift_reg, |
| 1932 | 1932 | get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter); |
| 1933 | 1933 | |
| 1934 | 1934 | if (m_live_state.bit_count_total > 33792*16) |
| r245621 | r245622 | |
| 1950 | 1950 | m_live_state.state = SEARCH_IDAM; |
| 1951 | 1951 | } |
| 1952 | 1952 | else |
| 1953 | | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str()); |
| 1953 | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).cstr()); |
| 1954 | 1954 | // Continue |
| 1955 | 1955 | break; |
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg); |
| 1958 | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X\n", tag(),tts(m_live_state.time).cstr(), m_live_state.data_reg); |
| 1959 | 1959 | |
| 1960 | 1960 | // Check for ident field (fe, ff, fd, fc) |
| 1961 | 1961 | if ((m_live_state.data_reg & 0xfc) != 0xfc) |
| r245621 | r245622 | |
| 1976 | 1976 | case READ_ID_FIELDS_INTO_REGS: |
| 1977 | 1977 | if (TRACE_LIVE && m_last_live_state != READ_ID_FIELDS_INTO_REGS) |
| 1978 | 1978 | { |
| 1979 | | logerror("%s: [%s] READ_ID_FIELDS_INTO_REGS\n", tag(),tts(m_live_state.time).c_str()); |
| 1979 | logerror("%s: [%s] READ_ID_FIELDS_INTO_REGS\n", tag(),tts(m_live_state.time).cstr()); |
| 1980 | 1980 | m_last_live_state = m_live_state.state; |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| r245621 | r245622 | |
| 2017 | 2017 | case SEARCH_DAM: |
| 2018 | 2018 | if (TRACE_LIVE && m_last_live_state != SEARCH_DAM) |
| 2019 | 2019 | { |
| 2020 | | logerror("%s: [%s] SEARCH_DAM\n", tag(),tts(m_live_state.time).c_str()); |
| 2020 | logerror("%s: [%s] SEARCH_DAM\n", tag(),tts(m_live_state.time).cstr()); |
| 2021 | 2021 | m_last_live_state = m_live_state.state; |
| 2022 | 2022 | } |
| 2023 | 2023 | |
| r245621 | r245622 | |
| 2026 | 2026 | if(read_one_bit(limit)) |
| 2027 | 2027 | return; |
| 2028 | 2028 | |
| 2029 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).c_str(), m_live_state.shift_reg, |
| 2029 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).cstr(), m_live_state.shift_reg, |
| 2030 | 2030 | get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter); |
| 2031 | 2031 | |
| 2032 | 2032 | if (!fm_mode()) |
| r245621 | r245622 | |
| 2040 | 2040 | |
| 2041 | 2041 | if (m_live_state.bit_counter >= 28*16 && m_live_state.shift_reg == 0x4489) |
| 2042 | 2042 | { |
| 2043 | | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str()); |
| 2043 | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).cstr()); |
| 2044 | 2044 | m_live_state.crc = 0x443b; |
| 2045 | 2045 | m_live_state.data_separator_phase = false; |
| 2046 | 2046 | m_live_state.bit_counter = 0; |
| r245621 | r245622 | |
| 2074 | 2074 | case READ_TWO_MORE_A1_DAM: { |
| 2075 | 2075 | if (TRACE_LIVE && m_last_live_state != READ_TWO_MORE_A1_DAM) |
| 2076 | 2076 | { |
| 2077 | | logerror("%s: [%s] READ_TWO_MORE_A1_DAM\n", tag(),tts(m_live_state.time).c_str()); |
| 2077 | logerror("%s: [%s] READ_TWO_MORE_A1_DAM\n", tag(),tts(m_live_state.time).cstr()); |
| 2078 | 2078 | m_last_live_state = m_live_state.state; |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | 2081 | if(read_one_bit(limit)) |
| 2082 | 2082 | return; |
| 2083 | 2083 | |
| 2084 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).c_str(), m_live_state.shift_reg, |
| 2084 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(m_live_state.time).cstr(), m_live_state.shift_reg, |
| 2085 | 2085 | get_data_from_encoding(m_live_state.shift_reg), m_live_state.bit_counter); |
| 2086 | 2086 | |
| 2087 | 2087 | // Repeat until we have collected 16 bits |
| r245621 | r245622 | |
| 2098 | 2098 | return; |
| 2099 | 2099 | } |
| 2100 | 2100 | else |
| 2101 | | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).c_str()); |
| 2101 | if (TRACE_LIVE) logerror("%s: [%s] Found an A1 mark\n", tag(),tts(m_live_state.time).cstr()); |
| 2102 | 2102 | // Continue |
| 2103 | 2103 | break; |
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg); |
| 2106 | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X\n", tag(),tts(m_live_state.time).cstr(), m_live_state.data_reg); |
| 2107 | 2107 | |
| 2108 | 2108 | if ((m_live_state.data_reg & 0xff) == 0xf8) |
| 2109 | 2109 | { |
| r245621 | r245622 | |
| 2133 | 2133 | { |
| 2134 | 2134 | if (TRACE_LIVE && m_last_live_state != READ_SECTOR_DATA) |
| 2135 | 2135 | { |
| 2136 | | logerror("%s: [%s] READ_SECTOR_DATA\n", tag(),tts(m_live_state.time).c_str()); |
| 2136 | logerror("%s: [%s] READ_SECTOR_DATA\n", tag(),tts(m_live_state.time).cstr()); |
| 2137 | 2137 | m_last_live_state = m_live_state.state; |
| 2138 | 2138 | } |
| 2139 | 2139 | |
| r245621 | r245622 | |
| 2158 | 2158 | // Repeat until we have collected 16 bits |
| 2159 | 2159 | if (m_live_state.bit_counter & 15) break; |
| 2160 | 2160 | |
| 2161 | | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X, CRC=%04x\n", tag(),tts(m_live_state.time).c_str(), m_live_state.data_reg, m_live_state.crc); |
| 2161 | if (TRACE_LIVE) logerror("%s: [%s] Found data value %02X, CRC=%04x\n", tag(),tts(m_live_state.time).cstr(), m_live_state.data_reg, m_live_state.crc); |
| 2162 | 2162 | int slot = (m_live_state.bit_counter >> 4)-1; |
| 2163 | 2163 | |
| 2164 | 2164 | if (slot < calc_sector_size()) |
| r245621 | r245622 | |
| 2179 | 2179 | } |
| 2180 | 2180 | else |
| 2181 | 2181 | { |
| 2182 | | if (TRACE_LIVE) logerror("%s: [%s] Sector read completed\n", tag(),tts(m_live_state.time).c_str()); |
| 2182 | if (TRACE_LIVE) logerror("%s: [%s] Sector read completed\n", tag(),tts(m_live_state.time).cstr()); |
| 2183 | 2183 | wait_for_realtime(IDLE); |
| 2184 | 2184 | } |
| 2185 | 2185 | return; |
| r245621 | r245622 | |
| 2191 | 2191 | case READ_SECTOR_DATA1: |
| 2192 | 2192 | if (TRACE_LIVE && m_last_live_state != READ_SECTOR_DATA1) |
| 2193 | 2193 | { |
| 2194 | | logerror("%s: [%s] READ_SECTOR_DATA1\n", tag(),tts(m_live_state.time).c_str()); |
| 2194 | logerror("%s: [%s] READ_SECTOR_DATA1\n", tag(),tts(m_live_state.time).cstr()); |
| 2195 | 2195 | m_last_live_state = m_live_state.state; |
| 2196 | 2196 | } |
| 2197 | 2197 | |
| r245621 | r245622 | |
| 2237 | 2237 | // 5. Write the CRC bytes |
| 2238 | 2238 | |
| 2239 | 2239 | if (TRACE_LIVE) |
| 2240 | | logerror("%s: [%s] WRITE_DAM_AND_SECTOR\n", tag(), tts(m_live_state.time).c_str()); |
| 2240 | logerror("%s: [%s] WRITE_DAM_AND_SECTOR\n", tag(), tts(m_live_state.time).cstr()); |
| 2241 | 2241 | |
| 2242 | 2242 | skip_on_track(m_gap2_size, WRITE_DAM_SYNC); |
| 2243 | 2243 | break; |
| r245621 | r245622 | |
| 2554 | 2554 | // The pause is implemented by doing dummy reads on the floppy |
| 2555 | 2555 | if (read_one_bit(limit)) |
| 2556 | 2556 | { |
| 2557 | | if (TRACE_LIVE) logerror("%s: [%s] return; limit=%s\n", tag(), tts(m_live_state.time).c_str(), tts(limit).c_str()); |
| 2557 | if (TRACE_LIVE) logerror("%s: [%s] return; limit=%s\n", tag(), tts(m_live_state.time).cstr(), tts(limit).cstr()); |
| 2558 | 2558 | return; |
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | 2561 | // Repeat until we have collected 16 bits |
| 2562 | 2562 | if ((m_live_state.bit_counter & 15)==0) |
| 2563 | 2563 | { |
| 2564 | | if (TRACE_READ && TRACE_DETAIL) logerror("%s: [%s] Read byte %02x, repeat = %d\n", tag(), tts(m_live_state.time).c_str(), m_live_state.data_reg, m_live_state.repeat); |
| 2564 | if (TRACE_READ && TRACE_DETAIL) logerror("%s: [%s] Read byte %02x, repeat = %d\n", tag(), tts(m_live_state.time).cstr(), m_live_state.data_reg, m_live_state.repeat); |
| 2565 | 2565 | wait_for_realtime(READ_TRACK_NEXT_BYTE); |
| 2566 | 2566 | return; |
| 2567 | 2567 | } |
| r245621 | r245622 | |
| 2636 | 2636 | if(m_live_state.time > machine().time()) |
| 2637 | 2637 | { |
| 2638 | 2638 | // If so, we must roll back to the last checkpoint |
| 2639 | | if (TRACE_SYNC) logerror("%s: [%s] Rolling back and replaying (%s)\n", tag(), ttsn().c_str(), tts(m_live_state.time).c_str()); |
| 2639 | if (TRACE_SYNC) logerror("%s: [%s] Rolling back and replaying (%s)\n", tag(), ttsn().cstr(), tts(m_live_state.time).cstr()); |
| 2640 | 2640 | rollback(); |
| 2641 | 2641 | // and replay until we reach the machine time |
| 2642 | 2642 | live_run_until(machine().time()); |
| r245621 | r245622 | |
| 2647 | 2647 | { |
| 2648 | 2648 | // We are behind machine time, so we will never get back to that |
| 2649 | 2649 | // time, thus we can commit that position |
| 2650 | | if (TRACE_SYNC) logerror("%s: [%s] Committing (%s)\n", tag(), ttsn().c_str(), tts(m_live_state.time).c_str()); |
| 2650 | if (TRACE_SYNC) logerror("%s: [%s] Committing (%s)\n", tag(), ttsn().cstr(), tts(m_live_state.time).cstr()); |
| 2651 | 2651 | // Write on floppy image |
| 2652 | 2652 | m_pll.commit(m_floppy, m_live_state.time); |
| 2653 | 2653 | |
| r245621 | r245622 | |
| 2672 | 2672 | { |
| 2673 | 2673 | if (!m_live_state.time.is_never() && m_live_state.time > machine().time()) |
| 2674 | 2674 | { |
| 2675 | | if (TRACE_LIVE) logerror("%s: Abort; rolling back and replaying (%s)\n", ttsn().c_str(), tts(m_live_state.time).c_str()); |
| 2675 | if (TRACE_LIVE) logerror("%s: Abort; rolling back and replaying (%s)\n", ttsn().cstr(), tts(m_live_state.time).cstr()); |
| 2676 | 2676 | rollback(); |
| 2677 | 2677 | live_run_until(machine().time()); |
| 2678 | 2678 | } |
| r245621 | r245622 | |
| 2735 | 2735 | { |
| 2736 | 2736 | m_live_state.next_state = state; |
| 2737 | 2737 | m_timer->adjust(m_live_state.time - machine().time()); |
| 2738 | | if (TRACE_LIVE) logerror("%s: [%s] Waiting for real time [%s] to catch up\n", tag(), tts(m_live_state.time).c_str(), tts(machine().time()).c_str()); |
| 2738 | if (TRACE_LIVE) logerror("%s: [%s] Waiting for real time [%s] to catch up\n", tag(), tts(m_live_state.time).cstr(), tts(machine().time()).cstr()); |
| 2739 | 2739 | } |
| 2740 | 2740 | |
| 2741 | 2741 | /* |
| r245621 | r245622 | |
| 2858 | 2858 | m_live_state.bit_counter = 16; |
| 2859 | 2859 | m_live_state.last_data_bit = raw & 1; |
| 2860 | 2860 | m_live_state.shift_reg = m_live_state.shift_reg_save = raw; |
| 2861 | | if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: [%s] Write %02x (%04x)\n", tag(), tts(m_live_state.time).c_str(), byte, raw); |
| 2861 | if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: [%s] Write %02x (%04x)\n", tag(), tts(m_live_state.time).cstr(), byte, raw); |
| 2862 | 2862 | checkpoint(); |
| 2863 | 2863 | } |
| 2864 | 2864 | |
| r245621 | r245622 | |
| 2872 | 2872 | m_live_state.bit_counter = 16; |
| 2873 | 2873 | m_live_state.shift_reg = m_live_state.shift_reg_save = raw; |
| 2874 | 2874 | m_live_state.last_data_bit = raw & 1; |
| 2875 | | if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: [%s] Write %02x (%04x)\n", tag(), tts(m_live_state.time).c_str(), get_data_from_encoding(raw), raw); |
| 2875 | if (TRACE_WRITE && TRACE_DETAIL) logerror("%s: [%s] Write %02x (%04x)\n", tag(), tts(m_live_state.time).cstr(), get_data_from_encoding(raw), raw); |
| 2876 | 2876 | checkpoint(); |
| 2877 | 2877 | } |
| 2878 | 2878 | |
| r245621 | r245622 | |
| 2960 | 2960 | { |
| 2961 | 2961 | if (m_executing) |
| 2962 | 2962 | { |
| 2963 | | logerror("%s: [%s] Error - previous command %02x not completed; new command %02x ignored\n", tag(), ttsn().c_str(), current_command(), data); |
| 2963 | logerror("%s: [%s] Error - previous command %02x not completed; new command %02x ignored\n", tag(), ttsn().cstr(), current_command(), data); |
| 2964 | 2964 | } |
| 2965 | 2965 | else |
| 2966 | 2966 | { |
| r245621 | r245622 | |
| 3169 | 3169 | |
| 3170 | 3170 | void hdc9234_device::index_callback(int level) |
| 3171 | 3171 | { |
| 3172 | | if (TRACE_LINES) logerror("%s: [%s] Index callback level=%d\n", tag(), ttsn().c_str(), level); |
| 3172 | if (TRACE_LINES) logerror("%s: [%s] Index callback level=%d\n", tag(), ttsn().cstr(), level); |
| 3173 | 3173 | |
| 3174 | 3174 | // Synchronize our position on the track |
| 3175 | 3175 | live_sync(); |
| r245621 | r245622 | |
| 3182 | 3182 | |
| 3183 | 3183 | if (m_event_line == INDEX_LINE && level == m_line_level && m_state_after_line != UNDEF) |
| 3184 | 3184 | { |
| 3185 | | if (TRACE_LINES) logerror("%s: [%s] Index pulse level=%d triggers event\n", tag(), ttsn().c_str(), level); |
| 3185 | if (TRACE_LINES) logerror("%s: [%s] Index pulse level=%d triggers event\n", tag(), ttsn().cstr(), level); |
| 3186 | 3186 | m_substate = m_state_after_line; |
| 3187 | 3187 | m_state_after_line = UNDEF; |
| 3188 | 3188 | if (m_stopwrite) |
| r245621 | r245622 | |
| 3197 | 3197 | |
| 3198 | 3198 | void hdc9234_device::ready_callback(int level) |
| 3199 | 3199 | { |
| 3200 | | if (TRACE_LINES) logerror("%s: [%s] Ready callback level=%d\n", tag(), ttsn().c_str(), level); |
| 3200 | if (TRACE_LINES) logerror("%s: [%s] Ready callback level=%d\n", tag(), ttsn().cstr(), level); |
| 3201 | 3201 | |
| 3202 | 3202 | // Set the interrupt status flag |
| 3203 | 3203 | set_bits(m_register_r[INT_STATUS], ST_RDYCHNG, true); |
| r245621 | r245622 | |
| 3222 | 3222 | |
| 3223 | 3223 | void hdc9234_device::seek_complete_callback(int level) |
| 3224 | 3224 | { |
| 3225 | | if (TRACE_LINES) logerror("%s: [%s] Seek complete callback level=%d\n", tag(), ttsn().c_str(), level); |
| 3225 | if (TRACE_LINES) logerror("%s: [%s] Seek complete callback level=%d\n", tag(), ttsn().cstr(), level); |
| 3226 | 3226 | |
| 3227 | 3227 | // Synchronize our position on the track |
| 3228 | 3228 | live_sync(); |
| r245621 | r245622 | |
| 3323 | 3323 | { |
| 3324 | 3324 | if (state==ASSERT_LINE) |
| 3325 | 3325 | { |
| 3326 | | if (TRACE_DMA) logerror("%s: [%s] DMA acknowledged\n", tag(), ttsn().c_str()); |
| 3326 | if (TRACE_DMA) logerror("%s: [%s] DMA acknowledged\n", tag(), ttsn().cstr()); |
| 3327 | 3327 | set_bits(m_register_r[INT_STATUS], ST_OVRUN, false); |
| 3328 | 3328 | } |
| 3329 | 3329 | } |
trunk/src/emu/machine/wd_fdc.c
| r245621 | r245622 | |
| 383 | 383 | return; |
| 384 | 384 | |
| 385 | 385 | default: |
| 386 | | logerror("%s: seek unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 386 | logerror("%s: seek unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 387 | 387 | return; |
| 388 | 388 | } |
| 389 | 389 | } |
| r245621 | r245622 | |
| 505 | 505 | break; |
| 506 | 506 | |
| 507 | 507 | default: |
| 508 | | logerror("%s: read sector unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 508 | logerror("%s: read sector unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 509 | 509 | return; |
| 510 | 510 | } |
| 511 | 511 | } |
| r245621 | r245622 | |
| 584 | 584 | return; |
| 585 | 585 | |
| 586 | 586 | default: |
| 587 | | logerror("%s: read track unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 587 | logerror("%s: read track unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 588 | 588 | return; |
| 589 | 589 | } |
| 590 | 590 | } |
| r245621 | r245622 | |
| 659 | 659 | return; |
| 660 | 660 | |
| 661 | 661 | default: |
| 662 | | logerror("%s: read id unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 662 | logerror("%s: read id unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 663 | 663 | return; |
| 664 | 664 | } |
| 665 | 665 | } |
| r245621 | r245622 | |
| 763 | 763 | sprintf(buf, "%02x", format_last_byte); |
| 764 | 764 | format_description_string += buf; |
| 765 | 765 | } |
| 766 | | if (TRACE_DESC) logerror("%s: track description %s\n", tag(), format_description_string.c_str()); |
| 766 | if (TRACE_DESC) logerror("%s: track description %s\n", tag(), format_description_string.cstr()); |
| 767 | 767 | command_end(); |
| 768 | 768 | return; |
| 769 | 769 | |
| 770 | 770 | default: |
| 771 | | logerror("%s: write track unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 771 | logerror("%s: write track unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 772 | 772 | return; |
| 773 | 773 | } |
| 774 | 774 | } |
| r245621 | r245622 | |
| 867 | 867 | break; |
| 868 | 868 | |
| 869 | 869 | default: |
| 870 | | logerror("%s: write sector unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 870 | logerror("%s: write sector unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 871 | 871 | return; |
| 872 | 872 | } |
| 873 | 873 | } |
| r245621 | r245622 | |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | if(command & 0x03) { |
| 901 | | logerror("%s: unhandled interrupt generation (%02x)\n", ttsn().c_str(), command); |
| 901 | logerror("%s: unhandled interrupt generation (%02x)\n", ttsn().cstr(), command); |
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| r245621 | r245622 | |
| 932 | 932 | write_sector_continue(); |
| 933 | 933 | break; |
| 934 | 934 | default: |
| 935 | | logerror("%s: general_continue on unknown main-state %d\n", ttsn().c_str(), main_state); |
| 935 | logerror("%s: general_continue on unknown main-state %d\n", ttsn().cstr(), main_state); |
| 936 | 936 | break; |
| 937 | 937 | } |
| 938 | 938 | } |
| r245621 | r245622 | |
| 963 | 963 | |
| 964 | 964 | default: |
| 965 | 965 | if(cur_live.tm.is_never()) |
| 966 | | logerror("%s: do_generic on unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 966 | logerror("%s: do_generic on unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 967 | 967 | break; |
| 968 | 968 | } |
| 969 | 969 | } |
| r245621 | r245622 | |
| 1285 | 1285 | break; |
| 1286 | 1286 | |
| 1287 | 1287 | default: |
| 1288 | | logerror("%s: Index pulse on unknown sub-state %d\n", ttsn().c_str(), sub_state); |
| 1288 | logerror("%s: Index pulse on unknown sub-state %d\n", ttsn().cstr(), sub_state); |
| 1289 | 1289 | break; |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| r245621 | r245622 | |
| 1360 | 1360 | { |
| 1361 | 1361 | if(!cur_live.tm.is_never()) { |
| 1362 | 1362 | if(cur_live.tm > machine().time()) { |
| 1363 | | if (TRACE_SYNC) logerror("%s: Rolling back and replaying (%s)\n", ttsn().c_str(), tts(cur_live.tm).c_str()); |
| 1363 | if (TRACE_SYNC) logerror("%s: Rolling back and replaying (%s)\n", ttsn().cstr(), tts(cur_live.tm).cstr()); |
| 1364 | 1364 | rollback(); |
| 1365 | 1365 | live_run(machine().time()); |
| 1366 | 1366 | pll_commit(floppy, cur_live.tm); |
| 1367 | 1367 | } else { |
| 1368 | | if (TRACE_SYNC) logerror("%s: Committing (%s)\n", ttsn().c_str(), tts(cur_live.tm).c_str()); |
| 1368 | if (TRACE_SYNC) logerror("%s: Committing (%s)\n", ttsn().cstr(), tts(cur_live.tm).cstr()); |
| 1369 | 1369 | pll_commit(floppy, cur_live.tm); |
| 1370 | 1370 | if(cur_live.next_state != -1) { |
| 1371 | 1371 | cur_live.state = cur_live.next_state; |
| r245621 | r245622 | |
| 1485 | 1485 | } |
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | | // fprintf(stderr, "%s: live_run(%s)\n", ttsn().c_str(), tts(limit).c_str()); |
| 1488 | // fprintf(stderr, "%s: live_run(%s)\n", ttsn().cstr(), tts(limit).cstr()); |
| 1489 | 1489 | |
| 1490 | 1490 | for(;;) { |
| 1491 | 1491 | switch(cur_live.state) { |
| r245621 | r245622 | |
| 1493 | 1493 | if(read_one_bit(limit)) |
| 1494 | 1494 | return; |
| 1495 | 1495 | |
| 1496 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg, |
| 1496 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d\n", tts(cur_live.tm).cstr(), cur_live.shift_reg, |
| 1497 | 1497 | (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) | |
| 1498 | 1498 | (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) | |
| 1499 | 1499 | (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) | |
| r245621 | r245622 | |
| 1526 | 1526 | if(read_one_bit(limit)) |
| 1527 | 1527 | return; |
| 1528 | 1528 | |
| 1529 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg, |
| 1529 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).cstr(), cur_live.shift_reg, |
| 1530 | 1530 | (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) | |
| 1531 | 1531 | (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) | |
| 1532 | 1532 | (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) | |
| r245621 | r245622 | |
| 1568 | 1568 | if(cur_live.bit_counter & 15) |
| 1569 | 1569 | break; |
| 1570 | 1570 | int slot = (cur_live.bit_counter >> 4)-1; |
| 1571 | | // fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).c_str(), slot, cur_live.data_reg, cur_live.crc); |
| 1571 | // fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).cstr(), slot, cur_live.data_reg, cur_live.crc); |
| 1572 | 1572 | cur_live.idbuf[slot] = cur_live.data_reg; |
| 1573 | 1573 | if(slot == 5) { |
| 1574 | 1574 | live_delay(IDLE); |
| r245621 | r245622 | |
| 1609 | 1609 | if(read_one_bit(limit)) |
| 1610 | 1610 | return; |
| 1611 | 1611 | |
| 1612 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d.%x\n", tts(cur_live.tm).c_str(), cur_live.shift_reg, |
| 1612 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x c=%d.%x\n", tts(cur_live.tm).cstr(), cur_live.shift_reg, |
| 1613 | 1613 | (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) | |
| 1614 | 1614 | (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) | |
| 1615 | 1615 | (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) | |
| r245621 | r245622 | |
| 1656 | 1656 | if(read_one_bit(limit)) |
| 1657 | 1657 | return; |
| 1658 | 1658 | |
| 1659 | | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).c_str(), cur_live.shift_reg, |
| 1659 | if (TRACE_SHIFT) logerror("%s: shift = %04x data=%02x counter=%d\n", tts(cur_live.tm).cstr(), cur_live.shift_reg, |
| 1660 | 1660 | (cur_live.shift_reg & 0x4000 ? 0x80 : 0x00) | |
| 1661 | 1661 | (cur_live.shift_reg & 0x1000 ? 0x40 : 0x00) | |
| 1662 | 1662 | (cur_live.shift_reg & 0x0400 ? 0x20 : 0x00) | |
| r245621 | r245622 | |
| 1954 | 1954 | break; |
| 1955 | 1955 | |
| 1956 | 1956 | default: |
| 1957 | | logerror("%s: Unknown sub state %d in WRITE_BYTE_DONE\n", tts(cur_live.tm).c_str(), sub_state); |
| 1957 | logerror("%s: Unknown sub state %d in WRITE_BYTE_DONE\n", tts(cur_live.tm).cstr(), sub_state); |
| 1958 | 1958 | live_abort(); |
| 1959 | 1959 | return; |
| 1960 | 1960 | } |
| r245621 | r245622 | |
| 2017 | 2017 | break; |
| 2018 | 2018 | |
| 2019 | 2019 | default: |
| 2020 | | logerror("%s: Unknown live state %d\n", tts(cur_live.tm).c_str(), cur_live.state); |
| 2020 | logerror("%s: Unknown live state %d\n", tts(cur_live.tm).cstr(), cur_live.state); |
| 2021 | 2021 | return; |
| 2022 | 2022 | } |
| 2023 | 2023 | } |
| r245621 | r245622 | |
| 2186 | 2186 | |
| 2187 | 2187 | /* if (TRACE_TRANSITION) |
| 2188 | 2188 | if(!when.is_never()) |
| 2189 | | logerror("transition_time=%s\n", tts(when).c_str()); |
| 2189 | logerror("transition_time=%s\n", tts(when).cstr()); |
| 2190 | 2190 | */ |
| 2191 | 2191 | for(;;) { |
| 2192 | 2192 | // if (TRACE_TRANSITION) logerror("slot=%2d, counter=%03x\n", slot, counter); |
| 2193 | 2193 | attotime etime = ctime+delays[slot]; |
| 2194 | | // if (TRACE_TRANSITION) logerror("etime=%s\n", tts(etime).c_str()); |
| 2194 | // if (TRACE_TRANSITION) logerror("etime=%s\n", tts(etime).cstr()); |
| 2195 | 2195 | if(etime > limit) |
| 2196 | 2196 | return -1; |
| 2197 | 2197 | if(transition_time == 0xffff && !when.is_never() && etime >= when) |
trunk/src/emu/romload.c
| r245621 | r245622 | |
| 441 | 441 | |
| 442 | 442 | bool is_chd_error = (is_chd && chderr != CHDERR_FILE_NOT_FOUND); |
| 443 | 443 | if (is_chd_error) |
| 444 | | romdata->errorstring.catprintf("%s CHD ERROR: %s\n", name.c_str(), chd_file::error_string(chderr)); |
| 444 | romdata->errorstring.catprintf("%s CHD ERROR: %s\n", name.cstr(), chd_file::error_string(chderr)); |
| 445 | 445 | |
| 446 | 446 | /* optional files are okay */ |
| 447 | 447 | if (ROM_ISOPTIONAL(romp)) |
| 448 | 448 | { |
| 449 | 449 | if (!is_chd_error) |
| 450 | | romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); |
| 450 | romdata->errorstring.catprintf("OPTIONAL %s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr()); |
| 451 | 451 | romdata->warnings++; |
| 452 | 452 | } |
| 453 | 453 | |
| r245621 | r245622 | |
| 455 | 455 | else if (hash_collection(ROM_GETHASHDATA(romp)).flag(hash_collection::FLAG_NO_DUMP)) |
| 456 | 456 | { |
| 457 | 457 | if (!is_chd_error) |
| 458 | | romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.c_str(), tried_file_names.c_str()); |
| 458 | romdata->errorstring.catprintf("%s NOT FOUND (NO GOOD DUMP KNOWN)%s\n", name.cstr(), tried_file_names.cstr()); |
| 459 | 459 | romdata->knownbad++; |
| 460 | 460 | } |
| 461 | 461 | |
| r245621 | r245622 | |
| 463 | 463 | else |
| 464 | 464 | { |
| 465 | 465 | if (!is_chd_error) |
| 466 | | romdata->errorstring.catprintf("%s NOT FOUND%s\n", name.c_str(), tried_file_names.c_str()); |
| 466 | romdata->errorstring.catprintf("%s NOT FOUND%s\n", name.cstr(), tried_file_names.cstr()); |
| 467 | 467 | romdata->errors++; |
| 468 | 468 | } |
| 469 | 469 | } |
| r245621 | r245622 | |
| 560 | 560 | if (romdata->errors != 0) |
| 561 | 561 | { |
| 562 | 562 | /* create the error message and exit fatally */ |
| 563 | | osd_printf_error("%s", romdata->errorstring.c_str()); |
| 563 | osd_printf_error("%s", romdata->errorstring.cstr()); |
| 564 | 564 | fatalerror_exitcode(romdata->machine(), MAMERR_MISSING_FILES, "Required files are missing, the %s cannot be run.",emulator_info::get_gamenoun()); |
| 565 | 565 | } |
| 566 | 566 | |
| r245621 | r245622 | |
| 570 | 570 | romdata->errorstring.cat("WARNING: the "); |
| 571 | 571 | romdata->errorstring.cat(emulator_info::get_gamenoun()); |
| 572 | 572 | romdata->errorstring.cat(" might not run correctly."); |
| 573 | | osd_printf_warning("%s\n", romdata->errorstring.c_str()); |
| 573 | osd_printf_warning("%s\n", romdata->errorstring.cstr()); |
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
| r245621 | r245622 | |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // prepare locations where we have to load from: list/parentname & list/clonename |
| 680 | | astring swlist(tag1.c_str()); |
| 680 | astring swlist(tag1.cstr()); |
| 681 | 681 | tag2.cpy(swlist.cat(tag4)); |
| 682 | 682 | if (has_parent) |
| 683 | 683 | { |
| r245621 | r245622 | |
| 695 | 695 | if (!is_list) |
| 696 | 696 | { |
| 697 | 697 | tried_file_names += " " + tag1; |
| 698 | | filerr = common_process_file(romdata->machine().options(), tag1.c_str(), has_crc, crc, romp, &romdata->file); |
| 698 | filerr = common_process_file(romdata->machine().options(), tag1.cstr(), has_crc, crc, romp, &romdata->file); |
| 699 | 699 | } |
| 700 | 700 | else |
| 701 | 701 | { |
| 702 | 702 | // try to load from list/setname |
| 703 | | if ((romdata->file == NULL) && (tag2.c_str() != NULL)) |
| 703 | if ((romdata->file == NULL) && (tag2.cstr() != NULL)) |
| 704 | 704 | { |
| 705 | 705 | tried_file_names += " " + tag2; |
| 706 | | filerr = common_process_file(romdata->machine().options(), tag2.c_str(), has_crc, crc, romp, &romdata->file); |
| 706 | filerr = common_process_file(romdata->machine().options(), tag2.cstr(), has_crc, crc, romp, &romdata->file); |
| 707 | 707 | } |
| 708 | 708 | // try to load from list/parentname |
| 709 | | if ((romdata->file == NULL) && has_parent && (tag3.c_str() != NULL)) |
| 709 | if ((romdata->file == NULL) && has_parent && (tag3.cstr() != NULL)) |
| 710 | 710 | { |
| 711 | 711 | tried_file_names += " " + tag3; |
| 712 | | filerr = common_process_file(romdata->machine().options(), tag3.c_str(), has_crc, crc, romp, &romdata->file); |
| 712 | filerr = common_process_file(romdata->machine().options(), tag3.cstr(), has_crc, crc, romp, &romdata->file); |
| 713 | 713 | } |
| 714 | 714 | // try to load from setname |
| 715 | | if ((romdata->file == NULL) && (tag4.c_str() != NULL)) |
| 715 | if ((romdata->file == NULL) && (tag4.cstr() != NULL)) |
| 716 | 716 | { |
| 717 | 717 | tried_file_names += " " + tag4; |
| 718 | | filerr = common_process_file(romdata->machine().options(), tag4.c_str(), has_crc, crc, romp, &romdata->file); |
| 718 | filerr = common_process_file(romdata->machine().options(), tag4.cstr(), has_crc, crc, romp, &romdata->file); |
| 719 | 719 | } |
| 720 | 720 | // try to load from parentname |
| 721 | | if ((romdata->file == NULL) && has_parent && (tag5.c_str() != NULL)) |
| 721 | if ((romdata->file == NULL) && has_parent && (tag5.cstr() != NULL)) |
| 722 | 722 | { |
| 723 | 723 | tried_file_names += " " + tag5; |
| 724 | | filerr = common_process_file(romdata->machine().options(), tag5.c_str(), has_crc, crc, romp, &romdata->file); |
| 724 | filerr = common_process_file(romdata->machine().options(), tag5.cstr(), has_crc, crc, romp, &romdata->file); |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | } |
| r245621 | r245622 | |
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | // prepare locations where we have to load from: list/parentname (if any) & list/clonename |
| 1081 | | astring swlist(tag1.c_str()); |
| 1081 | astring swlist(tag1.cstr()); |
| 1082 | 1082 | tag2.cpy(swlist.cat(tag4)); |
| 1083 | 1083 | if (has_parent) |
| 1084 | 1084 | { |
| r245621 | r245622 | |
| 1098 | 1098 | else |
| 1099 | 1099 | { |
| 1100 | 1100 | // try to load from list/setname |
| 1101 | | if ((filerr != FILERR_NONE) && (tag2.c_str() != NULL)) |
| 1102 | | filerr = common_process_file(options, tag2.c_str(), ".chd", romp, image_file); |
| 1101 | if ((filerr != FILERR_NONE) && (tag2.cstr() != NULL)) |
| 1102 | filerr = common_process_file(options, tag2.cstr(), ".chd", romp, image_file); |
| 1103 | 1103 | // try to load from list/parentname (if any) |
| 1104 | | if ((filerr != FILERR_NONE) && has_parent && (tag3.c_str() != NULL)) |
| 1105 | | filerr = common_process_file(options, tag3.c_str(), ".chd", romp, image_file); |
| 1104 | if ((filerr != FILERR_NONE) && has_parent && (tag3.cstr() != NULL)) |
| 1105 | filerr = common_process_file(options, tag3.cstr(), ".chd", romp, image_file); |
| 1106 | 1106 | // try to load from setname |
| 1107 | | if ((filerr != FILERR_NONE) && (tag4.c_str() != NULL)) |
| 1108 | | filerr = common_process_file(options, tag4.c_str(), ".chd", romp, image_file); |
| 1107 | if ((filerr != FILERR_NONE) && (tag4.cstr() != NULL)) |
| 1108 | filerr = common_process_file(options, tag4.cstr(), ".chd", romp, image_file); |
| 1109 | 1109 | // try to load from parentname (if any) |
| 1110 | | if ((filerr != FILERR_NONE) && has_parent && (tag5.c_str() != NULL)) |
| 1111 | | filerr = common_process_file(options, tag5.c_str(), ".chd", romp, image_file); |
| 1110 | if ((filerr != FILERR_NONE) && has_parent && (tag5.cstr() != NULL)) |
| 1111 | filerr = common_process_file(options, tag5.cstr(), ".chd", romp, image_file); |
| 1112 | 1112 | // only for CHD we also try to load from list/ |
| 1113 | | if ((filerr != FILERR_NONE) && (tag1.c_str() != NULL)) |
| 1113 | if ((filerr != FILERR_NONE) && (tag1.cstr() != NULL)) |
| 1114 | 1114 | { |
| 1115 | 1115 | tag1.del(tag1.len() - 1, 1); // remove the PATH_SEPARATOR |
| 1116 | | filerr = common_process_file(options, tag1.c_str(), ".chd", romp, image_file); |
| 1116 | filerr = common_process_file(options, tag1.cstr(), ".chd", romp, image_file); |
| 1117 | 1117 | } |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| r245621 | r245622 | |
| 1182 | 1182 | astring fname(ROM_GETNAME(romp), ".dif"); |
| 1183 | 1183 | |
| 1184 | 1184 | /* try to open the diff */ |
| 1185 | | LOG(("Opening differencing image file: %s\n", fname.c_str())); |
| 1185 | LOG(("Opening differencing image file: %s\n", fname.cstr())); |
| 1186 | 1186 | emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE); |
| 1187 | 1187 | file_error filerr = diff_file.open(fname); |
| 1188 | 1188 | if (filerr == FILERR_NONE) |
| r245621 | r245622 | |
| 1190 | 1190 | astring fullpath(diff_file.fullpath()); |
| 1191 | 1191 | diff_file.close(); |
| 1192 | 1192 | |
| 1193 | | LOG(("Opening differencing image file: %s\n", fullpath.c_str())); |
| 1193 | LOG(("Opening differencing image file: %s\n", fullpath.cstr())); |
| 1194 | 1194 | return diff_chd.open(fullpath, true, &source); |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /* didn't work; try creating it instead */ |
| 1198 | | LOG(("Creating differencing image: %s\n", fname.c_str())); |
| 1198 | LOG(("Creating differencing image: %s\n", fname.cstr())); |
| 1199 | 1199 | diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); |
| 1200 | 1200 | filerr = diff_file.open(fname); |
| 1201 | 1201 | if (filerr == FILERR_NONE) |
| r245621 | r245622 | |
| 1204 | 1204 | diff_file.close(); |
| 1205 | 1205 | |
| 1206 | 1206 | /* create the CHD */ |
| 1207 | | LOG(("Creating differencing image file: %s\n", fullpath.c_str())); |
| 1207 | LOG(("Creating differencing image file: %s\n", fullpath.cstr())); |
| 1208 | 1208 | chd_codec_type compression[4] = { CHD_CODEC_NONE }; |
| 1209 | 1209 | chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source); |
| 1210 | 1210 | if (err != CHDERR_NONE) |
| r245621 | r245622 | |
| 1239 | 1239 | astring filename(ROM_GETNAME(romp), ".chd"); |
| 1240 | 1240 | |
| 1241 | 1241 | /* first open the source drive */ |
| 1242 | | LOG(("Opening disk image: %s\n", filename.c_str())); |
| 1242 | LOG(("Opening disk image: %s\n", filename.cstr())); |
| 1243 | 1243 | err = chd_error(open_disk_image(romdata->machine().options(), &romdata->machine().system(), romp, chd->orig_chd(), locationtag)); |
| 1244 | 1244 | if (err != CHDERR_NONE) |
| 1245 | 1245 | { |
| r245621 | r245622 | |
| 1255 | 1255 | /* verify the hash */ |
| 1256 | 1256 | if (hashes != acthashes) |
| 1257 | 1257 | { |
| 1258 | | romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", filename.c_str()); |
| 1258 | romdata->errorstring.catprintf("%s WRONG CHECKSUMS:\n", filename.cstr()); |
| 1259 | 1259 | dump_wrong_and_correct_checksums(romdata, hashes, acthashes); |
| 1260 | 1260 | romdata->warnings++; |
| 1261 | 1261 | } |
| 1262 | 1262 | else if (hashes.flag(hash_collection::FLAG_BAD_DUMP)) |
| 1263 | 1263 | { |
| 1264 | | romdata->errorstring.catprintf("%s CHD NEEDS REDUMP\n", filename.c_str()); |
| 1264 | romdata->errorstring.catprintf("%s CHD NEEDS REDUMP\n", filename.cstr()); |
| 1265 | 1265 | romdata->knownbad++; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| r245621 | r245622 | |
| 1272 | 1272 | err = open_disk_diff(romdata->machine().options(), romp, chd->orig_chd(), chd->diff_chd()); |
| 1273 | 1273 | if (err != CHDERR_NONE) |
| 1274 | 1274 | { |
| 1275 | | romdata->errorstring.catprintf("%s DIFF CHD ERROR: %s\n", filename.c_str(), chd_file::error_string(err)); |
| 1275 | romdata->errorstring.catprintf("%s DIFF CHD ERROR: %s\n", filename.cstr(), chd_file::error_string(err)); |
| 1276 | 1276 | romdata->errors++; |
| 1277 | 1277 | global_free(chd); |
| 1278 | 1278 | continue; |
| r245621 | r245622 | |
| 1385 | 1385 | UINT32 regionlength = ROMREGION_GETLENGTH(region); |
| 1386 | 1386 | |
| 1387 | 1387 | device.subtag(regiontag, ROMREGION_GETTAG(region)); |
| 1388 | | LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength)); |
| 1388 | LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength)); |
| 1389 | 1389 | |
| 1390 | 1390 | /* the first entry must be a region */ |
| 1391 | 1391 | assert(ROMENTRY_ISREGION(region)); |
| r245621 | r245622 | |
| 1439 | 1439 | for (region = start_region; region != NULL; region = rom_next_region(region)) |
| 1440 | 1440 | { |
| 1441 | 1441 | device.subtag(regiontag, ROMREGION_GETTAG(region)); |
| 1442 | | region_post_process(romdata, regiontag.c_str(), ROMREGION_ISINVERTED(region)); |
| 1442 | region_post_process(romdata, regiontag.cstr(), ROMREGION_ISINVERTED(region)); |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | /* display the results and exit */ |
| r245621 | r245622 | |
| 1463 | 1463 | UINT32 regionlength = ROMREGION_GETLENGTH(region); |
| 1464 | 1464 | |
| 1465 | 1465 | rom_region_name(regiontag, *device, region); |
| 1466 | | LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength)); |
| 1466 | LOG(("Processing region \"%s\" (length=%X)\n", regiontag.cstr(), regionlength)); |
| 1467 | 1467 | |
| 1468 | 1468 | /* the first entry must be a region */ |
| 1469 | 1469 | assert(ROMENTRY_ISREGION(region)); |
| r245621 | r245622 | |
| 1548 | 1548 | } else { |
| 1549 | 1549 | specbios = romdata->machine().options().sub_value(temp,device->owner()->tag()+1,"bios"); |
| 1550 | 1550 | if (strlen(specbios) == 0) { |
| 1551 | | specbios = device->default_bios_tag().c_str(); |
| 1551 | specbios = device->default_bios_tag().cstr(); |
| 1552 | 1552 | } |
| 1553 | 1553 | } |
| 1554 | 1554 | determine_bios_rom(romdata, device, specbios); |
trunk/src/mame/drivers/bfm_sc45_helper.c
| r245621 | r245622 | |
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
| 240 | | sc45helperlog("%s", tempstring.c_str()); |
| 240 | sc45helperlog("%s", tempstring.cstr()); |
| 241 | 241 | |
| 242 | 242 | sc45helperlog("\n"); |
| 243 | 243 | |
| r245621 | r245622 | |
| 316 | 316 | |
| 317 | 317 | if (ignoreports[i][j] > 0) |
| 318 | 318 | { |
| 319 | | printf(" PORT_BIT( 0x%04x, IP_ACTIVE_HIGH, SC45_BUTTON_MATRIX_%d_%d ) PORT_NAME(\"%s\")\n", 1 << j, i,j/*ignoreports[i][j]*/, sc4inputs[i][j].name.c_str()); |
| 319 | printf(" PORT_BIT( 0x%04x, IP_ACTIVE_HIGH, SC45_BUTTON_MATRIX_%d_%d ) PORT_NAME(\"%s\")\n", 1 << j, i,j/*ignoreports[i][j]*/, sc4inputs[i][j].name.cstr()); |
| 320 | 320 | buttons_used++; |
| 321 | 321 | } |
| 322 | 322 | else if (ignoreports[i][j] == -3) |
| 323 | 323 | { |
| 324 | | printf(" // 0x%04x - \"%s\" // standard input (motherboard)\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 324 | printf(" // 0x%04x - \"%s\" // standard input (motherboard)\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 325 | 325 | } |
| 326 | 326 | else if (ignoreports[i][j] == -2) |
| 327 | 327 | { |
| 328 | | printf(" // 0x%04x - \"%s\" // standard input (expected here)\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 328 | printf(" // 0x%04x - \"%s\" // standard input (expected here)\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 329 | 329 | } |
| 330 | 330 | else if (ignoreports[i][j] == -1) |
| 331 | 331 | { |
| 332 | | printf(" // 0x%04x - \"%s\" // unexpected here\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 332 | printf(" // 0x%04x - \"%s\" // unexpected here\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 333 | 333 | } |
| 334 | 334 | else if (ignoreports[i][j] == -4) |
| 335 | 335 | { |
| 336 | | printf(" // 0x%04x - \"%s\" // known extended input, mapping not understood\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 336 | printf(" // 0x%04x - \"%s\" // known extended input, mapping not understood\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 337 | 337 | } |
| 338 | 338 | else if (ignoreports[i][j] == -5) |
| 339 | 339 | { |
| 340 | | printf(" // 0x%04x - \"%s\" // known extended input, usually 'top up'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 340 | printf(" // 0x%04x - \"%s\" // known extended input, usually 'top up'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 341 | 341 | } |
| 342 | 342 | else if (ignoreports[i][j] == -6) |
| 343 | 343 | { |
| 344 | | printf(" // 0x%04x - \"%s\" // known extended input, usually 'hopper low'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 344 | printf(" // 0x%04x - \"%s\" // known extended input, usually 'hopper low'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 345 | 345 | } |
| 346 | 346 | else if (ignoreports[i][j] == -7) |
| 347 | 347 | { |
| 348 | | printf(" // 0x%04x - \"%s\" // known extended input, usually 'hopper fit'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 348 | printf(" // 0x%04x - \"%s\" // known extended input, usually 'hopper fit'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 349 | 349 | } |
| 350 | 350 | else if (ignoreports[i][j] == -8) |
| 351 | 351 | { |
| 352 | | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'top up'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 352 | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'top up'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 353 | 353 | } |
| 354 | 354 | else if (ignoreports[i][j] == -9) |
| 355 | 355 | { |
| 356 | | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'hop hi'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 356 | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'hop hi'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 357 | 357 | } |
| 358 | 358 | else if (ignoreports[i][j] == -10) |
| 359 | 359 | { |
| 360 | | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'hop top'\n", 1 << j, sc4inputs[i][j].name.c_str()); |
| 360 | printf(" // 0x%04x - \"%s\" // known extended(?) input, sometimes 'hop top'\n", 1 << j, sc4inputs[i][j].name.cstr()); |
| 361 | 361 | } |
| 362 | 362 | buttons_used++; |
| 363 | 363 | } |
| r245621 | r245622 | |
| 390 | 390 | { |
| 391 | 391 | for (int x = 0; x < 16; x++) |
| 392 | 392 | { |
| 393 | | if (!strcmp(teststring.c_str(), lamps[y][x].lampname_alt.c_str())) |
| 393 | if (!strcmp(teststring.cstr(), lamps[y][x].lampname_alt.cstr())) |
| 394 | 394 | { |
| 395 | 395 | lamps[y][x].clickport = clickport; |
| 396 | 396 | lamps[y][x].clickmask = clickmask; |
| r245621 | r245622 | |
| 507 | 507 | fatalerror("duplicate lamp?\n"); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | | //sc45helperlog("%s", tempstring.c_str()); |
| 510 | //sc45helperlog("%s", tempstring.cstr()); |
| 511 | 511 | |
| 512 | 512 | //sc45helperlog("\n"); |
| 513 | 513 | |
| r245621 | r245622 | |
| 521 | 521 | //sc45helperlog("---ROW %02d---\n", y); |
| 522 | 522 | for (int x = 0; x < 16; x++) |
| 523 | 523 | { |
| 524 | | sc45helperlog("<element name=\"lamplabelel%d\"><text string=\"%s\"><color red=\"1.0\" green=\"1.0\" blue=\"1.0\" /></text></element>\n", d, lamps[y][x].lampname.c_str()); |
| 524 | sc45helperlog("<element name=\"lamplabelel%d\"><text string=\"%s\"><color red=\"1.0\" green=\"1.0\" blue=\"1.0\" /></text></element>\n", d, lamps[y][x].lampname.cstr()); |
| 525 | 525 | d++; |
| 526 | 526 | } |
| 527 | 527 | } |
| r245621 | r245622 | |
| 536 | 536 | |
| 537 | 537 | for (int x = 0; x < 6; x++) |
| 538 | 538 | { |
| 539 | | sc45helperlog("<element name=\"inputlabel%d-%d\"><text string=\"%s\"><color red=\"1.0\" green=\"1.0\" blue=\"1.0\" /></text></element>\n", realy,x,sc4inputs[realy][x].name.c_str()); |
| 539 | sc45helperlog("<element name=\"inputlabel%d-%d\"><text string=\"%s\"><color red=\"1.0\" green=\"1.0\" blue=\"1.0\" /></text></element>\n", realy,x,sc4inputs[realy][x].name.cstr()); |
| 540 | 540 | |
| 541 | 541 | } |
| 542 | 542 | } |
| r245621 | r245622 | |
| 593 | 593 | { |
| 594 | 594 | lamps[y][x].lampname_alt = lamps[y][x].lampname; |
| 595 | 595 | |
| 596 | | if (!strcmp(lamps[y][x].lampname_alt.c_str(), "hold2/hi")) lamps[y][x].lampname_alt = "hold2"; |
| 597 | | if (!strcmp(lamps[y][x].lampname_alt.c_str(), "hold3/lo")) lamps[y][x].lampname_alt = "hold3"; |
| 598 | | if (!strcmp(lamps[y][x].lampname_alt.c_str(), "chg stake")) lamps[y][x].lampname_alt = "chnge stk"; |
| 599 | | if (!strcmp(lamps[y][x].lampname_alt.c_str(), "canc/coll")) lamps[y][x].lampname_alt = "cancel"; |
| 600 | | if (!strcmp(lamps[y][x].lampname_alt.c_str(), "start")) lamps[y][x].lampname_alt = "strt exch"; |
| 596 | if (!strcmp(lamps[y][x].lampname_alt.cstr(), "hold2/hi")) lamps[y][x].lampname_alt = "hold2"; |
| 597 | if (!strcmp(lamps[y][x].lampname_alt.cstr(), "hold3/lo")) lamps[y][x].lampname_alt = "hold3"; |
| 598 | if (!strcmp(lamps[y][x].lampname_alt.cstr(), "chg stake")) lamps[y][x].lampname_alt = "chnge stk"; |
| 599 | if (!strcmp(lamps[y][x].lampname_alt.cstr(), "canc/coll")) lamps[y][x].lampname_alt = "cancel"; |
| 600 | if (!strcmp(lamps[y][x].lampname_alt.cstr(), "start")) lamps[y][x].lampname_alt = "strt exch"; |
| 601 | 601 | |
| 602 | 602 | } |
| 603 | 603 | } |
| r245621 | r245622 | |
| 625 | 625 | { |
| 626 | 626 | for (int x = 0; x < 16; x++) |
| 627 | 627 | { |
| 628 | | if (!strcmp(tempname2, lamps[y][x].lampname_alt.c_str())) |
| 628 | if (!strcmp(tempname2, lamps[y][x].lampname_alt.cstr())) |
| 629 | 629 | { |
| 630 | 630 | //sc45helperlog("%s found\n", tempname2); |
| 631 | 631 | lamps[y][x].draw_label = false; |
| r245621 | r245622 | |
| 640 | 640 | } |
| 641 | 641 | else |
| 642 | 642 | { |
| 643 | | //printf("%s:%s:\n", tempname2, lamps[y][x].lampname_alt.c_str()); |
| 643 | //printf("%s:%s:\n", tempname2, lamps[y][x].lampname_alt.cstr()); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | } |
| r245621 | r245622 | |
| 679 | 679 | //sc45helperlog("---ROW %02d---\n", y); |
| 680 | 680 | for (int x = 0; x < 16; x++) |
| 681 | 681 | { |
| 682 | | if (lamps[y][x].clickport== -1) sc45helperlog("<bezel name=\"lamp%d\" element=\"%s\" state=\"0\"><bounds x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/></bezel>\n", d, lamps[y][x].lamptypename.c_str(), lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); |
| 683 | | else sc45helperlog("<bezel name=\"lamp%d\" element=\"%s\" state=\"0\" inputtag=\"IN-%d\" inputmask=\"0x%02x\"><bounds x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" /></bezel>\n", d, lamps[y][x].lamptypename.c_str(), lamps[y][x].clickport, lamps[y][x].clickmask, lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); |
| 682 | if (lamps[y][x].clickport== -1) sc45helperlog("<bezel name=\"lamp%d\" element=\"%s\" state=\"0\"><bounds x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\"/></bezel>\n", d, lamps[y][x].lamptypename.cstr(), lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); |
| 683 | else sc45helperlog("<bezel name=\"lamp%d\" element=\"%s\" state=\"0\" inputtag=\"IN-%d\" inputmask=\"0x%02x\"><bounds x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" /></bezel>\n", d, lamps[y][x].lamptypename.cstr(), lamps[y][x].clickport, lamps[y][x].clickmask, lamps[y][x].x, lamps[y][x].y, lamps[y][x].width, lamps[y][x].height); |
| 684 | 684 | |
| 685 | 685 | if (lamps[y][x].draw_label == false) sc45helperlog("<!-- Label not drawn\n"); |
| 686 | 686 | sc45helperlog("<bezel name=\"lamplabel%d\" element=\"lamplabelel%d\"><bounds x=\"%d\" y=\"%d\" width=\"%d\" height=\"10\" /></bezel>\n", d,d, lamps[y][x].x, lamps[y][x].y-10, lamps[y][x].width); |
| r245621 | r245622 | |
| 905 | 905 | tempstring.cat("PND"); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | | sc45helperlog("%s", tempstring.c_str()); |
| 908 | sc45helperlog("%s", tempstring.cstr()); |
| 909 | 909 | |
| 910 | 910 | |
| 911 | 911 | |
trunk/src/mess/drivers/hh_ucom4.c
| r245621 | r245622 | |
| 12 | 12 | @031 uPD553C 1979, Bambino Superstar Football (ET-03) |
| 13 | 13 | *042 uPD552C 1979, Tomy Space Attack |
| 14 | 14 | @048 uPD552C 1980, Tomy Tennis (TN-04) |
| 15 | | @049 uPD553C 1979, Mego Mini-Vid Break Free |
| 16 | 15 | @055 uPD553C 1980, Bambino Laser Fight (ET-12) |
| 17 | 16 | *085 uPD650C 1980, Roland TR-808 |
| 18 | 17 | *102 uPD553C 1981, Bandai Block Out |
| r245621 | r245622 | |
| 20 | 19 | *128 uPD650C 1982, Roland TR-606 |
| 21 | 20 | 133 uPD650C 1982, Roland TB-303 -> tb303.c |
| 22 | 21 | @160 uPD553C 1982, Tomy Pac Man (TN-08) |
| 23 | | @192 uPD553C 1982, Tomy Scramble (TN-10) |
| 24 | 22 | @202 uPD553C 1982, Epoch Astro Command |
| 25 | 23 | @206 uPD553C 1982, Epoch Dracula |
| 26 | | @209 uPD553C 1982, Tomy Caveman (TN-12) |
| 24 | *209 uPD553C 1982, Tomy Caveman (TN-12) |
| 27 | 25 | @258 uPD553C 1984, Tomy Alien Chase (TN-16) |
| 28 | 26 | |
| 29 | 27 | (* denotes not yet emulated by MESS, @ denotes it's in this driver) |
| 30 | 28 | |
| 31 | 29 | ***************************************************************************/ |
| 32 | 30 | |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | | /*************************************************************************** |
| 37 | | |
| 38 | | Mego Mini-Vid Break Free (manufactured in Japan) |
| 39 | | * PCB label Mego 79 rev F |
| 40 | | * NEC uCOM-43 MCU, labeled D553C 031 |
| 41 | | * cyan VFD display Futaba DM-4.5 91 |
| 42 | | |
| 43 | | NOTE!: MESS external artwork is recommended |
| 44 | | |
| 45 | | ***************************************************************************/ |
| 46 | | |
| 47 | | |
| 48 | | /*************************************************************************** |
| 49 | | |
| 50 | | Tomy(tronic) Caveman (manufactured in Japan) |
| 51 | | * PCBs are labeled TN-12 2E114E03 |
| 52 | | * NEC uCOM-43 MCU, labeled D553C 209 |
| 53 | | * cyan/red/green VFD display NEC FIP8AM20T no. 2-42 |
| 54 | | |
| 55 | | NOTE!: MESS external artwork is recommended |
| 56 | | |
| 57 | | ***************************************************************************/ |
| 58 | | |
| 59 | | |
| 60 | | /*************************************************************************** |
| 61 | | |
| 62 | | Tomy(tronic) Scramble (manufactured in Japan) |
| 63 | | * PCBs are labeled TN-10 2E114E01 |
| 64 | | * NEC uCOM-43 MCU, labeled D553C 192 |
| 65 | | * cyan/red/green VFD display NEC FIP10CM20T no. 2-41 |
| 66 | | |
| 67 | | NOTE!: MESS external artwork is recommended |
| 68 | | |
| 69 | | ***************************************************************************/ |
| 70 | | |
| 71 | | |
| 72 | 31 | #include "emu.h" |
| 73 | 32 | #include "cpu/ucom4/ucom4.h" |
| 74 | 33 | #include "sound/speaker.h" |
| r245621 | r245622 | |
| 556 | 515 | Epoch Astro Command (manufactured in Japan) |
| 557 | 516 | * PCB label 96111 |
| 558 | 517 | * NEC uCOM-43 MCU, labeled D553C 202 |
| 559 | | * cyan/red VFD display NEC FIP9AM20T no. 42-42, with color overlay (FIP=fluorescent indicator panel) |
| 518 | * cyan/red VFD display NEC FIP9AM20T NO.42, with color overlay |
| 560 | 519 | |
| 561 | 520 | known releases: |
| 562 | 521 | - Japan: Astro Command |
| r245621 | r245622 | |
| 665 | 624 | Epoch Dracula (manufactured in Japan) |
| 666 | 625 | * PCB label 96121 |
| 667 | 626 | * NEC uCOM-43 MCU, labeled D553C 206 |
| 668 | | * cyan/red/green VFD display NEC FIP8BM20T no. 2-42 |
| 627 | * cyan/red/green VFD display NEC FIP8BM20T (FIP=fluorescent indicator panel) |
| 669 | 628 | |
| 670 | 629 | known releases: |
| 671 | 630 | - Japan: Dracula House, yellow case |
| r245621 | r245622 | |
| 758 | 717 | /*************************************************************************** |
| 759 | 718 | |
| 760 | 719 | Tomy(tronic) Tennis (manufactured in Japan) |
| 761 | | * PCB labeled TOMY TN-04 TENNIS |
| 720 | * board labeled TOMY TN-04 TENNIS |
| 762 | 721 | * NEC uCOM-44 MCU, labeled D552C 048 |
| 763 | | * VFD display NEC FIP11AM15T tube no. 0F |
| 722 | * VFD display NEC FIP11AM15T |
| 764 | 723 | |
| 765 | 724 | The initial release of this game was in 1979, known as Pro-Tennis, |
| 766 | 725 | it has a D553 instead of D552, with just a little over 50% ROM used. |
| r245621 | r245622 | |
| 917 | 876 | /*************************************************************************** |
| 918 | 877 | |
| 919 | 878 | Tomy(tronic) Pac-Man (manufactured in Japan) |
| 920 | | * PCBs are labeled TN-08 2E108E01 |
| 879 | * boards are labeled TN-08 2E108E01 |
| 921 | 880 | * NEC uCOM-43 MCU, labeled D553C 160 |
| 922 | | * cyan/red/green VFD display NEC FIP8AM18T no. 2-21 |
| 881 | * cyan/red/green VFD display NEC FIP8AM18T |
| 923 | 882 | * bright yellow round casing |
| 924 | 883 | |
| 925 | 884 | known releases: |
| r245621 | r245622 | |
| 1025 | 984 | /*************************************************************************** |
| 1026 | 985 | |
| 1027 | 986 | Tomy Alien Chase (manufactured in Japan) |
| 1028 | | * PCBs are labeled TN-16 2E121B01 |
| 987 | * boards are labeled TN-16 2E121B01 |
| 1029 | 988 | * NEC uCOM-43 MCU, labeled D553C 258 |
| 1030 | 989 | * red/green VFD display NEC FIP9AM24T, with color overlay, 2-sided* |
| 1031 | 990 | |
trunk/src/osd/sdl/input.c
| r245621 | r245622 | |
| 742 | 742 | |
| 743 | 743 | devinfo->joystick.device = joy; |
| 744 | 744 | |
| 745 | | osd_printf_verbose("Joystick: %s\n", devinfo->name.c_str()); |
| 745 | osd_printf_verbose("Joystick: %s\n", devinfo->name.cstr()); |
| 746 | 746 | osd_printf_verbose("Joystick: ... %d axes, %d buttons %d hats %d balls\n", SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumBalls(joy)); |
| 747 | 747 | osd_printf_verbose("Joystick: ... Physical id %d mapped to logical id %d\n", physical_stick, stick + 1); |
| 748 | 748 | |
| r245621 | r245622 | |
| 758 | 758 | else |
| 759 | 759 | itemid = ITEM_ID_OTHER_AXIS_ABSOLUTE; |
| 760 | 760 | |
| 761 | | sprintf(tempname, "A%d %s", axis, devinfo->name.c_str()); |
| 761 | sprintf(tempname, "A%d %s", axis, devinfo->name.cstr()); |
| 762 | 762 | devinfo->device->add_item(tempname, itemid, generic_axis_get_state, &devinfo->joystick.axes[axis]); |
| 763 | 763 | } |
| 764 | 764 | |
| r245621 | r245622 | |
| 809 | 809 | else |
| 810 | 810 | itemid = ITEM_ID_OTHER_AXIS_RELATIVE; |
| 811 | 811 | |
| 812 | | sprintf(tempname, "R%d %s", ball * 2, devinfo->name.c_str()); |
| 812 | sprintf(tempname, "R%d %s", ball * 2, devinfo->name.cstr()); |
| 813 | 813 | devinfo->device->add_item(tempname, (input_item_id) itemid, generic_axis_get_state, &devinfo->joystick.balls[ball * 2]); |
| 814 | | sprintf(tempname, "R%d %s", ball * 2 + 1, devinfo->name.c_str()); |
| 814 | sprintf(tempname, "R%d %s", ball * 2 + 1, devinfo->name.cstr()); |
| 815 | 815 | devinfo->device->add_item(tempname, (input_item_id) (itemid + 1), generic_axis_get_state, &devinfo->joystick.balls[ball * 2 + 1]); |
| 816 | 816 | } |
| 817 | 817 | } |
| r245621 | r245622 | |
| 869 | 869 | continue; |
| 870 | 870 | |
| 871 | 871 | // add the axes |
| 872 | | sprintf(defname, "X %s", devinfo->name.c_str()); |
| 872 | sprintf(defname, "X %s", devinfo->name.cstr()); |
| 873 | 873 | devinfo->device->add_item(defname, ITEM_ID_XAXIS, generic_axis_get_state, &devinfo->mouse.lX); |
| 874 | | sprintf(defname, "Y %s", devinfo->name.c_str()); |
| 874 | sprintf(defname, "Y %s", devinfo->name.cstr()); |
| 875 | 875 | devinfo->device->add_item(defname, ITEM_ID_YAXIS, generic_axis_get_state, &devinfo->mouse.lY); |
| 876 | 876 | |
| 877 | 877 | for (button = 0; button < 4; button++) |
| r245621 | r245622 | |
| 886 | 886 | |
| 887 | 887 | if (0 && mouse_enabled) |
| 888 | 888 | SDL_SetRelativeMouseMode(index, SDL_TRUE); |
| 889 | | osd_printf_verbose("Mouse: Registered %s\n", devinfo->name.c_str()); |
| 889 | osd_printf_verbose("Mouse: Registered %s\n", devinfo->name.cstr()); |
| 890 | 890 | } |
| 891 | 891 | osd_printf_verbose("Mouse: End initialization\n"); |
| 892 | 892 | } |
| r245621 | r245622 | |
| 903 | 903 | |
| 904 | 904 | // SDL 1.2 has only 1 mouse - 1.3+ will also change that, so revisit this then |
| 905 | 905 | devinfo = generic_device_alloc(&mouse_list, "System mouse"); |
| 906 | | devinfo->device = machine.input().device_class(DEVICE_CLASS_MOUSE).add_device(devinfo->name.c_str(), devinfo); |
| 906 | devinfo->device = machine.input().device_class(DEVICE_CLASS_MOUSE).add_device(devinfo->name.cstr(), devinfo); |
| 907 | 907 | |
| 908 | 908 | mouse_enabled = machine.options().mouse(); |
| 909 | 909 | |
| r245621 | r245622 | |
| 919 | 919 | devinfo->device->add_item(defname, itemid, generic_button_get_state, &devinfo->mouse.buttons[button]); |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | | osd_printf_verbose("Mouse: Registered %s\n", devinfo->name.c_str()); |
| 922 | osd_printf_verbose("Mouse: Registered %s\n", devinfo->name.cstr()); |
| 923 | 923 | osd_printf_verbose("Mouse: End initialization\n"); |
| 924 | 924 | } |
| 925 | 925 | #endif |
| r245621 | r245622 | |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | |
| 1129 | | sprintf(defname, "X %s", devinfo->name.c_str()); |
| 1129 | sprintf(defname, "X %s", devinfo->name.cstr()); |
| 1130 | 1130 | devinfo->device->add_item(defname, ITEM_ID_XAXIS, generic_axis_get_state, &devinfo->lightgun.lX); |
| 1131 | | sprintf(defname, "Y %s", devinfo->name.c_str()); |
| 1131 | sprintf(defname, "Y %s", devinfo->name.cstr()); |
| 1132 | 1132 | devinfo->device->add_item(defname, ITEM_ID_YAXIS, generic_axis_get_state, &devinfo->lightgun.lY); |
| 1133 | 1133 | |
| 1134 | 1134 | |
| r245621 | r245622 | |
| 1325 | 1325 | devinfo->device->add_item(defname, itemid, generic_button_get_state, &devinfo->keyboard.state[OSD_SDL_INDEX(key_trans_table[keynum].sdl_key)]); |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | | osd_printf_verbose("Keyboard: Registered %s\n", devinfo->name.c_str()); |
| 1328 | osd_printf_verbose("Keyboard: Registered %s\n", devinfo->name.cstr()); |
| 1329 | 1329 | } |
| 1330 | 1330 | osd_printf_verbose("Keyboard: End initialization\n"); |
| 1331 | 1331 | } |
| r245621 | r245622 | |
| 1346 | 1346 | // SDL 1.2 only has 1 keyboard (1.3+ will have multiple, this must be revisited then) |
| 1347 | 1347 | // add it now |
| 1348 | 1348 | devinfo = generic_device_alloc(&keyboard_list, "System keyboard"); |
| 1349 | | devinfo->device = machine.input().device_class(DEVICE_CLASS_KEYBOARD).add_device(devinfo->name.c_str(), devinfo); |
| 1349 | devinfo->device = machine.input().device_class(DEVICE_CLASS_KEYBOARD).add_device(devinfo->name.cstr(), devinfo); |
| 1350 | 1350 | |
| 1351 | 1351 | // populate it |
| 1352 | 1352 | for (keynum = 0; sdl_key_trans_table[keynum].mame_key != ITEM_ID_INVALID; keynum++) |
| r245621 | r245622 | |
| 1363 | 1363 | devinfo->device->add_item(defname, itemid, generic_button_get_state, &devinfo->keyboard.state[OSD_SDL_INDEX(key_trans_table[keynum].sdl_key)]); |
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | | osd_printf_verbose("Keyboard: Registered %s\n", devinfo->name.c_str()); |
| 1366 | osd_printf_verbose("Keyboard: Registered %s\n", devinfo->name.cstr()); |
| 1367 | 1367 | osd_printf_verbose("Keyboard: End initialization\n"); |
| 1368 | 1368 | } |
| 1369 | 1369 | #endif |
| r245621 | r245622 | |
| 1742 | 1742 | case SDL_KEYDOWN: |
| 1743 | 1743 | #ifdef SDL2_MULTIAPI |
| 1744 | 1744 | devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[event.key.which]); |
| 1745 | | //printf("Key down %d %d %s => %d %s (scrlock keycode is %d)\n", event.key.which, event.key.keysym.scancode, devinfo->name.c_str(), OSD_SDL_INDEX_KEYSYM(&event.key.keysym), sdl_key_trans_table[event.key.keysym.scancode].mame_key_name, KEYCODE_SCRLOCK); |
| 1745 | //printf("Key down %d %d %s => %d %s (scrlock keycode is %d)\n", event.key.which, event.key.keysym.scancode, devinfo->name.cstr(), OSD_SDL_INDEX_KEYSYM(&event.key.keysym), sdl_key_trans_table[event.key.keysym.scancode].mame_key_name, KEYCODE_SCRLOCK); |
| 1746 | 1746 | #else |
| 1747 | 1747 | devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[0]); |
| 1748 | 1748 | #endif |
| r245621 | r245622 | |
| 1841 | 1841 | devinfo = generic_device_find_index(mouse_list, mouse_map.logical[0]); |
| 1842 | 1842 | #endif |
| 1843 | 1843 | devinfo->mouse.buttons[event.button.button-1] = 0x80; |
| 1844 | | //printf("But down %d %d %d %d %s\n", event.button.which, event.button.button, event.button.x, event.button.y, devinfo->name.c_str()); |
| 1844 | //printf("But down %d %d %d %d %s\n", event.button.which, event.button.button, event.button.x, event.button.y, devinfo->name.cstr()); |
| 1845 | 1845 | if (event.button.button == 1) |
| 1846 | 1846 | { |
| 1847 | 1847 | // FIXME Move static declaration |
| r245621 | r245622 | |
| 1899 | 1899 | #endif |
| 1900 | 1900 | #if (SDLMAME_SDL2) |
| 1901 | 1901 | // FIXME: may apply to 1.2 as well ... |
| 1902 | | //printf("Motion %d %d %d %s\n", event.motion.which, event.motion.x, event.motion.y, devinfo->name.c_str()); |
| 1902 | //printf("Motion %d %d %d %s\n", event.motion.which, event.motion.x, event.motion.y, devinfo->name.cstr()); |
| 1903 | 1903 | devinfo->mouse.lX += event.motion.xrel * INPUT_RELATIVE_PER_PIXEL; |
| 1904 | 1904 | devinfo->mouse.lY += event.motion.yrel * INPUT_RELATIVE_PER_PIXEL; |
| 1905 | 1905 | #else |
trunk/src/tools/chdman.c
| r245621 | r245622 | |
| 327 | 327 | m_lastfile = m_info.track[tracknum].fname; |
| 328 | 328 | file_error filerr = core_fopen(m_lastfile, OPEN_FLAG_READ, &m_file); |
| 329 | 329 | if (filerr != FILERR_NONE) |
| 330 | | report_error(1, "Error opening input file (%s)'", m_lastfile.c_str()); |
| 330 | report_error(1, "Error opening input file (%s)'", m_lastfile.cstr()); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // iterate over frames |
| r245621 | r245622 | |
| 351 | 351 | core_fseek(m_file, src_frame_start, SEEK_SET); |
| 352 | 352 | UINT32 count = core_fread(m_file, dest, bytesperframe); |
| 353 | 353 | if (count != bytesperframe) |
| 354 | | report_error(1, "Error reading input file (%s)'", m_lastfile.c_str()); |
| 354 | report_error(1, "Error reading input file (%s)'", m_lastfile.cstr()); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // swap if appropriate |
| r245621 | r245622 | |
| 940 | 940 | { |
| 941 | 941 | chd_error err = input_parent_chd.open(*input_chd_parent_str); |
| 942 | 942 | if (err != CHDERR_NONE) |
| 943 | | report_error(1, "Error opening parent CHD file (%s): %s", input_chd_parent_str->c_str(), chd_file::error_string(err)); |
| 943 | report_error(1, "Error opening parent CHD file (%s): %s", input_chd_parent_str->cstr(), chd_file::error_string(err)); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | // process input file |
| r245621 | r245622 | |
| 949 | 949 | { |
| 950 | 950 | chd_error err = input_chd.open(*input_chd_str, writeable, input_parent_chd.opened() ? &input_parent_chd : NULL); |
| 951 | 951 | if (err != CHDERR_NONE) |
| 952 | | report_error(1, "Error opening CHD file (%s): %s", input_chd_str->c_str(), chd_file::error_string(err)); |
| 952 | report_error(1, "Error opening CHD file (%s): %s", input_chd_str->cstr(), chd_file::error_string(err)); |
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | |
| r245621 | r245622 | |
| 1028 | 1028 | { |
| 1029 | 1029 | chd_error err = output_parent_chd.open(*output_chd_parent_str); |
| 1030 | 1030 | if (err != CHDERR_NONE) |
| 1031 | | report_error(1, "Error opening parent CHD file (%s): %s", output_chd_parent_str->c_str(), chd_file::error_string(err)); |
| 1031 | report_error(1, "Error opening parent CHD file (%s): %s", output_chd_parent_str->cstr(), chd_file::error_string(err)); |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | // process output file |
| r245621 | r245622 | |
| 1083 | 1083 | { |
| 1084 | 1084 | astring name(*compression_str, start, (end == -1) ? -1 : end - start); |
| 1085 | 1085 | if (name.len() != 4) |
| 1086 | | report_error(1, "Invalid compressor '%s' specified", name.c_str()); |
| 1086 | report_error(1, "Invalid compressor '%s' specified", name.cstr()); |
| 1087 | 1087 | chd_codec_type type = CHD_MAKE_TAG(name[0], name[1], name[2], name[3]); |
| 1088 | 1088 | if (!chd_codec_list::codec_exists(type)) |
| 1089 | | report_error(1, "Invalid compressor '%s' specified", name.c_str()); |
| 1089 | report_error(1, "Invalid compressor '%s' specified", name.cstr()); |
| 1090 | 1090 | compression[index++] = type; |
| 1091 | 1091 | if (end == -1) |
| 1092 | 1092 | break; |
| r245621 | r245622 | |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | // output TRACK entry |
| 1261 | | core_fprintf(file, " TRACK %02d %s\n", tracknum + 1, tempstr.c_str()); |
| 1261 | core_fprintf(file, " TRACK %02d %s\n", tracknum + 1, tempstr.cstr()); |
| 1262 | 1262 | |
| 1263 | 1263 | // output PREGAP tag if pregap sectors are not in the file |
| 1264 | 1264 | if ((info.pregap > 0) && (info.pgdatasize == 0)) |
| r245621 | r245622 | |
| 1296 | 1296 | modesubmode.format("%s %s", cdrom_get_type_string(info.trktype), cdrom_get_subtype_string(info.subtype)); |
| 1297 | 1297 | else |
| 1298 | 1298 | modesubmode.format("%s", cdrom_get_type_string(info.trktype)); |
| 1299 | | core_fprintf(file, "TRACK %s\n", modesubmode.c_str()); |
| 1299 | core_fprintf(file, "TRACK %s\n", modesubmode.cstr()); |
| 1300 | 1300 | |
| 1301 | 1301 | // write out the attributes |
| 1302 | 1302 | core_fprintf(file, "NO COPY\n"); |
| r245621 | r245622 | |
| 1309 | 1309 | // output pregap |
| 1310 | 1310 | astring tempstr; |
| 1311 | 1311 | if (info.pregap > 0) |
| 1312 | | core_fprintf(file, "ZERO %s %s\n", modesubmode.c_str(), msf_string_from_frames(tempstr, info.pregap)); |
| 1312 | core_fprintf(file, "ZERO %s %s\n", modesubmode.cstr(), msf_string_from_frames(tempstr, info.pregap)); |
| 1313 | 1313 | |
| 1314 | 1314 | // all tracks but the first one have a file offset |
| 1315 | 1315 | if (tracknum > 0) |
| r245621 | r245622 | |
| 1340 | 1340 | |
| 1341 | 1341 | // print filename and version |
| 1342 | 1342 | astring tempstr; |
| 1343 | | printf("Input file: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 1343 | printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 1344 | 1344 | printf("File Version: %d\n", input_chd.version()); |
| 1345 | 1345 | if (input_chd.version() < 3) |
| 1346 | 1346 | report_error(1, "Unsupported version (%d); use an older chdman to upgrade to version 3 or later", input_chd.version()); |
| r245621 | r245622 | |
| 1504 | 1504 | UINT32 bytes_to_read = MIN((UINT32)buffer.count(), input_chd.logical_bytes() - offset); |
| 1505 | 1505 | chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); |
| 1506 | 1506 | if (err != CHDERR_NONE) |
| 1507 | | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->c_str(), chd_file::error_string(err)); |
| 1507 | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err)); |
| 1508 | 1508 | |
| 1509 | 1509 | // add to the checksum |
| 1510 | 1510 | rawsha1.append(buffer, bytes_to_read); |
| r245621 | r245622 | |
| 1568 | 1568 | { |
| 1569 | 1569 | file_error filerr = core_fopen(*input_file_str, OPEN_FLAG_READ, &input_file); |
| 1570 | 1570 | if (filerr != FILERR_NONE) |
| 1571 | | report_error(1, "Unable to open file (%s)", input_file_str->c_str()); |
| 1571 | report_error(1, "Unable to open file (%s)", input_file_str->cstr()); |
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | 1574 | // process output CHD |
| r245621 | r245622 | |
| 1604 | 1604 | |
| 1605 | 1605 | // print some info |
| 1606 | 1606 | astring tempstr; |
| 1607 | | printf("Output CHD: %s\n", output_chd_str->c_str()); |
| 1607 | printf("Output CHD: %s\n", output_chd_str->cstr()); |
| 1608 | 1608 | if (output_parent.opened()) |
| 1609 | | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->c_str()); |
| 1610 | | printf("Input file: %s\n", input_file_str->c_str()); |
| 1609 | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->cstr()); |
| 1610 | printf("Input file: %s\n", input_file_str->cstr()); |
| 1611 | 1611 | if (input_start != 0 || input_end != core_fsize(input_file)) |
| 1612 | 1612 | { |
| 1613 | 1613 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| r245621 | r245622 | |
| 1629 | 1629 | else |
| 1630 | 1630 | err = chd->create(*output_chd_str, input_end - input_start, hunk_size, unit_size, compression); |
| 1631 | 1631 | if (err != CHDERR_NONE) |
| 1632 | | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->c_str(), chd_file::error_string(err)); |
| 1632 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 1633 | 1633 | |
| 1634 | 1634 | // if we have a parent, copy forward all the metadata |
| 1635 | 1635 | if (output_parent.opened()) |
| r245621 | r245622 | |
| 1665 | 1665 | { |
| 1666 | 1666 | file_error filerr = core_fopen(*input_file_str, OPEN_FLAG_READ, &input_file); |
| 1667 | 1667 | if (filerr != FILERR_NONE) |
| 1668 | | report_error(1, "Unable to open file (%s)", input_file_str->c_str()); |
| 1668 | report_error(1, "Unable to open file (%s)", input_file_str->cstr()); |
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | // process output CHD |
| r245621 | r245622 | |
| 1740 | 1740 | // load the file |
| 1741 | 1741 | file_error filerr = core_fload(*ident_str, identdata); |
| 1742 | 1742 | if (filerr != FILERR_NONE) |
| 1743 | | report_error(1, "Error reading ident file (%s)", ident_str->c_str()); |
| 1743 | report_error(1, "Error reading ident file (%s)", ident_str->cstr()); |
| 1744 | 1744 | |
| 1745 | 1745 | // must be at least 14 bytes; extract CHS data from there |
| 1746 | 1746 | if (identdata.count() < 14) |
| 1747 | | report_error(1, "Ident file '%s' is invalid (too short)", ident_str->c_str()); |
| 1747 | report_error(1, "Ident file '%s' is invalid (too short)", ident_str->cstr()); |
| 1748 | 1748 | cylinders = (identdata[3] << 8) | identdata[2]; |
| 1749 | 1749 | heads = (identdata[7] << 8) | identdata[6]; |
| 1750 | 1750 | sectors = (identdata[13] << 8) | identdata[12]; |
| r245621 | r245622 | |
| 1775 | 1775 | |
| 1776 | 1776 | // print some info |
| 1777 | 1777 | astring tempstr; |
| 1778 | | printf("Output CHD: %s\n", output_chd_str->c_str()); |
| 1778 | printf("Output CHD: %s\n", output_chd_str->cstr()); |
| 1779 | 1779 | if (output_parent.opened()) |
| 1780 | | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->c_str()); |
| 1780 | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->cstr()); |
| 1781 | 1781 | if (input_file != NULL) |
| 1782 | 1782 | { |
| 1783 | | printf("Input file: %s\n", input_file_str->c_str()); |
| 1783 | printf("Input file: %s\n", input_file_str->cstr()); |
| 1784 | 1784 | if (input_start != 0 || input_end != core_fsize(input_file)) |
| 1785 | 1785 | { |
| 1786 | 1786 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| r245621 | r245622 | |
| 1807 | 1807 | else |
| 1808 | 1808 | err = chd->create(*output_chd_str, UINT64(totalsectors) * UINT64(sector_size), hunk_size, sector_size, compression); |
| 1809 | 1809 | if (err != CHDERR_NONE) |
| 1810 | | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->c_str(), chd_file::error_string(err)); |
| 1810 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 1811 | 1811 | |
| 1812 | 1812 | // add the standard hard disk metadata |
| 1813 | 1813 | astring metadata; |
| r245621 | r245622 | |
| 1856 | 1856 | { |
| 1857 | 1857 | chd_error err = chdcd_parse_toc(*input_file_str, toc, track_info); |
| 1858 | 1858 | if (err != CHDERR_NONE) |
| 1859 | | report_error(1, "Error parsing input file (%s: %s)\n", input_file_str->c_str(), chd_file::error_string(err)); |
| 1859 | report_error(1, "Error parsing input file (%s: %s)\n", input_file_str->cstr(), chd_file::error_string(err)); |
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | // process output CHD |
| r245621 | r245622 | |
| 1889 | 1889 | |
| 1890 | 1890 | // print some info |
| 1891 | 1891 | astring tempstr; |
| 1892 | | printf("Output CHD: %s\n", output_chd_str->c_str()); |
| 1892 | printf("Output CHD: %s\n", output_chd_str->cstr()); |
| 1893 | 1893 | if (output_parent.opened()) |
| 1894 | | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->c_str()); |
| 1895 | | printf("Input file: %s\n", input_file_str->c_str()); |
| 1894 | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->cstr()); |
| 1895 | printf("Input file: %s\n", input_file_str->cstr()); |
| 1896 | 1896 | printf("Input tracks: %d\n", toc.numtrks); |
| 1897 | 1897 | printf("Input length: %s\n", msf_string_from_frames(tempstr, origtotalsectors)); |
| 1898 | 1898 | printf("Compression: %s\n", compression_string(tempstr, compression)); |
| r245621 | r245622 | |
| 1910 | 1910 | else |
| 1911 | 1911 | err = chd->create(*output_chd_str, UINT64(totalsectors) * UINT64(CD_FRAME_SIZE), hunk_size, CD_FRAME_SIZE, compression); |
| 1912 | 1912 | if (err != CHDERR_NONE) |
| 1913 | | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->c_str(), chd_file::error_string(err)); |
| 1913 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 1914 | 1914 | |
| 1915 | 1915 | // add the standard CD metadata; we do this even if we have a parent because it might be different |
| 1916 | 1916 | err = cdrom_write_metadata(chd, &toc); |
| r245621 | r245622 | |
| 1947 | 1947 | { |
| 1948 | 1948 | avi_error avierr = avi_open(*input_file_str, &input_file); |
| 1949 | 1949 | if (avierr != AVIERR_NONE) |
| 1950 | | report_error(1, "Error opening AVI file (%s): %s\n", input_file_str->c_str(), avi_error_string(avierr)); |
| 1950 | report_error(1, "Error opening AVI file (%s): %s\n", input_file_str->cstr(), avi_error_string(avierr)); |
| 1951 | 1951 | } |
| 1952 | 1952 | const avi_movie_info *aviinfo = avi_get_movie_info(input_file); |
| 1953 | 1953 | |
| r245621 | r245622 | |
| 1999 | 1999 | |
| 2000 | 2000 | // print some info |
| 2001 | 2001 | astring tempstr; |
| 2002 | | printf("Output CHD: %s\n", output_chd_str->c_str()); |
| 2002 | printf("Output CHD: %s\n", output_chd_str->cstr()); |
| 2003 | 2003 | if (output_parent.opened()) |
| 2004 | | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->c_str()); |
| 2005 | | printf("Input file: %s\n", input_file_str->c_str()); |
| 2004 | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->cstr()); |
| 2005 | printf("Input file: %s\n", input_file_str->cstr()); |
| 2006 | 2006 | if (input_start != 0 && input_end != aviinfo->video_numsamples) |
| 2007 | 2007 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| 2008 | 2008 | printf("Input length: %s (%02d:%02d:%02d)\n", big_int_string(tempstr, input_end - input_start), |
| r245621 | r245622 | |
| 2028 | 2028 | else |
| 2029 | 2029 | err = chd->create(*output_chd_str, UINT64(input_end - input_start) * hunk_size, hunk_size, info.bytes_per_frame, compression); |
| 2030 | 2030 | if (err != CHDERR_NONE) |
| 2031 | | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->c_str(), chd_file::error_string(err)); |
| 2031 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 2032 | 2032 | |
| 2033 | 2033 | // write the core A/V metadata |
| 2034 | 2034 | astring metadata; |
| r245621 | r245622 | |
| 2112 | 2112 | |
| 2113 | 2113 | // print some info |
| 2114 | 2114 | astring tempstr; |
| 2115 | | printf("Output CHD: %s\n", output_chd_str->c_str()); |
| 2115 | printf("Output CHD: %s\n", output_chd_str->cstr()); |
| 2116 | 2116 | if (output_parent.opened()) |
| 2117 | | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->c_str()); |
| 2118 | | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2117 | printf("Parent CHD: %s\n", params.find(OPTION_OUTPUT_PARENT)->cstr()); |
| 2118 | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2119 | 2119 | if (input_start != 0 || input_end != input_chd.logical_bytes()) |
| 2120 | 2120 | { |
| 2121 | 2121 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| r245621 | r245622 | |
| 2137 | 2137 | else |
| 2138 | 2138 | err = chd->create(*output_chd_str, input_end - input_start, hunk_size, input_chd.unit_bytes(), compression); |
| 2139 | 2139 | if (err != CHDERR_NONE) |
| 2140 | | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->c_str(), chd_file::error_string(err)); |
| 2140 | report_error(1, "Error creating CHD file (%s): %s", output_chd_str->cstr(), chd_file::error_string(err)); |
| 2141 | 2141 | |
| 2142 | 2142 | // clone all the metadata, upgrading where appropriate |
| 2143 | 2143 | dynamic_buffer metadata; |
| r245621 | r245622 | |
| 2221 | 2221 | |
| 2222 | 2222 | // print some info |
| 2223 | 2223 | astring tempstr; |
| 2224 | | printf("Output File: %s\n", output_file_str->c_str()); |
| 2225 | | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2224 | printf("Output File: %s\n", output_file_str->cstr()); |
| 2225 | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2226 | 2226 | if (input_start != 0 || input_end != input_chd.logical_bytes()) |
| 2227 | 2227 | { |
| 2228 | 2228 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| r245621 | r245622 | |
| 2236 | 2236 | // process output file |
| 2237 | 2237 | file_error filerr = core_fopen(*output_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &output_file); |
| 2238 | 2238 | if (filerr != FILERR_NONE) |
| 2239 | | report_error(1, "Unable to open file (%s)", output_file_str->c_str()); |
| 2239 | report_error(1, "Unable to open file (%s)", output_file_str->cstr()); |
| 2240 | 2240 | |
| 2241 | 2241 | // copy all data |
| 2242 | 2242 | dynamic_buffer buffer((TEMP_BUFFER_SIZE / input_chd.hunk_bytes()) * input_chd.hunk_bytes()); |
| r245621 | r245622 | |
| 2248 | 2248 | UINT32 bytes_to_read = MIN((UINT32)buffer.count(), input_end - offset); |
| 2249 | 2249 | chd_error err = input_chd.read_bytes(offset, buffer, bytes_to_read); |
| 2250 | 2250 | if (err != CHDERR_NONE) |
| 2251 | | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->c_str(), chd_file::error_string(err)); |
| 2251 | report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err)); |
| 2252 | 2252 | |
| 2253 | 2253 | // write to the output |
| 2254 | 2254 | UINT32 count = core_fwrite(output_file, buffer, bytes_to_read); |
| 2255 | 2255 | if (count != bytes_to_read) |
| 2256 | | report_error(1, "Error writing to file; check disk space (%s)", output_file_str->c_str()); |
| 2256 | report_error(1, "Error writing to file; check disk space (%s)", output_file_str->cstr()); |
| 2257 | 2257 | |
| 2258 | 2258 | // advance |
| 2259 | 2259 | offset += bytes_to_read; |
| r245621 | r245622 | |
| 2306 | 2306 | if (chop != -1) |
| 2307 | 2307 | default_name.substr(0, chop); |
| 2308 | 2308 | char basename[128]; |
| 2309 | | strncpy(basename, default_name.c_str(), 127); |
| 2309 | strncpy(basename, default_name.cstr(), 127); |
| 2310 | 2310 | default_name.cat(".bin"); |
| 2311 | 2311 | if (output_bin_file_str == NULL) |
| 2312 | 2312 | output_bin_file_str = &default_name; |
| r245621 | r245622 | |
| 2314 | 2314 | |
| 2315 | 2315 | // print some info |
| 2316 | 2316 | astring tempstr; |
| 2317 | | printf("Output TOC: %s\n", output_file_str->c_str()); |
| 2318 | | printf("Output Data: %s\n", output_bin_file_str->c_str()); |
| 2319 | | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2317 | printf("Output TOC: %s\n", output_file_str->cstr()); |
| 2318 | printf("Output Data: %s\n", output_bin_file_str->cstr()); |
| 2319 | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2320 | 2320 | |
| 2321 | 2321 | // catch errors so we can close & delete the output file |
| 2322 | 2322 | core_file *output_bin_file = NULL; |
| r245621 | r245622 | |
| 2337 | 2337 | // process output file |
| 2338 | 2338 | file_error filerr = core_fopen(*output_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_NO_BOM, &output_toc_file); |
| 2339 | 2339 | if (filerr != FILERR_NONE) |
| 2340 | | report_error(1, "Unable to open file (%s)", output_file_str->c_str()); |
| 2340 | report_error(1, "Unable to open file (%s)", output_file_str->cstr()); |
| 2341 | 2341 | |
| 2342 | 2342 | // process output BIN file |
| 2343 | 2343 | if (mode != MODE_GDI) |
| 2344 | 2344 | { |
| 2345 | 2345 | filerr = core_fopen(*output_bin_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &output_bin_file); |
| 2346 | 2346 | if (filerr != FILERR_NONE) |
| 2347 | | report_error(1, "Unable to open file (%s)", output_bin_file_str->c_str()); |
| 2347 | report_error(1, "Unable to open file (%s)", output_bin_file_str->cstr()); |
| 2348 | 2348 | } |
| 2349 | 2349 | |
| 2350 | 2350 | // determine total frames |
| r245621 | r245622 | |
| 2384 | 2384 | |
| 2385 | 2385 | filerr = core_fopen(trackbin_name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &output_bin_file); |
| 2386 | 2386 | if (filerr != FILERR_NONE) |
| 2387 | | report_error(1, "Unable to open file (%s)", trackbin_name.c_str()); |
| 2387 | report_error(1, "Unable to open file (%s)", trackbin_name.cstr()); |
| 2388 | 2388 | |
| 2389 | 2389 | outputoffs = 0; |
| 2390 | 2390 | } |
| r245621 | r245622 | |
| 2449 | 2449 | core_fseek(output_bin_file, outputoffs, SEEK_SET); |
| 2450 | 2450 | UINT32 byteswritten = core_fwrite(output_bin_file, buffer, bufferoffs); |
| 2451 | 2451 | if (byteswritten != bufferoffs) |
| 2452 | | report_error(1, "Error writing frame %d to file (%s): %s\n", frame, output_file_str->c_str(), chd_file::error_string(CHDERR_WRITE_ERROR)); |
| 2452 | report_error(1, "Error writing frame %d to file (%s): %s\n", frame, output_file_str->cstr(), chd_file::error_string(CHDERR_WRITE_ERROR)); |
| 2453 | 2453 | outputoffs += bufferoffs; |
| 2454 | 2454 | bufferoffs = 0; |
| 2455 | 2455 | } |
| r245621 | r245622 | |
| 2548 | 2548 | |
| 2549 | 2549 | // print some info |
| 2550 | 2550 | astring tempstr; |
| 2551 | | printf("Output File: %s\n", output_file_str->c_str()); |
| 2552 | | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2551 | printf("Output File: %s\n", output_file_str->cstr()); |
| 2552 | printf("Input CHD: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2553 | 2553 | if (input_start != 0 || input_end != input_chd.hunk_count()) |
| 2554 | 2554 | { |
| 2555 | 2555 | printf("Input start: %s\n", big_int_string(tempstr, input_start)); |
| r245621 | r245622 | |
| 2563 | 2563 | // process output file |
| 2564 | 2564 | avi_error avierr = avi_create(*output_file_str, &info, &output_file); |
| 2565 | 2565 | if (avierr != AVIERR_NONE) |
| 2566 | | report_error(1, "Unable to open file (%s)", output_file_str->c_str()); |
| 2566 | report_error(1, "Unable to open file (%s)", output_file_str->cstr()); |
| 2567 | 2567 | |
| 2568 | 2568 | // create the codec configuration |
| 2569 | 2569 | avhuff_decompress_config avconfig; |
| r245621 | r245622 | |
| 2592 | 2592 | if (err != CHDERR_NONE) |
| 2593 | 2593 | { |
| 2594 | 2594 | UINT64 filepos = core_ftell(input_chd); |
| 2595 | | report_error(1, "Error reading hunk %" I64FMT "d at offset %" I64FMT "d from CHD file (%s): %s\n", framenum, filepos, params.find(OPTION_INPUT)->c_str(), chd_file::error_string(err)); |
| 2595 | report_error(1, "Error reading hunk %" I64FMT "d at offset %" I64FMT "d from CHD file (%s): %s\n", framenum, filepos, params.find(OPTION_INPUT)->cstr(), chd_file::error_string(err)); |
| 2596 | 2596 | } |
| 2597 | 2597 | |
| 2598 | 2598 | // write audio |
| r245621 | r245622 | |
| 2600 | 2600 | { |
| 2601 | 2601 | avi_error avierr = avi_append_sound_samples(output_file, chnum, avconfig.audio[chnum], actsamples, 0); |
| 2602 | 2602 | if (avierr != AVIERR_NONE) |
| 2603 | | report_error(1, "Error writing samples for hunk %" I64FMT "d to file (%s): %s\n", framenum, output_file_str->c_str(), avi_error_string(avierr)); |
| 2603 | report_error(1, "Error writing samples for hunk %" I64FMT "d to file (%s): %s\n", framenum, output_file_str->cstr(), avi_error_string(avierr)); |
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | // write video |
| r245621 | r245622 | |
| 2608 | 2608 | { |
| 2609 | 2609 | avi_error avierr = avi_append_video_frame(output_file, fullbitmap); |
| 2610 | 2610 | if (avierr != AVIERR_NONE) |
| 2611 | | report_error(1, "Error writing video for hunk %" I64FMT "d to file (%s): %s\n", framenum, output_file_str->c_str(), avi_error_string(avierr)); |
| 2611 | report_error(1, "Error writing video for hunk %" I64FMT "d to file (%s): %s\n", framenum, output_file_str->cstr(), avi_error_string(avierr)); |
| 2612 | 2612 | } |
| 2613 | 2613 | } |
| 2614 | 2614 | |
| r245621 | r245622 | |
| 2671 | 2671 | { |
| 2672 | 2672 | file_error filerr = core_fload(*file_str, file); |
| 2673 | 2673 | if (filerr != FILERR_NONE) |
| 2674 | | report_error(1, "Error reading metadata file (%s)", file_str->c_str()); |
| 2674 | report_error(1, "Error reading metadata file (%s)", file_str->cstr()); |
| 2675 | 2675 | } |
| 2676 | 2676 | |
| 2677 | 2677 | // make sure we have one or the other |
| r245621 | r245622 | |
| 2687 | 2687 | |
| 2688 | 2688 | // print some info |
| 2689 | 2689 | astring tempstr; |
| 2690 | | printf("Input file: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2690 | printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2691 | 2691 | printf("Tag: %c%c%c%c\n", (tag >> 24) & 0xff, (tag >> 16) & 0xff, (tag >> 8) & 0xff, tag & 0xff); |
| 2692 | 2692 | printf("Index: %d\n", index); |
| 2693 | 2693 | if (text_str != NULL) |
| 2694 | | printf("Text: %s\n", text.c_str()); |
| 2694 | printf("Text: %s\n", text.cstr()); |
| 2695 | 2695 | else |
| 2696 | | printf("Data: %s (%d bytes)\n", file_str->c_str(), file.count()); |
| 2696 | printf("Data: %s (%d bytes)\n", file_str->cstr(), file.count()); |
| 2697 | 2697 | |
| 2698 | 2698 | // write the metadata |
| 2699 | 2699 | chd_error err; |
| r245621 | r245622 | |
| 2736 | 2736 | |
| 2737 | 2737 | // print some info |
| 2738 | 2738 | astring tempstr; |
| 2739 | | printf("Input file: %s\n", params.find(OPTION_INPUT)->c_str()); |
| 2739 | printf("Input file: %s\n", params.find(OPTION_INPUT)->cstr()); |
| 2740 | 2740 | printf("Tag: %c%c%c%c\n", (tag >> 24) & 0xff, (tag >> 16) & 0xff, (tag >> 8) & 0xff, tag & 0xff); |
| 2741 | 2741 | printf("Index: %d\n", index); |
| 2742 | 2742 | |
| r245621 | r245622 | |
| 2795 | 2795 | { |
| 2796 | 2796 | file_error filerr = core_fopen(*output_file_str, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &output_file); |
| 2797 | 2797 | if (filerr != FILERR_NONE) |
| 2798 | | report_error(1, "Unable to open file (%s)", output_file_str->c_str()); |
| 2798 | report_error(1, "Unable to open file (%s)", output_file_str->cstr()); |
| 2799 | 2799 | |
| 2800 | 2800 | // output the metadata |
| 2801 | 2801 | UINT32 count = core_fwrite(output_file, buffer, buffer.count()); |
| 2802 | 2802 | if (count != buffer.count()) |
| 2803 | | report_error(1, "Error writing file (%s)", output_file_str->c_str()); |
| 2803 | report_error(1, "Error writing file (%s)", output_file_str->cstr()); |
| 2804 | 2804 | core_fclose(output_file); |
| 2805 | 2805 | |
| 2806 | 2806 | // provide some feedback |
| 2807 | 2807 | astring tempstr; |
| 2808 | | printf("File (%s) written, %s bytes\n", output_file_str->c_str(), big_int_string(tempstr, buffer.count())); |
| 2808 | printf("File (%s) written, %s bytes\n", output_file_str->cstr(), big_int_string(tempstr, buffer.count())); |
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | 2811 | // flush to stdout |
trunk/src/tools/src2html.c
| r245621 | r245622 | |
| 332 | 332 | |
| 333 | 333 | // create an index file |
| 334 | 334 | astring indexname; |
| 335 | | indexname.printf("%s%c%s", dstdir.c_str(), PATH_SEPARATOR[0], "index.html"); |
| 335 | indexname.printf("%s%c%s", dstdir.cstr(), PATH_SEPARATOR[0], "index.html"); |
| 336 | 336 | core_file *indexfile = create_file_and_output_header(indexname, tempheader, srcdir_subpath); |
| 337 | 337 | |
| 338 | 338 | // output the directory navigation |
| r245621 | r245622 | |
| 402 | 402 | |
| 403 | 403 | // build the source filename |
| 404 | 404 | astring srcfile; |
| 405 | | srcfile.printf("%s%c%s", srcdir.c_str(), PATH_SEPARATOR[0], curlist->name.c_str()); |
| 405 | srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr()); |
| 406 | 406 | |
| 407 | 407 | // if we have a file, output it |
| 408 | 408 | astring dstfile; |
| r245621 | r245622 | |
| 420 | 420 | // if we got a valid file, process it |
| 421 | 421 | if (type != FILE_TYPE_INVALID) |
| 422 | 422 | { |
| 423 | | dstfile.printf("%s%c%s.html", dstdir.c_str(), PATH_SEPARATOR[0], curlist->name.c_str()); |
| 423 | dstfile.printf("%s%c%s.html", dstdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr()); |
| 424 | 424 | if (indexfile != NULL) |
| 425 | | core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", curlist->name.c_str(), curlist->name.c_str()); |
| 425 | core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", curlist->name.cstr(), curlist->name.cstr()); |
| 426 | 426 | result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, srcdir == dstdir, tempheader, tempfooter); |
| 427 | 427 | } |
| 428 | 428 | } |
| r245621 | r245622 | |
| 430 | 430 | // if we have a directory, recurse |
| 431 | 431 | else |
| 432 | 432 | { |
| 433 | | dstfile.printf("%s%c%s", dstdir.c_str(), PATH_SEPARATOR[0], curlist->name.c_str()); |
| 433 | dstfile.printf("%s%c%s", dstdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr()); |
| 434 | 434 | if (indexfile != NULL) |
| 435 | | core_fprintf(indexfile, "\t<li><a href=\"%s/index.html\">%s/</a></li>\n", curlist->name.c_str(), curlist->name.c_str()); |
| 435 | core_fprintf(indexfile, "\t<li><a href=\"%s/index.html\">%s/</a></li>\n", curlist->name.cstr(), curlist->name.cstr()); |
| 436 | 436 | result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile, tempheader, tempfooter); |
| 437 | 437 | } |
| 438 | 438 | } |
| r245621 | r245622 | |
| 467 | 467 | astring srcfile_subpath; |
| 468 | 468 | normalized_subpath(srcfile_subpath, srcfile, srcrootlen + 1); |
| 469 | 469 | |
| 470 | | fprintf(stderr, "Processing %s\n", srcfile_subpath.c_str()); |
| 470 | fprintf(stderr, "Processing %s\n", srcfile_subpath.cstr()); |
| 471 | 471 | |
| 472 | 472 | // set some defaults |
| 473 | 473 | bool color_quotes = false; |
| r245621 | r245622 | |
| 519 | 519 | core_file *src; |
| 520 | 520 | if (core_fopen(srcfile, OPEN_FLAG_READ, &src) != FILERR_NONE) |
| 521 | 521 | { |
| 522 | | fprintf(stderr, "Unable to read file '%s'\n", srcfile.c_str()); |
| 522 | fprintf(stderr, "Unable to read file '%s'\n", srcfile.cstr()); |
| 523 | 523 | return 1; |
| 524 | 524 | } |
| 525 | 525 | |
| r245621 | r245622 | |
| 527 | 527 | core_file *dst = create_file_and_output_header(dstfile, tempheader, srcfile_subpath); |
| 528 | 528 | if (dst == NULL) |
| 529 | 529 | { |
| 530 | | fprintf(stderr, "Unable to write file '%s'\n", dstfile.c_str()); |
| 530 | fprintf(stderr, "Unable to write file '%s'\n", dstfile.cstr()); |
| 531 | 531 | core_fclose(src); |
| 532 | 532 | return 1; |
| 533 | 533 | } |
| r245621 | r245622 | |
| 659 | 659 | astring target; |
| 660 | 660 | if (find_include_file(target, srcrootlen, dstrootlen, srcfile, dstfile, filename)) |
| 661 | 661 | { |
| 662 | | dstline.catprintf("<a href=\"%s\">", target.c_str()); |
| 662 | dstline.catprintf("<a href=\"%s\">", target.cstr()); |
| 663 | 663 | quotes_are_linked = true; |
| 664 | 664 | } |
| 665 | 665 | } |
| r245621 | r245622 | |
| 738 | 738 | |
| 739 | 739 | // print a header |
| 740 | 740 | astring modified(templatefile); |
| 741 | | modified.replace(0, "<!--PATH-->", path.c_str()); |
| 742 | | core_fwrite(file, modified.c_str(), modified.len()); |
| 741 | modified.replace(0, "<!--PATH-->", path.cstr()); |
| 742 | core_fwrite(file, modified.cstr(), modified.len()); |
| 743 | 743 | |
| 744 | 744 | // return the file |
| 745 | 745 | return file; |
| r245621 | r245622 | |
| 754 | 754 | static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &path) |
| 755 | 755 | { |
| 756 | 756 | astring modified(templatefile); |
| 757 | | modified.replace(0, "<!--PATH-->", path.c_str()); |
| 758 | | core_fwrite(file, modified.c_str(), modified.len()); |
| 757 | modified.replace(0, "<!--PATH-->", path.cstr()); |
| 758 | core_fwrite(file, modified.cstr(), modified.len()); |
| 759 | 759 | core_fclose(file); |
| 760 | 760 | } |
| 761 | 761 | |
| r245621 | r245622 | |
| 807 | 807 | core_fprintf(file, "<a href=\""); |
| 808 | 808 | for (int depth = curdepth; depth < srcdepth; depth++) |
| 809 | 809 | core_fprintf(file, "../"); |
| 810 | | core_fprintf(file, "index.html\">%s</a>/", substr.c_str()); |
| 810 | core_fprintf(file, "index.html\">%s</a>/", substr.cstr()); |
| 811 | 811 | |
| 812 | 812 | lastslash = slashindex + 1; |
| 813 | 813 | } |
| r245621 | r245622 | |
| 815 | 815 | // and a final link to the current directory |
| 816 | 816 | astring substr(path, lastslash, -1); |
| 817 | 817 | if (end_is_directory) |
| 818 | | core_fprintf(file, "<a href=\"index.html\">%s</a>", substr.c_str()); |
| 818 | core_fprintf(file, "<a href=\"index.html\">%s</a>", substr.cstr()); |
| 819 | 819 | else if (link_to_file) |
| 820 | | core_fprintf(file, "<a href=\"%s\">%s</a>", substr.c_str(), substr.c_str()); |
| 820 | core_fprintf(file, "<a href=\"%s\">%s</a>", substr.cstr(), substr.cstr()); |
| 821 | 821 | else |
| 822 | | core_fprintf(file, "<a href=\"%s.html\">%s</a>", substr.c_str(), substr.c_str()); |
| 822 | core_fprintf(file, "<a href=\"%s.html\">%s</a>", substr.cstr(), substr.cstr()); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | |