src/emu/machine/pit8253.c
| r7461 | r7462 | |
| 56 | 56 | double clockin; /* input clock frequency in Hz */ |
| 57 | 57 | int clock; /* clock signal when clockin is 0 */ |
| 58 | 58 | |
| 59 | | pit8253_output_changed_func output_changed; /* callback function for when output changes */ |
| 59 | devcb_resolved_read_line in_gate_func; /* callback for gate input */ |
| 60 | devcb_resolved_write_line out_out_func; /* callback function for when output changes */ |
| 60 | 61 | |
| 61 | 62 | attotime last_updated; /* time when last updated */ |
| 62 | 63 | |
| r7461 | r7462 | |
| 119 | 120 | } |
| 120 | 121 | |
| 121 | 122 | |
| 123 | static int pit8253_gate(struct pit8253_timer *timer) |
| 124 | { |
| 125 | if (timer->in_gate_func.read != NULL) |
| 126 | return devcb_call_read_line(&timer->in_gate_func); |
| 127 | else |
| 128 | return timer->gate; |
| 129 | } |
| 130 | |
| 131 | |
| 122 | 132 | INLINE UINT32 decimal_from_bcd(UINT16 val) |
| 123 | 133 | { |
| 124 | 134 | /* In BCD mode, a nybble loaded with value A-F counts down the same as in |
| r7461 | r7462 | |
| 219 | 229 | if (output != timer->output) |
| 220 | 230 | { |
| 221 | 231 | timer->output = output; |
| 222 | | if (timer->output_changed != NULL) |
| 223 | | { |
| 224 | | timer->output_changed(device, output); |
| 225 | | } |
| 232 | devcb_call_write_line(&timer->out_out_func, timer->output); |
| 226 | 233 | } |
| 227 | 234 | } |
| 228 | 235 | |
| r7461 | r7462 | |
| 237 | 244 | int cycles_to_output = 0; |
| 238 | 245 | |
| 239 | 246 | LOG2(("pit8253: simulate2(): simulating %d cycles for %d in mode %d, bcd = %d, phase = %d, gate = %d, output %d, value = 0x%04x\n", |
| 240 | | (int)elapsed_cycles,timer->index,mode,bcd,timer->phase,timer->gate,timer->output,timer->value)); |
| 247 | (int)elapsed_cycles,timer->index,mode,bcd,timer->phase,pit8253_gate(timer),timer->output,timer->value)); |
| 241 | 248 | |
| 242 | 249 | switch (mode) { |
| 243 | 250 | case 0: |
| r7461 | r7462 | |
| 276 | 283 | load_counter_value( device, timer ); |
| 277 | 284 | } |
| 278 | 285 | |
| 279 | | if ( timer->gate == 0 ) |
| 286 | if ( pit8253_gate(timer) == 0 ) |
| 280 | 287 | { |
| 281 | 288 | cycles_to_output = CYCLES_NEVER; |
| 282 | 289 | } |
| r7461 | r7462 | |
| 387 | 394 | Rising-edge reloads count and initiates counting |
| 388 | 395 | Gate high enables counting. */ |
| 389 | 396 | |
| 390 | | if (timer->gate == 0 || timer->phase == 0) |
| 397 | if (pit8253_gate(timer) == 0 || timer->phase == 0) |
| 391 | 398 | { |
| 392 | 399 | /* Gate low or mode control write forces output high */ |
| 393 | 400 | set_output(device, timer, 1); |
| r7461 | r7462 | |
| 466 | 473 | Rising-edge reloads count and initiates counting |
| 467 | 474 | Gate high enables counting. */ |
| 468 | 475 | |
| 469 | | if (timer->gate == 0 || timer->phase == 0) |
| 476 | if (pit8253_gate(timer) == 0 || timer->phase == 0) |
| 470 | 477 | { |
| 471 | 478 | /* Gate low or mode control write forces output high */ |
| 472 | 479 | set_output(device, timer, 1); |
| r7461 | r7462 | |
| 549 | 556 | Mode 4 only: Gate level sensitive only. Low disables counting, high enables it. |
| 550 | 557 | Mode 5 only: Gate rising-edge sensitive only. Rising edge initiates counting */ |
| 551 | 558 | |
| 552 | | if (timer->gate == 0 && mode == 4) |
| 559 | if (pit8253_gate(timer) == 0 && mode == 4) |
| 553 | 560 | { |
| 554 | 561 | cycles_to_output = CYCLES_NEVER; |
| 555 | 562 | } |
| r7461 | r7462 | |
| 611 | 618 | } |
| 612 | 619 | |
| 613 | 620 | LOG2(("pit8253: simulate2(): simulating %d cycles for %d in mode %d, bcd = %d, phase = %d, gate = %d, output %d, value = 0x%04x, cycles_to_output = %04x\n", |
| 614 | | (int)elapsed_cycles,timer->index,mode,bcd,timer->phase,timer->gate,timer->output,timer->value,cycles_to_output)); |
| 621 | (int)elapsed_cycles,timer->index,mode,bcd,timer->phase,pit8253_gate(timer),timer->output,timer->value,cycles_to_output)); |
| 615 | 622 | } |
| 616 | 623 | |
| 617 | 624 | |
| r7461 | r7462 | |
| 974 | 981 | } |
| 975 | 982 | } |
| 976 | 983 | |
| 977 | | |
| 978 | | WRITE8_DEVICE_HANDLER( pit8253_gate_w ) |
| 984 | static void pit8253_gate_w(running_device *device, int gate, int state) |
| 979 | 985 | { |
| 980 | 986 | pit8253_t *pit8253 = get_safe_token(device); |
| 981 | | struct pit8253_timer *timer = get_timer(pit8253,offset); |
| 982 | | int mode; |
| 983 | | int gate = (data!=0 ? 1 : 0); |
| 987 | struct pit8253_timer *timer = get_timer(pit8253, gate); |
| 984 | 988 | |
| 985 | | LOG2(("pit8253_gate_w(): offset=%d gate=%d\n", offset, data)); |
| 989 | LOG2(("pit8253_gate_w(): gate=%d state=%d\n", gate, state)); |
| 986 | 990 | |
| 987 | 991 | if (timer == NULL) |
| 988 | 992 | return; |
| 989 | 993 | |
| 990 | | mode = CTRL_MODE(timer->control); |
| 991 | | |
| 992 | | if (gate != timer->gate) |
| 994 | if (timer->in_gate_func.read != NULL) |
| 993 | 995 | { |
| 994 | | update(device, timer); |
| 995 | | timer->gate = gate; |
| 996 | | if (gate != 0 && ( mode == 1 || mode == 2 || mode == 5 )) |
| 996 | logerror("pit8253_gate_w: write has no effect because a read handler is already defined!\n"); |
| 997 | } |
| 998 | else |
| 999 | { |
| 1000 | if (state != timer->gate) |
| 997 | 1001 | { |
| 998 | | timer->phase = 1; |
| 1002 | int mode = CTRL_MODE(timer->control); |
| 1003 | |
| 1004 | update(device, timer); |
| 1005 | timer->gate = state; |
| 1006 | if (state != 0 && ( mode == 1 || mode == 2 || mode == 5 )) |
| 1007 | { |
| 1008 | timer->phase = 1; |
| 1009 | } |
| 1010 | update(device, timer); |
| 999 | 1011 | } |
| 1000 | | update(device, timer); |
| 1001 | 1012 | } |
| 1002 | 1013 | } |
| 1003 | 1014 | |
| 1015 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate0_w ) { pit8253_gate_w(device, 0, state); } |
| 1016 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate1_w ) { pit8253_gate_w(device, 1, state); } |
| 1017 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate2_w ) { pit8253_gate_w(device, 2, state); } |
| 1004 | 1018 | |
| 1005 | 1019 | |
| 1006 | 1020 | /* ----------------------------------------------------------------------- */ |
| r7461 | r7462 | |
| 1032 | 1046 | } |
| 1033 | 1047 | |
| 1034 | 1048 | |
| 1035 | | void pit8253_set_clock_signal(running_device *device, int timerno, int state) |
| 1049 | static void pit8253_set_clock_signal(running_device *device, int timerno, int state) |
| 1036 | 1050 | { |
| 1037 | 1051 | pit8253_t *pit8253 = get_safe_token(device); |
| 1038 | 1052 | struct pit8253_timer *timer = get_timer(pit8253,timerno); |
| r7461 | r7462 | |
| 1048 | 1062 | timer->clock = state; |
| 1049 | 1063 | } |
| 1050 | 1064 | |
| 1065 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk0_w ) { pit8253_set_clock_signal(device, 0, state); } |
| 1066 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk1_w ) { pit8253_set_clock_signal(device, 1, state); } |
| 1067 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk2_w ) { pit8253_set_clock_signal(device, 2, state); } |
| 1051 | 1068 | |
| 1069 | |
| 1052 | 1070 | static void common_start( running_device *device, int device_type ) { |
| 1053 | 1071 | pit8253_t *pit8253 = get_safe_token(device); |
| 1054 | 1072 | int timerno; |
| r7461 | r7462 | |
| 1059 | 1077 | /* register for state saving */ |
| 1060 | 1078 | for (timerno = 0; timerno < MAX_TIMER; timerno++) |
| 1061 | 1079 | { |
| 1062 | | struct pit8253_timer *timer = get_timer(pit8253,timerno); |
| 1080 | struct pit8253_timer *timer = get_timer(pit8253, timerno); |
| 1063 | 1081 | |
| 1082 | /* initialize timer */ |
| 1064 | 1083 | timer->clockin = pit8253->config->timer[timerno].clockin; |
| 1065 | | timer->output_changed = pit8253->config->timer[timerno].output_changed; |
| 1066 | | |
| 1067 | 1084 | timer->updatetimer = timer_alloc(device->machine, update_timer_cb, (void *)device); |
| 1068 | 1085 | timer_adjust_oneshot(timer->updatetimer, attotime_never, timerno); |
| 1069 | 1086 | |
| 1087 | /* resolve callbacks */ |
| 1088 | devcb_resolve_read_line(&timer->in_gate_func, &pit8253->config->timer[timerno].in_gate_func, device); |
| 1089 | devcb_resolve_write_line(&timer->out_out_func, &pit8253->config->timer[timerno].out_out_func, device); |
| 1090 | |
| 1070 | 1091 | /* set up state save values */ |
| 1071 | 1092 | state_save_register_device_item(device, timerno, timer->clockin); |
| 1072 | 1093 | state_save_register_device_item(device, timerno, timer->control); |
| r7461 | r7462 | |
| 1116 | 1137 | timer->rmsb = timer->wmsb = 0; |
| 1117 | 1138 | timer->count = timer->value = timer->latch = 0; |
| 1118 | 1139 | timer->lowcount = 0; |
| 1119 | | timer->gate = 1; |
| 1140 | |
| 1141 | if (timer->in_gate_func.read != NULL) |
| 1142 | timer->gate = devcb_call_read_line(&timer->in_gate_func); |
| 1143 | else |
| 1144 | timer->gate = 1; |
| 1145 | |
| 1120 | 1146 | timer->output = 2; /* output is undetermined */ |
| 1121 | 1147 | timer->latched_count = 0; |
| 1122 | 1148 | timer->latched_status = 0; |
src/emu/machine/pit8253.h
| r7461 | r7462 | |
| 1 | | /***************************************************************************** |
| 2 | | * |
| 3 | | * Programmable Interval Timer 8253/8254 |
| 4 | | * |
| 5 | | *****************************************************************************/ |
| 1 | /*************************************************************************** |
| 6 | 2 | |
| 7 | | #ifndef __PIT8253_H_ |
| 8 | | #define __PIT8253_H_ |
| 3 | Intel 8253/8254 |
| 9 | 4 | |
| 10 | | #define PIT8253 DEVICE_GET_INFO_NAME(pit8253) |
| 11 | | #define PIT8254 DEVICE_GET_INFO_NAME(pit8254) |
| 5 | Programmable Interval Timer |
| 12 | 6 | |
| 7 | _____ _____ |
| 8 | D7 1 |* \_/ | 24 VCC |
| 9 | D6 2 | | 23 _WR |
| 10 | D5 3 | | 22 _RD |
| 11 | D4 4 | | 21 _CS |
| 12 | D3 5 | | 20 A1 |
| 13 | D2 6 | | 19 A0 |
| 14 | D1 7 | 8259A | 18 CLK2 |
| 15 | D0 8 | | 17 OUT2 |
| 16 | CLK0 9 | | 16 GATE2 |
| 17 | OUT0 10 | | 15 CLK1 |
| 18 | GATE0 11 | | 14 GATE1 |
| 19 | GND 12 |_____________| 13 OUT1 |
| 13 | 20 | |
| 14 | | typedef void (*pit8253_output_changed_func)(running_device *device, int state); |
| 15 | | #define PIT8253_OUTPUT_CHANGED(name) void name(running_device *device, int state ) |
| 21 | ***************************************************************************/ |
| 16 | 22 | |
| 23 | #ifndef __PIT8253_H__ |
| 24 | #define __PIT8253_H__ |
| 17 | 25 | |
| 26 | #include "devcb.h" |
| 27 | |
| 28 | |
| 29 | #define PIT8253 DEVICE_GET_INFO_NAME(pit8253) |
| 30 | #define PIT8254 DEVICE_GET_INFO_NAME(pit8254) |
| 31 | |
| 18 | 32 | struct pit8253_config |
| 19 | 33 | { |
| 20 | 34 | struct |
| 21 | 35 | { |
| 22 | | /* Input clock for this timer */ |
| 23 | | double clockin; |
| 24 | | |
| 25 | | /* If specified, this gets called whenever the output for this timer changes */ |
| 26 | | pit8253_output_changed_func output_changed; |
| 27 | | |
| 36 | double clockin; /* timer clock */ |
| 37 | devcb_read_line in_gate_func; /* gate signal */ |
| 38 | devcb_write_line out_out_func; /* out signal */ |
| 28 | 39 | } timer[3]; |
| 29 | 40 | }; |
| 30 | 41 | |
| r7461 | r7462 | |
| 50 | 61 | READ8_DEVICE_HANDLER( pit8253_r ); |
| 51 | 62 | WRITE8_DEVICE_HANDLER( pit8253_w ); |
| 52 | 63 | |
| 53 | | WRITE8_DEVICE_HANDLER( pit8253_gate_w ); |
| 64 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk0_w ); |
| 65 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk1_w ); |
| 66 | WRITE_LINE_DEVICE_HANDLER( pit8253_clk2_w ); |
| 54 | 67 | |
| 68 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate0_w ); |
| 69 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate1_w ); |
| 70 | WRITE_LINE_DEVICE_HANDLER( pit8253_gate2_w ); |
| 55 | 71 | |
| 56 | 72 | /* In the 8253/8254 the CLKx input lines can be attached to a regular clock |
| 57 | 73 | signal. Another option is to use the output from one timer as the input |
| r7461 | r7462 | |
| 60 | 76 | The functions below should supply both functionalities. If the signal is |
| 61 | 77 | a regular clock signal, use the pit8253_set_clockin function. If the |
| 62 | 78 | CLKx input signal is the output of the different source, set the new_clockin |
| 63 | | to 0 with pit8253_set_clockin and call pit8253_set_clock_signal to change |
| 79 | to 0 with pit8253_set_clockin and call pit8253_clkX_w to change |
| 64 | 80 | the state of the input CLKx signal. |
| 65 | 81 | */ |
| 66 | 82 | int pit8253_get_output(running_device *device, int timer); |
| 67 | 83 | void pit8253_set_clockin(running_device *device, int timer, double new_clockin); |
| 68 | | void pit8253_set_clock_signal(running_device *device, int timer, int state); |
| 69 | 84 | |
| 70 | 85 | |
| 71 | | #endif /* __PIT8253_H_ */ |
| 72 | | |
| 86 | #endif /* __PIT8253_H__ */ |
src/mess/machine/mz700.c
| r7461 | r7462 | |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | | static PIT8253_OUTPUT_CHANGED( pit_out0_changed ); |
| 56 | | static PIT8253_OUTPUT_CHANGED( pit_out1_changed ); |
| 57 | | static PIT8253_OUTPUT_CHANGED( pit_irq_2 ); |
| 55 | static WRITE_LINE_DEVICE_HANDLER( pit_out0_changed ); |
| 56 | static WRITE_LINE_DEVICE_HANDLER( pit_irq_2 ); |
| 58 | 57 | |
| 59 | 58 | const struct pit8253_config mz700_pit8253_config = |
| 60 | 59 | { |
| 61 | 60 | { |
| 62 | | /* clockin callback */ |
| 63 | | { XTAL_17_73447MHz/20, pit_out0_changed }, |
| 64 | | { 15611.0, pit_out1_changed }, |
| 65 | | { 0, pit_irq_2 }, |
| 61 | /* clockin gate callback */ |
| 62 | { XTAL_17_73447MHz/20, DEVCB_NULL, DEVCB_LINE(pit_out0_changed) }, |
| 63 | { 15611.0, DEVCB_LINE_VCC, DEVCB_LINE(pit8253_clk2_w) }, |
| 64 | { 0, DEVCB_LINE_VCC, DEVCB_LINE(pit_irq_2) }, |
| 66 | 65 | } |
| 67 | 66 | }; |
| 68 | 67 | |
| 69 | 68 | const struct pit8253_config mz800_pit8253_config = |
| 70 | 69 | { |
| 71 | 70 | { |
| 72 | | /* clockin callback */ |
| 73 | | { XTAL_17_73447MHz/16, pit_out0_changed }, |
| 74 | | { 15611.0, pit_out1_changed }, |
| 75 | | { 0, pit_irq_2 }, |
| 71 | /* clockin gate callback */ |
| 72 | { XTAL_17_73447MHz/16, DEVCB_NULL, DEVCB_LINE(pit_out0_changed) }, |
| 73 | { 15611.0, DEVCB_LINE_VCC, DEVCB_LINE(pit8253_clk2_w) }, |
| 74 | { 0, DEVCB_LINE_VCC, DEVCB_LINE(pit_irq_2) }, |
| 76 | 75 | } |
| 77 | 76 | }; |
| 78 | 77 | |
| r7461 | r7462 | |
| 130 | 129 | |
| 131 | 130 | data |= mz->other_timer; |
| 132 | 131 | data |= input_port_read(space->machine, "JOY"); |
| 133 | | data |= video_screen_get_hblank(space->machine->primary_screen); |
| 132 | data |= video_screen_get_hblank(space->machine->primary_screen) << 7; |
| 134 | 133 | |
| 135 | 134 | LOG(1, "mz700_e008_r", ("%02X\n", data), space->machine); |
| 136 | 135 | |
| 137 | 136 | return data; |
| 138 | 137 | } |
| 139 | 138 | |
| 139 | static WRITE8_HANDLER( mz700_e008_w ) |
| 140 | { |
| 141 | mz_state *mz = (mz_state *)space->machine->driver_data; |
| 142 | pit8253_gate0_w(mz->pit, BIT(data, 0)); |
| 143 | } |
| 140 | 144 | |
| 145 | |
| 141 | 146 | /*************************************************************************** |
| 142 | 147 | BANK SWITCHING |
| 143 | 148 | ***************************************************************************/ |
| r7461 | r7462 | |
| 283 | 288 | { |
| 284 | 289 | memory_install_readwrite8_device_handler(spc, mz->ppi, 0xe000, 0xfff3, 0, 0x1ff0, i8255a_r, i8255a_w); |
| 285 | 290 | memory_install_readwrite8_device_handler(spc, mz->pit, 0xe004, 0xfff7, 0, 0x1ff0, pit8253_r, pit8253_w); |
| 286 | | memory_install_read8_handler(spc, 0xe008, 0xfff8, 0, 0x1ff0, mz700_e008_r); |
| 287 | | memory_install_write8_device_handler(spc, mz->pit, 0xe008, 0xfff8, 0, 0x1ff0, pit8253_gate_w); |
| 291 | memory_install_readwrite8_handler(spc, 0xe008, 0xfff8, 0, 0x1ff0, mz700_e008_r, mz700_e008_w); |
| 288 | 292 | } |
| 289 | 293 | else |
| 290 | 294 | { |
| 291 | 295 | memory_install_readwrite8_device_handler(spc, mz->ppi, 0xe000, 0xe003, 0, 0, i8255a_r, i8255a_w); |
| 292 | 296 | memory_install_readwrite8_device_handler(spc, mz->pit, 0xe004, 0xe007, 0, 0, pit8253_r, pit8253_w); |
| 293 | | memory_install_read8_handler(spc, 0xe008, 0xe008, 0, 0, mz700_e008_r); |
| 294 | | memory_install_write8_device_handler(spc, mz->pit, 0xe008, 0xe008, 0, 0, pit8253_gate_w); |
| 297 | memory_install_readwrite8_handler(spc, 0xe008, 0xe008, 0, 0, mz700_e008_r, mz700_e008_w); |
| 295 | 298 | } |
| 296 | 299 | } |
| 297 | 300 | } |
| r7461 | r7462 | |
| 417 | 420 | static UINT8 speaker_level = 0; |
| 418 | 421 | static UINT8 prev_state = 0; |
| 419 | 422 | |
| 420 | | static PIT8253_OUTPUT_CHANGED( pit_out0_changed ) |
| 423 | static WRITE_LINE_DEVICE_HANDLER( pit_out0_changed ) |
| 421 | 424 | { |
| 422 | 425 | running_device *speaker = devtag_get_device(device->machine, "speaker"); |
| 423 | 426 | if((prev_state==0) && (state==1)) { |
| r7461 | r7462 | |
| 427 | 430 | speaker_level_w( speaker, speaker_level); |
| 428 | 431 | } |
| 429 | 432 | |
| 430 | | |
| 431 | | /* Timer 1 is the clock for timer 2 clock input */ |
| 432 | | static PIT8253_OUTPUT_CHANGED( pit_out1_changed ) |
| 433 | | { |
| 434 | | pit8253_set_clock_signal(device, 2, state); |
| 435 | | } |
| 436 | | |
| 437 | | |
| 438 | 433 | /* timer 2 is the AM/PM (12 hour) interrupt */ |
| 439 | | static PIT8253_OUTPUT_CHANGED( pit_irq_2 ) |
| 434 | static WRITE_LINE_DEVICE_HANDLER( pit_irq_2 ) |
| 440 | 435 | { |
| 441 | 436 | mz_state *mz = (mz_state *)device->machine->driver_data; |
| 442 | 437 | |
src/mess/machine/special.c
| r7461 | r7462 | |
| 207 | 207 | specimx_set_bank(space->machine, offset, data); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | | static PIT8253_OUTPUT_CHANGED( specimx_pit8253_out0_changed ) |
| 210 | static WRITE_LINE_DEVICE_HANDLER( specimx_pit8253_out0_changed ) |
| 211 | 211 | { |
| 212 | 212 | specimx_set_input( device->machine, 0, state ); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | |
| 217 | | static PIT8253_OUTPUT_CHANGED(specimx_pit8253_out1_changed) |
| 217 | static WRITE_LINE_DEVICE_HANDLER(specimx_pit8253_out1_changed) |
| 218 | 218 | { |
| 219 | 219 | specimx_set_input( device->machine, 1, state ); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | |
| 224 | | static PIT8253_OUTPUT_CHANGED(specimx_pit8253_out2_changed) |
| 224 | static WRITE_LINE_DEVICE_HANDLER(specimx_pit8253_out2_changed) |
| 225 | 225 | { |
| 226 | 226 | specimx_set_input( device->machine, 2, state ); |
| 227 | 227 | } |
| r7461 | r7462 | |
| 233 | 233 | { |
| 234 | 234 | { |
| 235 | 235 | 2000000, |
| 236 | | specimx_pit8253_out0_changed |
| 236 | DEVCB_NULL, |
| 237 | DEVCB_LINE(specimx_pit8253_out0_changed) |
| 237 | 238 | }, |
| 238 | 239 | { |
| 239 | 240 | 2000000, |
| 240 | | specimx_pit8253_out1_changed |
| 241 | DEVCB_NULL, |
| 242 | DEVCB_LINE(specimx_pit8253_out1_changed) |
| 241 | 243 | }, |
| 242 | 244 | { |
| 243 | 245 | 2000000, |
| 244 | | specimx_pit8253_out2_changed |
| 246 | DEVCB_NULL, |
| 247 | DEVCB_LINE(specimx_pit8253_out2_changed) |
| 245 | 248 | } |
| 246 | 249 | } |
| 247 | 250 | }; |
| r7461 | r7462 | |
| 256 | 259 | { |
| 257 | 260 | running_device *pit8253 = devtag_get_device(machine, "pit8253"); |
| 258 | 261 | |
| 259 | | pit8253_gate_w(pit8253, 0, 0); |
| 260 | | pit8253_gate_w(pit8253, 1, 0); |
| 261 | | pit8253_gate_w(pit8253, 2, 0); |
| 262 | pit8253_gate0_w(pit8253, 0); |
| 263 | pit8253_gate1_w(pit8253, 0); |
| 264 | pit8253_gate2_w(pit8253, 0); |
| 262 | 265 | } |
| 263 | 266 | |
| 264 | 267 | MACHINE_RESET( specimx ) |
src/mess/machine/mz80.c
| r7461 | r7462 | |
| 70 | 70 | |
| 71 | 71 | static UINT8 speaker_level = 0; |
| 72 | 72 | static UINT8 prev_state = 0; |
| 73 | | static PIT8253_OUTPUT_CHANGED( pit_out0_changed ) |
| 73 | |
| 74 | static WRITE_LINE_DEVICE_HANDLER( pit_out0_changed ) |
| 74 | 75 | { |
| 75 | 76 | running_device *speaker = devtag_get_device(device->machine, "speaker"); |
| 76 | 77 | if((prev_state==0) && (state==1)) { |
| r7461 | r7462 | |
| 80 | 81 | speaker_level_w( speaker, speaker_level); |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | | |
| 84 | | static PIT8253_OUTPUT_CHANGED( pit_out1_changed ) |
| 84 | static WRITE_LINE_DEVICE_HANDLER( pit_out2_changed ) |
| 85 | 85 | { |
| 86 | | pit8253_set_clock_signal( device, 2, state ); |
| 87 | | } |
| 88 | | |
| 89 | | |
| 90 | | static PIT8253_OUTPUT_CHANGED( pit_out2_changed ) |
| 91 | | { |
| 92 | 86 | cputag_set_input_line(device->machine, "maincpu", 0, HOLD_LINE); |
| 93 | 87 | } |
| 94 | 88 | |
| r7461 | r7462 | |
| 105 | 99 | const struct pit8253_config mz80k_pit8253_config = |
| 106 | 100 | { |
| 107 | 101 | { |
| 108 | | /* clockin irq callback */ |
| 109 | | { XTAL_8MHz/ 4, pit_out0_changed }, |
| 110 | | { XTAL_8MHz/256, pit_out1_changed }, |
| 111 | | { 0, pit_out2_changed }, |
| 102 | /* clockin gate callback */ |
| 103 | { XTAL_8MHz/ 4, DEVCB_NULL, DEVCB_LINE(pit_out0_changed) }, |
| 104 | { XTAL_8MHz/256, DEVCB_NULL, DEVCB_LINE(pit8253_clk2_w) }, |
| 105 | { 0, DEVCB_NULL, DEVCB_LINE(pit_out2_changed) }, |
| 112 | 106 | } |
| 113 | 107 | }; |
| 114 | 108 | |
| r7461 | r7462 | |
| 119 | 113 | WRITE8_HANDLER(mz80k_strobe_w) |
| 120 | 114 | { |
| 121 | 115 | running_device *pit = devtag_get_device(space->machine, "pit8253"); |
| 122 | | pit8253_gate_w(pit,0,data); |
| 116 | pit8253_gate0_w(pit, BIT(data, 0)); |
| 123 | 117 | } |
| 124 | | |
src/mess/machine/pc.c
| r7461 | r7462 | |
| 269 | 269 | * |
| 270 | 270 | *************************************************************/ |
| 271 | 271 | |
| 272 | | static PIT8253_OUTPUT_CHANGED( ibm5150_pit8253_out0_changed ) |
| 272 | static WRITE_LINE_DEVICE_HANDLER( ibm5150_pit8253_out1_changed ) |
| 273 | 273 | { |
| 274 | 274 | pc_state *st = (pc_state *)device->machine->driver_data; |
| 275 | | pic8259_ir0_w(st->pic8259, state); |
| 276 | | } |
| 277 | | |
| 278 | | |
| 279 | | static PIT8253_OUTPUT_CHANGED( ibm5150_pit8253_out1_changed ) |
| 280 | | { |
| 281 | | pc_state *st = (pc_state *)device->machine->driver_data; |
| 282 | 275 | /* Trigger DMA channel #0 */ |
| 283 | 276 | if ( st->out1 == 0 && state == 1 && st->u73_q2 == 0 ) |
| 284 | 277 | { |
| r7461 | r7462 | |
| 289 | 282 | } |
| 290 | 283 | |
| 291 | 284 | |
| 292 | | static PIT8253_OUTPUT_CHANGED( ibm5150_pit8253_out2_changed ) |
| 285 | static WRITE_LINE_DEVICE_HANDLER( ibm5150_pit8253_out2_changed ) |
| 293 | 286 | { |
| 294 | 287 | pc_speaker_set_input( device->machine, state ); |
| 295 | 288 | } |
| r7461 | r7462 | |
| 300 | 293 | { |
| 301 | 294 | { |
| 302 | 295 | XTAL_14_31818MHz/12, /* heartbeat IRQ */ |
| 303 | | ibm5150_pit8253_out0_changed |
| 296 | DEVCB_NULL, |
| 297 | DEVCB_DEVICE_LINE("pic8259", pic8259_ir0_w) |
| 304 | 298 | }, { |
| 305 | 299 | XTAL_14_31818MHz/12, /* dram refresh */ |
| 306 | | ibm5150_pit8253_out1_changed |
| 300 | DEVCB_NULL, |
| 301 | DEVCB_LINE(ibm5150_pit8253_out1_changed) |
| 307 | 302 | }, { |
| 308 | 303 | XTAL_14_31818MHz/12, /* pio port c pin 4, and speaker polling enough */ |
| 309 | | ibm5150_pit8253_out2_changed |
| 304 | DEVCB_NULL, |
| 305 | DEVCB_LINE(ibm5150_pit8253_out2_changed) |
| 310 | 306 | } |
| 311 | 307 | } |
| 312 | 308 | }; |
| r7461 | r7462 | |
| 323 | 319 | { |
| 324 | 320 | { |
| 325 | 321 | XTAL_14_31818MHz/12, /* heartbeat IRQ */ |
| 326 | | ibm5150_pit8253_out0_changed |
| 322 | DEVCB_NULL, |
| 323 | DEVCB_DEVICE_LINE("pic8259", pic8259_ir0_w) |
| 327 | 324 | }, { |
| 328 | 325 | XTAL_14_31818MHz/12, /* dram refresh */ |
| 329 | | NULL |
| 326 | DEVCB_NULL, |
| 327 | DEVCB_NULL |
| 330 | 328 | }, { |
| 331 | 329 | XTAL_14_31818MHz/12, /* pio port c pin 4, and speaker polling enough */ |
| 332 | | ibm5150_pit8253_out2_changed |
| 330 | DEVCB_NULL, |
| 331 | DEVCB_LINE(ibm5150_pit8253_out2_changed) |
| 333 | 332 | } |
| 334 | 333 | } |
| 335 | 334 | }; |
| r7461 | r7462 | |
| 744 | 743 | st->ppi_portc_switch_high = data & 0x08; |
| 745 | 744 | st->ppi_keyboard_clear = data & 0x80; |
| 746 | 745 | st->ppi_keyb_clock = data & 0x40; |
| 747 | | pit8253_gate_w( st->pit8253, 2, data & 1); |
| 746 | pit8253_gate2_w(st->pit8253, BIT(data, 0)); |
| 748 | 747 | pc_speaker_set_spkrdata( device->machine, data & 0x02 ); |
| 749 | 748 | |
| 750 | 749 | cassette_change_state( devtag_get_device(device->machine, "cassette"), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| r7461 | r7462 | |
| 902 | 901 | st->ppi_portc_switch_high = data & 0x08; |
| 903 | 902 | st->ppi_keyboard_clear = data & 0x80; |
| 904 | 903 | st->ppi_keyb_clock = data & 0x40; |
| 905 | | pit8253_gate_w( st->pit8253, 2, data & 0x01 ); |
| 904 | pit8253_gate2_w(st->pit8253, BIT(data, 0)); |
| 906 | 905 | pc_speaker_set_spkrdata( device->machine, data & 0x02 ); |
| 907 | 906 | |
| 908 | 907 | st->ppi_clock_signal = ( st->ppi_keyb_clock ) ? 1 : 0; |
| r7461 | r7462 | |
| 966 | 965 | st->ppi_portc_switch_high = data & 0x08; |
| 967 | 966 | st->ppi_keyboard_clear = data & 0x80; |
| 968 | 967 | st->ppi_keyb_clock = data & 0x40; |
| 969 | | pit8253_gate_w( st->pit8253, 2, data & 0x01 ); |
| 968 | pit8253_gate2_w(st->pit8253, BIT(data, 0)); |
| 970 | 969 | pc_speaker_set_spkrdata( device->machine, data & 0x02 ); |
| 971 | 970 | pc_keyb_set_clock( st->ppi_keyb_clock ); |
| 972 | 971 | |
| r7461 | r7462 | |
| 992 | 991 | /* KB controller port B */ |
| 993 | 992 | st->ppi_portb = data; |
| 994 | 993 | st->ppi_portc_switch_high = data & 0x08; |
| 995 | | pit8253_gate_w( devtag_get_device(device->machine, "pit8253"), 2, data & 1); |
| 994 | pit8253_gate2_w(devtag_get_device(device->machine, "pit8253"), BIT(data, 0)); |
| 996 | 995 | pc_speaker_set_spkrdata( device->machine, data & 0x02 ); |
| 997 | 996 | |
| 998 | 997 | cassette_change_state( devtag_get_device(device->machine, "cassette"), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
src/mess/drivers/tandy2k.c
| r7461 | r7462 | |
| 99 | 99 | state->extclk = BIT(data, 1);
|
| 100 | 100 | |
| 101 | 101 | /* speaker gate */
|
| 102 | | pit8253_gate_w(state->pit, 0, BIT(data, 2));
|
| 102 | pit8253_gate0_w(state->pit, BIT(data, 2));
|
| 103 | 103 | |
| 104 | 104 | /* speaker data */
|
| 105 | 105 | state->spkrdata = BIT(data, 3);
|
| 106 | 106 | speaker_update(state);
|
| 107 | 107 | |
| 108 | 108 | /* refresh and baud rate clocks */
|
| 109 | | pit8253_gate_w(state->pit, 1, BIT(data, 4));
|
| 110 | | pit8253_gate_w(state->pit, 2, BIT(data, 4));
|
| 109 | pit8253_gate1_w(state->pit, BIT(data, 4));
|
| 110 | pit8253_gate2_w(state->pit, BIT(data, 4));
|
| 111 | 111 | |
| 112 | 112 | /* FDC reset */
|
| 113 | 113 | upd765_reset_w(state->fdc, BIT(data, 5));
|
| r7461 | r7462 | |
| 472 | 472 | |
| 473 | 473 | /* Intel 8253 Interface */
|
| 474 | 474 | |
| 475 | | static PIT8253_OUTPUT_CHANGED( outspkr_w )
|
| 475 | static WRITE_LINE_DEVICE_HANDLER( outspkr_w )
|
| 476 | 476 | {
|
| 477 | 477 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 478 | 478 | |
| r7461 | r7462 | |
| 480 | 480 | speaker_update(driver_state);
|
| 481 | 481 | }
|
| 482 | 482 | |
| 483 | | static PIT8253_OUTPUT_CHANGED( intbrclk_w )
|
| 483 | static WRITE_LINE_DEVICE_HANDLER( intbrclk_w )
|
| 484 | 484 | {
|
| 485 | 485 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 486 | 486 | |
| r7461 | r7462 | |
| 491 | 491 | }
|
| 492 | 492 | }
|
| 493 | 493 | |
| 494 | | static PIT8253_OUTPUT_CHANGED( rfrqpulse_w )
|
| 494 | static WRITE_LINE_DEVICE_HANDLER( rfrqpulse_w )
|
| 495 | 495 | {
|
| 496 | 496 | }
|
| 497 | 497 | |
| r7461 | r7462 | |
| 500 | 500 | {
|
| 501 | 501 | {
|
| 502 | 502 | XTAL_16MHz/16,
|
| 503 | | outspkr_w
|
| 503 | DEVCB_NULL,
|
| 504 | DEVCB_LINE(outspkr_w)
|
| 504 | 505 | }, {
|
| 505 | 506 | XTAL_16MHz/8,
|
| 506 | | intbrclk_w
|
| 507 | DEVCB_NULL,
|
| 508 | DEVCB_LINE(intbrclk_w)
|
| 507 | 509 | }, {
|
| 508 | 510 | XTAL_16MHz/8,
|
| 509 | | rfrqpulse_w
|
| 511 | DEVCB_NULL,
|
| 512 | DEVCB_LINE(rfrqpulse_w)
|
| 510 | 513 | }
|
| 511 | 514 | }
|
| 512 | 515 | };
|
src/mess/drivers/bw2.c
| r7461 | r7462 | |
| 430 | 430 | |
| 431 | 431 | /* PIT */ |
| 432 | 432 | |
| 433 | | static PIT8253_OUTPUT_CHANGED( bw2_timer0_w ) |
| 433 | static WRITE_LINE_DEVICE_HANDLER( bw2_timer0_w ) |
| 434 | 434 | { |
| 435 | 435 | bw2_state *driver_state = (bw2_state *)device->machine->driver_data; |
| 436 | 436 | |
| r7461 | r7462 | |
| 438 | 438 | msm8251_receive_clock(driver_state->msm8251); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | | static PIT8253_OUTPUT_CHANGED( bw2_timer1_w ) |
| 441 | static WRITE_LINE_DEVICE_HANDLER( bw2_timer2_w ) |
| 442 | 442 | { |
| 443 | | pit8253_set_clock_signal(device, 2, state); |
| 444 | | } |
| 445 | | |
| 446 | | static PIT8253_OUTPUT_CHANGED( bw2_timer2_w ) |
| 447 | | { |
| 448 | 443 | bw2_state *driver_state = (bw2_state *)device->machine->driver_data; |
| 449 | 444 | |
| 450 | 445 | driver_state->mtron = state; |
| r7461 | r7462 | |
| 462 | 457 | { |
| 463 | 458 | { |
| 464 | 459 | XTAL_4MHz, /* 8251 USART TXC, RXC */ |
| 465 | | bw2_timer0_w |
| 460 | DEVCB_NULL, |
| 461 | DEVCB_LINE(bw2_timer0_w) |
| 466 | 462 | }, |
| 467 | 463 | { |
| 468 | 464 | 11000, /* LCD controller */ |
| 469 | | bw2_timer1_w |
| 465 | DEVCB_NULL, |
| 466 | DEVCB_LINE(pit8253_clk2_w) |
| 470 | 467 | }, |
| 471 | 468 | { |
| 472 | 469 | 0, /* Floppy /MTRON */ |
| 473 | | bw2_timer2_w |
| 470 | DEVCB_NULL, |
| 471 | DEVCB_LINE(bw2_timer2_w) |
| 474 | 472 | } |
| 475 | 473 | } |
| 476 | 474 | }; |
| r7461 | r7462 | |
| 526 | 524 | memory_configure_bank(machine, "bank1", BANK_RAM1, 1, state->work_ram, 0); |
| 527 | 525 | memory_configure_bank(machine, "bank1", BANK_VRAM, 1, state->video_ram, 0); |
| 528 | 526 | memory_configure_bank(machine, "bank1", BANK_ROM, 1, memory_region(machine, "ic1"), 0); |
| 529 | | |
| 527 | |
| 530 | 528 | /* register for state saving */ |
| 531 | 529 | state_save_register_global(machine, state->keyboard_row); |
| 532 | 530 | state_save_register_global_pointer(machine, state->work_ram, messram_get_size(devtag_get_device(machine, "messram"))); |