Previous 15994 Revisions Next

r9652 Wednesday 24th November, 2010 at 08:47:49 UTC by Robbbert
[H8] Added the IRQ code, although it might be buggy. If anyone wants to make it better, please do it.
[src/mess/drivers]h8.c

src/mess/drivers/h8.c
r9651r9652
99
1010   TODO:
1111   - Proper artwork
12   - Add extra interrupt stuff
12   - Fix interrupts
13   - Seems to crash when GO pressed (needs a subject-matter expert to test)
1314   - Add load/dump facility (cassette port)
1415
1516****************************************************************************/
r9651r9652
2526
2627static UINT8 h8_digit;
2728static UINT8 h8_segment;
29static UINT8 h8_irq_ctl;
2830static running_device *h8_beeper;
2931
3032static TIMER_DEVICE_CALLBACK( h8_irq_pulse )
3133{
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);
3336}
3437
3538static READ8_HANDLER( h8_f0_r )
3639{
3740    // 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
3846   UINT8 i,keyin,data = 0xff;
3947
4048   keyin = input_port_read(space->machine, "X0");
r9651r9652
6169{
6270    // this will always turn off int10 that was set by the timer
6371    // 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
6775    // d7 = beeper enable
6876
69   cpu_set_input_line(space->machine->device("maincpu"), INPUT_LINE_IRQ0, CLEAR_LINE);
7077   h8_digit = data & 15;
7178   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
7480   output_set_value("mon_led",(data & 0x20) ? 0 : 1);
7581   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;
7687}
7788
7889static WRITE8_HANDLER( h8_f1_w )
r9651r9652
136147   h8_beeper = machine->device("beep");
137148   beep_set_frequency(h8_beeper, H8_BEEP_FRQ);
138149   output_set_value("pwr_led", 0);
150   h8_irq_ctl = 1;
139151}
140152
141153static WRITE_LINE_DEVICE_HANDLER( h8_inte_callback )
142154{
143155        // operate the ION LED
144156   output_set_value("ion_led",(state) ? 0 : 1);
157   h8_irq_ctl &= 0x7f | ((state) ? 0 : 0x80);
145158}
146159
147160static WRITE8_DEVICE_HANDLER( h8_status_callback )
148161{
162/* This is rather messy, but basically there are 2 D flipflops, one drives the other,
163the data is /INTE while the clock is /M1. If the system is in Single Instruction mode,
164a int20 (output of 2nd flipflop) will occur after 4 M1 steps, to pause the running program.
165But, 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     
149189        // 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);
151191}
152192
153193static I8085_CONFIG( h8_cpu_config )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team