Previous 199869 Revisions Next

r21148 Sunday 17th February, 2013 at 15:32:02 UTC by Dirk Best
px4.c: Use core RS232 support
[src/mess/drivers]px4.c

trunk/src/mess/drivers/px4.c
r21147r21148
1717#include "machine/ram.h"
1818#include "machine/nvram.h"
1919#include "sound/speaker.h"
20#include "machine/serial.h"
2021#include "px4.lh"
2122
2223
r21147r21148
2425//  CONSTANTS
2526//**************************************************************************
2627
27#define VERBOSE 0
28#define VERBOSE 1
2829
2930// interrupt sources
3031#define INT0_7508   0x01
r21147r21148
8081         m_centronics(*this, "centronics"),
8182         m_ext_cas(*this, "extcas"),
8283         m_speaker(*this, SPEAKER_TAG),
83         m_sio(*this, "sio")
84         m_sio(*this, "sio"),
85         m_rs232(*this, "rs232")
8486         { }
8587
8688   // internal devices
r21147r21148
9092   required_device<cassette_image_device> m_ext_cas;
9193   required_device<speaker_sound_device> m_speaker;
9294   required_device<epson_sio_device> m_sio;
95   required_device<rs232_port_device> m_rs232;
9396
9497   /* gapnit register */
9598   UINT8 m_ctrl1;
r21147r21148
120123   UINT8 m_artcr;
121124   UINT8 m_swr;
122125
126   int rxd_r();
127   void txd_w(int data);
128
123129   /* 7508 internal */
124130   bool m_one_sec_int_enabled;
125131   bool m_alarm_int_enabled;
r21147r21148
136142   emu_timer *m_ext_cas_timer;
137143   int m_ear_last_state;
138144
139   /* external devices */
140   device_t *m_sio_device;
141   device_t *m_rs232c_device;
142
143145   void install_rom_capsule(address_space &space, int size, const char *region);
144146
145147   DECLARE_READ8_MEMBER(px4_icrlc_r);
r21147r21148
186188   TIMER_CALLBACK_MEMBER(receive_data);
187189   TIMER_DEVICE_CALLBACK_MEMBER(frc_tick);
188190   TIMER_DEVICE_CALLBACK_MEMBER(upd7508_1sec_callback);
189
190   void px4_rs232c_txd(device_t *device,int state);
191   int px4_rs232c_rxd(device_t *device);
192   void px4_rs232c_rts(device_t *device,int state);
193   int px4_rs232c_cts(device_t *device);
194   int px4_rs232c_dsr(device_t *device);
195   void px4_rs232c_dtr(device_t *device,int state);
196   int px4_rs232c_dcd(device_t *device);
197191};
198192
199193
200194//**************************************************************************
201//  RS232C PORT
202//**************************************************************************
203
204// Currently nothing is connected to this port
205
206void px4_state::px4_rs232c_txd(device_t *device,int state)
207{
208   if (VERBOSE)
209      logerror("px4_rs232c_txd: %d\n", state);
210}
211
212#ifdef UNUSED_FUNCTION
213int px4_state::px4_rs232c_rxd(device_t *device)
214{
215   if (VERBOSE)
216      logerror("px4_rs232c_rxd\n");
217   return ASSERT_LINE;
218}
219#endif
220
221void px4_state::px4_rs232c_rts(device_t *device,int state)
222{
223   if (VERBOSE)
224      logerror("px4_rs232c_rts: %d\n", state);
225}
226
227int px4_state::px4_rs232c_cts(device_t *device)
228{
229   if (VERBOSE)
230      logerror("px4_rs232c_cts\n");
231
232   return ASSERT_LINE;
233}
234
235int px4_state::px4_rs232c_dsr(device_t *device)
236{
237   if (VERBOSE)
238      logerror("px4_rs232c_dsr\n");
239
240   return ASSERT_LINE;
241}
242
243void px4_state::px4_rs232c_dtr(device_t *device,int state)
244{
245   if (VERBOSE)
246      logerror("px4_rs232c_dtr: %d\n", state);
247}
248
249int px4_state::px4_rs232c_dcd(device_t *device)
250{
251   if (VERBOSE)
252      logerror("px4_rs232c_dcd\n");
253
254   return ASSERT_LINE;
255}
256
257
258//**************************************************************************
259195//  GAPNIT
260196//**************************************************************************
261197
r21147r21148
518454   default:
519455      if (VERBOSE)
520456         logerror("invalid bank switch value: 0x%02x\n", data >> 4);
521
457      break;
522458   }
523459}
524460
r21147r21148
698634//  GAPNIO
699635//**************************************************************************
700636
637// helper function to read from selected serial port
638int px4_state::rxd_r()
639{
640   if (BIT(m_swr, 3))
641      // from rs232
642      return m_rs232->rx();
643   else
644      if (BIT(m_swr, 2))
645         // from sio
646         return m_sio->rx_r();
647      else
648         // from cartridge
649         return 0;
650}
651
652// helper function to write to selected serial port
653void px4_state::txd_w(int data)
654{
655   if (BIT(m_swr, 2))
656      // from sio
657      m_sio->tx_w(data);
658   else
659      if (BIT(m_swr, 3))
660         // from rs232
661         m_rs232->tx(data);
662      // else from cartridge
663}
664
701665TIMER_CALLBACK_MEMBER(px4_state::transmit_data)
702666{
703667   if (ART_TX_ENABLED)
r21147r21148
760724   if (VERBOSE)
761725      logerror("%s: px4_artsr_r\n", machine().describe_context());
762726
763   result |= px4_rs232c_dsr(m_rs232c_device) << 7;
727   result |= m_rs232->dsr_r() << 7;
764728
765729   return result | m_artsr;
766730}
r21147r21148
782746   if (VERBOSE)
783747      logerror("%s: px4_iostr_r\n", machine().describe_context());
784748
749   // centronics status
785750   result |= m_centronics->busy_r() << 0;
786751   result |= !m_centronics->pe_r() << 1;
752
753   // sio status
787754   result |= !m_sio->pin_r() << 2;
788   result |= m_sio->rx_r() << 3;
789   result |= px4_rs232c_dcd(m_rs232c_device) << 4;
790   result |= px4_rs232c_cts(m_rs232c_device) << 5;
755
756   // serial data
757   result |= rxd_r() << 3;
758
759   // rs232 status
760   result |= m_rs232->dcd_r() << 4;
761   result |= m_rs232->cts_r() << 5;
762
791763   result |= 1 << 6;   // bit 6, csel, cartridge option select signal, set to 'other mode'
792764   result |= 0 << 7;   // bit 7, caud - audio input from cartridge
793765
r21147r21148
804776
805777   // bit 0, txe - transmit enable
806778   if (!ART_TX_ENABLED)
807   {
808      // force high when disabled
809      m_sio->tx_w(1);
810      px4_rs232c_txd(m_rs232c_device, ASSERT_LINE);
811   }
779      txd_w(1); // force high when disabled
812780
813781   // bit 3, sbrk - break output
814782   if (ART_TX_ENABLED && BIT(data, 3))
815   {
816      // force low when enabled and transmit enabled
817      m_sio->tx_w(0);
818      px4_rs232c_txd(m_rs232c_device, CLEAR_LINE);
819   }
783      txd_w(0); // force low when enabled and transmit enabled
820784
821785   // error reset
822786   if (BIT(data, 4))
823787      m_artsr &= ~(ART_PE | ART_OE | ART_FE);
824788
825   px4_rs232c_dtr(m_rs232c_device, BIT(data, 1));
826   px4_rs232c_rts(m_rs232c_device, BIT(data, 5));
789   // rs232
790   m_rs232->dtr_w(BIT(data, 1));
791   m_rs232->rts_w(BIT(data, 5));
827792}
828793
829794// switch register
r21147r21148
1027992   m_ext_cas_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(px4_state::ext_cassette_read), this));
1028993   m_ear_last_state = 0;
1029994
1030   // external devices
1031   m_sio_device = machine().device("floppy");
1032   m_rs232c_device = NULL;
1033
1034995   // map os rom and last half of memory
1035996   membank("bank1")->set_base(memregion("os")->base());
1036997   membank("bank2")->set_base(m_ram->pointer() + 0x8000);
r21147r21148
12761237//  MACHINE DRIVERS
12771238//**************************************************************************
12781239
1240static const rs232_port_interface rs232_intf =
1241{
1242   DEVCB_NULL,
1243   DEVCB_NULL,
1244   DEVCB_NULL,
1245   DEVCB_NULL,
1246   DEVCB_NULL
1247};
1248
12791249static const cassette_interface px4_cassette_interface =
12801250{
12811251   cassette_default_formats,
r21147r21148
13231293   // sio port
13241294   MCFG_EPSON_SIO_ADD("sio")
13251295
1296   // rs232 port
1297   MCFG_RS232_PORT_ADD("rs232", rs232_intf, default_rs232_devices, NULL, NULL)
1298
13261299   // rom capsules
13271300   MCFG_CARTSLOT_ADD("capsule1")
13281301   MCFG_CARTSLOT_EXTENSION_LIST("bin")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team