Previous 199869 Revisions Next

r34269 Thursday 8th January, 2015 at 21:49:52 UTC by smf
fix incorrect cr+lf (nw)
[src/mame/includes]midtunit.h midwunit.h midyunit.h
[src/mame/machine]midtunit.c midwunit.c midyunit.c

trunk/src/mame/includes/midtunit.h
r242780r242781
1414   {
1515      TIMER_DMA
1616   };
17 
18   midtunit_state(const machine_config &mconfig, device_type type, const char *tag)
19      : driver_device(mconfig, type, tag),
20      m_maincpu(*this, "maincpu"),
21      m_palette(*this, "palette"),
22      m_dcs(*this, "dcs"),
23      m_cvsd_sound(*this, "cvsd"),
24      m_adpcm_sound(*this, "adpcm") ,
25      m_generic_paletteram_16(*this, "paletteram"),
26      m_nvram(*this, "nvram"),
27      m_gfxrom(*this, "gfxrom"),
28      m_ports(*this, tunit_ports) { }
29 
30   required_device<cpu_device> m_maincpu;
31   required_device<palette_device> m_palette;
32   optional_device<dcs_audio_device> m_dcs;
33   optional_device<williams_cvsd_sound_device> m_cvsd_sound;
34   optional_device<williams_adpcm_sound_device> m_adpcm_sound;
35   
36   required_shared_ptr<UINT16> m_generic_paletteram_16;
37   required_shared_ptr<UINT16> m_nvram;
38   
39   required_memory_region m_gfxrom;
40   
41   required_ioport_array<4> m_ports;
42   DECLARE_IOPORT_ARRAY(tunit_ports);
43 
44   DECLARE_WRITE16_MEMBER(midtunit_cmos_enable_w);
45   DECLARE_WRITE16_MEMBER(midtunit_cmos_w);
17
18   midtunit_state(const machine_config &mconfig, device_type type, const char *tag)
19      : driver_device(mconfig, type, tag),
20      m_maincpu(*this, "maincpu"),
21      m_palette(*this, "palette"),
22      m_dcs(*this, "dcs"),
23      m_cvsd_sound(*this, "cvsd"),
24      m_adpcm_sound(*this, "adpcm") ,
25      m_generic_paletteram_16(*this, "paletteram"),
26      m_nvram(*this, "nvram"),
27      m_gfxrom(*this, "gfxrom"),
28      m_ports(*this, tunit_ports) { }
29
30   required_device<cpu_device> m_maincpu;
31   required_device<palette_device> m_palette;
32   optional_device<dcs_audio_device> m_dcs;
33   optional_device<williams_cvsd_sound_device> m_cvsd_sound;
34   optional_device<williams_adpcm_sound_device> m_adpcm_sound;
35
36   required_shared_ptr<UINT16> m_generic_paletteram_16;
37   required_shared_ptr<UINT16> m_nvram;
38
39   required_memory_region m_gfxrom;
40
41   required_ioport_array<4> m_ports;
42   DECLARE_IOPORT_ARRAY(tunit_ports);
43
44   DECLARE_WRITE16_MEMBER(midtunit_cmos_enable_w);
45   DECLARE_WRITE16_MEMBER(midtunit_cmos_w);
4646   DECLARE_READ16_MEMBER(midtunit_cmos_r);
4747   DECLARE_READ16_MEMBER(midtunit_input_r);
4848   DECLARE_READ16_MEMBER(midtunit_sound_state_r);
r242780r242781
7373   DECLARE_READ16_MEMBER(midwunit_control_r);
7474   DECLARE_WRITE16_MEMBER(midtunit_paletteram_w);
7575   DECLARE_WRITE16_MEMBER(midxunit_paletteram_w);
76   DECLARE_READ16_MEMBER(midxunit_paletteram_r);
77   DECLARE_READ16_MEMBER(midtunit_dma_r);
78   DECLARE_WRITE16_MEMBER(midtunit_dma_w);
79   
80   TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
81   TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
82   TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update);
83   
84   DECLARE_DRIVER_INIT(mktunit);
85   DECLARE_DRIVER_INIT(mkturbo);
86   DECLARE_DRIVER_INIT(nbajamte);
87   DECLARE_DRIVER_INIT(nbajam);
88   DECLARE_DRIVER_INIT(jdreddp);
89   DECLARE_DRIVER_INIT(mk2);
90   
91   DECLARE_MACHINE_RESET(midtunit);
92   DECLARE_VIDEO_START(midtunit);
93 
94   void register_state_saving();
95   void init_tunit_generic(int sound);
96   void init_nbajam_common(int te_protection);
97 
98   /* CMOS-related variables */
99   UINT8    m_cmos_write_enable;
100 
101   /* sound-related variables */
102   UINT8    m_chip_type;
103   UINT8    m_fake_sound_state;
104 
105   /* protection */
106   UINT8    m_mk_prot_index;
107   UINT16   m_mk2_prot_data;
108 
109   const UINT32 *m_nbajam_prot_table;
110   UINT16   m_nbajam_prot_queue[5];
111   UINT8    m_nbajam_prot_index;
112 
113   const UINT8 *m_jdredd_prot_table;
114   UINT8    m_jdredd_prot_index;
115   UINT8    m_jdredd_prot_max;
116 
117   UINT8 m_gfx_rom_large;
118 
76   DECLARE_READ16_MEMBER(midxunit_paletteram_r);
77   DECLARE_READ16_MEMBER(midtunit_dma_r);
78   DECLARE_WRITE16_MEMBER(midtunit_dma_w);
79
80   TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
81   TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
82   TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update);
83
84   DECLARE_DRIVER_INIT(mktunit);
85   DECLARE_DRIVER_INIT(mkturbo);
86   DECLARE_DRIVER_INIT(nbajamte);
87   DECLARE_DRIVER_INIT(nbajam);
88   DECLARE_DRIVER_INIT(jdreddp);
89   DECLARE_DRIVER_INIT(mk2);
90
91   DECLARE_MACHINE_RESET(midtunit);
92   DECLARE_VIDEO_START(midtunit);
93
94   void register_state_saving();
95   void init_tunit_generic(int sound);
96   void init_nbajam_common(int te_protection);
97
98   /* CMOS-related variables */
99   UINT8    m_cmos_write_enable;
100
101   /* sound-related variables */
102   UINT8    m_chip_type;
103   UINT8    m_fake_sound_state;
104
105   /* protection */
106   UINT8    m_mk_prot_index;
107   UINT16   m_mk2_prot_data;
108
109   const UINT32 *m_nbajam_prot_table;
110   UINT16   m_nbajam_prot_queue[5];
111   UINT8    m_nbajam_prot_index;
112
113   const UINT8 *m_jdredd_prot_table;
114   UINT8    m_jdredd_prot_index;
115   UINT8    m_jdredd_prot_max;
116
117   UINT8 m_gfx_rom_large;
118
119119protected:
120120   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
121121};
trunk/src/mame/includes/midwunit.h
r242780r242781
1010
1111class midwunit_state : public midtunit_state
1212{
13public:
14   midwunit_state(const machine_config &mconfig, device_type type, const char *tag)
15      : midtunit_state(mconfig, type, tag),
16         m_midway_serial_pic(*this, "serial_pic"),
17         m_nvram(*this, "nvram"),
18         m_ports(*this, wunit_ports)
19         { }
20 
21   required_device<midway_serial_pic_device> m_midway_serial_pic;
22   required_shared_ptr<UINT16> m_nvram;
23   required_ioport_array<4> m_ports;
24   
25   DECLARE_IOPORT_ARRAY(wunit_ports);
26   
27   UINT8 m_cmos_write_enable;
28   UINT16 m_iodata[8];
29   UINT8 m_ioshuffle[16];
30   UINT8 m_uart[8];
31   UINT8 m_security_bits;
32   UINT16 *m_umk3_palette;
33   
34   DECLARE_WRITE16_MEMBER(midwunit_cmos_enable_w);
35   DECLARE_WRITE16_MEMBER(midwunit_cmos_w);
36   DECLARE_READ16_MEMBER(midwunit_cmos_r);
13public:
14   midwunit_state(const machine_config &mconfig, device_type type, const char *tag)
15      : midtunit_state(mconfig, type, tag),
16         m_midway_serial_pic(*this, "serial_pic"),
17         m_nvram(*this, "nvram"),
18         m_ports(*this, wunit_ports)
19         { }
20
21   required_device<midway_serial_pic_device> m_midway_serial_pic;
22   required_shared_ptr<UINT16> m_nvram;
23   required_ioport_array<4> m_ports;
24
25   DECLARE_IOPORT_ARRAY(wunit_ports);
26
27   UINT8 m_cmos_write_enable;
28   UINT16 m_iodata[8];
29   UINT8 m_ioshuffle[16];
30   UINT8 m_uart[8];
31   UINT8 m_security_bits;
32   UINT16 *m_umk3_palette;
33
34   DECLARE_WRITE16_MEMBER(midwunit_cmos_enable_w);
35   DECLARE_WRITE16_MEMBER(midwunit_cmos_w);
36   DECLARE_READ16_MEMBER(midwunit_cmos_r);
3737   DECLARE_WRITE16_MEMBER(midwunit_io_w);
3838   DECLARE_READ16_MEMBER(midwunit_io_r);
3939   DECLARE_READ16_MEMBER(midwunit_security_r);
4040   DECLARE_WRITE16_MEMBER(midwunit_security_w);
4141   DECLARE_READ16_MEMBER(midwunit_sound_r);
4242   DECLARE_READ16_MEMBER(midwunit_sound_state_r);
43   DECLARE_WRITE16_MEMBER(midwunit_sound_w);
44   DECLARE_WRITE16_MEMBER(umk3_palette_hack_w);
45   DECLARE_WRITE16_MEMBER(wwfmania_io_0_w);
46   
47   DECLARE_DRIVER_INIT(mk3r10);
48   DECLARE_DRIVER_INIT(nbahangt);
49   DECLARE_DRIVER_INIT(wwfmania);
43   DECLARE_WRITE16_MEMBER(midwunit_sound_w);
44   DECLARE_WRITE16_MEMBER(umk3_palette_hack_w);
45   DECLARE_WRITE16_MEMBER(wwfmania_io_0_w);
46
47   DECLARE_DRIVER_INIT(mk3r10);
48   DECLARE_DRIVER_INIT(nbahangt);
49   DECLARE_DRIVER_INIT(wwfmania);
5050   DECLARE_DRIVER_INIT(umk3);
5151   DECLARE_DRIVER_INIT(mk3);
5252   DECLARE_DRIVER_INIT(openice);
53   DECLARE_DRIVER_INIT(rmpgwt);
54   DECLARE_DRIVER_INIT(umk3r11);
55   DECLARE_DRIVER_INIT(mk3r20);
56   
57   DECLARE_MACHINE_RESET(midwunit);
58   DECLARE_VIDEO_START(midwunit);
59   
60   void register_state_saving();
61   void init_wunit_generic();
62   void init_mk3_common();
53   DECLARE_DRIVER_INIT(rmpgwt);
54   DECLARE_DRIVER_INIT(umk3r11);
55   DECLARE_DRIVER_INIT(mk3r20);
56
57   DECLARE_MACHINE_RESET(midwunit);
58   DECLARE_VIDEO_START(midwunit);
59
60   void register_state_saving();
61   void init_wunit_generic();
62   void init_mk3_common();
6363};
trunk/src/mame/includes/midyunit.h
r242780r242781
4545         m_oki(*this, "oki"),
4646         m_palette(*this, "palette"),
4747         m_narc_sound(*this, "narcsnd"),
48         m_cvsd_sound(*this, "cvsd"),
49         m_adpcm_sound(*this, "adpcm"),
50         m_generic_paletteram_16(*this, "paletteram"),
51         m_gfx_rom(*this, "gfx_rom", 16),
52         m_ports(*this, ports) { }
53 
54   required_device<cpu_device> m_maincpu;
55   optional_device<cpu_device> m_audiocpu;
48         m_cvsd_sound(*this, "cvsd"),
49         m_adpcm_sound(*this, "adpcm"),
50         m_generic_paletteram_16(*this, "paletteram"),
51         m_gfx_rom(*this, "gfx_rom", 16),
52         m_ports(*this, ports) { }
53
54   required_device<cpu_device> m_maincpu;
55   optional_device<cpu_device> m_audiocpu;
5656   optional_device<okim6295_device> m_oki;
5757   required_device<palette_device> m_palette;
5858   optional_device<williams_narc_sound_device> m_narc_sound;
5959   optional_device<williams_cvsd_sound_device> m_cvsd_sound;
6060   optional_device<williams_adpcm_sound_device> m_adpcm_sound;
61 
62   required_shared_ptr<UINT16> m_generic_paletteram_16;
63   optional_shared_ptr<UINT8> m_gfx_rom;
64   
65   optional_ioport_array<6> m_ports;
66   
67   DECLARE_IOPORT_ARRAY(ports);
68 
69   UINT16 *m_cmos_ram;
70   UINT32 m_cmos_page;
61
62   required_shared_ptr<UINT16> m_generic_paletteram_16;
63   optional_shared_ptr<UINT8> m_gfx_rom;
64
65   optional_ioport_array<6> m_ports;
66
67   DECLARE_IOPORT_ARRAY(ports);
68
69   UINT16 *m_cmos_ram;
70   UINT32 m_cmos_page;
7171   UINT16 m_prot_result;
7272   UINT16 m_prot_sequence[3];
7373   UINT8 m_prot_index;
trunk/src/mame/machine/midtunit.c
r242780r242781
2525 *  State saving
2626 *
2727 *************************************/
28 
29void midtunit_state::register_state_saving()
30{
31   save_item(NAME(m_cmos_write_enable));
32   save_item(NAME(m_fake_sound_state));
33   save_item(NAME(m_mk_prot_index));
34   save_item(NAME(m_mk2_prot_data));
35   save_item(NAME(m_nbajam_prot_queue));
36   save_item(NAME(m_nbajam_prot_index));
37   save_item(NAME(m_jdredd_prot_index));
38   save_item(NAME(m_jdredd_prot_max));
39}
40 
41 
4228
29void midtunit_state::register_state_saving()
30{
31   save_item(NAME(m_cmos_write_enable));
32   save_item(NAME(m_fake_sound_state));
33   save_item(NAME(m_mk_prot_index));
34   save_item(NAME(m_mk2_prot_data));
35   save_item(NAME(m_nbajam_prot_queue));
36   save_item(NAME(m_nbajam_prot_index));
37   save_item(NAME(m_jdredd_prot_index));
38   save_item(NAME(m_jdredd_prot_max));
39}
40
41
42
4343/*************************************
4444 *
4545 *  CMOS reads/writes
4646 *
4747 *************************************/
48 
49WRITE16_MEMBER(midtunit_state::midtunit_cmos_enable_w)
50{
51   m_cmos_write_enable = 1;
52}
53 
54 
55WRITE16_MEMBER(midtunit_state::midtunit_cmos_w)
56{
57   if (1)/*m_cmos_write_enable*/
58   {
59      COMBINE_DATA(m_nvram+offset);
60      m_cmos_write_enable = 0;
61   }
62   else
63   {
48
49WRITE16_MEMBER(midtunit_state::midtunit_cmos_enable_w)
50{
51   m_cmos_write_enable = 1;
52}
53
54
55WRITE16_MEMBER(midtunit_state::midtunit_cmos_w)
56{
57   if (1)/*m_cmos_write_enable*/
58   {
59      COMBINE_DATA(m_nvram+offset);
60      m_cmos_write_enable = 0;
61   }
62   else
63   {
6464      logerror("%08X:Unexpected CMOS W @ %05X\n", space.device().safe_pc(), offset);
6565      popmessage("Bad CMOS write");
6666   }
r242780r242781
7676
7777/*************************************
7878 *
79 *  Generic input ports
80 *
81 *************************************/
82 
83IOPORT_ARRAY_MEMBER(midtunit_state::tunit_ports) { "IN0", "IN1", "IN2", "DSW" };
84 
85READ16_MEMBER(midtunit_state::midtunit_input_r)
86{
87   return m_ports[offset]->read();
88}
89 
90 
79 *  Generic input ports
80 *
81 *************************************/
9182
83IOPORT_ARRAY_MEMBER(midtunit_state::tunit_ports) { "IN0", "IN1", "IN2", "DSW" };
84
85READ16_MEMBER(midtunit_state::midtunit_input_r)
86{
87   return m_ports[offset]->read();
88}
89
90
91
9292/*************************************
9393 *
9494 *  Mortal Kombat (T-unit) protection
r242780r242781
106106   0x16, 0x2d, 0x1a, 0x34, 0x28, 0x10, 0x21, 0x03,
107107   0xff
108108};
109 
110READ16_MEMBER(midtunit_state::mk_prot_r)
111{
112   logerror("%08X:Protection R @ %05X = %04X\n", space.device().safe_pc(), offset, mk_prot_values[m_mk_prot_index] << 9);
113 
114   /* just in case */
115   if (m_mk_prot_index >= sizeof(mk_prot_values))
116   {
117      logerror("%08X:Unexpected protection R @ %05X\n", space.device().safe_pc(), offset);
118      m_mk_prot_index = 0;
119   }
120 
121   return mk_prot_values[m_mk_prot_index++] << 9;
122}
123 
124WRITE16_MEMBER(midtunit_state::mk_prot_w)
109
110READ16_MEMBER(midtunit_state::mk_prot_r)
125111{
112   logerror("%08X:Protection R @ %05X = %04X\n", space.device().safe_pc(), offset, mk_prot_values[m_mk_prot_index] << 9);
113
114   /* just in case */
115   if (m_mk_prot_index >= sizeof(mk_prot_values))
116   {
117      logerror("%08X:Unexpected protection R @ %05X\n", space.device().safe_pc(), offset);
118      m_mk_prot_index = 0;
119   }
120
121   return mk_prot_values[m_mk_prot_index++] << 9;
122}
123
124WRITE16_MEMBER(midtunit_state::mk_prot_w)
125{
126126   if (ACCESSING_BITS_8_15)
127127   {
128128      int first_val = (data >> 9) & 0x3f;
129129      int i;
130130
131131      /* find the desired first value and stop then */
132      for (i = 0; i < sizeof(mk_prot_values); i++)
133         if (mk_prot_values[i] == first_val)
134         {
135            m_mk_prot_index = i;
136            break;
137         }
138 
132      for (i = 0; i < sizeof(mk_prot_values); i++)
133         if (mk_prot_values[i] == first_val)
134         {
135            m_mk_prot_index = i;
136            break;
137         }
138
139139      /* just in case */
140      if (i == sizeof(mk_prot_values))
141      {
142         logerror("%08X:Unhandled protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
143         m_mk_prot_index = 0;
144      }
145 
146      logerror("%08X:Protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
140      if (i == sizeof(mk_prot_values))
141      {
142         logerror("%08X:Unhandled protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
143         m_mk_prot_index = 0;
144      }
145
146      logerror("%08X:Protection W @ %05X = %04X\n", space.device().safe_pc(), offset, data);
147147   }
148148}
149149
r242780r242781
174174{
175175   return 2;
176176}
177 
178READ16_MEMBER(midtunit_state::mk2_prot_r)
179{
180   return m_mk2_prot_data;
181}
182 
183READ16_MEMBER(midtunit_state::mk2_prot_shift_r)
184{
185   return m_mk2_prot_data >> 1;
186}
187 
188WRITE16_MEMBER(midtunit_state::mk2_prot_w)
189{
190   COMBINE_DATA(&m_mk2_prot_data);
191}
192 
193 
194177
178READ16_MEMBER(midtunit_state::mk2_prot_r)
179{
180   return m_mk2_prot_data;
181}
182
183READ16_MEMBER(midtunit_state::mk2_prot_shift_r)
184{
185   return m_mk2_prot_data >> 1;
186}
187
188WRITE16_MEMBER(midtunit_state::mk2_prot_w)
189{
190   COMBINE_DATA(&m_mk2_prot_data);
191}
192
193
194
195195/*************************************
196196 *
197197 *  NBA Jam protection
r242780r242781
237237   0x30180c26, 0x31381c0e, 0x32393c3e, 0x33192c16, 0x343a3d1e, 0x351a2d36, 0x361b0d06, 0x373b1d2e,
238238   0x381c2e17, 0x393c3e3f, 0x3a3d1e0f, 0x3b1d0e27, 0x3c3e1f2f, 0x3d1e0f07, 0x3e1f2f37, 0x3f3f3f1f
239239};
240 
241READ16_MEMBER(midtunit_state::nbajam_prot_r)
242{
243   int result = m_nbajam_prot_queue[m_nbajam_prot_index];
244   if (m_nbajam_prot_index < 4)
245      m_nbajam_prot_index++;
246   return result;
247}
248 
249WRITE16_MEMBER(midtunit_state::nbajam_prot_w)
250{
251   int table_index = (offset >> 6) & 0x7f;
252   UINT32 protval = m_nbajam_prot_table[table_index];
253 
254   m_nbajam_prot_queue[0] = data;
255   m_nbajam_prot_queue[1] = ((protval >> 24) & 0xff) << 9;
256   m_nbajam_prot_queue[2] = ((protval >> 16) & 0xff) << 9;
257   m_nbajam_prot_queue[3] = ((protval >> 8) & 0xff) << 9;
258   m_nbajam_prot_queue[4] = ((protval >> 0) & 0xff) << 9;
259   m_nbajam_prot_index = 0;
260}
261 
262 
263240
241READ16_MEMBER(midtunit_state::nbajam_prot_r)
242{
243   int result = m_nbajam_prot_queue[m_nbajam_prot_index];
244   if (m_nbajam_prot_index < 4)
245      m_nbajam_prot_index++;
246   return result;
247}
248
249WRITE16_MEMBER(midtunit_state::nbajam_prot_w)
250{
251   int table_index = (offset >> 6) & 0x7f;
252   UINT32 protval = m_nbajam_prot_table[table_index];
253
254   m_nbajam_prot_queue[0] = data;
255   m_nbajam_prot_queue[1] = ((protval >> 24) & 0xff) << 9;
256   m_nbajam_prot_queue[2] = ((protval >> 16) & 0xff) << 9;
257   m_nbajam_prot_queue[3] = ((protval >> 8) & 0xff) << 9;
258   m_nbajam_prot_queue[4] = ((protval >> 0) & 0xff) << 9;
259   m_nbajam_prot_index = 0;
260}
261
262
263
264264/*************************************
265265 *
266266 *  Judge Dredd protection
r242780r242781
313313{
314314   logerror("%08X:jdredd_prot_w(%04X,%04X)\n", space.device().safe_pcbase(), offset*16, data);
315315
316   switch (offset)
317   {
318      case TOWORD(0x10740):
319         m_jdredd_prot_index = 0;
320         m_jdredd_prot_table = jdredd_prot_values_10740;
321         m_jdredd_prot_max = sizeof(jdredd_prot_values_10740);
322         logerror("-- reset prot table 10740\n");
323         break;
324 
325      case TOWORD(0x13240):
326         m_jdredd_prot_index = 0;
327         m_jdredd_prot_table = jdredd_prot_values_13240;
328         m_jdredd_prot_max = sizeof(jdredd_prot_values_13240);
329         logerror("-- reset prot table 13240\n");
330         break;
331 
332      case TOWORD(0x76540):
333         m_jdredd_prot_index = 0;
334         m_jdredd_prot_table = jdredd_prot_values_76540;
335         m_jdredd_prot_max = sizeof(jdredd_prot_values_76540);
336         logerror("-- reset prot table 76540\n");
337         break;
338 
339      case TOWORD(0x77760):
340         m_jdredd_prot_index = 0;
341         m_jdredd_prot_table = jdredd_prot_values_77760;
342         m_jdredd_prot_max = sizeof(jdredd_prot_values_77760);
343         logerror("-- reset prot table 77760\n");
344         break;
345 
346      case TOWORD(0x80020):
347         m_jdredd_prot_index = 0;
348         m_jdredd_prot_table = jdredd_prot_values_80020;
349         m_jdredd_prot_max = sizeof(jdredd_prot_values_80020);
350         logerror("-- reset prot table 80020\n");
351         break;
352   }
316   switch (offset)
317   {
318      case TOWORD(0x10740):
319         m_jdredd_prot_index = 0;
320         m_jdredd_prot_table = jdredd_prot_values_10740;
321         m_jdredd_prot_max = sizeof(jdredd_prot_values_10740);
322         logerror("-- reset prot table 10740\n");
323         break;
324
325      case TOWORD(0x13240):
326         m_jdredd_prot_index = 0;
327         m_jdredd_prot_table = jdredd_prot_values_13240;
328         m_jdredd_prot_max = sizeof(jdredd_prot_values_13240);
329         logerror("-- reset prot table 13240\n");
330         break;
331
332      case TOWORD(0x76540):
333         m_jdredd_prot_index = 0;
334         m_jdredd_prot_table = jdredd_prot_values_76540;
335         m_jdredd_prot_max = sizeof(jdredd_prot_values_76540);
336         logerror("-- reset prot table 76540\n");
337         break;
338
339      case TOWORD(0x77760):
340         m_jdredd_prot_index = 0;
341         m_jdredd_prot_table = jdredd_prot_values_77760;
342         m_jdredd_prot_max = sizeof(jdredd_prot_values_77760);
343         logerror("-- reset prot table 77760\n");
344         break;
345
346      case TOWORD(0x80020):
347         m_jdredd_prot_index = 0;
348         m_jdredd_prot_table = jdredd_prot_values_80020;
349         m_jdredd_prot_max = sizeof(jdredd_prot_values_80020);
350         logerror("-- reset prot table 80020\n");
351         break;
352   }
353353}
354354
355355READ16_MEMBER(midtunit_state::jdredd_prot_r)
356{
357   UINT16 result = 0xffff;
358 
359   if (m_jdredd_prot_table && m_jdredd_prot_index < m_jdredd_prot_max)
360      result = m_jdredd_prot_table[m_jdredd_prot_index++] << 9;
361 
362   logerror("%08X:jdredd_prot_r(%04X) = %04X\n", space.device().safe_pcbase(), offset*16, result);
363   return result;
356{
357   UINT16 result = 0xffff;
358
359   if (m_jdredd_prot_table && m_jdredd_prot_index < m_jdredd_prot_max)
360      result = m_jdredd_prot_table[m_jdredd_prot_index++] << 9;
361
362   logerror("%08X:jdredd_prot_r(%04X) = %04X\n", space.device().safe_pcbase(), offset*16, result);
363   return result;
364364}
365365
366366
r242780r242781
389389void midtunit_state::init_tunit_generic(int sound)
390390{
391391   /* register for state saving */
392   register_state_saving();
393 
394   /* load sound ROMs and set up sound handlers */
395   m_chip_type = sound;
396 
397 
398   /* default graphics functionality */
392   register_state_saving();
393
394   /* load sound ROMs and set up sound handlers */
395   m_chip_type = sound;
396
397
398   /* default graphics functionality */
399399   m_gfx_rom_large = 0;
400400}
401401
r242780r242781
434434{
435435   /* common init */
436436   init_tunit_generic(SOUND_ADPCM_LARGE);
437   /* protection */
438   if (!te_protection)
439   {
440      m_nbajam_prot_table = nbajam_prot_values;
441      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b14020, 0x1b2503f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
442   }
443   else
444   {
445      m_nbajam_prot_table = nbajamte_prot_values;
446      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b15f40, 0x1b37f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
447      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b95f40, 0x1bb7f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
448   }
437   /* protection */
438   if (!te_protection)
439   {
440      m_nbajam_prot_table = nbajam_prot_values;
441      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b14020, 0x1b2503f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
442   }
443   else
444   {
445      m_nbajam_prot_table = nbajamte_prot_values;
446      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b15f40, 0x1b37f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
447      m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1b95f40, 0x1bb7f5f, read16_delegate(FUNC(midtunit_state::nbajam_prot_r),this), write16_delegate(FUNC(midtunit_state::nbajam_prot_w),this));
448   }
449449
450450   /* sound chip protection (hidden RAM) */
451451   if (!te_protection)
r242780r242781
520520 *
521521 *************************************/
522522
523MACHINE_RESET_MEMBER(midtunit_state,midtunit)
524{
525   /* reset sound */
526   switch (m_chip_type)
527   {
528      case SOUND_ADPCM:
529      case SOUND_ADPCM_LARGE:
523MACHINE_RESET_MEMBER(midtunit_state,midtunit)
524{
525   /* reset sound */
526   switch (m_chip_type)
527   {
528      case SOUND_ADPCM:
529      case SOUND_ADPCM_LARGE:
530530         m_adpcm_sound->reset_write(1);
531531         m_adpcm_sound->reset_write(0);
532532         break;
r242780r242781
547547 *************************************/
548548
549549READ16_MEMBER(midtunit_state::midtunit_sound_state_r)
550{
551/*  logerror("%08X:Sound status read\n", space.device().safe_pc());*/
552 
553   if (m_chip_type == SOUND_DCS)
554      return m_dcs->control_r() >> 4;
555 
556   if (m_fake_sound_state)
557   {
558      m_fake_sound_state--;
559      return 0;
560   }
561   return ~0;
550{
551/*  logerror("%08X:Sound status read\n", space.device().safe_pc());*/
552
553   if (m_chip_type == SOUND_DCS)
554      return m_dcs->control_r() >> 4;
555
556   if (m_fake_sound_state)
557   {
558      m_fake_sound_state--;
559      return 0;
560   }
561   return ~0;
562562}
563563
564564READ16_MEMBER(midtunit_state::midtunit_sound_r)
565{
566   logerror("%08X:Sound data read\n", space.device().safe_pc());
567 
568   if (m_chip_type == SOUND_DCS)
569      return m_dcs->data_r() & 0xff;
570 
571   return ~0;
565{
566   logerror("%08X:Sound data read\n", space.device().safe_pc());
567
568   if (m_chip_type == SOUND_DCS)
569      return m_dcs->data_r() & 0xff;
570
571   return ~0;
572572}
573573
574574WRITE16_MEMBER(midtunit_state::midtunit_sound_w)
r242780r242781
579579      logerror("%08X:Unexpected write to sound (lo) = %04X\n", space.device().safe_pc(), data);
580580      return;
581581   }
582 
583   /* call through based on the sound type */
584   if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
585      switch (m_chip_type)
586      {
587         case SOUND_ADPCM:
588         case SOUND_ADPCM_LARGE:
582
583   /* call through based on the sound type */
584   if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
585      switch (m_chip_type)
586      {
587         case SOUND_ADPCM:
588         case SOUND_ADPCM_LARGE:
589589            m_adpcm_sound->reset_write(~data & 0x100);
590            m_adpcm_sound->write(space, offset, data & 0xff);
591 
592            /* the games seem to check for $82 loops, so this should be just barely enough */
593            m_fake_sound_state = 128;
594            break;
595 
596         case SOUND_DCS:
590            m_adpcm_sound->write(space, offset, data & 0xff);
591
592            /* the games seem to check for $82 loops, so this should be just barely enough */
593            m_fake_sound_state = 128;
594            break;
595
596         case SOUND_DCS:
597597            logerror("%08X:Sound write = %04X\n", space.device().safe_pc(), data);
598            m_dcs->reset_w(~data & 0x100);
599            m_dcs->data_w(data & 0xff);
600            /* the games seem to check for $82 loops, so this should be just barely enough */
601            m_fake_sound_state = 128;
602            break;
603      }
604}
598            m_dcs->reset_w(~data & 0x100);
599            m_dcs->data_w(data & 0xff);
600            /* the games seem to check for $82 loops, so this should be just barely enough */
601            m_fake_sound_state = 128;
602            break;
603      }
604}
trunk/src/mame/machine/midwunit.c
r242780r242781
110110/*************************************
111111 *
112112 *  General I/O reads
113 *
114 *************************************/
115 
116IOPORT_ARRAY_MEMBER(midwunit_state::wunit_ports) { "IN0", "IN1", "DSW", "IN2" };
117 
118READ16_MEMBER(midwunit_state::midwunit_io_r)
119{
120   /* apply I/O shuffling */
121   offset = m_ioshuffle[offset % 16];
122 
113 *
114 *************************************/
115
116IOPORT_ARRAY_MEMBER(midwunit_state::wunit_ports) { "IN0", "IN1", "DSW", "IN2" };
117
118READ16_MEMBER(midwunit_state::midwunit_io_r)
119{
120   /* apply I/O shuffling */
121   offset = m_ioshuffle[offset % 16];
122
123123   switch (offset)
124124   {
125125      case 0:
126      case 1:
127      case 2:
128      case 3:
129         return m_ports[offset]->read();
130 
131      case 4:
132         return (m_midway_serial_pic->status_r(space,0) << 12) | midwunit_sound_state_r(space,0,0xffff);
126      case 1:
127      case 2:
128      case 3:
129         return m_ports[offset]->read();
133130
131      case 4:
132         return (m_midway_serial_pic->status_r(space,0) << 12) | midwunit_sound_state_r(space,0,0xffff);
133
134134      default:
135135         logerror("%08X:Unknown I/O read from %d\n", space.device().safe_pc(), offset);
136136         break;
trunk/src/mame/machine/midyunit.c
r242780r242781
107107/*************************************
108108 *
109109 *  Generic input ports
110 *
111 *************************************/
112 
113IOPORT_ARRAY_MEMBER(midyunit_state::ports) { "IN0", "IN1", "IN2", "DSW", "UNK0", "UNK1" };
114 
115READ16_MEMBER(midyunit_state::midyunit_input_r)
116{
117   return m_ports[offset]->read();
118}
119 
120 
110 *
111 *************************************/
121112
113IOPORT_ARRAY_MEMBER(midyunit_state::ports) { "IN0", "IN1", "IN2", "DSW", "UNK0", "UNK1" };
114
115READ16_MEMBER(midyunit_state::midyunit_input_r)
116{
117   return m_ports[offset]->read();
118}
119
120
121
122122/*************************************
123123 *
124124 *  Special Terminator 2 input ports
125125 *
126126 *************************************/
127 
128READ16_MEMBER(midyunit_state::term2_input_r)
129{
130   if (offset != 2)
131      return m_ports[offset]->read();
132 
133   switch (m_term2_analog_select)
134   {
127
128READ16_MEMBER(midyunit_state::term2_input_r)
129{
130   if (offset != 2)
131      return m_ports[offset]->read();
132
133   switch (m_term2_analog_select)
134   {
135135      default:
136136      case 0:  return ioport("STICK0_X")->read();
137137      case 1:  return ioport("STICK0_Y")->read();
r242780r242781
497497
498498   /* special inputs */
499499   m_maincpu->space(AS_PROGRAM).install_read_handler(0x01c00000, 0x01c0005f, read16_delegate(FUNC(midyunit_state::term2_input_r), this));
500   m_maincpu->space(AS_PROGRAM).install_write_handler(0x01e00000, 0x01e0001f, write16_delegate(FUNC(midyunit_state::term2_sound_w), this));
501 
502   /* HACK: this prevents the freeze on the movies */
503   /* until we figure what's causing it, this is better than nothing */
504   m_t2_hack_mem = m_maincpu->space(AS_PROGRAM).install_write_handler(0x010aa0e0, 0x010aa0ff, hack_w);
505}
506 
500   m_maincpu->space(AS_PROGRAM).install_write_handler(0x01e00000, 0x01e0001f, write16_delegate(FUNC(midyunit_state::term2_sound_w), this));
501
502   /* HACK: this prevents the freeze on the movies */
503   /* until we figure what's causing it, this is better than nothing */
504   m_t2_hack_mem = m_maincpu->space(AS_PROGRAM).install_write_handler(0x010aa0e0, 0x010aa0ff, hack_w);
505}
506
507507DRIVER_INIT_MEMBER(midyunit_state,term2)    { term2_init_common(write16_delegate(FUNC(midyunit_state::term2_hack_w),this)); }
508508DRIVER_INIT_MEMBER(midyunit_state,term2la3) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2la3_hack_w),this)); }
509509DRIVER_INIT_MEMBER(midyunit_state,term2la2) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2la2_hack_w),this)); }


Previous 199869 Revisions Next


© 1997-2024 The MAME Team