src/mess/drivers/pc8801.c
| r10066 | r10067 | |
| 14 | 14 | - joystick / mouse support; |
| 15 | 15 | - cursor is 8 x 10, not 8 x 8 as current implementation. |
| 16 | 16 | - text DMAC stuff isn't well documented; |
| 17 | - CRTC really looks like to be a MCU; |
| 18 | - needs to support V1 / V2 properly; |
| 17 | 19 | |
| 18 | 20 | per-game specific TODO: |
| 19 | 21 | - 100 Yen disk(s): reads kanji ports; |
| 20 | 22 | - Acro Jet: hangs waiting for an irq; |
| 21 | 23 | - Adrenalin Connection: seems to have an unemulated screen mode; |
| 22 | | - Again: hangs waiting for something; |
| 23 | | - Agress: crashes after that it shows the title screen; |
| 24 | - Aggress: crashes after that it shows the title screen; |
| 25 | - American Success: uses some ALU characteristics, might be a good test case; |
| 26 | - American Success: reads the light pen? |
| 27 | - Alphos: test case for text VRAM attributes; |
| 28 | - Alphos: text VRAM garbage during gameplay; |
| 29 | - Alphos: background is supposed to be blue? |
| 24 | 30 | - Xevious: game is too fast |
| 25 | 31 | |
| 26 | 32 | Notes: |
| r10066 | r10067 | |
| 128 | 134 | static UINT8 i8214_irq_level,i8214_irq_state; |
| 129 | 135 | static UINT16 dma_counter[4],dma_address[4]; |
| 130 | 136 | static UINT8 dmac_mode; |
| 137 | static UINT8 alu_ctrl1,alu_ctrl2; |
| 131 | 138 | |
| 132 | 139 | static void pc8801_update_irq(running_machine *machine) |
| 133 | 140 | { |
| r10066 | r10067 | |
| 171 | 178 | |
| 172 | 179 | static struct |
| 173 | 180 | { |
| 174 | | UINT8 cmd,param_count,cursor_on; |
| 181 | UINT8 cmd,param_count,cursor_on,status,irq_mask; |
| 175 | 182 | UINT8 param[8][5]; |
| 176 | 183 | }crtc; |
| 177 | 184 | |
| r10066 | r10067 | |
| 241 | 248 | } |
| 242 | 249 | } |
| 243 | 250 | |
| 244 | | if(!(layer_mask & 1) && dmac_mode & 4) |
| 251 | if(!(layer_mask & 1) && dmac_mode & 4 && crtc.status & 0x10 && crtc.irq_mask == 3) |
| 245 | 252 | { |
| 246 | 253 | for(y=0;y<25;y++) |
| 247 | 254 | { |
| r10066 | r10067 | |
| 405 | 412 | return WRAM_BASE + (window_offset_bank << 8); |
| 406 | 413 | } |
| 407 | 414 | |
| 408 | | /* TODO: this isn't correct */ |
| 409 | 415 | static UINT32 pc8801_bankswitch_3_r(running_machine *machine) |
| 410 | 416 | { |
| 411 | 417 | if(vram_sel == 3) |
| 412 | 418 | return WRAM_BASE + 0xc000; |
| 413 | 419 | |
| 420 | if(misc_ctrl & 0x40) |
| 421 | { |
| 422 | vram_sel = 3; |
| 423 | if(alu_ctrl2 & 0x80) |
| 424 | return 0xc0000; // TODO: ALU hook-up |
| 425 | } |
| 426 | |
| 414 | 427 | return GRAM_BASE + 0x4000 * vram_sel; |
| 415 | 428 | } |
| 416 | 429 | |
| r10066 | r10067 | |
| 419 | 432 | if(vram_sel == 3) |
| 420 | 433 | return WRAM_BASE + 0xc000; |
| 421 | 434 | |
| 435 | if(misc_ctrl & 0x40) |
| 436 | { |
| 437 | vram_sel = 3; |
| 438 | if(alu_ctrl2 & 0x80) |
| 439 | return 0xc0000; // TODO: ALU hook-up |
| 440 | } |
| 441 | |
| 422 | 442 | return GRAM_BASE + 0x4000 * vram_sel; |
| 423 | 443 | } |
| 424 | 444 | |
| 425 | 445 | static UINT32 pc8801_bankswitch_4_r(running_machine *machine) |
| 426 | 446 | { |
| 427 | 447 | if(vram_sel == 3) |
| 428 | | return WRAM_BASE + 0xf000; |
| 448 | { |
| 449 | if(misc_ctrl & 0x10) // high VRAM |
| 450 | return WRAM_BASE + 0xf000; |
| 429 | 451 | |
| 452 | return WRAM_BASE + 0xf000 + 0x10000; |
| 453 | } |
| 454 | |
| 455 | if(misc_ctrl & 0x40) |
| 456 | { |
| 457 | vram_sel = 3; |
| 458 | if(alu_ctrl2 & 0x80) |
| 459 | return 0xc0000; // TODO: ALU hook-up |
| 460 | } |
| 461 | |
| 430 | 462 | return GRAM_BASE + 0x3000 + (0x4000 * vram_sel); |
| 431 | 463 | } |
| 432 | 464 | |
| 433 | 465 | static UINT32 pc8801_bankswitch_4_w(running_machine *machine) |
| 434 | 466 | { |
| 435 | 467 | if(vram_sel == 3) |
| 436 | | return WRAM_BASE + 0xf000; |
| 468 | { |
| 469 | if(misc_ctrl & 0x10) // high VRAM |
| 470 | return WRAM_BASE + 0xf000; |
| 437 | 471 | |
| 472 | return WRAM_BASE + 0xf000 + 0x10000; |
| 473 | } |
| 474 | |
| 475 | if(misc_ctrl & 0x40) |
| 476 | { |
| 477 | vram_sel = 3; |
| 478 | if(alu_ctrl2 & 0x80) |
| 479 | return 0xc0000; // TODO: ALU hook-up |
| 480 | } |
| 481 | |
| 438 | 482 | return GRAM_BASE + 0x3000 + (0x4000 * vram_sel); |
| 439 | 483 | } |
| 440 | 484 | |
| r10066 | r10067 | |
| 585 | 629 | misc_ctrl = data; |
| 586 | 630 | |
| 587 | 631 | sound_irq_mask = ((data & 0x80) == 0); |
| 632 | |
| 633 | if(data & 0x40) |
| 634 | printf("Extra VRAM triggered\n"); |
| 588 | 635 | } |
| 589 | 636 | |
| 590 | 637 | static WRITE8_HANDLER( pc8801_palram_w ) |
| r10066 | r10067 | |
| 623 | 670 | |
| 624 | 671 | static READ8_HANDLER( pc8801_crtc_status_r ) |
| 625 | 672 | { |
| 626 | | return 0xff; |
| 673 | /* |
| 674 | ---x ---- video enable |
| 675 | ---- x--- DMA is running |
| 676 | ---- -x-- special control character IRQ |
| 677 | ---- --x- indication end IRQ |
| 678 | ---- ---x light pen input |
| 679 | */ |
| 680 | |
| 681 | return crtc.status; |
| 627 | 682 | } |
| 628 | 683 | |
| 629 | 684 | static const char *const crtc_command[] = |
| r10066 | r10067 | |
| 643 | 698 | crtc.cmd = (data & 0xe0) >> 5; |
| 644 | 699 | crtc.param_count = 0; |
| 645 | 700 | |
| 646 | | if(crtc.cmd == 4) // load cursor position ON/OFF |
| 647 | | crtc.cursor_on = data & 1; |
| 701 | switch(crtc.cmd) |
| 702 | { |
| 703 | case 0: // reset CRTC |
| 704 | crtc.status &= (~0x10 | ~0x04 | ~0x02); |
| 705 | break; |
| 706 | case 1: // start display |
| 707 | crtc.status |= 0x10; |
| 708 | crtc.status &= (~0x08); |
| 709 | if(data & 1) |
| 710 | printf("CRTC reverse display ON\n"); |
| 648 | 711 | |
| 649 | | if((data >> 5) != 4) |
| 650 | | printf("CRTC cmd %s polled\n",crtc_command[data >> 5]); |
| 712 | break; |
| 713 | case 2: // set irq mask |
| 714 | crtc.irq_mask = data & 3; |
| 715 | break; |
| 716 | case 3: // read light pen |
| 717 | crtc.status &= (~0x01); |
| 718 | break; |
| 719 | case 4: // load cursor position ON/OFF |
| 720 | crtc.cursor_on = data & 1; |
| 721 | break; |
| 722 | case 5: // reset IRQ |
| 723 | case 6: // reset counters |
| 724 | crtc.status &= (~0x04 | ~0x02); |
| 725 | break; |
| 726 | } |
| 727 | |
| 728 | //if((data >> 5) != 4) |
| 729 | // printf("CRTC cmd %s polled\n",crtc_command[data >> 5]); |
| 651 | 730 | } |
| 652 | 731 | |
| 653 | 732 | static WRITE8_HANDLER( pc8801_dmac_w ) |
| r10066 | r10067 | |
| 667 | 746 | dmac_mode = data; |
| 668 | 747 | } |
| 669 | 748 | |
| 749 | static WRITE8_HANDLER( pc8801_extram_sel_w ) |
| 750 | { |
| 751 | if(data & 0x11) |
| 752 | printf("Extra RAM select %02x\n",data & 0x11); |
| 753 | } |
| 754 | |
| 755 | static WRITE8_HANDLER( pc8801_alu_ctrl1_w ) |
| 756 | { |
| 757 | alu_ctrl1 = data; |
| 758 | } |
| 759 | |
| 760 | static WRITE8_HANDLER( pc8801_alu_ctrl2_w ) |
| 761 | { |
| 762 | alu_ctrl2 = data; |
| 763 | bankr[3] = pc8801_bankswitch_3_r(space->machine); |
| 764 | bankr[4] = pc8801_bankswitch_4_r(space->machine); |
| 765 | bankw[3] = pc8801_bankswitch_3_w(space->machine); |
| 766 | bankw[4] = pc8801_bankswitch_4_w(space->machine); |
| 767 | } |
| 768 | |
| 670 | 769 | static ADDRESS_MAP_START( pc8801_io, ADDRESS_SPACE_IO, 8 ) |
| 671 | 770 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 672 | 771 | ADDRESS_MAP_UNMAP_HIGH |
| r10066 | r10067 | |
| 691 | 790 | AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") //AM_WRITE(pc88sr_outport_30) |
| 692 | 791 | AM_RANGE(0x31, 0x31) AM_READ_PORT("DSW2") AM_WRITE(pc8801_gfx_ctrl_w) |
| 693 | 792 | AM_RANGE(0x32, 0x32) AM_READWRITE(pc8801_misc_ctrl_r, pc8801_misc_ctrl_w) |
| 694 | | // AM_RANGE(0x34, 0x35) AM_WRITE(pc88sr_alu) |
| 793 | AM_RANGE(0x34, 0x34) AM_WRITE(pc8801_alu_ctrl1_w) |
| 794 | AM_RANGE(0x35, 0x35) AM_WRITE(pc8801_alu_ctrl2_w) |
| 695 | 795 | AM_RANGE(0x40, 0x40) AM_READWRITE(pc8801_ctrl_r, pc8801_ctrl_w) |
| 696 | 796 | AM_RANGE(0x44, 0x45) AM_DEVREADWRITE("ym2203", ym2203_r,ym2203_w) |
| 697 | 797 | // AM_RANGE(0x46, 0x47) AM_NOP /* OPNA extra port */ |
| r10066 | r10067 | |
| 718 | 818 | // AM_RANGE(0xd0, 0xd7) AM_NOP /* music & GP-IB */ |
| 719 | 819 | // AM_RANGE(0xd8, 0xd8) AM_NOP /* GP-IB */ |
| 720 | 820 | // AM_RANGE(0xdc, 0xdf) AM_NOP /* MODEM */ |
| 721 | | // AM_RANGE(0xe2, 0xe3) AM_READWRITE(pc88_extmem_r, pc88_extmem_w) /* expand RAM select */ |
| 821 | AM_RANGE(0xe2, 0xe2) AM_WRITE(pc8801_extram_sel_w) /* expand RAM select */ |
| 722 | 822 | AM_RANGE(0xe4, 0xe4) AM_WRITE(pc8801_irq_level_w) |
| 723 | 823 | AM_RANGE(0xe6, 0xe6) AM_WRITE(pc8801_irq_mask_w) |
| 724 | 824 | // AM_RANGE(0xe7, 0xe7) AM_NOP /* (unknown) */ |
| r10066 | r10067 | |
| 1020 | 1120 | PORT_DIPNAME( 0x20, 0x20, "Duplex" ) |
| 1021 | 1121 | PORT_DIPSETTING( 0x20, "Half" ) |
| 1022 | 1122 | PORT_DIPSETTING( 0x00, "Full" ) |
| 1023 | | PORT_DIPNAME( 0x40, 0x00, "Boot from floppy" ) |
| 1123 | /* PORT_DIPNAME( 0x40, 0x00, "Boot from floppy" ) |
| 1024 | 1124 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 1025 | 1125 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1026 | 1126 | PORT_DIPNAME( 0x80, 0x80, "Disable floppy" ) |
| 1027 | 1127 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 1028 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1128 | PORT_DIPSETTING( 0x00, DEF_STR( On ) )*/ |
| 1129 | PORT_DIPNAME( 0xc0, 0x40, "Basic mode" ) |
| 1130 | PORT_DIPSETTING( 0x80, "N-BASIC" ) |
| 1131 | PORT_DIPSETTING( 0xc0, "N88-BASIC (V1)" ) |
| 1132 | PORT_DIPSETTING( 0x40, "N88-BASIC (V2)" ) |
| 1029 | 1133 | |
| 1030 | 1134 | PORT_START("CFG") /* EXSWITCH */ |
| 1031 | | PORT_DIPNAME( 0x03, 0x01, "Basic mode" ) |
| 1032 | | PORT_DIPSETTING( 0x02, "N-BASIC" ) |
| 1033 | | PORT_DIPSETTING( 0x03, "N88-BASIC (V1)" ) |
| 1034 | | PORT_DIPSETTING( 0x01, "N88-BASIC (V2)" ) |
| 1035 | 1135 | PORT_DIPNAME( 0x04, 0x04, "Speed mode" ) |
| 1036 | 1136 | PORT_DIPSETTING( 0x00, "Slow" ) |
| 1037 | 1137 | PORT_DIPSETTING( 0x04, DEF_STR( High ) ) |
| r10066 | r10067 | |
| 1216 | 1316 | { |
| 1217 | 1317 | crtc.param_count = 0; |
| 1218 | 1318 | crtc.cmd = 0; |
| 1319 | crtc.status = 0; |
| 1219 | 1320 | } |
| 1220 | 1321 | |
| 1221 | 1322 | beep_set_frequency(machine->device("beeper"),2400); |