src/mess/drivers/pc8801.c
| r10063 | r10064 | |
| 2 | 2 | |
| 3 | 3 | PC-8801 (c) 1981 NEC |
| 4 | 4 | |
| 5 | | preliminary driver by Angelo Salese |
| 5 | preliminary driver by Angelo Salese, original MESS PC-88SR by ??? |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | 8 | - used to do more, currently under rewriting stage. We are currently using plain PC-8801 as the base, will add differences for the |
| r10063 | r10064 | |
| 116 | 116 | static UINT8 vrtc_irq_mask,sound_irq_mask; |
| 117 | 117 | static UINT8 window_offset_bank; |
| 118 | 118 | static UINT8 layer_mask; |
| 119 | static UINT8 i8214_irq_level,i8214_irq_state; |
| 119 | 120 | |
| 121 | static void pc8801_update_irq(running_machine *machine) |
| 122 | { |
| 123 | int level, i; |
| 124 | |
| 125 | level = -1; |
| 126 | for (i = 0; i < 8; i++) |
| 127 | { |
| 128 | if ((i8214_irq_state & (1<<i)) != 0) |
| 129 | level = i; |
| 130 | } |
| 131 | |
| 132 | if (level >= 0 && level < i8214_irq_level) |
| 133 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 134 | } |
| 135 | |
| 136 | static void pc8801_raise_irq(running_machine *machine, int level) |
| 137 | { |
| 138 | i8214_irq_state |= (1<<level); |
| 139 | pc8801_update_irq(machine); |
| 140 | } |
| 141 | |
| 120 | 142 | /* |
| 121 | 143 | CRTC command params: |
| 122 | 144 | 0. CRTC reset |
| r10063 | r10064 | |
| 503 | 525 | bankw[4] = pc8801_bankswitch_4_w(space->machine); |
| 504 | 526 | } |
| 505 | 527 | |
| 528 | static WRITE8_HANDLER( pc8801_irq_level_w ) |
| 529 | { |
| 530 | if(data & 8) |
| 531 | i8214_irq_level = 7; |
| 532 | else |
| 533 | i8214_irq_level = data & 7; |
| 534 | } |
| 535 | |
| 536 | |
| 506 | 537 | static WRITE8_HANDLER( pc8801_irq_mask_w ) |
| 507 | 538 | { |
| 508 | 539 | vrtc_irq_mask = data & 2; |
| r10063 | r10064 | |
| 537 | 568 | { |
| 538 | 569 | misc_ctrl = data; |
| 539 | 570 | |
| 540 | | if(!(data & 0x80)) |
| 541 | | sound_irq_mask = ((data & 0x80) == 0); |
| 571 | sound_irq_mask = ((data & 0x80) == 0); |
| 542 | 572 | } |
| 543 | 573 | |
| 544 | 574 | static WRITE8_HANDLER( pc8801_palram_w ) |
| r10063 | r10064 | |
| 655 | 685 | // AM_RANGE(0xd8, 0xd8) AM_NOP /* GP-IB */ |
| 656 | 686 | // AM_RANGE(0xdc, 0xdf) AM_NOP /* MODEM */ |
| 657 | 687 | // AM_RANGE(0xe2, 0xe3) AM_READWRITE(pc88_extmem_r, pc88_extmem_w) /* expand RAM select */ |
| 658 | | AM_RANGE(0xe4, 0xe4) AM_WRITENOP //AM_WRITE(pc8801_write_interrupt_level) |
| 688 | AM_RANGE(0xe4, 0xe4) AM_WRITE(pc8801_irq_level_w) |
| 659 | 689 | AM_RANGE(0xe6, 0xe6) AM_WRITE(pc8801_irq_mask_w) |
| 660 | 690 | // AM_RANGE(0xe7, 0xe7) AM_NOP /* (unknown) */ |
| 661 | 691 | // AM_RANGE(0xe8, 0xeb) AM_READWRITE(pc88_kanji_r, pc88_kanji_w) |
| r10063 | r10064 | |
| 1045 | 1075 | printf("%02x\n",sound_irq_mask); |
| 1046 | 1076 | |
| 1047 | 1077 | if(sound_irq_mask) |
| 1048 | | cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 4*2); |
| 1078 | pc8801_raise_irq(device->machine,4); |
| 1049 | 1079 | } |
| 1050 | 1080 | |
| 1051 | 1081 | |
| r10063 | r10064 | |
| 1088 | 1118 | NULL |
| 1089 | 1119 | }; |
| 1090 | 1120 | |
| 1091 | | static MACHINE_START( pc8801 ) |
| 1121 | static IRQ_CALLBACK( pc8801_irq_callback ) |
| 1092 | 1122 | { |
| 1123 | int level, i; |
| 1093 | 1124 | |
| 1125 | level = 0; |
| 1126 | for (i = 0; i < 8; i++) |
| 1127 | { |
| 1128 | if ((i8214_irq_state & (1<<i))!=0) |
| 1129 | level = i; |
| 1130 | } |
| 1131 | |
| 1132 | i8214_irq_state &= ~(1<<level); |
| 1133 | return level*2; |
| 1094 | 1134 | } |
| 1095 | 1135 | |
| 1136 | static MACHINE_START( pc8801 ) |
| 1137 | { |
| 1138 | cpu_set_irq_callback(machine->device("maincpu"), pc8801_irq_callback); |
| 1139 | } |
| 1140 | |
| 1096 | 1141 | static MACHINE_RESET( pc8801 ) |
| 1097 | 1142 | { |
| 1098 | 1143 | ext_rom_bank = 0xff; |
| r10063 | r10064 | |
| 1116 | 1161 | |
| 1117 | 1162 | fdc_irq_opcode = 0; //TODO: copied from PC-88VA, could be wrong here ... should be 0x7f ld a,a in the latter case |
| 1118 | 1163 | |
| 1119 | | vrtc_irq_mask = 0; |
| 1120 | | sound_irq_mask = 0; |
| 1121 | | |
| 1122 | 1164 | cpu_set_input_line_vector(machine->device("fdccpu"), 0, 0); |
| 1123 | 1165 | |
| 1124 | 1166 | { |
| r10063 | r10064 | |
| 1136 | 1178 | |
| 1137 | 1179 | beep_set_frequency(machine->device("beeper"),2400); |
| 1138 | 1180 | beep_set_state(machine->device("beeper"),0); |
| 1181 | |
| 1182 | { |
| 1183 | vrtc_irq_mask = 0; |
| 1184 | sound_irq_mask = 0; |
| 1185 | |
| 1186 | i8214_irq_level = 0; |
| 1187 | i8214_irq_state = 0; |
| 1188 | } |
| 1139 | 1189 | } |
| 1140 | 1190 | |
| 1141 | 1191 | static PALETTE_INIT( pc8801 ) |
| r10063 | r10064 | |
| 1159 | 1209 | static INTERRUPT_GEN( pc8801_vrtc_irq ) |
| 1160 | 1210 | { |
| 1161 | 1211 | if(vrtc_irq_mask) |
| 1162 | | cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 2); |
| 1212 | pc8801_raise_irq(device->machine,1); |
| 1163 | 1213 | } |
| 1164 | 1214 | |
| 1165 | 1215 | static MACHINE_CONFIG_START( pc8801, driver_device ) |