Previous 199869 Revisions Next

r21836 Wednesday 13th March, 2013 at 16:16:46 UTC by Andrew Gardner
Modernized CRT, okim6285, and ZSG2 devices. [Andrew Gardner]
[src/emu/sound]okim6258.c okim6258.h zsg2.c zsg2.h
[src/mame/audio]taito_zm.c
[src/mess/drivers]x68k.c
[src/mess/includes]pdp1.h tx0.h
[src/mess/video]crt.c crt.h pdp1.c tx0.c

trunk/src/emu/sound/okim6258.c
r21835r21836
2121
2222static const int dividers[4] = { 1024, 768, 512, 512 };
2323
24struct okim6258_state
25{
26   UINT8  status;
27
28   UINT32 master_clock;    /* master clock frequency */
29   UINT32 divider;         /* master clock divider */
30   UINT8 adpcm_type;       /* 3/4 bit ADPCM select */
31   UINT8 data_in;          /* ADPCM data-in register */
32   UINT8 nibble_shift;     /* nibble select */
33   sound_stream *stream;   /* which stream are we playing on? */
34
35   UINT8 output_bits;
36
37   INT32 signal;
38   INT32 step;
39};
40
4124/* step size index shift table */
4225static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
4326
r21835r21836
4730/* tables computed? */
4831static int tables_computed = 0;
4932
50INLINE okim6258_state *get_safe_token(device_t *device)
33
34
35// device type definition
36const device_type OKIM6258 = &device_creator<okim6258_device>;
37
38
39//**************************************************************************
40//  LIVE DEVICE
41//**************************************************************************
42
43//-------------------------------------------------
44//  okim6258_device - constructor
45//-------------------------------------------------
46
47okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
48   : device_t(mconfig, OKIM6258, "OKI6258", tag, owner, clock),
49     device_sound_interface(mconfig, *this),
50     m_status(0),
51     m_master_clock(0),
52     m_divider(0),
53     m_adpcm_type(0),
54     m_data_in(0),
55     m_nibble_shift(0),
56     m_stream(NULL),
57     m_output_bits(0),
58     m_signal(0),
59     m_step(0)
5160{
52   assert(device != NULL);
53   assert(device->type() == OKIM6258);
54   return (okim6258_state *)downcast<okim6258_device *>(device)->token();
5561}
5662
63
64
5765/**********************************************************************************************
5866
5967     compute_tables -- compute the difference tables
r21835r21836
94102}
95103
96104
97static INT16 clock_adpcm(okim6258_state *chip, UINT8 nibble)
105//-------------------------------------------------
106//  device_start - device-specific startup
107//-------------------------------------------------
108
109void okim6258_device::device_start()
98110{
99   INT32 max = (1 << (chip->output_bits - 1)) - 1;
100   INT32 min = -(1 << (chip->output_bits - 1));
111   const okim6258_interface *intf = (const okim6258_interface *)static_config();
101112
102   chip->signal += diff_lookup[chip->step * 16 + (nibble & 15)];
113   compute_tables();
103114
104   /* clamp to the maximum */
105   if (chip->signal > max)
106      chip->signal = max;
107   else if (chip->signal < min)
108      chip->signal = min;
115   m_master_clock = clock();
116   m_adpcm_type = intf->adpcm_type;
109117
110   /* adjust the step size and clamp */
111   chip->step += index_shift[nibble & 7];
112   if (chip->step > 48)
113      chip->step = 48;
114   else if (chip->step < 0)
115      chip->step = 0;
118   /* D/A precision is 10-bits but 12-bit data can be output serially to an external DAC */
119   m_output_bits = intf->output_12bits ? 12 : 10;
120   m_divider = dividers[intf->divider];
116121
117   /* return the signal scaled up to 32767 */
118   return chip->signal << 4;
122   m_stream = stream_alloc(0, 1, clock()/m_divider);
123
124   m_signal = -2;
125   m_step = 0;
126
127   okim6258_state_save_register();
119128}
120129
121/**********************************************************************************************
122130
123     okim6258_update -- update the sound chip so that it is in sync with CPU execution
131//-------------------------------------------------
132//  device_reset - device-specific reset
133//-------------------------------------------------
124134
125***********************************************************************************************/
135void okim6258_device::device_reset()
136{
137   m_stream->update();
126138
127static STREAM_UPDATE( okim6258_update )
139   m_signal = -2;
140   m_step = 0;
141   m_status = 0;
142}
143
144
145//-------------------------------------------------
146//  sound_stream_update - handle a stream update
147//-------------------------------------------------
148
149void okim6258_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
128150{
129   okim6258_state *chip = (okim6258_state *)param;
130151   stream_sample_t *buffer = outputs[0];
131152
132153   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
133154
134   if (chip->status & STATUS_PLAYING)
155   if (m_status & STATUS_PLAYING)
135156   {
136      int nibble_shift = chip->nibble_shift;
157      int nibble_shift = m_nibble_shift;
137158
138159      while (samples)
139160      {
140161         /* Compute the new amplitude and update the current step */
141         int nibble = (chip->data_in >> nibble_shift) & 0xf;
162         int nibble = (m_data_in >> nibble_shift) & 0xf;
142163
143164         /* Output to the buffer */
144         INT16 sample = clock_adpcm(chip, nibble);
165         INT16 sample = clock_adpcm(nibble);
145166
146167         nibble_shift ^= 4;
147168
r21835r21836
150171      }
151172
152173      /* Update the parameters */
153      chip->nibble_shift = nibble_shift;
174      m_nibble_shift = nibble_shift;
154175   }
155176   else
156177   {
r21835r21836
168189
169190***********************************************************************************************/
170191
171static void okim6258_state_save_register(okim6258_state *info, device_t *device)
192void okim6258_device::okim6258_state_save_register()
172193{
173   device->save_item(NAME(info->status));
174   device->save_item(NAME(info->master_clock));
175   device->save_item(NAME(info->divider));
176   device->save_item(NAME(info->data_in));
177   device->save_item(NAME(info->nibble_shift));
178   device->save_item(NAME(info->signal));
179   device->save_item(NAME(info->step));
194   save_item(NAME(m_status));
195   save_item(NAME(m_master_clock));
196   save_item(NAME(m_divider));
197   save_item(NAME(m_data_in));
198   save_item(NAME(m_nibble_shift));
199   save_item(NAME(m_signal));
200   save_item(NAME(m_step));
180201}
181202
182203
183/**********************************************************************************************
184
185     OKIM6258_start -- start emulation of an OKIM6258-compatible chip
186
187***********************************************************************************************/
188
189static DEVICE_START( okim6258 )
204INT16 okim6258_device::clock_adpcm(UINT8 nibble)
190205{
191   const okim6258_interface *intf = (const okim6258_interface *)device->static_config();
192   okim6258_state *info = get_safe_token(device);
206   INT32 max = (1 << (m_output_bits - 1)) - 1;
207   INT32 min = -(1 << (m_output_bits - 1));
193208
194   compute_tables();
209   m_signal += diff_lookup[m_step * 16 + (nibble & 15)];
195210
196   info->master_clock = device->clock();
197   info->adpcm_type = intf->adpcm_type;
211   /* clamp to the maximum */
212   if (m_signal > max)
213      m_signal = max;
214   else if (m_signal < min)
215      m_signal = min;
198216
199   /* D/A precision is 10-bits but 12-bit data can be output serially to an external DAC */
200   info->output_bits = intf->output_12bits ? 12 : 10;
201   info->divider = dividers[intf->divider];
217   /* adjust the step size and clamp */
218   m_step += index_shift[nibble & 7];
219   if (m_step > 48)
220      m_step = 48;
221   else if (m_step < 0)
222      m_step = 0;
202223
203   info->stream = device->machine().sound().stream_alloc(*device, 0, 1, device->clock()/info->divider, info, okim6258_update);
204
205   info->signal = -2;
206   info->step = 0;
207
208   okim6258_state_save_register(info, device);
224   /* return the signal scaled up to 32767 */
225   return m_signal << 4;
209226}
210227
211228
212229/**********************************************************************************************
213230
214     OKIM6258_stop -- stop emulation of an OKIM6258-compatible chip
231     okim6258::set_divider -- set the master clock divider
215232
216233***********************************************************************************************/
217234
218static DEVICE_RESET( okim6258 )
235void okim6258_device::set_divider(int val)
219236{
220   okim6258_state *info = get_safe_token(device);
221
222   info->stream->update();
223
224   info->signal = -2;
225   info->step = 0;
226   info->status = 0;
227}
228
229
230/**********************************************************************************************
231
232     okim6258_set_divider -- set the master clock divider
233
234***********************************************************************************************/
235
236void okim6258_set_divider(device_t *device, int val)
237{
238   okim6258_state *info = get_safe_token(device);
239237   int divider = dividers[val];
240238
241   info->divider = dividers[val];
242   info->stream->set_sample_rate(info->master_clock / divider);
239   m_divider = dividers[val];
240   m_stream->set_sample_rate(m_master_clock / divider);
243241}
244242
245243
246244/**********************************************************************************************
247245
248     okim6258_set_clock -- set the master clock
246     okim6258::set_clock -- set the master clock
249247
250248***********************************************************************************************/
251249
252void okim6258_set_clock(device_t *device, int val)
250void okim6258_device::set_clock(int val)
253251{
254   okim6258_state *info = get_safe_token(device);
255
256   info->master_clock = val;
257   info->stream->set_sample_rate(info->master_clock / info->divider);
252   m_master_clock = val;
253   m_stream->set_sample_rate(m_master_clock / m_divider);
258254}
259255
260256
261257/**********************************************************************************************
262258
263     okim6258_get_vclk -- get the VCLK/sampling frequency
259     okim6258::get_vclk -- get the VCLK/sampling frequency
264260
265261***********************************************************************************************/
266262
267int okim6258_get_vclk(device_t *device)
263int okim6258_device::get_vclk()
268264{
269   okim6258_state *info = get_safe_token(device);
270
271   return (info->master_clock / info->divider);
265   return (m_master_clock / m_divider);
272266}
273267
274268
r21835r21836
278272
279273***********************************************************************************************/
280274
281READ8_DEVICE_HANDLER( okim6258_status_r )
275READ8_MEMBER( okim6258_device::okim6258_status_r )
282276{
283   okim6258_state *info = get_safe_token(device);
277   m_stream->update();
284278
285   info->stream->update();
286
287   return (info->status & STATUS_PLAYING) ? 0x00 : 0x80;
279   return (m_status & STATUS_PLAYING) ? 0x00 : 0x80;
288280}
289281
290282
r21835r21836
293285     okim6258_data_w -- write to the control port of an OKIM6258-compatible chip
294286
295287***********************************************************************************************/
296WRITE8_DEVICE_HANDLER( okim6258_data_w )
288WRITE8_MEMBER( okim6258_device::okim6258_data_w )
297289{
298   okim6258_state *info = get_safe_token(device);
299
300290   /* update the stream */
301   info->stream->update();
291   m_stream->update();
302292
303   info->data_in = data;
304   info->nibble_shift = 0;
293   m_data_in = data;
294   m_nibble_shift = 0;
305295}
306296
307297
r21835r21836
311301
312302***********************************************************************************************/
313303
314WRITE8_DEVICE_HANDLER( okim6258_ctrl_w )
304WRITE8_MEMBER( okim6258_device::okim6258_ctrl_w )
315305{
316   okim6258_state *info = get_safe_token(device);
306   m_stream->update();
317307
318   info->stream->update();
319
320308   if (data & COMMAND_STOP)
321309   {
322      info->status &= ~(STATUS_PLAYING | STATUS_RECORDING);
310      m_status &= ~(STATUS_PLAYING | STATUS_RECORDING);
323311      return;
324312   }
325313
326314   if (data & COMMAND_PLAY)
327315   {
328      if (!(info->status & STATUS_PLAYING))
316      if (!(m_status & STATUS_PLAYING))
329317      {
330         info->status |= STATUS_PLAYING;
318         m_status |= STATUS_PLAYING;
331319
332320         /* Also reset the ADPCM parameters */
333         info->signal = -2;
334         info->step = 0;
335         info->nibble_shift = 0;
321         m_signal = -2;
322         m_step = 0;
323         m_nibble_shift = 0;
336324      }
337325   }
338326   else
339327   {
340      info->status &= ~STATUS_PLAYING;
328      m_status &= ~STATUS_PLAYING;
341329   }
342330
343331   if (data & COMMAND_RECORD)
344332   {
345333      logerror("M6258: Record enabled\n");
346      info->status |= STATUS_RECORDING;
334      m_status |= STATUS_RECORDING;
347335   }
348336   else
349337   {
350      info->status &= ~STATUS_RECORDING;
338      m_status &= ~STATUS_RECORDING;
351339   }
352340}
353341
354342
355const device_type OKIM6258 = &device_creator<okim6258_device>;
356
357okim6258_device::okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
358   : device_t(mconfig, OKIM6258, "OKI6258", tag, owner, clock),
359      device_sound_interface(mconfig, *this)
360{
361   m_token = global_alloc_clear(okim6258_state);
362}
363
364//-------------------------------------------------
365//  device_config_complete - perform any
366//  operations now that the configuration is
367//  complete
368//-------------------------------------------------
369
370void okim6258_device::device_config_complete()
371{
372}
373
374//-------------------------------------------------
375//  device_start - device-specific startup
376//-------------------------------------------------
377
378void okim6258_device::device_start()
379{
380   DEVICE_START_NAME( okim6258 )(this);
381}
382
383//-------------------------------------------------
384//  device_reset - device-specific reset
385//-------------------------------------------------
386
387void okim6258_device::device_reset()
388{
389   DEVICE_RESET_NAME( okim6258 )(this);
390}
391
392//-------------------------------------------------
393//  sound_stream_update - handle a stream update
394//-------------------------------------------------
395
396void okim6258_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
397{
398   // should never get here
399   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
400}
trunk/src/emu/sound/okim6258.h
r21835r21836
33#ifndef __OKIM6258_H__
44#define __OKIM6258_H__
55
6#include "devlegcy.h"
7
8/* an interface for the OKIM6258 and similar chips */
9
10struct okim6258_interface
11{
12   int divider;
13   int adpcm_type;
14   int output_12bits;
15};
16
17
186#define FOSC_DIV_BY_1024    0
197#define FOSC_DIV_BY_768     1
208#define FOSC_DIV_BY_512     2
r21835r21836
2513#define OUTPUT_10BITS       0
2614#define OUTPUT_12BITS       1
2715
28void okim6258_set_divider(device_t *device, int val);
29void okim6258_set_clock(device_t *device, int val);
30int okim6258_get_vclk(device_t *device);
3116
32DECLARE_READ8_DEVICE_HANDLER( okim6258_status_r );
33DECLARE_WRITE8_DEVICE_HANDLER( okim6258_data_w );
34DECLARE_WRITE8_DEVICE_HANDLER( okim6258_ctrl_w );
17//**************************************************************************
18//  INTERFACE CONFIGURATION MACROS
19//**************************************************************************
3520
21#define MCFG_OKIM6258_ADD(_tag, _clock) \
22   MCFG_DEVICE_ADD(_tag, OKIM6258, _clock)
23#define MCFG_OKIM6258_REPLACE(_tag, _clock) \
24   MCFG_DEVICE_REPLACE(_tag, OKIM6258, _clock)
25
26
27//**************************************************************************
28//  TYPE DEFINITIONS
29//**************************************************************************
30
31struct okim6258_interface
32{
33   int divider;
34   int adpcm_type;
35   int output_12bits;
36};
37
38
39// ======================> okim6258_device
40
3641class okim6258_device : public device_t,
37                           public device_sound_interface
42                  public device_sound_interface
3843{
3944public:
4045   okim6258_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
41   ~okim6258_device() { global_free(m_token); }
46   ~okim6258_device() { }
4247
43   // access to legacy token
44   void *token() const { assert(m_token != NULL); return m_token; }
4548protected:
4649   // device-level overrides
47   virtual void device_config_complete();
4850   virtual void device_start();
4951   virtual void device_reset();
5052
5153   // sound stream update overrides
5254   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
55
56public:
57    DECLARE_READ8_MEMBER( okim6258_status_r );
58    DECLARE_WRITE8_MEMBER( okim6258_data_w );
59    DECLARE_WRITE8_MEMBER( okim6258_ctrl_w );
60
61public:
62    void set_divider(int val);
63    void set_clock(int val);
64    int get_vclk();
65
5366private:
54   // internal state
55   void *m_token;
67    void okim6258_state_save_register();
68    INT16 clock_adpcm(UINT8 nibble);
69
70private:
71   UINT8  m_status;
72
73   UINT32 m_master_clock;    /* master clock frequency */
74   UINT32 m_divider;         /* master clock divider */
75   UINT8 m_adpcm_type;       /* 3/4 bit ADPCM select */
76   UINT8 m_data_in;          /* ADPCM data-in register */
77   UINT8 m_nibble_shift;     /* nibble select */
78   sound_stream *m_stream;   /* which stream are we playing on? */
79
80   UINT8 m_output_bits;
81
82   INT32 m_signal;
83   INT32 m_step;
5684};
5785
5886extern const device_type OKIM6258;
trunk/src/emu/sound/zsg2.c
r21835r21836
4646#include "emu.h"
4747#include "zsg2.h"
4848
49// 16 registers per channel, 48 channels
50struct zchan
51{
52   UINT16 v[16];
53};
5449
55struct zsg2_state
50// device type definition
51const device_type ZSG2 = &device_creator<zsg2_device>;
52
53
54//**************************************************************************
55//  LIVE DEVICE
56//**************************************************************************
57
58//-------------------------------------------------
59//  zsg2_device - constructor
60//-------------------------------------------------
61
62zsg2_device::zsg2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
63   : device_t(mconfig, ZSG2, "ZSG-2", tag, owner, clock),
64     device_sound_interface(mconfig, *this),
65     m_alow(0),
66      m_ahigh(0),
67     m_bank_samples(NULL),
68     m_sample_rate(0),
69     m_stream(NULL)
5670{
57   zchan zc[48];
58   UINT16 act[3];
59   UINT16 alow, ahigh;
60   UINT8 *bank_samples;
71   memset(m_act, 0, sizeof(UINT16)*3);
72}
6173
62   int sample_rate;
63   sound_stream *stream;
64};
6574
66INLINE zsg2_state *get_safe_token(device_t *device)
75//-------------------------------------------------
76//  device_start - device-specific startup
77//-------------------------------------------------
78
79void zsg2_device::device_start()
6780{
68   assert(device != NULL);
69   assert(device->type() == ZSG2);
70   return (zsg2_state *)downcast<zsg2_device *>(device)->token();
81   const zsg2_interface *intf = (const zsg2_interface *)static_config();
82
83   m_sample_rate = clock();
84
85   memset(&m_zc, 0, sizeof(m_zc));
86   memset(&m_act, 0, sizeof(m_act));
87
88   m_stream = stream_alloc(0, 2, m_sample_rate);
89
90   m_bank_samples = memregion(intf->samplergn)->base();
7191}
7292
73static STREAM_UPDATE( update_stereo )
93
94//-------------------------------------------------
95//  sound_stream_update - handle a stream update
96//-------------------------------------------------
97
98void zsg2_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
7499{
75//  zsg2_state *info = (zsg2_state *)param;
76100   stream_sample_t *dest1 = outputs[0];
77101   stream_sample_t *dest2 = outputs[1];
78102
r21835r21836
80104   memset(dest2, 0, sizeof(stream_sample_t) * samples);
81105}
82106
83static void chan_w(zsg2_state *info, int chan, int reg, UINT16 data)
107
108
109void zsg2_device::chan_w(int chan, int reg, UINT16 data)
84110{
85   info->zc[chan].v[reg] = data;
111   m_zc[chan].v[reg] = data;
86112   //  log_event("ZOOMCHAN", "chan %02x reg %x = %04x", chan, reg, data);
87113}
88114
89static UINT16 chan_r(zsg2_state *info, int chan, int reg)
115UINT16 zsg2_device::chan_r(int chan, int reg)
90116{
91117   //  log_event("ZOOMCHAN", "chan %02x read reg %x: %04x", chan, reg, zc[chan].v[reg]);
92   return info->zc[chan].v[reg];
118   return m_zc[chan].v[reg];
93119}
94120
95static void check_channel(zsg2_state *info, int chan)
121void zsg2_device::check_channel(int chan)
96122{
97123   //  log_event("ZOOM", "chan %02x e=%04x f=%04x", chan, zc[chan].v[14], zc[chan].v[15]);
98124}
99125
100static void keyon(zsg2_state *info, int chan)
126void zsg2_device::keyon(int chan)
101127{
102128#if 0
103129   log_event("ZOOM", "keyon %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x %04x",
104130      chan,
105      info->zc[chan].v[0x0], info->zc[chan].v[0x1], info->zc[chan].v[0x2], info->zc[chan].v[0x3],
106      info->zc[chan].v[0x4], info->zc[chan].v[0x5], info->zc[chan].v[0x6], info->zc[chan].v[0x7],
107      info->zc[chan].v[0x8], info->zc[chan].v[0x9], info->zc[chan].v[0xa], info->zc[chan].v[0xb],
108      info->zc[chan].v[0xc], info->zc[chan].v[0xd], info->zc[chan].v[0xe], info->zc[chan].v[0xf]);
131      m_zc[chan].v[0x0], m_zc[chan].v[0x1], m_zc[chan].v[0x2], m_zc[chan].v[0x3],
132      m_zc[chan].v[0x4], m_zc[chan].v[0x5], m_zc[chan].v[0x6], m_zc[chan].v[0x7],
133      m_zc[chan].v[0x8], m_zc[chan].v[0x9], m_zc[chan].v[0xa], m_zc[chan].v[0xb],
134      m_zc[chan].v[0xc], m_zc[chan].v[0xd], m_zc[chan].v[0xe], m_zc[chan].v[0xf]);
109135#endif
110136}
111137
112static void control_w(zsg2_state *info, int reg, UINT16 data)
138void zsg2_device::control_w(int reg, UINT16 data)
113139{
114140   switch(reg)
115141   {
r21835r21836
119145         int i;
120146         for(i=0; i<16; i++)
121147            if(data & (1<<i))
122               keyon(info, base+i);
148               keyon(base+i);
123149         break;
124150      }
125151
r21835r21836
129155         int i;
130156         for(i=0; i<16; i++)
131157            if(data & (1<<i))
132               check_channel(info, base+i);
158               check_channel(base+i);
133159         break;
134160      }
135161
r21835r21836
137163         break;
138164
139165      case 0x38:
140         info->alow = data;
166         m_alow = data;
141167         break;
142168
143169      case 0x3a:
144         info->ahigh = data;
170         m_ahigh = data;
145171         break;
146172
147173      default:
r21835r21836
150176   }
151177}
152178
153static UINT16 control_r(zsg2_state *info, int reg)
179UINT16 zsg2_device::control_r(int reg)
154180{
155181   switch(reg)
156182   {
r21835r21836
159185
160186      case 0x3c: case 0x3e:
161187      {
162         UINT32 adr = (info->ahigh << 16) | info->alow;
163         UINT32 val = *(unsigned int *)(info->bank_samples+adr);
188         UINT32 adr = (m_ahigh << 16) | m_alow;
189         UINT32 val = *(unsigned int *)(m_bank_samples+adr);
164190//          log_event("ZOOMCTRL", "rom read.%c %06x = %08x", reg == 0x3e ? 'h' : 'l', adr, val);
165191         return (reg == 0x3e) ? (val >> 16) : val;
166192      }
r21835r21836
171197   return 0xffff;
172198}
173199
174WRITE16_DEVICE_HANDLER( zsg2_w )
200
201WRITE16_MEMBER( zsg2_device::zsg2_w )
175202{
176   zsg2_state *info = get_safe_token(device);
177203   int adr = offset * 2;
178204
179205   assert(mem_mask == 0xffff); // we only support full 16-bit accesses
180206
181   info->stream->update();
207   m_stream->update();
182208
183209   if (adr < 0x600)
184210   {
185211      int chan = adr >> 5;
186212      int reg = (adr >> 1) & 15;
187213
188      chan_w(info, chan, reg, data);
214      chan_w(chan, reg, data);
189215   }
190216   else
191217   {
192      control_w(info, adr - 0x600, data);
218      control_w(adr - 0x600, data);
193219   }
194220}
195221
196READ16_DEVICE_HANDLER( zsg2_r )
222
223READ16_MEMBER( zsg2_device::zsg2_r )
197224{
198   zsg2_state *info = get_safe_token(device);
199225   int adr = offset * 2;
200226
201227   assert(mem_mask == 0xffff); // we only support full 16-bit accesses
r21835r21836
204230   {
205231      int chan = adr >> 5;
206232      int reg = (adr >> 1) & 15;
207      return chan_r(info, chan, reg);
233      return chan_r(chan, reg);
208234   }
209235   else
210236   {
211      return control_r(info, adr - 0x600);
237      return control_r(adr - 0x600);
212238   }
213239
214240   return 0;
215241}
216242
217static DEVICE_START( zsg2 )
218{
219   const zsg2_interface *intf = (const zsg2_interface *)device->static_config();
220   zsg2_state *info = get_safe_token(device);
221
222   info->sample_rate = device->clock();
223
224   memset(&info->zc, 0, sizeof(info->zc));
225   memset(&info->act, 0, sizeof(info->act));
226
227   info->stream = device->machine().sound().stream_alloc(*device, 0, 2, info->sample_rate, info, update_stereo);
228
229   info->bank_samples = device->machine().root_device().memregion(intf->samplergn)->base();
230}
231
232const device_type ZSG2 = &device_creator<zsg2_device>;
233
234zsg2_device::zsg2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
235   : device_t(mconfig, ZSG2, "ZSG-2", tag, owner, clock),
236      device_sound_interface(mconfig, *this)
237{
238   m_token = global_alloc_clear(zsg2_state);
239}
240
241//-------------------------------------------------
242//  device_config_complete - perform any
243//  operations now that the configuration is
244//  complete
245//-------------------------------------------------
246
247void zsg2_device::device_config_complete()
248{
249}
250
251//-------------------------------------------------
252//  device_start - device-specific startup
253//-------------------------------------------------
254
255void zsg2_device::device_start()
256{
257   DEVICE_START_NAME( zsg2 )(this);
258}
259
260//-------------------------------------------------
261//  sound_stream_update - handle a stream update
262//-------------------------------------------------
263
264void zsg2_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
265{
266   // should never get here
267   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
268}
trunk/src/emu/sound/zsg2.h
r21835r21836
77#ifndef __ZSG2_H__
88#define __ZSG2_H__
99
10DECLARE_READ16_DEVICE_HANDLER( zsg2_r );
11DECLARE_WRITE16_DEVICE_HANDLER( zsg2_w );
1210
11//**************************************************************************
12//  INTERFACE CONFIGURATION MACROS
13//**************************************************************************
14
15#define MCFG_ZSG2_ADD(_tag, _clock) \
16   MCFG_DEVICE_ADD(_tag, ZSG2, _clock)
17#define MCFG_ZSG2_REPLACE(_tag, _clock) \
18   MCFG_DEVICE_REPLACE(_tag, ZSG2, _clock)
19
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
1325struct zsg2_interface
1426{
1527   const char *samplergn;
1628};
1729
30// 16 registers per channel, 48 channels
31struct zchan
32{
33    zchan()
34    {
35        memset(v, 0, sizeof(UINT16)*16);
36    }
37   
38   UINT16 v[16];
39};
40
41
42// ======================> zsg2_device
43
1844class zsg2_device : public device_t,
19                           public device_sound_interface
45               public device_sound_interface
2046{
2147public:
2248   zsg2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
23   ~zsg2_device() { global_free(m_token); }
49   ~zsg2_device() { }
2450
25   // access to legacy token
26   void *token() const { assert(m_token != NULL); return m_token; }
2751protected:
2852   // device-level overrides
29   virtual void device_config_complete();
3053   virtual void device_start();
3154
3255   // sound stream update overrides
3356   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
57
58public:
59    DECLARE_READ16_MEMBER( zsg2_r );
60    DECLARE_WRITE16_MEMBER( zsg2_w );
61
62public:
63    void chan_w(int chan, int reg, UINT16 data);
64    UINT16 chan_r(int chan, int reg);
65    void check_channel(int chan);
66    void keyon(int chan);
67    void control_w(int reg, UINT16 data);
68    UINT16 control_r(int reg);
69
3470private:
35   // internal state
36   void *m_token;
71   zchan m_zc[48];
72   UINT16 m_act[3];
73   UINT16 m_alow;
74    UINT16 m_ahigh;
75   UINT8 *m_bank_samples;
76
77   int m_sample_rate;
78   sound_stream *m_stream;
3779};
3880
3981extern const device_type ZSG2;
trunk/src/mess/drivers/x68k.c
r21835r21836
902902WRITE8_MEMBER(x68k_state::ppi_port_c_w)
903903{
904904   // ADPCM / Joystick control
905   device_t *oki = machine().device("okim6258");
905   okim6258_device *oki = machine().device<okim6258_device>("okim6258");
906906
907907   m_ppi_port[2] = data;
908908   if((data & 0x0f) != (m_ppi_prev & 0x0f))
r21835r21836
910910      m_adpcm.pan = data & 0x03;
911911      m_adpcm.rate = data & 0x0c;
912912      x68k_set_adpcm();
913      okim6258_set_divider(oki, (data >> 2) & 3);
913      oki->set_divider((data >> 2) & 3);
914914   }
915915
916916   // The joystick enable bits also handle the multiplexer for various controllers
r21835r21836
10771077
10781078WRITE8_MEMBER(x68k_state::x68k_ct_w)
10791079{
1080   device_t *okim = space.machine().device("okim6258");
1080   okim6258_device *okim = space.machine().device<okim6258_device>("okim6258");
10811081
10821082   // CT1 and CT2 bits from YM2151 port 0x1b
10831083   // CT1 - ADPCM clock - 0 = 8MHz, 1 = 4MHz
r21835r21836
10851085   m_fdc.fdc->ready_w(data & 0x01);
10861086   m_adpcm.clock = data & 0x02;
10871087   x68k_set_adpcm();
1088   okim6258_set_clock(okim, data & 0x02 ? 4000000 : 8000000);
1088   okim->set_clock(data & 0x02 ? 4000000 : 8000000);
10891089}
10901090
10911091/*
r21835r21836
17761776
17771777WRITE8_MEMBER(x68k_state::x68030_adpcm_w)
17781778{
1779   device_t *device = machine().device("okim6258");
1779   okim6258_device *device = machine().device<okim6258_device>("okim6258");
17801780   switch(offset)
17811781   {
17821782      case 0x00:
1783         okim6258_ctrl_w(device,space,0,data);
1783         device->okim6258_ctrl_w(space,0,data);
17841784         break;
17851785      case 0x01:
1786         okim6258_data_w(device,space,0,data);
1786         device->okim6258_data_w(space,0,data);
17871787         break;
17881788   }
17891789}
r21835r21836
18791879//  AM_RANGE(0xe8c000, 0xe8dfff) AM_READWRITE(x68k_printer_r, x68k_printer_w)
18801880   AM_RANGE(0xe8e000, 0xe8ffff) AM_READWRITE(x68k_sysport_r, x68k_sysport_w)
18811881   AM_RANGE(0xe90000, 0xe91fff) AM_READWRITE(x68k_fm_r, x68k_fm_w)
1882   AM_RANGE(0xe92000, 0xe92001) AM_DEVREADWRITE8_LEGACY("okim6258", okim6258_status_r, okim6258_ctrl_w, 0x00ff)
1883   AM_RANGE(0xe92002, 0xe92003) AM_DEVREADWRITE8_LEGACY("okim6258", okim6258_status_r, okim6258_data_w, 0x00ff)
1882   AM_RANGE(0xe92000, 0xe92001) AM_DEVREADWRITE8("okim6258", okim6258_device, okim6258_status_r, okim6258_ctrl_w, 0x00ff)
1883   AM_RANGE(0xe92002, 0xe92003) AM_DEVREADWRITE8("okim6258", okim6258_device, okim6258_status_r, okim6258_data_w, 0x00ff)
18841884   AM_RANGE(0xe94000, 0xe94003) AM_DEVICE8("upd72065", upd72065_device, map, 0x00ff)
18851885   AM_RANGE(0xe94004, 0xe94007) AM_READWRITE(x68k_fdc_r, x68k_fdc_w)
18861886   AM_RANGE(0xe96000, 0xe9601f) AM_DEVREADWRITE("x68k_hdc", x68k_hdc_image_device, hdc_r, hdc_w)
r21835r21836
19171917//  AM_RANGE(0xe8c000, 0xe8dfff) AM_READWRITE(x68k_printer_r, x68k_printer_w)
19181918   AM_RANGE(0xe8e000, 0xe8ffff) AM_READWRITE(x68k_sysport_r, x68k_sysport_w)
19191919   AM_RANGE(0xe90000, 0xe91fff) AM_READWRITE(x68k_fm_r, x68k_fm_w)
1920   AM_RANGE(0xe92000, 0xe92001) AM_DEVREADWRITE8_LEGACY("okim6258", okim6258_status_r, okim6258_ctrl_w, 0x00ff)
1921   AM_RANGE(0xe92002, 0xe92003) AM_DEVREADWRITE8_LEGACY("okim6258", okim6258_status_r, okim6258_data_w, 0x00ff)
1920   AM_RANGE(0xe92000, 0xe92001) AM_DEVREADWRITE8("okim6258", okim6258_device, okim6258_status_r, okim6258_ctrl_w, 0x00ff)
1921   AM_RANGE(0xe92002, 0xe92003) AM_DEVREADWRITE8("okim6258", okim6258_device, okim6258_status_r, okim6258_data_w, 0x00ff)
19221922   AM_RANGE(0xe94000, 0xe94003) AM_DEVICE8("upd72065", upd72065_device, map, 0x00ff)
19231923   AM_RANGE(0xe94004, 0xe94007) AM_READWRITE(x68k_fdc_r, x68k_fdc_w)
19241924//  AM_RANGE(0xe96000, 0xe9601f) AM_DEVREADWRITE_LEGACY("x68k_hdc",x68k_hdc_r, x68k_hdc_w)
r21835r21836
19571957//  AM_RANGE(0xe8c000, 0xe8dfff) AM_READWRITE(x68k_printer_r, x68k_printer_w)
19581958   AM_RANGE(0xe8e000, 0xe8ffff) AM_READWRITE16(x68k_sysport_r, x68k_sysport_w,0xffffffff)
19591959   AM_RANGE(0xe90000, 0xe91fff) AM_READWRITE16(x68k_fm_r, x68k_fm_w,0xffffffff)
1960   AM_RANGE(0xe92000, 0xe92003) AM_DEVREAD8_LEGACY("okim6258", okim6258_status_r, 0x00ff00ff) AM_WRITE8(x68030_adpcm_w, 0x00ff00ff)
1960   AM_RANGE(0xe92000, 0xe92003) AM_DEVREAD8("okim6258", okim6258_device, okim6258_status_r, 0x00ff00ff) AM_WRITE8(x68030_adpcm_w, 0x00ff00ff)
19611961   AM_RANGE(0xe94000, 0xe94003) AM_DEVICE8("upd72065", upd72065_device, map, 0x00ff00ff)
19621962   AM_RANGE(0xe94004, 0xe94007) AM_READWRITE16(x68k_fdc_r, x68k_fdc_w,0xffffffff)
19631963//  AM_RANGE(0xe96000, 0xe9601f) AM_DEVREADWRITE16_LEGACY("x68k_hdc",x68k_hdc_r, x68k_hdc_w,0xffffffff)
r21835r21836
26712671   MCFG_YM2151_PORT_WRITE_HANDLER(WRITE8(x68k_state,x68k_ct_w))  // CT1, CT2 from YM2151 port 0x1b
26722672   MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
26732673   MCFG_SOUND_ROUTE(1, "rspeaker", 0.50)
2674   MCFG_SOUND_ADD("okim6258", OKIM6258, 4000000)
2674   MCFG_OKIM6258_ADD("okim6258", 4000000)
26752675   MCFG_SOUND_CONFIG(x68k_okim6258_interface)
26762676   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
26772677   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
trunk/src/mess/includes/pdp1.h
r21835r21836
77#ifndef PDP1_H_
88#define PDP1_H_
99
10#include <video/crt.h>
1011
1112/* defines for each bit and mask in input port "CSW" */
1213enum
r21835r21836
254255   lightpen_t m_previous_lightpen_state;
255256   int m_pos;
256257   int m_case_shift;
257   device_t *m_crt;
258   crt_device *m_crt;
258259   virtual void machine_start();
259260   virtual void machine_reset();
260261   virtual void video_start();
trunk/src/mess/includes/tx0.h
r21835r21836
77#ifndef TX0_H_
88#define TX0_H_
99
10#include <video/crt.h>
11
1012enum state_t
1113{
1214   MTS_UNSELECTED,
r21835r21836
144146   bitmap_ind16 m_typewriter_bitmap;
145147   int m_pos;
146148   int m_case_shift;
147   device_t *m_crt;
149   crt_device *m_crt;
148150   DECLARE_DRIVER_INIT(tx0);
149151   virtual void machine_start();
150152   virtual void machine_reset();
trunk/src/mess/video/pdp1.c
r21835r21836
5555   const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1);
5656   m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds);
5757
58   m_crt = machine().device("crt");
58   m_crt = machine().device<crt_device>("crt");
5959}
6060
6161
r21835r21836
6464   // rising edge
6565   if (state)
6666   {
67      crt_eof(m_crt);
67      m_crt->eof();
6868   }
6969}
7070
r21835r21836
7777   /* compute pixel coordinates and plot */
7878   x = x*crt_window_width/01777;
7979   y = y*crt_window_height/01777;
80   crt_plot(state->m_crt, x, y);
80   state->m_crt->plot(x, y);
8181}
8282
8383
r21835r21836
8787UINT32 pdp1_state::screen_update_pdp1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
8888{
8989   pdp1_erase_lightpen(this, bitmap);
90   crt_update(m_crt, bitmap);
90   m_crt->update(bitmap);
9191   pdp1_draw_lightpen(this, bitmap);
9292
9393   pdp1_draw_panel(machine(), m_panel_bitmap);
trunk/src/mess/video/crt.c
r21835r21836
2626*/
2727
2828#include <math.h>
29
3029#include "emu.h"
31
3230#include "video/crt.h"
3331
3432
35struct point
36{
37   int intensity;      /* current intensity of the pixel */
38                     /* a node is not in the list when (intensity == -1) */
39   int next;           /* index of next pixel in list */
40};
41
33// special value that tells that the node is not in list
4234enum
4335{
44   intensity_pixel_not_in_list = -1    /* special value that tells that the node is not in list */
36   intensity_pixel_not_in_list = -1
4537};
4638
47struct crt_t
48{
49   point *list;        /* array of (crt_window_width*crt_window_height) point */
50   int *list_head; /* head of the list of lit pixels (index in the array) */
51                     /* keep a separate list for each display line (makes the video code slightly faster) */
5239
53   int decay_counter;  /* incremented each frame (tells for how many frames the CRT has decayed between two screen refresh) */
40// device type definition
41const device_type CRT = &device_creator<crt_device>;
5442
55   /* CRT window */
56   int num_intensity_levels;
57   int window_offset_x, window_offset_y;
58   int window_width, window_height;
59};
43//**************************************************************************
44//  LIVE DEVICE
45//**************************************************************************
6046
47//-------------------------------------------------
48//  crt_device - constructor
49//-------------------------------------------------
6150
62INLINE crt_t *get_safe_token(device_t *device)
51crt_device::crt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
52   : device_t(mconfig, CRT, "CRT Video", tag, owner, clock),
53     m_list(NULL),
54     m_list_head(NULL),
55     m_decay_counter(0),
56     m_num_intensity_levels(0),
57     m_window_offset_x(0),
58      m_window_offset_y(0),
59     m_window_width(0),
60      m_window_height(0)
6361{
64   assert(device != NULL);
65   assert(device->type() == CRT);
66
67   return (crt_t *)downcast<crt_device *>(device)->token();
6862}
6963
70static DEVICE_START( crt )
64
65//-------------------------------------------------
66//  device_start - device-specific startup
67//-------------------------------------------------
68
69void crt_device::device_start()
7170{
72   crt_t *crt = get_safe_token(device);
73   const crt_interface *intf = (const crt_interface *)device->static_config();
71   const crt_interface *intf = (const crt_interface *)static_config();
7472   int width = intf->width;
7573   int height = intf->height;
7674   int i;
7775
78   crt->num_intensity_levels = intf->num_levels;
79   crt->window_offset_x = intf->offset_x;
80   crt->window_offset_y = intf->offset_y;
81   crt->window_width = width;
82   crt->window_height = height;
76   m_num_intensity_levels = intf->num_levels;
77   m_window_offset_x = intf->offset_x;
78   m_window_offset_y = intf->offset_y;
79   m_window_width = width;
80   m_window_height = height;
8381
8482   /* alloc the arrays */
85   crt->list = auto_alloc_array(device->machine(), point, width * height);
83   m_list = auto_alloc_array(machine(), crt_point, width * height);
8684
87   crt->list_head = auto_alloc_array(device->machine(), int, height);
85   m_list_head = auto_alloc_array(machine(), int, height);
8886
8987   /* fill with black and set up list as empty */
9088   for (i=0; i<(width * height); i++)
9189   {
92      crt->list[i].intensity = intensity_pixel_not_in_list;
90      m_list[i].intensity = intensity_pixel_not_in_list;
9391   }
9492
9593   for (i=0; i<height; i++)
96      crt->list_head[i] = -1;
94      m_list_head[i] = -1;
9795
98   crt->decay_counter = 0;
96   m_decay_counter = 0;
9997}
10098
10199
102const device_type CRT = &device_creator<crt_device>;
103
104crt_device::crt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
105   : device_t(mconfig, CRT, "CRT Video", tag, owner, clock)
100//
101//    crt_plot
102//
103//    schedule a pixel to be plotted
104//
105void crt_device::plot(int x, int y)
106106{
107   m_token = global_alloc_clear(crt_t);
108}
109
110//-------------------------------------------------
111//  device_config_complete - perform any
112//  operations now that the configuration is
113//  complete
114//-------------------------------------------------
115
116void crt_device::device_config_complete()
117{
118}
119
120//-------------------------------------------------
121//  device_start - device-specific startup
122//-------------------------------------------------
123
124void crt_device::device_start()
125{
126   DEVICE_START_NAME( crt )(this);
127}
128
129
130
131/*
132    crt_plot
133
134    schedule a pixel to be plotted
135*/
136void crt_plot(device_t *device, int x, int y)
137{
138   crt_t *crt = get_safe_token(device);
139   point *node;
107   crt_point *node;
140108   int list_index;
141109
142110   /* compute pixel coordinates */
143111   if (x<0) x=0;
144112   if (y<0) y=0;
145   if ((x>(crt->window_width-1)) || ((y>crt->window_height-1)))
113   if ((x>(m_window_width-1)) || ((y>m_window_height-1)))
146114      return;
147   y = (crt->window_height-1) - y;
115   y = (m_window_height-1) - y;
148116
149117   /* find entry in list */
150   list_index = x + y*crt->window_width;
118   list_index = x + y*m_window_width;
151119
152   node = &crt->list[list_index];
120   node = &m_list[list_index];
153121
154122   if (node->intensity == intensity_pixel_not_in_list)
155123   {   /* insert node in list if it is not in it */
156      node->next = crt->list_head[y];
157      crt->list_head[y] = list_index;
124      node->next = m_list_head[y];
125      m_list_head[y] = list_index;
158126   }
159127   /* set intensity */
160   node->intensity = crt->num_intensity_levels;
128   node->intensity = m_num_intensity_levels;
161129}
162130
163131
164/*
165    crt_eof
166
167    keep track of time
168*/
169void crt_eof(device_t *device)
132//
133//  crt_eof
134//
135//  keep track of time
136//
137void crt_device::eof()
170138{
171   crt_t *crt = get_safe_token(device);
172   crt->decay_counter++;
139   m_decay_counter++;
173140}
174141
175142
176/*
177    crt_update
178
179    update the bitmap
180*/
181void crt_update(device_t *device, bitmap_ind16 &bitmap)
143//
144//  crt_update
145//
146//  update the bitmap
147//
148void crt_device::update(bitmap_ind16 &bitmap)
182149{
183   crt_t *crt = get_safe_token(device);
184150   int i, p_i;
185151   int y;
186152
187   //if (crt->decay_counter)
153   //if (m_decay_counter)
188154   {
189155      /* some time has elapsed: let's update the screen */
190      for (y=0; y<crt->window_height; y++)
156      for (y=0; y<m_window_height; y++)
191157      {
192         UINT16 *line = &bitmap.pix16(y+crt->window_offset_y);
158         UINT16 *line = &bitmap.pix16(y+m_window_offset_y);
193159
194160         p_i = -1;
195161
196         for (i=crt->list_head[y]; (i != -1); i=crt->list[i].next)
162         for (i=m_list_head[y]; (i != -1); i=m_list[i].next)
197163         {
198            point *node = &crt->list[i];
199            int x = (i % crt->window_width) + crt->window_offset_x;
164            crt_point *node = &m_list[i];
165            int x = (i % m_window_width) + m_window_offset_x;
200166
201            if (node->intensity == crt->num_intensity_levels)
167            if (node->intensity == m_num_intensity_levels)
202168               /* new pixel: set to max intensity */
203               node->intensity = crt->num_intensity_levels-1;
169               node->intensity = m_num_intensity_levels-1;
204170            else
205171            {
206172               /* otherwise, apply intensity decay */
207               node->intensity -= crt->decay_counter;
173               node->intensity -= m_decay_counter;
208174               if (node->intensity < 0)
209175                  node->intensity = 0;
210176            }
211177
212178            /* draw pixel on screen */
213            //plot_pixel(bitmap, x, y+crt->window_offset_y, node->intensity);
179            //plot_pixel(bitmap, x, y+m_window_offset_y, node->intensity);
214180            line[x] = node->intensity;
215181
216182            if (node->intensity != 0)
r21835r21836
219185            {   /* delete current node */
220186               node->intensity = intensity_pixel_not_in_list;
221187               if (p_i != -1)
222                  crt->list[p_i].next = node->next;
188                  m_list[p_i].next = node->next;
223189               else
224                  crt->list_head[y] = node->next;
190                  m_list_head[y] = node->next;
225191            }
226192         }
227193      }
228194
229      crt->decay_counter = 0;
195      m_decay_counter = 0;
230196   }
231197}
trunk/src/mess/video/crt.h
r21835r21836
1010#define CRT_H_
1111
1212
13/*----------- defined in video/crt.c -----------*/
13//**************************************************************************
14//  INTERFACE CONFIGURATION MACROS
15//**************************************************************************
1416
17#define MCFG_CRT_ADD(_tag, _interface) \
18   MCFG_DEVICE_ADD(_tag, CRT, 0) \
19   MCFG_DEVICE_CONFIG(_interface)
20
21
22//**************************************************************************
23//  TYPE DEFINITIONS
24//**************************************************************************
25
1526struct crt_interface
1627{
1728   int num_levels;
r21835r21836
1930   int width, height;
2031};
2132
22void crt_plot(device_t *device, int x, int y);
23void crt_eof(device_t *device);
24void crt_update(device_t *device, bitmap_ind16 &bitmap);
2533
34struct crt_point
35{
36    crt_point() :
37      intensity(0),
38      next(0) {}
39   
40   int intensity;      /* current intensity of the pixel */
41                  /* a node is not in the list when (intensity == -1) */
42   int next;           /* index of next pixel in list */
43};
44
45// ======================> crt_device
46
2647class crt_device : public device_t
2748{
2849public:
2950   crt_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
30   ~crt_device() { global_free(m_token); }
51   ~crt_device() { }
3152
32   // access to legacy token
33   void *token() const { assert(m_token != NULL); return m_token; }
3453protected:
3554   // device-level overrides
36   virtual void device_config_complete();
3755   virtual void device_start();
56
57public:
58    void plot(int x, int y);
59    void eof();
60    void update(bitmap_ind16 &bitmap);
61
3862private:
39   // internal state
40   void *m_token;
63   crt_point *m_list; /* array of (crt_window_width*crt_window_height) point */
64   int *m_list_head;  /* head of the list of lit pixels (index in the array) */
65                  /* keep a separate list for each display line (makes the video code slightly faster) */
66
67   int m_decay_counter;  /* incremented each frame (tells for how many frames the CRT has decayed between two screen refresh) */
68
69   /* CRT window */
70   int m_num_intensity_levels;
71   int m_window_offset_x;
72    int m_window_offset_y;
73   int m_window_width;
74    int m_window_height;
4175};
4276
4377extern const device_type CRT;
4478
4579
46#define MCFG_CRT_ADD(_tag, _interface) \
47   MCFG_DEVICE_ADD(_tag, CRT, 0) \
48   MCFG_DEVICE_CONFIG(_interface)
4980
5081#endif /* CRT_H_ */
trunk/src/mess/video/tx0.c
r21835r21836
4141   const rectangle typewriter_bitmap_bounds(0, typewriter_window_width-1, 0, typewriter_window_height-1);
4242   m_typewriter_bitmap.fill(pen_typewriter_bg, typewriter_bitmap_bounds);
4343
44   m_crt = machine().device("crt");
44   m_crt = machine().device<crt_device>("crt");
4545}
4646
4747
r21835r21836
5050   // rising edge
5151   if (state)
5252   {
53      crt_eof(m_crt);
53      m_crt->eof();
5454   }
5555}
5656
r21835r21836
6565   /* compute pixel coordinates and plot */
6666   x = x*crt_window_width/0777;
6767   y = y*crt_window_height/0777;
68   crt_plot(state->m_crt, x, y);
68   state->m_crt->plot(x, y);
6969}
7070
7171
r21835r21836
7474*/
7575UINT32 tx0_state::screen_update_tx0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
7676{
77   crt_update(m_crt, bitmap);
77   m_crt->update(bitmap);
7878
7979   tx0_draw_panel(machine(), m_panel_bitmap);
8080   copybitmap(bitmap, m_panel_bitmap, 0, 0, panel_window_offset_x, panel_window_offset_y, cliprect);
trunk/src/mame/audio/taito_zm.c
r21835r21836
1818static ADDRESS_MAP_START(taitozoom_map, AS_PROGRAM, 16, driver_device )
1919   AM_RANGE(0x080000, 0x0fffff) AM_ROM AM_REGION("mn10200", 0)
2020   AM_RANGE(0x400000, 0x40ffff) AM_RAM
21   AM_RANGE(0x800000, 0x800fff) AM_DEVREADWRITE_LEGACY("zsg2", zsg2_r, zsg2_w)
21   AM_RANGE(0x800000, 0x800fff) AM_DEVREADWRITE("zsg2", zsg2_device, zsg2_r, zsg2_w)
2222   AM_RANGE(0xe00000, 0xe000ff) AM_RAM // main CPU comms (1fbe0xxx on FX-1B main CPU, banked with eeprom - raystorm writes command at PC=80015240)
2323   AM_RANGE(0xc00000, 0xc00001) AM_RAM // TMS57002 comms
2424ADDRESS_MAP_END
r21835r21836
5757//  MCFG_CPU_VBLANK_INT("screen", irq0_line_pulse)
5858
5959   // we assume the parent machine has created lspeaker/rspeaker
60   MCFG_SOUND_ADD("zsg2", ZSG2, 25000000/2)
60   MCFG_ZSG2_ADD("zsg2", 25000000/2)
6161   MCFG_SOUND_CONFIG(zsg2_taito_config)
6262   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
6363   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team