Previous 15994 Revisions Next

r9646 Tuesday 23rd November, 2010 at 12:30:40 UTC by Curt Coder
[TANDY2K] Video WIP.
[src/mess]mess.mak
[src/mess/drivers]tandy2k.c
[src/mess/includes]tandy2k.h
[src/mess/video]crt9007.c crt9007.h crt9212.c* crt9212.h*

src/mess/video/crt9007.c
r9645r9646
793793
794794
795795//-------------------------------------------------
796//  vlt_r -
797//-------------------------------------------------
798
799READ_LINE_MEMBER( crt9007_device::vlt_r )
800{
801   return m_vlt;
802}
803
804
805//-------------------------------------------------
806//  wben_r -
807//-------------------------------------------------
808
809READ_LINE_MEMBER( crt9007_device::wben_r )
810{
811   return m_wben;
812}
813
814
815//-------------------------------------------------
796816//  set_hpixels_per_column -
797817//-------------------------------------------------
798818
src/mess/video/crt9007.h
r9645r9646
133133    DECLARE_WRITE8_MEMBER( write );
134134   DECLARE_WRITE_LINE_MEMBER( ack_w );
135135   DECLARE_WRITE_LINE_MEMBER( lpstb_w );
136   DECLARE_READ_LINE_MEMBER( vlt_r );
137   DECLARE_READ_LINE_MEMBER( wben_r );
136138
137139   void set_hpixels_per_column(int hpixels_per_column);
138140
r9645r9646
184186   int m_hsync_start;
185187   int m_hsync_end;
186188   int m_hfp;
189   int m_vlt;
190   int m_wben;
187191
188192   // timers
189193   emu_timer *m_vsync_timer;
src/mess/video/crt9212.c
r0r9646
1/**********************************************************************
2
3    SMC CRT9212 Double Row Buffer (DRB) emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "crt9212.h"
12
13
14
15//**************************************************************************
16//   MACROS / CONSTANTS
17//**************************************************************************
18
19#define LOG 1
20
21
22#define REN \
23   devcb_call_read_line(&m_in_ren_func)
24
25#define WEN \
26   devcb_call_read_line(&m_in_wen_func)
27
28#define WEN2 \
29   devcb_call_read_line(&m_in_wen2_func)
30
31#define ROF(_state) \
32   devcb_call_write_line(&m_out_rof_func, _state);
33
34#define WOF(_state) \
35   devcb_call_write_line(&m_out_wof_func, _state);
36
37
38
39//**************************************************************************
40//  GLOBAL VARIABLES
41//**************************************************************************
42
43// devices
44const device_type CRT9212 = crt9212_device_config::static_alloc_device_config;
45
46
47
48//**************************************************************************
49//  DEVICE CONFIGURATION
50//**************************************************************************
51
52//-------------------------------------------------
53//  crt9212_device_config - constructor
54//-------------------------------------------------
55
56crt9212_device_config::crt9212_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
57   : device_config(mconfig, static_alloc_device_config, "SMC CRT9212", tag, owner, clock)
58{
59}
60
61
62//-------------------------------------------------
63//  static_alloc_device_config - allocate a new
64//  configuration object
65//-------------------------------------------------
66
67device_config *crt9212_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
68{
69   return global_alloc(crt9212_device_config(mconfig, tag, owner, clock));
70}
71
72
73//-------------------------------------------------
74//  alloc_device - allocate a new device object
75//-------------------------------------------------
76
77device_t *crt9212_device_config::alloc_device(running_machine &machine) const
78{
79   return auto_alloc(&machine, crt9212_device(machine, *this));
80}
81
82
83//-------------------------------------------------
84//  device_config_complete - perform any
85//  operations now that the configuration is
86//  complete
87//-------------------------------------------------
88
89void crt9212_device_config::device_config_complete()
90{
91   // inherit a copy of the static data
92   const crt9212_interface *intf = reinterpret_cast<const crt9212_interface *>(static_config());
93   if (intf != NULL)
94      *static_cast<crt9212_interface *>(this) = *intf;
95
96   // or initialize to defaults if none provided
97   else
98   {
99      memset(&out_rof_func, 0, sizeof(out_rof_func));
100      memset(&out_wof_func, 0, sizeof(out_wof_func));
101      memset(&in_ren_func, 0, sizeof(in_ren_func));
102      memset(&in_wen_func, 0, sizeof(in_wen_func));
103      memset(&in_wen2_func, 0, sizeof(in_wen2_func));
104   }
105}
106
107
108
109//**************************************************************************
110//  INLINE HELPERS
111//**************************************************************************
112
113
114//**************************************************************************
115//  LIVE DEVICE
116//**************************************************************************
117
118//-------------------------------------------------
119//  crt9212_device - constructor
120//-------------------------------------------------
121
122crt9212_device::crt9212_device(running_machine &_machine, const crt9212_device_config &config)
123    : device_t(_machine, config),
124      m_config(config)
125{
126}
127
128
129//-------------------------------------------------
130//  device_start - device-specific startup
131//-------------------------------------------------
132
133void crt9212_device::device_start()
134{
135   // resolve callbacks
136   devcb_resolve_write_line(&m_out_rof_func, &m_config.out_rof_func, this);
137   devcb_resolve_write_line(&m_out_wof_func, &m_config.out_wof_func, this);
138   devcb_resolve_read_line(&m_in_ren_func, &m_config.in_ren_func, this);
139   devcb_resolve_read_line(&m_in_wen_func, &m_config.in_wen_func, this);
140   devcb_resolve_read_line(&m_in_wen2_func, &m_config.in_wen2_func, this);
141
142   // register for state saving
143   state_save_register_device_item(this, 0, m_input);
144   state_save_register_device_item(this, 0, m_output);
145   state_save_register_device_item(this, 0, m_buffer);
146   state_save_register_device_item(this, 0, m_rac);
147   state_save_register_device_item(this, 0, m_wac);
148   state_save_register_device_item(this, 0, m_tog);
149   state_save_register_device_item(this, 0, m_clrcnt);
150   state_save_register_device_item(this, 0, m_rclk);
151   state_save_register_device_item(this, 0, m_wclk);
152}
153
154
155//-------------------------------------------------
156//  read - buffer read
157//-------------------------------------------------
158
159READ8_MEMBER( crt9212_device::read )
160{
161   return m_output;
162}
163
164
165//-------------------------------------------------
166//  write - buffer write
167//-------------------------------------------------
168
169WRITE8_MEMBER( crt9212_device::write )
170{
171   m_input = data;
172}
173
174
175//-------------------------------------------------
176//  clrcnt_w - clear address counters
177//-------------------------------------------------
178
179WRITE_LINE_MEMBER( crt9212_device::clrcnt_w )
180{
181   m_clrcnt = state;
182}
183
184
185//-------------------------------------------------
186//  tog_w - toggle buffer
187//-------------------------------------------------
188
189WRITE_LINE_MEMBER( crt9212_device::tog_w )
190{
191   m_tog = state;
192}
193
194
195//-------------------------------------------------
196//  rclk_w - read clock
197//-------------------------------------------------
198
199WRITE_LINE_MEMBER( crt9212_device::rclk_w )
200{
201   if (m_rclk && !state)
202   {
203      if (!m_clrcnt)
204      {
205         if (!m_tog)
206         {
207            // switch buffer
208            m_buffer = !m_buffer;
209
210            // clear write address counter
211            m_wac = 0;
212            WOF(0);
213         }
214         else
215         {
216            // clear read address counter
217            m_rac = 0;
218            ROF(0);
219         }
220      }
221      else
222      {
223         if (REN && (m_rac < CRT9212_RAM_SIZE))
224         {
225            //
226            m_output = m_ram[m_rac][!m_buffer];
227
228            // increment read address counter
229            m_rac++;
230
231            if (m_rac == CRT9212_RAM_SIZE)
232            {
233               // set read overflow
234               ROF(1);
235            }
236         }
237      }
238   }
239
240   m_rclk = state;
241}
242
243
244//-------------------------------------------------
245//  wclk_w - write clock
246//-------------------------------------------------
247
248WRITE_LINE_MEMBER( crt9212_device::wclk_w )
249{
250   if (!m_rclk && state)
251   {
252      if (WEN && WEN2 && (m_wac < CRT9212_RAM_SIZE))
253      {
254         //
255         m_ram[m_rac][m_buffer] = m_input;
256
257         // increment read address counter
258         m_wac++;
259
260         if (m_wac == CRT9212_RAM_SIZE)
261         {
262            // set write overflow
263            WOF(1);
264         }
265      }
266   }
267
268   m_wclk = state;
269}
src/mess/video/crt9212.h
r0r9646
1/**********************************************************************
2
3    SMC CRT9212 Double Row Buffer (DRB) emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                            _____   _____
10                  DIN2   1 |*    \_/     | 28  DIN3
11                  DIN1   2 |             | 27  _WCLK
12                  DIN0   3 |             | 26  _OE
13                 DOUT7   4 |             | 25  WEN2
14                 DOUT6   5 |             | 24  WEN1
15                 DOUT5   6 |             | 23  GND
16                 DOUT4   7 |   CRT9212   | 22  ROF
17                   Vcc   8 |             | 21  WOF
18                 DOUT3   9 |             | 20  REN
19                 DOUT2  10 |             | 19  _CLRCNT
20                 DOUT1  11 |             | 18  _TOG
21                 DOUT0  12 |             | 17  _RCLK
22                  DIN7  13 |             | 16  DIN4
23                  DIN6  14 |_____________| 15  DIN5
24
25**********************************************************************/
26
27#pragma once
28
29#ifndef __CRT9212__
30#define __CRT9212__
31
32#include "emu.h"
33
34
35
36//**************************************************************************
37//   MACROS / CONSTANTS
38//**************************************************************************
39
40const int CRT9212_RAM_SIZE   = 135;
41
42
43
44//**************************************************************************
45//  INTERFACE CONFIGURATION MACROS
46//**************************************************************************
47
48#define MDRV_CRT9212_ADD(_tag, _config) \
49   MDRV_DEVICE_ADD(_tag, CRT9212, 0) \
50   MDRV_DEVICE_CONFIG(_config)
51
52
53#define CRT9212_INTERFACE(name) \
54   const crt9212_interface (name) =
55
56
57
58//**************************************************************************
59//   TYPE DEFINITIONS
60//**************************************************************************
61
62
63// ======================> crt9212_interface
64
65struct crt9212_interface
66{
67   devcb_write_line      out_rof_func;
68   devcb_write_line      out_wof_func;
69   devcb_read_line         in_ren_func;
70   devcb_read_line         in_wen_func;
71   devcb_read_line         in_wen2_func;
72};
73
74
75
76// ======================> crt9212_device_config
77
78class crt9212_device_config :   public device_config,
79                                public crt9212_interface
80{
81    friend class crt9212_device;
82
83    // construction/destruction
84    crt9212_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
85
86public:
87    // allocators
88    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
89    virtual device_t *alloc_device(running_machine &machine) const;
90
91protected:
92   // device_config overrides
93   virtual void device_config_complete();
94};
95
96
97
98// ======================> crt9212_device
99
100class crt9212_device :   public device_t
101{
102    friend class crt9212_device_config;
103
104    // construction/destruction
105    crt9212_device(running_machine &_machine, const crt9212_device_config &_config);
106
107public:
108    DECLARE_READ8_MEMBER( read );
109    DECLARE_WRITE8_MEMBER( write );
110   DECLARE_WRITE_LINE_MEMBER( clrcnt_w );
111   DECLARE_WRITE_LINE_MEMBER( tog_w );
112   DECLARE_WRITE_LINE_MEMBER( rclk_w );
113   DECLARE_WRITE_LINE_MEMBER( wclk_w );
114
115protected:
116    // device-level overrides
117    virtual void device_start();
118
119private:
120   devcb_resolved_write_line   m_out_rof_func;
121   devcb_resolved_write_line   m_out_wof_func;
122   devcb_resolved_read_line   m_in_ren_func;
123   devcb_resolved_read_line   m_in_wen_func;
124   devcb_resolved_read_line   m_in_wen2_func;
125
126   UINT8 m_ram[CRT9212_RAM_SIZE][2];
127
128   UINT8 m_input;
129   UINT8 m_output;
130
131   int m_buffer;
132   int m_rac;
133   int m_wac;
134   int m_tog;
135   int m_clrcnt;
136   int m_rclk;
137   int m_wclk;
138
139   const crt9212_device_config &m_config;
140};
141
142
143// device type definition
144extern const device_type CRT9212;
145
146
147
148#endif
src/mess/includes/tandy2k.h
r9645r9646
2929        m_fdc(*this, I8272A_TAG),
3030        m_pic0(*this, I8259A_0_TAG),
3131        m_pic1(*this, I8259A_1_TAG),
32        m_drb0(*this, CRT9212_0_TAG),
33        m_drb1(*this, CRT9212_1_TAG),
3234        m_vpac(*this, CRT9007_TAG),
3335        m_centronics(*this, CENTRONICS_TAG),
3436        m_speaker(*this, SPEAKER_TAG),
r9645r9646
4446   required_device<running_device> m_pic0;
4547   required_device<running_device> m_pic1;
4648   required_device<crt9007_device> m_vpac;
47//   required_device<crt9212_device> m_drb0;
48//   required_device<crt9212_device> m_drb1;
49   required_device<crt9212_device> m_drb0;
50   required_device<crt9212_device> m_drb1;
4951//   required_device<crt9201_device> m_vag;
5052   required_device<running_device> m_centronics;
5153   required_device<running_device> m_speaker;
src/mess/mess.mak
r9645r9646
500500   $(MESS_VIDEO)/cdp1861.o      \
501501   $(MESS_VIDEO)/cdp1862.o      \
502502   $(MESS_VIDEO)/crt9007.o      \
503   $(MESS_VIDEO)/crt9212.o      \
503504   $(MESS_VIDEO)/crtc6845.o   \
504505   $(MESS_VIDEO)/dl1416.o      \
505506   $(MESS_VIDEO)/dm9368.o      \
src/mess/drivers/tandy2k.c
r9645r9646
3939#include "machine/upd765.h"
4040#include "sound/speaker.h"
4141#include "video/crt9007.h"
42#include "video/crt9212.h"
4243#include "includes/tandy2k.h"
4344
4445/* Read/Write Handlers */
r9645r9646
6364   UINT16 data = program->read_word(addr);
6465
6566   // character
66//   m_drb0->write(data & 0xff);
67   m_drb0->write(space, 0, data & 0xff);
6768
6869   // attributes
69//   m_drb1->write(data >> 8);
70   m_drb1->write(space, 0, data >> 8);
7071
7172   return data & 0xff;
7273}
r9645r9646
506507   }
507508}
508509*/
509static CRT9007_INTERFACE( crt9007_intf )
510static CRT9007_INTERFACE( vpac_intf )
510511{
511512   SCREEN_TAG,
512513   10,
r9645r9646
521522   DEVCB_NULL   // SLD      CRT9021B U14 SLD
522523};
523524
525static CRT9212_INTERFACE( drb0_intf )
526{
527   DEVCB_NULL, // ROF
528   DEVCB_NULL, // WOF
529   DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, vlt_r),
530   DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, wben_r),
531   DEVCB_LINE_VCC
532};
533
534static CRT9212_INTERFACE( drb1_intf )
535{
536   DEVCB_NULL, // ROF
537   DEVCB_NULL, // WOF
538   DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, vlt_r),
539   DEVCB_DEVICE_LINE_MEMBER(CRT9007_TAG, crt9007_device, wben_r),
540   DEVCB_LINE_VCC
541};
542
524543/* Intel 8251A Interface */
525544
526545static WRITE_LINE_DEVICE_HANDLER( rxrdy_w )
r9645r9646
815834   MDRV_PALETTE_LENGTH(2)
816835    MDRV_PALETTE_INIT(black_and_white)
817836
818   MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, crt9007_intf, vpac_mem)
837   MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, vpac_intf, vpac_mem)
838   MDRV_CRT9212_ADD(CRT9212_0_TAG, drb0_intf)
839   MDRV_CRT9212_ADD(CRT9212_1_TAG, drb1_intf)
819840
820841   /* sound hardware */
821842   MDRV_SPEAKER_STANDARD_MONO("mono")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team