Previous 15994 Revisions Next

r2380 Sunday 13th April, 2008 at 00:08:30 UTC by Robbbert
[THOMSON] to7 - Fixed possible crash with printing.
[src/mess/machine]thomson.c

src/mess/machine/thomson.c
r2379r2380
1818#include "audio/mea8000.h"
1919#include "devices/cartslot.h"
2020#include "machine/centroni.h"
21#include "devices/printer.h"
2122#include "includes/serial.h"
2223#include "devices/cassette.h"
2324#include "formats/thom_cas.h"
r2379r2380
523524   TO7_IO_RS232
524525} to7_io_dev;
525526
527static const device_config *printer_device(running_machine *machine)
528{
529   return device_list_find_by_tag(machine->config->devicelist, PRINTER, "printer");
530}
526531
527
528532/* test whether a parallel or a serial device is connected: both cannot
529533   be exploited at the same time!
530534*/
531static to7_io_dev to7_io_mode( void )
535static to7_io_dev to7_io_mode( running_machine *machine )
532536{
533   if ( image_exists( image_from_devtype_and_index( IO_PRINTER, 0 ) ) )
537   if ( printer_is_ready(printer_device(machine) ) )
534538      return TO7_IO_CENTRONICS;
535539   else if ( image_exists( image_from_devtype_and_index( IO_SERIAL, THOM_SERIAL_CC90323 ) ) )
536      return TO7_IO_CENTRONICS;
540      return TO7_IO_RS232;
537541   return TO7_IO_NONE;
538542}
539543
r2379r2380
572576   int dsr = ( to7_io_line.input_state & SERIAL_STATE_DSR ) ? 0 : 1;
573577   int rd  = get_in_data_bit( to7_io_line.input_state );
574578
575   if ( to7_io_mode() == TO7_IO_RS232 )
579   if ( to7_io_mode(machine) == TO7_IO_RS232 )
576580      cts = to7_io_line.input_state & SERIAL_STATE_CTS ? 0 : 1;
577581   else
578582      cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0;
579583
580   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(), cts, dsr, rd ));
584   LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(machine), cts, dsr, rd ));
581585
582586   return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0);
583587}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team