~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/emu/video/crt9212.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
        m_in_ren_func()
24
 
 
25
 
#define WEN \
26
 
        m_in_wen_func()
27
 
 
28
 
#define WEN2 \
29
 
        m_in_wen2_func()
30
 
 
31
 
#define ROF(_state) \
32
 
        m_out_rof_func(_state);
33
 
 
34
 
#define WOF(_state) \
35
 
        m_out_wof_func(_state);
36
 
 
37
 
 
38
 
 
39
 
//**************************************************************************
40
 
//  INLINE HELPERS
41
 
//**************************************************************************
42
 
 
43
 
 
44
 
//**************************************************************************
45
 
//  LIVE DEVICE
46
 
//**************************************************************************
47
 
 
48
 
// device type definition
49
 
const device_type CRT9212 = &device_creator<crt9212_device>;
50
 
 
51
 
//-------------------------------------------------
52
 
//  crt9212_device - constructor
53
 
//-------------------------------------------------
54
 
 
55
 
crt9212_device::crt9212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
56
 
        : device_t(mconfig, CRT9212, "SMC CRT9212", tag, owner, clock)
57
 
{
58
 
}
59
 
 
60
 
 
61
 
//-------------------------------------------------
62
 
//  device_config_complete - perform any
63
 
//  operations now that the configuration is
64
 
//  complete
65
 
//-------------------------------------------------
66
 
 
67
 
void crt9212_device::device_config_complete()
68
 
{
69
 
        // inherit a copy of the static data
70
 
        const crt9212_interface *intf = reinterpret_cast<const crt9212_interface *>(static_config());
71
 
        if (intf != NULL)
72
 
                *static_cast<crt9212_interface *>(this) = *intf;
73
 
 
74
 
        // or initialize to defaults if none provided
75
 
        else
76
 
        {
77
 
                memset(&m_out_rof_cb, 0, sizeof(m_out_rof_cb));
78
 
                memset(&m_out_wof_cb, 0, sizeof(m_out_wof_cb));
79
 
                memset(&m_in_ren_cb, 0, sizeof(m_in_ren_cb));
80
 
                memset(&m_in_wen_cb, 0, sizeof(m_in_wen_cb));
81
 
                memset(&m_in_wen2_cb, 0, sizeof(m_in_wen2_cb));
82
 
        }
83
 
}
84
 
 
85
 
 
86
 
//-------------------------------------------------
87
 
//  device_start - device-specific startup
88
 
//-------------------------------------------------
89
 
 
90
 
void crt9212_device::device_start()
91
 
{
92
 
        // resolve callbacks
93
 
        m_out_rof_func.resolve(m_out_rof_cb, *this);
94
 
        m_out_wof_func.resolve(m_out_wof_cb, *this);
95
 
        m_in_ren_func.resolve(m_in_ren_cb, *this);
96
 
        m_in_wen_func.resolve(m_in_wen_cb, *this);
97
 
        m_in_wen2_func.resolve(m_in_wen2_cb, *this);
98
 
 
99
 
        // register for state saving
100
 
        save_item(NAME(m_input));
101
 
        save_item(NAME(m_output));
102
 
        save_item(NAME(m_buffer));
103
 
        save_item(NAME(m_rac));
104
 
        save_item(NAME(m_wac));
105
 
        save_item(NAME(m_tog));
106
 
        save_item(NAME(m_clrcnt));
107
 
        save_item(NAME(m_rclk));
108
 
        save_item(NAME(m_wclk));
109
 
}
110
 
 
111
 
 
112
 
//-------------------------------------------------
113
 
//  read - buffer read
114
 
//-------------------------------------------------
115
 
 
116
 
READ8_MEMBER( crt9212_device::read )
117
 
{
118
 
        return m_output;
119
 
}
120
 
 
121
 
 
122
 
//-------------------------------------------------
123
 
//  write - buffer write
124
 
//-------------------------------------------------
125
 
 
126
 
WRITE8_MEMBER( crt9212_device::write )
127
 
{
128
 
        m_input = data;
129
 
}
130
 
 
131
 
 
132
 
//-------------------------------------------------
133
 
//  clrcnt_w - clear address counters
134
 
//-------------------------------------------------
135
 
 
136
 
WRITE_LINE_MEMBER( crt9212_device::clrcnt_w )
137
 
{
138
 
        m_clrcnt = state;
139
 
}
140
 
 
141
 
 
142
 
//-------------------------------------------------
143
 
//  tog_w - toggle buffer
144
 
//-------------------------------------------------
145
 
 
146
 
WRITE_LINE_MEMBER( crt9212_device::tog_w )
147
 
{
148
 
        m_tog = state;
149
 
}
150
 
 
151
 
 
152
 
//-------------------------------------------------
153
 
//  rclk_w - read clock
154
 
//-------------------------------------------------
155
 
 
156
 
WRITE_LINE_MEMBER( crt9212_device::rclk_w )
157
 
{
158
 
        if (m_rclk && !state)
159
 
        {
160
 
                if (!m_clrcnt)
161
 
                {
162
 
                        if (!m_tog)
163
 
                        {
164
 
                                // switch buffer
165
 
                                m_buffer = !m_buffer;
166
 
 
167
 
                                // clear write address counter
168
 
                                m_wac = 0;
169
 
                                WOF(0);
170
 
                        }
171
 
                        else
172
 
                        {
173
 
                                // clear read address counter
174
 
                                m_rac = 0;
175
 
                                ROF(0);
176
 
                        }
177
 
                }
178
 
                else
179
 
                {
180
 
                        if (REN && (m_rac < CRT9212_RAM_SIZE))
181
 
                        {
182
 
                                //
183
 
                                m_output = m_ram[m_rac][!m_buffer];
184
 
 
185
 
                                // increment read address counter
186
 
                                m_rac++;
187
 
 
188
 
                                if (m_rac == CRT9212_RAM_SIZE)
189
 
                                {
190
 
                                        // set read overflow
191
 
                                        ROF(1);
192
 
                                }
193
 
                        }
194
 
                }
195
 
        }
196
 
 
197
 
        m_rclk = state;
198
 
}
199
 
 
200
 
 
201
 
//-------------------------------------------------
202
 
//  wclk_w - write clock
203
 
//-------------------------------------------------
204
 
 
205
 
WRITE_LINE_MEMBER( crt9212_device::wclk_w )
206
 
{
207
 
        if (!m_rclk && state)
208
 
        {
209
 
                if (WEN && WEN2 && (m_wac < CRT9212_RAM_SIZE))
210
 
                {
211
 
                        //
212
 
                        m_ram[m_rac][m_buffer] = m_input;
213
 
 
214
 
                        // increment read address counter
215
 
                        m_wac++;
216
 
 
217
 
                        if (m_wac == CRT9212_RAM_SIZE)
218
 
                        {
219
 
                                // set write overflow
220
 
                                WOF(1);
221
 
                        }
222
 
                }
223
 
        }
224
 
 
225
 
        m_wclk = state;
226
 
}