src/mess/drivers/vc4000.c
| r15291 | r15292 | |
| 86 | 86 | The Select key (Z) and the joystick don't actually exist, but I've left them |
| 87 | 87 | in the keyboard matrix for now. |
| 88 | 88 | |
| 89 | |
| 90 | Quickloads |
| 91 | ---------- |
| 92 | You can load pgm and tvc files with the quickload facility. The quickloads |
| 93 | are meant for the ElektorTVGC, however with a bit a trickery they can be made |
| 94 | to work on the vc4000 as well. Procedure: |
| 95 | |
| 96 | - Get a copy of the Elektor bios and rename it to ELEKTOR.BIN then save it |
| 97 | with the rest of your vc4000 carts. |
| 98 | |
| 99 | - Start vc4000, and load ELEKTOR.BIN into the cartslot. Now your vc4000 |
| 100 | thinks it is an Elektor. |
| 101 | |
| 102 | - Load a quickload file. Some of them will work, and in some cases, better |
| 103 | than on the Elektor system. |
| 104 | |
| 89 | 105 | ******************************************************************************/ |
| 90 | 106 | |
| 91 | 107 | #include "includes/vc4000.h" |
| r15291 | r15292 | |
| 396 | 412 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 397 | 413 | |
| 398 | 414 | /* quickload */ |
| 399 | | MCFG_QUICKLOAD_ADD("quickload", vc4000, "tvc", 0) |
| 415 | MCFG_QUICKLOAD_ADD("quickload", vc4000, "pgm,tvc", 0) |
| 400 | 416 | |
| 401 | 417 | /* cartridge */ |
| 402 | 418 | MCFG_CARTSLOT_ADD("cart") |
| r15291 | r15292 | |
| 527 | 543 | quick_length = image.length(); |
| 528 | 544 | quick_data = (UINT8*)malloc(quick_length); |
| 529 | 545 | if (!quick_data) |
| 546 | { |
| 547 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 548 | image.message(" Cannot open file"); |
| 530 | 549 | return IMAGE_INIT_FAIL; |
| 550 | } |
| 531 | 551 | |
| 532 | 552 | read_ = image.fread( quick_data, quick_length); |
| 533 | 553 | if (read_ != quick_length) |
| 554 | { |
| 555 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 556 | image.message(" Cannot read the file"); |
| 534 | 557 | return IMAGE_INIT_FAIL; |
| 558 | } |
| 535 | 559 | |
| 536 | | if (quick_data[0] != 2) |
| 537 | | return IMAGE_INIT_FAIL; |
| 560 | if (mame_stricmp(image.filetype(), "tvc")==0) |
| 561 | { |
| 562 | if (quick_data[0] != 2) |
| 563 | { |
| 564 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 565 | image.message(" Invalid header"); |
| 566 | return IMAGE_INIT_FAIL; |
| 567 | } |
| 538 | 568 | |
| 539 | | quick_addr = quick_data[1] * 256 + quick_data[2]; |
| 540 | | exec_addr = quick_data[3] * 256 + quick_data[4]; |
| 569 | quick_addr = quick_data[1] * 256 + quick_data[2]; |
| 570 | exec_addr = quick_data[3] * 256 + quick_data[4]; |
| 541 | 571 | |
| 542 | | //if ((quick_addr + quick_length - 5) > 0x1000) |
| 543 | | // return IMAGE_INIT_FAIL; |
| 572 | space->write_byte(0x08be, quick_data[3]); |
| 573 | space->write_byte(0x08bf, quick_data[4]); |
| 544 | 574 | |
| 545 | | space->write_byte(0x08be, quick_data[3]); |
| 546 | | space->write_byte(0x08bf, quick_data[4]); |
| 575 | for (i = 0; i < quick_length - 5; i++) |
| 576 | if ((quick_addr + i) < 0x1600) |
| 577 | space->write_byte(i + quick_addr, quick_data[i+5]); |
| 547 | 578 | |
| 548 | | for (i = 0; i < quick_length - 5; i++) |
| 549 | | { if ((quick_addr + i) < 0x1000) |
| 550 | | space->write_byte(i + quick_addr, quick_data[i+5]); |
| 579 | /* display a message about the loaded quickload */ |
| 580 | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); |
| 581 | |
| 582 | // Start the quickload |
| 583 | cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr); |
| 584 | return IMAGE_INIT_PASS; |
| 551 | 585 | } |
| 586 | else |
| 587 | if (mame_stricmp(image.filetype(), "pgm")==0) |
| 588 | { |
| 589 | if (quick_data[0] != 0) |
| 590 | { |
| 591 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 592 | image.message(" Invalid header"); |
| 593 | return IMAGE_INIT_FAIL; |
| 594 | } |
| 552 | 595 | |
| 553 | | /* display a message about the loaded quickload */ |
| 554 | | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); |
| 596 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 555 | 597 | |
| 556 | | // Start the quickload (only does something on Elektor) |
| 557 | | cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr); |
| 558 | | return IMAGE_INIT_PASS; |
| 598 | if (exec_addr >= quick_length) |
| 599 | { |
| 600 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 601 | image.message(" Exec address beyond end of file"); |
| 602 | return IMAGE_INIT_FAIL; |
| 603 | } |
| 604 | |
| 605 | if (quick_length < 0x904) |
| 606 | { |
| 607 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 608 | image.message(" File too short"); |
| 609 | return IMAGE_INIT_FAIL; |
| 610 | } |
| 611 | |
| 612 | // some programs store data in PVI memory and other random places. This is not supported. |
| 613 | if (quick_length > 0x1600) |
| 614 | { |
| 615 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 616 | image.message(" File too long"); |
| 617 | return IMAGE_INIT_FAIL; |
| 618 | } |
| 619 | |
| 620 | for (i = quick_addr; i < quick_length; i++) |
| 621 | if (i < 0x1600) |
| 622 | space->write_byte(i, quick_data[i]); |
| 623 | |
| 624 | /* display a message about the loaded quickload */ |
| 625 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 626 | |
| 627 | // Start the quickload |
| 628 | cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, exec_addr); |
| 629 | return IMAGE_INIT_PASS; |
| 630 | } |
| 631 | else |
| 632 | return IMAGE_INIT_FAIL; |
| 559 | 633 | } |
| 560 | 634 | |
| 561 | 635 | |