src/mess/drivers/homelab.c
| r15494 | r15495 | |
| 6 | 6 | 15/06/2012 Various updates [Robbbert] |
| 7 | 7 | |
| 8 | 8 | ToDO: |
| 9 | - Quickload loads the files ok, but the machine crashes. |
| 9 | 10 | - homelab2 - cassette |
| 10 | 11 | Note that rom code 0x40-48 is meaningless garbage, |
| 11 | 12 | had to patch to stop it crashing. Need a new dump. |
| r15494 | r15495 | |
| 36 | 37 | #include "imagedev/cassette.h" |
| 37 | 38 | #include "audio/mea8000.h" |
| 38 | 39 | #include "sound/dac.h" |
| 40 | #include "imagedev/snapquik.h" |
| 39 | 41 | |
| 40 | 42 | |
| 41 | 43 | #define MACHINE_RESET_MEMBER(name) void name::machine_reset() |
| r15494 | r15495 | |
| 500 | 502 | |
| 501 | 503 | static const mea8000_interface brailab4_speech_intf = { "speech", NULL }; |
| 502 | 504 | |
| 505 | static QUICKLOAD_LOAD(homelab) |
| 506 | { |
| 507 | address_space *space = image.device().machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 508 | int i=0; |
| 509 | UINT8 ch; |
| 510 | UINT16 quick_addr; |
| 511 | UINT16 quick_length; |
| 512 | UINT8 *quick_data; |
| 513 | char pgmname[256]; |
| 514 | UINT16 args[3]; |
| 515 | int read_; |
| 516 | |
| 517 | quick_length = image.length(); |
| 518 | quick_data = (UINT8*)malloc(quick_length); |
| 519 | if (!quick_data) |
| 520 | { |
| 521 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot open file"); |
| 522 | image.message(" Cannot open file"); |
| 523 | return IMAGE_INIT_FAIL; |
| 524 | } |
| 525 | |
| 526 | read_ = image.fread( quick_data, quick_length); |
| 527 | if (read_ != quick_length) |
| 528 | { |
| 529 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Cannot read the file"); |
| 530 | image.message(" Cannot read the file"); |
| 531 | return IMAGE_INIT_FAIL; |
| 532 | } |
| 533 | |
| 534 | image.fseek(0x100, SEEK_SET); |
| 535 | ch = image.fgetc(); |
| 536 | if (ch != 0xA5) |
| 537 | { |
| 538 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid header"); |
| 539 | image.message(" Invalid header"); |
| 540 | return IMAGE_INIT_FAIL; |
| 541 | } |
| 542 | |
| 543 | while((ch = image.fgetc())) |
| 544 | { |
| 545 | if (ch == EOF) |
| 546 | { |
| 547 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file name"); |
| 548 | image.message(" Unexpected EOF while getting file name"); |
| 549 | return IMAGE_INIT_FAIL; |
| 550 | } |
| 551 | |
| 552 | if (ch != '\0') |
| 553 | { |
| 554 | if (i >= (ARRAY_LENGTH(pgmname) - 1)) |
| 555 | { |
| 556 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long"); |
| 557 | image.message(" File name too long"); |
| 558 | return IMAGE_INIT_FAIL; |
| 559 | } |
| 560 | |
| 561 | pgmname[i] = ch; /* build program name */ |
| 562 | i++; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | pgmname[i] = '\0'; /* terminate string with a null */ |
| 567 | |
| 568 | if (image.fread(args, sizeof(args)) != sizeof(args)) |
| 569 | { |
| 570 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size"); |
| 571 | image.message(" Unexpected EOF while getting file size"); |
| 572 | return IMAGE_INIT_FAIL; |
| 573 | } |
| 574 | |
| 575 | quick_addr = LITTLE_ENDIANIZE_INT16(args[0]); |
| 576 | quick_length = LITTLE_ENDIANIZE_INT16(args[1]); |
| 577 | int quick_end = quick_addr+quick_length-1; |
| 578 | |
| 579 | if (quick_end > 0x7fff) |
| 580 | { |
| 581 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too large"); |
| 582 | image.message(" File too large"); |
| 583 | return IMAGE_INIT_FAIL; |
| 584 | } |
| 585 | |
| 586 | /* display a message about the loaded quickload */ |
| 587 | image.message(" %s\nsize=%04X : start=%04X : end=%04X",pgmname,quick_length,quick_addr,quick_end); |
| 588 | |
| 589 | for (i = 0; i < quick_length; i++) |
| 590 | { |
| 591 | int j = (quick_addr + i); |
| 592 | if (image.fread(&ch, 1) != 1) |
| 593 | { |
| 594 | char message[256]; |
| 595 | snprintf(message, ARRAY_LENGTH(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); |
| 596 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, message); |
| 597 | image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); |
| 598 | return IMAGE_INIT_FAIL; |
| 599 | } |
| 600 | space->write_byte(j, ch); |
| 601 | } |
| 602 | |
| 603 | return IMAGE_INIT_PASS; |
| 604 | } |
| 605 | |
| 503 | 606 | /* Machine driver */ |
| 504 | 607 | static MACHINE_CONFIG_START( homelab, homelab_state ) |
| 505 | 608 | /* basic machine hardware */ |
| r15494 | r15495 | |
| 526 | 629 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 527 | 630 | |
| 528 | 631 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 632 | MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 2) |
| 529 | 633 | MACHINE_CONFIG_END |
| 530 | 634 | |
| 531 | 635 | static MACHINE_CONFIG_START( homelab3, homelab_state ) |
| r15494 | r15495 | |
| 553 | 657 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 554 | 658 | |
| 555 | 659 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 660 | MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 2) |
| 556 | 661 | MACHINE_CONFIG_END |
| 557 | 662 | |
| 558 | 663 | static MACHINE_CONFIG_START( brailab4, homelab_state ) |
| r15494 | r15495 | |
| 583 | 688 | |
| 584 | 689 | MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface ) |
| 585 | 690 | MCFG_MEA8000_ADD("mea8000", brailab4_speech_intf) |
| 691 | MCFG_QUICKLOAD_ADD("quickload", homelab, "htp", 8) |
| 586 | 692 | MACHINE_CONFIG_END |
| 587 | 693 | |
| 588 | 694 | |