src/mess/drivers/exidy.c
| r2024 | r2025 | |
| 221 | 221 | logerror("hd6402 state: %04x %04x\n",mask,data); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | | static TIMER_CALLBACK(exidy_reset_timer_callback) |
| 224 | /* after the first 4 bytes have been read from ROM, switch the ram back in */ |
| 225 | static TIMER_CALLBACK( exidy_reset ) |
| 225 | 226 | { |
| 226 | | cpunum_set_reg(0, REG_PC, 0x0e000); |
| 227 | memory_set_bank(1, 0); |
| 227 | 228 | } |
| 228 | 229 | |
| 229 | 230 | static void exidy_printer_handshake_in(int number, int data, int mask) |
| r2024 | r2025 | |
| 275 | 276 | |
| 276 | 277 | exidy_fe_port_w(machine, 0, 0); |
| 277 | 278 | |
| 278 | | timer_set(attotime_zero, NULL, 0, exidy_reset_timer_callback); |
| 279 | timer_set(ATTOTIME_IN_USEC(10), NULL, 0, exidy_reset); |
| 280 | memory_set_bank(1, 1); |
| 279 | 281 | } |
| 280 | 282 | |
| 281 | 283 | static MACHINE_RESET( exidy ) |
| 282 | 284 | { |
| 285 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 283 | 286 | MACHINE_RESET_CALL( exidyd ); |
| 284 | | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |
| 285 | 287 | } |
| 286 | 288 | |
| 287 | 289 | |
| r2024 | r2025 | |
| 324 | 326 | } |
| 325 | 327 | |
| 326 | 328 | |
| 327 | | static ADDRESS_MAP_START( exidy_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 328 | | ADDRESS_MAP_UNMAP_HIGH |
| 329 | | AM_RANGE(0x0000, 0x7fff) AM_RAM /* ram 32k machine */ |
| 330 | | AM_RANGE(0xbc00, 0xbcff) AM_ROM |
| 331 | | AM_RANGE(0xbe00, 0xbe03) AM_READWRITE(exidy_wd179x_r, exidy_wd179x_w) |
| 332 | | |
| 333 | | AM_RANGE(0xc000, 0xefff) AM_ROM /* rom pac */ |
| 334 | | AM_RANGE(0xf000, 0xf7ff) AM_RAM /* screen ram */ |
| 335 | | AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ |
| 336 | | AM_RANGE(0xfc00, 0xffff) AM_RAM /* programmable chars */ |
| 337 | | ADDRESS_MAP_END |
| 338 | | |
| 339 | | static ADDRESS_MAP_START( exidyd_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 340 | | ADDRESS_MAP_UNMAP_HIGH |
| 341 | | AM_RANGE(0x0000, 0xbfff) AM_RAM /* ram 48k diskless machine */ |
| 342 | | AM_RANGE(0xc000, 0xefff) AM_ROM /* rom pac */ |
| 343 | | AM_RANGE(0xf000, 0xf7ff) AM_RAM /* screen ram */ |
| 344 | | AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ |
| 345 | | AM_RANGE(0xfc00, 0xffff) AM_RAM /* programmable chars */ |
| 346 | | ADDRESS_MAP_END |
| 347 | | |
| 348 | 329 | static WRITE8_HANDLER(exidy_fc_port_w) |
| 349 | 330 | { |
| 350 | 331 | logerror("exidy fc w: %04x %02x\n",offset,data); |
| r2024 | r2025 | |
| 506 | 487 | UINT8 data = 0xe0; |
| 507 | 488 | |
| 508 | 489 | /* bit 4: parity error */ |
| 509 | | if (exidy_hd6402_state & HD6402_OUTPUT_PE) data |= (1<<4); |
| 490 | if (exidy_hd6402_state & HD6402_OUTPUT_PE) data |= 16; |
| 510 | 491 | |
| 511 | 492 | /* bit 3: framing error */ |
| 512 | | if (exidy_hd6402_state & HD6402_OUTPUT_FE) data |= (1<<3); |
| 493 | if (exidy_hd6402_state & HD6402_OUTPUT_FE) data |= 8; |
| 513 | 494 | |
| 514 | 495 | /* bit 2: over-run error */ |
| 515 | | if (exidy_hd6402_state & HD6402_OUTPUT_OE) data |= (1<<2); |
| 496 | if (exidy_hd6402_state & HD6402_OUTPUT_OE) data |= 4; |
| 516 | 497 | |
| 517 | 498 | /* bit 1: data receive ready - data ready in receive reg */ |
| 518 | | if (exidy_hd6402_state & HD6402_OUTPUT_DR) data |= (1<<1); |
| 499 | if (exidy_hd6402_state & HD6402_OUTPUT_DR) data |= 2; |
| 519 | 500 | |
| 520 | 501 | /* bit 0: transmitter buffer receive empty */ |
| 521 | 502 | /* if this BIT is forced high, then the cassette save routine does not hang */ |
| 522 | | if (exidy_hd6402_state & HD6402_OUTPUT_TBRE) data |= (1<<0); |
| 503 | if (exidy_hd6402_state & HD6402_OUTPUT_TBRE) data |= 1; |
| 523 | 504 | |
| 524 | 505 | logerror("exidy fd r: %04x %02x\n",offset,data); |
| 525 | 506 | |
| r2024 | r2025 | |
| 563 | 544 | } |
| 564 | 545 | |
| 565 | 546 | |
| 547 | static READ8_HANDLER( exidy_read_ff ) { return 0xff; } |
| 548 | |
| 549 | static ADDRESS_MAP_START( exidy_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 550 | ADDRESS_MAP_UNMAP_HIGH |
| 551 | AM_RANGE(0x0000, 0x07ff) AM_RAMBANK(1) |
| 552 | AM_RANGE(0x0800, 0x7fff) AM_RAM /* ram 32k machine */ |
| 553 | AM_RANGE(0x8000, 0xbbff) AM_READWRITE(exidy_read_ff, SMH_NOP) |
| 554 | AM_RANGE(0xbc00, 0xbcff) AM_ROM /* disk bios */ |
| 555 | AM_RANGE(0xbd00, 0xbdff) AM_READWRITE(exidy_read_ff, SMH_NOP) |
| 556 | AM_RANGE(0xbe00, 0xbe03) AM_READWRITE(exidy_wd179x_r, exidy_wd179x_w) |
| 557 | AM_RANGE(0xbe04, 0xbfff) AM_READWRITE(exidy_read_ff, SMH_NOP) |
| 558 | AM_RANGE(0xc000, 0xefff) AM_ROM /* rom pac and bios */ |
| 559 | AM_RANGE(0xf000, 0xf7ff) AM_RAM /* screen ram */ |
| 560 | AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ |
| 561 | AM_RANGE(0xfc00, 0xffff) AM_RAM /* programmable chars */ |
| 562 | ADDRESS_MAP_END |
| 563 | |
| 564 | static ADDRESS_MAP_START( exidyd_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 565 | ADDRESS_MAP_UNMAP_HIGH |
| 566 | AM_RANGE(0x0000, 0x07ff) AM_RAMBANK(1) |
| 567 | AM_RANGE(0x0800, 0xbfff) AM_RAM /* ram 48k diskless machine */ |
| 568 | AM_RANGE(0xc000, 0xefff) AM_ROM /* rom pac and bios */ |
| 569 | AM_RANGE(0xf000, 0xf7ff) AM_RAM /* screen ram */ |
| 570 | AM_RANGE(0xf800, 0xfbff) AM_ROM /* char rom */ |
| 571 | AM_RANGE(0xfc00, 0xffff) AM_RAM /* programmable chars */ |
| 572 | ADDRESS_MAP_END |
| 573 | |
| 566 | 574 | static ADDRESS_MAP_START( exidy_io , ADDRESS_SPACE_IO, 8) |
| 567 | 575 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 568 | 576 | ADDRESS_MAP_UNMAP_HIGH |
| r2024 | r2025 | |
| 745 | 753 | MDRV_MACHINE_RESET( exidyd ) |
| 746 | 754 | MACHINE_DRIVER_END |
| 747 | 755 | |
| 756 | static DRIVER_INIT( exidy ) |
| 757 | { |
| 758 | UINT8 *RAM = memory_region(REGION_CPU1); |
| 759 | memory_configure_bank(1, 0, 2, &RAM[0x0000], 0xe000); |
| 760 | // timer_pulse(ATTOTIME_IN_HZ(200000),NULL,0,exidy_timer); /* timer for cassette */ |
| 761 | } |
| 762 | |
| 748 | 763 | /*************************************************************************** |
| 749 | 764 | |
| 750 | 765 | Game driver(s) |
| r2024 | r2025 | |
| 757 | 772 | ROM_LOAD("exmo1-2.dat", 0xe800, 0x0800, CRC(ead1d0f6) SHA1(c68bed7344091bca135e427b4793cc7d49ca01be) ) |
| 758 | 773 | ROM_LOAD("exchr-1.dat", 0xf800, 0x0400, CRC(4a7e1cdd) SHA1(2bf07a59c506b6e0c01ec721fb7b747b20f5dced) ) /* char rom */ |
| 759 | 774 | ROM_LOAD_OPTIONAL("diskboot.dat",0xbc00, 0x0100, BAD_DUMP CRC(d82a40d6) SHA1(cd1ef5fb0312cd1640e0853d2442d7d858bc3e3b)) |
| 760 | | ROM_CART_LOAD(0, "rom", 0xc000, 0x2000, ROM_NOMIRROR | ROM_OPTIONAL) |
| 775 | ROM_CART_LOAD(0, "rom", 0xc000, 0x2000, ROM_FILL_FF | ROM_OPTIONAL) |
| 761 | 776 | |
| 762 | 777 | ROM_REGION( 0x0020, REGION_PROMS, 0 ) |
| 763 | 778 | ROM_LOAD_OPTIONAL("bruce.dat", 0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */ |
| r2024 | r2025 | |
| 768 | 783 | ROM_LOAD("exmo1-1.dat", 0xe000, 0x0800, CRC(ac924f67) SHA1(72fcad6dd1ed5ec0527f967604401284d0e4b6a1) ) /* monitor roms */ |
| 769 | 784 | ROM_LOAD("exmo1-2.dat", 0xe800, 0x0800, CRC(ead1d0f6) SHA1(c68bed7344091bca135e427b4793cc7d49ca01be) ) |
| 770 | 785 | ROM_LOAD("exchr-1.dat", 0xf800, 0x0400, CRC(4a7e1cdd) SHA1(2bf07a59c506b6e0c01ec721fb7b747b20f5dced) ) /* char rom */ |
| 771 | | ROM_CART_LOAD(0, "rom", 0xc000, 0x2000, ROM_NOMIRROR | ROM_OPTIONAL) |
| 786 | ROM_CART_LOAD(0, "rom", 0xc000, 0x2000, ROM_FILL_FF | ROM_OPTIONAL) |
| 772 | 787 | |
| 773 | 788 | ROM_REGION( 0x0020, REGION_PROMS, 0 ) |
| 774 | 789 | ROM_LOAD_OPTIONAL("bruce.dat", 0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */ |
| r2024 | r2025 | |
| 776 | 791 | |
| 777 | 792 | static QUICKLOAD_LOAD( exidy ) |
| 778 | 793 | { |
| 779 | | UINT8 sw = readinputportbytag("CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 794 | UINT8 sw = readinputportbytag("CONFIG") & 1; /* reading the dipswitch: 1 = autorun */ |
| 780 | 795 | UINT16 exec_addr, start_addr, end_addr; |
| 781 | 796 | |
| 782 | 797 | if (z80bin_load_file( machine, image, file_type, &exec_addr, &start_addr, &end_addr ) == INIT_FAIL) |
| 783 | | return INIT_FAIL; /* load file */ |
| 798 | return INIT_FAIL; |
| 784 | 799 | |
| 800 | if (exec_addr == 0xffff) return INIT_PASS; /* data file */ |
| 801 | |
| 802 | if ((exec_addr >= 0xc000) && (exec_addr <= 0xdfff) && (program_read_byte(0xdffa) != 0xc3)) |
| 803 | return INIT_PASS; /* can't run a program if the cartridge isn't in */ |
| 804 | |
| 785 | 805 | /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run. |
| 786 | 806 | 1. A start address of 01D5 indicates a basic program which needs its pointers fixed up. |
| 787 | | 2. An exec address of C858 indicates a basic program. |
| 788 | | This address is unsuitable, so the routine at F020 is used instead. |
| 789 | | 3. If the start address is 1D5 and the exec address is NOT C858, |
| 790 | | the pointers still need fixing, but then jump to the exec address. |
| 791 | | 4. If autorun is turned off, the pointers still need fixing, but then display READY. |
| 807 | 2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt). |
| 792 | 808 | Important addresses: |
| 793 | 809 | 01D5 = start (load) address of a conventional basic program |
| 794 | 810 | C858 = an autorun basic program will have this exec address on the tape |
| 795 | | C3DD = part of basic that displays READY and lets user enter input |
| 796 | | F020 = custom routine to fix basic pointers |
| 797 | | F030 = exec address to jump to after fixing the pointers */ |
| 811 | C3DD = part of basic that displays READY and lets user enter input */ |
| 798 | 812 | |
| 799 | 813 | if ((start_addr == 0x1d5) || (exec_addr == 0xc858)) |
| 800 | 814 | { |
| 801 | | UINT8 i, sec[18]={ |
| 802 | | 0x2a, 2, 0xf0, // LD HL,(F002) ;get saved end_addr+1 |
| 803 | | 0x22, 0xb7, 1, // LD (01B7),HL ;move it to correct place |
| 815 | UINT8 i, data[]={ |
| 804 | 816 | 0xcd, 0x26, 0xc4, // CALL C426 ;set up other pointers |
| 805 | | 0x21, 0xd4, 1, // LD HL,01D4 ;dummy-start address |
| 806 | | 0x36, 0, // LD (HL),00 ;make sure it is end-of-line |
| 807 | | 0, // NOP ;line up jump address to an even byte |
| 808 | | 0xc3, 0x89, 0xc6,}; // JP C689 ;run program - f030 = adjustable jump |
| 817 | 0x21, 0xd4, 1, // LD HL,01D4 ;start of program address (used by C689) |
| 818 | 0x36, 0, // LD (HL),00 ;make sure dummy end-of-line is there |
| 819 | 0xc3, 0x89, 0xc6,}; // JP C689 ;run program |
| 809 | 820 | |
| 810 | | for (i = 0; i < 18; i++) program_write_byte(0xf020 + i, sec[i]); |
| 821 | for (i = 0; i < 11; i++) program_write_byte(0xf01f + i, data[i]); |
| 822 | if (!sw) program_write_word_16le(0xf028,0xc3dd); |
| 823 | program_write_byte(0x1b7, end_addr&0xff); /* Tell BASIC where program ends */ |
| 824 | program_write_byte(0x1b8, end_addr>>8); |
| 825 | if ((exec_addr != 0xc858) && (sw)) program_write_word_16le(0xf028,exec_addr); |
| 826 | cpunum_set_reg(0, REG_PC, 0xf01f); |
| 827 | } |
| 828 | else |
| 829 | if (sw) cpunum_set_reg(0, REG_PC, exec_addr); |
| 811 | 830 | |
| 812 | | if (!sw) program_write_word_16le(0xf030,0xc3dd); |
| 813 | | |
| 814 | | if (start_addr == 0x1d5) |
| 815 | | { |
| 816 | | program_write_word_16le(0xf002,end_addr+1); |
| 817 | | if ((exec_addr != 0xc858) && (sw == 1)) program_write_word_16le(0xf030,exec_addr); |
| 818 | | exec_addr=0xf020; |
| 819 | | } |
| 820 | | else |
| 821 | | exec_addr=0xf02f; // skip fixing pointers, just jump into bios |
| 822 | | |
| 823 | | sw = 1; |
| 824 | | |
| 825 | | if (program_read_byte(0xdffa) != 0xc3) exec_addr=0xffff; // can't run if cart not in |
| 826 | | } |
| 827 | | |
| 828 | | if ((exec_addr != 0xffff) && (sw)) cpunum_set_reg(0, REG_PC, exec_addr); |
| 829 | | |
| 830 | 831 | return INIT_PASS; |
| 831 | 832 | } |
| 832 | 833 | |
| r2024 | r2025 | |
| 905 | 906 | |
| 906 | 907 | |
| 907 | 908 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 908 | | COMP(1979, exidy, 0, 0, exidy, exidy, 0, exidy, "Exidy Inc", "Sorcerer", 0 ) |
| 909 | | COMP(1979, exidyd, exidy, 0, exidyd, exidy, 0, exidyd, "Exidy Inc", "Sorcerer (Cassette only)", 0 ) |
| 909 | COMP(1979, exidy, 0, 0, exidy, exidy, exidy, exidy, "Exidy Inc", "Sorcerer", 0 ) |
| 910 | COMP(1979, exidyd, exidy, 0, exidyd, exidy, exidy, exidyd, "Exidy Inc", "Sorcerer (Cassette only)", 0 ) |
| 910 | 911 | |