Previous 15994 Revisions Next

r3560 Monday 24th November, 2008 at 09:51:18 UTC by Barry Rodewald
1. Added Oki MSM6258 ADPCM core.
2. [HD63450] More fixes to array chain transfers.
[src/emu]sndintrf.c sndintrf.h
[src/emu/sound]okim6258.c* okim6258.h* sound.mak
[src/mess]mess.mak
[src/mess/drivers]x68k.c
[src/mess/includes]x68k.h
[src/mess/machine]hd63450.c hd63450.h

src/emu/sound/sound.mak
r3559r3560
366366SOUNDDEFS += -DHAS_MSM5205=$(if $(filter MSM5205,$(SOUNDS)),1,0)
367367SOUNDDEFS += -DHAS_MSM5232=$(if $(filter MSM5232,$(SOUNDS)),1,0)
368368SOUNDDEFS += -DHAS_OKIM6295=$(if $(filter OKIM6295,$(SOUNDS)),1,0)
369SOUNDDEFS += -DHAS_OKIM6258=$(if $(filter OKIM6258,$(SOUNDS)),1,0)
369370
370371ifneq ($(filter MSM5205,$(SOUNDS)),)
371372SOUNDOBJS += $(SOUNDOBJ)/msm5205.o
r3559r3560
379380SOUNDOBJS += $(SOUNDOBJ)/okim6295.o
380381endif
381382
383ifneq ($(filter OKIM6258,$(SOUNDS)),)
384SOUNDOBJS += $(SOUNDOBJ)/okim6258.o
385endif
382386
383387
388
384389#-------------------------------------------------
385390# Philips SAA1099
386391#-------------------------------------------------
src/emu/sound/okim6258.c
r0r3560
1/**********************************************************************************************
2 *
3 *   OKI MSM6258 ADPCM
4 *
5 *   TODO:
6 *   3-bit ADPCM support
7 *   Recording?
8 *
9 **********************************************************************************************/
10
11
12#include <math.h>
13
14#include "sndintrf.h"
15#include "deprecat.h"
16#include "streams.h"
17#include "okim6258.h"
18
19#define COMMAND_STOP      (1 << 0)
20#define COMMAND_PLAY      (1 << 1)
21#define   COMMAND_RECORD      (1 << 2)
22
23#define STATUS_PLAYING      (1 << 1)
24#define STATUS_RECORDING   (1 << 2)
25
26static const int dividers[4] = { 1024, 768, 512, 512 };
27
28struct okim6258
29{
30   UINT8  status;
31
32   UINT32 master_clock;   /* master clock frequency */
33   UINT32 divider;         /* master clock divider */
34   UINT8 adpcm_type;      /* 3/4 bit ADPCM select */
35   UINT8 data_in;         /* ADPCM data-in register */
36   UINT8 nibble_shift;      /* nibble select */
37   sound_stream *stream;   /* which stream are we playing on? */
38
39   UINT8 output_bits;
40
41   INT32 signal;
42   INT32 step;
43};
44
45/* step size index shift table */
46static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
47
48/* lookup table for the precomputed difference */
49static int diff_lookup[49*16];
50
51/* tables computed? */
52static int tables_computed = 0;
53
54/**********************************************************************************************
55
56     compute_tables -- compute the difference tables
57
58***********************************************************************************************/
59
60static void compute_tables(void)
61{
62   /* nibble to bit map */
63   static const int nbl2bit[16][4] =
64   {
65      { 1, 0, 0, 0}, { 1, 0, 0, 1}, { 1, 0, 1, 0}, { 1, 0, 1, 1},
66      { 1, 1, 0, 0}, { 1, 1, 0, 1}, { 1, 1, 1, 0}, { 1, 1, 1, 1},
67      {-1, 0, 0, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 0, 1, 1},
68      {-1, 1, 0, 0}, {-1, 1, 0, 1}, {-1, 1, 1, 0}, {-1, 1, 1, 1}
69   };
70
71   int step, nib;
72
73   /* loop over all possible steps */
74   for (step = 0; step <= 48; step++)
75   {
76      /* compute the step value */
77      int stepval = floor(16.0 * pow(11.0 / 10.0, (double)step));
78
79      /* loop over all nibbles and compute the difference */
80      for (nib = 0; nib < 16; nib++)
81      {
82         diff_lookup[step*16 + nib] = nbl2bit[nib][0] *
83            (stepval   * nbl2bit[nib][1] +
84             stepval/2 * nbl2bit[nib][2] +
85             stepval/4 * nbl2bit[nib][3] +
86             stepval/8);
87      }
88   }
89
90   tables_computed = 1;
91}
92
93
94static INT16 clock_adpcm(struct okim6258 *chip, UINT8 nibble)
95{
96   INT32 max = (1 << (chip->output_bits - 1)) - 1;
97   INT32 min = -(1 << (chip->output_bits - 1));
98
99   chip->signal += diff_lookup[chip->step * 16 + (nibble & 15)];
100
101   /* clamp to the maximum */
102   if (chip->signal > max)
103      chip->signal = max;
104   else if (chip->signal < min)
105      chip->signal = min;
106
107   /* adjust the step size and clamp */
108   chip->step += index_shift[nibble & 7];
109   if (chip->step > 48)
110      chip->step = 48;
111   else if (chip->step < 0)
112      chip->step = 0;
113
114   /* return the signal scaled up to 32767 */
115   return chip->signal << 4;
116}
117
118/**********************************************************************************************
119
120     okim6258_update -- update the sound chip so that it is in sync with CPU execution
121
122***********************************************************************************************/
123
124static void okim6258_update(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
125{
126   struct okim6258 *chip = param;
127   stream_sample_t *buffer = outputs[0];
128
129   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
130
131   if (chip->status & STATUS_PLAYING)
132   {
133      int nibble_shift = chip->nibble_shift;
134
135      while (samples)
136      {
137         /* Compute the new amplitude and update the current step */
138         int nibble = (chip->data_in >> nibble_shift) & 0xf;
139
140         /* Output to the buffer */   
141         INT16 sample = clock_adpcm(chip, nibble);
142
143         nibble_shift ^= 4;
144
145         *buffer++ = sample;
146         samples--;
147      }
148
149      /* Update the parameters */
150      chip->nibble_shift = nibble_shift;
151   }
152   else
153   {
154      /* Fill with 0 */
155      while (samples--)
156         *buffer++ = 0;
157   }
158}
159
160
161
162/**********************************************************************************************
163
164     state save support for MAME
165
166***********************************************************************************************/
167
168static void okim6258_state_save_register(struct okim6258 *info, int sndindex)
169{
170   char buf[20];
171
172   sprintf(buf, "OKIM6258");
173
174   state_save_register_item(buf, sndindex, info->status);
175   state_save_register_item(buf, sndindex, info->master_clock);
176   state_save_register_item(buf, sndindex, info->divider);
177   state_save_register_item(buf, sndindex, info->data_in);
178   state_save_register_item(buf, sndindex, info->nibble_shift);
179   state_save_register_item(buf, sndindex, info->signal);
180   state_save_register_item(buf, sndindex, info->step);
181}
182
183
184/**********************************************************************************************
185
186     OKIM6258_start -- start emulation of an OKIM6258-compatible chip
187
188***********************************************************************************************/
189
190static void *okim6258_start(const char *tag, int sndindex, int clock, const void *config)
191{
192   const okim6258_interface *intf = config;
193   struct okim6258 *info;           
194
195   info = auto_malloc(sizeof(*info));
196   memset(info, 0, sizeof(*info));
197
198   compute_tables();
199
200   info->master_clock = clock;
201   info->adpcm_type = intf->adpcm_type;
202
203   /* D/A precision is 10-bits but 12-bit data can be output serially to an external DAC */
204   info->output_bits = intf->output_12bits ? 12 : 10;
205   info->divider = dividers[intf->divider];
206
207   info->stream = stream_create(0, 1, clock/info->divider, info, okim6258_update);
208
209   info->signal = -2;
210   info->step = 0;
211
212   okim6258_state_save_register(info, sndindex);
213
214   return info;
215}
216
217
218/**********************************************************************************************
219
220     OKIM6258_stop -- stop emulation of an OKIM6258-compatible chip
221
222***********************************************************************************************/
223
224static void okim6258_reset(void *chip)
225{
226   struct okim6258 *info = chip;
227
228   stream_update(info->stream);
229
230   info->signal = -2;
231   info->step = 0;
232   info->status = 0;
233}
234
235
236/**********************************************************************************************
237
238     okim6258_set_divider -- set the master clock divider
239
240***********************************************************************************************/
241
242void okim6258_set_divider(int which, int val)
243{
244   struct okim6258 *info = sndti_token(SOUND_OKIM6258, which);
245   int divider = dividers[val];
246   
247   info->divider = dividers[val];
248   stream_set_sample_rate(info->stream, info->master_clock / divider);
249}
250
251
252/**********************************************************************************************
253
254     okim6258_set_clock -- set the master clock
255
256***********************************************************************************************/
257
258void okim6258_set_clock(int which, int val)
259{
260   struct okim6258 *info = sndti_token(SOUND_OKIM6258, which);
261
262   info->master_clock = val;
263   stream_set_sample_rate(info->stream, info->master_clock / info->divider);
264}
265
266
267/**********************************************************************************************
268
269     okim6258_get_vclk -- get the VCLK/sampling frequency
270
271***********************************************************************************************/
272
273int okim6258_get_vclk(int which)
274{
275   struct okim6258 *info = sndti_token(SOUND_OKIM6258, which);
276
277   return (info->master_clock / info->divider);
278}
279
280
281/**********************************************************************************************
282
283     okim6258_status_r -- read the status port of an OKIM6258-compatible chip
284
285***********************************************************************************************/
286
287static int okim6258_status_r(int num)
288{
289   struct okim6258 *info = sndti_token(SOUND_OKIM6258, num);
290
291   stream_update(info->stream);
292
293   return (info->status & STATUS_PLAYING) ? 0x00 : 0x80;
294}
295
296
297/**********************************************************************************************
298
299     okim6258_data_w -- write to the control port of an OKIM6258-compatible chip
300
301***********************************************************************************************/
302static void okim6258_data_w(int num, int data)
303{
304   struct okim6258 *info = sndti_token(SOUND_OKIM6258, num);
305
306   /* update the stream */
307   stream_update(info->stream);
308
309   info->data_in = data;
310   info->nibble_shift = 0;
311}
312
313
314/**********************************************************************************************
315
316     okim6258_ctrl_w -- write to the control port of an OKIM6258-compatible chip
317
318***********************************************************************************************/
319
320static void okim6258_ctrl_w(int num, int data)
321{
322   struct okim6258 *info = sndti_token(SOUND_OKIM6258, num);
323
324   stream_update(info->stream);
325
326   if (data & COMMAND_STOP)
327   {
328      info->status &= ~(STATUS_PLAYING | STATUS_RECORDING);
329      return;
330   }
331
332   if (data & COMMAND_PLAY)
333   {
334      if (!(info->status & STATUS_PLAYING))
335      {
336         info->status |= STATUS_PLAYING;
337
338         /* Also reset the ADPCM parameters */
339         info->signal = -2;
340         info->step = 0;
341         info->nibble_shift = 0;
342      }
343   }
344   else
345   {
346      info->status &= ~STATUS_PLAYING;
347   }
348
349   if (data & COMMAND_RECORD)
350   {
351      logerror("M6258: Record enabled\n");
352      info->status |= STATUS_RECORDING;
353   }
354   else
355   {
356      info->status &= ~STATUS_RECORDING;
357   }
358}
359
360
361/**********************************************************************************************
362
363     okim6258_status_0_r -- generic status read functions
364
365***********************************************************************************************/
366
367READ8_HANDLER( okim6258_status_0_r )
368{
369   return okim6258_status_r(0);
370}
371
372READ16_HANDLER( okim6258_status_0_lsb_r )
373{
374   return okim6258_status_r(0);
375}
376
377READ16_HANDLER( okim6258_status_0_msb_r )
378{
379   return okim6258_status_r(0) << 8;
380}
381
382READ8_HANDLER( okim6258_data_0_r )
383{
384   // TODO
385   return 0;
386}
387
388READ16_HANDLER( okim6258_data_0_lsb_r )
389{
390   // TODO
391   return 0;
392}
393
394READ16_HANDLER( okim6258_data_0_msb_r )
395{
396   // TODO
397   return 0;
398}
399
400/**********************************************************************************************
401
402     okim6258_data_0_w -- generic data write functions
403     okim6258_data_1_w
404
405***********************************************************************************************/
406
407WRITE8_HANDLER( okim6258_data_0_w )
408{
409   okim6258_data_w(0, data);
410}
411
412WRITE8_HANDLER( okim6258_data_1_w )
413{
414   okim6258_data_w(1, data);
415}
416
417WRITE8_HANDLER( okim6258_data_2_w )
418{
419   okim6258_data_w(2, data);
420}
421
422WRITE16_HANDLER( okim6258_data_0_lsb_w )
423{
424   if (ACCESSING_BITS_0_7)
425      okim6258_data_w(0, data & 0xff);
426}
427
428WRITE16_HANDLER( okim6258_data_1_lsb_w )
429{
430   if (ACCESSING_BITS_0_7)
431      okim6258_data_w(1, data & 0xff);
432}
433
434WRITE16_HANDLER( okim6258_data_2_lsb_w )
435{
436   if (ACCESSING_BITS_0_7)
437      okim6258_data_w(2, data & 0xff);
438}
439
440WRITE16_HANDLER( okim6258_data_0_msb_w )
441{
442   if (ACCESSING_BITS_8_15)
443      okim6258_data_w(0, data >> 8);
444}
445
446WRITE16_HANDLER( okim6258_data_1_msb_w )
447{
448   if (ACCESSING_BITS_8_15)
449      okim6258_data_w(1, data >> 8);
450}
451
452WRITE16_HANDLER( okim6258_data_2_msb_w )
453{
454   if (ACCESSING_BITS_8_15)
455      okim6258_data_w(2, data >> 8);
456}
457
458WRITE16_HANDLER( okim6258_ctrl_0_lsb_w )
459{
460   if (ACCESSING_BITS_0_7)
461      okim6258_ctrl_w(0, data & 0xff);
462}
463
464
465/**************************************************************************
466 * Generic get_info
467 **************************************************************************/
468
469static void okim6258_set_info(void *token, UINT32 state, sndinfo *info)
470{
471   switch (state)
472   {
473      /* no parameters to set */
474   }
475}
476
477
478void okim6258_get_info(void *token, UINT32 state, sndinfo *info)
479{
480   switch (state)
481   {
482      /* --- the following bits of info are returned as 64-bit signed integers --- */
483
484      /* --- the following bits of info are returned as pointers to data or functions --- */
485      case SNDINFO_PTR_SET_INFO:                  info->set_info = okim6258_set_info;      break;
486      case SNDINFO_PTR_START:                     info->start = okim6258_start;         break;
487      case SNDINFO_PTR_STOP:                     /* nothing */                     break;
488      case SNDINFO_PTR_RESET:                     info->reset = okim6258_reset;         break;
489
490      /* --- the following bits of info are returned as NULL-terminated strings --- */
491      case SNDINFO_STR_NAME:                     info->s = "OKI6258";               break;
492      case SNDINFO_STR_CORE_FAMILY:               info->s = "OKI ADPCM";               break;
493      case SNDINFO_STR_CORE_VERSION:               info->s = "1.0";                  break;
494      case SNDINFO_STR_CORE_FILE:                  info->s = __FILE__;                  break;
495      case SNDINFO_STR_CORE_CREDITS:               info->s = "Copyright Nicola Salmoria and the MAME Team"; break;
496   }
497}
498
src/emu/sound/okim6258.h
r0r3560
1#pragma once
2
3#ifndef __OKIM6258_H__
4#define __OKIM6258_H__
5
6/* an interface for the OKIM6258 and similar chips */
7
8struct _okim6258_interface
9{
10   int divider;
11   int adpcm_type;
12   int output_12bits;
13};
14
15typedef struct _okim6258_interface okim6258_interface;
16
17#define FOSC_DIV_BY_1024   0
18#define FOSC_DIV_BY_768      1
19#define FOSC_DIV_BY_512      2
20
21#define TYPE_3BITS           0
22#define TYPE_4BITS         1
23
24#define   OUTPUT_10BITS      0
25#define   OUTPUT_12BITS      1
26
27void okim6258_set_divider(int which, int val);
28void okim6258_set_clock(int which, int val);
29
30READ8_HANDLER( okim6258_status_0_r );
31READ16_HANDLER( okim6258_status_0_lsb_r );
32READ16_HANDLER( okim6258_status_0_msb_r );
33WRITE8_HANDLER( okim6258_data_0_w );
34READ8_HANDLER( okim6258_data_0_r );
35WRITE8_HANDLER( okim6258_ctrl_0_w );
36WRITE16_HANDLER( okim6258_data_0_lsb_w );
37WRITE16_HANDLER( okim6258_ctrl_0_lsb_w );
38READ16_HANDLER( okim6258_data_0_lsb_r );
39READ16_HANDLER( okim6258_data_0_msb_r );
40
41#endif /* __OKIM6258_H__ */
src/emu/sndintrf.c
r3559r3560
123123void okim6295_get_info(void *token, UINT32 state, sndinfo *info);
124124void msm5205_get_info(void *token, UINT32 state, sndinfo *info);
125125void msm5232_get_info(void *token, UINT32 state, sndinfo *info);
126void okim6258_get_info(void *token, UINT32 state, sndinfo *info);
126127void upd7759_get_info(void *token, UINT32 state, sndinfo *info);
127128void hc55516_get_info(void *token, UINT32 state, sndinfo *info);
128129void mc3417_get_info(void *token, UINT32 state, sndinfo *info);
r3559r3560
485486#if (HAS_AICA)
486487   { SOUND_AICA, aica_get_info },
487488#endif
489#if (HAS_OKIM6258)
490   { SOUND_OKIM6258, okim6258_get_info },
491#endif
488492
489493   { SOUND_FILTER_VOLUME, filter_volume_get_info },
490494   { SOUND_FILTER_RC, filter_rc_get_info },
src/emu/sndintrf.h
r3559r3560
8484   SOUND_TMS5220,
8585   SOUND_VLM5030,
8686   SOUND_OKIM6295,
87   SOUND_OKIM6258,
8788   SOUND_MSM5205,
8889   SOUND_MSM5232,
8990   SOUND_UPD7759,
src/mess/includes/x68k.h
r3559r3560
6666   {
6767      int rate;  // ADPCM sample rate
6868      int pan;  // ADPCM output switch
69      int clock;  // ADPCM clock speed
6970   } adpcm;
7071   struct
7172   {
src/mess/machine/hd63450.c
r3559r3560
2626      dmac->timer[x] = timer_alloc(dma_transfer_timer, (void*)device);
2727      dmac->reg[x].niv = 0x0f;  // defaults?
2828      dmac->reg[x].eiv = 0x0f;
29      dmac->clock[x] = dmac->intf->clock[x];
30      dmac->burst_clock[x] = dmac->intf->burst_clock[x];
2931   }
3032   return DEVICE_START_OK;
3133}
r3559r3560
200202   dmac->reg[channel].csr &= ~0xe0;
201203   dmac->reg[channel].csr |= 0x08;  // Channel active
202204   dmac->reg[channel].csr &= ~0x30;  // Reset Error and Normal termination bits
203   if(dmac->reg[channel].btc > 0)
205   if((dmac->reg[channel].ocr & 0x0c) != 0x00)  // Array chain or Link array chain
204206   {
205207      dmac->reg[channel].mar = program_read_word(dmac->reg[channel].bar) << 16;
206208      dmac->reg[channel].mar |= program_read_word(dmac->reg[channel].bar+2);
207209      dmac->reg[channel].mtc = program_read_word(dmac->reg[channel].bar+4);
208      dmac->reg[channel].btc--;
210      if(dmac->reg[channel].btc > 0)
211         dmac->reg[channel].btc--;
209212   }
210213
211214   // Burst transfers will halt the CPU until the transfer is complete
212215   if((dmac->reg[channel].dcr & 0xc0) == 0x00)  // Burst transfer
213216   {
214217      cpunum_set_input_line(device->machine, dmac->intf->cpu,INPUT_LINE_HALT,ASSERT_LINE);
215      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->intf->burst_clock[channel]);
218      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->burst_clock[channel]);
216219   }
217220   else
218      timer_adjust_periodic(dmac->timer[channel], ATTOTIME_IN_USEC(500), channel, dmac->intf->clock[channel]);
221      timer_adjust_periodic(dmac->timer[channel], ATTOTIME_IN_USEC(500), channel, dmac->clock[channel]);
219222
220
221223   dmac->transfer_size[channel] = dmac->reg[channel].mtc;
222224
223225   logerror("DMA: Transfer begins: size=0x%08x\n",dmac->transfer_size[channel]);
224226}
225227
228void hd63450_set_timer(const device_config* device, int channel, attotime tm)
229{
230   hd63450_t* dmac = device->token;
231
232   dmac->clock[channel] = tm;
233   if(dmac->in_progress[channel] != 0)
234      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->clock[channel]);
235}
236
226237static TIMER_CALLBACK(dma_transfer_timer)
227238{
228239   hd63450_single_transfer(ptr, param);
r3559r3560
255266   if(dmac->halted[channel] != 0)
256267   {
257268      dmac->halted[channel] = 0;
258      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->intf->clock[channel]);
269      timer_adjust_periodic(dmac->timer[channel], attotime_zero, channel, dmac->clock[channel]);
259270   }
260271}
261272
r3559r3560
366377         {
367378            // End of transfer
368379            logerror("DMA#%i: End of transfer\n",x);
369            if(dmac->reg[x].btc > 0)
380            if((dmac->reg[x].ocr & 0x0c) != 0 && dmac->reg[x].btc > 0)
370381            {
371382               dmac->reg[x].btc--;
372383               dmac->reg[x].bar+=6;
src/mess/machine/hd63450.h
r3559r3560
4444{
4545    hd63450_regs reg[4];
4646   emu_timer* timer[4];  // for timing data reading/writing each channel
47   attotime clock[4];
48   attotime burst_clock[4];
4749   int in_progress[4];  // if a channel is in use
4850   int transfer_size[4];
4951   int halted[4];  // non-zero if a channel has been halted, and can be continued later.
r3559r3560
5658int hd63450_read(const device_config* device, int offset, UINT16 mem_mask);
5759void hd63450_write(const device_config* device,int offset, int data, UINT16 mem_mask);
5860void hd63450_single_transfer(const device_config* device, int x);
61void hd63450_set_timer(const device_config* device, int channel, attotime tm);
5962
6063void dma_transfer_start(const device_config* device, int channel, int dir);
6164
src/mess/mess.mak
r3559r3560
339339SOUNDS += SID6581
340340SOUNDS += SID8580
341341SOUNDS += SP0256
342SOUNDS += OKIM6258
342343
343344
344345#-------------------------------------------------
src/mess/drivers/x68k.c
r3559r3560
105105      Keyboard doesn't work (MFP USART).
106106      Supervisor area set isn't implemented.
107107
108    Some minor game-specific issues (at 22/10/08):
108    Some minor game-specific issues (at 14/05/08):
109109      Pacmania:      Black squares on the maze (transparency?).
110      Nemesis '94:   Menu system doesn't work except for start buttons.
111      Flying Shark:  Appears to lock up at main menu.
110112      Salamander:    System error when using keys in-game.  No error if a joystick is used.
111113      Kyukyoku Tiger:Sprites offset by a looooong way.
112      Dragon Buster: Text is black and unreadable.
113      Baraduke:      Locks up on demo mode.
114      Dragon Buster: Text is black and unreadable (text palette should be loaded from disk, but it reads all zeroes).
115      Baraduke:      Corrupt background, locks up on demo mode.
116      Viewpoint:     Corrupt graphics on title screen, phantom movements on title screen, corrupt sprites, locks up.
114117      Tetris:        Black dots over screen (text layer).
115118      Parodius Da!:  Black squares in areas.
116119
r3559r3560
126129#include "machine/8255ppi.h"
127130#include "machine/nec765.h"
128131#include "sound/2151intf.h"
129#include "sound/okim6295.h"
132#include "sound/okim6258.h"
130133#include "machine/8530scc.h"
131134#include "machine/hd63450.h"
132135#include "machine/rp5c15.h"
r3559r3560
650653   }
651654}
652655
656static void x68k_set_adpcm(running_machine* machine)
657{
658   const device_config *dev = device_list_find_by_tag(machine->config->devicelist, HD63450, "hd63450");
659   UINT32 rate = 0;
660
661   switch(sys.adpcm.rate & 0x0c)
662   {
663      case 0x00:
664         rate = 7812/2;
665         break;
666      case 0x04:
667         rate = 10417/2;
668         break;
669      case 0x08:
670         rate = 15625/2;
671         break;
672      default:
673         logerror("PPI: Invalid ADPCM sample rate set.\n");
674         rate = 15625/2;
675   }
676   if(sys.adpcm.clock != 0)
677      rate = rate/2;
678   hd63450_set_timer(dev,3,ATTOTIME_IN_HZ(rate));
679}
680
681
653682// Judging from the XM6 source code, PPI ports A and B are joystick inputs
654683static READ8_DEVICE_HANDLER( ppi_port_a_r )
655684{
r3559r3560
685714static WRITE8_DEVICE_HANDLER( ppi_port_c_w )
686715{
687716   // ADPCM / Joystick control
717   
688718   ppi_port[2] = data;
689719   sys.adpcm.pan = data & 0x03;
690720   sys.adpcm.rate = data & 0x0c;
721   x68k_set_adpcm(device->machine);
722   okim6258_set_divider(0, (data >> 2) & 3);
723
691724   sys.joy.joy1_enable = data & 0x10;
692725   sys.joy.joy2_enable = data & 0x20;
693726   sys.joy.ioc6 = data & 0x40;
r3559r3560
695728}
696729
697730
698
699731// NEC uPD72065 at 0xe94000
700732static WRITE16_HANDLER( x68k_fdc_w )
701733{
r3559r3560
866898   // CT1 - ADPCM clock - 0 = 8MHz, 1 = 4MHz
867899   // CT2 - 1 = Set ready state of FDC
868900   nec765_set_ready_state(data & 0x01);
901   sys.adpcm.clock = data & 0x02;
902   x68k_set_adpcm(machine);
903   okim6258_set_clock(0, data & 0x02 ? 4000000 : 8000000);
869904}
870905
871906/*
r3559r3560
13301365   return 0xff;
13311366}
13321367
1333static READ16_HANDLER( x68k_adpcm_r )
1334{
1335   return 0x0000;
1336}
1337
1338static WRITE16_HANDLER( x68k_adpcm_w )
1339{
1340}
1341
13421368static READ16_HANDLER( x68k_areaset_r )
13431369{
13441370   // register is write-only
r3559r3560
15001526   prev = level;
15011527}
15021528
1529static INTERRUPT_GEN( x68k_vsync_irq )
1530{
1531//  if(sys.mfp.ierb & 0x40)
1532//  {
1533//      sys.mfp.isrb |= 0x40;
1534//      current_vector[6] = (sys.mfp.vr & 0xf0) | 0x06;  // GPIP4 (V-DISP)
1535//      current_irq_line = 6;
1536//  mfp_timer_a_callback(0);  // Timer A is usually always in event count mode, and is tied to V-DISP
1537//  mfp_trigger_irq(MFP_IRQ_GPIP4);
1538//  }
1539//  if(sys.crtc.height == 256)
1540//      video_screen_update_partial(machine->primary_screen,256);//sys.crtc.reg[4]/2);
1541//  else
1542//      video_screen_update_partial(machine->primary_screen,512);//sys.crtc.reg[4]);
1543}
1544
15031545static IRQ_CALLBACK(x68k_int_ack)
15041546{
15051547   const device_config *x68k_mfp = device_list_find_by_tag(machine->config->devicelist, MC68901, MC68901_TAG);
15061548
15071549   if(irqline == 6)  // MFP
15081550   {
1551//      if(sys.mfp.isra & 0x10)
1552//          sys.mfp.rsr &= ~0x80;
1553//      if(sys.mfp.isra & 0x04)
1554//          sys.mfp.tsr &= ~0x80;
1555
1556//      if(sys.mfp.current_irq < 8)
1557//      {
1558//          sys.mfp.iprb &= ~(1 << sys.mfp.current_irq);
1559         // IRQ is in service
1560//          if(sys.mfp.eoi_mode != 0)  // automatic EOI does not set the ISR registers
1561//              sys.mfp.isrb |= (1 << sys.mfp.current_irq);
1562//      }
1563//      else
1564//      {
1565//          sys.mfp.ipra &= ~(1 << (sys.mfp.current_irq - 8));
1566         // IRQ is in service
1567//          if(sys.mfp.eoi_mode != 0)  // automatic EOI does not set the ISR registers
1568//              sys.mfp.isra |= (1 << (sys.mfp.current_irq - 8));
1569//      }
15091570      sys.mfp.current_irq = -1;
15101571      current_vector[6] = mc68901_get_vector(x68k_mfp);
15111572      logerror("SYS: IRQ acknowledged (vector=0x%02x, line = %i)\n",current_vector[6],irqline);
r3559r3560
15421603//  AM_RANGE(0xe8c000, 0xe8dfff) AM_READWRITE(x68k_printer_r, x68k_printer_w)
15431604   AM_RANGE(0xe8e000, 0xe8ffff) AM_READWRITE(x68k_sysport_r, x68k_sysport_w)
15441605   AM_RANGE(0xe90000, 0xe91fff) AM_READWRITE(x68k_fm_r, x68k_fm_w)
1545   AM_RANGE(0xe92000, 0xe93fff) AM_READWRITE(x68k_adpcm_r, x68k_adpcm_w)
1606   AM_RANGE(0xe92000, 0xe92001) AM_READWRITE(okim6258_status_0_lsb_r, okim6258_ctrl_0_lsb_w)
1607   AM_RANGE(0xe92002, 0xe92003) AM_READWRITE(okim6258_data_0_lsb_r, okim6258_data_0_lsb_w)
15461608   AM_RANGE(0xe94000, 0xe95fff) AM_READWRITE(x68k_fdc_r, x68k_fdc_w)
15471609   AM_RANGE(0xe96000, 0xe97fff) AM_DEVREADWRITE(X68KHDC,"x68k_hdc",x68k_hdc_r, x68k_hdc_w)
15481610   AM_RANGE(0xe98000, 0xe99fff) AM_READWRITE(x68k_scc_r, x68k_scc_w)
r3559r3560
15861648static const hd63450_intf dmac_interface =
15871649{
15881650   0,  // CPU - 68000
1589   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_USEC(4),STATIC_ATTOTIME_IN_USEC(32)},  // Cycle steal mode timing (guesstimate)
1651   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_USEC(4),STATIC_ATTOTIME_IN_HZ(15625/2)},  // Cycle steal mode timing (guesstimate)
15901652   {STATIC_ATTOTIME_IN_USEC(32),STATIC_ATTOTIME_IN_NSEC(450),STATIC_ATTOTIME_IN_NSEC(50),STATIC_ATTOTIME_IN_NSEC(50)}, // Burst mode timing (guesstimate)
15911653   x68k_dma_end,
15921654   x68k_dma_error,
r3559r3560
16081670   x68k_ct_w  // CT1, CT2 from YM2151 port 0x1b
16091671};
16101672
1673static const okim6258_interface x68k_okim6258_interface =
1674{
1675   FOSC_DIV_BY_512,
1676   TYPE_4BITS,
1677   OUTPUT_10BITS,
1678};
1679
16111680static const struct rp5c15_interface rtc_intf =
16121681{
16131682   x68k_rtc_alarm_irq
r3559r3560
20502119   led_timer = timer_alloc(x68k_led_callback,NULL);
20512120}
20522121
2053
20542122static MACHINE_DRIVER_START( x68000 )
20552123   /* basic machine hardware */
20562124   MDRV_CPU_ADD("main", M68000, 10000000)  /* 10 MHz */
20572125   MDRV_CPU_PROGRAM_MAP(x68k_map, 0)
2126   MDRV_CPU_VBLANK_INT("main", x68k_vsync_irq)
20582127   MDRV_INTERLEAVE(1)
20592128
20602129   MDRV_MACHINE_START( x68000 )
r3559r3560
20952164   MDRV_SOUND_ADD("ym2151", YM2151, 4000000)
20962165   MDRV_SOUND_CONFIG(x68k_ym2151_interface)
20972166   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
2098//  MDRV_SOUND_ADD("okim6295", OKIM6295, 0)
2099//  MDRV_SOUND_CONFIG(oki_interface)
2100//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
2167    MDRV_SOUND_ADD("okim6258", OKIM6258, 4000000)
2168    MDRV_SOUND_CONFIG(x68k_okim6258_interface)
2169    MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
21012170
21022171   MDRV_NVRAM_HANDLER( generic_0fill )
21032172MACHINE_DRIVER_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team