Previous 199869 Revisions Next

r24658 Friday 2nd August, 2013 at 14:23:21 UTC by Osso
Converted NMK004 to a device. (Osso)
[src/mame/drivers]nmk16.c
[src/mame/includes]nmk16.h
[src/mame/machine]nmk004.c nmk004.h

trunk/src/mame/machine/nmk004.c
r24657r24658
11#include "emu.h"
22#include "nmk004.h"
3#include "sound/2203intf.h"
4#include "sound/okim6295.h"
53
6
7
8#define FM_CHANNELS          6
9#define PSG_CHANNELS         3
10#define EFFECTS_CHANNELS     8
11
124#define FM_FLAG_NEED_INITIALIZATION      (1<<0)
135#define FM_FLAG_UNKNOWN2                 (1<<1)
146#define FM_FLAG_NOTE_IS_PAUSE            (1<<2)
r24657r24658
3022
3123#define NOTE_PAUSE             0x0c
3224
33struct psg_control
34{
35/* C220      */ UINT8  flags;
36/* C221-C222 */ UINT16 note_timer;
37/* C223-C224 */ UINT16 note_length;
38/* C225      */ UINT8  volume_timer;
39/* C227-C228 */ UINT16 current;     // current position in control table
40/* C229-C22A */ UINT16 return_address[16];  // return address when control table calls a subtable
41            int return_address_depth;
42/* C22B-C22C */ UINT16 loop_start;  // first instruction of loop
43/* C22D      */ UINT8  loop_times;  // number of times to loop
44/* C22E      */ UINT8  volume_shape;
45/* C22F      */ UINT8  volume_position;
46/* C230      */ UINT8  octave;  // base octave
47/* C231      */ UINT8  note;    // note to play
48/* C233      */ UINT8  note_period_hi_bits;
49};
50
51struct fm_control
52{
53UINT8 note;
54/* C020      */ UINT8  flags;
55/* C021      */ UINT8  slot;    // for ym2203 keyon command
56/* C022-C039 */ UINT8  voice_params[0x18];  // parameters for the YM2203 to configure sound shape
57/* C03A-C03B */ UINT16 f_number;
58/* C03C      */ UINT8  self_feedback;
59/* C03D      */ UINT8  note_duration_table_select;
60/* C03E-C03F */ UINT16 current; // current position in control table
61/* C040-C041 */ UINT16 loop_start;  // first instruction of loop
62/* C042      */ UINT8  loop_times;  // number of times to loop
63/* C043-C044 */ UINT16 return_address[16];  // return address when control table calls a subtable
64            int    return_address_depth;
65/* C045      */ UINT8  octave;
66/* C046-C047 */ UINT16 timer1;
67/* C048-C049 */ UINT16 timer2;
68/* C04A-C04B */ UINT16 timer1_duration;
69/* C04C-C04D */ UINT16 timer2_duration;
70/* C04E      */ UINT8  modulation_table_number;
71/* C04F-C050 */ UINT16 modulation_timer;
72/* C051-C052 */ UINT16 modulation_table;
73/* C053-C054 */ UINT16 modulation_table_position;
74/* C055-C056 */ UINT16 note_period;
75/* C057-C05A */ UINT8  voice_volume[4]; // parameters for the YM2203 to configure sound shape
76/* C05C      */ UINT8  must_update_voice_params;
77};
78
79struct effects_control
80{
81/* C1A0      */ UINT8  flags;
82/* C1BE-C1BF */ UINT16 current; // current position in control table
83/* C1C0-C1C1 */ UINT16 loop_start;  // first instruction of loop
84/* C1C2      */ UINT8  loop_times;  // number of times to loop
85/* C1C3-C1C4 */ UINT16 return_address[16];  // return address when control table calls a subtable
86            int    return_address_depth;
87/* C1C6-C1C7 */ UINT16 timer;
88/* C1CA-C1CB */ UINT16 timer_duration;
89};
90
91struct nmk004_state
92{
93public:
94   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
95   void set_machine(running_machine &machine) { m_machine = &machine; }
96
97   const UINT8 *rom;   // NMK004 data ROM
98   UINT8 from_main;    // command from main CPU
99   UINT8 to_main;      // answer to main CPU
100   int protection_check;
101
102   ym2203_device *ymdevice;
103   okim6295_device *oki1device;
104   okim6295_device *oki2device;
105
106   /* C001      */ UINT8 last_command;     // last command received
107   /* C016      */ UINT8 oki_playing;      // bitmap of active Oki channels
108   /* C020-C19F */ struct fm_control fm_control[FM_CHANNELS];
109   /* C220-C2DF */ struct psg_control psg_control[PSG_CHANNELS];
110   /* C1A0-C21F */ struct effects_control effects_control[EFFECTS_CHANNELS];
111
112private:
113   running_machine *m_machine;
114};
115
116static nmk004_state NMK004_state;
117
118
11925#define SAMPLE_TABLE_0      0xefe0
12026#define SAMPLE_TABLE_1      0xefe2
12127#define FM_MODULATION_TABLE 0xefe4
r24657r24658
12834#define PSG_NOTE_TABLE      0xeff2
12935
13036
131static UINT8 read8(int address)
37const device_type NMK004 = &device_creator<nmk004_device>;
38
39nmk004_device::nmk004_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
40   : device_t(mconfig, NMK004, "NMK004", tag, owner, clock, "nmk004", __FILE__),
41   m_rom(NULL),
42   m_from_main(0),
43   m_to_main(0),
44   m_protection_check(0),
45   m_last_command(0),
46   m_oki_playing(0)
13247{
133   return NMK004_state.rom[address];
48   memset(m_fm_control, 0, sizeof(m_fm_control));
49   memset(m_psg_control, 0, sizeof(m_psg_control));
50   memset(m_effects_control, 0, sizeof(m_effects_control));
13451}
13552
136static UINT16 read16(int address)
53//-------------------------------------------------
54//  device_config_complete - perform any
55//  operations now that the configuration is
56//  complete
57//-------------------------------------------------
58
59void nmk004_device::device_config_complete()
13760{
138   return NMK004_state.rom[address] + 256 * NMK004_state.rom[address+1];
13961}
14062
63//-------------------------------------------------
64//  device_start - device-specific startup
65//-------------------------------------------------
14166
67void nmk004_device::device_start()
68{
69   /* we have to do this via a timer because we get called before the sound reset */
70   machine().scheduler().synchronize(timer_expired_delegate(FUNC(nmk004_device::real_init), this));
71}
14272
73//-------------------------------------------------
74//  device_reset - device-specific reset
75//-------------------------------------------------
76
77void nmk004_device::device_reset()
78{
79}
80
81UINT8 nmk004_device::read8(int address)
82{
83   return m_rom[address];
84}
85
86UINT16 nmk004_device::read16(int address)
87{
88   return m_rom[address] + 256 * m_rom[address+1];
89}
90
91
92
14393/*****************************
14494
14595          OKI6295
14696
14797*****************************/
14898
149static void oki_play_sample(int sample_no)
99void nmk004_device::oki_play_sample(int sample_no)
150100{
151101   UINT16 table_start = (sample_no & 0x80) ? read16(SAMPLE_TABLE_1) : read16(SAMPLE_TABLE_0);
152102   UINT8 byte1 = read8(table_start + 2 * (sample_no & 0x7f) + 0);
153103   UINT8 byte2 = read8(table_start + 2 * (sample_no & 0x7f) + 1);
154104   int chip = (byte1 & 0x80) >> 7;
155   okim6295_device *okidevice = (chip) ? NMK004_state.oki2device : NMK004_state.oki1device;
105   okim6295_device *okidevice = (chip) ? m_oki2device : m_oki1device;
156106
157107   if ((byte1 & 0x7f) == 0)
158108   {
r24657r24658
165115      int ch = byte2 & 0x03;
166116      int force = (byte2 & 0x80) >> 7;
167117
168      if (!force && (NMK004_state.oki_playing & (1 << (ch + 4*chip))))
118      if (!force && (m_oki_playing & (1 << (ch + 4*chip))))
169119         return;
170120
171      NMK004_state.oki_playing |= 1 << (ch + 4*chip);
121      m_oki_playing |= 1 << (ch + 4*chip);
172122
173123      // stop channel
174124      okidevice->write_command( 0x08 << ch );
175125
176126      if (sample != 0)
177127      {
178         UINT8 *rom = NMK004_state.machine().root_device().memregion((chip == 0) ? "oki1" : "oki2")->base();
128         UINT8 *rom = machine().root_device().memregion((chip == 0) ? "oki1" : "oki2")->base();
179129         int bank = (byte2 & 0x0c) >> 2;
180130         int vol = (byte2 & 0x70) >> 4;
181131
r24657r24658
188138   }
189139}
190140
191static void oki_update_state(void)
141void nmk004_device::oki_update_state(void)
192142{
193   NMK004_state.oki_playing = ((NMK004_state.oki2device->read_status() & 0x0f) << 4) | (NMK004_state.oki1device->read_status() & 0x0f);
143   m_oki_playing = ((m_oki2device->read_status() & 0x0f) << 4) | (m_oki1device->read_status() & 0x0f);
194144}
195145
196146
r24657r24658
201151
202152*****************************/
203153
204static void effects_update(int channel)
154void nmk004_device::effects_update(int channel)
205155{
206   struct effects_control *effects = &NMK004_state.effects_control[channel];
156   struct effects_control *effects = &m_effects_control[channel];
207157
208158   // advance the timers
209159   if (effects->timer)
r24657r24658
308258
309259*****************************/
310260
311static void fm_update(int channel)
261void nmk004_device::fm_update(int channel)
312262{
313   struct fm_control *fm = &NMK004_state.fm_control[channel];
314   address_space &space = NMK004_state.machine().firstcpu->space(AS_PROGRAM);
263   struct fm_control *fm = &m_fm_control[channel];
264   address_space &space = machine().firstcpu->space(AS_PROGRAM);
315265
316266   // advance the timers
317267   if (fm->timer1)
r24657r24658
355305                  case 0xf0:  // slot (for keyon ym2203 command)
356306                     fm->flags |= FM_FLAG_MUST_SEND_CONFIGURATION;
357307                     fm->slot = read8(fm->current++);
358                     if (channel < 3 || !(NMK004_state.fm_control[channel-3].flags & FM_FLAG_ACTIVE))
308                     if (channel < 3 || !(m_fm_control[channel-3].flags & FM_FLAG_ACTIVE))
359309                     {
360                        NMK004_state.ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
361                        NMK004_state.ymdevice->write_port_w(space, 0, channel % 3);
310                        m_ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
311                        m_ymdevice->write_port_w(space, 0, channel % 3);
362312                     }
363313                     break;
364314
r24657r24658
558508
559509#if 0
560510popmessage("%02x %02x %02x %02x %02x %02x",
561      NMK004_state.fm_control[0].note,
562      NMK004_state.fm_control[1].note,
563      NMK004_state.fm_control[2].note,
564      NMK004_state.fm_control[3].note,
565      NMK004_state.fm_control[4].note,
566      NMK004_state.fm_control[5].note);
511      m_fm_control[0].note,
512      m_fm_control[1].note,
513      m_fm_control[2].note,
514      m_fm_control[3].note,
515      m_fm_control[4].note,
516      m_fm_control[5].note);
567517#endif
568518#if 0
569519popmessage("%02x %02x%02x%02x%02x %02x %02x%02x%02x%02x %02x %02x%02x%02x%02x",
570      NMK004_state.fm_control[3].note,
571      NMK004_state.fm_control[3].voice_volume[0],
572      NMK004_state.fm_control[3].voice_volume[1],
573      NMK004_state.fm_control[3].voice_volume[2],
574      NMK004_state.fm_control[3].voice_volume[3],
575      NMK004_state.fm_control[4].note,
576      NMK004_state.fm_control[4].voice_volume[0],
577      NMK004_state.fm_control[4].voice_volume[1],
578      NMK004_state.fm_control[4].voice_volume[2],
579      NMK004_state.fm_control[4].voice_volume[3],
580      NMK004_state.fm_control[5].note,
581      NMK004_state.fm_control[5].voice_volume[0],
582      NMK004_state.fm_control[5].voice_volume[1],
583      NMK004_state.fm_control[5].voice_volume[2],
584      NMK004_state.fm_control[5].voice_volume[3]);
520      m_fm_control[3].note,
521      m_fm_control[3].voice_volume[0],
522      m_fm_control[3].voice_volume[1],
523      m_fm_control[3].voice_volume[2],
524      m_fm_control[3].voice_volume[3],
525      m_fm_control[4].note,
526      m_fm_control[4].voice_volume[0],
527      m_fm_control[4].voice_volume[1],
528      m_fm_control[4].voice_volume[2],
529      m_fm_control[4].voice_volume[3],
530      m_fm_control[5].note,
531      m_fm_control[5].voice_volume[0],
532      m_fm_control[5].voice_volume[1],
533      m_fm_control[5].voice_volume[2],
534      m_fm_control[5].voice_volume[3]);
585535#endif
586536}
587537
588538
589static void fm_voices_update(void)
539void nmk004_device::fm_voices_update(void)
590540{
591541   static const int ym2203_registers[0x18] =
592542   {
r24657r24658
595545   };
596546   int channel,i;
597547
598   address_space &space = NMK004_state.machine().firstcpu->space(AS_PROGRAM);
548   address_space &space = machine().firstcpu->space(AS_PROGRAM);
599549   for (channel = 0; channel < 3;channel++)
600550   {
601      struct fm_control *fm1 = &NMK004_state.fm_control[channel];
602      struct fm_control *fm2 = &NMK004_state.fm_control[channel + 3];
551      struct fm_control *fm1 = &m_fm_control[channel];
552      struct fm_control *fm2 = &m_fm_control[channel + 3];
603553
604554      if (fm1->flags &  FM_FLAG_MUST_SEND_CONFIGURATION)
605555      {
r24657r24658
607557
608558         for (i = 0; i < 0x18; i++)
609559         {
610            NMK004_state.ymdevice->control_port_w(space, 0, ym2203_registers[i] + channel);
611            NMK004_state.ymdevice->write_port_w(space, 0, fm1->voice_params[i]);
560            m_ymdevice->control_port_w(space, 0, ym2203_registers[i] + channel);
561            m_ymdevice->write_port_w(space, 0, fm1->voice_params[i]);
612562         }
613563      }
614564
r24657r24658
620570         {
621571            for (i = 0; i < 0x18; i++)
622572            {
623               NMK004_state.ymdevice->control_port_w(space, 0, ym2203_registers[i] + channel);
624               NMK004_state.ymdevice->write_port_w(space, 0, fm2->voice_params[i]);
573               m_ymdevice->control_port_w(space, 0, ym2203_registers[i] + channel);
574               m_ymdevice->write_port_w(space, 0, fm2->voice_params[i]);
625575            }
626576         }
627577      }
r24657r24658
629579
630580      if (fm1->flags & FM_FLAG_ACTIVE)
631581      {
632         NMK004_state.ymdevice->control_port_w(space, 0, 0xb0 + channel); // self-feedback
633         NMK004_state.ymdevice->write_port_w(space, 0, fm1->self_feedback);
582         m_ymdevice->control_port_w(space, 0, 0xb0 + channel); // self-feedback
583         m_ymdevice->write_port_w(space, 0, fm1->self_feedback);
634584
635         NMK004_state.ymdevice->control_port_w(space, 0, 0xa4 + channel); // F-number
636         NMK004_state.ymdevice->write_port_w(space, 0, fm1->f_number >> 8);
585         m_ymdevice->control_port_w(space, 0, 0xa4 + channel); // F-number
586         m_ymdevice->write_port_w(space, 0, fm1->f_number >> 8);
637587
638         NMK004_state.ymdevice->control_port_w(space, 0, 0xa0 + channel); // F-number
639         NMK004_state.ymdevice->write_port_w(space, 0, fm1->f_number & 0xff);
588         m_ymdevice->control_port_w(space, 0, 0xa0 + channel); // F-number
589         m_ymdevice->write_port_w(space, 0, fm1->f_number & 0xff);
640590      }
641591      else
642592      {
643         NMK004_state.ymdevice->control_port_w(space, 0, 0xb0 + channel); // self-feedback
644         NMK004_state.ymdevice->write_port_w(space, 0, fm2->self_feedback);
593         m_ymdevice->control_port_w(space, 0, 0xb0 + channel); // self-feedback
594         m_ymdevice->write_port_w(space, 0, fm2->self_feedback);
645595
646         NMK004_state.ymdevice->control_port_w(space, 0, 0xa4 + channel); // F-number
647         NMK004_state.ymdevice->write_port_w(space, 0, fm2->f_number >> 8);
596         m_ymdevice->control_port_w(space, 0, 0xa4 + channel); // F-number
597         m_ymdevice->write_port_w(space, 0, fm2->f_number >> 8);
648598
649         NMK004_state.ymdevice->control_port_w(space, 0, 0xa0 + channel); // F-number
650         NMK004_state.ymdevice->write_port_w(space, 0, fm2->f_number & 0xff);
599         m_ymdevice->control_port_w(space, 0, 0xa0 + channel); // F-number
600         m_ymdevice->write_port_w(space, 0, fm2->f_number & 0xff);
651601      }
652602
653603
r24657r24658
656606      {
657607         fm1->flags &= ~FM_FLAG_MUST_SEND_KEYON;
658608
659         NMK004_state.ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
660         NMK004_state.ymdevice->write_port_w(space, 0, fm1->slot | channel);
609         m_ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
610         m_ymdevice->write_port_w(space, 0, fm1->slot | channel);
661611      }
662612
663613      if (fm2->flags & FM_FLAG_MUST_SEND_KEYON)
r24657r24658
666616
667617         if (!(fm1->flags & FM_FLAG_ACTIVE))
668618         {
669            NMK004_state.ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
670            NMK004_state.ymdevice->write_port_w(space, 0, fm2->slot | channel);
619            m_ymdevice->control_port_w(space, 0, 0x28);   // keyon/off
620            m_ymdevice->write_port_w(space, 0, fm2->slot | channel);
671621         }
672622      }
673623   }
r24657r24658
681631
682632*****************************/
683633
684static void psg_update(int channel)
634void nmk004_device::psg_update(int channel)
685635{
686   struct psg_control *psg = &NMK004_state.psg_control[channel];
687   address_space &space = NMK004_state.machine().firstcpu->space(AS_PROGRAM);
636   struct psg_control *psg = &m_psg_control[channel];
637   address_space &space = machine().firstcpu->space(AS_PROGRAM);
688638
689639   // advance the timers
690640   if (psg->note_timer)
r24657r24658
706656         psg->flags &= ~PSG_FLAG_NOISE_NOT_ENABLED;
707657
708658         // enable noise, disable tone on this channel
709         NMK004_state.ymdevice->control_port_w(space, 0, 0x07);
710         enable = NMK004_state.ymdevice->read_port_r(space, 0);
659         m_ymdevice->control_port_w(space, 0, 0x07);
660         enable = m_ymdevice->read_port_r(space, 0);
711661         enable |=  (0x01 << channel);   // disable tone
712662         enable &= ~(0x08 << channel);   // enable noise
713         NMK004_state.ymdevice->write_port_w(space, 0, enable);
663         m_ymdevice->write_port_w(space, 0, enable);
714664      }
715665
716666
r24657r24658
744694                     psg->flags &= ~PSG_FLAG_NOISE_NOT_ENABLED;
745695
746696                     // enable noise, disable tone on this channel
747                     NMK004_state.ymdevice->control_port_w(space, 0, 0x07);
748                     enable = NMK004_state.ymdevice->read_port_r(space, 0);
697                     m_ymdevice->control_port_w(space, 0, 0x07);
698                     enable = m_ymdevice->read_port_r(space, 0);
749699                     enable |=  (0x01 << channel);   // disable tone
750700                     enable &= ~(0x08 << channel);   // enable noise
751                     NMK004_state.ymdevice->write_port_w(space, 0, enable);
701                     m_ymdevice->write_port_w(space, 0, enable);
752702                     break;
753703
754704                  case 0xf2:  // set volume shape
r24657r24658
793743                     psg->volume_shape = 0;
794744
795745                     // mute channel
796                     NMK004_state.ymdevice->control_port_w(space, 0, 8 + channel);
797                     NMK004_state.ymdevice->write_port_w(space, 0, 0);
746                     m_ymdevice->control_port_w(space, 0, 8 + channel);
747                     m_ymdevice->write_port_w(space, 0, 0);
798748                     return;
799749               }
800750            }
r24657r24658
834784
835785               period >>= octave;
836786
837               NMK004_state.ymdevice->control_port_w(space, 0, 2 * channel + 1);
838               NMK004_state.ymdevice->write_port_w(space, 0, (period & 0x0f00) >> 8);
839               NMK004_state.ymdevice->control_port_w(space, 0, 2 * channel + 0);
840               NMK004_state.ymdevice->write_port_w(space, 0, (period & 0x00ff));
787               m_ymdevice->control_port_w(space, 0, 2 * channel + 1);
788               m_ymdevice->write_port_w(space, 0, (period & 0x0f00) >> 8);
789               m_ymdevice->control_port_w(space, 0, 2 * channel + 0);
790               m_ymdevice->write_port_w(space, 0, (period & 0x00ff));
841791
842792               psg->note_period_hi_bits = (period & 0x0f00) >> 8;
843793            }
r24657r24658
850800                  psg->flags |= PSG_FLAG_NOISE_NOT_ENABLED;
851801
852802                  // disable noise, enable tone on this channel
853                  NMK004_state.ymdevice->control_port_w(space, 0, 0x07);
854                  enable = NMK004_state.ymdevice->read_port_r(space, 0);
803                  m_ymdevice->control_port_w(space, 0, 0x07);
804                  enable = m_ymdevice->read_port_r(space, 0);
855805                  enable &= ~(0x01 << channel);   // enable tone
856806                  enable |=  (0x08 << channel);   // disable noise
857                  NMK004_state.ymdevice->write_port_w(space, 0, enable);
807                  m_ymdevice->write_port_w(space, 0, enable);
858808               }
859809
860               NMK004_state.ymdevice->control_port_w(space, 0, 0x06);   // noise period
861               NMK004_state.ymdevice->write_port_w(space, 0, psg->note);
810               m_ymdevice->control_port_w(space, 0, 0x06);   // noise period
811               m_ymdevice->write_port_w(space, 0, psg->note);
862812               psg->note_period_hi_bits = psg->note;
863813            }
864814         }
r24657r24658
883833            volume = 0;
884834
885835         // set volume
886         NMK004_state.ymdevice->control_port_w(space, 0, 8 + channel);
887         NMK004_state.ymdevice->write_port_w(space, 0, volume & 0x0f);
836         m_ymdevice->control_port_w(space, 0, 8 + channel);
837         m_ymdevice->write_port_w(space, 0, volume & 0x0f);
888838      }
889839   }
890840}
r24657r24658
897847
898848*****************************/
899849
900static void get_command(void)
850void nmk004_device::get_command(void)
901851{
902852   static const UINT8 from_main[] =
903853   {
r24657r24658
908858      0x82,0xc7,0x00,0x2c,0x6c,0x00,0x9f,0xc7,0x00,0x29,0x69,0x00,0x8b,0xc7,0x00
909859   };
910860
911   UINT8 cmd = NMK004_state.from_main;
861   UINT8 cmd = m_from_main;
912862
913   if (NMK004_state.protection_check < sizeof(to_main))
863   if (m_protection_check < sizeof(to_main))
914864   {
915865      // startup handshake
916      if (cmd == from_main[NMK004_state.protection_check])
866      if (cmd == from_main[m_protection_check])
917867      {
918         logerror("advance handshake to %02x\n",to_main[NMK004_state.protection_check]);
919         NMK004_state.to_main = to_main[NMK004_state.protection_check++];
868         logerror("advance handshake to %02x\n",to_main[m_protection_check]);
869         m_to_main = to_main[m_protection_check++];
920870      }
921871   }
922872   else
923873   {
924874      // send command back to main CPU to acknowledge reception
925      NMK004_state.to_main = cmd;
875      m_to_main = cmd;
926876   }
927877
928   if (NMK004_state.last_command != cmd)
878   if (m_last_command != cmd)
929879   {
930880      UINT16 table_start = read16(COMMAND_TABLE);
931881      UINT16 cmd_table = read16(table_start + 2 * cmd);
932882
933      NMK004_state.last_command = cmd;
883      m_last_command = cmd;
934884
935885      if ((cmd_table & 0xff00) == 0)
936886      {
r24657r24658
950900//logerror("%04x: channel %d table %04x\n",cmd_table-3,channel,table_start);
951901            if (channel < FM_CHANNELS)
952902            {
953               NMK004_state.fm_control[channel].current = table_start;
954               NMK004_state.fm_control[channel].return_address_depth = 0;
955               NMK004_state.fm_control[channel].flags |= FM_FLAG_NEED_INITIALIZATION;
903               m_fm_control[channel].current = table_start;
904               m_fm_control[channel].return_address_depth = 0;
905               m_fm_control[channel].flags |= FM_FLAG_NEED_INITIALIZATION;
956906            }
957907            else
958908            {
959909               channel -= FM_CHANNELS;
960910               if (channel < PSG_CHANNELS)
961911               {
962                  NMK004_state.psg_control[channel].current = table_start;
963                  NMK004_state.psg_control[channel].return_address_depth = 0;
964                  NMK004_state.psg_control[channel].flags |= PSG_FLAG_NEED_INITIALIZATION;
912                  m_psg_control[channel].current = table_start;
913                  m_psg_control[channel].return_address_depth = 0;
914                  m_psg_control[channel].flags |= PSG_FLAG_NEED_INITIALIZATION;
965915               }
966916               else
967917               {
r24657r24658
970920                  {
971921                     fatalerror("too many effects channels\n");
972922                  }
973                  NMK004_state.effects_control[channel].current = table_start;
974                  NMK004_state.effects_control[channel].return_address_depth = 0;
975                  NMK004_state.effects_control[channel].flags |= EFFECTS_FLAG_NEED_INITIALIZATION;
923                  m_effects_control[channel].current = table_start;
924                  m_effects_control[channel].return_address_depth = 0;
925                  m_effects_control[channel].flags |= EFFECTS_FLAG_NEED_INITIALIZATION;
976926               }
977927            }
978928         }
r24657r24658
982932
983933
984934
985static void update_music(void)
935void nmk004_device::update_music(void)
986936{
987937   int channel;
988938
r24657r24658
999949
1000950
1001951
1002void NMK004_irq(device_t *device, int irq)
952void nmk004_device::ym2203_irq_handler(int irq)
1003953{
1004954   if (irq)
1005955   {
1006      address_space &space = NMK004_state.machine().firstcpu->space(AS_PROGRAM);
1007      int status = NMK004_state.ymdevice->status_port_r(space,0);
956      address_space &space = machine().firstcpu->space(AS_PROGRAM);
957      int status = m_ymdevice->status_port_r(space,0);
1008958
1009959      if (status & 1) // timer A expired
1010960      {
r24657r24658
1013963         update_music();
1014964
1015965         // restart timer
1016         NMK004_state.ymdevice->control_port_w(space, 0, 0x27);
1017         NMK004_state.ymdevice->write_port_w(space, 0, 0x15);
966         m_ymdevice->control_port_w(space, 0, 0x27);
967         m_ymdevice->write_port_w(space, 0, 0x15);
1018968      }
1019969   }
1020970}
1021971
1022972
1023static TIMER_CALLBACK( real_nmk004_init )
973TIMER_CALLBACK_MEMBER( nmk004_device::real_init )
1024974{
1025975   static const UINT8 ym2203_init[] =
1026976   {
r24657r24658
1030980   };
1031981   int i;
1032982
1033   memset(&NMK004_state, 0, sizeof(NMK004_state));
983   m_ymdevice = machine().device<ym2203_device>("ymsnd");
984   m_oki1device = machine().device<okim6295_device>("oki1");
985   m_oki2device = machine().device<okim6295_device>("oki2");
1034986
1035   NMK004_state.set_machine(machine);
1036   NMK004_state.ymdevice = machine.device<ym2203_device>("ymsnd");
1037   NMK004_state.oki1device = machine.device<okim6295_device>("oki1");
1038   NMK004_state.oki2device = machine.device<okim6295_device>("oki2");
987   m_rom = machine().root_device().memregion("audiocpu")->base();
1039988
1040   NMK004_state.rom = machine.root_device().memregion("audiocpu")->base();
1041
1042   address_space &space = NMK004_state.machine().firstcpu->space(AS_PROGRAM);
1043   NMK004_state.ymdevice->control_port_w(space, 0, 0x2f);
1044
1045   i = 0;
1046   while (ym2203_init[i] != 0xff)
989   address_space &space = machine().firstcpu->space(AS_PROGRAM);
990   
991   if (m_ymdevice != NULL)
1047992   {
1048      NMK004_state.ymdevice->control_port_w(space, 0, ym2203_init[i++]);
1049      NMK004_state.ymdevice->write_port_w(space, 0, ym2203_init[i++]);
1050   }
993      m_ymdevice->control_port_w(space, 0, 0x2f);
1051994
1052   NMK004_state.oki_playing = 0;
995      i = 0;
996      while (ym2203_init[i] != 0xff)
997      {
998         m_ymdevice->control_port_w(space, 0, ym2203_init[i++]);
999         m_ymdevice->write_port_w(space, 0, ym2203_init[i++]);
1000      }
1001   }   
1002   else
1003      return;
1004   
1005   m_oki_playing = 0;
10531006
10541007   oki_play_sample(0);
10551008
1056   NMK004_state.protection_check = 0;
1009   m_protection_check = 0;
10571010}
10581011
1059void NMK004_init(running_machine &machine)
1060{
1061   /* we have to do this via a timer because we get called before the sound reset */
1062   machine.scheduler().synchronize(FUNC(real_nmk004_init));
1063}
10641012
1065
1066WRITE16_HANDLER( NMK004_w )
1013WRITE16_MEMBER( nmk004_device::write )
10671014{
10681015   if (ACCESSING_BITS_0_7)
10691016   {
10701017//logerror("%06x: NMK004_w %02x\n",space.device().safe_pc(),data);
1071      NMK004_state.from_main = data & 0xff;
1018      m_from_main = data & 0xff;
10721019   }
10731020}
10741021
1075READ16_HANDLER( NMK004_r )
1022READ16_MEMBER( nmk004_device::read )
10761023{
10771024//static int last;
1078   int res = NMK004_state.to_main;
1025   int res = m_to_main;
10791026
10801027//if (res != last) logerror("%06x: NMK004_r %02x\n",space.device().safe_pc(),res);
10811028//last = res;
trunk/src/mame/machine/nmk004.h
r24657r24658
1void NMK004_init(running_machine &machine);
2void NMK004_irq(device_t *device, int irq);
3DECLARE_READ16_HANDLER( NMK004_r );
4DECLARE_WRITE16_HANDLER( NMK004_w );
1#include "sound/2203intf.h"
2#include "sound/okim6295.h"
3
4#define FM_CHANNELS          6
5#define PSG_CHANNELS         3
6#define EFFECTS_CHANNELS     8
7
8struct psg_control
9{
10/* C220      */ UINT8  flags;
11/* C221-C222 */ UINT16 note_timer;
12/* C223-C224 */ UINT16 note_length;
13/* C225      */ UINT8  volume_timer;
14/* C227-C228 */ UINT16 current;     // current position in control table
15/* C229-C22A */ UINT16 return_address[16];  // return address when control table calls a subtable
16            int return_address_depth;
17/* C22B-C22C */ UINT16 loop_start;  // first instruction of loop
18/* C22D      */ UINT8  loop_times;  // number of times to loop
19/* C22E      */ UINT8  volume_shape;
20/* C22F      */ UINT8  volume_position;
21/* C230      */ UINT8  octave;  // base octave
22/* C231      */ UINT8  note;    // note to play
23/* C233      */ UINT8  note_period_hi_bits;
24};
25
26struct fm_control
27{
28UINT8 note;
29/* C020      */ UINT8  flags;
30/* C021      */ UINT8  slot;    // for ym2203 keyon command
31/* C022-C039 */ UINT8  voice_params[0x18];  // parameters for the YM2203 to configure sound shape
32/* C03A-C03B */ UINT16 f_number;
33/* C03C      */ UINT8  self_feedback;
34/* C03D      */ UINT8  note_duration_table_select;
35/* C03E-C03F */ UINT16 current; // current position in control table
36/* C040-C041 */ UINT16 loop_start;  // first instruction of loop
37/* C042      */ UINT8  loop_times;  // number of times to loop
38/* C043-C044 */ UINT16 return_address[16];  // return address when control table calls a subtable
39            int    return_address_depth;
40/* C045      */ UINT8  octave;
41/* C046-C047 */ UINT16 timer1;
42/* C048-C049 */ UINT16 timer2;
43/* C04A-C04B */ UINT16 timer1_duration;
44/* C04C-C04D */ UINT16 timer2_duration;
45/* C04E      */ UINT8  modulation_table_number;
46/* C04F-C050 */ UINT16 modulation_timer;
47/* C051-C052 */ UINT16 modulation_table;
48/* C053-C054 */ UINT16 modulation_table_position;
49/* C055-C056 */ UINT16 note_period;
50/* C057-C05A */ UINT8  voice_volume[4]; // parameters for the YM2203 to configure sound shape
51/* C05C      */ UINT8  must_update_voice_params;
52};
53
54struct effects_control
55{
56/* C1A0      */ UINT8  flags;
57/* C1BE-C1BF */ UINT16 current; // current position in control table
58/* C1C0-C1C1 */ UINT16 loop_start;  // first instruction of loop
59/* C1C2      */ UINT8  loop_times;  // number of times to loop
60/* C1C3-C1C4 */ UINT16 return_address[16];  // return address when control table calls a subtable
61            int    return_address_depth;
62/* C1C6-C1C7 */ UINT16 timer;
63/* C1CA-C1CB */ UINT16 timer_duration;
64};
65
66class nmk004_device : public device_t
67{
68public:
69   nmk004_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
70   ~nmk004_device() {}
71   
72   void ym2203_irq_handler(int irq);
73   DECLARE_READ16_MEMBER( read );
74   DECLARE_WRITE16_MEMBER( write );
75
76protected:
77   // device-level overrides
78   virtual void device_config_complete();
79   virtual void device_start();
80   virtual void device_reset();
81
82private:
83   // internal state
84   const UINT8 *m_rom;   // NMK004 data ROM
85   UINT8 m_from_main;    // command from main CPU
86   UINT8 m_to_main;      // answer to main CPU
87   int m_protection_check;
88
89   ym2203_device *m_ymdevice;
90   okim6295_device *m_oki1device;
91   okim6295_device *m_oki2device;
92
93   /* C001      */ UINT8 m_last_command;     // last command received
94   /* C016      */ UINT8 m_oki_playing;      // bitmap of active Oki channels
95   /* C020-C19F */ struct fm_control m_fm_control[FM_CHANNELS];
96   /* C220-C2DF */ struct psg_control m_psg_control[PSG_CHANNELS];
97   /* C1A0-C21F */ struct effects_control m_effects_control[EFFECTS_CHANNELS];
98   
99   TIMER_CALLBACK_MEMBER( real_init );
100   UINT8 read8(int address);
101   UINT16 read16(int address);
102   void oki_play_sample(int sample_no);
103   void oki_update_state(void);
104   void effects_update(int channel);
105   void fm_update(int channel);
106   void fm_voices_update(void);
107   void psg_update(int channel);
108   void get_command(void);
109   void update_music(void);
110};
111
112extern const device_type NMK004;
113
114#define MCFG_NMK004_ADD(_tag) \
115   MCFG_DEVICE_ADD(_tag, NMK004, 0)
trunk/src/mame/includes/nmk16.h
r24657r24658
137137   TILE_GET_INFO_MEMBER(bjtwin_get_bg_tile_info);
138138   TILE_GET_INFO_MEMBER(get_tile_info_0_8bit);
139139   DECLARE_VIDEO_START(macross);
140   DECLARE_MACHINE_RESET(NMK004);
141140   DECLARE_VIDEO_START(bioship);
142141   DECLARE_VIDEO_START(strahl);
143142   DECLARE_VIDEO_START(gunnail);
trunk/src/mame/drivers/nmk16.c
r24657r24658
190190}
191191
192192
193MACHINE_RESET_MEMBER(nmk16_state,NMK004)
194{
195   NMK004_init(machine());
196}
197
198193WRITE16_MEMBER(nmk16_state::ssmissin_sound_w)
199194{
200195   if (ACCESSING_BITS_0_7)
r24657r24658
309304   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
310305   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
311306   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("DSW2")
312   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
307   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
313308   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    /* IRQ enable? */
314309   AM_RANGE(0x080018, 0x080019) AM_WRITE(nmk_tilebank_w)
315   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
310   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
316311   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
317312   AM_RANGE(0x08c000, 0x08c007) AM_WRITE(vandyke_scroll_w)
318313   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24657r24658
327322   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
328323   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
329324   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("DSW2")
330   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
325   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
331326   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    /* IRQ enable? */
332327   AM_RANGE(0x080018, 0x080019) AM_WRITE(nmk_tilebank_w)
333328   AM_RANGE(0x080010, 0x08001d) AM_WRITE(vandykeb_scroll_w) /* 10, 12, 1a, 1c */
334   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
329   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
335330   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
336331   AM_RANGE(0x08c000, 0x08c007) AM_WRITENOP    /* just in case... */
337332   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24657r24658
400395   AM_RANGE(0x080000, 0x080001) AM_READ_PORT("IN0")
401396   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
402397   AM_RANGE(0x080004, 0x080005) AM_READ_PORT("DSW1")
403   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r) AM_WRITENOP
398   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read) AM_WRITENOP
404399   AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
405400   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    // frame number?
406   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
401   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
407402   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
408403   AM_RANGE(0x08c000, 0x08c001) AM_WRITE(mustang_scroll_w)
409404   AM_RANGE(0x08c002, 0x08c087) AM_WRITENOP    // ??
r24657r24658
455450   AM_RANGE(0xc0002, 0xc0003) AM_READ_PORT("IN1")
456451   AM_RANGE(0xc0008, 0xc0009) AM_READ_PORT("DSW1")
457452   AM_RANGE(0xc000a, 0xc000b) AM_READ_PORT("DSW2")
458   AM_RANGE(0xc000e, 0xc000f) AM_READ_LEGACY(NMK004_r)
453   AM_RANGE(0xc000e, 0xc000f) AM_DEVREAD("nmk004", nmk004_device, read)
459454   AM_RANGE(0xc0014, 0xc0015) AM_WRITE(nmk_flipscreen_w)
460455   AM_RANGE(0xc0016, 0xc0017) AM_WRITENOP
461456   AM_RANGE(0xc0018, 0xc0019) AM_WRITE(nmk_tilebank_w)
462   AM_RANGE(0xc001e, 0xc001f) AM_WRITE_LEGACY(NMK004_w)
457   AM_RANGE(0xc001e, 0xc001f) AM_DEVWRITE("nmk004", nmk004_device, write)
463458   AM_RANGE(0xc4000, 0xc45ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_word_w) AM_SHARE("paletteram")
464459   AM_RANGE(0xc8000, 0xc8007) AM_RAM_WRITE(nmk_scroll_w)
465460   AM_RANGE(0xcc000, 0xcffff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24657r24658
472467   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
473468   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
474469   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("DSW2")
475   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
470   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
476471//  AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
477   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
472   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
478473   AM_RANGE(0x084000, 0x084001) AM_WRITE(bioship_bank_w)
479474   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
480475   AM_RANGE(0x08c000, 0x08c007) AM_RAM_WRITE(bioshipbg_scroll_w)
r24657r24658
650645   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
651646   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
652647   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("UNK")
653   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
648   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
654649   AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
655650   AM_RANGE(0x080018, 0x080019) AM_WRITE(nmk_tilebank_w)
656   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
651   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
657652   /* Video Region */
658653   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
659654   AM_RANGE(0x08c000, 0x08c007) AM_WRITE(nmk_scroll_w)
r24657r24658
882877   AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("IN1")
883878   AM_RANGE(0x0c0008, 0x0c0009) AM_READ_PORT("DSW1")
884879   AM_RANGE(0x0c000a, 0x0c000b) AM_READ_PORT("DSW2")
885   AM_RANGE(0x0c000e, 0x0c000f) AM_READ_LEGACY(NMK004_r)
880   AM_RANGE(0x0c000e, 0x0c000f) AM_DEVREAD("nmk004", nmk004_device, read)
886881   AM_RANGE(0x0c0014, 0x0c0015) AM_WRITE(nmk_flipscreen_w) /* Maybe */
887882   AM_RANGE(0x0c0018, 0x0c0019) AM_WRITE(nmk_tilebank_w) /* Tile Bank ? */
888   AM_RANGE(0x0c001e, 0x0c001f) AM_WRITE_LEGACY(NMK004_w)
883   AM_RANGE(0x0c001e, 0x0c001f) AM_DEVWRITE("nmk004", nmk004_device, write)
889884   AM_RANGE(0x0c4000, 0x0c4007) AM_RAM_WRITE(nmk_scroll_w)
890885   AM_RANGE(0x0c8000, 0x0c87ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
891886   AM_RANGE(0x0cc000, 0x0cffff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24657r24658
945940   AM_RANGE(0x80002, 0x80003) AM_READ_PORT("IN1")
946941   AM_RANGE(0x80008, 0x80009) AM_READ_PORT("DSW1")
947942   AM_RANGE(0x8000a, 0x8000b) AM_READ_PORT("DSW2")
948   AM_RANGE(0x8000e, 0x8000f) AM_READ_LEGACY(NMK004_r)
943   AM_RANGE(0x8000e, 0x8000f) AM_DEVREAD("nmk004", nmk004_device, read)
949944   AM_RANGE(0x80014, 0x80015) AM_WRITE(nmk_flipscreen_w)
950945   AM_RANGE(0x80016, 0x80017) AM_WRITENOP  /* IRQ enable? */
951   AM_RANGE(0x8001e, 0x8001f) AM_WRITE_LEGACY(NMK004_w)
946   AM_RANGE(0x8001e, 0x8001f) AM_DEVWRITE("nmk004", nmk004_device, write)
952947   AM_RANGE(0x84000, 0x84007) AM_RAM_WRITE(nmk_scroll_w)
953948   AM_RANGE(0x88000, 0x88007) AM_RAM_WRITE(nmk_scroll_2_w)
954949   AM_RANGE(0x8c000, 0x8c7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_word_w) AM_SHARE("paletteram")
r24657r24658
964959   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
965960   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
966961   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("DSW2")
967   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
962   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
968963   AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
969964   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    /* IRQ enable? */
970965   AM_RANGE(0x080018, 0x080019) AM_WRITE(nmk_tilebank_w)
971   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
966   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
972967   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
973968   AM_RANGE(0x08c000, 0x08c007) AM_RAM_WRITE(nmk_scroll_w)
974969   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(nmk_bgvideoram0_w) AM_SHARE("nmk_bgvideoram0")
r24657r24658
982977   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
983978   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
984979   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("DSW2")
985   AM_RANGE(0x08000e, 0x08000f) AM_READ_LEGACY(NMK004_r)
980   AM_RANGE(0x08000e, 0x08000f) AM_DEVREAD("nmk004", nmk004_device, read)
986981   AM_RANGE(0x080014, 0x080015) AM_WRITE(nmk_flipscreen_w)
987982   AM_RANGE(0x080016, 0x080017) AM_WRITENOP    /* IRQ enable? */
988983   AM_RANGE(0x080018, 0x080019) AM_WRITE(nmk_tilebank_w)
989   AM_RANGE(0x08001e, 0x08001f) AM_WRITE_LEGACY(NMK004_w)
984   AM_RANGE(0x08001e, 0x08001f) AM_DEVWRITE("nmk004", nmk004_device, write)
990985   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
991986   AM_RANGE(0x08c000, 0x08c1ff) AM_WRITEONLY AM_SHARE("scrollram")
992987   AM_RANGE(0x08c200, 0x08c3ff) AM_WRITEONLY AM_SHARE("scrollramy")
r24657r24658
36723667   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
36733668   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
36743669
3675   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
3676
36773670   /* video hardware */
36783671   MCFG_SCREEN_ADD("screen", RASTER)
36793672   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
36903683
36913684   /* sound hardware */
36923685   MCFG_SPEAKER_STANDARD_MONO("mono")
3686   
3687   MCFG_NMK004_ADD("nmk004")
36933688
36943689   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
3695   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
3690   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
36963691   MCFG_YM2203_AY8910_INTF(&ay8910_config)
36973692   MCFG_SOUND_ROUTE(0, "mono", 0.50)
36983693   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
37463741   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 100)/* 112 breaks the title screen */
37473742   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
37483743
3749   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
3750
37513744   /* video hardware */
37523745   MCFG_SCREEN_ADD("screen", RASTER)
37533746   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
37643757
37653758   /* sound hardware */
37663759   MCFG_SPEAKER_STANDARD_MONO("mono")
3760   
3761   MCFG_NMK004_ADD("nmk004")
37673762
37683763   MCFG_SOUND_ADD("ymsnd", YM2203, BIOSHIP_CRYSTAL2 / 8) /* 1.5 Mhz (verified) */
3769   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
3764   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
37703765   MCFG_YM2203_AY8910_INTF(&ay8910_config)
37713766   MCFG_SOUND_ROUTE(0, "mono", 0.50)
37723767   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
37883783   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
37893784   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
37903785
3791   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
3792
37933786   /* video hardware */
37943787   MCFG_SCREEN_ADD("screen", RASTER)
37953788   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
38063799
38073800   /* sound hardware */
38083801   MCFG_SPEAKER_STANDARD_MONO("mono")
3802   
3803   MCFG_NMK004_ADD("nmk004")
38093804
38103805   MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/8) /* verified on pcb */
3811   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
3806   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
38123807   MCFG_YM2203_AY8910_INTF(&ay8910_config)
38133808   MCFG_SOUND_ROUTE(0, "mono", 0.50)
38143809   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
38333828   MCFG_CPU_ADD("mcu", PIC16C57, 12000000) /* 3MHz */
38343829   MCFG_DEVICE_DISABLE()
38353830
3836   //MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004) // no NMK004
3837
38383831   /* video hardware */
38393832   MCFG_SCREEN_ADD("screen", RASTER)
38403833   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
38513844
38523845   /* sound hardware */
38533846   MCFG_SPEAKER_STANDARD_MONO("mono")
3847   
3848   MCFG_NMK004_ADD("nmk004")
38543849
38553850   MCFG_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW)
38563851   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
r24657r24658
38643859   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
38653860   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
38663861
3867   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
3868
38693862   /* video hardware */
38703863   MCFG_SCREEN_ADD("screen", RASTER)
38713864   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
38823875
38833876   /* sound hardware */
38843877   MCFG_SPEAKER_STANDARD_MONO("mono")
3878   
3879   MCFG_NMK004_ADD("nmk004")
38853880
38863881   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000) /* (verified on pcb) */
3887   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
3882   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
38883883   MCFG_YM2203_AY8910_INTF(&ay8910_config)
38893884   MCFG_SOUND_ROUTE(0, "mono", 0.50)
38903885   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
39373932   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ?? drives music */
39383933   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
39393934
3940   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
3941
39423935   /* video hardware */
39433936   MCFG_SCREEN_ADD("screen", RASTER)
39443937   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
39563949
39573950   /* sound hardware */
39583951   MCFG_SPEAKER_STANDARD_MONO("mono")
3952   
3953   MCFG_NMK004_ADD("nmk004")
39593954
39603955   MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/8) /* verified on pcb */
3961   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
3956   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
39623957   MCFG_YM2203_AY8910_INTF(&ay8910_config)
39633958   MCFG_SOUND_ROUTE(0, "mono", 0.50)
39643959   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
40134008   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
40144009   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", nmk16_state, nmk16_scanline, "screen", 0, 1)
40154010
4016   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
4017
4018   /* video hardware */
4011      /* video hardware */
40194012   MCFG_SCREEN_ADD("screen", RASTER)
40204013   MCFG_SCREEN_REFRESH_RATE(56)
40214014   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
r24657r24658
40314024
40324025   /* sound hardware */
40334026   MCFG_SPEAKER_STANDARD_MONO("mono")
4027   
4028   MCFG_NMK004_ADD("nmk004")
40344029
40354030   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4036   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
4031   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
40374032   MCFG_YM2203_AY8910_INTF(&ay8910_config)
40384033   MCFG_SOUND_ROUTE(0, "mono", 0.50)
40394034   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
40554050   MCFG_CPU_VBLANK_INT_DRIVER("screen", nmk16_state,  irq4_line_hold)
40564051   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
40574052
4058   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
4059
40604053   /* video hardware */
40614054   MCFG_SCREEN_ADD("screen", RASTER)
40624055   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
40744067
40754068   /* sound hardware */
40764069   MCFG_SPEAKER_STANDARD_MONO("mono")
4070   
4071   MCFG_NMK004_ADD("nmk004")
40774072
40784073   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4079   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
4074   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
40804075   MCFG_YM2203_AY8910_INTF(&ay8910_config)
40814076   MCFG_SOUND_ROUTE(0, "mono", 0.50)
40824077   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
40984093   MCFG_CPU_VBLANK_INT_DRIVER("screen", nmk16_state,  irq4_line_hold)
40994094   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
41004095
4101   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
4102
41034096   /* video hardware */
41044097   MCFG_SCREEN_ADD("screen", RASTER)
41054098   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
41164109
41174110   /* sound hardware */
41184111   MCFG_SPEAKER_STANDARD_MONO("mono")
4112   
4113   MCFG_NMK004_ADD("nmk004")
41194114
41204115   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4121   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
4116   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
41224117   MCFG_YM2203_AY8910_INTF(&ay8910_config)
41234118   MCFG_SOUND_ROUTE(0, "mono", 0.50)
41244119   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
41404135   MCFG_CPU_VBLANK_INT_DRIVER("screen", nmk16_state,  irq4_line_hold)
41414136   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)/* ???????? */
41424137
4143   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
4144
41454138   /* video hardware */
41464139   MCFG_SCREEN_ADD("screen", RASTER)
41474140   MCFG_SCREEN_REFRESH_RATE(56.18) /* verified on pcb */
r24657r24658
41584151
41594152   /* sound hardware */
41604153   MCFG_SPEAKER_STANDARD_MONO("mono")
4154   
4155   MCFG_NMK004_ADD("nmk004")
41614156
41624157   MCFG_SOUND_ADD("ymsnd", YM2203, XTAL_12MHz/8 ) /* verified on pcb */
4163   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
4158   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
41644159   MCFG_YM2203_AY8910_INTF(&ay8910_config)
41654160   MCFG_SOUND_ROUTE(0, "mono", 0.50)
41664161   MCFG_SOUND_ROUTE(1, "mono", 0.50)
r24657r24658
41824177   MCFG_CPU_VBLANK_INT_DRIVER("screen", nmk16_state,  irq4_line_hold)
41834178   MCFG_CPU_PERIODIC_INT_DRIVER(nmk16_state, irq1_line_hold, 112)
41844179
4185   MCFG_MACHINE_RESET_OVERRIDE(nmk16_state,NMK004)
4186
41874180   /* video hardware */
41884181   MCFG_SCREEN_ADD("screen", RASTER)
41894182   MCFG_SCREEN_REFRESH_RATE(56)
r24657r24658
42004193
42014194   /* sound hardware */
42024195   MCFG_SPEAKER_STANDARD_MONO("mono")
4196   
4197   MCFG_NMK004_ADD("nmk004")
42034198
42044199   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
4205   MCFG_YM2203_IRQ_HANDLER(WRITELINE(driver_device, member_wrapper_line<NMK004_irq>))
4200   MCFG_YM2203_IRQ_HANDLER(DEVWRITELINE("nmk004", nmk004_device, ym2203_irq_handler))
42064201   MCFG_YM2203_AY8910_INTF(&ay8910_config)
42074202   MCFG_SOUND_ROUTE(0, "mono", 0.50)
42084203   MCFG_SOUND_ROUTE(1, "mono", 0.50)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team