Previous 199869 Revisions Next

r29254 Friday 4th April, 2014 at 12:23:42 UTC by Curt Coder
(MESS) tandy2k: WIP. (nw)
[src/emu/video]crt9007.c crt9007.h crt9021.c crt9021.h crt9212.c crt9212.h
[src/mess/drivers]tandy2k.c
[src/mess/includes]tandy2k.h

trunk/src/emu/video/crt9007.c
r29253r29254
3838#include "crt9007.h"
3939
4040
41// device type definition
42const device_type CRT9007 = &device_creator<crt9007_device>;
4341
42//**************************************************************************
43//  DEVICE DEFINITIONS
44//**************************************************************************
4445
46const device_type CRT9007 = &device_creator<crt9007_t>;
47
48
49
4550//**************************************************************************
4651//  MACROS / CONSTANTS
4752//**************************************************************************
4853
49#define LOG 0
54#define LOG 1
5055
5156#define HAS_VALID_PARAMETERS \
5257   (m_reg[0x00] && m_reg[0x01] && m_reg[0x07] && m_reg[0x08] && m_reg[0x09])
r29253r29254
217222//**************************************************************************
218223
219224// default address map
220static ADDRESS_MAP_START( crt9007, AS_0, 8, crt9007_device )
225static ADDRESS_MAP_START( crt9007, AS_0, 8, crt9007_t )
221226   AM_RANGE(0x0000, 0x3fff) AM_RAM
222227ADDRESS_MAP_END
223228
r29253r29254
231236//  readbyte - read a byte at the given address
232237//-------------------------------------------------
233238
234inline UINT8 crt9007_device::readbyte(offs_t address)
239inline UINT8 crt9007_t::readbyte(offs_t address)
235240{
236241   return space().read_byte(address);
237242}
r29253r29254
241246//  trigger_interrupt -
242247//-------------------------------------------------
243248
244inline void crt9007_device::trigger_interrupt(int line)
249inline void crt9007_t::trigger_interrupt(int line)
245250{
246251   if (INTERRUPT_ENABLE & line)
247252   {
r29253r29254
252257      if (!(status & STATUS_INTERRUPT_PENDING))
253258      {
254259         if (LOG) logerror("CRT9007 '%s' INT 1\n", tag());
255         m_out_int_func(ASSERT_LINE);
260         m_write_int(ASSERT_LINE);
256261      }
257262   }
258263}
r29253r29254
262267//  update_cblank_line -
263268//-------------------------------------------------
264269
265inline void crt9007_device::update_cblank_line()
270inline void crt9007_t::update_cblank_line()
266271{
267272   int x = m_screen->hpos();
268273   int y = m_screen->vpos();
r29253r29254
276281
277282      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CBLANK %u\n", tag(), y, x, m_cblank);
278283
279      m_out_cblank_func(m_cblank);
284      m_write_cblank(m_cblank);
280285   }
281286}
282287
r29253r29254
285290//  update_hsync_timer -
286291//-------------------------------------------------
287292
288inline void crt9007_device::update_hsync_timer(int state)
293inline void crt9007_t::update_hsync_timer(int state)
289294{
290295   int y = m_screen->vpos();
291296
r29253r29254
302307//  update_vsync_timer -
303308//-------------------------------------------------
304309
305inline void crt9007_device::update_vsync_timer(int state)
310inline void crt9007_t::update_vsync_timer(int state)
306311{
307312   int next_y = state ? m_vsync_start : m_vsync_end;
308313
r29253r29254
316321//  update_vlt_timer -
317322//-------------------------------------------------
318323
319inline void crt9007_device::update_vlt_timer(int state)
324inline void crt9007_t::update_vlt_timer(int state)
320325{
321326   // this signal is active during all visible scan lines and during the horizontal trace at vertical retrace
322327   int y = m_screen->vpos();
r29253r29254
334339//  update_curs_timer -
335340//-------------------------------------------------
336341
337inline void crt9007_device::update_curs_timer(int state)
342inline void crt9007_t::update_curs_timer(int state)
338343{
339344   // this signal is active for 1 character time for all scanlines within the data row
340345   // TODO
r29253r29254
345350//  update_drb_timer -
346351//-------------------------------------------------
347352
348inline void crt9007_device::update_drb_timer(int state)
353inline void crt9007_t::update_drb_timer(int state)
349354{
350355   // this signal is active for 1 full scan line (VLT edge to edge) at the top scan line of each new row
351356   // there is 1 extra DRB signal during the 1st scanline of the vertical retrace interval
r29253r29254
381386//  update_dma_timer -
382387//-------------------------------------------------
383388
384inline void crt9007_device::update_dma_timer()
389inline void crt9007_t::update_dma_timer()
385390{
386391   // TODO
387392}
r29253r29254
391396//  recompute_parameters -
392397//-------------------------------------------------
393398
394inline void crt9007_device::recompute_parameters()
399inline void crt9007_t::recompute_parameters()
395400{
396401   // check that necessary registers have been loaded
397402   if (!HAS_VALID_PARAMETERS) return;
r29253r29254
444449//**************************************************************************
445450
446451//-------------------------------------------------
447//  crt9007_device - constructor
452//  crt9007_t - constructor
448453//-------------------------------------------------
449454
450crt9007_device::crt9007_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
451   : device_t(mconfig, CRT9007, "SMC CRT9007", tag, owner, clock, "crt9007", __FILE__),
452      device_memory_interface(mconfig, *this),
453      device_video_interface(mconfig, *this),
454      m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007))
455crt9007_t::crt9007_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
456   device_t(mconfig, CRT9007, "SMC CRT9007", tag, owner, clock, "crt9007", __FILE__),
457   device_memory_interface(mconfig, *this),
458   device_video_interface(mconfig, *this),
459   m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007)),
460   m_write_int(*this),
461   m_write_dmar(*this),
462   m_write_hs(*this),
463   m_write_vs(*this),
464   m_write_vlt(*this),
465   m_write_curs(*this),
466   m_write_drb(*this),
467   m_write_cblank(*this),
468   m_write_slg(*this),
469   m_write_sld(*this)
455470{
456471   for (int i = 0; i < 0x3d; i++)
457472      m_reg[i] = 0;
r29253r29254
459474
460475
461476//-------------------------------------------------
462//  device_config_complete - perform any
463//  operations now that the configuration is
464//  complete
465//-------------------------------------------------
466
467void crt9007_device::device_config_complete()
468{
469   // inherit a copy of the static data
470   const crt9007_interface *intf = reinterpret_cast<const crt9007_interface *>(static_config());
471   if (intf != NULL)
472      *static_cast<crt9007_interface *>(this) = *intf;
473
474   // or initialize to defaults if none provided
475   else
476   {
477      memset(&m_out_int_cb, 0, sizeof(m_out_int_cb));
478      memset(&m_out_dmar_cb, 0, sizeof(m_out_dmar_cb));
479      memset(&m_out_vs_cb, 0, sizeof(m_out_vs_cb));
480      memset(&m_out_hs_cb, 0, sizeof(m_out_hs_cb));
481      memset(&m_out_vlt_cb, 0, sizeof(m_out_vlt_cb));
482      memset(&m_out_curs_cb, 0, sizeof(m_out_curs_cb));
483      memset(&m_out_drb_cb, 0, sizeof(m_out_drb_cb));
484      memset(&m_out_cblank_cb, 0, sizeof(m_out_cblank_cb));
485      memset(&m_out_slg_cb, 0, sizeof(m_out_slg_cb));
486      memset(&m_out_sld_cb, 0, sizeof(m_out_sld_cb));
487   }
488}
489
490
491//-------------------------------------------------
492477//  device_start - device-specific startup
493478//-------------------------------------------------
494479
495void crt9007_device::device_start()
480void crt9007_t::device_start()
496481{
497482   // allocate timers
498483   m_hsync_timer = timer_alloc(TIMER_HSYNC);
r29253r29254
503488   m_dma_timer = timer_alloc(TIMER_DMA);
504489
505490   // resolve callbacks
506   m_out_int_func.resolve(m_out_int_cb, *this);
507   m_out_dmar_func.resolve(m_out_dmar_cb, *this);
508   m_out_hs_func.resolve(m_out_hs_cb, *this);
509   m_out_vs_func.resolve(m_out_vs_cb, *this);
510   m_out_vlt_func.resolve(m_out_vlt_cb, *this);
511   m_out_curs_func.resolve(m_out_curs_cb, *this);
512   m_out_drb_func.resolve(m_out_drb_cb, *this);
513   m_out_cblank_func.resolve(m_out_cblank_cb, *this);
514   m_out_slg_func.resolve(m_out_slg_cb, *this);
515   m_out_sld_func.resolve(m_out_sld_cb, *this);
516
517   // set horizontal pixels per column
518   m_hpixels_per_column = hpixels_per_column;
519
520   // register for state saving
521//  state_save_register_device_item(this, 0, );
491   m_write_int.resolve_safe();
492   m_write_dmar.resolve_safe();
493   m_write_hs.resolve_safe();
494   m_write_vs.resolve_safe();
495   m_write_vlt.resolve_safe();
496   m_write_curs.resolve_safe();
497   m_write_drb.resolve_safe();
498   m_write_cblank.resolve_safe();
499   m_write_slg.resolve_safe();
500   m_write_sld.resolve_safe();
522501}
523502
524503
r29253r29254
526505//  device_reset - device-specific reset
527506//-------------------------------------------------
528507
529void crt9007_device::device_reset()
508void crt9007_t::device_reset()
530509{
531510   m_disp = 0;
532511   m_vs = 0;
533512   m_cblank = 0;
534513
535514   // HS = 1
536   m_out_hs_func(1);
515   m_write_hs(1);
537516
538517   // VS = 1
539   m_out_vs_func(1);
518   m_write_vs(1);
540519
541520   // CBLANK = 1
542   m_out_cblank_func(0);
521   m_write_cblank(0);
543522
544523   // CURS = 0
545   m_out_curs_func(0);
524   m_write_curs(0);
546525
547526   // VLT = 0
548   m_out_vlt_func(0);
527   m_write_vlt(0);
549528
550529   // DRB = 1
551   m_out_drb_func(1);
530   m_write_drb(1);
552531
553532   // INT = 0
554   m_out_int_func(CLEAR_LINE);
533   m_write_int(CLEAR_LINE);
555534
556535   // 28 (DMAR) = 0
557   m_out_dmar_func(CLEAR_LINE);
536   m_write_dmar(CLEAR_LINE);
558537
559538   // 29 (WBEN) = 0
560539
561540   // 30 (SLG) = 0
562   m_out_slg_func(0);
541   m_write_slg(0);
563542
564543   // 31 (SLD) = 0
565   m_out_sld_func(0);
544   m_write_sld(0);
566545
567546   // 32 (LPSTB) = 0
568547}
r29253r29254
572551//  device_clock_changed - handle clock change
573552//-------------------------------------------------
574553
575void crt9007_device::device_clock_changed()
554void crt9007_t::device_clock_changed()
576555{
577556   recompute_parameters();
578557}
r29253r29254
582561//  device_timer - handle timer events
583562//-------------------------------------------------
584563
585void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
564void crt9007_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
586565{
587566   int x = m_screen->hpos();
588567   int y = m_screen->vpos();
r29253r29254
594573
595574      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : HS %u\n", tag(), y, x, m_hs);
596575
597      m_out_hs_func(m_hs);
576      m_write_hs(m_hs);
598577
599578      update_cblank_line();
600579
r29253r29254
606585
607586      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VS %u\n", tag(), y, x, m_vs);
608587
609      m_out_vs_func(param);
588      m_write_vs(param);
610589
611590      if (m_vs)
612591      {
r29253r29254
628607
629608      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VLT %u\n", tag(), y, x, m_vlt);
630609
631      m_out_vlt_func(param);
610      m_write_vlt(param);
632611
633612      update_vlt_timer(param);
634613      break;
r29253r29254
636615   case TIMER_CURS:
637616      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CURS %u\n", tag(), y, x, param);
638617
639      m_out_curs_func(param);
618      m_write_curs(param);
640619
641620      update_curs_timer(param);
642621      break;
r29253r29254
646625
647626      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : DRB %u\n", tag(), y, x, m_drb);
648627
649      m_out_drb_func(param);
628      m_write_drb(param);
650629
651630      if (!m_drb && !DMA_DISABLE)
652631      {
r29253r29254
657636         m_dmar = 1;
658637
659638         if (LOG) logerror("CRT9007 '%s' DMAR 1\n", tag());
660         m_out_dmar_func(ASSERT_LINE);
639         m_write_dmar(ASSERT_LINE);
661640      }
662641
663642      update_drb_timer(param);
r29253r29254
677656//  any address spaces owned by this device
678657//-------------------------------------------------
679658
680const address_space_config *crt9007_device::memory_space_config(address_spacenum spacenum) const
659const address_space_config *crt9007_t::memory_space_config(address_spacenum spacenum) const
681660{
682661   return (spacenum == AS_0) ? &m_space_config : NULL;
683662}
r29253r29254
687666//  read - register read
688667//-------------------------------------------------
689668
690READ8_MEMBER( crt9007_device::read )
669READ8_MEMBER( crt9007_t::read )
691670{
692671   UINT8 data = 0;
693672
r29253r29254
717696      // reset interrupt pending bit
718697      m_status &= ~STATUS_INTERRUPT_PENDING;
719698      if (LOG) logerror("CRT9007 '%s' INT 0\n", tag());
720      m_out_int_func(CLEAR_LINE);
699      m_write_int(CLEAR_LINE);
721700      break;
722701
723702   case 0x3b:
r29253r29254
743722//  write - register write
744723//-------------------------------------------------
745724
746WRITE8_MEMBER( crt9007_device::write )
725WRITE8_MEMBER( crt9007_t::write )
747726{
748727   m_reg[offset] = data;
749728
r29253r29254
913892//  ack_w - DMA acknowledge
914893//-------------------------------------------------
915894
916WRITE_LINE_MEMBER( crt9007_device::ack_w )
895WRITE_LINE_MEMBER( crt9007_t::ack_w )
917896{
918897   if (LOG) logerror("CRT9007 '%s' ACK: %u\n", tag(), state);
919898
r29253r29254
931910//  lpstb_w - light pen strobe
932911//-------------------------------------------------
933912
934WRITE_LINE_MEMBER( crt9007_device::lpstb_w )
913WRITE_LINE_MEMBER( crt9007_t::lpstb_w )
935914{
936915   if (LOG) logerror("CRT9007 '%s' LPSTB: %u\n", tag(), state);
937916
r29253r29254
945924
946925
947926//-------------------------------------------------
948//  vlt_r -
927//  set_character_width -
949928//-------------------------------------------------
950929
951READ_LINE_MEMBER( crt9007_device::vlt_r )
930void crt9007_t::set_character_width(int value)
952931{
953   return m_vlt;
954}
932   m_hpixels_per_column = value;
955933
956
957//-------------------------------------------------
958//  wben_r -
959//-------------------------------------------------
960
961READ_LINE_MEMBER( crt9007_device::wben_r )
962{
963   return m_wben;
964}
965
966
967//-------------------------------------------------
968//  set_hpixels_per_column -
969//-------------------------------------------------
970
971void crt9007_device::set_hpixels_per_column(int hpixels_per_column)
972{
973   m_hpixels_per_column = hpixels_per_column;
974934   recompute_parameters();
975935}
trunk/src/emu/video/crt9007.h
r29253r29254
5252//  INTERFACE CONFIGURATION MACROS
5353//**************************************************************************
5454
55#define MCFG_CRT9007_ADD(_tag, _clock, _config, _map) \
56   MCFG_DEVICE_ADD(_tag, CRT9007, _clock) \
57   MCFG_DEVICE_CONFIG(_config) \
58   MCFG_DEVICE_ADDRESS_MAP(AS_0, _map)
55#define MCFG_CRT9007_CHARACTER_WIDTH(_value) \
56   crt9007_t::static_set_character_width(*device, _value);
5957
58#define MCFG_CRT9007_INT_CALLBACK(_write) \
59   devcb = &crt9007_t::set_int_wr_callback(*device, DEVCB2_##_write);
6060
61#define CRT9007_INTERFACE(name) \
62   const crt9007_interface (name) =
61#define MCFG_CRT9007_DMAR_CALLBACK(_write) \
62   devcb = &crt9007_t::set_dmar_wr_callback(*device, DEVCB2_##_write);
6363
64#define MCFG_CRT9007_VS_CALLBACK(_write) \
65   devcb = &crt9007_t::set_vs_wr_callback(*device, DEVCB2_##_write);
6466
67#define MCFG_CRT9007_HS_CALLBACK(_write) \
68   devcb = &crt9007_t::set_hs_wr_callback(*device, DEVCB2_##_write);
6569
66//**************************************************************************
67//  TYPE DEFINITIONS
68//**************************************************************************
70#define MCFG_CRT9007_VLT_CALLBACK(_write) \
71   devcb = &crt9007_t::set_vlt_wr_callback(*device, DEVCB2_##_write);
6972
73#define MCFG_CRT9007_CURS_CALLBACK(_write) \
74   devcb = &crt9007_t::set_curs_wr_callback(*device, DEVCB2_##_write);
7075
71// ======================> crt9007_interface
76#define MCFG_CRT9007_DRB_CALLBACK(_write) \
77   devcb = &crt9007_t::set_drb_wr_callback(*device, DEVCB2_##_write);
7278
73struct crt9007_interface
74{
75   int hpixels_per_column;     /* number of pixels per video memory address */
79#define MCFG_CRT9007_CBLANK_CALLBACK(_write) \
80   devcb = &crt9007_t::set_cblank_wr_callback(*device, DEVCB2_##_write);
7681
77   devcb_write_line        m_out_int_cb;
78   devcb_write_line        m_out_dmar_cb;
82#define MCFG_CRT9007_SLG_CALLBACK(_write) \
83   devcb = &crt9007_t::set_slg_wr_callback(*device, DEVCB2_##_write);
7984
80   devcb_write_line        m_out_vs_cb;
81   devcb_write_line        m_out_hs_cb;
85#define MCFG_CRT9007_SLD_CALLBACK(_write) \
86   devcb = &crt9007_t::set_sld_wr_callback(*device, DEVCB2_##_write);
8287
83   devcb_write_line        m_out_vlt_cb;
84   devcb_write_line        m_out_curs_cb;
85   devcb_write_line        m_out_drb_cb;
86   devcb_write_line        m_out_cblank_cb;
8788
88   devcb_write_line        m_out_slg_cb;
89   devcb_write_line        m_out_sld_cb;
90};
9189
90//**************************************************************************
91//  TYPE DEFINITIONS
92//**************************************************************************
9293
94// ======================> crt9007_t
9395
94// ======================> crt9007_device
95
96class crt9007_device :  public device_t,
97                  public device_memory_interface,
98                  public device_video_interface,
99                  public crt9007_interface
96class crt9007_t :  public device_t,
97               public device_memory_interface,
98               public device_video_interface
10099{
101100public:
102101   // construction/destruction
103   crt9007_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
102   crt9007_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
104103
104   static void static_set_character_width(device_t &device, int value) { downcast<crt9007_t &>(device).m_hpixels_per_column = value; }
105
106   template<class _Object> static devcb2_base &set_int_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_int.set_callback(object); }
107   template<class _Object> static devcb2_base &set_dmar_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_dmar.set_callback(object); }
108   template<class _Object> static devcb2_base &set_vs_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_vs.set_callback(object); }
109   template<class _Object> static devcb2_base &set_hs_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_hs.set_callback(object); }
110   template<class _Object> static devcb2_base &set_vlt_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_vlt.set_callback(object); }
111   template<class _Object> static devcb2_base &set_curs_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_curs.set_callback(object); }
112   template<class _Object> static devcb2_base &set_drb_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_drb.set_callback(object); }
113   template<class _Object> static devcb2_base &set_cblank_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_cblank.set_callback(object); }
114   template<class _Object> static devcb2_base &set_slg_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_slg.set_callback(object); }
115   template<class _Object> static devcb2_base &set_sld_wr_callback(device_t &device, _Object object) { return downcast<crt9007_t &>(device).m_write_sld.set_callback(object); }
116
105117   DECLARE_READ8_MEMBER( read );
106118   DECLARE_WRITE8_MEMBER( write );
107119   DECLARE_WRITE_LINE_MEMBER( ack_w );
108120   DECLARE_WRITE_LINE_MEMBER( lpstb_w );
109   DECLARE_READ_LINE_MEMBER( vlt_r );
110   DECLARE_READ_LINE_MEMBER( wben_r );
111121
112   void set_hpixels_per_column(int hpixels_per_column);
122   void set_character_width(int value);
113123
114124protected:
115125   // device-level overrides
116   virtual void device_config_complete();
117126   virtual void device_start();
118127   virtual void device_reset();
119128   virtual void device_clock_changed();
r29253r29254
123132   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
124133
125134private:
126   static const device_timer_id TIMER_HSYNC = 0;
127   static const device_timer_id TIMER_VSYNC = 1;
128   static const device_timer_id TIMER_VLT = 2;
129   static const device_timer_id TIMER_CURS = 3;
130   static const device_timer_id TIMER_DRB = 4;
131   static const device_timer_id TIMER_DMA = 5;
135   enum
136   {
137      TIMER_HSYNC,
138      TIMER_VSYNC,
139      TIMER_VLT,
140      TIMER_CURS,
141      TIMER_DRB,
142      TIMER_DMA
143   };
132144
133145   inline UINT8 readbyte(offs_t address);
134146
r29253r29254
143155
144156   inline void recompute_parameters();
145157
146   devcb_resolved_write_line   m_out_int_func;
147   devcb_resolved_write_line   m_out_dmar_func;
148   devcb_resolved_write_line   m_out_hs_func;
149   devcb_resolved_write_line   m_out_vs_func;
150   devcb_resolved_write_line   m_out_vlt_func;
151   devcb_resolved_write_line   m_out_curs_func;
152   devcb_resolved_write_line   m_out_drb_func;
153   devcb_resolved_write_line   m_out_cblank_func;
154   devcb_resolved_write_line   m_out_slg_func;
155   devcb_resolved_write_line   m_out_sld_func;
158   // address space configurations
159   const address_space_config      m_space_config;
156160
161   devcb2_write_line   m_write_int;
162   devcb2_write_line   m_write_dmar;
163   devcb2_write_line   m_write_hs;
164   devcb2_write_line   m_write_vs;
165   devcb2_write_line   m_write_vlt;
166   devcb2_write_line   m_write_curs;
167   devcb2_write_line   m_write_drb;
168   devcb2_write_line   m_write_cblank;
169   devcb2_write_line   m_write_slg;
170   devcb2_write_line   m_write_sld;
171
157172   // registers
158173   UINT8 m_reg[0x3d];
159174   UINT8 m_status;
r29253r29254
175190   int m_cblank;
176191   int m_vlt;
177192   int m_drb;
178   int m_wben;
193   //int m_wben;
179194   //int m_slg;
180195   //int m_sld;
181196   int m_lpstb;
r29253r29254
194209   emu_timer *m_curs_timer;
195210   emu_timer *m_drb_timer;
196211   emu_timer *m_dma_timer;
197
198   // address space configurations
199   const address_space_config      m_space_config;
200212};
201213
202214
trunk/src/emu/video/crt9212.c
r29253r29254
99
1010**********************************************************************/
1111
12#include "emu.h"
13#include "crt9212.h"
12/*
1413
14   TODO:
1515
16   - RCLK and WCLK are clocked simultaneously since that's what tandy2k does and we have no other users
1617
17//**************************************************************************
18//  MACROS / CONSTANTS
19//**************************************************************************
18*/
2019
21#define LOG 0
20#include "crt9212.h"
2221
2322
24#define REN \
25   m_in_ren_cb()
2623
27#define WEN \
28   m_in_wen_cb()
24//**************************************************************************
25//  DEVICE DEFINITIONS
26//**************************************************************************
2927
30#define WEN2 \
31   m_in_wen2_cb()
28const device_type CRT9212 = &device_creator<crt9212_t>;
3229
33#define ROF(_state) \
34   m_out_rof_cb(_state);
3530
36#define WOF(_state) \
37   m_out_wof_cb(_state);
3831
39
40
4132//**************************************************************************
42//  INLINE HELPERS
33//  MACROS / CONSTANTS
4334//**************************************************************************
4435
36#define LOG 0
4537
38
39
4640//**************************************************************************
4741//  LIVE DEVICE
4842//**************************************************************************
4943
50// device type definition
51const device_type CRT9212 = &device_creator<crt9212_device>;
52
5344//-------------------------------------------------
54//  crt9212_device - constructor
45//  crt9212_t - constructor
5546//-------------------------------------------------
5647
57crt9212_device::crt9212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
58   : device_t(mconfig, CRT9212, "SMC CRT9212", tag, owner, clock, "crt9212", __FILE__),
59      m_out_rof_cb(*this),
60      m_out_wof_cb(*this),
61      m_in_ren_cb(*this),
62      m_in_wen_cb(*this),
63      m_in_wen2_cb(*this)
48crt9212_t::crt9212_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
49   device_t(mconfig, CRT9212, "SMC CRT9212", tag, owner, clock, "crt9212", __FILE__),
50   m_write_dout(*this),
51   m_write_rof(*this),
52   m_write_wof(*this),
53   m_data(0),
54   m_clrcnt(0),
55   m_tog(0),
56   m_ren(0),
57   m_wen1(1),
58   m_wen2(0),
59   m_oe(0),
60   m_rclk(0),
61   m_wclk(0),
62   m_buffer(0),
63   m_rac(0),
64   m_wac(0)
6465{
6566}
6667
68
6769//-------------------------------------------------
6870//  device_start - device-specific startup
6971//-------------------------------------------------
7072
71void crt9212_device::device_start()
73void crt9212_t::device_start()
7274{
7375   // resolve callbacks
74   m_out_rof_cb.resolve_safe();
75   m_out_wof_cb.resolve_safe();
76   m_in_ren_cb.resolve_safe(0);
77   m_in_wen_cb.resolve_safe(0);
78   m_in_wen2_cb.resolve_safe(0);
76   m_write_dout.resolve_safe();
77   m_write_rof.resolve_safe();
78   m_write_wof.resolve_safe();
7979
80   // register for state saving
81   save_item(NAME(m_input));
82   save_item(NAME(m_output));
83   save_item(NAME(m_buffer));
84   save_item(NAME(m_rac));
85   save_item(NAME(m_wac));
86   save_item(NAME(m_tog));
80   // allocate timers
81   m_rwclk_timer = timer_alloc();
82
83   if (clock())
84   {
85      m_rwclk_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
86   }
87
88   // state saving
89   save_item(NAME(m_data));
8790   save_item(NAME(m_clrcnt));
91   save_item(NAME(m_tog));
92   save_item(NAME(m_ren));
93   save_item(NAME(m_wen1));
94   save_item(NAME(m_wen2));
95   save_item(NAME(m_oe));
8896   save_item(NAME(m_rclk));
8997   save_item(NAME(m_wclk));
98   save_item(NAME(m_ram[0]));
99   save_item(NAME(m_ram[1]));
100   save_item(NAME(m_buffer));
101   save_item(NAME(m_rac));
102   save_item(NAME(m_wac));
90103}
91104
92105
93106//-------------------------------------------------
94//  read - buffer read
107//  device_clock_changed - handle clock change
95108//-------------------------------------------------
96109
97READ8_MEMBER( crt9212_device::read )
110void crt9212_t::device_clock_changed()
98111{
99   return m_output;
112   m_rwclk_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
100113}
101114
102115
103116//-------------------------------------------------
104//  write - buffer write
117//  device_timer - handle timer events
105118//-------------------------------------------------
106119
107WRITE8_MEMBER( crt9212_device::write )
120void crt9212_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
108121{
109   m_input = data;
110}
122   rclk_w(1);
123   rclk_w(0);
111124
112
113//-------------------------------------------------
114//  clrcnt_w - clear address counters
115//-------------------------------------------------
116
117WRITE_LINE_MEMBER( crt9212_device::clrcnt_w )
118{
119   m_clrcnt = state;
125   wclk_w(1);
126   wclk_w(0);
120127}
121128
122129
123130//-------------------------------------------------
124//  tog_w - toggle buffer
125//-------------------------------------------------
126
127WRITE_LINE_MEMBER( crt9212_device::tog_w )
128{
129   m_tog = state;
130}
131
132
133//-------------------------------------------------
134131//  rclk_w - read clock
135132//-------------------------------------------------
136133
137WRITE_LINE_MEMBER( crt9212_device::rclk_w )
134WRITE_LINE_MEMBER( crt9212_t::rclk_w )
138135{
139136   if (m_rclk && !state)
140137   {
r29253r29254
147144
148145            // clear write address counter
149146            m_wac = 0;
150            WOF(0);
147            m_write_wof(0);
151148         }
152149         else
153150         {
154151            // clear read address counter
155152            m_rac = 0;
156            ROF(0);
153            m_write_rof(0);
157154         }
158155      }
159156      else
160157      {
161         if (REN && (m_rac < CRT9212_RAM_SIZE))
158         if (m_ren && (m_rac < CRT9212_RAM_SIZE))
162159         {
163160            //
164            m_output = m_ram[m_rac][!m_buffer];
161            m_write_dout(m_ram[m_rac][!m_buffer]);
165162
166163            // increment read address counter
167164            m_rac++;
r29253r29254
169166            if (m_rac == CRT9212_RAM_SIZE)
170167            {
171168               // set read overflow
172               ROF(1);
169               m_write_rof(1);
173170            }
174171         }
175172      }
r29253r29254
183180//  wclk_w - write clock
184181//-------------------------------------------------
185182
186WRITE_LINE_MEMBER( crt9212_device::wclk_w )
183WRITE_LINE_MEMBER( crt9212_t::wclk_w )
187184{
188   if (!m_rclk && state)
185   if (!m_wclk && state)
189186   {
190      if (WEN && WEN2 && (m_wac < CRT9212_RAM_SIZE))
187      if (m_wen1 && m_wen2 && (m_wac < CRT9212_RAM_SIZE))
191188      {
192189         //
193         m_ram[m_rac][m_buffer] = m_input;
190         m_ram[m_rac][m_buffer] = m_data;
194191
195192         // increment read address counter
196193         m_wac++;
r29253r29254
198195         if (m_wac == CRT9212_RAM_SIZE)
199196         {
200197            // set write overflow
201            WOF(1);
198            m_write_wof(1);
202199         }
203200      }
204201   }
trunk/src/emu/video/crt9212.h
r29253r29254
4747//  INTERFACE CONFIGURATION MACROS
4848//**************************************************************************
4949
50#define MCFG_CRT9212_OUT_ROF_CB(_devcb) \
51   devcb = &crt9212_device::set_out_rof_callback(*device, DEVCB2_##_devcb);
50#define MCFG_CRT9212_DOUT_CALLBACK(_write) \
51   devcb = &crt9212_t::set_dout_wr_callback(*device, DEVCB2_##_write);
5252
53#define MCFG_CRT9212_OUT_WOF_CB(_devcb) \
54   devcb = &crt9212_device::set_out_wof_callback(*device, DEVCB2_##_devcb);
55   
56#define MCFG_CRT9212_IN_REN_CB(_devcb) \
57   devcb = &crt9212_device::set_in_ren_callback(*device, DEVCB2_##_devcb);
53#define MCFG_CRT9212_ROF_CALLBACK(_write) \
54   devcb = &crt9212_t::set_rof_wr_callback(*device, DEVCB2_##_write);
5855
59#define MCFG_CRT9212_IN_WEN_CB(_devcb) \
60   devcb = &crt9212_device::set_in_wen_callback(*device, DEVCB2_##_devcb);
56#define MCFG_CRT9212_WOF_CALLBACK(_write) \
57   devcb = &crt9212_t::set_wof_wr_callback(*device, DEVCB2_##_write);
6158
62#define MCFG_CRT9212_IN_WEN2_CB(_devcb) \
63   devcb = &crt9212_device::set_in_wen2_callback(*device, DEVCB2_##_devcb);
6459
6560
6661//**************************************************************************
6762//  TYPE DEFINITIONS
6863//**************************************************************************
6964
70// ======================> crt9212_device
65// ======================> crt9212_t
7166
72class crt9212_device :  public device_t
67class crt9212_t :  public device_t
7368{
7469public:
7570   // construction/destruction
76   crt9212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
71   crt9212_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7772   
78   template<class _Object> static devcb2_base &set_out_rof_callback(device_t &device, _Object object) { return downcast<crt9212_device &>(device).m_out_rof_cb.set_callback(object); }
79   template<class _Object> static devcb2_base &set_out_wof_callback(device_t &device, _Object object) { return downcast<crt9212_device &>(device).m_out_wof_cb.set_callback(object); }
80   template<class _Object> static devcb2_base &set_in_ren_callback(device_t &device, _Object object) { return downcast<crt9212_device &>(device).m_in_ren_cb.set_callback(object); }
81   template<class _Object> static devcb2_base &set_in_wen_callback(device_t &device, _Object object) { return downcast<crt9212_device &>(device).m_in_wen_cb.set_callback(object); }
82   template<class _Object> static devcb2_base &set_in_wen2_callback(device_t &device, _Object object) { return downcast<crt9212_device &>(device).m_in_wen2_cb.set_callback(object); }
73   template<class _Object> static devcb2_base &set_dout_wr_callback(device_t &device, _Object object) { return downcast<crt9212_t &>(device).m_write_dout.set_callback(object); }
74   template<class _Object> static devcb2_base &set_rof_wr_callback(device_t &device, _Object object) { return downcast<crt9212_t &>(device).m_write_rof.set_callback(object); }
75   template<class _Object> static devcb2_base &set_wof_wr_callback(device_t &device, _Object object) { return downcast<crt9212_t &>(device).m_write_wof.set_callback(object); }
8376
84   DECLARE_READ8_MEMBER( read );
85   DECLARE_WRITE8_MEMBER( write );
86   DECLARE_WRITE_LINE_MEMBER( clrcnt_w );
87   DECLARE_WRITE_LINE_MEMBER( tog_w );
77   DECLARE_WRITE8_MEMBER( write ) { m_data = data; }
78   DECLARE_WRITE_LINE_MEMBER( clrcnt_w ) { m_clrcnt = state; }
79   DECLARE_WRITE_LINE_MEMBER( tog_w ) { m_tog = state; }
80   DECLARE_WRITE_LINE_MEMBER( ren_w ) { m_ren = state; }
81   DECLARE_WRITE_LINE_MEMBER( wen1_w ) { m_wen1 = state; }
82   DECLARE_WRITE_LINE_MEMBER( wen2_w ) { m_wen2 = state; }
83   DECLARE_WRITE_LINE_MEMBER( oe_w ) { m_oe = state; }
8884   DECLARE_WRITE_LINE_MEMBER( rclk_w );
8985   DECLARE_WRITE_LINE_MEMBER( wclk_w );
9086
9187protected:
9288   // device-level overrides
9389   virtual void device_start();
90   virtual void device_clock_changed();
91   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
9492
9593private:
96   devcb2_write_line        m_out_rof_cb;
97   devcb2_write_line        m_out_wof_cb;
98   devcb2_read_line         m_in_ren_cb;
99   devcb2_read_line         m_in_wen_cb;
100   devcb2_read_line         m_in_wen2_cb;
94   devcb2_write8         m_write_dout;
95   devcb2_write_line       m_write_rof;
96   devcb2_write_line       m_write_wof;
10197
98   // inputs
99   UINT8 m_data;
100   int m_clrcnt;
101   int m_tog;
102   int m_ren;
103   int m_wen1;
104   int m_wen2;
105   int m_oe;
106   int m_rclk;
107   int m_wclk;
108
109   // internal state
102110   UINT8 m_ram[CRT9212_RAM_SIZE][2];
103
104   UINT8 m_input;
105   UINT8 m_output;
106
107111   int m_buffer;
108112   int m_rac;
109113   int m_wac;
110   int m_tog;
111   int m_clrcnt;
112   int m_rclk;
113   int m_wclk;
114
115   // timers
116   emu_timer *m_rwclk_timer;
114117};
115118
116119
trunk/src/emu/video/crt9021.c
r29253r29254
1414    TODO:
1515
1616    - attributes
17        - reverse video
18        - character blank
1917        - character blink
2018        - underline
2119        - full/half intensity
r29253r29254
2624        - character mode w/underline
2725    - double height characters
2826    - double width characters
29    - parallel scan line
3027    - serial scan line
3128    - cursor
3229        - underline
r29253r29254
3532        - blinking reverse video
3633    - programmable character blink rate (75/25 duty)
3734    - programmable cursor blink rate (50/50 duty)
38    - data/attribute latches
35    - attribute latches
3936
4037*/
4138
42#include "emu.h"
4339#include "crt9021.h"
4440
4541
46// device type definition
47const device_type CRT9021 = &device_creator<crt9021_device>;
48
49
5042//**************************************************************************
51//  MACROS / CONSTANTS
43//  DEVICE DEFINITIONS
5244//**************************************************************************
5345
54#define LOG 0
46const device_type CRT9021 = &device_creator<crt9021_t>;
5547
5648
57// attributes
58enum
59{
60   ATTRIBUTE_REVID = 0x80,
61   ATTRIBUTE_INT   = 0x40,
62   ATTRIBUTE_BLINK = 0x20,
63   ATTRIBUTE_MS1   = 0x10,
64   ATTRIBUTE_MS0   = 0x08,
65   ATTRIBUTE_CHABL = 0x04,
66   ATTRIBUTE_BKC   = 0x02,
67   ATTRIBUTE_BLC   = 0x01
68};
6949
70
71
7250//**************************************************************************
73//  INLINE HELPERS
51//  MACROS / CONSTANTS
7452//**************************************************************************
7553
54#define LOG 0
7655
7756
57
7858//**************************************************************************
7959//  LIVE DEVICE
8060//**************************************************************************
8161
8262//-------------------------------------------------
83//  crt9021_device - constructor
63//  crt9021_t - constructor
8464//-------------------------------------------------
8565
86crt9021_device::crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
87   : device_t(mconfig, CRT9021, "SMC CRT9021", tag, owner, clock, "crt9021", __FILE__),
88      device_video_interface(mconfig, *this),
89      m_in_data_cb(*this),
90      m_in_attr_cb(*this),
91      m_in_atten_cb(*this)
66crt9021_t::crt9021_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
67   device_t(mconfig, CRT9021, "SMC CRT9021", tag, owner, clock, "crt9021", __FILE__),
68   device_video_interface(mconfig, *this),
69   m_data(0),
70   m_ms0(0),
71   m_ms1(0),
72   m_revid(0),
73   m_chabl(0),
74   m_blink(0),
75   m_intin(0),
76   m_atten(0),
77   m_cursor(0),
78   m_retbl(0),
79   m_ld_sh(1),
80   m_sld(1),
81   m_slg(0),
82   m_blc(0),
83   m_bkc(0),
84   m_sl0(0),
85   m_sl1(0),
86   m_sl2(0),
87   m_sl3(0),
88   m_vsync(0),
89   m_sr(0),
90   m_intout(0)
9291{
9392}
9493
r29253r29254
9796//  device_start - device-specific startup
9897//-------------------------------------------------
9998
100void crt9021_device::device_start()
99void crt9021_t::device_start()
101100{
102101   // allocate timers
102   m_vdc_timer = timer_alloc();
103103
104   // resolve callbacks
105   m_in_data_cb.resolve_safe(0);
106   m_in_attr_cb.resolve_safe(0);
107   m_in_atten_cb.resolve_safe(0);
104   if (!m_display_cb.isnull())
105   {
106      m_vdc_timer->adjust(clocks_to_attotime(8), 0, clocks_to_attotime(8));
107   }
108108
109   // register for state saving
110   save_item(NAME(m_slg));
111   save_item(NAME(m_sld));
109   // register bitmap
110   m_screen->register_screen_bitmap(m_bitmap);
111
112   // state saving
113   save_item(NAME(m_data));
114   save_item(NAME(m_ms0));
115   save_item(NAME(m_ms1));
116   save_item(NAME(m_revid));
117   save_item(NAME(m_chabl));
118   save_item(NAME(m_blink));
119   save_item(NAME(m_intin));
120   save_item(NAME(m_atten));
112121   save_item(NAME(m_cursor));
113122   save_item(NAME(m_retbl));
123   save_item(NAME(m_ld_sh));
124   save_item(NAME(m_sld));
125   save_item(NAME(m_slg));
126   save_item(NAME(m_blc));
127   save_item(NAME(m_bkc));
128   save_item(NAME(m_sl0));
129   save_item(NAME(m_sl1));
130   save_item(NAME(m_sl2));
131   save_item(NAME(m_sl3));
114132   save_item(NAME(m_vsync));
133   save_item(NAME(m_sr));
134   save_item(NAME(m_intout));
135   save_item(NAME(m_sld));
115136}
116137
117138
r29253r29254
119140//  device_clock_changed - handle clock change
120141//-------------------------------------------------
121142
122void crt9021_device::device_clock_changed()
143void crt9021_t::device_clock_changed()
123144{
145   if (!m_display_cb.isnull())
146   {
147      m_vdc_timer->adjust(clocks_to_attotime(8), 0, clocks_to_attotime(8));
148   }
124149}
125150
126151
r29253r29254
128153//  device_timer - handle timer events
129154//-------------------------------------------------
130155
131void crt9021_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
156void crt9021_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
132157{
158   m_display_cb(m_bitmap, m_screen->vpos(), m_screen->hpos(), m_sr, m_intout);
133159}
134160
135161
136162//-------------------------------------------------
137//  slg_w - scan line gate
163//  ld_sh_w - load/shift
138164//-------------------------------------------------
139165
140WRITE_LINE_MEMBER( crt9021_device::slg_w )
166WRITE_LINE_MEMBER( crt9021_t::ld_sh_w )
141167{
142   if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state);
168   if (LOG) logerror("CRT9021 '%s' LD/SH: %u\n", tag(), state);
143169
144   m_slg = state;
145}
170   if (!m_ld_sh && state)
171   {
172      // shift in scanline data
173      if (!m_slg)
174      {
175         m_sl >>= 1;
176         m_sl |= m_sld << 3;
177      }
146178
179      // latch data
180      if (m_retbl)
181      {
182         m_sr = 0;
183      }
184      else
185      {
186         m_sr = m_chabl ? 0 : m_data;
147187
148//-------------------------------------------------
149//  sld_w - scan line data
150//-------------------------------------------------
188         if (m_revid) m_sr ^= 0xff;
189      }
151190
152WRITE_LINE_MEMBER( crt9021_device::sld_w )
153{
154   if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state);
155
156   if (!m_slg)
157   {
158      m_sld <<= 1;
159      m_sld |= state;
191      // latch attributes
192      if (m_atten)
193      {
194         // TODO
195      }
160196   }
161197}
162198
163199
164200//-------------------------------------------------
165//  cursor_w - cursor
166//-------------------------------------------------
167
168WRITE_LINE_MEMBER( crt9021_device::cursor_w )
169{
170   if (LOG) logerror("CRT9021 '%s' CURSOR: %u\n", tag(), state);
171
172   m_cursor = state;
173}
174
175
176//-------------------------------------------------
177//  retbl_w - retrace blank
178//-------------------------------------------------
179
180WRITE_LINE_MEMBER( crt9021_device::retbl_w )
181{
182   if (LOG) logerror("CRT9021 '%s' RETBL: %u\n", tag(), state);
183
184   m_retbl = state;
185}
186
187
188//-------------------------------------------------
189201//  vsync_w - vertical sync
190202//-------------------------------------------------
191203
192WRITE_LINE_MEMBER( crt9021_device::vsync_w )
204WRITE_LINE_MEMBER( crt9021_t::vsync_w )
193205{
194206   if (LOG) logerror("CRT9021 '%s' VSYNC: %u\n", tag(), state);
195
196   m_vsync = state;
197207}
198208
199209
r29253r29254
201211//  screen_update - update screen
202212//-------------------------------------------------
203213
204UINT32 crt9021_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
214UINT32 crt9021_t::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
205215{
216   m_bitmap.fill(rgb_t::black, cliprect);
217
206218   return 0;
207219}
trunk/src/emu/video/crt9021.h
r29253r29254
3636
3737
3838//**************************************************************************
39//  MACROS / CONSTANTS
39//  INTERFACE CONFIGURATION MACROS
4040//**************************************************************************
4141
42#define CRT9021_DRAW_CHARACTER_MEMBER(_name) void _name(bitmap_rgb32 &bitmap, int y, int x, UINT8 data, int intout)
4243
4344
45#define MCFG_CRT9021_DRAW_CHARACTER_CALLBACK_OWNER(_class, _method) \
46   crt9021_t::static_set_display_callback(*device, crt9021_draw_character_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
4447
48
4549//**************************************************************************
46//  INTERFACE CONFIGURATION MACROS
50//  TYPE DEFINITIONS
4751//**************************************************************************
4852
49#define MCFG_CRT9021_IN_DATA_CB(_devcb) \
50   devcb = &crt9021_device::set_in_data_callback(*device, DEVCB2_##_devcb);
53typedef device_delegate<void (bitmap_rgb32 &bitmap, int y, int x, UINT8 data, int intout)> crt9021_draw_character_delegate;
5154
52#define MCFG_CRT9021_IN_ATTR_CB(_devcb) \
53   devcb = &crt9021_device::set_in_attr_callback(*device, DEVCB2_##_devcb);
5455
55#define MCFG_CRT9021_IN_ATTEN_CB(_devcb) \
56   devcb = &crt9021_device::set_in_atten_callback(*device, DEVCB2_##_devcb);   
56// ======================> crt9021_t
5757
58//**************************************************************************
59//  TYPE DEFINITIONS
60//**************************************************************************
61
62// ======================> crt9021_device
63
64class crt9021_device :  public device_t,
65                  public device_video_interface
58class crt9021_t :  public device_t,
59               public device_video_interface
6660{
6761public:
6862   // construction/destruction
69   crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
63   crt9021_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7064   
71   template<class _Object> static devcb2_base &set_in_data_callback(device_t &device, _Object object) { return downcast<crt9021_device &>(device).m_in_data_cb.set_callback(object); }
72   template<class _Object> static devcb2_base &set_in_attr_callback(device_t &device, _Object object) { return downcast<crt9021_device &>(device).m_in_attr_cb.set_callback(object); }
73   template<class _Object> static devcb2_base &set_in_atten_callback(device_t &device, _Object object) { return downcast<crt9021_device &>(device).m_in_atten_cb.set_callback(object); }
65   static void static_set_display_callback(device_t &device, crt9021_draw_character_delegate callback) { downcast<crt9021_t &>(device).m_display_cb = callback; }
7466
75   DECLARE_WRITE_LINE_MEMBER( slg_w );
76   DECLARE_WRITE_LINE_MEMBER( sld_w );
77   DECLARE_WRITE_LINE_MEMBER( cursor_w );
78   DECLARE_WRITE_LINE_MEMBER( retbl_w );
67   DECLARE_WRITE8_MEMBER( write ) { m_data = data; }
68   DECLARE_WRITE_LINE_MEMBER( ms0_w ) { m_ms0 = state; }
69   DECLARE_WRITE_LINE_MEMBER( ms1_w ) { m_ms1 = state; }
70   DECLARE_WRITE_LINE_MEMBER( revid_w ) { m_revid = state; }
71   DECLARE_WRITE_LINE_MEMBER( chabl_w ) { m_chabl = state; }
72   DECLARE_WRITE_LINE_MEMBER( blink_w ) { m_blink = state; }
73   DECLARE_WRITE_LINE_MEMBER( intin_w ) { m_intin = state; }
74   DECLARE_WRITE_LINE_MEMBER( atten_w ) { m_atten = state; }
75   DECLARE_WRITE_LINE_MEMBER( cursor_w ) { m_cursor = state; }
76   DECLARE_WRITE_LINE_MEMBER( retbl_w ) { m_retbl = state; }
77   DECLARE_WRITE_LINE_MEMBER( ld_sh_w );
78   DECLARE_WRITE_LINE_MEMBER( sld_w ) { m_sld = state; }
79   DECLARE_WRITE_LINE_MEMBER( slg_w ) { m_slg = state; }
80   DECLARE_WRITE_LINE_MEMBER( blc_w ) { m_blc = state; }
81   DECLARE_WRITE_LINE_MEMBER( bkc_w ) { m_bkc = state; }
82   DECLARE_WRITE_LINE_MEMBER( sl0_w ) { m_sl0 = state; }
83   DECLARE_WRITE_LINE_MEMBER( sl1_w ) { m_sl1 = state; }
84   DECLARE_WRITE_LINE_MEMBER( sl2_w ) { m_sl2 = state; }
85   DECLARE_WRITE_LINE_MEMBER( sl3_w ) { m_sl3 = state; }
7986   DECLARE_WRITE_LINE_MEMBER( vsync_w );
8087
8188   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
r29253r29254
8794   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8895
8996private:
90   devcb2_read8             m_in_data_cb;
91   devcb2_read8             m_in_attr_cb;
97   enum
98   {
99      MS_WIDE_GRAPHICS,
100      MS_CHARACTER,
101      MS_THIN_GRAPHICS,
102      MS_UNDERLINE
103   };
92104
93   devcb2_read_line         m_in_atten_cb;
105   crt9021_draw_character_delegate m_display_cb;
94106
95   int m_slg;
96   int m_sld;
107   bitmap_rgb32 m_bitmap;
108
109   // inputs
110   UINT8 m_data;
111   int m_ms0;
112   int m_ms1;
113   int m_revid;
114   int m_chabl;
115   int m_blink;
116   int m_intin;
117   int m_atten;
97118   int m_cursor;
98119   int m_retbl;
120   int m_ld_sh;
121   int m_sld;
122   int m_slg;
123   int m_blc;
124   int m_bkc;
125   int m_sl0;
126   int m_sl1;
127   int m_sl2;
128   int m_sl3;
99129   int m_vsync;
130
131   // outputs
132   UINT8 m_sr;
133   int m_intout;
134   int m_sl;
135
136   // timers
137   emu_timer *m_vdc_timer;
100138};
101139
102140
trunk/src/mess/includes/tandy2k.h
r29253r29254
4141class tandy2k_state : public driver_device
4242{
4343public:
44   tandy2k_state(const machine_config &mconfig, device_type type, const char *tag)
45      : driver_device(mconfig, type, tag),
44   tandy2k_state(const machine_config &mconfig, device_type type, const char *tag) :
45      driver_device(mconfig, type, tag),
4646      m_maincpu(*this, I80186_TAG),
4747      m_uart(*this, I8251A_TAG),
4848      m_i8255a(*this, I8255A_TAG),
r29253r29254
7373   required_device<i8272a_device> m_fdc;
7474   required_device<pic8259_device> m_pic0;
7575   required_device<pic8259_device> m_pic1;
76   required_device<crt9007_device> m_vpac;
77   required_device<crt9212_device> m_drb0;
78   required_device<crt9212_device> m_drb1;
79   required_device<crt9021_device> m_vac;
76   required_device<crt9007_t> m_vpac;
77   required_device<crt9212_t> m_drb0;
78   required_device<crt9212_t> m_drb1;
79   required_device<crt9021_t> m_vac;
8080   required_device<centronics_device> m_centronics;
8181   required_device<speaker_sound_device> m_speaker;
8282   required_device<ram_device> m_ram;
r29253r29254
115115   DECLARE_WRITE_LINE_MEMBER( kbddat_w );
116116   DECLARE_READ8_MEMBER( irq_callback );
117117   DECLARE_WRITE_LINE_MEMBER( fdc_drq );
118   DECLARE_WRITE8_MEMBER( drb_attr_w );
118119
119120   /* DMA state */
120121   UINT8 m_dma_mux;
trunk/src/mess/drivers/tandy2k.c
r29253r29254
235235
236236   if (m_clkcnt != BIT(data, 6))
237237   {
238      m_vpac->set_hpixels_per_column(character_width);
238      m_vpac->set_character_width(character_width);
239239      m_clkcnt = BIT(data, 6);
240240   }
241241
r29253r29254
279279   AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8(I8259A_0_TAG, pic8259_device, read, write, 0x00ff)
280280   AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8(I8259A_1_TAG, pic8259_device, read, write, 0x00ff)
281281   AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8(I8272A_TAG, i8272a_device, mdma_r, mdma_w, 0x00ff)
282//  AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_device, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
282//  AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_t, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
283283   AM_RANGE(0x00100, 0x0017f) AM_READWRITE(vpac_r, vpac_w)
284284//  AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff)
285285//  AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w)
r29253r29254
353353   m_drb1->tog_w(state);
354354}
355355
356static CRT9007_INTERFACE( vpac_intf )
356WRITE8_MEMBER( tandy2k_state::drb_attr_w )
357357{
358   10,
359   DEVCB_DEVICE_LINE_MEMBER(I8259A_1_TAG, pic8259_device, ir1_w),
360   DEVCB_NULL, // DMAR     80186 HOLD
361   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, vsync_w), // VS
362   DEVCB_NULL, // HS
363   DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_vlt_w), // VLT
364   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, cursor_w), // CURS
365   DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_drb_w), // DRB
366   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, retbl_w), // CBLANK
367   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, slg_w), // SLG
368   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, sld_w) // SLD
369};
358   /*
370359
360       bit     description
361
362       0       BLC -> DBLC
363       1       BKC -> DBKC
364       2       CHABL
365       3       MS0
366       4       MS1
367       5       BLINK
368       6       INT
369       7       REVID
370
371   */
372
373   m_vac->chabl_w(BIT(data, 2));
374   m_vac->ms0_w(BIT(data, 3));
375   m_vac->ms1_w(BIT(data, 4));
376   m_vac->blink_w(BIT(data, 5));
377   m_vac->intin_w(BIT(data, 6));
378   m_vac->revid_w(BIT(data, 7));
379}
380
371381// Intel 8251A Interface
372382
373383WRITE_LINE_MEMBER( tandy2k_state::rxrdy_w )
r29253r29254
632642   MCFG_SCREEN_SIZE(640, 480)
633643   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
634644
635   MCFG_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, vpac_intf, vpac_mem)
645   MCFG_DEVICE_ADD(CRT9007_TAG, CRT9007, XTAL_16MHz*28/16)
646   MCFG_DEVICE_ADDRESS_MAP(AS_0, vpac_mem)
647   MCFG_CRT9007_CHARACTER_WIDTH(10)
648   MCFG_CRT9007_INT_CALLBACK(DEVWRITELINE(I8259A_1_TAG, pic8259_device, ir1_w))
649   //MCFG_CRT9007_DMAR_CALLBACK(80186 HOLD)
650   MCFG_CRT9007_VS_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, vsync_w))
651   MCFG_CRT9007_VLT_CALLBACK(WRITELINE(tandy2k_state, vpac_vlt_w))
652   MCFG_CRT9007_CURS_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, cursor_w))
653   MCFG_CRT9007_DRB_CALLBACK(WRITELINE(tandy2k_state, vpac_drb_w))
654   MCFG_CRT9007_CBLANK_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, retbl_w))
655   MCFG_CRT9007_SLG_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, slg_w))
656   MCFG_CRT9007_SLD_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, sld_w))
636657   MCFG_VIDEO_SET_SCREEN(SCREEN_TAG)
637   MCFG_DEVICE_ADD(CRT9212_0_TAG, CRT9212, 0)
638   // ROF
639   // WOF
640   MCFG_CRT9212_IN_REN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, vlt_r)) // REN
641   MCFG_CRT9212_IN_WEN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, wben_r)) // WEN
642   MCFG_CRT9212_IN_WEN2_CB(VCC) // WEN2
643   MCFG_DEVICE_ADD(CRT9212_1_TAG, CRT9212, 0)
644   // ROF
645   // WOF
646   MCFG_CRT9212_IN_REN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, vlt_r)) // REN
647   MCFG_CRT9212_IN_WEN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, wben_r)) // WEN
648   MCFG_CRT9212_IN_WEN2_CB(VCC) // WEN2
658
659   MCFG_DEVICE_ADD(CRT9212_0_TAG, CRT9212, XTAL_16MHz*28/16/8)
660   MCFG_CRT9212_DOUT_CALLBACK(DEVWRITE8(CRT9021B_TAG, crt9021_t, write))
661
662   MCFG_DEVICE_ADD(CRT9212_1_TAG, CRT9212, XTAL_16MHz*28/16/8)
663   MCFG_CRT9212_DOUT_CALLBACK(WRITE8(tandy2k_state, drb_attr_w))
664
649665   MCFG_DEVICE_ADD(CRT9021B_TAG, CRT9021, XTAL_16MHz*28/16/8)
650   MCFG_CRT9021_IN_DATA_CB(DEVREAD8(CRT9212_0_TAG, crt9212_device, read)) // data
651   MCFG_CRT9021_IN_ATTR_CB(DEVREAD8(CRT9212_1_TAG, crt9212_device, read)) // attributes
652   MCFG_CRT9021_IN_ATTEN_CB(VCC)
653666   MCFG_VIDEO_SET_SCREEN(SCREEN_TAG)
667   MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette")
654668
655669   // sound hardware
656670   MCFG_SPEAKER_STANDARD_MONO("mono")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team