trunk/src/mess/drivers/vc4000.c
| r22585 | r22586 | |
| 533 | 533 | int quick_length; |
| 534 | 534 | UINT8 *quick_data; |
| 535 | 535 | int read_; |
| 536 | int result = IMAGE_INIT_FAIL; |
| 536 | 537 | |
| 537 | 538 | quick_length = image.length(); |
| 538 | 539 | quick_data = (UINT8*)malloc(quick_length); |
| r22585 | r22586 | |
| 540 | 541 | { |
| 541 | 542 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 542 | 543 | image.message(" Cannot open file"); |
| 543 | | return IMAGE_INIT_FAIL; |
| 544 | 544 | } |
| 545 | | |
| 546 | | read_ = image.fread( quick_data, quick_length); |
| 547 | | if (read_ != quick_length) |
| 545 | else |
| 548 | 546 | { |
| 549 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 550 | | image.message(" Cannot read the file"); |
| 551 | | return IMAGE_INIT_FAIL; |
| 552 | | } |
| 553 | | |
| 554 | | if (mame_stricmp(image.filetype(), "tvc")==0) |
| 555 | | { |
| 556 | | if (quick_data[0] != 2) |
| 547 | read_ = image.fread( quick_data, quick_length); |
| 548 | if (read_ != quick_length) |
| 557 | 549 | { |
| 558 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 559 | | image.message(" Invalid header"); |
| 560 | | return IMAGE_INIT_FAIL; |
| 550 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 551 | image.message(" Cannot read the file"); |
| 561 | 552 | } |
| 553 | else |
| 554 | { |
| 555 | if (mame_stricmp(image.filetype(), "tvc")==0) |
| 556 | { |
| 557 | if (quick_data[0] != 2) |
| 558 | { |
| 559 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 560 | image.message(" Invalid header"); |
| 561 | } |
| 562 | else |
| 563 | { |
| 564 | quick_addr = quick_data[1] * 256 + quick_data[2]; |
| 565 | exec_addr = quick_data[3] * 256 + quick_data[4]; |
| 562 | 566 | |
| 563 | | quick_addr = quick_data[1] * 256 + quick_data[2]; |
| 564 | | exec_addr = quick_data[3] * 256 + quick_data[4]; |
| 567 | space.write_byte(0x08be, quick_data[3]); |
| 568 | space.write_byte(0x08bf, quick_data[4]); |
| 565 | 569 | |
| 566 | | space.write_byte(0x08be, quick_data[3]); |
| 567 | | space.write_byte(0x08bf, quick_data[4]); |
| 570 | for (i = 0; i < quick_length - 5; i++) |
| 571 | if ((quick_addr + i) < 0x1600) |
| 572 | space.write_byte(i + quick_addr, quick_data[i+5]); |
| 568 | 573 | |
| 569 | | for (i = 0; i < quick_length - 5; i++) |
| 570 | | if ((quick_addr + i) < 0x1600) |
| 571 | | space.write_byte(i + quick_addr, quick_data[i+5]); |
| 574 | /* display a message about the loaded quickload */ |
| 575 | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); |
| 572 | 576 | |
| 573 | | /* display a message about the loaded quickload */ |
| 574 | | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length-5,quick_addr,quick_addr+quick_length-5,exec_addr); |
| 577 | // Start the quickload |
| 578 | m_maincpu->set_pc(exec_addr); |
| 579 | result = IMAGE_INIT_PASS; |
| 580 | } |
| 581 | } |
| 582 | else |
| 583 | if (mame_stricmp(image.filetype(), "pgm")==0) |
| 584 | { |
| 585 | if (quick_data[0] != 0) |
| 586 | { |
| 587 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 588 | image.message(" Invalid header"); |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 575 | 593 | |
| 576 | | // Start the quickload |
| 577 | | m_maincpu->set_pc(exec_addr); |
| 578 | | return IMAGE_INIT_PASS; |
| 579 | | } |
| 580 | | else |
| 581 | | if (mame_stricmp(image.filetype(), "pgm")==0) |
| 582 | | { |
| 583 | | if (quick_data[0] != 0) |
| 584 | | { |
| 585 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 586 | | image.message(" Invalid header"); |
| 587 | | return IMAGE_INIT_FAIL; |
| 588 | | } |
| 594 | if (exec_addr >= quick_length) |
| 595 | { |
| 596 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 597 | image.message(" Exec address beyond end of file"); |
| 598 | } |
| 599 | else |
| 600 | if (quick_length < 0x904) |
| 601 | { |
| 602 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 603 | image.message(" File too short"); |
| 604 | } |
| 605 | else |
| 606 | // some programs store data in PVI memory and other random places. This is not supported. |
| 607 | if (quick_length > 0x1600) |
| 608 | { |
| 609 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 610 | image.message(" File too long"); |
| 611 | } |
| 612 | else |
| 613 | { |
| 614 | for (i = quick_addr; i < quick_length; i++) |
| 615 | if (i < 0x1600) |
| 616 | space.write_byte(i, quick_data[i]); |
| 589 | 617 | |
| 590 | | exec_addr = quick_data[1] * 256 + quick_data[2]; |
| 618 | /* display a message about the loaded quickload */ |
| 619 | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 591 | 620 | |
| 592 | | if (exec_addr >= quick_length) |
| 593 | | { |
| 594 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Exec address beyond end of file"); |
| 595 | | image.message(" Exec address beyond end of file"); |
| 596 | | return IMAGE_INIT_FAIL; |
| 621 | // Start the quickload |
| 622 | m_maincpu->set_pc(exec_addr); |
| 623 | result = IMAGE_INIT_PASS; |
| 624 | } |
| 625 | } |
| 626 | } |
| 597 | 627 | } |
| 598 | | |
| 599 | | if (quick_length < 0x904) |
| 600 | | { |
| 601 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short"); |
| 602 | | image.message(" File too short"); |
| 603 | | return IMAGE_INIT_FAIL; |
| 604 | | } |
| 605 | | |
| 606 | | // some programs store data in PVI memory and other random places. This is not supported. |
| 607 | | if (quick_length > 0x1600) |
| 608 | | { |
| 609 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too long"); |
| 610 | | image.message(" File too long"); |
| 611 | | return IMAGE_INIT_FAIL; |
| 612 | | } |
| 613 | | |
| 614 | | for (i = quick_addr; i < quick_length; i++) |
| 615 | | if (i < 0x1600) |
| 616 | | space.write_byte(i, quick_data[i]); |
| 617 | | |
| 618 | | /* display a message about the loaded quickload */ |
| 619 | | image.message(" Quickload: size=%04X : exec=%04X",quick_length,exec_addr); |
| 620 | | |
| 621 | | // Start the quickload |
| 622 | | m_maincpu->set_pc(exec_addr); |
| 623 | | return IMAGE_INIT_PASS; |
| 628 | free (quick_data); |
| 624 | 629 | } |
| 625 | | else |
| 626 | | return IMAGE_INIT_FAIL; |
| 630 | return result; |
| 627 | 631 | } |
| 628 | 632 | |
| 629 | 633 | |
trunk/src/mess/drivers/d6800.c
| r22585 | r22586 | |
| 338 | 338 | { |
| 339 | 339 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 340 | 340 | int i; |
| 341 | | int quick_addr = 0x0200; |
| 341 | int quick_addr = 0x200; |
| 342 | 342 | int exec_addr = 0xc000; |
| 343 | 343 | int quick_length; |
| 344 | 344 | UINT8 *quick_data; |
| 345 | 345 | int read_; |
| 346 | int result = IMAGE_INIT_FAIL; |
| 346 | 347 | |
| 347 | 348 | quick_length = image.length(); |
| 348 | 349 | quick_data = (UINT8*)malloc(quick_length); |
| r22585 | r22586 | |
| 350 | 351 | { |
| 351 | 352 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 352 | 353 | image.message(" Cannot open file"); |
| 353 | | return IMAGE_INIT_FAIL; |
| 354 | 354 | } |
| 355 | | |
| 356 | | read_ = image.fread( quick_data, quick_length); |
| 357 | | if (read_ != quick_length) |
| 355 | else |
| 358 | 356 | { |
| 359 | | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 360 | | image.message(" Cannot read the file"); |
| 361 | | return IMAGE_INIT_FAIL; |
| 362 | | } |
| 357 | read_ = image.fread( quick_data, quick_length); |
| 358 | if (read_ != quick_length) |
| 359 | { |
| 360 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 361 | image.message(" Cannot read the file"); |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | for (i = 0; i < quick_length; i++) |
| 366 | if ((quick_addr + i) < 0x800) |
| 367 | space.write_byte(i + quick_addr, quick_data[i]); |
| 363 | 368 | |
| 364 | | for (i = 0; i < quick_length; i++) |
| 365 | | if ((quick_addr + i) < 0x800) |
| 366 | | space.write_byte(i + quick_addr, quick_data[i]); |
| 369 | /* display a message about the loaded quickload */ |
| 370 | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length,quick_addr,quick_addr+quick_length,exec_addr); |
| 367 | 371 | |
| 368 | | /* display a message about the loaded quickload */ |
| 369 | | image.message(" Quickload: size=%04X : start=%04X : end=%04X : exec=%04X",quick_length,quick_addr,quick_addr+quick_length,exec_addr); |
| 372 | // Start the quickload |
| 373 | m_maincpu->set_pc(exec_addr); |
| 370 | 374 | |
| 371 | | // Start the quickload |
| 372 | | m_maincpu->set_pc(exec_addr); |
| 373 | | return IMAGE_INIT_PASS; |
| 375 | result = IMAGE_INIT_PASS; |
| 376 | } |
| 377 | |
| 378 | free( quick_data ); |
| 379 | } |
| 380 | |
| 381 | return result; |
| 374 | 382 | } |
| 375 | 383 | |
| 376 | 384 | static MACHINE_CONFIG_START( d6800, d6800_state ) |
trunk/src/mess/drivers/homelab.c
| r22585 | r22586 | |
| 10 | 10 | |
| 11 | 11 | ToDO: |
| 12 | 12 | - HTP files should be a cassette format, not a quickload. |
| 13 | - Quickloads cause the emulated machine to hang or reboot. |
| 13 | 14 | - homelab2 - cassette to fix. |
| 14 | 15 | Note that rom code 0x40-48 is meaningless garbage, |
| 15 | 16 | had to patch to stop it crashing. Need a new dump. |
| r22585 | r22586 | |
| 661 | 662 | { |
| 662 | 663 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 663 | 664 | image.message(" Cannot open file"); |
| 665 | free(quick_data); |
| 664 | 666 | return IMAGE_INIT_FAIL; |
| 665 | 667 | } |
| 666 | 668 | |
| r22585 | r22586 | |
| 669 | 671 | { |
| 670 | 672 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 671 | 673 | image.message(" Cannot read the file"); |
| 674 | free(quick_data); |
| 672 | 675 | return IMAGE_INIT_FAIL; |
| 673 | 676 | } |
| 674 | 677 | |
| r22585 | r22586 | |
| 678 | 681 | { |
| 679 | 682 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 680 | 683 | image.message(" Invalid header"); |
| 684 | free(quick_data); |
| 681 | 685 | return IMAGE_INIT_FAIL; |
| 682 | 686 | } |
| 683 | 687 | |
| r22585 | r22586 | |
| 687 | 691 | { |
| 688 | 692 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long"); |
| 689 | 693 | image.message(" File name too long"); |
| 694 | free(quick_data); |
| 690 | 695 | return IMAGE_INIT_FAIL; |
| 691 | 696 | } |
| 692 | 697 | |
| r22585 | r22586 | |
| 700 | 705 | { |
| 701 | 706 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size"); |
| 702 | 707 | image.message(" Unexpected EOF while getting file size"); |
| 708 | free(quick_data); |
| 703 | 709 | return IMAGE_INIT_FAIL; |
| 704 | 710 | } |
| 705 | 711 | |
| r22585 | r22586 | |
| 711 | 717 | { |
| 712 | 718 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too large"); |
| 713 | 719 | image.message(" File too large"); |
| 720 | free(quick_data); |
| 714 | 721 | return IMAGE_INIT_FAIL; |
| 715 | 722 | } |
| 716 | 723 | |
| r22585 | r22586 | |
| 726 | 733 | snprintf(message, ARRAY_LENGTH(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); |
| 727 | 734 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, message); |
| 728 | 735 | image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); |
| 736 | free(quick_data); |
| 729 | 737 | return IMAGE_INIT_FAIL; |
| 730 | 738 | } |
| 731 | 739 | space.write_byte(j, ch); |
| 732 | 740 | } |
| 733 | 741 | |
| 742 | free(quick_data); |
| 734 | 743 | return IMAGE_INIT_PASS; |
| 735 | 744 | } |
| 736 | 745 | |