Previous 15994 Revisions Next

r4332 Monday 23rd February, 2009 at 11:13:56 UTC by Dirk Best
[CENTRONICS/PC_LPT] Updated to use DEVINFO_PTR_MACHINE_CONFIG
[src/mess/drivers]bbc.c
[src/mess/machine]ctronics.c ctronics.h pc_lpt.c pc_lpt.h thomson.c

src/mess/machine/thomson.c
r4331r4332
729729   TO7_IO_RS232
730730} to7_io_dev;
731731
732static const device_config *printer_device(running_machine *machine)
733{
734   return devtag_get_device(machine, PRINTER, "centronics");
735}
736
737732/* test whether a parallel or a serial device is connected: both cannot
738733   be exploited at the same time!
739734*/
740735static to7_io_dev to7_io_mode( running_machine *machine )
741736{
742   if ( printer_is_ready(printer_device(machine) ) )
737   const device_config *centronics = devtag_get_device(machine, CENTRONICS, "centronics");
738
739   if (centronics_pe_r(centronics) == TRUE)
743740      return TO7_IO_CENTRONICS;
744741   else if ( image_exists( image_from_devtype_and_index( machine, IO_SERIAL, THOM_SERIAL_CC90323 ) ) )
745742      return TO7_IO_RS232;
src/mess/machine/ctronics.c
r4331r4332
66
77#include "driver.h"
88#include "ctronics.h"
9#include "devices/printer.h"
910
1011
1112/***************************************************************************
1213    FUNCTION PROTOTYPES
1314***************************************************************************/
1415
16static WRITE_LINE_DEVICE_HANDLER( centronics_printer_online );
1517static TIMER_CALLBACK( ack_callback );
1618static TIMER_CALLBACK( busy_callback );
1719
r4331r4332
6870
6971
7072/*****************************************************************************
73    PRINTER INTERFACE
74*****************************************************************************/
75
76static MACHINE_DRIVER_START( centronics )
77   MDRV_PRINTER_ADD("printer")
78   MDRV_PRINTER_ONLINE(centronics_printer_online)
79MACHINE_DRIVER_END
80
81
82/*****************************************************************************
7183    DEVICE INTERFACE
7284*****************************************************************************/
7385
r4331r4332
7587{
7688   centronics_state *centronics = get_safe_token(device);
7789   const centronics_interface *intf = device->static_config;
90   astring *tempstring = astring_alloc();
7891
7992   /* validate some basic stuff */
8093   assert(device->static_config != NULL);
r4331r4332
8598   centronics->busy = TRUE;
8699
87100   /* get printer device */
88   centronics->printer = devtag_get_device(device->machine, PRINTER, device->tag);
101   centronics->printer = devtag_get_device(device->machine, PRINTER, device_build_tag(tempstring, device, "printer"));
89102   assert(centronics->printer != NULL);
90103
91104   /* make sure it's running */
r4331r4332
106119   state_save_register_device_item(device, 0, centronics->busy);
107120   state_save_register_device_item(device, 0, centronics->ack);
108121   state_save_register_device_item(device, 0, centronics->data);
122
123   astring_free(tempstring);
109124}
110125
111126static DEVICE_RESET( centronics )
r4331r4332
129144      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;                     break;
130145      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;      break;
131146
147      /* --- the following bits of info are returned as pointers --- */
148      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(centronics);   break;
149
132150      /* --- the following bits of info are returned as pointers to data or functions --- */
133      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME( centronics );   break;
134      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME( centronics );         break;
151      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME(centronics);   break;
152      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(centronics);      break;
135153      case DEVINFO_FCT_STOP:               /* Nothing */                              break;
136      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME( centronics );         break;
154      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(centronics);      break;
137155
138156      /* --- the following bits of info are returned as NULL-terminated strings --- */
139157      case DEVINFO_STR_NAME:               strcpy(info->s, "Centronics");         break;
r4331r4332
156174
157175void centronics_printer_online(const device_config *device, int state)
158176{
159   const device_config *c = devtag_get_device(device->machine, CENTRONICS, device->tag);
160   centronics_state *centronics = get_safe_token(c);
177   centronics_state *centronics = get_safe_token(device->owner);
161178
162179   /* when going online, set PE and FAULT high and BUSY low */
163180   centronics->pe = state;
src/mess/machine/ctronics.h
r4331r4332
88#define __CTRONICS_H__
99
1010#include "devcb.h"
11#include "devices/printer.h"
1211
1312
1413/***************************************************************************
r4331r4332
5756READ_LINE_DEVICE_HANDLER( centronics_vcc_r );
5857READ_LINE_DEVICE_HANDLER( centronics_fault_r );
5958
60/* callback for the printer device */
61void centronics_printer_online(const device_config *device, int state);
6259
63
6460/***************************************************************************
6561    DEVICE CONFIGURATION MACROS
6662***************************************************************************/
r4331r4332
6864#define CENTRONICS DEVICE_GET_INFO_NAME(centronics)
6965
7066#define MDRV_CENTRONICS_ADD(_tag, _intf) \
71   MDRV_PRINTER_ADD(_tag) \
72   MDRV_PRINTER_ONLINE(centronics_printer_online) \
7367   MDRV_DEVICE_ADD(_tag, CENTRONICS, 0) \
7468   MDRV_DEVICE_CONFIG(_intf)
7569
7670#define MDRV_CENTRONICS_REMOVE(_tag) \
77   MDRV_DEVICE_REMOVE(_tag, PRINTER) \
7871   MDRV_DEVICE_REMOVE(_tag, CENTRONICS)
7972
8073
src/mess/machine/pc_lpt.c
r4331r4332
66 
77#include "driver.h"
88#include "pc_lpt.h"
9#include "machine/ctronics.h"
910 
1011 
1112/***************************************************************************
r4331r4332
4142    CENTRONICS INTERFACE
4243***************************************************************************/
4344 
44const centronics_interface pc_centronics_config =
45static const centronics_interface pc_centronics_config =
4546{
4647   TRUE,
4748   DEVCB_LINE(pc_lpt_ack_w),
r4331r4332
4950   DEVCB_NULL
5051};
5152 
53static MACHINE_DRIVER_START( pc_lpt )
54   MDRV_CENTRONICS_ADD("centronics", pc_centronics_config)
55MACHINE_DRIVER_END
5256 
57 
5358/*****************************************************************************
5459    INLINE FUNCTIONS
5560*****************************************************************************/
r4331r4332
7277{
7378   pc_lpt_state *lpt = get_safe_token(device);
7479   const pc_lpt_interface *intf = device->static_config;
80   astring *tempstring = astring_alloc();
7581 
7682   /* validate some basic stuff */
7783   assert(device->static_config != NULL);
7884 
7985   /* get centronics device */
80   lpt->centronics = devtag_get_device(device->machine, CENTRONICS, device->tag);
86   lpt->centronics = devtag_get_device(device->machine, CENTRONICS, device_build_tag(tempstring, device, "centronics"));
8187   assert(lpt->centronics != NULL);
8288 
8389   /* make sure it's running */
r4331r4332
9298 
9399   /* register for state saving */
94100   state_save_register_device_item(device, 0, lpt->ack);
101   state_save_register_device_item(device, 0, lpt->strobe);
102   state_save_register_device_item(device, 0, lpt->autofd);
103   state_save_register_device_item(device, 0, lpt->init);
104   state_save_register_device_item(device, 0, lpt->select);
105   state_save_register_device_item(device, 0, lpt->irq_enabled);
106 
107   astring_free(tempstring);
95108}
96109 
97110static DEVICE_RESET( pc_lpt )
r4331r4332
122135      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;                     break;
123136      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;      break;
124137 
138      /* --- the following bits of info are returned as pointers --- */
139      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(pc_lpt);   break;
140 
125141      /* --- the following bits of info are returned as pointers to data or functions --- */
126      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME( pc_lpt );   break;
127      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME( pc_lpt );         break;
128      case DEVINFO_FCT_STOP:               /* Nothing */                              break;
129      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME( pc_lpt );         break;
142      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME(pc_lpt);   break;
143      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(pc_lpt);      break;
144      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
145      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(pc_lpt);      break;
130146 
131147      /* --- the following bits of info are returned as NULL-terminated strings --- */
132148      case DEVINFO_STR_NAME:               strcpy(info->s, "PC-LPT");            break;
r4331r4332
144160 
145161static WRITE_LINE_DEVICE_HANDLER( pc_lpt_ack_w )
146162{
147   const device_config *lpt_device = devtag_get_device(device->machine, PC_LPT, device->tag);
148   pc_lpt_state *lpt = get_safe_token(lpt_device);
163   pc_lpt_state *lpt = get_safe_token(device->owner);
149164 
150165   if (lpt->irq_enabled && lpt->ack == TRUE && state == FALSE)
151166   {
src/mess/machine/pc_lpt.h
r4331r4332
88#define __PC_LPT_H__
99 
1010#include "devcb.h"
11#include "machine/ctronics.h"
1211 
1312 
1413/***************************************************************************
15    CENTRONICS INTERFACE
16***************************************************************************/
17 
18extern const centronics_interface pc_centronics_config;
19 
20 
21/***************************************************************************
2214    TYPE DEFINITIONS
2315***************************************************************************/
2416 
r4331r4332
5244#define PC_LPT DEVICE_GET_INFO_NAME(pc_lpt)
5345 
5446#define MDRV_PC_LPT_ADD(_tag, _intf) \
55   MDRV_CENTRONICS_ADD(_tag, pc_centronics_config) \
5647   MDRV_DEVICE_ADD(_tag, PC_LPT, 0) \
5748   MDRV_DEVICE_CONFIG(_intf)
5849 
5950#define MDRV_PC_LPT_REMOVE(_tag) \
60   MDRV_CENTRONICS_REMOVE(_tag) \
6151   MDRV_DEVICE_REMOVE(_tag, PC_LPT)
6252 
6353 
src/mess/drivers/bbc.c
r4331r4332
898898   MDRV_NVRAM_HANDLER( mc146818 )
899899
900900   /* printer */
901   MDRV_PRINTER_ADD("printer")
901   MDRV_CENTRONICS_ADD("centronics", bbcb_centronics_config)
902902
903903   /* cassette */
904904   MDRV_CASSETTE_ADD( "cassette", bbc_cassette_config )
r4331r4332
910910   MDRV_UPD7002_ADD("upd7002",BBC_uPD7002)
911911   MDRV_VIA6522_ADD("via6522_0", 1000000, bbcb_system_via)
912912   MDRV_VIA6522_ADD("via6522_1", 1000000, bbcb_user_via)
913   MDRV_CENTRONICS_ADD("centronics", bbcb_centronics_config)
914913   MDRV_WD177X_ADD("wd177x", bbc_wd17xx_interface )
915914
916915   MDRV_IMPORT_FROM(bbc_cartslot)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team