src/mess/drivers/h8.c
| r9651 | r9652 | |
| 9 | 9 | |
| 10 | 10 | TODO: |
| 11 | 11 | - Proper artwork |
| 12 | | - Add extra interrupt stuff |
| 12 | - Fix interrupts |
| 13 | - Seems to crash when GO pressed (needs a subject-matter expert to test) |
| 13 | 14 | - Add load/dump facility (cassette port) |
| 14 | 15 | |
| 15 | 16 | ****************************************************************************/ |
| r9651 | r9652 | |
| 25 | 26 | |
| 26 | 27 | static UINT8 h8_digit; |
| 27 | 28 | static UINT8 h8_segment; |
| 29 | static UINT8 h8_irq_ctl; |
| 28 | 30 | static running_device *h8_beeper; |
| 29 | 31 | |
| 30 | 32 | static TIMER_DEVICE_CALLBACK( h8_irq_pulse ) |
| 31 | 33 | { |
| 32 | | cpu_set_input_line_and_vector(timer.machine->device("maincpu"), INPUT_LINE_IRQ0, ASSERT_LINE, 0xcf); |
| 34 | if (h8_irq_ctl & 1) |
| 35 | cpu_set_input_line_and_vector(timer.machine->device("maincpu"), INPUT_LINE_IRQ0, ASSERT_LINE, 0xcf); |
| 33 | 36 | } |
| 34 | 37 | |
| 35 | 38 | static READ8_HANDLER( h8_f0_r ) |
| 36 | 39 | { |
| 37 | 40 | // reads the keyboard |
| 41 | |
| 42 | // The following not emulated, can occur any time even if keyboard not being scanned |
| 43 | // - if 0 and RTM pressed, causes int10 |
| 44 | // - if 0 and RST pressed, resets cpu |
| 45 | |
| 38 | 46 | UINT8 i,keyin,data = 0xff; |
| 39 | 47 | |
| 40 | 48 | keyin = input_port_read(space->machine, "X0"); |
| r9651 | r9652 | |
| 61 | 69 | { |
| 62 | 70 | // this will always turn off int10 that was set by the timer |
| 63 | 71 | // d0-d3 = digit select |
| 64 | | // d4 = int20 |
| 65 | | // d5 = mon LED |
| 66 | | // d6 = int10 |
| 72 | // d4 = int20 is allowed |
| 73 | // d5 = mon led |
| 74 | // d6 = int10 is allowed |
| 67 | 75 | // d7 = beeper enable |
| 68 | 76 | |
| 69 | | cpu_set_input_line(space->machine->device("maincpu"), INPUT_LINE_IRQ0, CLEAR_LINE); |
| 70 | 77 | h8_digit = data & 15; |
| 71 | 78 | if (h8_digit) output_set_digit_value(h8_digit, h8_segment); |
| 72 | | //if (~data & 0x40) h8_irqset(space->machine, 160, 0xcf); |
| 73 | | //if (data & 0x10) h8_irqset(space->machine, 160, 0xd7); |
| 79 | |
| 74 | 80 | output_set_value("mon_led",(data & 0x20) ? 0 : 1); |
| 75 | 81 | beep_set_state(h8_beeper, (data & 0x80) ? 0 : 1); |
| 82 | |
| 83 | cpu_set_input_line(space->machine->device("maincpu"), INPUT_LINE_IRQ0, CLEAR_LINE); |
| 84 | h8_irq_ctl &= 0xf0; |
| 85 | if (data & 0x40) h8_irq_ctl |= 1; |
| 86 | if (~data & 0x10) h8_irq_ctl |= 2; |
| 76 | 87 | } |
| 77 | 88 | |
| 78 | 89 | static WRITE8_HANDLER( h8_f1_w ) |
| r9651 | r9652 | |
| 136 | 147 | h8_beeper = machine->device("beep"); |
| 137 | 148 | beep_set_frequency(h8_beeper, H8_BEEP_FRQ); |
| 138 | 149 | output_set_value("pwr_led", 0); |
| 150 | h8_irq_ctl = 1; |
| 139 | 151 | } |
| 140 | 152 | |
| 141 | 153 | static WRITE_LINE_DEVICE_HANDLER( h8_inte_callback ) |
| 142 | 154 | { |
| 143 | 155 | // operate the ION LED |
| 144 | 156 | output_set_value("ion_led",(state) ? 0 : 1); |
| 157 | h8_irq_ctl &= 0x7f | ((state) ? 0 : 0x80); |
| 145 | 158 | } |
| 146 | 159 | |
| 147 | 160 | static WRITE8_DEVICE_HANDLER( h8_status_callback ) |
| 148 | 161 | { |
| 162 | /* This is rather messy, but basically there are 2 D flipflops, one drives the other, |
| 163 | the data is /INTE while the clock is /M1. If the system is in Single Instruction mode, |
| 164 | a int20 (output of 2nd flipflop) will occur after 4 M1 steps, to pause the running program. |
| 165 | But, all of this can only occur if bit 5 of port F0 is low. */ |
| 166 | |
| 167 | static UINT8 b=0; |
| 168 | |
| 169 | UINT8 state = (data & I8085_STATUS_M1) ? 0 : 1; |
| 170 | UINT8 c,a = (h8_irq_ctl & 0x80) ? 1 : 0; |
| 171 | |
| 172 | if (h8_irq_ctl & 2) |
| 173 | { |
| 174 | if (!state) // rising pulse to push data through flipflops |
| 175 | { |
| 176 | c=b^1; // from /Q of 2nd flipflop |
| 177 | b=a; // from Q of 1st flipflop |
| 178 | if (c) |
| 179 | cpu_set_input_line_and_vector(device->machine->device("maincpu"), INPUT_LINE_IRQ0, ASSERT_LINE, 0xd7); |
| 180 | } |
| 181 | } |
| 182 | else |
| 183 | { // flipflops are 'set' |
| 184 | c=0; |
| 185 | b=1; |
| 186 | } |
| 187 | |
| 188 | |
| 149 | 189 | // operate the RUN LED |
| 150 | | output_set_value("run_led", (data & I8085_STATUS_M1) ? 1 : 0); |
| 190 | output_set_value("run_led", (data & I8085_STATUS_M1) ? 0 : 1); |
| 151 | 191 | } |
| 152 | 192 | |
| 153 | 193 | static I8085_CONFIG( h8_cpu_config ) |