Previous 15994 Revisions Next

r5358 Thursday 6th August, 2009 at 11:02:08 UTC by Fabio Priuli
More NES work: [Robert Bohms]
* Fixes bug in nes_apu that caused errors reading $4015
* Adds length counter status bits to $4015
* Fixes 4-screen mirroring (PPU regression)
* MMC5 emulation improved (ExRAM/Fill register support)
* Added: mapper 164 (preliminary), 207 (working, split from mapper 80)

Also, sync'd MAME files
[src/emu/sound]nes_apu.c nes_defs.h
[src/mame/drivers]cham24.c
[src/mame/video]ppu2c0x.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_mmc.c

src/mame/video/ppu2c0x.c
r5357r5358
1919
2020    * Micro Machines has minor rendering glitches (needs better timing).
2121    * Mach Rider has minor road rendering glitches (needs better timing).
22    * Rad Racer demonstrates road glitches: it changes horizontal scrolling mid-line.
2223
2324******************************************************************************/
2425
r5357r5358
380381
381382   const pen_t *color_table;
382383   const pen_t *paldata;
383   // const UINT8 *sd;
384384
385385   int tilecount = 0;
386386
r5357r5358
447447
448448      if (start_x < VISIBLE_SCREEN_WIDTH)
449449      {
450         UINT8 plane1, plane2;   // use extended size so I can shift!
450         UINT8 plane1, plane2;
451451         paldata = &color_table[4 * (((color_byte >> color_bits) & 0x03))];
452         // start = scroll_y_fine * line_modulo;
453452
454453         // need to read 0x0000 or 0x1000 + 16*nametable data
455454         address = ((this_ppu->tile_page) ? 0x1000 : 0) + (page2 * 16);
456455         // plus something that accounts for y
457         // address -= (scanline % 8);
458456         address += scroll_y_fine;
459457
460458         plane1 = memory_read_byte(device->space[0], (address & 0x1fff));
461459         plane2 = memory_read_byte(device->space[0], (address + 8) & 0x1fff);
462         // plane2 = plane2 << 1;
463460
464461         /* render the pixel */
465462         for (i = 0; i < 8; i++)
r5357r5358
618615      plane1 = memory_read_byte(device->space[0], (index1 + sprite_line) & 0x1fff);
619616      plane2 = memory_read_byte(device->space[0], (index1 + sprite_line + 8) & 0x1fff);
620617
621//      sd = gfx_element_get_data(device->machine->gfx[gfx_bank], index1 % total_elements) + start;
622//      if (size > 8)
623//          gfx_element_get_data(device->machine->gfx[gfx_bank], (index1 + 1) % total_elements);
624
625618      if (pri)
626619      {
627620         /* draw the low-priority sprites */
628621         for (pixel = 0; pixel < 8; pixel++)
629622         {
630//              UINT8 pixelData = flipx ? sd[7-pixel] : sd[pixel];
631623            UINT8 pixelData;
632624            if (flipx)
633625            {
634626               pixelData = (plane1 & 1) + ((plane2 & 1) << 1);
635627               plane1 = plane1 >> 1;
636628               plane2 = plane2 >> 1;
637               // sd[7 - pixel]
638629            }
639630            else
640631            {
641632               pixelData = ((plane1 >> 7) & 1) | (((plane2 >> 7) & 1) << 1);
642633               plane1 = plane1 << 1;
643634               plane2 = plane2 << 1;
644               // sd[pixel];
645635            }
646636
647637            /* is this pixel non-transparent? */
r5357r5358
10371027{
10381028   ppu2c0x_chip *this_ppu = get_token(space->cpu);
10391029   {
1040      // it's a palette
1041      // ERROR: doesn't currently handle monochrome!
10421030      if (this_ppu->regs[PPU_CONTROL1] & PPU_CONTROL1_DISPLAY_MONO)
10431031         return (this_ppu->palette_ram[offset & 0x1f] & 0x30);
1044      else return (this_ppu->palette_ram[offset & 0x1f] & 0x3f);
1032
1033      else
1034         return (this_ppu->palette_ram[offset & 0x1f] & 0x3f);
10451035   }
10461036}
10471037
r5357r5358
12421232            {
12431233               /* store the data */
12441234               memory_write_byte(device->space[0], tempAddr, data);
1245
1246               /* mark the char dirty */
1247               // gfx_element_mark_dirty(device->machine->gfx[intf->gfx_layout_number], tempAddr >> 4);
12481235            }
12491236
12501237            else
r5357r5358
12731260   int i;
12741261   int address = page << 8;
12751262
1276//  logerror("sprite DMA: %d (scanline: %d)\n", page, this_ppu->scanline);
12771263   for (i = 0; i < SPRITERAM_SIZE; i++)
12781264   {
12791265      UINT8 spriteData = memory_read_byte(space, address + i);
12801266      memory_write_byte(space, 0x2004, spriteData);
1281//      ppu2c0x_w(device, PPU_SPRITE_DATA, spriteData);
12821267   }
12831268
12841269   // should last 513 CPU cycles.
12851270   cpu_adjust_icount(space->cpu, -513);
1286
1287   // ????TODO : need to account for PPU rendering - this is roughly 4.5 scanlines eaten up.
1288   // Because the DMA is only useful during vblank, this may not be strictly necessary since
1289   // the scanline timers should catch us up before drawing actually happens.
1290#if 0
1291{
1292   scanline_callback(device);
1293   scanline_callback(device);
1294   scanline_callback(device);
1295   scanline_callback(device);
12961271}
1297#endif
1298}
12991272
13001273/*************************************
13011274 *
src/mame/drivers/cham24.c
r5357r5358
244244
245245static MACHINE_RESET( cham24 )
246246{
247   /* switch PRG rom */
248   UINT8* dst = memory_region(machine, "maincpu");
249   UINT8* src = memory_region(machine, "user1");
250
251   memcpy(&dst[0x8000], &src[0x0f8000], 0x4000);
252   memcpy(&dst[0xc000], &src[0x0f8000], 0x4000);
253247}
254248
255249static PALETTE_INIT( cham24 )
r5357r5358
282276   return 0;
283277}
284278
285static DRIVER_INIT( cham24 )
279
280static MACHINE_START( cham24 )
286281{
282   /* switch PRG rom */
283   UINT8* dst = memory_region(machine, "maincpu");
284   UINT8* src = memory_region(machine, "user1");
285
286   memcpy(&dst[0x8000], &src[0x0f8000], 0x4000);
287   memcpy(&dst[0xc000], &src[0x0f8000], 0x4000);
288
287289   /* uses 8K swapping, all ROM!*/
288290   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x0000, 0x1fff, 0, 0, SMH_BANK(1), 0);
289291   memory_set_bankptr(machine, 1, memory_region(machine, "gfx1"));
r5357r5358
299301   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, nt_r, nt_w);
300302}
301303
304static DRIVER_INIT( cham24 )
305{
306}
307
302308static GFXDECODE_START( cham24 )
303309   /* none, the ppu generates one */
304310GFXDECODE_END
r5357r5358
309315   MDRV_CPU_PROGRAM_MAP(cham24_map)
310316
311317   MDRV_MACHINE_RESET( cham24 )
318   MDRV_MACHINE_START( cham24 )
312319
313320   /* video hardware */
314321   MDRV_SCREEN_ADD("screen", RASTER)
src/emu/sound/nes_defs.h
r5357r5358
5050
5151typedef struct queue_s
5252{
53  int pos;
54  unsigned char reg,val;
53   int pos;
54   unsigned char reg,val;
5555} queue_t;
5656
5757#endif
r5357r5358
8686/* Square Wave */
8787typedef struct square_s
8888{
89   uint8 regs[4];
90   int vbl_length;
91   int freq;
92   float phaseacc;
93   float output_vol;
94   float env_phase;
95   float sweep_phase;
96   uint8 adder;
97   uint8 env_vol;
98   boolean enabled;
89   uint8 regs[4];
90   int vbl_length;
91   int freq;
92   float phaseacc;
93   float output_vol;
94   float env_phase;
95   float sweep_phase;
96   uint8 adder;
97   uint8 env_vol;
98   boolean enabled;
9999} square_t;
100100
101101/* Triangle Wave */
102102typedef struct triangle_s
103103{
104   uint8 regs[4]; /* regs[1] unused */
105   int linear_length;
106   int vbl_length;
107   int write_latency;
108   float phaseacc;
109   float output_vol;
110   uint8 adder;
111   boolean counter_started;
112   boolean enabled;
104   uint8 regs[4]; /* regs[1] unused */
105   int linear_length;
106   int vbl_length;
107   int write_latency;
108   float phaseacc;
109   float output_vol;
110   uint8 adder;
111   boolean counter_started;
112   boolean enabled;
113113} triangle_t;
114114
115115/* Noise Wave */
116116typedef struct noise_s
117117{
118   uint8 regs[4]; /* regs[1] unused */
119   int cur_pos;
120   int vbl_length;
121   float phaseacc;
122   float output_vol;
123   float env_phase;
124   uint8 env_vol;
125   boolean enabled;
118   uint8 regs[4]; /* regs[1] unused */
119   int cur_pos;
120   int vbl_length;
121   float phaseacc;
122   float output_vol;
123   float env_phase;
124   uint8 env_vol;
125   boolean enabled;
126126} noise_t;
127127
128128/* DPCM Wave */
129129typedef struct dpcm_s
130130{
131   uint8 regs[4];
132   uint32 address;
133   uint32 length;
134   int bits_left;
135   float phaseacc;
136   float output_vol;
137   uint8 cur_byte;
138   boolean enabled;
139   boolean irq_occurred;
140   const address_space *memory;
141   signed char vol;
131   uint8 regs[4];
132   uint32 address;
133   uint32 length;
134   int bits_left;
135   float phaseacc;
136   float output_vol;
137   uint8 cur_byte;
138   boolean enabled;
139   boolean irq_occurred;
140   const address_space *memory;
141   signed char vol;
142142} dpcm_t;
143143
144144/* APU type */
145145typedef struct apu
146146{
147   /* Sound channels */
148   square_t   squ[2];
149   triangle_t tri;
150   noise_t    noi;
151   dpcm_t     dpcm;
147   /* Sound channels */
148   square_t   squ[2];
149   triangle_t tri;
150   noise_t    noi;
151   dpcm_t     dpcm;
152152
153   /* APU registers */
154   unsigned char regs[0x17];
153   /* APU registers */
154   unsigned char regs[0x17];
155155
156   /* Sound pointers */
157   void *buffer;
156   /* Sound pointers */
157   void *buffer;
158158
159159#ifdef USE_QUEUE
160160
161   /* Event queue */
162   queue_t queue[QUEUE_SIZE];
163   int head,tail;
161   /* Event queue */
162   queue_t queue[QUEUE_SIZE];
163   int head, tail;
164164
165165#else
166166
167   int buf_pos;
167   int buf_pos;
168168
169169#endif
170170
171   int step_mode;
171172} apu_t;
172173
173174/* CONSTANTS */
src/emu/sound/nes_apu.c
r5357r5358
8888/* INITIALIZE WAVE TIMES RELATIVE TO SAMPLE RATE */
8989static void create_vbltimes(uint32 * table,const uint8 *vbl,unsigned int rate)
9090{
91  int i;
91   int i;
9292
93  for (i=0;i<0x20;i++)
94    table[i]=vbl[i]*rate;
93   for (i = 0; i < 0x20; i++)
94      table[i] = vbl[i] * rate;
9595}
9696
9797/* INITIALIZE SAMPLE TIMES IN TERMS OF VSYNCS */
9898static void create_syncs(nesapu_state *info, unsigned long sps)
9999{
100  int i;
101  unsigned long val=sps;
100   int i;
101   unsigned long val = sps;
102102
103  for (i=0;i<SYNCS_MAX1;i++)
104  {
105    info->sync_times1[i]=val;
106    val+=sps;
107  }
103   for (i = 0; i < SYNCS_MAX1; i++)
104   {
105      info->sync_times1[i] = val;
106      val += sps;
107   }
108108
109  val=0;
110  for (i=0;i<SYNCS_MAX2;i++)
111  {
112    info->sync_times2[i]=val;
113    info->sync_times2[i]>>=2;
114    val+=sps;
115  }
109   val = 0;
110   for (i = 0; i < SYNCS_MAX2; i++)
111   {
112      info->sync_times2[i] = val;
113      info->sync_times2[i] >>= 2;
114      val += sps;
115   }
116116}
117117
118118/* INITIALIZE NOISE LOOKUP TABLE */
119119static void create_noise(uint8 *buf, const int bits, int size)
120120{
121   static int m = 0x0011;
122   int xor_val, i;
121   static int m = 0x0011;
122   int xor_val, i;
123123
124   for (i = 0; i < size; i++)
125   {
126      xor_val = m & 1;
127      m >>= 1;
128      xor_val ^= (m & 1);
129      m |= xor_val << (bits - 1);
124   for (i = 0; i < size; i++)
125   {
126      xor_val = m & 1;
127      m >>= 1;
128      xor_val ^= (m & 1);
129      m |= xor_val << (bits - 1);
130130
131      buf[i] = m;
132   }
131      buf[i] = m;
132   }
133133}
134134
135135/* TODO: sound channels should *ALL* have DC volume decay */
r5357r5358
137137/* OUTPUT SQUARE WAVE SAMPLE (VALUES FROM -16 to +15) */
138138static int8 apu_square(nesapu_state *info, square_t *chan)
139139{
140   int env_delay;
141   int sweep_delay;
142   int8 output;
140   int env_delay;
141   int sweep_delay;
142   int8 output;
143143
144   /* reg0: 0-3=volume, 4=envelope, 5=hold, 6-7=duty cycle
145   ** reg1: 0-2=sweep shifts, 3=sweep inc/dec, 4-6=sweep length, 7=sweep on
146   ** reg2: 8 bits of freq
147   ** reg3: 0-2=high freq, 7-4=vbl length counter
148   */
144   /* reg0: 0-3=volume, 4=envelope, 5=hold, 6-7=duty cycle
145   ** reg1: 0-2=sweep shifts, 3=sweep inc/dec, 4-6=sweep length, 7=sweep on
146   ** reg2: 8 bits of freq
147   ** reg3: 0-2=high freq, 7-4=vbl length counter
148   */
149149
150   if (FALSE == chan->enabled)
151      return 0;
150   if (FALSE == chan->enabled)
151      return 0;
152152
153   /* enveloping */
154   env_delay = info->sync_times1[chan->regs[0] & 0x0F];
153   /* enveloping */
154   env_delay = info->sync_times1[chan->regs[0] & 0x0F];
155155
156   /* decay is at a rate of (env_regs + 1) / 240 secs */
157   chan->env_phase -= 4;
158   while (chan->env_phase < 0)
159   {
160      chan->env_phase += env_delay;
161      if (chan->regs[0] & 0x20)
162         chan->env_vol = (chan->env_vol + 1) & 15;
163      else if (chan->env_vol < 15)
164         chan->env_vol++;
165   }
156   /* decay is at a rate of (env_regs + 1) / 240 secs */
157   chan->env_phase -= 4;
158   while (chan->env_phase < 0)
159   {
160      chan->env_phase += env_delay;
161      if (chan->regs[0] & 0x20)
162         chan->env_vol = (chan->env_vol + 1) & 15;
163      else if (chan->env_vol < 15)
164         chan->env_vol++;
165   }
166166
167   /* vbl length counter */
168   if (chan->vbl_length > 0 && 0 == (chan->regs [0] & 0x20))
169      chan->vbl_length--;
167   /* vbl length counter */
168   if (chan->vbl_length > 0 && 0 == (chan->regs [0] & 0x20))
169      chan->vbl_length--;
170170
171   if (0 == chan->vbl_length)
172      return 0;
171   if (0 == chan->vbl_length)
172      return 0;
173173
174   /* freqsweeps */
175   if ((chan->regs[1] & 0x80) && (chan->regs[1] & 7))
176   {
177      sweep_delay = info->sync_times1[(chan->regs[1] >> 4) & 7];
178      chan->sweep_phase -= 2;
179      while (chan->sweep_phase < 0)
180      {
181         chan->sweep_phase += sweep_delay;
182         if (chan->regs[1] & 8)
183            chan->freq -= chan->freq >> (chan->regs[1] & 7);
184         else
185            chan->freq += chan->freq >> (chan->regs[1] & 7);
186      }
187   }
174   /* freqsweeps */
175   if ((chan->regs[1] & 0x80) && (chan->regs[1] & 7))
176   {
177      sweep_delay = info->sync_times1[(chan->regs[1] >> 4) & 7];
178      chan->sweep_phase -= 2;
179      while (chan->sweep_phase < 0)
180      {
181         chan->sweep_phase += sweep_delay;
182         if (chan->regs[1] & 8)
183            chan->freq -= chan->freq >> (chan->regs[1] & 7);
184         else
185            chan->freq += chan->freq >> (chan->regs[1] & 7);
186      }
187   }
188188
189   if ((0 == (chan->regs[1] & 8) && (chan->freq >> 16) > freq_limit[chan->regs[1] & 7])
190       || (chan->freq >> 16) < 4)
191      return 0;
189   if ((0 == (chan->regs[1] & 8) && (chan->freq >> 16) > freq_limit[chan->regs[1] & 7])
190       || (chan->freq >> 16) < 4)
191      return 0;
192192
193   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
193   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
194194
195   while (chan->phaseacc < 0)
196   {
197      chan->phaseacc += (chan->freq >> 16);
198      chan->adder = (chan->adder + 1) & 0x0F;
199   }
195   while (chan->phaseacc < 0)
196   {
197      chan->phaseacc += (chan->freq >> 16);
198      chan->adder = (chan->adder + 1) & 0x0F;
199   }
200200
201   if (chan->regs[0] & 0x10) /* fixed volume */
202      output = chan->regs[0] & 0x0F;
203   else
204      output = 0x0F - chan->env_vol;
201   if (chan->regs[0] & 0x10) /* fixed volume */
202      output = chan->regs[0] & 0x0F;
203   else
204      output = 0x0F - chan->env_vol;
205205
206   if (chan->adder < (duty_lut[chan->regs[0] >> 6]))
207      output = -output;
206   if (chan->adder < (duty_lut[chan->regs[0] >> 6]))
207      output = -output;
208208
209   return (int8) output;
209   return (int8) output;
210210}
211211
212212/* OUTPUT TRIANGLE WAVE SAMPLE (VALUES FROM -16 to +15) */
213213static int8 apu_triangle(nesapu_state *info, triangle_t *chan)
214214{
215   int freq;
216   int8 output;
217   /* reg0: 7=holdnote, 6-0=linear length counter
218   ** reg2: low 8 bits of frequency
219   ** reg3: 7-3=length counter, 2-0=high 3 bits of frequency
220   */
215   int freq;
216   int8 output;
217   /* reg0: 7=holdnote, 6-0=linear length counter
218   ** reg2: low 8 bits of frequency
219   ** reg3: 7-3=length counter, 2-0=high 3 bits of frequency
220   */
221221
222   if (FALSE == chan->enabled)
223      return 0;
222   if (FALSE == chan->enabled)
223      return 0;
224224
225   if (FALSE == chan->counter_started && 0 == (chan->regs[0] & 0x80))
226   {
227      if (chan->write_latency)
228         chan->write_latency--;
229      if (0 == chan->write_latency)
230         chan->counter_started = TRUE;
231   }
225   if (FALSE == chan->counter_started && 0 == (chan->regs[0] & 0x80))
226   {
227      if (chan->write_latency)
228         chan->write_latency--;
229      if (0 == chan->write_latency)
230         chan->counter_started = TRUE;
231   }
232232
233   if (chan->counter_started)
234   {
235      if (chan->linear_length > 0)
236         chan->linear_length--;
237      if (chan->vbl_length && 0 == (chan->regs[0] & 0x80))
238            chan->vbl_length--;
233   if (chan->counter_started)
234   {
235      if (chan->linear_length > 0)
236         chan->linear_length--;
237      if (chan->vbl_length && 0 == (chan->regs[0] & 0x80))
238            chan->vbl_length--;
239239
240      if (0 == chan->vbl_length)
241         return 0;
242   }
240      if (0 == chan->vbl_length)
241         return 0;
242   }
243243
244   if (0 == chan->linear_length)
245      return 0;
244   if (0 == chan->linear_length)
245      return 0;
246246
247   freq = (((chan->regs[3] & 7) << 8) + chan->regs[2]) + 1;
247   freq = (((chan->regs[3] & 7) << 8) + chan->regs[2]) + 1;
248248
249   if (freq < 4) /* inaudible */
250      return 0;
249   if (freq < 4) /* inaudible */
250      return 0;
251251
252   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
253   while (chan->phaseacc < 0)
254   {
255      chan->phaseacc += freq;
256      chan->adder = (chan->adder + 1) & 0x1F;
252   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
253   while (chan->phaseacc < 0)
254   {
255      chan->phaseacc += freq;
256      chan->adder = (chan->adder + 1) & 0x1F;
257257
258      output = (chan->adder & 7) << 1;
259      if (chan->adder & 8)
260         output = 0x10 - output;
261      if (chan->adder & 0x10)
262         output = -output;
258      output = (chan->adder & 7) << 1;
259      if (chan->adder & 8)
260         output = 0x10 - output;
261      if (chan->adder & 0x10)
262         output = -output;
263263
264      chan->output_vol = output;
265   }
264      chan->output_vol = output;
265   }
266266
267   return (int8) chan->output_vol;
267   return (int8) chan->output_vol;
268268}
269269
270270/* OUTPUT NOISE WAVE SAMPLE (VALUES FROM -16 to +15) */
271271static int8 apu_noise(nesapu_state *info, noise_t *chan)
272272{
273   int freq, env_delay;
274   uint8 outvol;
275   uint8 output;
273   int freq, env_delay;
274   uint8 outvol;
275   uint8 output;
276276
277   /* reg0: 0-3=volume, 4=envelope, 5=hold
278   ** reg2: 7=small(93 byte) sample,3-0=freq lookup
279   ** reg3: 7-4=vbl length counter
280   */
277   /* reg0: 0-3=volume, 4=envelope, 5=hold
278   ** reg2: 7=small(93 byte) sample,3-0=freq lookup
279   ** reg3: 7-4=vbl length counter
280   */
281281
282   if (FALSE == chan->enabled)
283      return 0;
282   if (FALSE == chan->enabled)
283      return 0;
284284
285   /* enveloping */
286   env_delay = info->sync_times1[chan->regs[0] & 0x0F];
285   /* enveloping */
286   env_delay = info->sync_times1[chan->regs[0] & 0x0F];
287287
288   /* decay is at a rate of (env_regs + 1) / 240 secs */
289   chan->env_phase -= 4;
290   while (chan->env_phase < 0)
291   {
292      chan->env_phase += env_delay;
293      if (chan->regs[0] & 0x20)
294         chan->env_vol = (chan->env_vol + 1) & 15;
295      else if (chan->env_vol < 15)
296         chan->env_vol++;
297   }
288   /* decay is at a rate of (env_regs + 1) / 240 secs */
289   chan->env_phase -= 4;
290   while (chan->env_phase < 0)
291   {
292      chan->env_phase += env_delay;
293      if (chan->regs[0] & 0x20)
294         chan->env_vol = (chan->env_vol + 1) & 15;
295      else if (chan->env_vol < 15)
296         chan->env_vol++;
297   }
298298
299   /* length counter */
300   if (0 == (chan->regs[0] & 0x20))
301   {
302      if (chan->vbl_length > 0)
303         chan->vbl_length--;
304   }
299   /* length counter */
300   if (0 == (chan->regs[0] & 0x20))
301   {
302      if (chan->vbl_length > 0)
303         chan->vbl_length--;
304   }
305305
306   if (0 == chan->vbl_length)
307      return 0;
306   if (0 == chan->vbl_length)
307      return 0;
308308
309   freq = noise_freq[chan->regs[2] & 0x0F];
310   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
311   while (chan->phaseacc < 0)
312   {
313      chan->phaseacc += freq;
309   freq = noise_freq[chan->regs[2] & 0x0F];
310   chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
311   while (chan->phaseacc < 0)
312   {
313      chan->phaseacc += freq;
314314
315      chan->cur_pos++;
316      if (NOISE_SHORT == chan->cur_pos && (chan->regs[2] & 0x80))
317         chan->cur_pos = 0;
318      else if (NOISE_LONG == chan->cur_pos)
319         chan->cur_pos = 0;
320   }
315      chan->cur_pos++;
316      if (NOISE_SHORT == chan->cur_pos && (chan->regs[2] & 0x80))
317         chan->cur_pos = 0;
318      else if (NOISE_LONG == chan->cur_pos)
319         chan->cur_pos = 0;
320   }
321321
322   if (chan->regs[0] & 0x10) /* fixed volume */
323      outvol = chan->regs[0] & 0x0F;
324   else
325      outvol = 0x0F - chan->env_vol;
322   if (chan->regs[0] & 0x10) /* fixed volume */
323      outvol = chan->regs[0] & 0x0F;
324   else
325      outvol = 0x0F - chan->env_vol;
326326
327   output = info->noise_lut[chan->cur_pos];
328   if (output > outvol)
329      output = outvol;
327   output = info->noise_lut[chan->cur_pos];
328   if (output > outvol)
329      output = outvol;
330330
331   if (info->noise_lut[chan->cur_pos] & 0x80) /* make it negative */
332      output = -output;
331   if (info->noise_lut[chan->cur_pos] & 0x80) /* make it negative */
332      output = -output;
333333
334   return (int8) output;
334   return (int8) output;
335335}
336336
337337/* RESET DPCM PARAMETERS */
338338INLINE void apu_dpcmreset(dpcm_t *chan)
339339{
340   chan->address = 0xC000 + (uint16) (chan->regs[2] << 6);
341   chan->length = (uint16) (chan->regs[3] << 4) + 1;
342   chan->bits_left = chan->length << 3;
343   chan->irq_occurred = FALSE;
344   chan->enabled = TRUE; /* Fixed * Proper DPCM channel ENABLE/DISABLE flag behaviour*/
345   chan->vol = 0; /* Fixed * DPCM DAC resets itself when restarted */
340   chan->address = 0xC000 + (uint16) (chan->regs[2] << 6);
341   chan->length = (uint16) (chan->regs[3] << 4) + 1;
342   chan->bits_left = chan->length << 3;
343   chan->irq_occurred = FALSE;
344   chan->enabled = TRUE; /* Fixed * Proper DPCM channel ENABLE/DISABLE flag behaviour*/
345   chan->vol = 0; /* Fixed * DPCM DAC resets itself when restarted */
346346}
347347
348348/* OUTPUT DPCM WAVE SAMPLE (VALUES FROM -64 to +63) */
349349/* TODO: centerline naughtiness */
350350static int8 apu_dpcm(nesapu_state *info, dpcm_t *chan)
351351{
352   int freq, bit_pos;
352   int freq, bit_pos;
353353
354   /* reg0: 7=irq gen, 6=looping, 3-0=pointer to clock table
355   ** reg1: output dc level, 7 bits unsigned
356   ** reg2: 8 bits of 64-byte aligned address offset : $C000 + (value * 64)
357   ** reg3: length, (value * 16) + 1
358   */
354   /* reg0: 7=irq gen, 6=looping, 3-0=pointer to clock table
355   ** reg1: output dc level, 7 bits unsigned
356   ** reg2: 8 bits of 64-byte aligned address offset : $C000 + (value * 64)
357   ** reg3: length, (value * 16) + 1
358   */
359359
360   if (chan->enabled)
361   {
362      freq = dpcm_clocks[chan->regs[0] & 0x0F];
363      chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
360   if (chan->enabled)
361   {
362      freq = dpcm_clocks[chan->regs[0] & 0x0F];
363      chan->phaseacc -= (float) info->apu_incsize; /* # of cycles per sample */
364364
365      while (chan->phaseacc < 0)
366      {
367         chan->phaseacc += freq;
365      while (chan->phaseacc < 0)
366      {
367         chan->phaseacc += freq;
368368
369         if (0 == chan->length)
370         {
371            chan->enabled = FALSE; /* Fixed * Proper DPCM channel ENABLE/DISABLE flag behaviour*/
372            chan->vol=0; /* Fixed * DPCM DAC resets itself when restarted */
373            if (chan->regs[0] & 0x40)
374               apu_dpcmreset(chan);
375            else
376            {
377               if (chan->regs[0] & 0x80) /* IRQ Generator */
378               {
379                  chan->irq_occurred = TRUE;
380                  n2a03_irq(info->APU.dpcm.memory->cpu);
381               }
382               break;
383            }
384         }
369         if (0 == chan->length)
370         {
371            chan->enabled = FALSE; /* Fixed * Proper DPCM channel ENABLE/DISABLE flag behaviour*/
372            chan->vol=0; /* Fixed * DPCM DAC resets itself when restarted */
373            if (chan->regs[0] & 0x40)
374               apu_dpcmreset(chan);
375            else
376            {
377               if (chan->regs[0] & 0x80) /* IRQ Generator */
378               {
379                  chan->irq_occurred = TRUE;
380                  n2a03_irq(info->APU.dpcm.memory->cpu);
381               }
382               break;
383            }
384         }
385385
386386
387         chan->bits_left--;
388         bit_pos = 7 - (chan->bits_left & 7);
389         if (7 == bit_pos)
390         {
391            chan->cur_byte = memory_read_byte(info->APU.dpcm.memory, chan->address);
392            chan->address++;
393            chan->length--;
394         }
387         chan->bits_left--;
388         bit_pos = 7 - (chan->bits_left & 7);
389         if (7 == bit_pos)
390         {
391            chan->cur_byte = memory_read_byte(info->APU.dpcm.memory, chan->address);
392            chan->address++;
393            chan->length--;
394         }
395395
396         if (chan->cur_byte & (1 << bit_pos))
397//            chan->regs[1]++;
398            chan->vol+=2; /* FIXED * DPCM channel only uses the upper 6 bits of the DAC */
399         else
400//            chan->regs[1]--;
401            chan->vol-=2;
402      }
403   }
396         if (chan->cur_byte & (1 << bit_pos))
397//            chan->regs[1]++;
398            chan->vol+=2; /* FIXED * DPCM channel only uses the upper 6 bits of the DAC */
399         else
400//            chan->regs[1]--;
401            chan->vol-=2;
402      }
403   }
404404
405   if (chan->vol > 63)
406      chan->vol = 63;
407   else if (chan->vol < -64)
408      chan->vol = -64;
405   if (chan->vol > 63)
406      chan->vol = 63;
407   else if (chan->vol < -64)
408      chan->vol = -64;
409409
410   return (int8) (chan->vol);
410   return (int8) (chan->vol);
411411}
412412
413413/* WRITE REGISTER VALUE */
414414INLINE void apu_regwrite(nesapu_state *info,int address, uint8 value)
415415{
416   int chan = (address & 4) ? 1 : 0;
416   int chan = (address & 4) ? 1 : 0;
417417
418   switch (address)
419   {
420   /* squares */
421   case APU_WRA0:
422   case APU_WRB0:
423      info->APU.squ[chan].regs[0] = value;
424      break;
418   switch (address)
419   {
420   /* squares */
421   case APU_WRA0:
422   case APU_WRB0:
423      info->APU.squ[chan].regs[0] = value;
424      break;
425425
426   case APU_WRA1:
427   case APU_WRB1:
428      info->APU.squ[chan].regs[1] = value;
429      break;
426   case APU_WRA1:
427   case APU_WRB1:
428      info->APU.squ[chan].regs[1] = value;
429      break;
430430
431   case APU_WRA2:
432   case APU_WRB2:
433      info->APU.squ[chan].regs[2] = value;
434      if (info->APU.squ[chan].enabled)
435         info->APU.squ[chan].freq = ((((info->APU.squ[chan].regs[3] & 7) << 8) + value) + 1) << 16;
436      break;
431   case APU_WRA2:
432   case APU_WRB2:
433      info->APU.squ[chan].regs[2] = value;
434      if (info->APU.squ[chan].enabled)
435         info->APU.squ[chan].freq = ((((info->APU.squ[chan].regs[3] & 7) << 8) + value) + 1) << 16;
436      break;
437437
438   case APU_WRA3:
439   case APU_WRB3:
440      info->APU.squ[chan].regs[3] = value;
438   case APU_WRA3:
439   case APU_WRB3:
440      info->APU.squ[chan].regs[3] = value;
441441
442      if (info->APU.squ[chan].enabled)
443      {
444         info->APU.squ[chan].vbl_length = info->vbl_times[value >> 3];
445         info->APU.squ[chan].env_vol = 0;
446         info->APU.squ[chan].freq = ((((value & 7) << 8) + info->APU.squ[chan].regs[2]) + 1) << 16;
447      }
442      if (info->APU.squ[chan].enabled)
443      {
444         info->APU.squ[chan].vbl_length = info->vbl_times[value >> 3];
445         info->APU.squ[chan].env_vol = 0;
446         info->APU.squ[chan].freq = ((((value & 7) << 8) + info->APU.squ[chan].regs[2]) + 1) << 16;
447      }
448448
449      break;
449      break;
450450
451   /* triangle */
452   case APU_WRC0:
453      info->APU.tri.regs[0] = value;
451   /* triangle */
452   case APU_WRC0:
453      info->APU.tri.regs[0] = value;
454454
455      if (info->APU.tri.enabled)
456      {                                          /* ??? */
457         if (FALSE == info->APU.tri.counter_started)
458            info->APU.tri.linear_length = info->sync_times2[value & 0x7F];
459      }
455      if (info->APU.tri.enabled)
456      {                                          /* ??? */
457         if (FALSE == info->APU.tri.counter_started)
458            info->APU.tri.linear_length = info->sync_times2[value & 0x7F];
459      }
460460
461      break;
461      break;
462462
463   case 0x4009:
464      /* unused */
465      info->APU.tri.regs[1] = value;
466      break;
463   case 0x4009:
464      /* unused */
465      info->APU.tri.regs[1] = value;
466      break;
467467
468   case APU_WRC2:
469      info->APU.tri.regs[2] = value;
470      break;
468   case APU_WRC2:
469      info->APU.tri.regs[2] = value;
470      break;
471471
472   case APU_WRC3:
473      info->APU.tri.regs[3] = value;
472   case APU_WRC3:
473      info->APU.tri.regs[3] = value;
474474
475      /* this is somewhat of a hack.  there is some latency on the Real
476      ** Thing between when trireg0 is written to and when the linear
477      ** length counter actually begins its countdown.  we want to prevent
478      ** the case where the program writes to the freq regs first, then
479      ** to reg 0, and the counter accidentally starts running because of
480      ** the sound queue's timestamp processing.
481      **
482      ** set to a few NES sample -- should be sufficient
483      **
484      **     3 * (1789772.727 / 44100) = ~122 cycles, just around one scanline
485      **
486      ** should be plenty of time for the 6502 code to do a couple of table
487      ** dereferences and load up the other triregs
488      */
475      /* this is somewhat of a hack.  there is some latency on the Real
476      ** Thing between when trireg0 is written to and when the linear
477      ** length counter actually begins its countdown.  we want to prevent
478      ** the case where the program writes to the freq regs first, then
479      ** to reg 0, and the counter accidentally starts running because of
480      ** the sound queue's timestamp processing.
481      **
482      ** set to a few NES sample -- should be sufficient
483      **
484      **     3 * (1789772.727 / 44100) = ~122 cycles, just around one scanline
485      **
486      ** should be plenty of time for the 6502 code to do a couple of table
487      ** dereferences and load up the other triregs
488      */
489489
490490   /* used to be 3, but now we run the clock faster, so base it on samples/sync */
491      info->APU.tri.write_latency = (info->samps_per_sync + 239) / 240;
491      info->APU.tri.write_latency = (info->samps_per_sync + 239) / 240;
492492
493      if (info->APU.tri.enabled)
494      {
495         info->APU.tri.counter_started = FALSE;
496         info->APU.tri.vbl_length = info->vbl_times[value >> 3];
497         info->APU.tri.linear_length = info->sync_times2[info->APU.tri.regs[0] & 0x7F];
498      }
493      if (info->APU.tri.enabled)
494      {
495         info->APU.tri.counter_started = FALSE;
496         info->APU.tri.vbl_length = info->vbl_times[value >> 3];
497         info->APU.tri.linear_length = info->sync_times2[info->APU.tri.regs[0] & 0x7F];
498      }
499499
500      break;
500      break;
501501
502   /* noise */
503   case APU_WRD0:
504      info->APU.noi.regs[0] = value;
505      break;
502   /* noise */
503   case APU_WRD0:
504      info->APU.noi.regs[0] = value;
505      break;
506506
507   case 0x400D:
508      /* unused */
509      info->APU.noi.regs[1] = value;
510      break;
507   case 0x400D:
508      /* unused */
509      info->APU.noi.regs[1] = value;
510      break;
511511
512   case APU_WRD2:
513      info->APU.noi.regs[2] = value;
514      break;
512   case APU_WRD2:
513      info->APU.noi.regs[2] = value;
514      break;
515515
516   case APU_WRD3:
517      info->APU.noi.regs[3] = value;
516   case APU_WRD3:
517      info->APU.noi.regs[3] = value;
518518
519      if (info->APU.noi.enabled)
520      {
521         info->APU.noi.vbl_length = info->vbl_times[value >> 3];
522         info->APU.noi.env_vol = 0; /* reset envelope */
523      }
524      break;
519      if (info->APU.noi.enabled)
520      {
521         info->APU.noi.vbl_length = info->vbl_times[value >> 3];
522         info->APU.noi.env_vol = 0; /* reset envelope */
523      }
524      break;
525525
526   /* DMC */
527   case APU_WRE0:
528      info->APU.dpcm.regs[0] = value;
529      if (0 == (value & 0x80))
530         info->APU.dpcm.irq_occurred = FALSE;
531      break;
526   /* DMC */
527   case APU_WRE0:
528      info->APU.dpcm.regs[0] = value;
529      if (0 == (value & 0x80))
530         info->APU.dpcm.irq_occurred = FALSE;
531      break;
532532
533   case APU_WRE1: /* 7-bit DAC */
534      //info->APU.dpcm.regs[1] = value - 0x40;
535      info->APU.dpcm.regs[1] = value & 0x7F;
536      info->APU.dpcm.vol = (info->APU.dpcm.regs[1]-64);
537      break;
533   case APU_WRE1: /* 7-bit DAC */
534      //info->APU.dpcm.regs[1] = value - 0x40;
535      info->APU.dpcm.regs[1] = value & 0x7F;
536      info->APU.dpcm.vol = (info->APU.dpcm.regs[1]-64);
537      break;
538538
539   case APU_WRE2:
540      info->APU.dpcm.regs[2] = value;
541      //apu_dpcmreset(info->APU.dpcm);
542      break;
539   case APU_WRE2:
540      info->APU.dpcm.regs[2] = value;
541      //apu_dpcmreset(info->APU.dpcm);
542      break;
543543
544   case APU_WRE3:
545      info->APU.dpcm.regs[3] = value;
546      break;
544   case APU_WRE3:
545      info->APU.dpcm.regs[3] = value;
546      break;
547547
548   case APU_IRQCTRL:
549      break;
548   case APU_IRQCTRL:
549      if(value & 0x80)
550         info->APU.step_mode = 5;
551      else
552         info->APU.step_mode = 4;
553      break;
550554
551   case APU_SMASK:
552      if (value & 0x01)
553         info->APU.squ[0].enabled = TRUE;
554      else
555      {
556         info->APU.squ[0].enabled = FALSE;
557         info->APU.squ[0].vbl_length = 0;
558      }
555   case APU_SMASK:
556      if (value & 0x01)
557         info->APU.squ[0].enabled = TRUE;
558      else
559      {
560         info->APU.squ[0].enabled = FALSE;
561         info->APU.squ[0].vbl_length = 0;
562      }
559563
560      if (value & 0x02)
561         info->APU.squ[1].enabled = TRUE;
562      else
563      {
564         info->APU.squ[1].enabled = FALSE;
565         info->APU.squ[1].vbl_length = 0;
566      }
564      if (value & 0x02)
565         info->APU.squ[1].enabled = TRUE;
566      else
567      {
568         info->APU.squ[1].enabled = FALSE;
569         info->APU.squ[1].vbl_length = 0;
570      }
567571
568      if (value & 0x04)
569         info->APU.tri.enabled = TRUE;
570      else
571      {
572         info->APU.tri.enabled = FALSE;
573         info->APU.tri.vbl_length = 0;
574         info->APU.tri.linear_length = 0;
575         info->APU.tri.counter_started = FALSE;
576         info->APU.tri.write_latency = 0;
577      }
572      if (value & 0x04)
573         info->APU.tri.enabled = TRUE;
574      else
575      {
576         info->APU.tri.enabled = FALSE;
577         info->APU.tri.vbl_length = 0;
578         info->APU.tri.linear_length = 0;
579         info->APU.tri.counter_started = FALSE;
580         info->APU.tri.write_latency = 0;
581      }
578582
579      if (value & 0x08)
580         info->APU.noi.enabled = TRUE;
581      else
582      {
583         info->APU.noi.enabled = FALSE;
584         info->APU.noi.vbl_length = 0;
585      }
583      if (value & 0x08)
584         info->APU.noi.enabled = TRUE;
585      else
586      {
587         info->APU.noi.enabled = FALSE;
588         info->APU.noi.vbl_length = 0;
589      }
586590
587      if (value & 0x10)
588      {
589         /* only reset dpcm values if DMA is finished */
590         if (FALSE == info->APU.dpcm.enabled)
591         {
592            info->APU.dpcm.enabled = TRUE;
593            apu_dpcmreset(&info->APU.dpcm);
594         }
595      }
596      else
597         info->APU.dpcm.enabled = FALSE;
591      if (value & 0x10)
592      {
593         /* only reset dpcm values if DMA is finished */
594         if (FALSE == info->APU.dpcm.enabled)
595         {
596            info->APU.dpcm.enabled = TRUE;
597            apu_dpcmreset(&info->APU.dpcm);
598         }
599      }
600      else
601         info->APU.dpcm.enabled = FALSE;
598602
599      info->APU.dpcm.irq_occurred = FALSE;
603      info->APU.dpcm.irq_occurred = FALSE;
600604
601      break;
602   default:
605      break;
606   default:
603607#ifdef MAME_DEBUG
604608logerror("invalid apu write: $%02X at $%04X\n", value, address);
605609#endif
606      break;
607   }
610      break;
611   }
608612}
609613
610614/* UPDATE SOUND BUFFER USING CURRENT DATA */
611615INLINE void apu_update(nesapu_state *info, stream_sample_t *buffer16, int samples)
612616{
613   int accum;
617   int accum;
614618
615   while (samples--)
616   {
617      accum = apu_square(info, &info->APU.squ[0]);
618      accum += apu_square(info, &info->APU.squ[1]);
619      accum += apu_triangle(info, &info->APU.tri);
620      accum += apu_noise(info, &info->APU.noi);
621      accum += apu_dpcm(info, &info->APU.dpcm);
619   while (samples--)
620   {
621      accum = apu_square(info, &info->APU.squ[0]);
622      accum += apu_square(info, &info->APU.squ[1]);
623      accum += apu_triangle(info, &info->APU.tri);
624      accum += apu_noise(info, &info->APU.noi);
625      accum += apu_dpcm(info, &info->APU.dpcm);
622626
623      /* 8-bit clamps */
624      if (accum > 127)
625         accum = 127;
626      else if (accum < -128)
627         accum = -128;
627      /* 8-bit clamps */
628      if (accum > 127)
629         accum = 127;
630      else if (accum < -128)
631         accum = -128;
628632
629      *(buffer16++)=accum<<8;
630   }
633      *(buffer16++)=accum<<8;
634   }
631635}
632636
633637/* READ VALUES FROM REGISTERS */
634638INLINE uint8 apu_read(nesapu_state *info,int address)
635639{
636  if (address == 0x0f) /*FIXED* Address $4015 has different behaviour*/
640   if (address == 0x15) /*FIXED* Address $4015 has different behaviour*/
637641     {
638     int readval = 0;
639        if ( info->APU.dpcm.enabled == TRUE )
640           {
641              readval |= 0x10;
642           }
642      int readval = 0;
643      if (info->APU.squ[0].vbl_length > 0)
644         readval |= 0x01;
643645
644        if ( info->APU.dpcm.irq_occurred == TRUE )
645           {
646              readval |= 0x80;
647           }
648        return readval;
649        }
650  else
651  return info->APU.regs[address];
646      if (info->APU.squ[1].vbl_length > 0)
647         readval |= 0x02;
648
649      if (info->APU.tri.vbl_length > 0)
650         readval |= 0x04;
651
652      if (info->APU.noi.vbl_length > 0)
653         readval |= 0x08;
654
655        if (info->APU.dpcm.enabled == TRUE)
656         readval |= 0x10;
657
658        if (info->APU.dpcm.irq_occurred == TRUE)
659         readval |= 0x80;
660
661      return readval;
662   }
663   else
664      return info->APU.regs[address];
652665}
653666
654667/* WRITE VALUE TO TEMP REGISTRY AND QUEUE EVENT */
655668INLINE void apu_write(nesapu_state *info,int address, uint8 value)
656669{
657   info->APU.regs[address]=value;
658   stream_update(info->stream);
659   apu_regwrite(info,address,value);
670   info->APU.regs[address]=value;
671   stream_update(info->stream);
672   apu_regwrite(info,address,value);
660673}
661674
662675/* EXTERNAL INTERFACE FUNCTIONS */
r5357r5358
753766   state_save_register_device_item(device, 0, info->APU.tail);
754767#else
755768   state_save_register_device_item(device, 0, info->APU.buf_pos);
769   state_save_register_device_item(device, 0, info->APU.step_mode);
756770#endif
757771}
758772
src/mess/includes/nes.h
r5357r5358
5757   UINT8 *vram;
5858   UINT8 *wram;
5959   UINT8 *ciram; //PPU nametable RAM - external to PPU!
60   UINT8 *exram; //MMC5 exram. We should move this one day
6160
6261   /* Variables which can change */
6362   UINT8 mid_ram_enable;
src/mess/machine/nes.c
r5357r5358
8080   nes.vram = memory_region(machine, "gfx2");
8181   nes.ciram = memory_region(machine, "gfx3");
8282   nes.wram = memory_region(machine, "user1");
83   nes.exram = auto_alloc_array(machine, UINT8, 0x400);
8483
8584   /* Brutal hack put in as a consequence of the new memory system; we really
8685    * need to fix the NES code */
src/mess/machine/nes_mmc.c
r5357r5358
77   . 67 display issues, but vrom fixed
88   . 70 (ark2j) starts on round 0 - is this right? Yep!
99   . 82 has chr-rom banking problems. Also mapper is in the middle of sram, which is unemulated.
10   . 95 doesn't match documentation
1011   . 96 is preliminary.
1112   . 118 mirroring is a guess, chr-rom banking is likely different
13   . 164 preliminary - no sprites?
1214   . 228 seems wrong
1315   . 229 is preliminary
1416   . 230 not working yet
r5357r5358
5052#define CIRAM 0
5153#define ROM 1
5254#define EXRAM 2
55#define MMC5FILL 3
56#define CART_NTRAM 4
5357
5458typedef struct
5559{
56   int source;   //defines source of base pointer
57   int origin; //defines offset of 0x400 byte segment at base pointer
58   int writable; //ExRAM, at least, can be write-protected AND used as nametable
59   UINT8* access;   //source translated + origin -> valid pointer!
60   int source;      /* defines source of base pointer */
61   int origin;      /* defines offset of 0x400 byte segment at base pointer */
62   int writable;   /* ExRAM, at least, can be write-protected AND used as nametable */
63   UINT8* access;   /* direct access when possible */
6064} name_table;
6165
6266/* Global variables */
r5357r5358
99103static int MMC3_chr[6];
100104static int MMC3_prg_base, MMC3_prg_mask;
101105static int MMC3_chr_base, MMC3_chr_mask;
106UINT8* extended_ntram;
102107
103108static int MMC5_rom_bank_mode;
104109static int MMC5_vrom_bank_mode;
105110static int MMC5_vram_protect;
106111static int MMC5_scanline;
112static int MMC5_floodtile;
113static int MMC5_floodattr;
107114UINT8 MMC5_vram[0x400];
108115int MMC5_vram_control;
109116
r5357r5358
158165READ8_HANDLER(nes_nt_r)
159166{
160167   int page = ((offset & 0xc00) >> 10);
168   if (nt_page[page].source == MMC5FILL)
169   {
170      if ((offset & 0x3ff) >= 0x3c0)
171         return MMC5_floodattr;
161172
173      return MMC5_floodtile;
174   }
162175   return nt_page[page].access[offset & 0x3ff];
163176}
164177
r5357r5358
246259 * Some helpful routines used by the mappers
247260 */
248261
249static void ppu_mirror_custom( int page, int address )
250{
251   logerror("Unimplemented: custom NT mirroring");
252}
253
254262static void ppu_mirror_MMC5( int page, int src )
255263{
256264   switch(src)
r5357r5358
264272   case 2:   /* ExRAM */
265273      set_nt_page(page, EXRAM, 0, 1);   // actually only works during rendering.
266274      break;
267   case 3:   /* FillRegisters -useless without dot-based PPU, in general */
275   case 3: /* Fill Registers */
276      set_nt_page(page, MMC5FILL, 0, 0);
277      break;
268278   default:   
269      logerror("Unimplemented: Fill support");
279      fatalerror("This should never happen");
270280      break;
271281   }
272282}
r5357r5358
363373
364374   switch (source)
365375   {
376      case CART_NTRAM:
377         base_ptr = extended_ntram;
378         break;
379      case MMC5FILL:
380         base_ptr = NULL;
381         break;
366382      case ROM:
367383         base_ptr = nes.vrom;
368384         break;
369
370385      case EXRAM:
371         base_ptr = nes.exram;
386         base_ptr = MMC5_vram;
372387         break;
373
374388      case CIRAM:
375389      default:
376390         base_ptr = nes.ciram;
377391         break;
378392   }
379393
380   page &= 3; // mask down to the 4 logical pages
394   page &= 3; /* mask down to the 4 logical pages */
381395   nt_page[page].source = source;
382   nt_page[page].origin = bank * 0x400;
383   nt_page[page].access = base_ptr + nt_page[page].origin;
396   if(NULL != base_ptr)
397   {
398      nt_page[page].origin = bank * 0x400;
399      nt_page[page].access = base_ptr + nt_page[page].origin;
400   }
384401   nt_page[page].writable = writable;
385402}
386403
r5357r5358
422439      default:
423440         /* external RAM needs to be used somehow. */
424441         /* but as a default, we'll arbitrarily set vertical so as not to crash*/
442         /* mappers should use set_nt_page and assign which pages are which */
443
425444         logerror("Mapper set 4-screen mirroring without supplying external nametable memory!\n");
426445
427446         set_nt_page(0, CIRAM, 0, 1);
r5357r5358
683702                  int bank = MMC1_reg & (nes.chr_chunks - 1);
684703                  //int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1);
685704                  chr8(space->machine, bank>>1, CHRROM);
686//                  ppu2c0x_set_videorom_bank(state->ppu, 0, 8, bank, 256);
687705                  LOG_MMC(("MMC1 8k VROM switch: %02x\n", MMC1_reg));
688706               }
689707               else
690708               {
691709                  int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1);
692710                  chr4_0(space->machine,bank, CHRROM);
693//                  ppu2c0x_set_videorom_bank(state->ppu, 0, 4, bank, 256);
694711                  LOG_MMC(("MMC1 4k VROM switch (low): %02x\n", MMC1_reg));
695712               }
696713            }
r5357r5358
718735            {
719736               int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1);
720737               chr4_4(space->machine, bank, CHRROM);
721               //ppu2c0x_set_videorom_bank(state->ppu, 4, 4, bank, 256);
722738               LOG_MMC(("MMC1 4k VROM switch (high): %02x\n", MMC1_reg));
723739            }
724740            break;
r5357r5358
826842
827843static void mapper4_set_chr (running_machine *machine)
828844{
829   //nes_state *state = machine->driver_data;
830845   UINT8 chr_page = (MMC3_cmd & 0x80) >> 5;
831846
832847   chr2_x(machine, chr_page ^ 0, MMC3_chr_base | ( (MMC3_chr[0]>>1) & ( MMC3_chr_mask ) ), CHRROM);
r5357r5358
835850   chr1_x(machine, chr_page ^5, MMC3_chr_base | (MMC3_chr[3]& ( MMC3_chr_mask ) ), CHRROM);
836851   chr1_x(machine, chr_page ^6, MMC3_chr_base | (MMC3_chr[4]& ( MMC3_chr_mask ) ), CHRROM);
837852   chr1_x(machine, chr_page ^7, MMC3_chr_base | (MMC3_chr[5]& ( MMC3_chr_mask ) ), CHRROM);
838   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 0, 2, MMC3_chr_base * 64 | ( MMC3_chr[0] & ( MMC3_chr_mask * 64 ) ), 1);
839   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 2, 2, MMC3_chr_base * 64 | ( MMC3_chr[1] & ( MMC3_chr_mask * 64 ) ), 1);
840   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 4, 1, MMC3_chr_base * 64 | ( MMC3_chr[2] & ( MMC3_chr_mask * 64 ) ), 1);
841   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 5, 1, MMC3_chr_base * 64 | ( MMC3_chr[3] & ( MMC3_chr_mask * 64 ) ), 1);
842   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 6, 1, MMC3_chr_base * 64 | ( MMC3_chr[4] & ( MMC3_chr_mask * 64 ) ), 1);
843   //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 7, 1, MMC3_chr_base * 64 | ( MMC3_chr[5] & ( MMC3_chr_mask * 64 ) ), 1);
844853}
845854
846855static void mapper4_irq ( const device_config *device, int scanline, int vblank, int blanked )
r5357r5358
963972
964973static WRITE8_HANDLER( mapper118_w )
965974{
966   //nes_state *state = space->machine->driver_data;
967975   static UINT8 last_bank = 0xff;
968976
969977//   logerror("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline);
r5357r5358
10601068   UINT8 chr_page = (MMC3_cmd & 0x80) >> 5;
10611069   if(MMC3_chr[0]&0x40)
10621070      chr2_x(machine, chr_page ^ 0, (MMC3_chr[0]>>1)&3, CHRRAM);
1063   else chr2_x(machine, chr_page ^ 0, ((MMC3_chr[0])>>1), CHRROM);
1071   else chr2_x(machine, chr_page ^ 0, ((MMC3_chr[0]&0x3f)>>1), CHRROM);
10641072   if(MMC3_chr[1]&0x40)
10651073      chr2_x(machine, chr_page ^ 2, (MMC3_chr[1]>>1)&3, CHRRAM);
1066   else chr2_x(machine, chr_page ^ 2, (MMC3_chr[1]>>1), CHRROM);
1074   else chr2_x(machine, chr_page ^ 2, ((MMC3_chr[1]&0x3f)>>1), CHRROM);
10671075   if(MMC3_chr[2]&0x40)
10681076      chr1_x(machine, chr_page ^ 4, MMC3_chr[2]&7, CHRRAM);
1069   else chr1_x(machine, chr_page ^ 4, MMC3_chr[2], CHRROM);
1077   else chr1_x(machine, chr_page ^ 4, MMC3_chr[2]&0x3f, CHRROM);
10701078
10711079   if(MMC3_chr[3]&0x40)
10721080      chr1_x(machine, chr_page ^ 5, MMC3_chr[3]&7, CHRRAM);
1073   else chr1_x(machine, chr_page ^ 5, MMC3_chr[3], CHRROM);
1081   else chr1_x(machine, chr_page ^ 5, MMC3_chr[3]&0x3f, CHRROM);
10741082   if(MMC3_chr[4]&0x40)
10751083      chr1_x(machine, chr_page ^ 6, MMC3_chr[4]&7, CHRRAM);
1076   else chr1_x(machine, chr_page ^ 6, MMC3_chr[4], CHRROM);
1084   else chr1_x(machine, chr_page ^ 6, MMC3_chr[4]&0x3f, CHRROM);
10771085   if(MMC3_chr[5]&0x40)
10781086      chr1_x(machine, chr_page ^ 7, MMC3_chr[5]&7, CHRRAM);
1079   else chr1_x(machine, chr_page ^ 7, MMC3_chr[5], CHRROM);
1087   else chr1_x(machine, chr_page ^ 7, MMC3_chr[5]&0x3f, CHRROM);
10801088}
10811089
10821090static WRITE8_HANDLER( mapper119_w )
10831091{
1084   //nes_state *state = space->machine->driver_data;
10851092   static UINT8 last_bank = 0xff;
10861093
10871094//   logerror("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline);
r5357r5358
10971104         {
10981105            /* Reset the banks */
10991106            mapper4_set_prg (space);
1100            mapper4_set_chr (space->machine);
1107            mapper119_set_chr (space->machine);
11011108            LOG_MMC(("     MMC3 reset banks\n"));
11021109         }
11031110         last_bank = data & 0xc0;
r5357r5358
11091116         switch (cmd)
11101117         {
11111118            case 0: case 1:
1112               //data &= 0xfe;
11131119               MMC3_chr[cmd] = data;
11141120               mapper119_set_chr (space->machine);
11151121               LOG_MMC(("     MMC3 set vram %d: %d\n", cmd, data));
11161122               break;
11171123
11181124            case 2: case 3: case 4: case 5:
1119               MMC3_chr[cmd] = data;// * 64;
1125               MMC3_chr[cmd] = data;
11201126               mapper119_set_chr (space->machine);
11211127               LOG_MMC(("     MMC3 set vram %d: %d\n", cmd, data));
11221128               break;
r5357r5358
11991205{
12001206   int retVal;
12011207
1202#ifdef MMC5_VRAM
12031208   /* $5c00 - $5fff: extended videoram attributes */
12041209   if ((offset >= 0x1b00) && (offset <= 0x1eff))
12051210   {
12061211      return MMC5_vram[offset - 0x1b00];
12071212   }
1208#endif
12091213
12101214   switch (offset)
12111215   {
r5357r5358
12561260      return;
12571261   }
12581262
1259#ifdef MMC5_VRAM
12601263   /* $5c00 - $5fff: extended videoram attributes */
12611264   if ((offset >= 0x1b00) && (offset <= 0x1eff))
12621265   {
r5357r5358
12641267         MMC5_vram[offset - 0x1b00] = data;
12651268      return;
12661269   }
1267#endif
12681270
12691271   switch (offset)
12701272   {
r5357r5358
13051307         ppu_mirror_MMC5 (3, (data & 0xc0) >> 6);
13061308         break;
13071309
1308      /* $5106 - Fill mode: Tile bits ?? cv3 sets to 0 */
1309      /* $5107 - Fill mode: Attr bits?? cv3 sets to 0 */
1310      /* tile data for MMC5 flood-fill NT mode */
1311      case 0x1006:
1312         MMC5_floodtile=data;
1313         break;
13101314
1315      /* attr data for MMC5 flood-fill NT mode */
1316      case 0x1007:
1317         switch (data & 3)
1318         {
1319         default:
1320         case 0: MMC5_floodattr = 0x00; break;
1321         case 1: MMC5_floodattr = 0x55; break;
1322         case 2: MMC5_floodattr = 0xaa; break;
1323         case 3: MMC5_floodattr = 0xff; break;
1324         }
1325         break;
1326
13111327      case 0x1013: /* $5113 */
13121328         logerror ("MMC5 mid RAM bank select: %02x\n", data & 0x07);
13131329         memory_set_bankptr (space->machine, 5, &nes.wram[data * 0x2000]);
r5357r5358
16561672         {
16571673            case 0x00:
16581674               /* 8k switch */
1659               chr8 (space->machine, data, CHRROM);
1675               /* switches in first half of an 8K bank!) */
1676               chr4_0 (space->machine, data << 1, CHRROM);
1677               chr4_4 (space->machine, data << 1, CHRROM);
16601678               break;
16611679            case 0x01:
16621680               /* 4k switch */
r5357r5358
19601978
19611979   switch (offset & 0x000f)
19621980   {
1963      //use new utility functions for bounds checks!
19641981      case 0:
19651982      case 1:
19661983      case 2:
r5357r5358
21542171         vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f);
21552172         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
21562173         chr1_0(space->machine, vrom_bank[0], CHRROM);
2157//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
21582174         break;
21592175      case 0x2001:
21602176         /* Switch 1k vrom at $0000 - high 4 bits */
21612177         vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4);
21622178         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
21632179         chr1_0(space->machine, vrom_bank[0], CHRROM);
2164//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
21652180         break;
21662181      case 0x2002:
21672182         /* Switch 1k vrom at $0400 - low 4 bits */
21682183         vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f);
21692184         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
21702185         chr1_1(space->machine, vrom_bank[1], CHRROM);
2171//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
21722186         break;
21732187      case 0x2003:
21742188         /* Switch 1k vrom at $0400 - high 4 bits */
21752189         vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4);
21762190         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
21772191         chr1_1(space->machine, vrom_bank[1], CHRROM);
2178//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
21792192         break;
21802193      case 0x3000:
21812194         /* Switch 1k vrom at $0800 - low 4 bits */
21822195         vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f);
21832196         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
21842197         chr1_2(space->machine, vrom_bank[2], CHRROM);
2185//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
21862198         break;
21872199      case 0x3001:
21882200         /* Switch 1k vrom at $0800 - high 4 bits */
21892201         vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4);
21902202         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
21912203         chr1_2(space->machine, vrom_bank[2], CHRROM);
2192//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
21932204         break;
21942205      case 0x3002:
21952206         /* Switch 1k vrom at $0c00 - low 4 bits */
21962207         vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f);
21972208         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
21982209         chr1_3(space->machine, vrom_bank[3], CHRROM);
2199//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
22002210         break;
22012211      case 0x3003:
22022212         /* Switch 1k vrom at $0c00 - high 4 bits */
22032213         vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4);
22042214         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
22052215         chr1_3(space->machine, vrom_bank[3], CHRROM);
2206//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
22072216         break;
22082217      case 0x4000:
22092218         /* Switch 1k vrom at $1000 - low 4 bits */
22102219         vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f);
22112220         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
22122221         chr1_4(space->machine, vrom_bank[4], CHRROM);
2213//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
22142222         break;
22152223      case 0x4001:
22162224         /* Switch 1k vrom at $1000 - high 4 bits */
22172225         vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4);
22182226         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
22192227         chr1_4(space->machine, vrom_bank[4], CHRROM);
2220//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
22212228         break;
22222229      case 0x4002:
22232230         /* Switch 1k vrom at $1400 - low 4 bits */
22242231         vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f);
22252232         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
22262233         chr1_5(space->machine, vrom_bank[5], CHRROM);
2227//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
22282234         break;
22292235      case 0x4003:
22302236         /* Switch 1k vrom at $1400 - high 4 bits */
22312237         vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4);
22322238         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
22332239         chr1_5(space->machine, vrom_bank[5], CHRROM);
2234//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
22352240         break;
22362241      case 0x5000:
22372242         /* Switch 1k vrom at $1800 - low 4 bits */
22382243         vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f);
22392244         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
22402245         chr1_6(space->machine, vrom_bank[6], CHRROM);
2241//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
22422246         break;
22432247      case 0x5001:
22442248         /* Switch 1k vrom at $1800 - high 4 bits */
22452249         vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4);
22462250         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
22472251         chr1_6(space->machine, vrom_bank[6], CHRROM);
2248//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
22492252         break;
22502253      case 0x5002:
22512254         /* Switch 1k vrom at $1c00 - low 4 bits */
22522255         vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f);
22532256         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
22542257         chr1_7(space->machine, vrom_bank[7], CHRROM);
2255//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
22562258         break;
22572259      case 0x5003:
22582260         /* Switch 1k vrom at $1c00 - high 4 bits */
22592261         vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4);
22602262         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
22612263         chr1_7(space->machine, vrom_bank[7], CHRROM);
2262//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
22632264         break;
22642265
22652266/* LBO - these are unverified */
r5357r5358
26282629         vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f);
26292630         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
26302631         chr1_0(space->machine, vrom_bank[0], CHRROM);
2631//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
26322632         break;
26332633      case 0x3001:
26342634         /* Switch 1k vrom at $0000 - high 4 bits */
26352635         vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4);
26362636         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
26372637         chr1_0(space->machine, vrom_bank[0], CHRROM);
2638//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
26392638         break;
26402639      case 0x3002:
26412640         /* Switch 1k vrom at $0400 - low 4 bits */
26422641         vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f);
26432642         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
26442643         chr1_1(space->machine, vrom_bank[1], CHRROM);
2645//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
26462644         break;
26472645      case 0x3003:
26482646         /* Switch 1k vrom at $0400 - high 4 bits */
26492647         vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4);
26502648         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
26512649         chr1_1(space->machine, vrom_bank[1], CHRROM);
2652//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
26532650         break;
26542651      case 0x4000:
26552652         /* Switch 1k vrom at $0800 - low 4 bits */
26562653         vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f);
26572654         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
26582655         chr1_2(space->machine, vrom_bank[2], CHRROM);
2659//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
26602656         break;
26612657      case 0x4001:
26622658         /* Switch 1k vrom at $0800 - high 4 bits */
26632659         vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4);
26642660         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
26652661         chr1_2(space->machine, vrom_bank[2], CHRROM);
2666//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
26672662         break;
26682663      case 0x4002:
26692664         /* Switch 1k vrom at $0c00 - low 4 bits */
26702665         vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f);
26712666         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
26722667         chr1_3(space->machine, vrom_bank[3], CHRROM);
2673//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
26742668         break;
26752669      case 0x4003:
26762670         /* Switch 1k vrom at $0c00 - high 4 bits */
26772671         vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4);
26782672         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
26792673         chr1_3(space->machine, vrom_bank[3], CHRROM);
2680         //ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
26812674         break;
26822675      case 0x5000:
26832676         /* Switch 1k vrom at $1000 - low 4 bits */
26842677         vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f);
26852678         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
26862679         chr1_4(space->machine, vrom_bank[4], CHRROM);
2687//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
26882680         break;
26892681      case 0x5001:
26902682         /* Switch 1k vrom at $1000 - high 4 bits */
26912683         vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4);
26922684         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
26932685         chr1_4(space->machine, vrom_bank[4], CHRROM);
2694//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
26952686         break;
26962687      case 0x5002:
26972688         /* Switch 1k vrom at $1400 - low 4 bits */
26982689         vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f);
26992690         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
27002691         chr1_5(space->machine, vrom_bank[5], CHRROM);
2701//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
27022692         break;
27032693      case 0x5003:
27042694         /* Switch 1k vrom at $1400 - high 4 bits */
27052695         vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4);
27062696         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
27072697         chr1_5(space->machine, vrom_bank[5], CHRROM);
2708//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
27092698         break;
27102699      case 0x6000:
27112700         /* Switch 1k vrom at $1800 - low 4 bits */
27122701         vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f);
27132702         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
27142703         chr1_6(space->machine, vrom_bank[6], CHRROM);
2715//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
27162704         break;
27172705      case 0x6001:
27182706         /* Switch 1k vrom at $1800 - high 4 bits */
27192707         vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4);
27202708         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
27212709         chr1_6(space->machine, vrom_bank[6], CHRROM);
2722//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
27232710         break;
27242711      case 0x6002:
27252712         /* Switch 1k vrom at $1c00 - low 4 bits */
27262713         vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f);
27272714         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
27282715         chr1_7(space->machine, vrom_bank[7], CHRROM);
2729//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
27302716         break;
27312717      case 0x6003:
27322718         /* Switch 1k vrom at $1c00 - high 4 bits */
27332719         vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4);
27342720         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
27352721         chr1_7(space->machine, vrom_bank[7], CHRROM);
2736//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
27372722         break;
27382723      case 0x7000:
27392724         /* Set low 4 bits of latch */
r5357r5358
27882773         vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f);
27892774         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
27902775         chr1_0(space->machine, vrom_bank[0], CHRROM);
2791//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
27922776         break;
27932777      case 0x3002:
27942778         /* Switch 1k vrom at $0000 - high 4 bits */
27952779         vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4);
27962780         vrom_bank[0] &= ((nes.chr_chunks << 3) - 1);
27972781         chr1_0(space->machine, vrom_bank[0], CHRROM);
2798//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64);
27992782         break;
28002783      case 0x3001:
28012784      case 0x3004:
r5357r5358
28032786         vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f);
28042787         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
28052788         chr1_1(space->machine, vrom_bank[1], CHRROM);
2806//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
28072789         break;
28082790      case 0x3003:
28092791      case 0x3006:
r5357r5358
28112793         vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4);
28122794         vrom_bank[1] &= ((nes.chr_chunks << 3) - 1);
28132795         chr1_1(space->machine, vrom_bank[1], CHRROM);
2814//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64);
28152796         break;
28162797      case 0x4000:
28172798         /* Switch 1k vrom at $0800 - low 4 bits */
28182799         vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f);
28192800         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
28202801         chr1_2(space->machine, vrom_bank[2], CHRROM);
2821//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
28222802         break;
28232803      case 0x4002:
28242804         /* Switch 1k vrom at $0800 - high 4 bits */
28252805         vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4);
28262806         vrom_bank[2] &= ((nes.chr_chunks << 3) - 1);
28272807         chr1_2(space->machine, vrom_bank[2], CHRROM);
2828//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64);
28292808         break;
28302809      case 0x4001:
28312810      case 0x4004:
r5357r5358
28332812         vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f);
28342813         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
28352814         chr1_3(space->machine, vrom_bank[3], CHRROM);
2836//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
28372815         break;
28382816      case 0x4003:
28392817      case 0x4006:
r5357r5358
28412819         vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4);
28422820         vrom_bank[3] &= ((nes.chr_chunks << 3) - 1);
28432821         chr1_3(space->machine, vrom_bank[3], CHRROM);
2844//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64);
28452822         break;
28462823      case 0x5000:
28472824         /* Switch 1k vrom at $1000 - low 4 bits */
28482825         vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f);
28492826         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
28502827         chr1_4(space->machine, vrom_bank[4], CHRROM);
2851//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
28522828         break;
28532829      case 0x5002:
28542830         /* Switch 1k vrom at $1000 - high 4 bits */
28552831         vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4);
28562832         vrom_bank[4] &= ((nes.chr_chunks << 3) - 1);
28572833         chr1_4(space->machine, vrom_bank[4], CHRROM);
2858//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64);
28592834         break;
28602835      case 0x5001:
28612836      case 0x5004:
r5357r5358
28632838         vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f);
28642839         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
28652840         chr1_5(space->machine, vrom_bank[5], CHRROM);
2866//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
28672841         break;
28682842      case 0x5003:
28692843      case 0x5006:
r5357r5358
28712845         vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4);
28722846         vrom_bank[5] &= ((nes.chr_chunks << 3) - 1);
28732847         chr1_5(space->machine, vrom_bank[5], CHRROM);
2874//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64);
28752848         break;
28762849      case 0x6000:
28772850         /* Switch 1k vrom at $1800 - low 4 bits */
28782851         vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f);
28792852         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
28802853         chr1_6(space->machine, vrom_bank[6], CHRROM);
2881//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
28822854         break;
28832855      case 0x6002:
28842856         /* Switch 1k vrom at $1800 - high 4 bits */
28852857         vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4);
28862858         vrom_bank[6] &= ((nes.chr_chunks << 3) - 1);
28872859         chr1_6(space->machine, vrom_bank[6], CHRROM);
2888//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64);
28892860         break;
28902861      case 0x6001:
28912862      case 0x6004:
r5357r5358
28932864         vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f);
28942865         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
28952866         chr1_7(space->machine, vrom_bank[7], CHRROM);
2896//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
28972867         break;
28982868      case 0x6003:
28992869      case 0x6006:
r5357r5358
29012871         vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4);
29022872         vrom_bank[7] &= ((nes.chr_chunks << 3) - 1);
29032873         chr1_7(space->machine, vrom_bank[7], CHRROM);
2904//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64);
29052874         break;
29062875      case 0x7000:
29072876         /* Set low 4 bits of latch */
r5357r5358
29722941      case 0x5003:
29732942         /* switch 1k VROM at $0000-$0c00 */
29742943         chr1_x(space->machine, offset&3, data, CHRROM);
2975//         ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 0, 1, data, 64);
29762944         break;
29772945
29782946      case 0x6000:
r5357r5358
29812949      case 0x6003:
29822950         /* switch 1k VROM at $1000-$1c00 */
29832951         chr1_x(space->machine, (offset&3)+4, data, CHRROM);
2984//         ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 4, 1, data, 64);
29852952         break;
29862953
29872954      case 0x7000:
r5357r5358
30343001      case 0x5000:
30353002         /* Switch 1k VROM at $0000 */
30363003         chr1_0(space->machine,data, CHRROM);
3037//         ppu2c0x_set_videorom_bank(state->ppu, 0, 1, data, 64);
30383004         break;
30393005      case 0x5002:
30403006         /* Switch 1k VROM at $0400 */
30413007         chr1_1(space->machine,data, CHRROM);
3042//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64);
30433008         break;
30443009      case 0x5001:
30453010         /* Switch 1k VROM at $0800 */
30463011         chr1_2(space->machine,data, CHRROM);
3047//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64);
30483012         break;
30493013      case 0x5003:
30503014         /* Switch 1k VROM at $0c00 */
30513015         chr1_3(space->machine,data, CHRROM);
3052//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64);
30533016         break;
30543017      case 0x6000:
30553018         /* Switch 1k VROM at $1000 */
30563019         chr1_4(space->machine,data, CHRROM);
3057//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64);
30583020         break;
30593021      case 0x6002:
30603022         /* Switch 1k VROM at $1400 */
30613023         chr1_5(space->machine,data, CHRROM);
3062//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64);
30633024         break;
30643025      case 0x6001:
30653026         /* Switch 1k VROM at $1800 */
30663027         chr1_6(space->machine,data, CHRROM);
3067//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64);
30683028         break;
30693029      case 0x6003:
30703030         /* Switch 1k VROM at $1c00 */
30713031         chr1_7(space->machine,data, CHRROM);
3072//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64);
30733032         break;
30743033      case 0x7000:
30753034         IRQ_count_latch = data;
r5357r5358
31183077      case 0x3000:
31193078         /* Switch 1k VROM at $1000 */
31203079         chr1_x(space->machine, offset&7, data, CHRROM);
3121         //ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64);
31223080         break;
31233081      default:
31243082         logerror("Uncaught mapper 32 write, addr: %04x value: %02x\n", offset + 0x8000, data);
r5357r5358
31453103      case 0x0002:
31463104         /* Switch 2k VROM at $0000 */
31473105         chr2_0(space->machine, data, CHRROM);
3148//         ppu2c0x_set_videorom_bank(state->ppu, 0, 2, data, 128);
31493106         break;
31503107      case 0x0003:
31513108         /* Switch 2k VROM at $0800 */
31523109         chr2_2(space->machine, data, CHRROM);
3153//         ppu2c0x_set_videorom_bank(state->ppu, 2, 2, data, 128);
31543110         break;
31553111      case 0x2000:
31563112         /* Switch 1k VROM at $1000 */
31573113         chr1_4(space->machine, data, CHRROM);
3158//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64);
31593114         break;
31603115      case 0x2001:
31613116         /* Switch 1k VROM at $1400 */
31623117         chr1_5(space->machine, data, CHRROM);
3163//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64);
31643118         break;
31653119      case 0x2002:
31663120         /* Switch 1k VROM at $1800 */
31673121         chr1_6(space->machine, data, CHRROM);
3168//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64);
31693122         break;
31703123      case 0x2003:
31713124         /* Switch 1k VROM at $1c00 */
31723125         chr1_7(space->machine, data, CHRROM);
3173//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64);
31743126         break;
31753127      default:
31763128         logerror("Uncaught mapper 33 write, addr: %04x value: %02x\n", offset + 0x8000, data);
r5357r5358
41484100      case 0x1ef0:
41494101         /* Switch 2k VROM at $0000 */
41504102         chr2_0 (space->machine, (data & 0x7f) >> 1, CHRROM);
4103         break;
4104      case 0x1ef1:
4105         /* Switch 2k VROM at $0000 */
4106         chr2_2 (space->machine, (data & 0x7f) >> 1, CHRROM);
4107         break;
4108      case 0x1ef2:
4109         /* Switch 1k VROM at $1000 */
4110         chr1_4(space->machine, data, CHRROM);
4111         break;
4112      case 0x1ef3:
4113         /* Switch 1k VROM at $1400 */
4114         chr1_5(space->machine, data, CHRROM);
4115         break;
4116      case 0x1ef4:
4117         /* Switch 1k VROM at $1800 */
4118         chr1_6(space->machine, data, CHRROM);
4119         break;
4120      case 0x1ef5:
4121         /* Switch 1k VROM at $1c00 */
4122         chr1_7(space->machine, data, CHRROM);
4123         break;
4124      case 0x1ef6:
4125         /* Switch 1k VROM at $1c00 */
4126         (data&1)? set_nt_mirroring(PPU_MIRROR_VERT):set_nt_mirroring(PPU_MIRROR_HORZ);
4127         break;
4128      case 0x1efa: case 0x1efb:
4129         /* Switch 8k ROM at $8000 */
4130         prg8_89 (space, data);
4131         break;
4132      case 0x1efc: case 0x1efd:
4133         /* Switch 8k ROM at $a000 */
4134         prg8_ab (space, data);
4135         break;
4136      case 0x1efe: case 0x1eff:
4137         /* Switch 8k ROM at $c000 */
4138         prg8_cd (space, data);
4139         break;
4140      default:
4141         logerror("mapper80_m_w uncaught addr: %04x, value: %02x\n", offset + 0x6000, data);
4142         break;
4143   }
4144}
4145/* clone of 80, but with custom nametable stuff */
4146static WRITE8_HANDLER( mapper207_m_w )
4147{
4148   logerror("mapper80_m_w, offset: %04x, data: %02x\n", offset, data);
4149
4150   switch (offset)
4151   {
4152      case 0x1ef0:
4153         /* Switch 2k VROM at $0000 */
4154         chr2_0 (space->machine, (data & 0x7f) >> 1, CHRROM);
41514155         if (data & 0x80)
41524156         {
4153            /* Horizontal, $2000-$27ff */
4154            ppu_mirror_custom (0, 0);
4155            ppu_mirror_custom (1, 0);
4157            set_nt_page(0, CIRAM, 1, 1);
4158            set_nt_page(1, CIRAM, 1, 1);
41564159         }
41574160         else
41584161         {
4159            /* Vertical, $2000-$27ff */
4160            ppu_mirror_custom (0, 0);
4161            ppu_mirror_custom (1, 1);
4162            set_nt_page(0, CIRAM, 0, 1);
4163            set_nt_page(1, CIRAM, 0, 1);
41624164         }
41634165         break;
41644166      case 0x1ef1:
r5357r5358
41664168         chr2_2 (space->machine, (data & 0x7f) >> 1, CHRROM);
41674169         if (data & 0x80)
41684170         {
4169            /* Horizontal, $2800-$2fff */
4170            ppu_mirror_custom (2, 0);
4171            ppu_mirror_custom (3, 0);
4171            set_nt_page(2, CIRAM, 1, 1);
4172            set_nt_page(3, CIRAM, 1, 1);
41724173         }
41734174         else
41744175         {
4175            /* Vertical, $2800-$2fff */
4176            ppu_mirror_custom (2, 0);
4177            ppu_mirror_custom (3, 1);
4176            set_nt_page(2, CIRAM, 0, 1);
4177            set_nt_page(3, CIRAM, 0, 1);
41784178         }
41794179         break;
41804180      case 0x1ef2:
r5357r5358
44024402      case 0x2008: case 0x2010: case 0x2018:
44034403         /* Switch 1k VROM at $0400 */
44044404         chr1_1(space->machine, data, CHRROM);
4405//         ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64);
44064405         break;
44074406      case 0x3000:
44084407         /* Switch 1k VROM at $0800 */
44094408         chr1_2(space->machine, data, CHRROM);
4410//         ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64);
44114409         break;
44124410      case 0x3008: case 0x3010: case 0x3018:
44134411         /* Switch 1k VROM at $0c00 */
44144412         chr1_3(space->machine, data, CHRROM);
4415//         ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64);
44164413         break;
44174414      case 0x4000:
44184415         /* Switch 1k VROM at $1000 */
44194416         chr1_4(space->machine, data, CHRROM);
4420//         ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64);
44214417         break;
44224418      case 0x4008: case 0x4010: case 0x4018:
44234419         /* Switch 1k VROM at $1400 */
44244420         chr1_5(space->machine, data, CHRROM);
4425//         ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64);
44264421         break;
44274422      case 0x5000:
44284423         /* Switch 1k VROM at $1800 */
44294424         chr1_6(space->machine, data, CHRROM);
4430//         ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64);
44314425         break;
44324426      case 0x5008: case 0x5010: case 0x5018:
44334427         /* Switch 1k VROM at $1c00 */
44344428         chr1_7(space->machine, data, CHRROM);
4435//         ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64);
44364429         break;
44374430
44384431      case 0x6000:
r5357r5358
47264719      }
47274720   }
47284721}
4722
4723static WRITE8_HANDLER( mapper164_l_w )
4724{
4725   offset += 0x4100; /* the checks work better on addresses */
4726   if (0x5000 == (offset & 0x7300))
4727      prg32(space, data);
4728}
4729
4730static WRITE8_HANDLER( mapper164_w )
4731{
4732   if ((offset & 0x7300) == 0x5000)
4733      prg32(space, data);
4734}
4735
47294736static WRITE8_HANDLER( mapper88_w )
47304737{
4731   switch(offset&1)
4738   switch (offset&1)
47324739   {
47334740   case 0:
47344741      {
r5357r5358
54325439         prg32(space, 0);
54335440         break;
54345441      case 4:
5442      case 206:
5443         /* Only MMC3 and clones seem to use 4-screen! */
5444
5445         /* hardware uses an 8K RAM chip, but can't address the high 4K! */
5446         /* that much is documented for Nintendo Gauntlet boards */
5447         if(nes.four_screen_vram)
5448         {
5449            extended_ntram=auto_alloc_array(space->machine, UINT8, 0x2000);
5450            set_nt_page(0, CART_NTRAM, 0, 1);
5451            set_nt_page(1, CART_NTRAM, 1, 1);
5452            set_nt_page(2, CART_NTRAM, 2, 1);
5453            set_nt_page(3, CART_NTRAM, 3, 1);
5454         }
5455
54355456      case 118:
54365457      case 119:
5437      case 206:
54385458         /* Can switch 8k prg banks */
54395459         IRQ_enable = 0;
54405460         IRQ_count = IRQ_count_latch = 0;
r5357r5358
56745694      case 82:
56755695      case 85:
56765696      case 86:
5697      case 207:
56775698         prg16_89ab (space, 0);
56785699         prg16_cdef (space, nes.prg_chunks-1);
56795700         break;
r5357r5358
57345755         prg16_89ab (space, nes.prg_chunks-2);
57355756         prg16_cdef (space, nes.prg_chunks-1);
57365757         break;
5737
5758      case 164:
5759         prg32(space, 0xFF);
5760         nes.mid_ram_enable = 1;
5761         break;
57385762      case 180:
57395763         prg16_89ab(space, 0);
57405764         prg16_cdef(space, 0);
5765         break;
57415766      case 182:
57425767         IRQ_enable = 0;
57435768         IRQ_count = 0;
r5357r5358
58035828         err = 2;
58045829         break;
58055830   }
5806
5807//   if (nes.chr_chunks)
5808//      memcpy (videoram, nes.vrom, 0x2000);
5809
58105831   return err;
58115832}
58125833
r5357r5358
59005921   { 140, "Jaleco",                        NULL, NULL, mapper_140_m_w, NULL, NULL, NULL, NULL },
59015922   { 144, "AGCI 50282",         NULL, NULL, NULL, mapper144_w, NULL, NULL, NULL }, //Death Race only
59025923   { 154, "Devil Man",            NULL, NULL, NULL, mapper154_w, NULL, NULL, NULL },
5924   { 164, "Final Fantasy V",            mapper164_l_w, NULL, NULL, mapper164_w, NULL, NULL, NULL },
59035925   { 180, "Nihon Bussan - PRG HI",   NULL, NULL, NULL, mapper180_w, NULL, NULL, NULL },
59045926   { 182, "Super games",         NULL, NULL, NULL, mapper182_w, NULL, NULL, mapper182_irq },
59055927   { 184, "Sunsoft VROM/4K",      NULL, NULL, mapper184_m_w, NULL, NULL, NULL, NULL },
r5357r5358
59095931   { 201, "X-in-1",            NULL, NULL, NULL, mapper201_w, NULL, NULL, NULL },
59105932   { 202, "150-in-1",            NULL, NULL, NULL, mapper202_w, NULL, NULL, NULL },
59115933   { 203, "35-in-1",            NULL, NULL, NULL, mapper203_w, NULL, NULL, NULL },
5912   { 206, "MMC3 no mirror",      NULL, NULL, NULL, mapper206_w, NULL, NULL, mapper4_irq },
5934   { 206, "MIMIC-1",            NULL, NULL, NULL, mapper206_w, NULL, NULL, mapper4_irq },
5935   { 207, "Fudou Myouou Den",      NULL, NULL, mapper207_m_w, NULL, NULL, NULL, NULL },
59135936   { 225, "72-in-1 bootleg",      NULL, NULL, NULL, mapper225_w, NULL, NULL, NULL },
59145937   { 226, "76-in-1 bootleg",      NULL, NULL, NULL, mapper226_w, NULL, NULL, NULL },
59155938   { 227, "1200-in-1 bootleg",      NULL, NULL, NULL, mapper227_w, NULL, NULL, NULL },

Previous 15994 Revisions Next


© 1998-2018 The MESS Team