Previous 199869 Revisions Next

r34267 Thursday 8th January, 2015 at 17:41:40 UTC by Osso
midtunit.c, midwunit.c, midyunit.c: reduced tagmap lookups (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
r242778r242779
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_nvram(*this, "nvram"),
21         m_gfxrom(*this, "gfxrom"),
22         m_cvsd_sound(*this, "cvsd"),
23         m_adpcm_sound(*this, "adpcm") ,
24      m_maincpu(*this, "maincpu"),
25      m_palette(*this, "palette"),
26      m_dcs(*this, "dcs"),
27      m_generic_paletteram_16(*this, "paletteram") { }
28
29   required_shared_ptr<UINT16> m_nvram;
30   required_memory_region m_gfxrom;
31   optional_device<williams_cvsd_sound_device> m_cvsd_sound;
32   optional_device<williams_adpcm_sound_device> m_adpcm_sound;
33
34   DECLARE_WRITE16_MEMBER(midtunit_cmos_enable_w);
35   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);
3646   DECLARE_READ16_MEMBER(midtunit_cmos_r);
3747   DECLARE_READ16_MEMBER(midtunit_input_r);
3848   DECLARE_READ16_MEMBER(midtunit_sound_state_r);
r242778r242779
6373   DECLARE_READ16_MEMBER(midwunit_control_r);
6474   DECLARE_WRITE16_MEMBER(midtunit_paletteram_w);
6575   DECLARE_WRITE16_MEMBER(midxunit_paletteram_w);
66   DECLARE_READ16_MEMBER(midxunit_paletteram_r);
67   DECLARE_READ16_MEMBER(midtunit_dma_r);
68   DECLARE_WRITE16_MEMBER(midtunit_dma_w);
69   TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg);
70   TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg);
71   TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_update);
72   DECLARE_DRIVER_INIT(mktunit);
73   DECLARE_DRIVER_INIT(mkturbo);
74   DECLARE_DRIVER_INIT(nbajamte);
75   DECLARE_DRIVER_INIT(nbajam);
76   DECLARE_DRIVER_INIT(jdreddp);
77   DECLARE_DRIVER_INIT(mk2);
78   DECLARE_MACHINE_RESET(midtunit);
79   DECLARE_VIDEO_START(midtunit);
80   required_device<cpu_device> m_maincpu;
81   required_device<palette_device> m_palette;
82   optional_device<dcs_audio_device> m_dcs;
83   required_shared_ptr<UINT16> m_generic_paletteram_16;
84
85   void register_state_saving();
86   void init_tunit_generic(int sound);
87   void init_nbajam_common(int te_protection);
88
89   /* CMOS-related variables */
90   UINT8    cmos_write_enable;
91
92   /* sound-related variables */
93   UINT8    chip_type;
94   UINT8    fake_sound_state;
95
96   /* protection */
97   UINT8    mk_prot_index;
98   UINT16   mk2_prot_data;
99
100   const UINT32 *nbajam_prot_table;
101   UINT16   nbajam_prot_queue[5];
102   UINT8    nbajam_prot_index;
103
104   const UINT8 *jdredd_prot_table;
105   UINT8    jdredd_prot_index;
106   UINT8    jdredd_prot_max;
107
108   UINT8 m_gfx_rom_large;
109
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 
110119protected:
111120   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
112121};
trunk/src/mame/includes/midwunit.h
r242778r242779
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_nvram(*this, "nvram"),
17         m_midway_serial_pic(*this, "serial_pic") { }
18
19   required_shared_ptr<UINT16> m_nvram;
20   required_device<midway_serial_pic_device> m_midway_serial_pic;
21   UINT8 m_cmos_write_enable;
22   UINT16 m_iodata[8];
23   UINT8 m_ioshuffle[16];
24   UINT8 m_uart[8];
25   UINT8 m_security_bits;
26   UINT16 *m_umk3_palette;
27   DECLARE_WRITE16_MEMBER(midwunit_cmos_enable_w);
28   DECLARE_WRITE16_MEMBER(midwunit_cmos_w);
29   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);
3037   DECLARE_WRITE16_MEMBER(midwunit_io_w);
3138   DECLARE_READ16_MEMBER(midwunit_io_r);
3239   DECLARE_READ16_MEMBER(midwunit_security_r);
3340   DECLARE_WRITE16_MEMBER(midwunit_security_w);
3441   DECLARE_READ16_MEMBER(midwunit_sound_r);
3542   DECLARE_READ16_MEMBER(midwunit_sound_state_r);
36   DECLARE_WRITE16_MEMBER(midwunit_sound_w);
37   DECLARE_WRITE16_MEMBER(umk3_palette_hack_w);
38   DECLARE_WRITE16_MEMBER(wwfmania_io_0_w);
39   DECLARE_DRIVER_INIT(mk3r10);
40   DECLARE_DRIVER_INIT(nbahangt);
41   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);
4250   DECLARE_DRIVER_INIT(umk3);
4351   DECLARE_DRIVER_INIT(mk3);
4452   DECLARE_DRIVER_INIT(openice);
45   DECLARE_DRIVER_INIT(rmpgwt);
46   DECLARE_DRIVER_INIT(umk3r11);
47   DECLARE_DRIVER_INIT(mk3r20);
48   DECLARE_MACHINE_RESET(midwunit);
49   DECLARE_VIDEO_START(midwunit);
50   void register_state_saving();
51   void init_wunit_generic();
52   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();
5363};
trunk/src/mame/includes/midyunit.h
r242778r242779
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
53   required_device<cpu_device> m_maincpu;
54   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;
5556   optional_device<okim6295_device> m_oki;
5657   required_device<palette_device> m_palette;
5758   optional_device<williams_narc_sound_device> m_narc_sound;
5859   optional_device<williams_cvsd_sound_device> m_cvsd_sound;
5960   optional_device<williams_adpcm_sound_device> m_adpcm_sound;
60
61   required_shared_ptr<UINT16> m_generic_paletteram_16;
62   optional_shared_ptr<UINT8> m_gfx_rom;
63
64   UINT16 *m_cmos_ram;
65   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;
6671   UINT16 m_prot_result;
6772   UINT16 m_prot_sequence[3];
6873   UINT8 m_prot_index;
trunk/src/mame/machine/midtunit.c
r242778r242779
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 
2842
29void midtunit_state::register_state_saving()
30{
31   save_item(NAME(cmos_write_enable));
32   save_item(NAME(fake_sound_state));
33   save_item(NAME(mk_prot_index));
34   save_item(NAME(mk2_prot_data));
35   save_item(NAME(nbajam_prot_queue));
36   save_item(NAME(nbajam_prot_index));
37   save_item(NAME(jdredd_prot_index));
38   save_item(NAME(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   cmos_write_enable = 1;
52}
53
54
55WRITE16_MEMBER(midtunit_state::midtunit_cmos_w)
56{
57   if (1)/*cmos_write_enable)*/
58   {
59      COMBINE_DATA(m_nvram+offset);
60      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   }
r242778r242779
7676
7777/*************************************
7878 *
79 *  Generic input ports
80 *
81 *************************************/
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 
8291
83READ16_MEMBER(midtunit_state::midtunit_input_r)
84{
85   static const char *const portnames[] = { "IN0", "IN1", "IN2", "DSW" };
86
87   return ioport(portnames[offset])->read();
88}
89
90
91
9292/*************************************
9393 *
9494 *  Mortal Kombat (T-unit) protection
r242778r242779
106106   0x16, 0x2d, 0x1a, 0x34, 0x28, 0x10, 0x21, 0x03,
107107   0xff
108108};
109
110READ16_MEMBER(midtunit_state::mk_prot_r)
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)
111125{
112   logerror("%08X:Protection R @ %05X = %04X\n", space.device().safe_pc(), offset, mk_prot_values[mk_prot_index] << 9);
113
114   /* just in case */
115   if (mk_prot_index >= sizeof(mk_prot_values))
116   {
117      logerror("%08X:Unexpected protection R @ %05X\n", space.device().safe_pc(), offset);
118      mk_prot_index = 0;
119   }
120
121   return mk_prot_values[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            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         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
r242778r242779
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 
177194
178READ16_MEMBER(midtunit_state::mk2_prot_r)
179{
180   return mk2_prot_data;
181}
182
183READ16_MEMBER(midtunit_state::mk2_prot_shift_r)
184{
185   return mk2_prot_data >> 1;
186}
187
188WRITE16_MEMBER(midtunit_state::mk2_prot_w)
189{
190   COMBINE_DATA(&mk2_prot_data);
191}
192
193
194
195195/*************************************
196196 *
197197 *  NBA Jam protection
r242778r242779
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 
240263
241READ16_MEMBER(midtunit_state::nbajam_prot_r)
242{
243   int result = nbajam_prot_queue[nbajam_prot_index];
244   if (nbajam_prot_index < 4)
245      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 = nbajam_prot_table[table_index];
253
254   nbajam_prot_queue[0] = data;
255   nbajam_prot_queue[1] = ((protval >> 24) & 0xff) << 9;
256   nbajam_prot_queue[2] = ((protval >> 16) & 0xff) << 9;
257   nbajam_prot_queue[3] = ((protval >> 8) & 0xff) << 9;
258   nbajam_prot_queue[4] = ((protval >> 0) & 0xff) << 9;
259   nbajam_prot_index = 0;
260}
261
262
263
264264/*************************************
265265 *
266266 *  Judge Dredd protection
r242778r242779
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         jdredd_prot_index = 0;
320         jdredd_prot_table = jdredd_prot_values_10740;
321         jdredd_prot_max = sizeof(jdredd_prot_values_10740);
322         logerror("-- reset prot table 10740\n");
323         break;
324
325      case TOWORD(0x13240):
326         jdredd_prot_index = 0;
327         jdredd_prot_table = jdredd_prot_values_13240;
328         jdredd_prot_max = sizeof(jdredd_prot_values_13240);
329         logerror("-- reset prot table 13240\n");
330         break;
331
332      case TOWORD(0x76540):
333         jdredd_prot_index = 0;
334         jdredd_prot_table = jdredd_prot_values_76540;
335         jdredd_prot_max = sizeof(jdredd_prot_values_76540);
336         logerror("-- reset prot table 76540\n");
337         break;
338
339      case TOWORD(0x77760):
340         jdredd_prot_index = 0;
341         jdredd_prot_table = jdredd_prot_values_77760;
342         jdredd_prot_max = sizeof(jdredd_prot_values_77760);
343         logerror("-- reset prot table 77760\n");
344         break;
345
346      case TOWORD(0x80020):
347         jdredd_prot_index = 0;
348         jdredd_prot_table = jdredd_prot_values_80020;
349         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 (jdredd_prot_table && jdredd_prot_index < jdredd_prot_max)
360      result = jdredd_prot_table[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
r242778r242779
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   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
r242778r242779
434434{
435435   /* common init */
436436   init_tunit_generic(SOUND_ADPCM_LARGE);
437   /* protection */
438   if (!te_protection)
439   {
440      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      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)
r242778r242779
520520 *
521521 *************************************/
522522
523MACHINE_RESET_MEMBER(midtunit_state,midtunit)
524{
525   /* reset sound */
526   switch (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;
r242778r242779
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 (chip_type == SOUND_DCS)
554      return m_dcs->control_r() >> 4;
555
556   if (fake_sound_state)
557   {
558      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 (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)
r242778r242779
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 (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            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            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
r242778r242779
110110/*************************************
111111 *
112112 *  General I/O reads
113 *
114 *************************************/
115
116READ16_MEMBER(midwunit_state::midwunit_io_r)
117{
118   static const char *const portnames[] = { "IN0", "IN1", "DSW", "IN2" };
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 ioport(portnames[offset])->read();
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);
130133
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
r242778r242779
107107/*************************************
108108 *
109109 *  Generic input ports
110 *
111 *************************************/
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 
112121
113READ16_MEMBER(midyunit_state::midyunit_input_r)
114{
115   static const char *const portnames[] = { "IN0", "IN1", "IN2", "DSW", "UNK0", "UNK1" };
116
117   return ioport(portnames[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   static const char *const portnames[] = { "IN0", "IN1", NULL, "DSW", "UNK0", "UNK1" };
131
132   if (offset != 2)
133      return ioport(portnames[offset])->read();
134
135   switch (m_term2_analog_select)
136   {
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   {
137135      default:
138136      case 0:  return ioport("STICK0_X")->read();
139137      case 1:  return ioport("STICK0_Y")->read();
r242778r242779
499497
500498   /* special inputs */
501499   m_maincpu->space(AS_PROGRAM).install_read_handler(0x01c00000, 0x01c0005f, read16_delegate(FUNC(midyunit_state::term2_input_r), this));
502   m_maincpu->space(AS_PROGRAM).install_write_handler(0x01e00000, 0x01e0001f, write16_delegate(FUNC(midyunit_state::term2_sound_w), this));
503
504   /* HACK: this prevents the freeze on the movies */
505   /* until we figure whats causing it, this is better than nothing */
506   m_t2_hack_mem = m_maincpu->space(AS_PROGRAM).install_write_handler(0x010aa0e0, 0x010aa0ff, hack_w);
507}
508
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 
509507DRIVER_INIT_MEMBER(midyunit_state,term2)    { term2_init_common(write16_delegate(FUNC(midyunit_state::term2_hack_w),this)); }
510508DRIVER_INIT_MEMBER(midyunit_state,term2la3) { term2_init_common(write16_delegate(FUNC(midyunit_state::term2la3_hack_w),this)); }
511509DRIVER_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