src/mess/drivers/fmtowns.c
| r6033 | r6034 | |
| 39 | 39 | * 0x0028 RW: bit 0 = NMI mask (read/write) |
| 40 | 40 | * 0x0030 R : Machine ID (low) |
| 41 | 41 | * 0x0031 R : Machine ID (high) |
| 42 | | * 0x0032 RW: bit 7 = RESET, bit 6 = CLK (serial?) |
| 42 | * 0x0032 RW: bit 7 = RESET, bit 6 = CLK, bit 0 = data (serial ROM) |
| 43 | 43 | * 0x0040 : 8253 PIT counter 0 |
| 44 | 44 | * 0x0042 : 8253 PIT counter 1 |
| 45 | 45 | * 0x0044 : 8253 PIT counter 2 |
| r6033 | r6034 | |
| 50 | 50 | * 0x00b0-bf: DMA controller 2 (uPD71071) |
| 51 | 51 | * 0x0200-0f: Floppy controller (MB8877A) |
| 52 | 52 | * 0x0400 : Video / CRTC (unknown) |
| 53 | | * 0x0404 : Video / CRTC (unknown) |
| 53 | * 0x0404 : Enable whole first MB of RAM (disable VRAM, CMOS, BIOS ROM) |
| 54 | 54 | * 0x0440-5f: Video / CRTC (unknown) |
| 55 | | * 0x0480 RW: bit 1 = some sort of RAM switch? |
| 55 | * 0x0480 RW: bit 1 = disable BIOS ROM |
| 56 | 56 | * 0x04c0-cf: CD-ROM controller (unknown? SCSI?) |
| 57 | 57 | * 0x04d5 : Sound mute |
| 58 | 58 | * 0x04d8 : YM3438 control port A / status |
| r6033 | r6034 | |
| 70 | 70 | * 0x3000 - 0x3fff : CMOS RAM |
| 71 | 71 | * 0xfd90-a0: CRTC / Video |
| 72 | 72 | * 0xff81: CRTC / Video - returns value in RAM location 0xcff81? |
| 73 | * |
| 74 | * IRQ list |
| 75 | * |
| 76 | * IRQ0 - PIT Timer IRQ |
| 77 | * IRQ1 - Keyboard |
| 78 | * IRQ2 - Serial Port |
| 79 | * IRQ6 - Floppy Disc Drive |
| 80 | * IRQ7 - PIC Cascade IRQ |
| 81 | * IRQ8 - SCSI controller |
| 82 | * IRQ9 - Built-in CD-ROM controller |
| 83 | * IRQ11 - VSync interrupt |
| 84 | * IRQ12 - Printer port |
| 85 | * IRQ13 - Sound (FM?), Mouse |
| 86 | * IRQ15 - PCM |
| 73 | 87 | */ |
| 74 | 88 | |
| 75 | 89 | #include "driver.h" |
| r6033 | r6034 | |
| 113 | 127 | static UINT8 towns_rtc_data; |
| 114 | 128 | static UINT8 towns_rtc_reg[16]; |
| 115 | 129 | emu_timer* towns_rtc_timer; |
| 130 | static UINT8 towns_timer_mask; |
| 131 | static UINT8 towns_crtc_mix; |
| 116 | 132 | |
| 133 | |
| 117 | 134 | static void towns_update_video_banks(const address_space* space); |
| 135 | static PIC8259_SET_INT_LINE( towns_pic_irq ); |
| 118 | 136 | |
| 119 | 137 | static void towns_init_serial_rom(void) |
| 120 | 138 | { |
| r6033 | r6034 | |
| 498 | 516 | logerror("KB: wrote 0x%02x to offset %02x\n",data,offset); |
| 499 | 517 | } |
| 500 | 518 | |
| 519 | /* |
| 520 | * Port 0x60 - PIT Timer control |
| 521 | * On read: bit 0: Timer 0 output level |
| 522 | * bit 1: Timer 1 output level |
| 523 | * bits 4-2: Timer masks (timer 2 = sound) |
| 524 | * On write: bits 2-0: Timer mask set |
| 525 | * bit 7: Timer 0 output reset |
| 526 | */ |
| 501 | 527 | static READ8_HANDLER(towns_port60_r) |
| 502 | 528 | { |
| 503 | 529 | UINT8 val = 0x00; |
| 504 | | if ( pit8253_get_output(devtag_get_device(space->machine, "pit"), 2 ) ) |
| 505 | | val |= 0x20; |
| 506 | | else |
| 507 | | val &= ~0x20; |
| 530 | |
| 531 | if ( pit8253_get_output(devtag_get_device(space->machine, "pit"), 0 ) ) |
| 532 | val |= 0x01; |
| 533 | if ( pit8253_get_output(devtag_get_device(space->machine, "pit"), 1 ) ) |
| 534 | val |= 0x02; |
| 508 | 535 | |
| 536 | val |= (towns_timer_mask & 0x07) << 2; |
| 537 | |
| 509 | 538 | logerror("PIT: port 0x60 read, returning 0x%02x\n",val); |
| 510 | 539 | return val; |
| 511 | 540 | } |
| 512 | 541 | |
| 513 | 542 | static WRITE8_HANDLER(towns_port60_w) |
| 514 | 543 | { |
| 515 | | pit8253_gate_w(devtag_get_device(space->machine, "pit"), 2, data & 1); |
| 544 | const device_config* dev = devtag_get_device(space->machine,"pic8259_master"); |
| 545 | |
| 546 | if(data & 0x80) |
| 547 | { |
| 548 | towns_pic_irq(dev,0); |
| 549 | } |
| 550 | towns_timer_mask = data & 0x07; |
| 551 | // bit 2 = sound (beeper?) |
| 516 | 552 | logerror("PIT: wrote 0x%02x to port 0x60\n",data); |
| 517 | 553 | } |
| 518 | 554 | |
| r6033 | r6034 | |
| 627 | 663 | |
| 628 | 664 | switch(offset) |
| 629 | 665 | { |
| 666 | case 0x00: // mix register |
| 667 | return towns_crtc_mix; |
| 630 | 668 | case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) |
| 631 | 669 | return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane; |
| 632 | 670 | case 0x16: // Kanji character data |
| r6033 | r6034 | |
| 655 | 693 | |
| 656 | 694 | switch(offset) |
| 657 | 695 | { |
| 696 | case 0x00: // mix register |
| 697 | towns_crtc_mix = data; |
| 698 | break; |
| 658 | 699 | case 0x01: // read/write plane select (bit 0-3 write, bit 6-7 read) |
| 659 | 700 | towns_vram_wplane = data & 0x0f; |
| 660 | 701 | towns_vram_rplane = (data & 0xc0) >> 6; |
| r6033 | r6034 | |
| 898 | 939 | return 0x08; |
| 899 | 940 | } |
| 900 | 941 | |
| 942 | static READ8_HANDLER(towns_41ff_r) |
| 943 | { |
| 944 | logerror("I/O port 0x41ff read\n"); |
| 945 | return 0x01; |
| 946 | } |
| 947 | |
| 901 | 948 | static IRQ_CALLBACK( towns_irq_callback ) |
| 902 | 949 | { |
| 903 | 950 | const device_config* pic1 = devtag_get_device(device->machine,"pic8259_master"); |
| r6033 | r6034 | |
| 915 | 962 | |
| 916 | 963 | static PIC8259_SET_INT_LINE( towns_pic_irq ) |
| 917 | 964 | { |
| 918 | | cputag_set_input_line(device->machine,"maincpu",0,interrupt ? ASSERT_LINE : CLEAR_LINE); |
| 965 | cputag_set_input_line(device->machine,"maincpu",0,interrupt ? HOLD_LINE : CLEAR_LINE); |
| 966 | logerror("PIC#1: set IRQ line to %i\n",interrupt); |
| 919 | 967 | } |
| 920 | 968 | |
| 921 | 969 | static PIC8259_SET_INT_LINE( towns_slave_pic_irq ) |
| 922 | 970 | { |
| 923 | | cputag_set_input_line(device->machine,"maincpu",7,interrupt ? ASSERT_LINE : CLEAR_LINE); |
| 971 | const device_config* dev = devtag_get_device(device->machine,"pic8259_master"); |
| 972 | |
| 973 | pic8259_set_irq_line(dev,7,interrupt); |
| 974 | logerror("PIC#2: set IRQ line to %i\n",interrupt); |
| 924 | 975 | } |
| 925 | 976 | |
| 926 | 977 | static PIT8253_OUTPUT_CHANGED( towns_pit_out0_changed ) |
| 927 | 978 | { |
| 928 | 979 | const device_config* dev = devtag_get_device(device->machine,"pic8259_master"); |
| 929 | | pic8259_set_irq_line(dev,0,state); |
| 980 | |
| 981 | if(towns_timer_mask & 0x01) |
| 982 | { |
| 983 | pic8259_set_irq_line(dev,0,state); |
| 984 | } |
| 930 | 985 | } |
| 931 | 986 | |
| 987 | static PIT8253_OUTPUT_CHANGED( towns_pit_out1_changed ) |
| 988 | { |
| 989 | const device_config* dev = devtag_get_device(device->machine,"pic8259_master"); |
| 990 | |
| 991 | if(towns_timer_mask & 0x02) |
| 992 | { |
| 993 | pic8259_set_irq_line(dev,0,state); |
| 994 | } |
| 995 | } |
| 996 | |
| 932 | 997 | static ADDRESS_MAP_START(towns_mem, ADDRESS_SPACE_PROGRAM, 32) |
| 933 | 998 | // memory map based on FM-Towns/Bochs (Bochs modified to emulate the FM-Towns) |
| 934 | 999 | // may not be (and probably is not) correct |
| r6033 | r6034 | |
| 1005 | 1070 | AM_RANGE(0x0c30,0x0c33) AM_READ8(towns_unknown_r,0x00ff0000) |
| 1006 | 1071 | // CMOS |
| 1007 | 1072 | AM_RANGE(0x3000,0x3fff) AM_READWRITE8(towns_cmos8_r, towns_cmos8_w,0x00ff00ff) |
| 1073 | // Something (MS-DOS wants this 0x41ff be 1 |
| 1074 | AM_RANGE(0x41fc,0x41ff) AM_READ8(towns_41ff_r,0xff000000) |
| 1008 | 1075 | // CRTC / Video (again) |
| 1009 | 1076 | AM_RANGE(0xfd90,0xfda3) AM_READWRITE8(towns_video_fd90_r, towns_video_fd90_w, 0xffffffff) |
| 1010 | 1077 | AM_RANGE(0xff80,0xff83) AM_READWRITE8(towns_video_ff81_r, towns_video_ff81_w, 0x0000ff00) |
| r6033 | r6034 | |
| 1085 | 1152 | }, |
| 1086 | 1153 | { |
| 1087 | 1154 | 307200, |
| 1088 | | NULL |
| 1155 | towns_pit_out1_changed |
| 1089 | 1156 | }, |
| 1090 | 1157 | { |
| 1091 | 1158 | 307200, |