src/mame/machine/pcshare.c
| r2186 | r2187 | |
| 34 | 34 | #include "machine/pckeybrd.h" |
| 35 | 35 | |
| 36 | 36 | #ifdef MESS |
| 37 | | #include "machine/uart8250.h" |
| 38 | | #include "video/pc_vga.h" |
| 39 | | #include "video/pc_cga.h" |
| 40 | | #include "video/pc_mda.h" |
| 41 | | #include "video/pc_aga.h" |
| 42 | | |
| 43 | | #include "includes/pc_mouse.h" |
| 44 | 37 | #include "machine/pc_fdc.h" |
| 45 | | |
| 46 | | #include "includes/pclpt.h" |
| 47 | | #include "machine/centroni.h" |
| 48 | | |
| 49 | 38 | #include "machine/pc_hdc.h" |
| 50 | | #include "machine/nec765.h" |
| 51 | 39 | #include "audio/pc.h" |
| 52 | | |
| 53 | | #include "mscommon.h" |
| 54 | 40 | #endif /* MESS */ |
| 55 | 41 | |
| 56 | 42 | #define VERBOSE_DBG 0 /* general debug messages */ |
| r2186 | r2187 | |
| 61 | 47 | #define JOY_LOG(N,M,A) \ |
| 62 | 48 | if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; } |
| 63 | 49 | |
| 64 | | #define FDC_DMA 2 |
| 65 | 50 | |
| 66 | | |
| 67 | 51 | static emu_timer *pc_keyboard_timer; |
| 68 | 52 | |
| 69 | 53 | static TIMER_CALLBACK( pc_keyb_timer ); |
| r2186 | r2187 | |
| 71 | 55 | #define LOG_PORT80 0 |
| 72 | 56 | |
| 73 | 57 | |
| 74 | | |
| 75 | | /* ---------------------------------------------------------------------- */ |
| 76 | | |
| 77 | | #ifdef MESS |
| 78 | | /* called when a interrupt is set/cleared from com hardware */ |
| 79 | | static void pc_com_interrupt(int nr, int state) |
| 80 | | { |
| 81 | | static const int irq[4] = {4, 3, 4, 3}; |
| 82 | | |
| 83 | | /* issue COM1/3 IRQ4, COM2/4 IRQ3 */ |
| 84 | | pic8259_set_irq_line(0, irq[nr], state); |
| 85 | | } |
| 86 | | |
| 87 | | /* called when com registers read/written - used to update peripherals that |
| 88 | | are connected */ |
| 89 | | static void pc_com_refresh_connected(int n, int data) |
| 90 | | { |
| 91 | | /* mouse connected to this port? */ |
| 92 | | if (readinputport(3) & (0x80>>n)) |
| 93 | | pc_mouse_handshake_in(n,data); |
| 94 | | } |
| 95 | | |
| 96 | | /* PC interface to PC-com hardware. Done this way because PCW16 also |
| 97 | | uses PC-com hardware and doesn't have the same setup! */ |
| 98 | | static const uart8250_interface com_interface[4]= |
| 99 | | { |
| 100 | | { |
| 101 | | TYPE8250, |
| 102 | | 1843200, |
| 103 | | pc_com_interrupt, |
| 104 | | NULL, |
| 105 | | pc_com_refresh_connected |
| 106 | | }, |
| 107 | | { |
| 108 | | TYPE8250, |
| 109 | | 1843200, |
| 110 | | pc_com_interrupt, |
| 111 | | NULL, |
| 112 | | pc_com_refresh_connected |
| 113 | | }, |
| 114 | | { |
| 115 | | TYPE8250, |
| 116 | | 1843200, |
| 117 | | pc_com_interrupt, |
| 118 | | NULL, |
| 119 | | pc_com_refresh_connected |
| 120 | | }, |
| 121 | | { |
| 122 | | TYPE8250, |
| 123 | | 1843200, |
| 124 | | pc_com_interrupt, |
| 125 | | NULL, |
| 126 | | pc_com_refresh_connected |
| 127 | | } |
| 128 | | }; |
| 129 | | #endif /* MESS */ |
| 130 | | |
| 131 | | |
| 132 | | |
| 133 | 58 | static void pc_timer0_w(int state) |
| 134 | 59 | { |
| 135 | 60 | pic8259_set_irq_line(0, 0, state); |
| 136 | 61 | } |
| 137 | 62 | |
| 138 | 63 | |
| 139 | | |
| 140 | 64 | /* |
| 141 | 65 | * timer0 heartbeat IRQ |
| 142 | 66 | * timer1 DRAM refresh (ignored) |
| r2186 | r2187 | |
| 191 | 115 | }; |
| 192 | 116 | |
| 193 | 117 | |
| 194 | | #ifdef MESS |
| 195 | | static const PC_LPT_CONFIG lpt_config[3]={ |
| 196 | | { |
| 197 | | 1, |
| 198 | | LPT_UNIDIRECTIONAL, |
| 199 | | NULL |
| 200 | | }, |
| 201 | | { |
| 202 | | 1, |
| 203 | | LPT_UNIDIRECTIONAL, |
| 204 | | NULL |
| 205 | | }, |
| 206 | | { |
| 207 | | 1, |
| 208 | | LPT_UNIDIRECTIONAL, |
| 209 | | NULL |
| 210 | | } |
| 211 | | }; |
| 212 | 118 | |
| 213 | | static const CENTRONICS_CONFIG cent_config[3]={ |
| 214 | | { |
| 215 | | PRINTER_IBM, |
| 216 | | pc_lpt_handshake_in |
| 217 | | }, |
| 218 | | { |
| 219 | | PRINTER_IBM, |
| 220 | | pc_lpt_handshake_in |
| 221 | | }, |
| 222 | | { |
| 223 | | PRINTER_IBM, |
| 224 | | pc_lpt_handshake_in |
| 225 | | } |
| 226 | | }; |
| 227 | | #endif |
| 228 | | |
| 229 | | |
| 230 | | |
| 231 | 119 | /************************************************************************* |
| 232 | 120 | * |
| 233 | 121 | * PC DMA stuff |
| r2186 | r2187 | |
| 381 | 269 | |
| 382 | 270 | /* ----------------------------------------------------------------------- */ |
| 383 | 271 | |
| 384 | | #ifdef MESS |
| 385 | | static void pc_fdc_interrupt(int state) |
| 386 | | { |
| 387 | | pic8259_set_irq_line(0, 6, state); |
| 388 | | } |
| 389 | | |
| 390 | | |
| 391 | | |
| 392 | | static void pc_fdc_dma_drq(int state, int read_) |
| 393 | | { |
| 394 | | dma8237_drq_write(0, FDC_DMA, state); |
| 395 | | } |
| 396 | | |
| 397 | | |
| 398 | | |
| 399 | | static const struct pc_fdc_interface fdc_interface = |
| 400 | | { |
| 401 | | NEC765A, |
| 402 | | NEC765_RDY_PIN_CONNECTED, |
| 403 | | pc_fdc_interrupt, |
| 404 | | pc_fdc_dma_drq, |
| 405 | | }; |
| 406 | | |
| 407 | | static const struct pc_fdc_interface fdc_interface_nc = |
| 408 | | { |
| 409 | | NEC765A, |
| 410 | | NEC765_RDY_PIN_NOT_CONNECTED, |
| 411 | | pc_fdc_interrupt, |
| 412 | | pc_fdc_dma_drq, |
| 413 | | }; |
| 414 | | #endif /* MESS */ |
| 415 | | |
| 416 | | |
| 417 | | |
| 418 | | /* ----------------------------------------------------------------------- */ |
| 419 | | |
| 420 | 272 | static void pc_pic_set_int_line(int which, int interrupt) |
| 421 | 273 | { |
| 422 | 274 | switch(which) |
| r2186 | r2187 | |
| 437 | 289 | |
| 438 | 290 | void init_pc_common(UINT32 flags) |
| 439 | 291 | { |
| 440 | | #ifdef MESS |
| 441 | | /* MESS managed RAM */ |
| 442 | | if (mess_ram) |
| 443 | | memory_set_bankptr(10, mess_ram); |
| 444 | | #endif /* MESS */ |
| 445 | | |
| 446 | 292 | /* PIT */ |
| 447 | 293 | if (flags & PCCOMMON_TIMER_8254) |
| 448 | 294 | pit8253_init(1, &pc_pit8254_config); |
| 449 | 295 | else if (flags & PCCOMMON_TIMER_8253) |
| 450 | 296 | pit8253_init(1, &pc_pit8253_config); |
| 451 | 297 | |
| 452 | | #ifdef MESS |
| 453 | | /* FDC/HDC hardware */ |
| 454 | | pc_fdc_init( ( flags & PCCOMMON_NEC765_RDY_NC ) ? &fdc_interface_nc : &fdc_interface); |
| 455 | | pc_hdc_setup(); |
| 456 | | |
| 457 | | /* com hardware */ |
| 458 | | uart8250_init(0, com_interface); |
| 459 | | uart8250_reset(0); |
| 460 | | uart8250_init(1, com_interface+1); |
| 461 | | uart8250_reset(1); |
| 462 | | uart8250_init(2, com_interface+2); |
| 463 | | uart8250_reset(2); |
| 464 | | uart8250_init(3, com_interface+3); |
| 465 | | uart8250_reset(3); |
| 466 | | |
| 467 | | pc_lpt_config(0, lpt_config); |
| 468 | | centronics_config(0, cent_config); |
| 469 | | pc_lpt_set_device(0, &CENTRONICS_PRINTER_DEVICE); |
| 470 | | pc_lpt_config(1, lpt_config+1); |
| 471 | | centronics_config(1, cent_config+1); |
| 472 | | pc_lpt_set_device(1, &CENTRONICS_PRINTER_DEVICE); |
| 473 | | pc_lpt_config(2, lpt_config+2); |
| 474 | | centronics_config(2, cent_config+2); |
| 475 | | pc_lpt_set_device(2, &CENTRONICS_PRINTER_DEVICE); |
| 476 | | |
| 477 | | /* serial mouse */ |
| 478 | | pc_mouse_set_serial_port(0); |
| 479 | | pc_mouse_initialise(); |
| 480 | | #endif /* MESS */ |
| 481 | | |
| 482 | 298 | /* PC-XT keyboard */ |
| 483 | 299 | if (flags & PCCOMMON_KEYBOARD_AT) |
| 484 | 300 | at_keyboard_init(AT_KEYBOARD_TYPE_AT); |
src/mess/machine/pc.c
| r2186 | r2187 | |
| 36 | 36 | #include "includes/pclpt.h" |
| 37 | 37 | #include "machine/centroni.h" |
| 38 | 38 | |
| 39 | #include "machine/pc_fdc.h" |
| 39 | 40 | #include "machine/pc_hdc.h" |
| 40 | 41 | #include "machine/nec765.h" |
| 41 | 42 | #include "includes/amstr_pc.h" |
| r2186 | r2187 | |
| 47 | 48 | #include "machine/8237dma.h" |
| 48 | 49 | |
| 49 | 50 | |
| 51 | /********************************************************** |
| 52 | * |
| 53 | * COM hardware |
| 54 | * |
| 55 | **********************************************************/ |
| 56 | |
| 57 | /* called when a interrupt is set/cleared from com hardware */ |
| 58 | static void pc_com_interrupt(int nr, int state) |
| 59 | { |
| 60 | static const int irq[4] = {4, 3, 4, 3}; |
| 61 | |
| 62 | /* issue COM1/3 IRQ4, COM2/4 IRQ3 */ |
| 63 | pic8259_set_irq_line(0, irq[nr], state); |
| 64 | } |
| 65 | |
| 66 | /* called when com registers read/written - used to update peripherals that |
| 67 | are connected */ |
| 68 | static void pc_com_refresh_connected(int n, int data) |
| 69 | { |
| 70 | /* mouse connected to this port? */ |
| 71 | if (readinputport(3) & (0x80>>n)) |
| 72 | pc_mouse_handshake_in(n,data); |
| 73 | } |
| 74 | |
| 75 | /* PC interface to PC-com hardware. Done this way because PCW16 also |
| 76 | uses PC-com hardware and doesn't have the same setup! */ |
| 77 | static const uart8250_interface com_interface[4]= |
| 78 | { |
| 79 | { |
| 80 | TYPE8250, |
| 81 | 1843200, |
| 82 | pc_com_interrupt, |
| 83 | NULL, |
| 84 | pc_com_refresh_connected |
| 85 | }, |
| 86 | { |
| 87 | TYPE8250, |
| 88 | 1843200, |
| 89 | pc_com_interrupt, |
| 90 | NULL, |
| 91 | pc_com_refresh_connected |
| 92 | }, |
| 93 | { |
| 94 | TYPE8250, |
| 95 | 1843200, |
| 96 | pc_com_interrupt, |
| 97 | NULL, |
| 98 | pc_com_refresh_connected |
| 99 | }, |
| 100 | { |
| 101 | TYPE8250, |
| 102 | 1843200, |
| 103 | pc_com_interrupt, |
| 104 | NULL, |
| 105 | pc_com_refresh_connected |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | |
| 110 | /********************************************************** |
| 111 | * |
| 112 | * LPT interface |
| 113 | * |
| 114 | **********************************************************/ |
| 115 | |
| 116 | static const PC_LPT_CONFIG lpt_config[3]={ |
| 117 | { |
| 118 | 1, |
| 119 | LPT_UNIDIRECTIONAL, |
| 120 | NULL |
| 121 | }, |
| 122 | { |
| 123 | 1, |
| 124 | LPT_UNIDIRECTIONAL, |
| 125 | NULL |
| 126 | }, |
| 127 | { |
| 128 | 1, |
| 129 | LPT_UNIDIRECTIONAL, |
| 130 | NULL |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | static const CENTRONICS_CONFIG cent_config[3]={ |
| 135 | { |
| 136 | PRINTER_IBM, |
| 137 | pc_lpt_handshake_in |
| 138 | }, |
| 139 | { |
| 140 | PRINTER_IBM, |
| 141 | pc_lpt_handshake_in |
| 142 | }, |
| 143 | { |
| 144 | PRINTER_IBM, |
| 145 | pc_lpt_handshake_in |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | |
| 150 | |
| 151 | /********************************************************** |
| 152 | * |
| 153 | * NEC uPD765 floppy interface |
| 154 | * |
| 155 | **********************************************************/ |
| 156 | |
| 157 | #define FDC_DMA 2 |
| 158 | |
| 159 | static void pc_fdc_interrupt(int state) |
| 160 | { |
| 161 | pic8259_set_irq_line(0, 6, state); |
| 162 | } |
| 163 | |
| 164 | static void pc_fdc_dma_drq(int state, int read_) |
| 165 | { |
| 166 | dma8237_drq_write(0, FDC_DMA, state); |
| 167 | } |
| 168 | |
| 169 | static const struct pc_fdc_interface fdc_interface = |
| 170 | { |
| 171 | NEC765A, |
| 172 | NEC765_RDY_PIN_CONNECTED, |
| 173 | pc_fdc_interrupt, |
| 174 | pc_fdc_dma_drq, |
| 175 | }; |
| 176 | |
| 177 | static const struct pc_fdc_interface fdc_interface_nc = |
| 178 | { |
| 179 | NEC765A, |
| 180 | NEC765_RDY_PIN_NOT_CONNECTED, |
| 181 | pc_fdc_interrupt, |
| 182 | pc_fdc_dma_drq, |
| 183 | }; |
| 184 | |
| 185 | |
| 186 | void mess_init_pc_common(UINT32 flags) { |
| 187 | init_pc_common(flags); |
| 188 | |
| 189 | /* MESS managed RAM */ |
| 190 | if ( mess_ram ) |
| 191 | memory_set_bankptr( 10, mess_ram ); |
| 192 | |
| 193 | /* FDC/HDC hardware */ |
| 194 | pc_fdc_init( ( flags & PCCOMMON_NEC765_RDY_NC ) ? &fdc_interface_nc : &fdc_interface); |
| 195 | pc_hdc_setup(); |
| 196 | |
| 197 | /* com hardware */ |
| 198 | uart8250_init(0, com_interface); |
| 199 | uart8250_reset(0); |
| 200 | uart8250_init(1, com_interface+1); |
| 201 | uart8250_reset(1); |
| 202 | uart8250_init(2, com_interface+2); |
| 203 | uart8250_reset(2); |
| 204 | uart8250_init(3, com_interface+3); |
| 205 | uart8250_reset(3); |
| 206 | |
| 207 | pc_lpt_config(0, lpt_config); |
| 208 | centronics_config(0, cent_config); |
| 209 | pc_lpt_set_device(0, &CENTRONICS_PRINTER_DEVICE); |
| 210 | pc_lpt_config(1, lpt_config+1); |
| 211 | centronics_config(1, cent_config+1); |
| 212 | pc_lpt_set_device(1, &CENTRONICS_PRINTER_DEVICE); |
| 213 | pc_lpt_config(2, lpt_config+2); |
| 214 | centronics_config(2, cent_config+2); |
| 215 | pc_lpt_set_device(2, &CENTRONICS_PRINTER_DEVICE); |
| 216 | |
| 217 | /* serial mouse */ |
| 218 | pc_mouse_set_serial_port(0); |
| 219 | pc_mouse_initialise(); |
| 220 | } |
| 221 | |
| 50 | 222 | DRIVER_INIT( pccga ) |
| 51 | 223 | { |
| 52 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 224 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 53 | 225 | ppi8255_init(&pc_ppi8255_interface); |
| 54 | 226 | pc_rtc_init(); |
| 55 | 227 | pc_turbo_setup(0, 3, 0x02, 4.77/12, 1); |
| r2186 | r2187 | |
| 57 | 229 | |
| 58 | 230 | DRIVER_INIT( bondwell ) |
| 59 | 231 | { |
| 60 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 232 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 61 | 233 | ppi8255_init(&pc_ppi8255_interface); |
| 62 | 234 | pc_turbo_setup(0, 3, 0x02, 4.77/12, 1); |
| 63 | 235 | } |
| 64 | 236 | |
| 65 | 237 | DRIVER_INIT( pcmda ) |
| 66 | 238 | { |
| 67 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 239 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 68 | 240 | ppi8255_init(&pc_ppi8255_interface); |
| 69 | 241 | pc_turbo_setup(0, 3, 0x02, 4.77/12, 1); |
| 70 | 242 | } |
| r2186 | r2187 | |
| 90 | 262 | rom[0xfffff]=256-a; |
| 91 | 263 | } |
| 92 | 264 | |
| 93 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 265 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 94 | 266 | |
| 95 | 267 | europc_rtc_init(); |
| 96 | 268 | // europc_rtc_set_time(machine); |
| r2186 | r2187 | |
| 103 | 275 | /* just a plain bit pattern for graphics data generation */ |
| 104 | 276 | for (i = 0; i < 256; i++) |
| 105 | 277 | gfx[i] = i; |
| 106 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 278 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 107 | 279 | pc_turbo_setup(0, 3, 0x02, 4.77/12, 1); |
| 108 | 280 | } |
| 109 | 281 | |
| r2186 | r2187 | |
| 122 | 294 | videoram=memory_region(REGION_CPU1)+0xb0000; |
| 123 | 295 | memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc200_16le_port378_r ); |
| 124 | 296 | |
| 125 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 297 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 126 | 298 | } |
| 127 | 299 | |
| 128 | 300 | DRIVER_INIT( pc1512 ) |
| r2186 | r2187 | |
| 143 | 315 | memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc16le_parallelport2_r ); |
| 144 | 316 | |
| 145 | 317 | |
| 146 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 318 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 147 | 319 | mc146818_init(MC146818_IGNORE_CENTURY); |
| 148 | 320 | } |
| 149 | 321 | |
| r2186 | r2187 | |
| 206 | 378 | memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc1640_16le_port278_r ); |
| 207 | 379 | memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x4278, 0x427b, 0, 0, pc1640_16le_port4278_r ); |
| 208 | 380 | |
| 209 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 381 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 210 | 382 | |
| 211 | 383 | mc146818_init(MC146818_IGNORE_CENTURY); |
| 212 | 384 | } |
| 213 | 385 | |
| 214 | 386 | DRIVER_INIT( pc_vga ) |
| 215 | 387 | { |
| 216 | | init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 388 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC); |
| 217 | 389 | ppi8255_init(&pc_ppi8255_interface); |
| 218 | 390 | |
| 219 | 391 | pc_vga_init(&vga_interface, NULL); |