Previous 15994 Revisions Next

r4342 Tuesday 24th February, 2009 at 12:47:15 UTC by Robbbert
[SUPER80] Fix crash hard reset super80; device cleanup; interrupt partial fix.
[src/mess/drivers]super80.c

src/mess/drivers/super80.c
r4341r4342
1919
2020static UINT8 current_palette;   /* for super80m and super80v */
2121static UINT8 current_charset;   /* for super80m */
22static UINT8 irq_counter;
2223
2324static const device_config *super80_z80pio;
25static const device_config *super80_speaker;
26static const device_config *super80_cassette;
27static const device_config *super80_printer;
2428
2529/* the rest are for super80v */
2630static UINT8 *pcgram;
r4341r4342
348352
349353static UINT8 keylatch;
350354
355/* Due to pio bug since 128u7, need to eat first interrupt after boot.
356   Only works for super80m and super80v. The irq doesn't work at all for the others at this time. */
351357static void super80_pio_interrupt(const device_config *device, int state)
352358{
353//128u7   cputag_set_input_line(device->machine, "main", 0, state );
359   if ((state) && (!irq_counter))
360      irq_counter++;
361   else
362   {
363      cputag_set_input_line(device->machine, "main", 0, state );
364      if (state) irq_counter=0;
365   }
354366}
355367
356368static WRITE8_DEVICE_HANDLER( pio_port_a_w )
r4341r4342
393405
394406/**************************** CASSETTE ROUTINES *****************************************************************/
395407
396static const device_config *cassette_device_image(running_machine *machine)
408static void super80_cassette_motor( running_machine *machine, UINT8 data )
397409{
398   return devtag_get_device(machine, CASSETTE, "cassette");
399}
400
401static void cassette_motor( running_machine *machine, UINT8 data )
402{
403410   if (data)
404      cassette_change_state(cassette_device_image(machine), CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
411      cassette_change_state(super80_cassette, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
405412   else
406      cassette_change_state(cassette_device_image(machine), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
413      cassette_change_state(super80_cassette, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
407414
408415   /* does user want to hear the sound? */
409416   if (input_port_read(machine, "CONFIG") & 8)
410      cassette_change_state(cassette_device_image(machine), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
417      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
411418   else
412      cassette_change_state(cassette_device_image(machine), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
419      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
413420}
414421
415422/********************************************* TIMER ************************************************/
r4341r4342
432439   UINT8 cass_ws=0;
433440
434441   cass_data[1]++;
435   cass_ws = (cassette_input(cassette_device_image(machine)) > +0.03) ? 4 : 0;
442   cass_ws = (cassette_input(super80_cassette) > +0.03) ? 4 : 0;
436443
437444   if (cass_ws != cass_data[0])
438445   {
r4341r4342
466473
467474static READ8_HANDLER( super80_dc_r )
468475{
469   const device_config *printer = devtag_get_device(space->machine, CENTRONICS, "centronics");
470476   UINT8 data=0x7f;
471477
472478   /* bit 7 = printer busy
473479   0 = printer is not busy */
474480
475   data |= centronics_busy_r(printer) << 7;
481   data |= centronics_busy_r(super80_printer) << 7;
476482
477483   return data;
478484}
r4341r4342
500506static WRITE8_HANDLER( super80_dc_w )
501507{
502508   /* hardware strobe driven from port select, bit 7..0 = data */
503   const device_config *printer = devtag_get_device(space->machine, CENTRONICS, "centronics");
504   centronics_strobe_w(printer, 1);
505   centronics_data_w(printer, 0, data);
506   centronics_strobe_w(printer, 0);
509   centronics_strobe_w(super80_printer, 1);
510   centronics_data_w(super80_printer, 0, data);
511   centronics_strobe_w(super80_printer, 0);
507512}
508513
509514static UINT8 last_data;
510515
511516static WRITE8_HANDLER( super80_f0_w )
512517{
513   const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker");
514518   UINT8 bits = data ^ last_data;
515519
516520   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
517   speaker_level_w(speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
521   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
518522   super80_mhz = (data & 4) ? 1 : 2;            /* bit 2 - video on/off */
519   if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
520   if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
523   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
524   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
521525
522526   last_data = data;
523527}
524528
525529static WRITE8_HANDLER( super80r_f0_w )
526530{
527   const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker");
528531   UINT8 bits = data ^ last_data;
529532
530533   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
531   speaker_level_w(speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
532   if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
533   if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
534   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
535   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
536   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
534537
535538   last_data = data;
536539}
537540
538541static WRITE8_HANDLER( super80v_f0_w )
539542{
540   const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker");
541543   UINT8 bits = data ^ last_data;
542544
543545   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
544546   super80v_rom_pcg = data & 0x10;               /* bit 4 - bankswitch gfx rom or pcg */
545   speaker_level_w(speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
547   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
546548   super80v_vid_col = data & 4;               /* bit 2 - bankswitch video or colour ram */
547   if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
548   if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
549   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
550   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
549551
550552   last_data = data;
551553}
r4341r4342
979981
980982static MACHINE_RESET( super80 )
981983{
982   super80_z80pio = devtag_get_device(machine, Z80PIO, "z80pio");
983984   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset);
984985   memory_set_bank(machine, 1, 1);
986   super80_z80pio = devtag_get_device(machine, Z80PIO, "z80pio");
987   super80_speaker = devtag_get_device(machine, SOUND, "speaker");
988   super80_cassette = devtag_get_device(machine, CASSETTE, "cassette");
989   super80_printer = devtag_get_device(machine, CENTRONICS, "centronics");
985990}
986991
987992static const cassette_config super80_cassette_config =

Previous 15994 Revisions Next


© 1998-2018 The MESS Team