Previous 199869 Revisions Next

r18064 Friday 21st September, 2012 at 15:23:07 UTC by Fabio Priuli
nes.c: modernized the driver by moving most code into the class, work by Micko. no whatsnew.
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_ines.c nes_mmc.c nes_mmc.h nes_pcb.c

trunk/src/mess/machine/nes.c
r18063r18064
2323    FUNCTION PROTOTYPES
2424***************************************************************************/
2525
26static void init_nes_core(running_machine &machine);
2726static void nes_machine_stop(running_machine &machine);
2827
2928
r18063r18064
3332    FUNCTIONS
3433***************************************************************************/
3534
36static void init_nes_core( running_machine &machine )
35void nes_state::init_nes_core()
3736{
38   nes_state *state = machine.driver_data<nes_state>();
39   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
37   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
4038   static const char *const bank_names[] = { "bank1", "bank2", "bank3", "bank4" };
41   int prg_banks = (state->m_prg_chunks == 1) ? (2 * 2) : (state->m_prg_chunks * 2);
39   int prg_banks = (m_prg_chunks == 1) ? (2 * 2) : (m_prg_chunks * 2);
4240   int i;
4341
44   state->m_rom = machine.root_device().memregion("maincpu")->base();
45   state->m_ciram = machine.root_device().memregion("ciram")->base();
42   m_rom = machine().root_device().memregion("maincpu")->base();
43   m_ciram = machine().root_device().memregion("ciram")->base();
4644   // other pointers got set in the loading routine
4745
4846   /* Brutal hack put in as a consequence of the new memory system; we really need to fix the NES code */
4947   space.install_readwrite_bank(0x0000, 0x07ff, 0, 0x1800, "bank10");
5048
51   machine.device("ppu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0, 0x1fff, FUNC(nes_chr_r), FUNC(nes_chr_w));
52   machine.device("ppu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x2000, 0x3eff, FUNC(nes_nt_r), FUNC(nes_nt_w));
49   machine().device("ppu")->memory().space(AS_PROGRAM).install_readwrite_handler(0, 0x1fff, read8_delegate(FUNC(nes_state::nes_chr_r),this), write8_delegate(FUNC(nes_state::nes_chr_w),this));
50   machine().device("ppu")->memory().space(AS_PROGRAM).install_readwrite_handler(0x2000, 0x3eff, read8_delegate(FUNC(nes_state::nes_nt_r),this), write8_delegate(FUNC(nes_state::nes_nt_w),this));
5351
54   state->membank("bank10")->set_base(state->m_rom);
52   membank("bank10")->set_base(m_rom);
5553
5654   /* If there is Disk Expansion and no cart has been loaded, setup memory accordingly */
57   if (state->m_disk_expansion && state->m_pcb_id == NO_BOARD)
55   if (m_disk_expansion && m_pcb_id == NO_BOARD)
5856   {
59      /* If we are loading a disk we have already filled state->m_fds_data and we don't want to overwrite it,
57      /* If we are loading a disk we have already filled m_fds_data and we don't want to overwrite it,
6058         if we are loading a cart image identified as mapper 20 (probably wrong mapper...) we need to alloc
6159         memory for use in nes_fds_r/nes_fds_w. Same goes for allocation of fds_ram (used for bank2)  */
62      if (state->m_fds_data == NULL)
60      if (m_fds_data == NULL)
6361      {
64         UINT32 size = (state->m_prg_chunks == 1) ? 2 * 0x4000 : state->m_prg_chunks * 0x4000;
65         state->m_fds_data = auto_alloc_array_clear(machine, UINT8, size);
66         memcpy(state->m_fds_data, state->m_prg, size);   // copy in fds_data the cart PRG
62         UINT32 size = (m_prg_chunks == 1) ? 2 * 0x4000 : m_prg_chunks * 0x4000;
63         m_fds_data = auto_alloc_array_clear(machine(), UINT8, size);
64         memcpy(m_fds_data, m_prg, size);   // copy in fds_data the cart PRG
6765      }
68      if (state->m_fds_ram == NULL)
69         state->m_fds_ram = auto_alloc_array(machine, UINT8, 0x8000);
66      if (m_fds_ram == NULL)
67         m_fds_ram = auto_alloc_array(machine(), UINT8, 0x8000);
7068
71      space.install_read_handler(0x4030, 0x403f, read8_delegate(FUNC(nes_state::nes_fds_r),state));
69      space.install_read_handler(0x4030, 0x403f, read8_delegate(FUNC(nes_state::nes_fds_r),this));
7270      space.install_read_bank(0x6000, 0xdfff, "bank2");
7371      space.install_read_bank(0xe000, 0xffff, "bank1");
7472
75      space.install_write_handler(0x4020, 0x402f, write8_delegate(FUNC(nes_state::nes_fds_w),state));
73      space.install_write_handler(0x4020, 0x402f, write8_delegate(FUNC(nes_state::nes_fds_w),this));
7674      space.install_write_bank(0x6000, 0xdfff, "bank2");
7775
78      state->membank("bank1")->set_base(&state->m_rom[0xe000]);
79      state->membank("bank2")->set_base(state->m_fds_ram);
76      membank("bank1")->set_base(&m_rom[0xe000]);
77      membank("bank2")->set_base(m_fds_ram);
8078      return;
8179   }
8280
8381   /* Set up the mapper callbacks */
84   pcb_handlers_setup(machine);
82   pcb_handlers_setup(machine());
8583
8684   /* Set up the memory handlers for the mapper */
8785   space.install_read_bank(0x8000, 0x9fff, "bank1");
r18063r18064
9391   /* configure banks 1-4 */
9492   for (i = 0; i < 4; i++)
9593   {
96      state->membank(bank_names[i])->configure_entries(0, prg_banks, state->m_prg, 0x2000);
94      membank(bank_names[i])->configure_entries(0, prg_banks, m_prg, 0x2000);
9795      // some mappers (e.g. MMC5) can map PRG RAM in  0x8000-0xffff as well
98      if (state->m_prg_ram)
99         state->membank(bank_names[i])->configure_entries(prg_banks, state->m_wram_size / 0x2000, state->m_wram, 0x2000);
96      if (m_prg_ram)
97         membank(bank_names[i])->configure_entries(prg_banks, m_wram_size / 0x2000, m_wram, 0x2000);
10098      // however, at start we point to PRG ROM
101      state->membank(bank_names[i])->set_entry(i);
102      state->m_prg_bank[i] = i;
99      membank(bank_names[i])->set_entry(i);
100      m_prg_bank[i] = i;
103101   }
104102
105103   /* bank 5 configuration is more delicate, since it can have PRG RAM, PRG ROM or SRAM mapped to it */
106   /* we first map PRG ROM banks, then the battery bank (if a battery is present), and finally PRG RAM (state->m_wram) */
107   state->membank("bank5")->configure_entries(0, prg_banks, state->m_prg, 0x2000);
108   state->m_battery_bank5_start = prg_banks;
109   state->m_prgram_bank5_start = prg_banks;
110   state->m_empty_bank5_start = prg_banks;
104   /* we first map PRG ROM banks, then the battery bank (if a battery is present), and finally PRG RAM (m_wram) */
105   membank("bank5")->configure_entries(0, prg_banks, m_prg, 0x2000);
106   m_battery_bank5_start = prg_banks;
107   m_prgram_bank5_start = prg_banks;
108   m_empty_bank5_start = prg_banks;
111109
112110   /* add battery ram, but only if there's no trainer since they share overlapping memory. */
113   if (state->m_battery && !state->m_trainer)
111   if (m_battery && !m_trainer)
114112   {
115      UINT32 bank_size = (state->m_battery_size > 0x2000) ? 0x2000 : state->m_battery_size;
116      int bank_num = (state->m_battery_size > 0x2000) ? state->m_battery_size / 0x2000 : 1;
117      state->membank("bank5")->configure_entries(prg_banks, bank_num, state->m_battery_ram, bank_size);
118      state->m_prgram_bank5_start += bank_num;
119      state->m_empty_bank5_start += bank_num;
113      UINT32 bank_size = (m_battery_size > 0x2000) ? 0x2000 : m_battery_size;
114      int bank_num = (m_battery_size > 0x2000) ? m_battery_size / 0x2000 : 1;
115      membank("bank5")->configure_entries(prg_banks, bank_num, m_battery_ram, bank_size);
116      m_prgram_bank5_start += bank_num;
117      m_empty_bank5_start += bank_num;
120118   }
121119   /* add prg ram. */
122   if (state->m_prg_ram)
120   if (m_prg_ram)
123121   {
124      state->membank("bank5")->configure_entries(state->m_prgram_bank5_start, state->m_wram_size / 0x2000, state->m_wram, 0x2000);
125      state->m_empty_bank5_start += state->m_wram_size / 0x2000;
122      membank("bank5")->configure_entries(m_prgram_bank5_start, m_wram_size / 0x2000, m_wram, 0x2000);
123      m_empty_bank5_start += m_wram_size / 0x2000;
126124   }
127125
128   state->membank("bank5")->configure_entry(state->m_empty_bank5_start, state->m_rom + 0x6000);
126   membank("bank5")->configure_entry(m_empty_bank5_start, m_rom + 0x6000);
129127
130128   /* if we have any additional PRG RAM, point bank5 to its first bank */
131   if (state->m_battery || state->m_prg_ram)
132      state->m_prg_bank[4] = state->m_battery_bank5_start;
129   if (m_battery || m_prg_ram)
130      m_prg_bank[4] = m_battery_bank5_start;
133131   else
134      state->m_prg_bank[4] = state->m_empty_bank5_start; // or shall we point to "maincpu" region at 0x6000? point is that we should never access this region if no sram or wram is present!
132      m_prg_bank[4] = m_empty_bank5_start; // or shall we point to "maincpu" region at 0x6000? point is that we should never access this region if no sram or wram is present!
135133
136   state->membank("bank5")->set_entry(state->m_prg_bank[4]);
134   membank("bank5")->set_entry(m_prg_bank[4]);
137135
138   if (state->m_four_screen_vram)
136   if (m_four_screen_vram)
139137   {
140      state->m_extended_ntram = auto_alloc_array_clear(machine, UINT8, 0x2000);
141      state->save_pointer(NAME(state->m_extended_ntram), 0x2000);
138      m_extended_ntram = auto_alloc_array_clear(machine(), UINT8, 0x2000);
139      save_pointer(NAME(m_extended_ntram), 0x2000);
142140   }
143141
144   if (state->m_four_screen_vram)
145      set_nt_mirroring(machine, PPU_MIRROR_4SCREEN);
142   if (m_four_screen_vram)
143      set_nt_mirroring(machine(), PPU_MIRROR_4SCREEN);
146144   else
147145   {
148      switch (state->m_hard_mirroring)
146      switch (m_hard_mirroring)
149147      {
150148         case PPU_MIRROR_HORZ:
151149         case PPU_MIRROR_VERT:
152150         case PPU_MIRROR_HIGH:
153151         case PPU_MIRROR_LOW:
154            set_nt_mirroring(machine, state->m_hard_mirroring);
152            set_nt_mirroring(machine(), m_hard_mirroring);
155153            break;
156154         default:
157            set_nt_mirroring(machine, PPU_MIRROR_NONE);
155            set_nt_mirroring(machine(), PPU_MIRROR_NONE);
158156            break;
159157      }
160158   }
161159
162160   // there are still some quirk about writes to bank5... I hope to fix them soon. (mappers 34,45,52,246 have both mid_w and WRAM-->check)
163   if (state->m_mmc_write_mid)
164      space.install_legacy_write_handler(0x6000, 0x7fff, state->m_mmc_write_mid,state->m_mmc_write_mid_name);
165   if (state->m_mmc_write)
166      space.install_legacy_write_handler(0x8000, 0xffff, state->m_mmc_write, state->m_mmc_write_name);
161   if (!m_mmc_write_mid.isnull())
162      space.install_write_handler(0x6000, 0x7fff, m_mmc_write_mid);
163   if (!m_mmc_write.isnull())
164      space.install_write_handler(0x8000, 0xffff, m_mmc_write);
167165
168166   // In fact, we also allow single pcbs to overwrite the bank read handlers defined above,
169167   // because some pcbs (mainly pirate ones) require protection values to be read instead of
170168   // the expected ROM banks: these handlers, though, must take care of the ROM access as well
171   if (state->m_mmc_read_mid)
172      space.install_legacy_read_handler(0x6000, 0x7fff, state->m_mmc_read_mid,state->m_mmc_read_mid_name);
173   if (state->m_mmc_read)
174      space.install_legacy_read_handler(0x8000, 0xffff, state->m_mmc_read,state->m_mmc_read_name);
169   if (!m_mmc_read_mid.isnull())
170      space.install_read_handler(0x6000, 0x7fff, m_mmc_read_mid);
171   if (!m_mmc_read.isnull())
172      space.install_read_handler(0x8000, 0xffff, m_mmc_read);
175173
176174   // install additional handlers
177   if (state->m_pcb_id == BTL_SMB2B || state->m_mapper == 50)
175   if (m_pcb_id == BTL_SMB2B || m_mapper == 50)
178176   {
179      space.install_legacy_write_handler(0x4020, 0x403f, FUNC(smb2jb_extra_w));
180      space.install_legacy_write_handler(0x40a0, 0x40bf, FUNC(smb2jb_extra_w));
177      space.install_write_handler(0x4020, 0x403f, write8_delegate(FUNC(nes_state::smb2jb_extra_w),this));
178      space.install_write_handler(0x40a0, 0x40bf, write8_delegate(FUNC(nes_state::smb2jb_extra_w),this));
181179   }
182180
183   if (state->m_pcb_id == KAISER_KS7017)
181   if (m_pcb_id == KAISER_KS7017)
184182   {
185      space.install_legacy_read_handler(0x4030, 0x4030, FUNC(ks7017_extra_r));
186      space.install_legacy_write_handler(0x4020, 0x40ff, FUNC(ks7017_extra_w));
183      space.install_read_handler(0x4030, 0x4030, read8_delegate(FUNC(nes_state::ks7017_extra_r),this));
184      space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_state::ks7017_extra_w),this));
187185   }
188186
189   if (state->m_pcb_id == UNL_603_5052)
187   if (m_pcb_id == UNL_603_5052)
190188   {
191      space.install_legacy_read_handler(0x4020, 0x40ff, FUNC(unl_6035052_extra_r));
192      space.install_legacy_write_handler(0x4020, 0x40ff, FUNC(unl_6035052_extra_w));
189      space.install_read_handler(0x4020, 0x40ff, read8_delegate(FUNC(nes_state::unl_6035052_extra_r),this));
190      space.install_write_handler(0x4020, 0x40ff, write8_delegate(FUNC(nes_state::unl_6035052_extra_w),this));
193191   }
194192
195   if (state->m_pcb_id == WAIXING_SH2)
196      machine.device("ppu")->memory().space(AS_PROGRAM).install_legacy_read_handler(0, 0x1fff, FUNC(waixing_sh2_chr_r));
193   if (m_pcb_id == WAIXING_SH2)
194      machine().device("ppu")->memory().space(AS_PROGRAM).install_read_handler(0, 0x1fff, read8_delegate(FUNC(nes_state::waixing_sh2_chr_r),this));
197195}
198196
199197// to be probably removed (it does nothing since a long time)
r18063r18064
291289{
292290
293291   m_ppu = machine().device<ppu2c0x_device>("ppu");
294   init_nes_core(machine());
292   init_nes_core();
295293   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(nes_machine_stop),&machine()));
296294
297295   m_maincpu = machine().device<cpu_device>("maincpu");
trunk/src/mess/machine/nes_mmc.c
r18063r18064
137137#define LOG_FDS(x) do { if (VERBOSE) logerror x; } while (0)
138138
139139static void ffe_irq( device_t *device, int scanline, int vblank, int blanked );
140static DECLARE_WRITE8_HANDLER( mapper6_l_w );
141static DECLARE_WRITE8_HANDLER( mapper6_w );
142static DECLARE_WRITE8_HANDLER( mapper8_w );
143static DECLARE_WRITE8_HANDLER( mapper17_l_w );
144140
145141/*************************************************************
146142
r18063r18064
165161
166162*************************************************************/
167163
168WRITE8_HANDLER( nes_chr_w )
164WRITE8_MEMBER(nes_state::nes_chr_w)
169165{
170   nes_state *state = space.machine().driver_data<nes_state>();
171166   int bank = offset >> 10;
172167
173   if (state->m_chr_map[bank].source == CHRRAM)
168   if (m_chr_map[bank].source == CHRRAM)
174169   {
175      state->m_chr_map[bank].access[offset & 0x3ff] = data;
170      m_chr_map[bank].access[offset & 0x3ff] = data;
176171   }
177172}
178173
179READ8_HANDLER( nes_chr_r )
174READ8_MEMBER(nes_state::nes_chr_r)
180175{
181   nes_state *state = space.machine().driver_data<nes_state>();
182176   int bank = offset >> 10;
183177
184178   // a few CNROM boards contained copy protection schemes through
185179   // suitably configured diodes, so that subsequent CHR reads can
186180   // give actual VROM content or open bus values.
187181   // For most boards, chr_open_bus remains always zero.
188   if (state->m_chr_open_bus)
182   if (m_chr_open_bus)
189183      return 0xff;
190184
191   return state->m_chr_map[bank].access[offset & 0x3ff];
185   return m_chr_map[bank].access[offset & 0x3ff];
192186}
193187
194WRITE8_HANDLER( nes_nt_w )
188WRITE8_MEMBER(nes_state::nes_nt_w)
195189{
196   nes_state *state = space.machine().driver_data<nes_state>();
197190   int page = ((offset & 0xc00) >> 10);
198191
199   if (state->m_nt_page[page].writable == 0)
192   if (m_nt_page[page].writable == 0)
200193      return;
201194
202   state->m_nt_page[page].access[offset & 0x3ff] = data;
195   m_nt_page[page].access[offset & 0x3ff] = data;
203196}
204197
205READ8_HANDLER( nes_nt_r )
198READ8_MEMBER(nes_state::nes_nt_r)
206199{
207   nes_state *state = space.machine().driver_data<nes_state>();
208200   int page = ((offset & 0xc00) >> 10);
209201
210   if (state->m_nt_page[page].source == MMC5FILL)
202   if (m_nt_page[page].source == MMC5FILL)
211203   {
212204      if ((offset & 0x3ff) >= 0x3c0)
213         return state->m_MMC5_floodattr;
205         return m_MMC5_floodattr;
214206
215      return state->m_MMC5_floodtile;
207      return m_MMC5_floodtile;
216208   }
217   return state->m_nt_page[page].access[offset & 0x3ff];
209   return m_nt_page[page].access[offset & 0x3ff];
218210}
219211
220WRITE8_HANDLER( nes_low_mapper_w )
212WRITE8_MEMBER(nes_state::nes_low_mapper_w)
221213{
222   nes_state *state = space.machine().driver_data<nes_state>();
223214
224   if (state->m_mmc_write_low)
225      (*state->m_mmc_write_low)(space, offset, data, mem_mask);
215   if (!m_mmc_write_low.isnull())
216      (m_mmc_write_low)(space, offset, data, mem_mask);
226217   else
227218      logerror("Unimplemented LOW mapper write, offset: %04x, data: %02x\n", offset + 0x4100, data);
228219}
229220
230READ8_HANDLER( nes_low_mapper_r )
221READ8_MEMBER(nes_state::nes_low_mapper_r)
231222{
232   nes_state *state = space.machine().driver_data<nes_state>();
233223
234   if (state->m_mmc_read_low)
235      return (*state->m_mmc_read_low)(space, offset, mem_mask);
224   if (!m_mmc_read_low.isnull())
225      return (m_mmc_read_low)(space, offset, mem_mask);
236226   else
237227      logerror("Unimplemented LOW mapper read, offset: %04x\n", offset + 0x4100);
238228
trunk/src/mess/machine/nes_mmc.h
r18063r18064
116116void pcb_handlers_setup(running_machine &machine);
117117int nes_pcb_reset(running_machine &machine);
118118
119
120DECLARE_WRITE8_HANDLER( nes_low_mapper_w );
121DECLARE_READ8_HANDLER( nes_low_mapper_r );
122DECLARE_WRITE8_HANDLER( nes_chr_w );
123DECLARE_READ8_HANDLER( nes_chr_r );
124DECLARE_WRITE8_HANDLER( nes_nt_w );
125DECLARE_READ8_HANDLER( nes_nt_r );
126
127DECLARE_WRITE8_HANDLER( smb2jb_extra_w );
128DECLARE_WRITE8_HANDLER( ks7017_extra_w );
129DECLARE_READ8_HANDLER( ks7017_extra_r );
130DECLARE_WRITE8_HANDLER( unl_6035052_extra_w );
131DECLARE_READ8_HANDLER( unl_6035052_extra_r );
132DECLARE_READ8_HANDLER( waixing_sh2_chr_r );
133
134119//TEMPORARY PPU STUFF
135120
136121/* mirroring types */
trunk/src/mess/machine/nes_ines.c
r18063r18064
4545   }
4646}
4747
48static WRITE8_HANDLER( mapper6_l_w )
48WRITE8_MEMBER(nes_state::mapper6_l_w)
4949{
50   nes_state *state = space.machine().driver_data<nes_state>();
5150   LOG_MMC(("mapper6_l_w, offset: %04x, data: %02x\n", offset, data));
5251
5352   switch (offset)
5453   {
5554      case 0x1fe:
56         state->m_mmc_latch1 = data & 0x80;
57         set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
55         m_mmc_latch1 = data & 0x80;
56         set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
5857         break;
5958      case 0x1ff:
60         set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
59         set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6160         break;
6261
6362      case 0x401:
64         state->m_IRQ_enable = data & 0x01;
63         m_IRQ_enable = data & 0x01;
6564         break;
6665      case 0x402:
67         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
66         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
6867         break;
6968      case 0x403:
70         state->m_IRQ_enable = 1;
71         state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
69         m_IRQ_enable = 1;
70         m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
7271         break;
7372   }
7473}
7574
76static WRITE8_HANDLER( mapper6_w )
75WRITE8_MEMBER(nes_state::mapper6_w)
7776{
78   nes_state *state = space.machine().driver_data<nes_state>();
7977   LOG_MMC(("mapper6_w, offset: %04x, data: %02x\n", offset, data));
8078
81   if (!state->m_mmc_latch1)   // when in "FFE mode" we are forced to use CHRRAM/EXRAM bank?
79   if (!m_mmc_latch1)   // when in "FFE mode" we are forced to use CHRRAM/EXRAM bank?
8280   {
83      prg16_89ab(space.machine(), data >> 2);
84      // chr8(space.machine(), data & 0x03, ???);
81      prg16_89ab(machine(), data >> 2);
82      // chr8(machine(), data & 0x03, ???);
8583      // due to lack of info on the exact behavior, we simply act as if mmc_latch1=1
86      if (state->m_mmc_chr_source == CHRROM)
87         chr8(space.machine(), data & 0x03, CHRROM);
84      if (m_mmc_chr_source == CHRROM)
85         chr8(machine(), data & 0x03, CHRROM);
8886   }
89   else if (state->m_mmc_chr_source == CHRROM)         // otherwise, we can use CHRROM (when present)
90      chr8(space.machine(), data, CHRROM);
87   else if (m_mmc_chr_source == CHRROM)         // otherwise, we can use CHRROM (when present)
88      chr8(machine(), data, CHRROM);
9189}
9290
9391/*************************************************************
r18063r18064
10199
102100*************************************************************/
103101
104static WRITE8_HANDLER( mapper8_w )
102WRITE8_MEMBER(nes_state::mapper8_w)
105103{
106104   LOG_MMC(("mapper8_w, offset: %04x, data: %02x\n", offset, data));
107105
108   chr8(space.machine(), data & 0x07, CHRROM);
109   prg16_89ab(space.machine(), data >> 3);
106   chr8(machine(), data & 0x07, CHRROM);
107   prg16_89ab(machine(), data >> 3);
110108}
111109
112110/*************************************************************
r18063r18064
121119
122120*************************************************************/
123121
124static WRITE8_HANDLER( mapper17_l_w )
122WRITE8_MEMBER(nes_state::mapper17_l_w)
125123{
126   nes_state *state = space.machine().driver_data<nes_state>();
127124   LOG_MMC(("mapper17_l_w, offset: %04x, data: %02x\n", offset, data));
128125
129126   switch (offset)
130127   {
131128      case 0x1fe:
132         set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
129         set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
133130         break;
134131      case 0x1ff:
135         set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
132         set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
136133         break;
137134
138135      case 0x401:
139         state->m_IRQ_enable = data & 0x01;
136         m_IRQ_enable = data & 0x01;
140137         break;
141138      case 0x402:
142         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
139         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
143140         break;
144141      case 0x403:
145         state->m_IRQ_enable = 1;
146         state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
142         m_IRQ_enable = 1;
143         m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
147144         break;
148145
149146      case 0x404:
150         prg8_89(space.machine(), data);
147         prg8_89(machine(), data);
151148         break;
152149      case 0x405:
153         prg8_ab(space.machine(), data);
150         prg8_ab(machine(), data);
154151         break;
155152      case 0x406:
156         prg8_cd(space.machine(), data);
153         prg8_cd(machine(), data);
157154         break;
158155      case 0x407:
159         prg8_ef(space.machine(), data);
156         prg8_ef(machine(), data);
160157         break;
161158
162159      case 0x410:
r18063r18064
167164      case 0x415:
168165      case 0x416:
169166      case 0x417:
170         chr1_x(space.machine(), offset & 7, data, CHRROM);
167         chr1_x(machine(), offset & 7, data, CHRROM);
171168         break;
172169   }
173170}
trunk/src/mess/machine/nes_pcb.c
r18063r18064
714714
715715 *************************************************************/
716716
717static WRITE8_HANDLER( uxrom_w )
717WRITE8_MEMBER(nes_state::uxrom_w)
718718{
719719   LOG_MMC(("uxrom_w, offset: %04x, data: %02x\n", offset, data));
720720
721   prg16_89ab(space.machine(), data);
721   prg16_89ab(machine(), data);
722722}
723723
724724/*************************************************************
r18063r18064
737737
738738 *************************************************************/
739739
740static WRITE8_HANDLER( uxrom_cc_w )
740WRITE8_MEMBER(nes_state::uxrom_cc_w)
741741{
742742   LOG_MMC(("uxrom_cc_w, offset: %04x, data: %02x\n", offset, data));
743743
744   prg16_cdef(space.machine(), data);
744   prg16_cdef(machine(), data);
745745}
746746
747747/*************************************************************
r18063r18064
760760
761761 *************************************************************/
762762
763static WRITE8_HANDLER( un1rom_w )
763WRITE8_MEMBER(nes_state::un1rom_w)
764764{
765765   LOG_MMC(("un1rom_w, offset: %04x, data: %02x\n", offset, data));
766766
767   prg16_89ab(space.machine(), data >> 2);
767   prg16_89ab(machine(), data >> 2);
768768}
769769
770770/*************************************************************
r18063r18064
791791
792792 *************************************************************/
793793
794static WRITE8_HANDLER( cnrom_w )
794WRITE8_MEMBER(nes_state::cnrom_w)
795795{
796   nes_state *state = space.machine().driver_data<nes_state>();
797796   LOG_MMC(("cnrom_w, offset: %04x, data: %02x\n", offset, data));
798797
799   if (state->m_ce_mask)
798   if (m_ce_mask)
800799   {
801      chr8(space.machine(), data & ~state->m_ce_mask, CHRROM);
800      chr8(machine(), data & ~m_ce_mask, CHRROM);
802801
803      if ((data & state->m_ce_mask) == state->m_ce_state)
804         state->m_chr_open_bus = 0;
802      if ((data & m_ce_mask) == m_ce_state)
803         m_chr_open_bus = 0;
805804      else
806         state->m_chr_open_bus = 1;
805         m_chr_open_bus = 1;
807806   }
808807   else
809      chr8(space.machine(), data, CHRROM);
808      chr8(machine(), data, CHRROM);
810809}
811810
812811/*************************************************************
r18063r18064
821820
822821 *************************************************************/
823822
824static WRITE8_HANDLER( bandai_pt554_m_w )
823WRITE8_MEMBER(nes_state::bandai_pt554_m_w)
825824{
826825   LOG_MMC(("Bandai PT-554 Sound write, data: %02x\n", data));
827826
r18063r18064
846845
847846 *************************************************************/
848847
849static WRITE8_HANDLER( cprom_w )
848WRITE8_MEMBER(nes_state::cprom_w)
850849{
851850   LOG_MMC(("cprom_w, offset: %04x, data: %02x\n", offset, data));
852   chr4_4(space.machine(), data, CHRRAM);
851   chr4_4(machine(), data, CHRRAM);
853852}
854853
855854/*************************************************************
r18063r18064
868867
869868 *************************************************************/
870869
871static WRITE8_HANDLER( axrom_w )
870WRITE8_MEMBER(nes_state::axrom_w)
872871{
873872   LOG_MMC(("axrom_w, offset: %04x, data: %02x\n", offset, data));
874873
875   set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
876   prg32(space.machine(), data);
874   set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
875   prg32(machine(), data);
877876}
878877
879878/*************************************************************
r18063r18064
888887
889888 *************************************************************/
890889
891static WRITE8_HANDLER( bxrom_w )
890WRITE8_MEMBER(nes_state::bxrom_w)
892891{
893892   /* This portion of the mapper is nearly identical to Mapper 7, except no one-screen mirroring */
894893   /* Deadly Towers is really a BxROM game - the demo screens look wrong using mapper 7. */
895894   LOG_MMC(("bxrom_w, offset: %04x, data: %02x\n", offset, data));
896895
897   prg32(space.machine(), data);
896   prg32(machine(), data);
898897}
899898
900899/*************************************************************
r18063r18064
909908
910909 *************************************************************/
911910
912static WRITE8_HANDLER( gxrom_w )
911WRITE8_MEMBER(nes_state::gxrom_w)
913912{
914913   LOG_MMC(("gxrom_w, offset %04x, data: %02x\n", offset, data));
915914
916   prg32(space.machine(), (data & 0xf0) >> 4);
917   chr8(space.machine(), data & 0x0f, CHRROM);
915   prg32(machine(), (data & 0xf0) >> 4);
916   chr8(machine(), data & 0x0f, CHRROM);
918917}
919918
920919/*************************************************************
r18063r18064
11011100   }
11021101}
11031102
1104static WRITE8_HANDLER( sxrom_w )
1103WRITE8_MEMBER(nes_state::sxrom_w)
11051104{
1106   nes_state *state = space.machine().driver_data<nes_state>();
11071105
11081106   LOG_MMC(("sxrom_w, offset: %04x, data: %02x\n", offset, data));
1109   common_sxrom_write_handler(space, offset, data, state->m_pcb_id);
1107   common_sxrom_write_handler(space, offset, data, m_pcb_id);
11101108}
11111109
11121110/*************************************************************
r18063r18064
11501148   }
11511149}
11521150
1153static WRITE8_HANDLER( pxrom_w )
1151WRITE8_MEMBER(nes_state::pxrom_w)
11541152{
1155   nes_state *state = space.machine().driver_data<nes_state>();
11561153   LOG_MMC(("pxrom_w, offset: %04x, data: %02x\n", offset, data));
11571154   switch (offset & 0x7000)
11581155   {
11591156      case 0x2000:
1160         prg8_89(space.machine(), data);
1157         prg8_89(machine(), data);
11611158         break;
11621159      case 0x3000:
1163         state->m_mmc_reg[0] = data;
1164         if (state->m_mmc_latch1 == 0xfd)
1165            chr4_0(space.machine(), state->m_mmc_reg[0], CHRROM);
1160         m_mmc_reg[0] = data;
1161         if (m_mmc_latch1 == 0xfd)
1162            chr4_0(machine(), m_mmc_reg[0], CHRROM);
11661163         break;
11671164      case 0x4000:
1168         state->m_mmc_reg[1] = data;
1169         if (state->m_mmc_latch1 == 0xfe)
1170            chr4_0(space.machine(), state->m_mmc_reg[1], CHRROM);
1165         m_mmc_reg[1] = data;
1166         if (m_mmc_latch1 == 0xfe)
1167            chr4_0(machine(), m_mmc_reg[1], CHRROM);
11711168         break;
11721169      case 0x5000:
1173         state->m_mmc_reg[2] = data;
1174         if (state->m_mmc_latch2 == 0xfd)
1175            chr4_4(space.machine(), state->m_mmc_reg[2], CHRROM);
1170         m_mmc_reg[2] = data;
1171         if (m_mmc_latch2 == 0xfd)
1172            chr4_4(machine(), m_mmc_reg[2], CHRROM);
11761173         break;
11771174      case 0x6000:
1178         state->m_mmc_reg[3] = data;
1179         if (state->m_mmc_latch2 == 0xfe)
1180            chr4_4(space.machine(), state->m_mmc_reg[3], CHRROM);
1175         m_mmc_reg[3] = data;
1176         if (m_mmc_latch2 == 0xfe)
1177            chr4_4(machine(), m_mmc_reg[3], CHRROM);
11811178         break;
11821179      case 0x7000:
1183         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1180         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
11841181         break;
11851182      default:
11861183         LOG_MMC(("MMC2 uncaught w: %04x:%02x\n", offset, data));
r18063r18064
12001197
12011198*************************************************************/
12021199
1203static WRITE8_HANDLER( fxrom_w )
1200WRITE8_MEMBER(nes_state::fxrom_w)
12041201{
12051202   LOG_MMC(("fxrom_w, offset: %04x, data: %02x\n", offset, data));
12061203   switch (offset & 0x7000)
12071204   {
12081205      case 0x2000:
1209         prg16_89ab(space.machine(), data);
1206         prg16_89ab(machine(), data);
12101207         break;
12111208      default:
12121209         pxrom_w(space, offset, data, mem_mask);
r18063r18064
12281225   nes_state *state = machine.driver_data<nes_state>();
12291226
12301227   // skip this function if we are emulating a MMC3 clone with mid writes
1231   if (state->m_mmc_write_mid != NULL)
1228   if (!state->m_mmc_write_mid.isnull())
12321229      return;
12331230
12341231   if (BIT(state->m_mmc3_wram_protect, 7))
r18063r18064
12971294   state->m_IRQ_clear = 0;
12981295}
12991296
1300static WRITE8_HANDLER( txrom_w )
1297WRITE8_MEMBER(nes_state::txrom_w)
13011298{
1302   nes_state *state = space.machine().driver_data<nes_state>();
13031299   UINT8 mmc_helper, cmd;
13041300
13051301   LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data));
r18063r18064
13071303   switch (offset & 0x6001)
13081304   {
13091305      case 0x0000:
1310         mmc_helper = state->m_mmc3_latch ^ data;
1311         state->m_mmc3_latch = data;
1306         mmc_helper = m_mmc3_latch ^ data;
1307         m_mmc3_latch = data;
13121308
13131309         /* Has PRG Mode changed? */
13141310         if (mmc_helper & 0x40)
1315            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1311            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
13161312
13171313         /* Has CHR Mode changed? */
13181314         if (mmc_helper & 0x80)
1319            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
1315            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
13201316         break;
13211317
13221318      case 0x0001:
1323         cmd = state->m_mmc3_latch & 0x07;
1319         cmd = m_mmc3_latch & 0x07;
13241320         switch (cmd)
13251321         {
13261322         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
13271323         case 2: case 3: case 4: case 5:
1328            state->m_mmc_vrom_bank[cmd] = data;
1329            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
1324            m_mmc_vrom_bank[cmd] = data;
1325            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
13301326            break;
13311327         case 6:
13321328         case 7:
1333            state->m_mmc_prg_bank[cmd - 6] = data;
1334            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1329            m_mmc_prg_bank[cmd - 6] = data;
1330            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
13351331            break;
13361332         }
13371333         break;
13381334
13391335      case 0x2000:
1340         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1336         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
13411337         break;
13421338
13431339      case 0x2001:
1344         state->m_mmc3_wram_protect = data;
1340         m_mmc3_wram_protect = data;
13451341         mmc3_set_wram(space);
13461342         break;
13471343
13481344      case 0x4000:
1349         state->m_IRQ_count_latch = data;
1345         m_IRQ_count_latch = data;
13501346         break;
13511347
13521348      case 0x4001:
1353         state->m_IRQ_count = 0;
1349         m_IRQ_count = 0;
13541350         break;
13551351
13561352      case 0x6000:
1357         state->m_IRQ_enable = 0;
1353         m_IRQ_enable = 0;
13581354         break;
13591355
13601356      case 0x6001:
1361         state->m_IRQ_enable = 1;
1357         m_IRQ_enable = 1;
13621358         break;
13631359
13641360      default:
r18063r18064
13751371
13761372 *************************************************************/
13771373
1378static WRITE8_HANDLER( hkrom_m_w )
1374WRITE8_MEMBER(nes_state::hkrom_m_w)
13791375{
1380   nes_state *state = space.machine().driver_data<nes_state>();
13811376   UINT8 write_hi, write_lo;
13821377   LOG_MMC(("hkrom_m_w, offset: %04x, data: %02x\n", offset, data));
13831378
r18063r18064
13851380      return;
13861381
13871382   // banks can be written only if both read & write is enabled!
1388   write_hi = ((state->m_mmc6_reg & 0xc0) == 0xc0);
1389   write_lo = ((state->m_mmc6_reg & 0x30) == 0x30);
1383   write_hi = ((m_mmc6_reg & 0xc0) == 0xc0);
1384   write_lo = ((m_mmc6_reg & 0x30) == 0x30);
13901385
13911386   if (BIT(offset, 9) && write_hi)   // access to upper 1k
1392      state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)] = data;
1387      m_mapper_bram[offset & (m_mapper_bram_size - 1)] = data;
13931388
13941389   if (!BIT(offset, 9) && write_lo)   // access to lower 1k
1395      state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)] = data;
1390      m_mapper_bram[offset & (m_mapper_bram_size - 1)] = data;
13961391}
13971392
1398static READ8_HANDLER( hkrom_m_r )
1393READ8_MEMBER(nes_state::hkrom_m_r)
13991394{
1400   nes_state *state = space.machine().driver_data<nes_state>();
14011395   LOG_MMC(("hkrom_m_r, offset: %04x\n", offset));
14021396
14031397   if (offset < 0x1000)
14041398      return 0xff;   // here it should be open bus
14051399
1406   if (!(state->m_mmc6_reg & 0xa0))
1400   if (!(m_mmc6_reg & 0xa0))
14071401      return 0xff;   // here it should be open bus
14081402
1409   if (BIT(offset, 9) && BIT(state->m_mmc6_reg, 7))   // access to upper 1k when upper read is enabled
1410      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
1403   if (BIT(offset, 9) && BIT(m_mmc6_reg, 7))   // access to upper 1k when upper read is enabled
1404      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
14111405
1412   if (!BIT(offset, 9) && BIT(state->m_mmc6_reg, 5))   // access to lower 1k when lower read is enabled
1413      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
1406   if (!BIT(offset, 9) && BIT(m_mmc6_reg, 5))   // access to lower 1k when lower read is enabled
1407      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
14141408
14151409   // If only one bank is enabled for reading, the other reads back as zero
14161410   return 0x00;
14171411}
14181412
1419static WRITE8_HANDLER( hkrom_w )
1413WRITE8_MEMBER(nes_state::hkrom_w)
14201414{
1421   nes_state *state = space.machine().driver_data<nes_state>();
14221415   UINT8 mmc6_helper;
14231416   LOG_MMC(("hkrom_w, offset: %04x, data: %02x\n", offset, data));
14241417
14251418   switch (offset & 0x6001)
14261419   {
14271420      case 0x0000:
1428         mmc6_helper = state->m_mmc3_latch ^ data;
1429         state->m_mmc3_latch = data;
1421         mmc6_helper = m_mmc3_latch ^ data;
1422         m_mmc3_latch = data;
14301423
1431         if (!state->m_mmc_latch2 && BIT(data, 5))   // if WRAM is disabled and has to be enabled, write
1432            state->m_mmc_latch2 = BIT(data, 5);   // (once WRAM has been enabled, it cannot be disabled without resetting the game)
1424         if (!m_mmc_latch2 && BIT(data, 5))   // if WRAM is disabled and has to be enabled, write
1425            m_mmc_latch2 = BIT(data, 5);   // (once WRAM has been enabled, it cannot be disabled without resetting the game)
14331426
14341427         /* Has PRG Mode changed? */
14351428         if (BIT(mmc6_helper, 6))
1436            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1429            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
14371430
14381431         /* Has CHR Mode changed? */
14391432         if (BIT(mmc6_helper, 7))
1440            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
1433            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
14411434         break;
14421435
14431436      case 0x2001:
1444         if (state->m_mmc_latch2)
1445            state->m_mmc6_reg = data;
1437         if (m_mmc_latch2)
1438            m_mmc6_reg = data;
14461439         break;
14471440
14481441      case 0x4001:
1449         state->m_IRQ_count = 0;
1450         state->m_IRQ_clear = 1;
1442         m_IRQ_count = 0;
1443         m_IRQ_clear = 1;
14511444         break;
14521445
14531446      default:
r18063r18064
14941487   chr1_x(machine, start, bank, source);
14951488}
14961489
1497static WRITE8_HANDLER( txsrom_w )
1490WRITE8_MEMBER(nes_state::txsrom_w)
14981491{
14991492   LOG_MMC(("txsrom_w, offset: %04x, data: %02x\n", offset, data));
15001493
r18063r18064
15441537   chr1_x(machine, chr_page ^ 7, (state->m_mmc_vrom_bank[5] & chr_mask[5]), chr_src[5]);
15451538}
15461539
1547static WRITE8_HANDLER( tqrom_w )
1540WRITE8_MEMBER(nes_state::tqrom_w)
15481541{
1549   nes_state *state = space.machine().driver_data<nes_state>();
15501542   UINT8 mmc_helper, cmd;
15511543   LOG_MMC(("tqrom_w, offset: %04x, data: %02x\n", offset, data));
15521544
15531545   switch (offset & 0x6001)
15541546   {
15551547      case 0x0000:
1556         mmc_helper = state->m_mmc3_latch ^ data;
1557         state->m_mmc3_latch = data;
1548         mmc_helper = m_mmc3_latch ^ data;
1549         m_mmc3_latch = data;
15581550
15591551         /* Has PRG Mode changed? */
15601552         if (mmc_helper & 0x40)
1561            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1553            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
15621554
15631555         /* Has CHR Mode changed? */
15641556         if (mmc_helper & 0x80)
1565            tqrom_set_chr(space.machine());
1557            tqrom_set_chr(machine());
15661558         break;
15671559      case 0x0001: /* $8001 */
1568         cmd = state->m_mmc3_latch & 0x07;
1560         cmd = m_mmc3_latch & 0x07;
15691561         switch (cmd)
15701562         {
15711563         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
15721564         case 2: case 3: case 4: case 5:
1573            state->m_mmc_vrom_bank[cmd] = data;
1574            tqrom_set_chr(space.machine());
1565            m_mmc_vrom_bank[cmd] = data;
1566            tqrom_set_chr(machine());
15751567            break;
15761568         case 6:
15771569         case 7:
1578            state->m_mmc_prg_bank[cmd - 6] = data;
1579            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1570            m_mmc_prg_bank[cmd - 6] = data;
1571            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
15801572            break;
15811573         }
15821574         break;
r18063r18064
15961588
15971589 *************************************************************/
15981590
1599static WRITE8_HANDLER( zz_m_w )
1591WRITE8_MEMBER(nes_state::zz_m_w)
16001592{
1601   nes_state *state = space.machine().driver_data<nes_state>();
16021593   UINT8 mmc_helper = data & 0x07;
16031594   LOG_MMC(("zz_m_w, offset: %04x, data: %02x\n", offset, data));
16041595
1605   state->m_mmc_prg_base = (BIT(mmc_helper, 2) << 4) | (((mmc_helper & 0x03) == 0x03) ? 0x08 : 0);
1606   state->m_mmc_prg_mask = (mmc_helper << 1) | 0x07;
1607   state->m_mmc_chr_base = BIT(mmc_helper, 2) << 7;
1608   state->m_mmc_chr_mask = 0x7f;
1609   mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1610   mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
1596   m_mmc_prg_base = (BIT(mmc_helper, 2) << 4) | (((mmc_helper & 0x03) == 0x03) ? 0x08 : 0);
1597   m_mmc_prg_mask = (mmc_helper << 1) | 0x07;
1598   m_mmc_chr_base = BIT(mmc_helper, 2) << 7;
1599   m_mmc_chr_mask = 0x7f;
1600   mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1601   mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
16111602}
16121603
16131604/*************************************************************
r18063r18064
16191610
16201611 *************************************************************/
16211612
1622static WRITE8_HANDLER( qj_m_w )
1613WRITE8_MEMBER(nes_state::qj_m_w)
16231614{
1624   nes_state *state = space.machine().driver_data<nes_state>();
16251615   LOG_MMC(("qj_m_w, offset: %04x, data: %02x\n", offset, data));
16261616
1627   state->m_mmc_prg_base = BIT(data, 0) << 4;
1628   state->m_mmc_prg_mask = 0x0f;
1629   state->m_mmc_chr_base = BIT(data, 0) << 7;
1630   state->m_mmc_chr_mask = 0x7f;
1631   mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
1632   mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
1617   m_mmc_prg_base = BIT(data, 0) << 4;
1618   m_mmc_prg_mask = 0x0f;
1619   m_mmc_chr_base = BIT(data, 0) << 7;
1620   m_mmc_chr_mask = 0x7f;
1621   mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1622   mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
16331623}
16341624
16351625/*************************************************************
r18063r18064
18561846   }
18571847}
18581848
1859static READ8_HANDLER( exrom_l_r )
1849READ8_MEMBER(nes_state::exrom_l_r)
18601850{
1861   nes_state *state = space.machine().driver_data<nes_state>();
18621851   int retVal;
18631852
18641853   /* $5c00 - $5fff: extended videoram attributes */
18651854   if ((offset >= 0x1b00) && (offset <= 0x1eff))
18661855   {
1867      return state->m_mapper_ram[offset - 0x1b00];
1856      return m_mapper_ram[offset - 0x1b00];
18681857   }
18691858
18701859   switch (offset)
r18063r18064
18761865         else
18771866            return 0x00;
18781867#else
1879         retVal = state->m_IRQ_status;
1880         state->m_IRQ_status &= ~0x80;
1868         retVal = m_IRQ_status;
1869         m_IRQ_status &= ~0x80;
18811870         return retVal;
18821871#endif
18831872
18841873      case 0x1105: /* $5205 */
1885         return (state->m_mult1 * state->m_mult2) & 0xff;
1874         return (m_mult1 * m_mult2) & 0xff;
18861875      case 0x1106: /* $5206 */
1887         return ((state->m_mult1 * state->m_mult2) & 0xff00) >> 8;
1876         return ((m_mult1 * m_mult2) & 0xff00) >> 8;
18881877
18891878      default:
18901879         logerror("** MMC5 uncaught read, offset: %04x\n", offset + 0x4100);
r18063r18064
18931882}
18941883
18951884
1896static WRITE8_HANDLER( exrom_l_w )
1885WRITE8_MEMBER(nes_state::exrom_l_w)
18971886{
1898   nes_state *state = space.machine().driver_data<nes_state>();
18991887
19001888   //  LOG_MMC(("Mapper 5 write, offset: %04x, data: %02x\n", offset + 0x4100, data));
19011889   /* Send $5000-$5015 to the sound chip */
19021890   if ((offset >= 0xf00) && (offset <= 0xf15))
19031891   {
1904      nes_psg_w(state->m_sound, space, offset & 0x1f, data);
1892      nes_psg_w(m_sound, space, offset & 0x1f, data);
19051893      return;
19061894   }
19071895
19081896   /* $5c00 - $5fff: extended videoram attributes */
19091897   if ((offset >= 0x1b00) && (offset <= 0x1eff))
19101898   {
1911      if (state->m_MMC5_vram_protect == 0x03)
1912         state->m_mapper_ram[offset - 0x1b00] = data;
1899      if (m_MMC5_vram_protect == 0x03)
1900         m_mapper_ram[offset - 0x1b00] = data;
19131901      return;
19141902   }
19151903
19161904   switch (offset)
19171905   {
19181906      case 0x1000: /* $5100 */
1919         state->m_mmc5_prg_mode = data & 0x03;
1920         //          mmc5_update_prg(space.machine());
1907         m_mmc5_prg_mode = data & 0x03;
1908         //          mmc5_update_prg(machine());
19211909         LOG_MMC(("MMC5 rom bank mode: %02x\n", data));
19221910         break;
19231911
19241912      case 0x1001: /* $5101 */
1925         state->m_mmc5_chr_mode = data & 0x03;
1913         m_mmc5_chr_mode = data & 0x03;
19261914         // update chr
19271915         LOG_MMC(("MMC5 vrom bank mode: %02x\n", data));
19281916         break;
19291917
19301918      case 0x1002: /* $5102 */
19311919         if (data == 0x02)
1932            state->m_MMC5_vram_protect |= 1;
1920            m_MMC5_vram_protect |= 1;
19331921         else
1934            state->m_MMC5_vram_protect = 0;
1922            m_MMC5_vram_protect = 0;
19351923         LOG_MMC(("MMC5 vram protect 1: %02x\n", data));
19361924         break;
19371925      case 0x1003: /* 5103 */
19381926         if (data == 0x01)
1939            state->m_MMC5_vram_protect |= 2;
1927            m_MMC5_vram_protect |= 2;
19401928         else
1941            state->m_MMC5_vram_protect = 0;
1929            m_MMC5_vram_protect = 0;
19421930         LOG_MMC(("MMC5 vram protect 2: %02x\n", data));
19431931         break;
19441932
19451933      case 0x1004: /* $5104 - Extra VRAM (EXRAM) control */
1946         state->m_mmc5_vram_control = data & 0x03;
1934         m_mmc5_vram_control = data & 0x03;
19471935         // update render
1948         mmc5_update_render_mode(space.machine());
1936         mmc5_update_render_mode(machine());
19491937         LOG_MMC(("MMC5 exram control: %02x\n", data));
19501938         break;
19511939
19521940      case 0x1005: /* $5105 */
1953         mmc5_ppu_mirror(space.machine(), 0, data & 0x03);
1954         mmc5_ppu_mirror(space.machine(), 1, (data & 0x0c) >> 2);
1955         mmc5_ppu_mirror(space.machine(), 2, (data & 0x30) >> 4);
1956         mmc5_ppu_mirror(space.machine(), 3, (data & 0xc0) >> 6);
1941         mmc5_ppu_mirror(machine(), 0, data & 0x03);
1942         mmc5_ppu_mirror(machine(), 1, (data & 0x0c) >> 2);
1943         mmc5_ppu_mirror(machine(), 2, (data & 0x30) >> 4);
1944         mmc5_ppu_mirror(machine(), 3, (data & 0xc0) >> 6);
19571945         // update render
1958         mmc5_update_render_mode(space.machine());
1946         mmc5_update_render_mode(machine());
19591947         break;
19601948
19611949         /* tile data for MMC5 flood-fill NT mode */
19621950      case 0x1006:
1963         state->m_MMC5_floodtile = data;
1951         m_MMC5_floodtile = data;
19641952         break;
19651953
19661954         /* attr data for MMC5 flood-fill NT mode */
r18063r18064
19681956         switch (data & 3)
19691957      {
19701958         default:
1971         case 0: state->m_MMC5_floodattr = 0x00; break;
1972         case 1: state->m_MMC5_floodattr = 0x55; break;
1973         case 2: state->m_MMC5_floodattr = 0xaa; break;
1974         case 3: state->m_MMC5_floodattr = 0xff; break;
1959         case 0: m_MMC5_floodattr = 0x00; break;
1960         case 1: m_MMC5_floodattr = 0x55; break;
1961         case 2: m_MMC5_floodattr = 0xaa; break;
1962         case 3: m_MMC5_floodattr = 0xff; break;
19751963      }
19761964         break;
19771965
19781966      case 0x1013: /* $5113 */
19791967         LOG_MMC(("MMC5 mid RAM bank select: %02x\n", data & 0x07));
19801968         // FIXME: a few Koei games have both WRAM & BWRAM but here we don't support this (yet)
1981         if (state->m_battery)
1982            wram_bank(space.machine(), data, NES_BATTERY);
1969         if (m_battery)
1970            wram_bank(machine(), data, NES_BATTERY);
19831971         else
1984            wram_bank(space.machine(), data, NES_WRAM);
1972            wram_bank(machine(), data, NES_WRAM);
19851973         break;
19861974
19871975
r18063r18064
19891977      case 0x1015: /* $5115 */
19901978      case 0x1016: /* $5116 */
19911979      case 0x1017: /* $5117 */
1992         state->m_mmc5_prg_regs[offset & 3] = data;
1993         mmc5_update_prg(space.machine());
1980         m_mmc5_prg_regs[offset & 3] = data;
1981         mmc5_update_prg(machine());
19941982         break;
19951983
19961984#if 0
r18063r18064
20031991      case 0x1025: /* $5125 */
20041992      case 0x1026: /* $5126 */
20051993      case 0x1027: /* $5127 */
2006         data |= (state->m_mmc5_chr_high << 8);
2007         if (!state->m_mmc5_last_chr_a)
1994         data |= (m_mmc5_chr_high << 8);
1995         if (!m_mmc5_last_chr_a)
20081996         {
2009            state->m_mmc5_vrom_regA[offset & 0x07] = data;
2010            state->m_mmc5_last_chr_a = 1;
2011            if (state->m_ppu->get_current_scanline() == 240 || !state->m_ppu->is_sprite_8x16())
2012               mmc5_update_chr_a(space.machine());
1997            m_mmc5_vrom_regA[offset & 0x07] = data;
1998            m_mmc5_last_chr_a = 1;
1999            if (m_ppu->get_current_scanline() == 240 || !m_ppu->is_sprite_8x16())
2000               mmc5_update_chr_a(machine());
20132001         }
20142002         break;
20152003
r18063r18064
20182006      case 0x1029: /* $5129 */
20192007      case 0x102a: /* $512a */
20202008      case 0x102b: /* $512b */
2021         data |= (state->m_mmc5_chr_high << 8);
2022         state->m_mmc5_vrom_regB[offset & 0x03] = data;
2023         state->m_mmc5_last_chr_a = 0;
2024         if (state->m_ppu->get_current_scanline() == 240 || !state->m_ppu->is_sprite_8x16())
2025            mmc5_update_chr_b(space.machine());
2009         data |= (m_mmc5_chr_high << 8);
2010         m_mmc5_vrom_regB[offset & 0x03] = data;
2011         m_mmc5_last_chr_a = 0;
2012         if (m_ppu->get_current_scanline() == 240 || !m_ppu->is_sprite_8x16())
2013            mmc5_update_chr_b(machine());
20262014         break;
20272015
20282016      case 0x1030: /* $5130 */
2029         state->m_mmc5_chr_high = data & 0x03;
2030         if (state->m_mmc5_vram_control == 1)
2017         m_mmc5_chr_high = data & 0x03;
2018         if (m_mmc5_vram_control == 1)
20312019         {
2032            // in this case state->m_mmc5_chr_high selects which 256KB of CHR ROM
2020            // in this case m_mmc5_chr_high selects which 256KB of CHR ROM
20332021            // is to be used for all background tiles on the screen.
20342022         }
20352023         break;
r18063r18064
20372025#endif
20382026
20392027      case 0x1020: /* $5120 */
2040         LOG_MMC(("MMC5 $5120 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2041         switch (state->m_mmc5_chr_mode)
2028         LOG_MMC(("MMC5 $5120 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2029         switch (m_mmc5_chr_mode)
20422030      {
20432031         case 0x03:
20442032            /* 1k switch */
2045            state->m_MMC5_vrom_bank[0] = data | (state->m_mmc5_high_chr << 8);
2033            m_MMC5_vrom_bank[0] = data | (m_mmc5_high_chr << 8);
20462034            //                  mapper5_sync_vrom(0);
2047            chr1_0(space.machine(), state->m_MMC5_vrom_bank[0], CHRROM);
2048            //                  state->m_nes_vram_sprite[0] = state->m_MMC5_vrom_bank[0] * 64;
2035            chr1_0(machine(), m_MMC5_vrom_bank[0], CHRROM);
2036            //                  m_nes_vram_sprite[0] = m_MMC5_vrom_bank[0] * 64;
20492037            //                  vrom_next[0] = 4;
20502038            //                  vrom_page_a = 1;
20512039            //                  vrom_page_b = 0;
r18063r18064
20532041      }
20542042         break;
20552043      case 0x1021: /* $5121 */
2056         LOG_MMC(("MMC5 $5121 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2057         switch (state->m_mmc5_chr_mode)
2044         LOG_MMC(("MMC5 $5121 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2045         switch (m_mmc5_chr_mode)
20582046      {
20592047         case 0x02:
20602048            /* 2k switch */
2061            chr2_0(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2049            chr2_0(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
20622050            break;
20632051         case 0x03:
20642052            /* 1k switch */
2065            state->m_MMC5_vrom_bank[1] = data | (state->m_mmc5_high_chr << 8);
2053            m_MMC5_vrom_bank[1] = data | (m_mmc5_high_chr << 8);
20662054            //                  mapper5_sync_vrom(0);
2067            chr1_1(space.machine(), state->m_MMC5_vrom_bank[1], CHRROM);
2068            //                  state->m_nes_vram_sprite[1] = state->m_MMC5_vrom_bank[0] * 64;
2055            chr1_1(machine(), m_MMC5_vrom_bank[1], CHRROM);
2056            //                  m_nes_vram_sprite[1] = m_MMC5_vrom_bank[0] * 64;
20692057            //                  vrom_next[1] = 5;
20702058            //                  vrom_page_a = 1;
20712059            //                  vrom_page_b = 0;
r18063r18064
20732061      }
20742062         break;
20752063      case 0x1022: /* $5122 */
2076         LOG_MMC(("MMC5 $5122 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2077         switch (state->m_mmc5_chr_mode)
2064         LOG_MMC(("MMC5 $5122 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2065         switch (m_mmc5_chr_mode)
20782066      {
20792067         case 0x03:
20802068            /* 1k switch */
2081            state->m_MMC5_vrom_bank[2] = data | (state->m_mmc5_high_chr << 8);
2069            m_MMC5_vrom_bank[2] = data | (m_mmc5_high_chr << 8);
20822070            //                  mapper5_sync_vrom(0);
2083            chr1_2(space.machine(), state->m_MMC5_vrom_bank[2], CHRROM);
2084            //                  state->m_nes_vram_sprite[2] = state->m_MMC5_vrom_bank[0] * 64;
2071            chr1_2(machine(), m_MMC5_vrom_bank[2], CHRROM);
2072            //                  m_nes_vram_sprite[2] = m_MMC5_vrom_bank[0] * 64;
20852073            //                  vrom_next[2] = 6;
20862074            //                  vrom_page_a = 1;
20872075            //                  vrom_page_b = 0;
r18063r18064
20892077      }
20902078         break;
20912079      case 0x1023: /* $5123 */
2092         LOG_MMC(("MMC5 $5123 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2093         switch (state->m_mmc5_chr_mode)
2080         LOG_MMC(("MMC5 $5123 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2081         switch (m_mmc5_chr_mode)
20942082      {
20952083         case 0x01:
2096            chr4_0(space.machine(), data, CHRROM);
2084            chr4_0(machine(), data, CHRROM);
20972085            break;
20982086         case 0x02:
20992087            /* 2k switch */
2100            chr2_2(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2088            chr2_2(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
21012089            break;
21022090         case 0x03:
21032091            /* 1k switch */
2104            state->m_MMC5_vrom_bank[3] = data | (state->m_mmc5_high_chr << 8);
2092            m_MMC5_vrom_bank[3] = data | (m_mmc5_high_chr << 8);
21052093            //                  mapper5_sync_vrom(0);
2106            chr1_3(space.machine(), state->m_MMC5_vrom_bank[3], CHRROM);
2107            //                  state->m_nes_vram_sprite[3] = state->m_MMC5_vrom_bank[0] * 64;
2094            chr1_3(machine(), m_MMC5_vrom_bank[3], CHRROM);
2095            //                  m_nes_vram_sprite[3] = m_MMC5_vrom_bank[0] * 64;
21082096            //                  vrom_next[3] = 7;
21092097            //                  vrom_page_a = 1;
21102098            //                  vrom_page_b = 0;
r18063r18064
21122100      }
21132101         break;
21142102      case 0x1024: /* $5124 */
2115         LOG_MMC(("MMC5 $5124 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2116         switch (state->m_mmc5_chr_mode)
2103         LOG_MMC(("MMC5 $5124 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2104         switch (m_mmc5_chr_mode)
21172105      {
21182106         case 0x03:
21192107            /* 1k switch */
2120            state->m_MMC5_vrom_bank[4] = data | (state->m_mmc5_high_chr << 8);
2108            m_MMC5_vrom_bank[4] = data | (m_mmc5_high_chr << 8);
21212109            //                  mapper5_sync_vrom(0);
2122            chr1_4(space.machine(), state->m_MMC5_vrom_bank[4], CHRROM);
2123            //                  state->m_nes_vram_sprite[4] = state->m_MMC5_vrom_bank[0] * 64;
2110            chr1_4(machine(), m_MMC5_vrom_bank[4], CHRROM);
2111            //                  m_nes_vram_sprite[4] = m_MMC5_vrom_bank[0] * 64;
21242112            //                  vrom_next[0] = 0;
21252113            //                  vrom_page_a = 0;
21262114            //                  vrom_page_b = 0;
r18063r18064
21282116      }
21292117         break;
21302118      case 0x1025: /* $5125 */
2131         LOG_MMC(("MMC5 $5125 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2132         switch (state->m_mmc5_chr_mode)
2119         LOG_MMC(("MMC5 $5125 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2120         switch (m_mmc5_chr_mode)
21332121      {
21342122         case 0x02:
21352123            /* 2k switch */
2136            chr2_4(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2124            chr2_4(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
21372125            break;
21382126         case 0x03:
21392127            /* 1k switch */
2140            state->m_MMC5_vrom_bank[5] = data | (state->m_mmc5_high_chr << 8);
2128            m_MMC5_vrom_bank[5] = data | (m_mmc5_high_chr << 8);
21412129            //                  mapper5_sync_vrom(0);
2142            chr1_5(space.machine(), state->m_MMC5_vrom_bank[5], CHRROM);
2143            //                  state->m_nes_vram_sprite[5] = state->m_MMC5_vrom_bank[0] * 64;
2130            chr1_5(machine(), m_MMC5_vrom_bank[5], CHRROM);
2131            //                  m_nes_vram_sprite[5] = m_MMC5_vrom_bank[0] * 64;
21442132            //                  vrom_next[1] = 1;
21452133            //                  vrom_page_a = 0;
21462134            //                  vrom_page_b = 0;
r18063r18064
21482136      }
21492137         break;
21502138      case 0x1026: /* $5126 */
2151         LOG_MMC(("MMC5 $5126 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2152         switch (state->m_mmc5_chr_mode)
2139         LOG_MMC(("MMC5 $5126 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2140         switch (m_mmc5_chr_mode)
21532141      {
21542142         case 0x03:
21552143            /* 1k switch */
2156            state->m_MMC5_vrom_bank[6] = data | (state->m_mmc5_high_chr << 8);
2144            m_MMC5_vrom_bank[6] = data | (m_mmc5_high_chr << 8);
21572145            //                  mapper5_sync_vrom(0);
2158            chr1_6(space.machine(), state->m_MMC5_vrom_bank[6], CHRROM);
2159            //                  state->m_nes_vram_sprite[6] = state->m_MMC5_vrom_bank[0] * 64;
2146            chr1_6(machine(), m_MMC5_vrom_bank[6], CHRROM);
2147            //                  m_nes_vram_sprite[6] = m_MMC5_vrom_bank[0] * 64;
21602148            //                  vrom_next[2] = 2;
21612149            //                  vrom_page_a = 0;
21622150            //                  vrom_page_b = 0;
r18063r18064
21642152      }
21652153         break;
21662154      case 0x1027: /* $5127 */
2167         LOG_MMC(("MMC5 $5127 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2168         switch (state->m_mmc5_chr_mode)
2155         LOG_MMC(("MMC5 $5127 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2156         switch (m_mmc5_chr_mode)
21692157      {
21702158         case 0x00:
21712159            /* 8k switch */
2172            chr8(space.machine(), data, CHRROM);
2160            chr8(machine(), data, CHRROM);
21732161            break;
21742162         case 0x01:
21752163            /* 4k switch */
2176            chr4_4(space.machine(), data, CHRROM);
2164            chr4_4(machine(), data, CHRROM);
21772165            break;
21782166         case 0x02:
21792167            /* 2k switch */
2180            chr2_6(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2168            chr2_6(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
21812169            break;
21822170         case 0x03:
21832171            /* 1k switch */
2184            state->m_MMC5_vrom_bank[7] = data | (state->m_mmc5_high_chr << 8);
2172            m_MMC5_vrom_bank[7] = data | (m_mmc5_high_chr << 8);
21852173            //                  mapper5_sync_vrom(0);
2186            chr1_7(space.machine(), state->m_MMC5_vrom_bank[7], CHRROM);
2187            //                  state->m_nes_vram_sprite[7] = state->m_MMC5_vrom_bank[0] * 64;
2174            chr1_7(machine(), m_MMC5_vrom_bank[7], CHRROM);
2175            //                  m_nes_vram_sprite[7] = m_MMC5_vrom_bank[0] * 64;
21882176            //                  vrom_next[3] = 3;
21892177            //                  vrom_page_a = 0;
21902178            //                  vrom_page_b = 0;
r18063r18064
21922180      }
21932181         break;
21942182      case 0x1028: /* $5128 */
2195         LOG_MMC(("MMC5 $5128 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2196         switch (state->m_mmc5_chr_mode)
2183         LOG_MMC(("MMC5 $5128 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2184         switch (m_mmc5_chr_mode)
21972185      {
21982186         case 0x03:
21992187            /* 1k switch */
2200            state->m_MMC5_vrom_bank[8] = data | (state->m_mmc5_high_chr << 8);
2188            m_MMC5_vrom_bank[8] = data | (m_mmc5_high_chr << 8);
22012189            //                  nes_vram[vrom_next[0]] = data * 64;
22022190            //                  nes_vram[0 + (vrom_page_a*4)] = data * 64;
22032191            //                  nes_vram[0] = data * 64;
2204            chr1_4(space.machine(), state->m_MMC5_vrom_bank[8], CHRROM);
2192            chr1_4(machine(), m_MMC5_vrom_bank[8], CHRROM);
22052193            //                  mapper5_sync_vrom(1);
2206            if (!state->m_vrom_page_b)
2194            if (!m_vrom_page_b)
22072195            {
2208               state->m_vrom_page_a ^= 0x01;
2209               state->m_vrom_page_b = 1;
2196               m_vrom_page_a ^= 0x01;
2197               m_vrom_page_b = 1;
22102198            }
22112199            break;
22122200      }
22132201         break;
22142202      case 0x1029: /* $5129 */
2215         LOG_MMC(("MMC5 $5129 vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2216         switch (state->m_mmc5_chr_mode)
2203         LOG_MMC(("MMC5 $5129 vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2204         switch (m_mmc5_chr_mode)
22172205      {
22182206         case 0x02:
22192207            /* 2k switch */
2220            chr2_0(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2221            chr2_4(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2208            chr2_0(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
2209            chr2_4(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
22222210            break;
22232211         case 0x03:
22242212            /* 1k switch */
2225            state->m_MMC5_vrom_bank[9] = data | (state->m_mmc5_high_chr << 8);
2213            m_MMC5_vrom_bank[9] = data | (m_mmc5_high_chr << 8);
22262214            //                  nes_vram[vrom_next[1]] = data * 64;
22272215            //                  nes_vram[1 + (vrom_page_a*4)] = data * 64;
22282216            //                  nes_vram[1] = data * 64;
2229            chr1_5(space.machine(), state->m_MMC5_vrom_bank[9], CHRROM);
2217            chr1_5(machine(), m_MMC5_vrom_bank[9], CHRROM);
22302218            //                  mapper5_sync_vrom(1);
2231            if (!state->m_vrom_page_b)
2219            if (!m_vrom_page_b)
22322220            {
2233               state->m_vrom_page_a ^= 0x01;
2234               state->m_vrom_page_b = 1;
2221               m_vrom_page_a ^= 0x01;
2222               m_vrom_page_b = 1;
22352223            }
22362224            break;
22372225      }
22382226         break;
22392227      case 0x102a: /* $512a */
2240         LOG_MMC(("MMC5 $512a vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2241         switch (state->m_mmc5_chr_mode)
2228         LOG_MMC(("MMC5 $512a vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2229         switch (m_mmc5_chr_mode)
22422230      {
22432231         case 0x03:
22442232            /* 1k switch */
2245            state->m_MMC5_vrom_bank[10] = data | (state->m_mmc5_high_chr << 8);
2233            m_MMC5_vrom_bank[10] = data | (m_mmc5_high_chr << 8);
22462234            //                  nes_vram[vrom_next[2]] = data * 64;
22472235            //                  nes_vram[2 + (vrom_page_a*4)] = data * 64;
22482236            //                  nes_vram[2] = data * 64;
2249            chr1_6(space.machine(), state->m_MMC5_vrom_bank[10], CHRROM);
2237            chr1_6(machine(), m_MMC5_vrom_bank[10], CHRROM);
22502238            //                  mapper5_sync_vrom(1);
2251            if (!state->m_vrom_page_b)
2239            if (!m_vrom_page_b)
22522240            {
2253               state->m_vrom_page_a ^= 0x01;
2254               state->m_vrom_page_b = 1;
2241               m_vrom_page_a ^= 0x01;
2242               m_vrom_page_b = 1;
22552243            }
22562244            break;
22572245      }
22582246         break;
22592247      case 0x102b: /* $512b */
2260         LOG_MMC(("MMC5 $512b vrom select: %02x (mode: %d)\n", data, state->m_mmc5_chr_mode));
2261         switch (state->m_mmc5_chr_mode)
2248         LOG_MMC(("MMC5 $512b vrom select: %02x (mode: %d)\n", data, m_mmc5_chr_mode));
2249         switch (m_mmc5_chr_mode)
22622250      {
22632251         case 0x00:
22642252            /* 8k switch */
22652253            /* switches in first half of an 8K bank!) */
2266            chr4_0(space.machine(), data << 1, CHRROM);
2267            chr4_4(space.machine(), data << 1, CHRROM);
2254            chr4_0(machine(), data << 1, CHRROM);
2255            chr4_4(machine(), data << 1, CHRROM);
22682256            break;
22692257         case 0x01:
22702258            /* 4k switch */
2271            chr4_0(space.machine(), data, CHRROM);
2272            chr4_4(space.machine(), data, CHRROM);
2259            chr4_0(machine(), data, CHRROM);
2260            chr4_4(machine(), data, CHRROM);
22732261            break;
22742262         case 0x02:
22752263            /* 2k switch */
2276            chr2_2(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2277            chr2_6(space.machine(), data | (state->m_mmc5_high_chr << 8), CHRROM);
2264            chr2_2(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
2265            chr2_6(machine(), data | (m_mmc5_high_chr << 8), CHRROM);
22782266            break;
22792267         case 0x03:
22802268            /* 1k switch */
2281            state->m_MMC5_vrom_bank[11] = data | (state->m_mmc5_high_chr << 8);
2269            m_MMC5_vrom_bank[11] = data | (m_mmc5_high_chr << 8);
22822270            //                  nes_vram[vrom_next[3]] = data * 64;
22832271            //                  nes_vram[3 + (vrom_page_a*4)] = data * 64;
22842272            //                  nes_vram[3] = data * 64;
2285            chr1_7(space.machine(), state->m_MMC5_vrom_bank[11], CHRROM);
2273            chr1_7(machine(), m_MMC5_vrom_bank[11], CHRROM);
22862274            //                  mapper5_sync_vrom(1);
2287            if (!state->m_vrom_page_b)
2275            if (!m_vrom_page_b)
22882276            {
2289               state->m_vrom_page_a ^= 0x01;
2290               state->m_vrom_page_b = 1;
2277               m_vrom_page_a ^= 0x01;
2278               m_vrom_page_b = 1;
22912279            }
22922280            break;
22932281      }
22942282         break;
22952283
22962284      case 0x1030: /* $5130 */
2297         state->m_mmc5_high_chr = data & 0x03;
2298         if (state->m_mmc5_vram_control == 1)
2285         m_mmc5_high_chr = data & 0x03;
2286         if (m_mmc5_vram_control == 1)
22992287         {
2300            // in this case state->m_mmc5_high_chr selects which 256KB of CHR ROM
2288            // in this case m_mmc5_high_chr selects which 256KB of CHR ROM
23012289            // is to be used for all background tiles on the screen.
23022290         }
23032291         break;
23042292
23052293
23062294      case 0x1100: /* $5200 */
2307         state->m_mmc5_split_scr = data;
2295         m_mmc5_split_scr = data;
23082296         // in EX2 and EX3 modes, no split screen
2309         if (state->m_mmc5_vram_control & 0x02)
2310            state->m_mmc5_split_scr &= 0x7f;
2311         state->m_mmc5_split_ctrl = data;
2297         if (m_mmc5_vram_control & 0x02)
2298            m_mmc5_split_scr &= 0x7f;
2299         m_mmc5_split_ctrl = data;
23122300         break;
23132301
23142302      case 0x1101: /* $5201 */
2315         state->m_mmc5_split_yst = (data >= 240) ? data - 16 : data;
2303         m_mmc5_split_yst = (data >= 240) ? data - 16 : data;
23162304         break;
23172305
23182306      case 0x1102: /* $5202 */
2319         state->m_mmc5_split_bank = data;
2307         m_mmc5_split_bank = data;
23202308         break;
23212309
23222310      case 0x1103: /* $5203 */
2323         state->m_IRQ_count = data;
2324         state->m_MMC5_scanline = data;
2325         LOG_MMC(("MMC5 irq scanline: %d\n", state->m_IRQ_count));
2311         m_IRQ_count = data;
2312         m_MMC5_scanline = data;
2313         LOG_MMC(("MMC5 irq scanline: %d\n", m_IRQ_count));
23262314         break;
23272315      case 0x1104: /* $5204 */
2328         state->m_IRQ_enable = data & 0x80;
2316         m_IRQ_enable = data & 0x80;
23292317         LOG_MMC(("MMC5 irq enable: %02x\n", data));
23302318         break;
23312319      case 0x1105: /* $5205 */
2332         state->m_mult1 = data;
2320         m_mult1 = data;
23332321         break;
23342322      case 0x1106: /* $5206 */
2335         state->m_mult2 = data;
2323         m_mult2 = data;
23362324         break;
23372325
23382326      default:
r18063r18064
23952383   }
23962384}
23972385
2398static WRITE8_HANDLER( ntbrom_w )
2386WRITE8_MEMBER(nes_state::ntbrom_w)
23992387{
2400   nes_state *state = space.machine().driver_data<nes_state>();
24012388
24022389   LOG_MMC(("ntbrom_w, offset %04x, data: %02x\n", offset, data));
24032390
24042391   switch (offset & 0x7000)
24052392   {
24062393      case 0x0000:
2407         chr2_0(space.machine(), data, CHRROM);
2394         chr2_0(machine(), data, CHRROM);
24082395         break;
24092396      case 0x1000:
2410         chr2_2(space.machine(), data, CHRROM);
2397         chr2_2(machine(), data, CHRROM);
24112398         break;
24122399      case 0x2000:
2413         chr2_4(space.machine(), data, CHRROM);
2400         chr2_4(machine(), data, CHRROM);
24142401         break;
24152402      case 0x3000:
2416         chr2_6(space.machine(), data, CHRROM);
2403         chr2_6(machine(), data, CHRROM);
24172404         break;
24182405      case 0x4000:
2419         state->m_mmc_latch1 = data & 0x7f;
2420         ntbrom_mirror(space.machine(), state->m_mmc_reg[0], state->m_mmc_latch1, state->m_mmc_latch2);
2406         m_mmc_latch1 = data & 0x7f;
2407         ntbrom_mirror(machine(), m_mmc_reg[0], m_mmc_latch1, m_mmc_latch2);
24212408         break;
24222409      case 0x5000:
2423         state->m_mmc_latch2 = data & 0x7f;
2424         ntbrom_mirror(space.machine(), state->m_mmc_reg[0], state->m_mmc_latch1, state->m_mmc_latch2);
2410         m_mmc_latch2 = data & 0x7f;
2411         ntbrom_mirror(machine(), m_mmc_reg[0], m_mmc_latch1, m_mmc_latch2);
24252412         break;
24262413      case 0x6000:
2427         state->m_mmc_reg[0] = data & 0x13;
2428         ntbrom_mirror(space.machine(), state->m_mmc_reg[0], state->m_mmc_latch1, state->m_mmc_latch2);
2414         m_mmc_reg[0] = data & 0x13;
2415         ntbrom_mirror(machine(), m_mmc_reg[0], m_mmc_latch1, m_mmc_latch2);
24292416         break;
24302417      case 0x7000:
2431         prg16_89ab(space.machine(), data);
2418         prg16_89ab(machine(), data);
24322419         break;
24332420      default:
24342421         LOG_MMC(("ntbrom_w uncaught write, offset: %04x, data: %02x\n", offset, data));
r18063r18064
24742461   }
24752462}
24762463
2477static WRITE8_HANDLER( jxrom_w )
2464WRITE8_MEMBER(nes_state::jxrom_w)
24782465{
2479   nes_state *state = space.machine().driver_data<nes_state>();
24802466   LOG_MMC(("jxrom_w, offset %04x, data: %02x\n", offset, data));
24812467
24822468   switch (offset & 0x6000)
24832469   {
24842470      case 0x0000:
2485         state->m_mmc_latch1 = data & 0x0f;
2471         m_mmc_latch1 = data & 0x0f;
24862472         break;
24872473
24882474      case 0x2000:
2489         switch (state->m_mmc_latch1)
2475         switch (m_mmc_latch1)
24902476         {
24912477         case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
2492            chr1_x(space.machine(), state->m_mmc_latch1, data, CHRROM);
2478            chr1_x(machine(), m_mmc_latch1, data, CHRROM);
24932479            break;
24942480
24952481         case 8:
r18063r18064
24972483            {
24982484               // is PRG ROM
24992485               space.unmap_write(0x6000, 0x7fff);
2500               prg8_67(space.machine(), data & 0x3f);
2486               prg8_67(machine(), data & 0x3f);
25012487            }
25022488            else if (data & 0x80)
25032489            {
25042490               // is PRG RAM
25052491               space.install_write_bank(0x6000, 0x7fff, "bank5");
2506               state->m_prg_bank[4] = state->m_battery_bank5_start + (data & 0x3f);
2507               state->membank("bank5")->set_entry(state->m_prg_bank[4]);
2492               m_prg_bank[4] = m_battery_bank5_start + (data & 0x3f);
2493               membank("bank5")->set_entry(m_prg_bank[4]);
25082494            }
25092495            break;
25102496
25112497         case 9:
2512            prg8_89(space.machine(), data);
2498            prg8_89(machine(), data);
25132499            break;
25142500         case 0x0a:
2515            prg8_ab(space.machine(), data);
2501            prg8_ab(machine(), data);
25162502            break;
25172503         case 0x0b:
2518            prg8_cd(space.machine(), data);
2504            prg8_cd(machine(), data);
25192505            break;
25202506         case 0x0c:
25212507            switch (data & 0x03)
25222508            {
2523            case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
2524            case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
2525            case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
2526            case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
2509            case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
2510            case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
2511            case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
2512            case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
25272513            }
25282514            break;
25292515         case 0x0d:
2530            state->m_IRQ_enable = data;
2516            m_IRQ_enable = data;
25312517            break;
25322518         case 0x0e:
2533            state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
2519            m_IRQ_count = (m_IRQ_count & 0xff00) | data;
25342520            break;
25352521         case 0x0f:
2536            state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
2522            m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
25372523            break;
25382524         }
25392525         break;
r18063r18064
25672553
25682554 *************************************************************/
25692555
2570static WRITE8_HANDLER( dxrom_w )
2556WRITE8_MEMBER(nes_state::dxrom_w)
25712557{
2572   nes_state *state = space.machine().driver_data<nes_state>();
25732558   LOG_MMC(("dxrom_w, offset: %04x, data: %02x\n", offset, data));
25742559
25752560    if (offset >= 0x2000)
r18063r18064
25782563   switch (offset & 1)
25792564   {
25802565      case 1:
2581         switch (state->m_mmc_latch1 & 0x07)
2566         switch (m_mmc_latch1 & 0x07)
25822567         {
2583         case 0: chr2_0(space.machine(), data >> 1, CHRROM); break;
2584         case 1: chr2_2(space.machine(), data >> 1, CHRROM); break;
2585         case 2: chr1_4(space.machine(), data | 0x40, CHRROM); break;
2586         case 3: chr1_5(space.machine(), data | 0x40, CHRROM); break;
2587         case 4: chr1_6(space.machine(), data | 0x40, CHRROM); break;
2588         case 5: chr1_7(space.machine(), data | 0x40, CHRROM); break;
2589         case 6: prg8_89(space.machine(), data); break;
2590         case 7: prg8_ab(space.machine(), data); break;
2568         case 0: chr2_0(machine(), data >> 1, CHRROM); break;
2569         case 1: chr2_2(machine(), data >> 1, CHRROM); break;
2570         case 2: chr1_4(machine(), data | 0x40, CHRROM); break;
2571         case 3: chr1_5(machine(), data | 0x40, CHRROM); break;
2572         case 4: chr1_6(machine(), data | 0x40, CHRROM); break;
2573         case 5: chr1_7(machine(), data | 0x40, CHRROM); break;
2574         case 6: prg8_89(machine(), data); break;
2575         case 7: prg8_ab(machine(), data); break;
25912576         }
25922577         break;
25932578      case 0:
2594         state->m_mmc_latch1 = data;
2579         m_mmc_latch1 = data;
25952580         break;
25962581   }
25972582}
r18063r18064
26102595
26112596 *************************************************************/
26122597
2613static WRITE8_HANDLER( namcot3453_w )
2598WRITE8_MEMBER(nes_state::namcot3453_w)
26142599{
26152600   LOG_MMC(("namcot3453_w, offset: %04x, data: %02x\n", offset, data));
26162601
26172602   // additional mirroring control when writing to even addresses
26182603   if (!(offset & 1))
2619      set_nt_mirroring(space.machine(), BIT(data, 6) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
2604      set_nt_mirroring(machine(), BIT(data, 6) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
26202605
26212606   dxrom_w(space, offset, data, mem_mask);
26222607}
r18063r18064
26332618
26342619 *************************************************************/
26352620
2636static WRITE8_HANDLER( namcot3446_w )
2621WRITE8_MEMBER(nes_state::namcot3446_w)
26372622{
2638   nes_state *state = space.machine().driver_data<nes_state>();
26392623   LOG_MMC(("namcot3446_w, offset: %04x, data: %02x\n", offset, data));
26402624
26412625   // NEStopia does not have this!
26422626   if (offset >= 0x2000)
26432627   {
26442628      if (!(offset & 1))
2645         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
2629         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
26462630      return;
26472631   }
26482632
26492633   switch (offset & 1)
26502634   {
26512635      case 1:
2652         switch (state->m_mmc_latch1 & 0x07)
2636         switch (m_mmc_latch1 & 0x07)
26532637         {
2654         case 2: chr2_0(space.machine(), data, CHRROM); break;
2655         case 3: chr2_2(space.machine(), data, CHRROM); break;
2656         case 4: chr2_4(space.machine(), data, CHRROM); break;
2657         case 5: chr2_6(space.machine(), data, CHRROM); break;
2658         case 6: BIT(state->m_mmc_latch1, 6) ? prg8_cd(space.machine(), data) : prg8_89(space.machine(), data); break;
2659         case 7: prg8_ab(space.machine(), data); break;
2638         case 2: chr2_0(machine(), data, CHRROM); break;
2639         case 3: chr2_2(machine(), data, CHRROM); break;
2640         case 4: chr2_4(machine(), data, CHRROM); break;
2641         case 5: chr2_6(machine(), data, CHRROM); break;
2642         case 6: BIT(m_mmc_latch1, 6) ? prg8_cd(machine(), data) : prg8_89(machine(), data); break;
2643         case 7: prg8_ab(machine(), data); break;
26602644         }
26612645         break;
26622646      case 0:
2663         state->m_mmc_latch1 = data;
2647         m_mmc_latch1 = data;
26642648         break;
26652649   }
26662650}
r18063r18064
26782662
26792663 *************************************************************/
26802664
2681static WRITE8_HANDLER( namcot3425_w )
2665WRITE8_MEMBER(nes_state::namcot3425_w)
26822666{
2683   nes_state *state = space.machine().driver_data<nes_state>();
26842667   UINT8 mode;
26852668   LOG_MMC(("namcot3425_w, offset: %04x, data: %02x\n", offset, data));
26862669   if (offset >= 0x2000)
r18063r18064
26892672   switch (offset & 1)
26902673   {
26912674      case 1:
2692         mode = state->m_mmc_latch1 & 0x07;
2675         mode = m_mmc_latch1 & 0x07;
26932676         switch (mode)
26942677         {
2695         case 0: chr2_0(space.machine(), data >> 1, CHRROM); break;
2696         case 1: chr2_2(space.machine(), data >> 1, CHRROM); break;
2678         case 0: chr2_0(machine(), data >> 1, CHRROM); break;
2679         case 1: chr2_2(machine(), data >> 1, CHRROM); break;
26972680         case 2:
26982681         case 3:
26992682         case 4:
27002683         case 5:
2701            chr1_x(space.machine(), 2 + mode, data, CHRROM);
2702            state->m_mmc_reg[mode - 2] = BIT(data, 5);
2703            if (!BIT(state->m_mmc_latch1, 7))
2684            chr1_x(machine(), 2 + mode, data, CHRROM);
2685            m_mmc_reg[mode - 2] = BIT(data, 5);
2686            if (!BIT(m_mmc_latch1, 7))
27042687            {
2705                  set_nt_page(space.machine(), 0, CIRAM, state->m_mmc_reg[0], 1);
2706                  set_nt_page(space.machine(), 1, CIRAM, state->m_mmc_reg[1], 1);
2707                  set_nt_page(space.machine(), 2, CIRAM, state->m_mmc_reg[2], 1);
2708                  set_nt_page(space.machine(), 3, CIRAM, state->m_mmc_reg[3], 1);
2688                  set_nt_page(machine(), 0, CIRAM, m_mmc_reg[0], 1);
2689                  set_nt_page(machine(), 1, CIRAM, m_mmc_reg[1], 1);
2690                  set_nt_page(machine(), 2, CIRAM, m_mmc_reg[2], 1);
2691                  set_nt_page(machine(), 3, CIRAM, m_mmc_reg[3], 1);
27092692            }
27102693            else
2711               set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ);
2694               set_nt_mirroring(machine(), PPU_MIRROR_HORZ);
27122695            break;
2713         case 6: prg8_89(space.machine(), data); break;
2714         case 7: prg8_ab(space.machine(), data); break;
2696         case 6: prg8_89(machine(), data); break;
2697         case 7: prg8_ab(machine(), data); break;
27152698         }
27162699         break;
27172700      case 0:
2718         state->m_mmc_latch1 = data;
2701         m_mmc_latch1 = data;
27192702         break;
27202703   }
27212704}
r18063r18064
27322715
27332716 *************************************************************/
27342717
2735static WRITE8_HANDLER( dis_74x377_w )
2718WRITE8_MEMBER(nes_state::dis_74x377_w)
27362719{
2737   nes_state *state = space.machine().driver_data<nes_state>();
27382720   LOG_MMC(("dis_74x377_w, offset: %04x, data: %02x\n", offset, data));
27392721
2740   chr8(space.machine(), data >> 4, state->m_mmc_chr_source);
2741   prg32(space.machine(), data & 0x0f);
2722   chr8(machine(), data >> 4, m_mmc_chr_source);
2723   prg32(machine(), data & 0x0f);
27422724}
27432725
27442726/*************************************************************
r18063r18064
27492731
27502732 *************************************************************/
27512733
2752static WRITE8_HANDLER( dis_74x139x74_m_w )
2734WRITE8_MEMBER(nes_state::dis_74x139x74_m_w)
27532735{
27542736   LOG_MMC(("dis_74x139x74_m_w, offset: %04x, data: %02x\n", offset, data));
27552737
2756   chr8(space.machine(), ((data & 0x02) >> 1) | ((data & 0x01) << 1), CHRROM);
2738   chr8(machine(), ((data & 0x02) >> 1) | ((data & 0x01) << 1), CHRROM);
27572739}
27582740
27592741/*************************************************************
r18063r18064
27662748
27672749 *************************************************************/
27682750
2769static WRITE8_HANDLER( dis_74x161x138_m_w )
2751WRITE8_MEMBER(nes_state::dis_74x161x138_m_w)
27702752{
27712753   LOG_MMC(("dis_74x161x138_m_w, offset: %04x, data: %02x\n", offset, data));
27722754
2773   chr8(space.machine(), data >> 2, CHRROM);
2774   prg32(space.machine(), data);
2755   chr8(machine(), data >> 2, CHRROM);
2756   prg32(machine(), data);
27752757}
27762758
27772759/*************************************************************
r18063r18064
27862768
27872769 *************************************************************/
27882770
2789static WRITE8_HANDLER( dis_74x161x161x32_w )
2771WRITE8_MEMBER(nes_state::dis_74x161x161x32_w)
27902772{
2791   nes_state *state = space.machine().driver_data<nes_state>();
27922773   LOG_MMC(("dis_74x161x161x32_w, offset: %04x, data: %02x\n", offset, data));
27932774
2794   if (!state->m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
2795      set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
2796   chr8(space.machine(), data, CHRROM);
2797   prg16_89ab(space.machine(), data >> 4);
2775   if (!m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
2776      set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
2777   chr8(machine(), data, CHRROM);
2778   prg16_89ab(machine(), data >> 4);
27982779}
27992780
28002781/*************************************************************
r18063r18064
28402821   }
28412822}
28422823
2843static WRITE8_HANDLER( lz93d50_w )
2824WRITE8_MEMBER(nes_state::lz93d50_w)
28442825{
2845   nes_state *state = space.machine().driver_data<nes_state>();
28462826   LOG_MMC(("lz93d50_w, offset: %04x, data: %02x\n", offset, data));
28472827
28482828   switch (offset & 0x000f)
28492829   {
28502830      case 0: case 1: case 2: case 3:
28512831      case 4: case 5: case 6: case 7:
2852         chr1_x(space.machine(), offset & 0x07, data, state->m_mmc_chr_source);
2832         chr1_x(machine(), offset & 0x07, data, m_mmc_chr_source);
28532833         break;
28542834      case 8:
2855         prg16_89ab(space.machine(), data);
2835         prg16_89ab(machine(), data);
28562836         break;
28572837      case 9:
28582838         switch (data & 0x03)
28592839         {
2860         case 0: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
2861         case 1: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
2862         case 2: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
2863         case 3: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
2840         case 0: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
2841         case 1: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
2842         case 2: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
2843         case 3: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
28642844         }
28652845         break;
28662846      case 0x0a:
2867         state->m_IRQ_enable = data & 0x01;
2847         m_IRQ_enable = data & 0x01;
28682848         break;
28692849      case 0x0b:
2870         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
2850         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
28712851         break;
28722852      case 0x0c:
2873         state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
2853         m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
28742854         break;
28752855      default:
28762856         logerror("lz93d50_w uncaught write, offset: %04x, data: %02x\n", offset, data);
r18063r18064
28782858   }
28792859}
28802860
2881static WRITE8_HANDLER( lz93d50_m_w )
2861WRITE8_MEMBER(nes_state::lz93d50_m_w)
28822862{
2883   nes_state *state = space.machine().driver_data<nes_state>();
28842863   LOG_MMC(("lz93d50_m_w, offset: %04x, data: %02x\n", offset, data));
28852864
2886   if (!state->m_battery && !state->m_wram)
2865   if (!m_battery && !m_wram)
28872866      lz93d50_w(space, offset & 0x0f, data, mem_mask);
2888   else if (state->m_battery)
2889      state->m_battery_ram[offset] = data;
2867   else if (m_battery)
2868      m_battery_ram[offset] = data;
28902869   else
2891      state->m_wram[offset] = data;
2870      m_wram[offset] = data;
28922871}
28932872
28942873static void fjump2_set_prg( running_machine &machine )
r18063r18064
29042883   prg16_cdef(machine, mmc_helper | 0x0f);
29052884}
29062885
2907static WRITE8_HANDLER( fjump2_w )
2886WRITE8_MEMBER(nes_state::fjump2_w)
29082887{
2909   nes_state *state = space.machine().driver_data<nes_state>();
29102888   LOG_MMC(("fjump2_w, offset: %04x, data: %02x\n", offset, data));
29112889
29122890   switch (offset & 0x000f)
29132891   {
29142892      case 0: case 1: case 2: case 3:
29152893      case 4: case 5: case 6: case 7:
2916         state->m_mmc_reg[offset & 0x000f] = data;
2917         fjump2_set_prg(space.machine());
2894         m_mmc_reg[offset & 0x000f] = data;
2895         fjump2_set_prg(machine());
29182896         break;
29192897      case 8:
2920         state->m_mmc_latch1 = (data & 0x0f);
2921         fjump2_set_prg(space.machine());
2898         m_mmc_latch1 = (data & 0x0f);
2899         fjump2_set_prg(machine());
29222900         break;
29232901      default:
29242902         lz93d50_m_w(space, offset & 0x0f, data, mem_mask);
r18063r18064
29382916
29392917 *************************************************************/
29402918
2941static WRITE8_HANDLER( bandai_ks_w )
2919WRITE8_MEMBER(nes_state::bandai_ks_w)
29422920{
29432921   LOG_MMC(("bandai_ks_w, offset: %04x, data: %02x\n", offset, data));
29442922
2945   prg16_89ab(space.machine(), data ^ 0x08);
2923   prg16_89ab(machine(), data ^ 0x08);
29462924}
29472925
29482926/*************************************************************
r18063r18064
29582936
29592937 *************************************************************/
29602938
2961static WRITE8_HANDLER( bandai_ok_w )
2939WRITE8_MEMBER(nes_state::bandai_ok_w)
29622940{
2963   nes_state *state = space.machine().driver_data<nes_state>();
29642941   UINT8 mmc_helper;
29652942   LOG_MMC(("mapper96_w, offset: %04x, data: %02x\n", offset, data));
29662943
2967   prg32(space.machine(), data);
2944   prg32(machine(), data);
29682945
2969   state->m_mmc_latch1 = data;
2970   mmc_helper = (state->m_mmc_latch1 & 0x03) | (data & 0x04);
2971   chr4_0(space.machine(), mmc_helper, CHRRAM);
2972   chr4_4(space.machine(), 0x03 | (data & 0x04), CHRRAM);
2946   m_mmc_latch1 = data;
2947   mmc_helper = (m_mmc_latch1 & 0x03) | (data & 0x04);
2948   chr4_0(machine(), mmc_helper, CHRRAM);
2949   chr4_4(machine(), 0x03 | (data & 0x04), CHRRAM);
29732950}
29742951
29752952/*************************************************************
r18063r18064
29822959
29832960 *************************************************************/
29842961
2985static WRITE8_HANDLER( lrog017_w )
2962WRITE8_MEMBER(nes_state::lrog017_w)
29862963{
29872964   LOG_MMC(("lrog017_w, offset: %04x, data: %02x\n", offset, data));
29882965
2989   prg32(space.machine(), data);
2990   chr2_0(space.machine(), (data >> 4), CHRROM);
2966   prg32(machine(), data);
2967   chr2_0(machine(), (data >> 4), CHRROM);
29912968}
29922969
29932970/*************************************************************
r18063r18064
29982975
29992976 *************************************************************/
30002977
3001static WRITE8_HANDLER( irem_hd_w )
2978WRITE8_MEMBER(nes_state::irem_hd_w)
30022979{
30032980   LOG_MMC(("irem_hd_w, offset: %04x, data: %02x\n", offset, data));
30042981
3005   set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
3006   chr8(space.machine(), data >> 4, CHRROM);
3007   prg16_89ab(space.machine(), data);
2982   set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
2983   chr8(machine(), data >> 4, CHRROM);
2984   prg16_89ab(machine(), data);
30082985}
30092986
30102987/*************************************************************
r18063r18064
30192996
30202997 *************************************************************/
30212998
3022static WRITE8_HANDLER( tam_s1_w )
2999WRITE8_MEMBER(nes_state::tam_s1_w)
30233000{
30243001   LOG_MMC(("tam_s1_w, offset: %04x, data: %02x\n", offset, data));
30253002
30263003   if (offset < 0x4000)
30273004   {
3028      set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
3029      prg16_cdef(space.machine(), data);
3005      set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
3006      prg16_cdef(machine(), data);
30303007   }
30313008}
30323009
r18063r18064
30403017
30413018 *************************************************************/
30423019
3043static WRITE8_HANDLER( g101_w )
3020WRITE8_MEMBER(nes_state::g101_w)
30443021{
3045   nes_state *state = space.machine().driver_data<nes_state>();
30463022   LOG_MMC(("g101_w, offset: %04x, data: %02x\n", offset, data));
30473023
30483024   switch (offset & 0x7000)
30493025   {
30503026      case 0x0000:
30513027         // NEStopia here differs a little bit
3052         state->m_mmc_latch1 ? prg8_cd(space.machine(), data) : prg8_89(space.machine(), data);
3028         m_mmc_latch1 ? prg8_cd(machine(), data) : prg8_89(machine(), data);
30533029         break;
30543030      case 0x1000:
3055         state->m_mmc_latch1 = BIT(data, 1);
3056         if (!state->m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
3057            set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
3031         m_mmc_latch1 = BIT(data, 1);
3032         if (!m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
3033            set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
30583034         break;
30593035      case 0x2000:
3060         prg8_ab(space.machine(), data);
3036         prg8_ab(machine(), data);
30613037         break;
30623038      case 0x3000:
3063         chr1_x(space.machine(), offset & 0x07, data, CHRROM);
3039         chr1_x(machine(), offset & 0x07, data, CHRROM);
30643040         break;
30653041   }
30663042}
r18063r18064
30963072   }
30973073}
30983074
3099static WRITE8_HANDLER( h3001_w )
3075WRITE8_MEMBER(nes_state::h3001_w)
31003076{
3101   nes_state *state = space.machine().driver_data<nes_state>();
31023077   LOG_MMC(("h3001_w, offset %04x, data: %02x\n", offset, data));
31033078
31043079   switch (offset & 0x7fff)
31053080   {
31063081      case 0x0000:
3107         prg8_89(space.machine(), data);
3082         prg8_89(machine(), data);
31083083         break;
31093084
31103085      case 0x1001:
3111         set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
3086         set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
31123087         break;
31133088
31143089      case 0x1003:
3115         state->m_IRQ_enable = data & 0x80;
3090         m_IRQ_enable = data & 0x80;
31163091         break;
31173092
31183093      case 0x1004:
3119         state->m_IRQ_count = state->m_IRQ_count_latch;
3094         m_IRQ_count = m_IRQ_count_latch;
31203095         break;
31213096
31223097      case 0x1005:
3123         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0x00ff) | (data << 8);
3098         m_IRQ_count_latch = (m_IRQ_count_latch & 0x00ff) | (data << 8);
31243099         break;
31253100
31263101      case 0x1006:
3127         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xff00) | data;
3102         m_IRQ_count_latch = (m_IRQ_count_latch & 0xff00) | data;
31283103         break;
31293104
31303105      case 0x2000:
3131         prg8_ab(space.machine(), data);
3106         prg8_ab(machine(), data);
31323107         break;
31333108
31343109      case 0x3000: case 0x3001: case 0x3002: case 0x3003:
31353110      case 0x3004: case 0x3005: case 0x3006: case 0x3007:
3136         chr1_x(space.machine(), offset & 0x07, data, CHRROM);
3111         chr1_x(machine(), offset & 0x07, data, CHRROM);
31373112         break;
31383113
31393114      case 0x4000:
3140         prg8_cd(space.machine(), data);
3115         prg8_cd(machine(), data);
31413116         break;
31423117
31433118      default:
r18063r18064
32093184   }
32103185}
32113186
3212static WRITE8_HANDLER( ss88006_w )
3187WRITE8_MEMBER(nes_state::ss88006_w)
32133188{
3214   nes_state *state = space.machine().driver_data<nes_state>();
32153189   UINT8 bank;
32163190   LOG_MMC(("mapper18_w, offset: %04x, data: %02x\n", offset, data));
32173191
32183192   switch (offset & 0x7003)
32193193   {
32203194      case 0x0000:
3221         state->m_mmc_prg_bank[0] = (state->m_mmc_prg_bank[0] & 0xf0) | (data & 0x0f);
3222         prg8_89(space.machine(), state->m_mmc_prg_bank[0]);
3195         m_mmc_prg_bank[0] = (m_mmc_prg_bank[0] & 0xf0) | (data & 0x0f);
3196         prg8_89(machine(), m_mmc_prg_bank[0]);
32233197         break;
32243198      case 0x0001:
3225         state->m_mmc_prg_bank[0] = (state->m_mmc_prg_bank[0] & 0x0f) | (data << 4);
3226         prg8_89(space.machine(), state->m_mmc_prg_bank[0]);
3199         m_mmc_prg_bank[0] = (m_mmc_prg_bank[0] & 0x0f) | (data << 4);
3200         prg8_89(machine(), m_mmc_prg_bank[0]);
32273201         break;
32283202      case 0x0002:
3229         state->m_mmc_prg_bank[1] = (state->m_mmc_prg_bank[1] & 0xf0) | (data & 0x0f);
3230         prg8_ab(space.machine(), state->m_mmc_prg_bank[1]);
3203         m_mmc_prg_bank[1] = (m_mmc_prg_bank[1] & 0xf0) | (data & 0x0f);
3204         prg8_ab(machine(), m_mmc_prg_bank[1]);
32313205         break;
32323206      case 0x0003:
3233         state->m_mmc_prg_bank[1] = (state->m_mmc_prg_bank[1] & 0x0f) | (data << 4);
3234         prg8_ab(space.machine(), state->m_mmc_prg_bank[1]);
3207         m_mmc_prg_bank[1] = (m_mmc_prg_bank[1] & 0x0f) | (data << 4);
3208         prg8_ab(machine(), m_mmc_prg_bank[1]);
32353209         break;
32363210      case 0x1000:
3237         state->m_mmc_prg_bank[2] = (state->m_mmc_prg_bank[2] & 0xf0) | (data & 0x0f);
3238         prg8_cd(space.machine(), state->m_mmc_prg_bank[2]);
3211         m_mmc_prg_bank[2] = (m_mmc_prg_bank[2] & 0xf0) | (data & 0x0f);
3212         prg8_cd(machine(), m_mmc_prg_bank[2]);
32393213         break;
32403214      case 0x1001:
3241         state->m_mmc_prg_bank[2] = (state->m_mmc_prg_bank[2] & 0x0f) | (data << 4);
3242         prg8_cd(space.machine(), state->m_mmc_prg_bank[2]);
3215         m_mmc_prg_bank[2] = (m_mmc_prg_bank[2] & 0x0f) | (data << 4);
3216         prg8_cd(machine(), m_mmc_prg_bank[2]);
32433217         break;
32443218
32453219         /* $9002, 3 (1002, 3) uncaught = Jaleco Baseball writes 0 */
r18063r18064
32513225      case 0x5000: case 0x5001: case 0x5002: case 0x5003:
32523226         bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0002) >> 1);
32533227         if (offset & 0x0001)
3254            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f)<< 4);
3228            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f)<< 4);
32553229         else
3256            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
3230            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
32573231
3258         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
3232         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
32593233         break;
32603234
32613235      case 0x6000:
3262         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xfff0) | (data & 0x0f);
3236         m_IRQ_count_latch = (m_IRQ_count_latch & 0xfff0) | (data & 0x0f);
32633237         break;
32643238      case 0x6001:
3265         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xff0f) | ((data & 0x0f) << 4);
3239         m_IRQ_count_latch = (m_IRQ_count_latch & 0xff0f) | ((data & 0x0f) << 4);
32663240         break;
32673241      case 0x6002:
3268         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xf0ff) | ((data & 0x0f) << 8);
3242         m_IRQ_count_latch = (m_IRQ_count_latch & 0xf0ff) | ((data & 0x0f) << 8);
32693243         break;
32703244      case 0x6003:
3271         state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0x0fff) | ((data & 0x0f) << 12);
3245         m_IRQ_count_latch = (m_IRQ_count_latch & 0x0fff) | ((data & 0x0f) << 12);
32723246         break;
32733247
32743248      case 0x7000:
3275         state->m_IRQ_count = state->m_IRQ_count_latch;
3249         m_IRQ_count = m_IRQ_count_latch;
32763250         break;
32773251      case 0x7001:
3278         state->m_IRQ_enable = data & 0x01;
3279         state->m_IRQ_mode = data & 0x0e;
3252         m_IRQ_enable = data & 0x01;
3253         m_IRQ_mode = data & 0x0e;
32803254         break;
32813255
32823256      case 0x7002:
32833257         switch (data & 0x03)
32843258         {
3285         case 0: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
3286         case 1: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
3287         case 2: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
3288         case 3: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
3259         case 0: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
3260         case 1: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
3261         case 2: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
3262         case 3: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
32893263         }
32903264         break;
32913265
r18063r18064
33073281
33083282 *************************************************************/
33093283
3310static WRITE8_HANDLER( jf11_m_w )
3284WRITE8_MEMBER(nes_state::jf11_m_w)
33113285{
33123286   LOG_MMC(("jf11_m_w, offset: %04x, data: %02x\n", offset, data));
3313   chr8(space.machine(), data, CHRROM);
3314   prg32(space.machine(), data >> 4);
3287   chr8(machine(), data, CHRROM);
3288   prg32(machine(), data >> 4);
33153289}
33163290
33173291/*************************************************************
r18063r18064
33283302
33293303 *************************************************************/
33303304
3331static WRITE8_HANDLER( jf13_m_w )
3305WRITE8_MEMBER(nes_state::jf13_m_w)
33323306{
33333307   LOG_MMC(("jf13_m_w, offset: %04x, data: %02x\n", offset, data));
33343308
33353309   if (offset == 0)
33363310   {
3337      prg32(space.machine(), (data >> 4) & 0x03);
3338      chr8(space.machine(), ((data >> 4) & 0x04) | (data & 0x03), CHRROM);
3311      prg32(machine(), (data >> 4) & 0x03);
3312      chr8(machine(), ((data >> 4) & 0x04) | (data & 0x03), CHRROM);
33393313   }
33403314
33413315   if (offset == 0x1000)
r18063r18064
33573331
33583332 *************************************************************/
33593333
3360static WRITE8_HANDLER( jf16_w )
3334WRITE8_MEMBER(nes_state::jf16_w)
33613335{
33623336   LOG_MMC(("jf16_w, offset: %04x, data: %02x\n", offset, data));
33633337
3364   set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
3365   chr8(space.machine(), data >> 4, CHRROM);
3366   prg16_89ab(space.machine(), data);
3338   set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
3339   chr8(machine(), data >> 4, CHRROM);
3340   prg16_89ab(machine(), data);
33673341}
33683342
33693343/*************************************************************
r18063r18064
33813355
33823356 *************************************************************/
33833357
3384static WRITE8_HANDLER( jf17_w )
3358WRITE8_MEMBER(nes_state::jf17_w)
33853359{
33863360   LOG_MMC(("jf17_w, offset: %04x, data: %02x\n", offset, data));
33873361
33883362   if (BIT(data, 7))
3389      prg16_89ab(space.machine(), data & 0x0f);
3363      prg16_89ab(machine(), data & 0x0f);
33903364   if (BIT(data, 6))
3391      chr8(space.machine(), data & 0x0f, CHRROM);
3365      chr8(machine(), data & 0x0f, CHRROM);
33923366   if (BIT(data, 5) && !BIT(data,4))
33933367      LOG_MMC(("Jaleco JF-17 sound write, data: %02x\n", data & 0x1f));
33943368}
r18063r18064
34073381
34083382 *************************************************************/
34093383
3410static WRITE8_HANDLER( jf19_w )
3384WRITE8_MEMBER(nes_state::jf19_w)
34113385{
34123386   LOG_MMC(("jf19_w, offset: %04x, data: %02x\n", offset, data));
34133387
34143388   if (BIT(data, 7))
3415      prg16_cdef(space.machine(), data & 0x0f);
3389      prg16_cdef(machine(), data & 0x0f);
34163390   if (BIT(data, 6))
3417      chr8(space.machine(), data & 0x0f, CHRROM);
3391      chr8(machine(), data & 0x0f, CHRROM);
34183392   if (BIT(data, 5) && !BIT(data,4))
34193393      LOG_MMC(("Jaleco JF-19 sound write, data: %02x\n", data & 0x1f));
34203394}
r18063r18064
34313405
34323406 *************************************************************/
34333407
3434static WRITE8_HANDLER( konami_vrc1_w )
3408WRITE8_MEMBER(nes_state::konami_vrc1_w)
34353409{
3436   nes_state *state = space.machine().driver_data<nes_state>();
34373410   LOG_MMC(("konami_vrc1_w, offset: %04x, data: %02x\n", offset, data));
34383411
34393412   switch (offset & 0x7000)
34403413   {
34413414      case 0x0000:
3442         prg8_89(space.machine(), data);
3415         prg8_89(machine(), data);
34433416         break;
34443417      case 0x1000:
3445         set_nt_mirroring(space.machine(), (data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
3446         state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & 0x0f) | ((data & 0x02) << 3);
3447         state->m_mmc_vrom_bank[1] = (state->m_mmc_vrom_bank[1] & 0x0f) | ((data & 0x04) << 2);
3448         chr4_0(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
3449         chr4_4(space.machine(), state->m_mmc_vrom_bank[1], CHRROM);
3418         set_nt_mirroring(machine(), (data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
3419         m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & 0x0f) | ((data & 0x02) << 3);
3420         m_mmc_vrom_bank[1] = (m_mmc_vrom_bank[1] & 0x0f) | ((data & 0x04) << 2);
3421         chr4_0(machine(), m_mmc_vrom_bank[0], CHRROM);
3422         chr4_4(machine(), m_mmc_vrom_bank[1], CHRROM);
34503423         break;
34513424      case 0x2000:
3452         prg8_ab(space.machine(), data);
3425         prg8_ab(machine(), data);
34533426         break;
34543427      case 0x4000:
3455         prg8_cd(space.machine(), data);
3428         prg8_cd(machine(), data);
34563429         break;
34573430      case 0x6000:
3458         state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & 0x10) | (data & 0x0f);
3459         chr4_0(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
3431         m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & 0x10) | (data & 0x0f);
3432         chr4_0(machine(), m_mmc_vrom_bank[0], CHRROM);
34603433         break;
34613434      case 0x7000:
3462         state->m_mmc_vrom_bank[1] = (state->m_mmc_vrom_bank[1] & 0x10) | (data & 0x0f);
3463         chr4_4(space.machine(), state->m_mmc_vrom_bank[1], CHRROM);
3435         m_mmc_vrom_bank[1] = (m_mmc_vrom_bank[1] & 0x10) | (data & 0x0f);
3436         chr4_4(machine(), m_mmc_vrom_bank[1], CHRROM);
34643437         break;
34653438   }
34663439}
r18063r18064
34733446
34743447 *************************************************************/
34753448
3476static WRITE8_HANDLER( konami_vrc2_w )
3449WRITE8_MEMBER(nes_state::konami_vrc2_w)
34773450{
3478   nes_state *state = space.machine().driver_data<nes_state>();
34793451   UINT8 bank, shift, mask;
34803452   UINT32 shifted_offs = (offset & 0x7000)
3481                  | ((offset << (9 - state->m_vrc_ls_prg_a)) & 0x200)
3482                  | ((offset << (8 - state->m_vrc_ls_prg_b)) & 0x100);
3453                  | ((offset << (9 - m_vrc_ls_prg_a)) & 0x200)
3454                  | ((offset << (8 - m_vrc_ls_prg_b)) & 0x100);
34833455   LOG_MMC(("konami_vrc2_w, offset: %04x, data: %02x\n", offset, data));
34843456
34853457   if (offset < 0x1000)
3486      prg8_89(space.machine(), data);
3458      prg8_89(machine(), data);
34873459   else if (offset < 0x2000)
34883460   {
34893461      switch (data & 0x03)
34903462      {
3491         case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
3492         case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
3493         case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
3494         case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
3463         case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
3464         case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
3465         case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
3466         case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
34953467      }
34963468   }
34973469   else if (offset < 0x3000)
3498      prg8_ab(space.machine(), data);
3470      prg8_ab(machine(), data);
34993471   else if (offset < 0x7000)
35003472   {
35013473      bank = ((shifted_offs & 0x7000) - 0x3000) / 0x0800 + BIT(shifted_offs, 9);
35023474      shift = BIT(shifted_offs, 8) * 4;
35033475      mask = (0xf0 >> shift);
3504      state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & mask)
3505                           | (((data >> state->m_vrc_ls_chr) & 0x0f) << shift);
3506      chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
3476      m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & mask)
3477                           | (((data >> m_vrc_ls_chr) & 0x0f) << shift);
3478      chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
35073479   }
35083480   else
35093481      logerror("konami_vrc2_w uncaught write, addr: %04x value: %02x\n", offset + 0x8000, data);
r18063r18064
35213493
35223494 *************************************************************/
35233495
3524static WRITE8_HANDLER( konami_vrc3_w )
3496WRITE8_MEMBER(nes_state::konami_vrc3_w)
35253497{
35263498   LOG_MMC(("konami_vrc3_w, offset: %04x, data: %02x\n", offset, data));
3527   nes_state *state = space.machine().driver_data<nes_state>();
35283499
35293500   switch (offset & 0x7000)
35303501   {
35313502      case 0x0000:
35323503      case 0x1000:
35333504         /* dunno which address controls these */
3534         state->m_IRQ_count_latch = data;
3535         state->m_IRQ_enable_latch = data;
3505         m_IRQ_count_latch = data;
3506         m_IRQ_enable_latch = data;
35363507         break;
35373508      case 0x2000:
3538         state->m_IRQ_enable = data;
3509         m_IRQ_enable = data;
35393510         break;
35403511      case 0x3000:
3541         state->m_IRQ_count &= ~0x0f;
3542         state->m_IRQ_count |= data & 0x0f;
3512         m_IRQ_count &= ~0x0f;
3513         m_IRQ_count |= data & 0x0f;
35433514         break;
35443515      case 0x4000:
3545         state->m_IRQ_count &= ~0xf0;
3546         state->m_IRQ_count |= (data & 0x0f) << 4;
3516         m_IRQ_count &= ~0xf0;
3517         m_IRQ_count |= (data & 0x0f) << 4;
35473518         break;
35483519      case 0x7000:
3549         prg16_89ab(space.machine(), data);
3520         prg16_89ab(machine(), data);
35503521         break;
35513522      default:
35523523         logerror("konami_vrc3_w uncaught write, offset %04x, data: %02x\n", offset, data);
r18063r18064
35893560   }
35903561}
35913562
3592static WRITE8_HANDLER( konami_vrc4_w )
3563WRITE8_MEMBER(nes_state::konami_vrc4_w)
35933564{
3594   nes_state *state = space.machine().driver_data<nes_state>();
35953565   UINT8 bank, shift, mask;
35963566   UINT32 shifted_offs = (offset & 0x7000)
3597                  | ((offset << (9 - state->m_vrc_ls_prg_a)) & 0x200)
3598                  | ((offset << (8 - state->m_vrc_ls_prg_b)) & 0x100);
3567                  | ((offset << (9 - m_vrc_ls_prg_a)) & 0x200)
3568                  | ((offset << (8 - m_vrc_ls_prg_b)) & 0x100);
35993569   LOG_MMC(("konami_vrc4_w, offset: %04x, data: %02x\n", offset, data));
36003570
36013571   if (offset < 0x1000)
36023572   {
3603      state->m_mmc_prg_bank[0] = data;
3604      vrc4_set_prg(space.machine());
3573      m_mmc_prg_bank[0] = data;
3574      vrc4_set_prg(machine());
36053575   }
36063576   else if (offset >= 0x2000 && offset < 0x3000)
3607      prg8_ab(space.machine(), data);
3577      prg8_ab(machine(), data);
36083578   else
36093579   {
36103580      switch (shifted_offs & 0x7300)
r18063r18064
36133583         case 0x1100:
36143584            switch (data & 0x03)
36153585            {
3616            case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
3617            case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
3618            case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
3619            case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
3586            case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
3587            case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
3588            case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
3589            case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
36203590            }
36213591            break;
36223592         case 0x1200:
36233593         case 0x1300:
3624            state->m_mmc_latch1 = data & 0x02;
3625            vrc4_set_prg(space.machine());
3594            m_mmc_latch1 = data & 0x02;
3595            vrc4_set_prg(machine());
36263596            break;
36273597         case 0x3000:
36283598         case 0x3100:
r18063r18064
36433613            bank = ((shifted_offs & 0x7000) - 0x3000) / 0x0800 + BIT(shifted_offs, 9);
36443614            shift = BIT(shifted_offs, 8) * 4;
36453615            mask = (0xf0 >> shift);
3646            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & mask) | ((data & 0x0f) << shift);
3647            chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
3616            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & mask) | ((data & 0x0f) << shift);
3617            chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
36483618            break;
36493619         case 0x7000:
3650            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xf0) | (data & 0x0f);
3620            m_IRQ_count_latch = (m_IRQ_count_latch & 0xf0) | (data & 0x0f);
36513621            break;
36523622         case 0x7100:
3653            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
3623            m_IRQ_count_latch = (m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
36543624            break;
36553625         case 0x7200:
3656            state->m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3657            state->m_IRQ_enable = data & 0x02;
3658            state->m_IRQ_enable_latch = data & 0x01;
3626            m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3627            m_IRQ_enable = data & 0x02;
3628            m_IRQ_enable_latch = data & 0x01;
36593629            if (data & 0x02)
3660               state->m_IRQ_count = state->m_IRQ_count_latch;
3630               m_IRQ_count = m_IRQ_count_latch;
36613631            break;
36623632         case 0x7300:
3663            state->m_IRQ_enable = state->m_IRQ_enable_latch;
3633            m_IRQ_enable = m_IRQ_enable_latch;
36643634            break;
36653635         default:
36663636            logerror("konami_vrc4_w uncaught write, addr: %04x value: %02x\n", shifted_offs + 0x8000, data);
r18063r18064
36783648
36793649 *************************************************************/
36803650
3681static WRITE8_HANDLER( konami_vrc6_w )
3651WRITE8_MEMBER(nes_state::konami_vrc6_w)
36823652{
3683   nes_state *state = space.machine().driver_data<nes_state>();
36843653   UINT8 bank;
36853654   UINT32 shifted_offs = (offset & 0x7000)
3686                  | ((offset << (9 - state->m_vrc_ls_prg_a)) & 0x200)
3687                  | ((offset << (8 - state->m_vrc_ls_prg_b)) & 0x100);
3655                  | ((offset << (9 - m_vrc_ls_prg_a)) & 0x200)
3656                  | ((offset << (8 - m_vrc_ls_prg_b)) & 0x100);
36883657   LOG_MMC(("konami_vrc6_w, offset: %04x, data: %02x\n", offset, data));
36893658
36903659   if (offset < 0x1000)
3691      prg16_89ab(space.machine(), data);
3660      prg16_89ab(machine(), data);
36923661   else if (offset >= 0x4000 && offset < 0x5000)
3693      prg8_cd(space.machine(), data);
3662      prg8_cd(machine(), data);
36943663   else
36953664   {
36963665      switch (shifted_offs & 0x7300)
r18063r18064
37093678         case 0x3300:
37103679            switch (data & 0x0c)
37113680            {
3712            case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
3713            case 0x04: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
3714            case 0x08: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
3715            case 0x0c: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
3681            case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
3682            case 0x04: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
3683            case 0x08: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
3684            case 0x0c: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
37163685            }
37173686            break;
37183687         case 0x5000:
r18063r18064
37243693         case 0x6200:
37253694         case 0x6300:
37263695            bank = ((shifted_offs & 0x7000) - 0x5000) / 0x0400 + ((shifted_offs & 0x0300) >> 8);
3727            chr1_x(space.machine(), bank, data, CHRROM);
3696            chr1_x(machine(), bank, data, CHRROM);
37283697            break;
37293698         case 0x7000:
3730            state->m_IRQ_count_latch = data;
3699            m_IRQ_count_latch = data;
37313700            break;
37323701         case 0x7100:
3733            state->m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3734            state->m_IRQ_enable = data & 0x02;
3735            state->m_IRQ_enable_latch = data & 0x01;
3702            m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3703            m_IRQ_enable = data & 0x02;
3704            m_IRQ_enable_latch = data & 0x01;
37363705            if (data & 0x02)
3737               state->m_IRQ_count = state->m_IRQ_count_latch;
3706               m_IRQ_count = m_IRQ_count_latch;
37383707            break;
37393708         case 0x7200:
3740            state->m_IRQ_enable = state->m_IRQ_enable_latch;
3709            m_IRQ_enable = m_IRQ_enable_latch;
37413710            break;
37423711         default:
37433712            logerror("konami_vrc6_w uncaught write, addr: %04x value: %02x\n", shifted_offs + 0x8000, data);
r18063r18064
37583727
37593728 *************************************************************/
37603729
3761static WRITE8_HANDLER( konami_vrc7_w )
3730WRITE8_MEMBER(nes_state::konami_vrc7_w)
37623731{
3763   nes_state *state = space.machine().driver_data<nes_state>();
37643732   UINT8 bank;
37653733   LOG_MMC(("konami_vrc7_w, offset: %04x, data: %02x\n", offset, data));
37663734
37673735   switch (offset & 0x7018)
37683736   {
37693737      case 0x0000:
3770         prg8_89(space.machine(), data);
3738         prg8_89(machine(), data);
37713739         break;
37723740      case 0x0008:
37733741      case 0x0010:
37743742      case 0x0018:
3775         prg8_ab(space.machine(), data);
3743         prg8_ab(machine(), data);
37763744         break;
37773745
37783746      case 0x1000:
3779         prg8_cd(space.machine(), data);
3747         prg8_cd(machine(), data);
37803748         break;
37813749
37823750         /* TODO: there are sound regs in here */
r18063r18064
37983766      case 0x5010:
37993767      case 0x5018:
38003768         bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0018) ? 1 : 0);
3801         chr1_x(space.machine(), bank, data, state->m_mmc_chr_source);
3769         chr1_x(machine(), bank, data, m_mmc_chr_source);
38023770         break;
38033771
38043772      case 0x6000:
38053773         switch (data & 0x03)
38063774         {
3807         case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
3808         case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
3809         case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
3810         case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
3775         case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
3776         case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
3777         case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
3778         case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
38113779         }
38123780         break;
38133781      case 0x6008: case 0x6010: case 0x6018:
3814         state->m_IRQ_count_latch = data;
3782         m_IRQ_count_latch = data;
38153783         break;
38163784      case 0x7000:
3817         state->m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3818         state->m_IRQ_enable = data & 0x02;
3819         state->m_IRQ_enable_latch = data & 0x01;
3785         m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
3786         m_IRQ_enable = data & 0x02;
3787         m_IRQ_enable_latch = data & 0x01;
38203788         if (data & 0x02)
3821            state->m_IRQ_count = state->m_IRQ_count_latch;
3789            m_IRQ_count = m_IRQ_count_latch;
38223790         break;
38233791      case 0x7008: case 0x7010: case 0x7018:
3824         state->m_IRQ_enable = state->m_IRQ_enable_latch;
3792         m_IRQ_enable = m_IRQ_enable_latch;
38253793         break;
38263794
38273795      default:
r18063r18064
38623830   }
38633831}
38643832
3865static WRITE8_HANDLER( namcot163_l_w )
3833WRITE8_MEMBER(nes_state::namcot163_l_w)
38663834{
3867   nes_state *state = space.machine().driver_data<nes_state>();
38683835   LOG_MMC(("namcot163_l_w, offset: %04x, data: %02x\n", offset, data));
38693836   offset += 0x100;
38703837
r18063r18064
38743841         LOG_MMC(("Namcot-163 sound reg write, data: %02x\n", data));
38753842         break;
38763843      case 0x1000: /* low byte of IRQ */
3877         state->m_IRQ_count = (state->m_IRQ_count & 0x7f00) | data;
3844         m_IRQ_count = (m_IRQ_count & 0x7f00) | data;
38783845         break;
38793846      case 0x1800: /* high byte of IRQ, IRQ enable in high bit */
3880         state->m_IRQ_count = (state->m_IRQ_count & 0xff) | ((data & 0x7f) << 8);
3881         state->m_IRQ_enable = data & 0x80;
3847         m_IRQ_count = (m_IRQ_count & 0xff) | ((data & 0x7f) << 8);
3848         m_IRQ_enable = data & 0x80;
38823849         break;
38833850   }
38843851}
38853852
3886static READ8_HANDLER( namcot163_l_r )
3853READ8_MEMBER(nes_state::namcot163_l_r)
38873854{
3888   nes_state *state = space.machine().driver_data<nes_state>();
38893855   LOG_MMC(("namcot163_l_r, offset: %04x\n", offset));
38903856   offset += 0x100;
38913857
38923858   switch (offset & 0x1800)
38933859   {
38943860      case 0x1000:
3895         return state->m_IRQ_count & 0xff;
3861         return m_IRQ_count & 0xff;
38963862      case 0x1800:
3897         return (state->m_IRQ_count >> 8) & 0xff;
3863         return (m_IRQ_count >> 8) & 0xff;
38983864      case 0x0800:
38993865         LOG_MMC(("Namcot-163 sound reg read\n"));
39003866      default:
r18063r18064
39103876      set_nt_page(machine, page, ROM, data, 0);
39113877}
39123878
3913static WRITE8_HANDLER( namcot163_w )
3879WRITE8_MEMBER(nes_state::namcot163_w)
39143880{
3915   nes_state *state = space.machine().driver_data<nes_state>();
39163881   LOG_MMC(("namcot163_w, offset: %04x, data: %02x\n", offset, data));
39173882   switch (offset & 0x7800)
39183883   {
r18063r18064
39203885      case 0x1000: case 0x1800:
39213886      case 0x2000: case 0x2800:
39223887      case 0x3000: case 0x3800:
3923         chr1_x(space.machine(), offset / 0x800, data, CHRROM);
3888         chr1_x(machine(), offset / 0x800, data, CHRROM);
39243889         break;
39253890      case 0x4000:
3926         namcot163_set_mirror(space.machine(), 0, data);
3891         namcot163_set_mirror(machine(), 0, data);
39273892         break;
39283893      case 0x4800:
3929         namcot163_set_mirror(space.machine(), 1, data);
3894         namcot163_set_mirror(machine(), 1, data);
39303895         break;
39313896      case 0x5000:
3932         namcot163_set_mirror(space.machine(), 2, data);
3897         namcot163_set_mirror(machine(), 2, data);
39333898         break;
39343899      case 0x5800:
3935         namcot163_set_mirror(space.machine(), 3, data);
3900         namcot163_set_mirror(machine(), 3, data);
39363901         break;
39373902      case 0x6000:
3938         prg8_89(space.machine(), data & 0x3f);
3903         prg8_89(machine(), data & 0x3f);
39393904         break;
39403905      case 0x6800:
3941         state->m_mmc_latch1 = data & 0xc0;      // this should enable High CHRRAM, but we still have to properly implement it!
3942         prg8_ab(space.machine(), data & 0x3f);
3906         m_mmc_latch1 = data & 0xc0;      // this should enable High CHRRAM, but we still have to properly implement it!
3907         prg8_ab(machine(), data & 0x3f);
39433908         break;
39443909      case 0x7000:
3945         prg8_cd(space.machine(), data & 0x3f);
3910         prg8_cd(machine(), data & 0x3f);
39463911         break;
39473912      case 0x7800:
39483913         LOG_MMC(("Namcot-163 sound address write, data: %02x\n", data));
r18063r18064
39623927
39633928 *************************************************************/
39643929
3965static WRITE8_HANDLER( sunsoft1_m_w )
3930WRITE8_MEMBER(nes_state::sunsoft1_m_w)
39663931{
3967   nes_state *state = space.machine().driver_data<nes_state>();
39683932   LOG_MMC(("sunsoft1_m_w, offset: %04x, data: %02x\n", offset, data));
39693933
3970   if (state->m_chr_chunks)
3934   if (m_chr_chunks)
39713935   {
3972      chr4_0(space.machine(), data & 0x0f, CHRROM);
3973      chr4_4(space.machine(), data >> 4, CHRROM);
3936      chr4_0(machine(), data & 0x0f, CHRROM);
3937      chr4_4(machine(), data >> 4, CHRROM);
39743938   }
39753939   else
3976      prg16_89ab(space.machine(), data & 0x0f);
3940      prg16_89ab(machine(), data & 0x0f);
39773941}
39783942
39793943/*************************************************************
r18063r18064
39873951
39883952 *************************************************************/
39893953
3990static WRITE8_HANDLER( sunsoft2_w )
3954WRITE8_MEMBER(nes_state::sunsoft2_w)
39913955{
3992   nes_state *state = space.machine().driver_data<nes_state>();
39933956   UINT8 sunsoft_helper = (data & 0x07) | ((data & 0x80) ? 0x08 : 0x00);
39943957   LOG_MMC(("sunsoft2_w, offset: %04x, data: %02x\n", offset, data));
39953958
3996   if (!state->m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
3997      set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
3998   if (state->m_chr_chunks)
3999      chr8(space.machine(), sunsoft_helper, CHRROM);
3959   if (!m_hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
3960      set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
3961   if (m_chr_chunks)
3962      chr8(machine(), sunsoft_helper, CHRROM);
40003963
4001   prg16_89ab(space.machine(), data >> 4);
3964   prg16_89ab(machine(), data >> 4);
40023965}
40033966
40043967/*************************************************************
r18063r18064
40343997   }
40353998}
40363999
4037static WRITE8_HANDLER( sunsoft3_w )
4000WRITE8_MEMBER(nes_state::sunsoft3_w)
40384001{
4039   nes_state *state = space.machine().driver_data<nes_state>();
40404002   LOG_MMC(("sunsoft3_w, offset %04x, data: %02x\n", offset, data));
40414003
40424004   switch (offset & 0x7800)
40434005   {
40444006      case 0x0800:
4045         chr2_0(space.machine(), data, CHRROM);
4007         chr2_0(machine(), data, CHRROM);
40464008         break;
40474009      case 0x1800:
4048         chr2_2(space.machine(), data, CHRROM);
4010         chr2_2(machine(), data, CHRROM);
40494011         break;
40504012      case 0x2800:
4051         chr2_4(space.machine(), data, CHRROM);
4013         chr2_4(machine(), data, CHRROM);
40524014         break;
40534015      case 0x3800:
4054         chr2_6(space.machine(), data, CHRROM);
4016         chr2_6(machine(), data, CHRROM);
40554017         break;
40564018      case 0x4000:
40574019      case 0x4800:
4058         state->m_IRQ_toggle ^= 1;
4059         if (state->m_IRQ_toggle)
4060            state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
4020         m_IRQ_toggle ^= 1;
4021         if (m_IRQ_toggle)
4022            m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
40614023         else
4062            state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
4024            m_IRQ_count = (m_IRQ_count & 0xff00) | data;
40634025         break;
40644026      case 0x5800:
4065         state->m_IRQ_enable = BIT(data, 4);
4066         state->m_IRQ_toggle = 0;
4027         m_IRQ_enable = BIT(data, 4);
4028         m_IRQ_toggle = 0;
40674029         break;
40684030      case 0x6800:
40694031         switch (data & 3)
40704032         {
4071         case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
4072         case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
4073         case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
4074         case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
4033         case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
4034         case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
4035         case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
4036         case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
40754037         }
40764038         break;
40774039      case 0x7800:
4078         prg16_89ab(space.machine(), data);
4040         prg16_89ab(machine(), data);
40794041         break;
40804042      default:
40814043         LOG_MMC(("sunsoft3_w uncaught write, offset: %04x, data: %02x\n", offset, data));
r18063r18064
40974059
40984060 *************************************************************/
40994061
4100static WRITE8_HANDLER( tc0190fmc_w )
4062WRITE8_MEMBER(nes_state::tc0190fmc_w)
41014063{
41024064   LOG_MMC(("tc0190fmc_w, offset: %04x, data: %02x\n", offset, data));
41034065
41044066   switch (offset & 0x7003)
41054067   {
41064068      case 0x0000:
4107         set_nt_mirroring(space.machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4108         prg8_89(space.machine(), data);
4069         set_nt_mirroring(machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4070         prg8_89(machine(), data);
41094071         break;
41104072      case 0x0001:
4111         prg8_ab(space.machine(), data);
4073         prg8_ab(machine(), data);
41124074         break;
41134075      case 0x0002:
4114         chr2_0(space.machine(), data, CHRROM);
4076         chr2_0(machine(), data, CHRROM);
41154077         break;
41164078      case 0x0003:
4117         chr2_2(space.machine(), data, CHRROM);
4079         chr2_2(machine(), data, CHRROM);
41184080         break;
41194081      case 0x2000:
4120         chr1_4(space.machine(), data, CHRROM);
4082         chr1_4(machine(), data, CHRROM);
41214083         break;
41224084      case 0x2001:
4123         chr1_5(space.machine(), data, CHRROM);
4085         chr1_5(machine(), data, CHRROM);
41244086         break;
41254087      case 0x2002:
4126         chr1_6(space.machine(), data, CHRROM);
4088         chr1_6(machine(), data, CHRROM);
41274089         break;
41284090      case 0x2003:
4129         chr1_7(space.machine(), data, CHRROM);
4091         chr1_7(machine(), data, CHRROM);
41304092         break;
41314093   }
41324094}
r18063r18064
41504112
41514113 *************************************************************/
41524114
4153static WRITE8_HANDLER( tc0190fmc_p16_w )
4115WRITE8_MEMBER(nes_state::tc0190fmc_p16_w)
41544116{
4155   nes_state *state = space.machine().driver_data<nes_state>();
41564117   LOG_MMC(("tc0190fmc_p16_w, offset: %04x, data: %02x\n", offset, data));
41574118
41584119   switch (offset & 0x7003)
41594120   {
41604121      case 0x0000:
4161         prg8_89(space.machine(), data);
4122         prg8_89(machine(), data);
41624123         break;
41634124      case 0x0001:
41644125      case 0x0002:
r18063r18064
41704131         tc0190fmc_w(space, offset, data, mem_mask);
41714132         break;
41724133      case 0x4000:
4173         state->m_IRQ_count_latch = (0x100 - data) & 0xff;
4134         m_IRQ_count_latch = (0x100 - data) & 0xff;
41744135         break;
41754136      case 0x4001:
4176         state->m_IRQ_count = state->m_IRQ_count_latch;
4137         m_IRQ_count = m_IRQ_count_latch;
41774138         break;
41784139      case 0x4002:
4179         state->m_IRQ_enable = 1;
4140         m_IRQ_enable = 1;
41804141         break;
41814142      case 0x4003:
4182         state->m_IRQ_enable = 0;
4143         m_IRQ_enable = 0;
41834144         break;
41844145      case 0x6000:
4185         set_nt_mirroring(space.machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4146         set_nt_mirroring(machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
41864147         break;
41874148   }
41884149}
r18063r18064
42014162
42024163 *************************************************************/
42034164
4204static WRITE8_HANDLER( x1005_m_w )
4165WRITE8_MEMBER(nes_state::x1005_m_w)
42054166{
4206   nes_state *state = space.machine().driver_data<nes_state>();
42074167   LOG_MMC(("x1005_m_w, offset: %04x, data: %02x\n", offset, data));
42084168
42094169   switch (offset)
42104170   {
42114171      case 0x1ef0:
4212         chr2_0(space.machine(), (data & 0x7f) >> 1, CHRROM);
4172         chr2_0(machine(), (data & 0x7f) >> 1, CHRROM);
42134173         break;
42144174      case 0x1ef1:
4215         chr2_2(space.machine(), (data & 0x7f) >> 1, CHRROM);
4175         chr2_2(machine(), (data & 0x7f) >> 1, CHRROM);
42164176         break;
42174177      case 0x1ef2:
4218         chr1_4(space.machine(), data, CHRROM);
4178         chr1_4(machine(), data, CHRROM);
42194179         break;
42204180      case 0x1ef3:
4221         chr1_5(space.machine(), data, CHRROM);
4181         chr1_5(machine(), data, CHRROM);
42224182         break;
42234183      case 0x1ef4:
4224         chr1_6(space.machine(), data, CHRROM);
4184         chr1_6(machine(), data, CHRROM);
42254185         break;
42264186      case 0x1ef5:
4227         chr1_7(space.machine(), data, CHRROM);
4187         chr1_7(machine(), data, CHRROM);
42284188         break;
42294189      case 0x1ef6:
42304190      case 0x1ef7:
4231         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
4191         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
42324192         break;
42334193      case 0x1ef8:
42344194      case 0x1ef9:
4235         state->m_mmc_latch1 = data;
4195         m_mmc_latch1 = data;
42364196         break;
42374197      case 0x1efa:
42384198      case 0x1efb:
4239         prg8_89(space.machine(), data);
4199         prg8_89(machine(), data);
42404200         break;
42414201      case 0x1efc:
42424202      case 0x1efd:
4243         prg8_ab(space.machine(), data);
4203         prg8_ab(machine(), data);
42444204         break;
42454205      case 0x1efe:
42464206      case 0x1eff:
4247         prg8_cd(space.machine(), data);
4207         prg8_cd(machine(), data);
42484208         break;
42494209      default:
42504210         logerror("mapper80_m_w uncaught addr: %04x, value: %02x\n", offset + 0x6000, data);
42514211         break;
42524212   }
42534213
4254   if (offset >= 0x1f00 && state->m_mapper_ram != NULL && state->m_mmc_latch1 == 0xa3)
4255      state->m_mapper_ram[offset & (state->m_mapper_ram_size - 1)] = data;
4256   else if (offset >= 0x1f00 && state->m_mapper_bram != NULL && state->m_mmc_latch1 == 0xa3)
4257      state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)] = data;
4214   if (offset >= 0x1f00 && m_mapper_ram != NULL && m_mmc_latch1 == 0xa3)
4215      m_mapper_ram[offset & (m_mapper_ram_size - 1)] = data;
4216   else if (offset >= 0x1f00 && m_mapper_bram != NULL && m_mmc_latch1 == 0xa3)
4217      m_mapper_bram[offset & (m_mapper_bram_size - 1)] = data;
42584218}
42594219
4260static READ8_HANDLER( x1005_m_r )
4220READ8_MEMBER(nes_state::x1005_m_r)
42614221{
4262   nes_state *state = space.machine().driver_data<nes_state>();
42634222   LOG_MMC(("x1005a_m_r, offset: %04x\n", offset));
42644223
4265   if (offset >= 0x1f00 && state->m_mapper_ram != NULL && state->m_mmc_latch1 == 0xa3)
4266      return state->m_mapper_ram[offset & (state->m_mapper_ram_size - 1)];
4267   else if (offset >= 0x1f00 && state->m_mapper_bram != NULL && state->m_mmc_latch1 == 0xa3)
4268      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
4224   if (offset >= 0x1f00 && m_mapper_ram != NULL && m_mmc_latch1 == 0xa3)
4225      return m_mapper_ram[offset & (m_mapper_ram_size - 1)];
4226   else if (offset >= 0x1f00 && m_mapper_bram != NULL && m_mmc_latch1 == 0xa3)
4227      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
42694228
42704229   return 0xff;
42714230}
42724231
4273static WRITE8_HANDLER( x1005a_m_w )
4232WRITE8_MEMBER(nes_state::x1005a_m_w)
42744233{
42754234   LOG_MMC(("x1005a_m_w, offset: %04x, data: %02x\n", offset, data));
42764235
r18063r18064
42814240   switch (offset)
42824241   {
42834242      case 0x1ef0:
4284         set_nt_page(space.machine(), 0, CIRAM, (data & 0x80) ? 1 : 0, 1);
4285         set_nt_page(space.machine(), 1, CIRAM, (data & 0x80) ? 1 : 0, 1);
4243         set_nt_page(machine(), 0, CIRAM, (data & 0x80) ? 1 : 0, 1);
4244         set_nt_page(machine(), 1, CIRAM, (data & 0x80) ? 1 : 0, 1);
42864245         break;
42874246      case 0x1ef1:
4288         set_nt_page(space.machine(), 2, CIRAM, (data & 0x80) ? 1 : 0, 1);
4289         set_nt_page(space.machine(), 3, CIRAM, (data & 0x80) ? 1 : 0, 1);
4247         set_nt_page(machine(), 2, CIRAM, (data & 0x80) ? 1 : 0, 1);
4248         set_nt_page(machine(), 3, CIRAM, (data & 0x80) ? 1 : 0, 1);
42904249         break;
42914250   }
42924251
r18063r18064
43284287   chr1_x(machine, 7 ^ state->m_mmc_latch1, state->m_mmc_vrom_bank[5], CHRROM);
43294288}
43304289
4331static WRITE8_HANDLER( x1017_m_w )
4290WRITE8_MEMBER(nes_state::x1017_m_w)
43324291{
4333   nes_state *state = space.machine().driver_data<nes_state>();
43344292   UINT8 reg = offset & 0x07;
43354293   LOG_MMC(("x1017_m_w, offset: %04x, data: %02x\n", offset, data));
43364294
r18063r18064
43384296   {
43394297      case 0x1ef0:
43404298      case 0x1ef1:
4341         if (state->m_mmc_vrom_bank[reg] != data)
4299         if (m_mmc_vrom_bank[reg] != data)
43424300         {
4343            state->m_mmc_vrom_bank[reg] = data;
4344            x1017_set_chr(space.machine());
4301            m_mmc_vrom_bank[reg] = data;
4302            x1017_set_chr(machine());
43454303         }
43464304         break;
43474305      case 0x1ef2:
43484306      case 0x1ef3:
43494307      case 0x1ef4:
43504308      case 0x1ef5:
4351         if (state->m_mmc_vrom_bank[reg] != data)
4309         if (m_mmc_vrom_bank[reg] != data)
43524310         {
4353            state->m_mmc_vrom_bank[reg] = data;
4354            x1017_set_chr(space.machine());
4311            m_mmc_vrom_bank[reg] = data;
4312            x1017_set_chr(machine());
43554313         }
43564314         break;
43574315      case 0x1ef6:
4358         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
4359         state->m_mmc_latch1 = ((data & 0x02) << 1);
4360         x1017_set_chr(space.machine());
4316         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
4317         m_mmc_latch1 = ((data & 0x02) << 1);
4318         x1017_set_chr(machine());
43614319         break;
43624320      case 0x1ef7:
43634321      case 0x1ef8:
43644322      case 0x1ef9:
4365         state->m_mmc_reg[(offset & 0x0f) - 7] = data;
4323         m_mmc_reg[(offset & 0x0f) - 7] = data;
43664324         break;
43674325      case 0x1efa:
4368         prg8_89(space.machine(), data >> 2);
4326         prg8_89(machine(), data >> 2);
43694327         break;
43704328      case 0x1efb:
4371         prg8_ab(space.machine(), data >> 2);
4329         prg8_ab(machine(), data >> 2);
43724330         break;
43734331      case 0x1efc:
4374         prg8_cd(space.machine(), data >> 2);
4332         prg8_cd(machine(), data >> 2);
43754333         break;
43764334      default:
43774335         logerror("x1017_m_w uncaught write, addr: %04x, value: %02x\n", offset + 0x6000, data);
r18063r18064
43794337   }
43804338}
43814339
4382static READ8_HANDLER( x1017_m_r )
4340READ8_MEMBER(nes_state::x1017_m_r)
43834341{
4384   nes_state *state = space.machine().driver_data<nes_state>();
43854342   LOG_MMC(("x1017_m_r, offset: %04x\n", offset));
43864343
43874344   // 2+2+1 KB of Internal RAM can be independently enabled/disabled!
4388   if (offset < 0x0800 && state->m_mapper_bram != NULL && state->m_mmc_reg[0] == 0xca)
4389      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
4390   if (offset < 0x1000 && state->m_mapper_bram != NULL && state->m_mmc_reg[1] == 0x69)
4391      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
4392   if (offset < 0x1800 && state->m_mapper_bram != NULL && state->m_mmc_reg[2] == 0x84)
4393      return state->m_mapper_bram[offset & (state->m_mapper_bram_size - 1)];
4345   if (offset < 0x0800 && m_mapper_bram != NULL && m_mmc_reg[0] == 0xca)
4346      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
4347   if (offset < 0x1000 && m_mapper_bram != NULL && m_mmc_reg[1] == 0x69)
4348      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
4349   if (offset < 0x1800 && m_mapper_bram != NULL && m_mmc_reg[2] == 0x84)
4350      return m_mapper_bram[offset & (m_mapper_bram_size - 1)];
43944351
43954352   return 0xff;
43964353}
r18063r18064
44134370
44144371 *************************************************************/
44154372
4416static WRITE8_HANDLER( agci_50282_w )
4373WRITE8_MEMBER(nes_state::agci_50282_w)
44174374{
44184375   LOG_MMC(("agci_50282_w, offset: %04x, data: %02x\n", offset, data));
44194376
44204377   offset += 0x8000;
44214378   data |= (space.read_byte(offset) & 1);
44224379
4423   chr8(space.machine(), data >> 4, CHRROM);
4424   prg32(space.machine(), data);
4380   chr8(machine(), data >> 4, CHRROM);
4381   prg32(machine(), data);
44254382}
44264383
44274384/*************************************************************
r18063r18064
44324389
44334390 *************************************************************/
44344391
4435static WRITE8_HANDLER( nina01_m_w )
4392WRITE8_MEMBER(nes_state::nina01_m_w)
44364393{
44374394   LOG_MMC(("nina01_m_w, offset: %04x, data: %02x\n", offset, data));
44384395
44394396   switch (offset)
44404397   {
44414398      case 0x1ffd:
4442         prg32(space.machine(), data);
4399         prg32(machine(), data);
44434400         break;
44444401      case 0x1ffe:
4445         chr4_0(space.machine(), data, CHRROM);
4402         chr4_0(machine(), data, CHRROM);
44464403         break;
44474404      case 0x1fff:
4448         chr4_4(space.machine(), data, CHRROM);
4405         chr4_4(machine(), data, CHRROM);
44494406         break;
44504407   }
44514408}
r18063r18064
44634420
44644421 *************************************************************/
44654422
4466static WRITE8_HANDLER( nina06_l_w )
4423WRITE8_MEMBER(nes_state::nina06_l_w)
44674424{
44684425   LOG_MMC(("nina06_l_w, offset: %04x, data: %02x\n", offset, data));
44694426
44704427   if (!(offset & 0x0100))
44714428   {
4472      prg32(space.machine(), data >> 3);
4473      chr8(space.machine(), data, CHRROM);
4429      prg32(machine(), data >> 3);
4430      chr8(machine(), data, CHRROM);
44744431   }
44754432}
44764433
r18063r18064
44824439
44834440 *************************************************************/
44844441
4485static WRITE8_HANDLER( ae_act52_w )
4442WRITE8_MEMBER(nes_state::ae_act52_w)
44864443{
44874444   int pbank, cbank;
44884445   UINT8 pmode;
44894446   LOG_MMC(("ae_act52_w, offset: %04x, data: %02x\n", offset, data));
44904447
4491   set_nt_mirroring(space.machine(), BIT(offset, 13) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4448   set_nt_mirroring(machine(), BIT(offset, 13) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
44924449
44934450   cbank = (data & 0x03) | ((offset & 0x0f) << 2);
4494   chr8(space.machine(), cbank, CHRROM);
4451   chr8(machine(), cbank, CHRROM);
44954452
44964453   pmode = offset & 0x20;
44974454   pbank = (offset & 0x1fc0) >> 6;
44984455   if (pmode)
44994456   {
4500      prg16_89ab(space.machine(), pbank);
4501      prg16_cdef(space.machine(), pbank);
4457      prg16_89ab(machine(), pbank);
4458      prg16_cdef(machine(), pbank);
45024459   }
45034460   else
4504      prg32(space.machine(), pbank >> 1);
4461      prg32(machine(), pbank >> 1);
45054462}
45064463
45074464
r18063r18064
45204477
45214478 *************************************************************/
45224479
4523static WRITE8_HANDLER( cne_decathl_w )
4480WRITE8_MEMBER(nes_state::cne_decathl_w)
45244481{
45254482   LOG_MMC(("cne_decathl_w, offset: %04x, data: %02x\n", offset, data));
45264483
r18063r18064
45284485      return;
45294486   if (offset < 0x00a5)
45304487   {
4531      prg32(space.machine(), (offset - 0x0065) & 0x03);
4488      prg32(machine(), (offset - 0x0065) & 0x03);
45324489      return;
45334490   }
45344491   if (offset < 0x00e5)
45354492   {
4536      chr8(space.machine(), (offset - 0x00a5) & 0x07, CHRROM);
4493      chr8(machine(), (offset - 0x00a5) & 0x07, CHRROM);
45374494   }
45384495}
45394496
r18063r18064
45544511
45554512 *************************************************************/
45564513
4557static WRITE8_HANDLER( cne_fsb_m_w )
4514WRITE8_MEMBER(nes_state::cne_fsb_m_w)
45584515{
4559   nes_state *state = space.machine().driver_data<nes_state>();
45604516   LOG_MMC(("cne_fsb_m_w, offset: %04x, data: %02x\n", offset, data));
45614517
45624518   if (offset < 0x0800)
r18063r18064
45644520      switch (offset & 0x0007)
45654521      {
45664522         case 0x0000:
4567            prg8_89(space.machine(), data);
4523            prg8_89(machine(), data);
45684524            break;
45694525         case 0x0001:
4570            prg8_ab(space.machine(), data);
4526            prg8_ab(machine(), data);
45714527            break;
45724528         case 0x0002:
4573            prg8_cd(space.machine(), data);
4529            prg8_cd(machine(), data);
45744530            break;
45754531         case 0x0003:
4576            prg8_ef(space.machine(), data);
4532            prg8_ef(machine(), data);
45774533            break;
45784534         case 0x0004:
4579            chr2_0(space.machine(), data, CHRROM);
4535            chr2_0(machine(), data, CHRROM);
45804536            break;
45814537         case 0x0005:
4582            chr2_2(space.machine(), data, CHRROM);
4538            chr2_2(machine(), data, CHRROM);
45834539            break;
45844540         case 0x0006:
4585            chr2_4(space.machine(), data, CHRROM);
4541            chr2_4(machine(), data, CHRROM);
45864542            break;
45874543         case 0x0007:
4588            chr2_6(space.machine(), data, CHRROM);
4544            chr2_6(machine(), data, CHRROM);
45894545            break;
45904546      }
45914547   }
45924548   else
4593      state->m_battery_ram[offset] = data;
4549      m_battery_ram[offset] = data;
45944550}
45954551
45964552/*************************************************************
r18063r18064
46104566
46114567 *************************************************************/
46124568
4613static WRITE8_HANDLER( cne_shlz_l_w )
4569WRITE8_MEMBER(nes_state::cne_shlz_l_w)
46144570{
46154571   LOG_MMC(("cne_shlz_l_w, offset: %04x, data: %02x\n", offset, data));
46164572
4617   prg32(space.machine(), data >> 4);
4618   chr8(space.machine(), data & 0x0f, CHRROM);
4573   prg32(machine(), data >> 4);
4574   chr8(machine(), data & 0x0f, CHRROM);
46194575}
46204576
46214577/*************************************************************
r18063r18064
46304586
46314587 *************************************************************/
46324588
4633static WRITE8_HANDLER( caltron6in1_m_w )
4589WRITE8_MEMBER(nes_state::caltron6in1_m_w)
46344590{
4635   nes_state *state = space.machine().driver_data<nes_state>();
46364591   LOG_MMC(("caltron6in1_m_w, offset: %04x, data: %02x\n", offset, data));
46374592
4638   state->m_mmc_latch1 = offset & 0xff;
4639   set_nt_mirroring(space.machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4640   prg32(space.machine(), offset & 0x07);
4593   m_mmc_latch1 = offset & 0xff;
4594   set_nt_mirroring(machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4595   prg32(machine(), offset & 0x07);
46414596}
46424597
4643static WRITE8_HANDLER( caltron6in1_w )
4598WRITE8_MEMBER(nes_state::caltron6in1_w)
46444599{
4645   nes_state *state = space.machine().driver_data<nes_state>();
46464600   LOG_MMC(("caltron6in1_w, offset: %04x, data: %02x\n", offset, data));
46474601
4648   if (state->m_mmc_latch1 & 0x04)
4649      chr8(space.machine(), ((state->m_mmc_latch1 & 0x18) >> 1) | (data & 0x03), CHRROM);
4602   if (m_mmc_latch1 & 0x04)
4603      chr8(machine(), ((m_mmc_latch1 & 0x18) >> 1) | (data & 0x03), CHRROM);
46504604}
46514605
46524606/*************************************************************
r18063r18064
46664620
46674621 *************************************************************/
46684622
4669static WRITE8_HANDLER( bf9093_w )
4623WRITE8_MEMBER(nes_state::bf9093_w)
46704624{
4671   nes_state *state = space.machine().driver_data<nes_state>();
46724625   LOG_MMC(("bf9093_w, offset: %04x, data: %02x\n", offset, data));
46734626
46744627   switch (offset & 0x7000)
46754628   {
46764629      case 0x0000:
46774630      case 0x1000:
4678         if (!state->m_hard_mirroring)
4679            set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
4631         if (!m_hard_mirroring)
4632            set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
46804633         break;
46814634      case 0x4000:
46824635      case 0x5000:
46834636      case 0x6000:
46844637      case 0x7000:
4685         prg16_89ab(space.machine(), data);
4638         prg16_89ab(machine(), data);
46864639         break;
46874640   }
46884641}
r18063r18064
47124665   prg16_cdef(machine, 0x03 | ((state->m_mmc_latch1 & 0x18) >> 1));
47134666}
47144667
4715static WRITE8_HANDLER( bf9096_w )
4668WRITE8_MEMBER(nes_state::bf9096_w)
47164669{
4717   nes_state *state = space.machine().driver_data<nes_state>();
47184670   LOG_MMC(("bf9096_w, offset: %04x, data: %02x\n", offset, data));
47194671
47204672   if (offset < 0x2000)
4721      state->m_mmc_latch1 = data;
4673      m_mmc_latch1 = data;
47224674   else
4723      state->m_mmc_latch2 = data;
4675      m_mmc_latch2 = data;
47244676
4725   bf9096_set_prg(space.machine());
4677   bf9096_set_prg(machine());
47264678}
47274679
47284680/*************************************************************
r18063r18064
47374689
47384690 *************************************************************/
47394691
4740static WRITE8_HANDLER( golden5_w )
4692WRITE8_MEMBER(nes_state::golden5_w)
47414693{
4742   nes_state *state = space.machine().driver_data<nes_state>();
47434694   LOG_MMC(("golden5_w, offset: %04x, data: %02x\n", offset, data));
47444695
47454696   if (offset < 0x4000)
47464697   {
47474698      if (data & 0x08)
47484699      {
4749         state->m_mmc_prg_bank[0] = ((data & 0x07) << 4) | (state->m_mmc_prg_bank[0] & 0x0f);
4750         prg16_89ab(space.machine(), state->m_mmc_prg_bank[0]);
4751         prg16_cdef(space.machine(), ((data & 0x07) << 4) | 0x0f);
4700         m_mmc_prg_bank[0] = ((data & 0x07) << 4) | (m_mmc_prg_bank[0] & 0x0f);
4701         prg16_89ab(machine(), m_mmc_prg_bank[0]);
4702         prg16_cdef(machine(), ((data & 0x07) << 4) | 0x0f);
47524703      }
47534704
47544705   }
47554706   else
47564707   {
4757      state->m_mmc_prg_bank[0] = (state->m_mmc_prg_bank[0] & 0x70) | (data & 0x0f);
4758      prg16_89ab(space.machine(), state->m_mmc_prg_bank[0]);
4708      m_mmc_prg_bank[0] = (m_mmc_prg_bank[0] & 0x70) | (data & 0x0f);
4709      prg16_89ab(machine(), m_mmc_prg_bank[0]);
47594710   }
47604711}
47614712
r18063r18064
47724723
47734724 *************************************************************/
47744725
4775static WRITE8_HANDLER( cony_l_w )
4726WRITE8_MEMBER(nes_state::cony_l_w)
47764727{
4777   nes_state *state = space.machine().driver_data<nes_state>();
47784728   LOG_MMC(("cony_l_w, offset: %04x, data: %02x\n", offset, data));
47794729
47804730   if (offset >= 0x1000 && offset < 0x1103) // from 0x5100-0x51ff
4781      state->m_mapper83_low_reg[offset & 0x03] = data;
4731      m_mapper83_low_reg[offset & 0x03] = data;
47824732}
47834733
4784static READ8_HANDLER( cony_l_r )
4734READ8_MEMBER(nes_state::cony_l_r)
47854735{
4786   nes_state *state = space.machine().driver_data<nes_state>();
47874736   LOG_MMC(("cony_l_r, offset: %04x\n", offset));
47884737
47894738   if (offset == 0x0f00)   // 0x5000
r18063r18064
47914740      // read dipswitch bit! - currently unimplemented
47924741   }
47934742   if (offset >= 0x1000 && offset < 0x1103) // from 0x5100-0x51ff
4794      return state->m_mapper83_low_reg[offset & 0x03];
4743      return m_mapper83_low_reg[offset & 0x03];
47954744   else
47964745      return 0x00;
47974746}
r18063r18064
48314780   }
48324781}
48334782
4834static WRITE8_HANDLER( cony_w )
4783WRITE8_MEMBER(nes_state::cony_w)
48354784{
4836   nes_state *state = space.machine().driver_data<nes_state>();
48374785   LOG_MMC(("cony_w, offset: %04x, data: %02x\n", offset, data));
48384786
48394787   switch (offset)
48404788   {
48414789      case 0x0000:
4842         state->m_mmc_latch1 = 1;
4790         m_mmc_latch1 = 1;
48434791      case 0x3000:
48444792      case 0x30ff:
48454793      case 0x31ff:
4846         state->m_mapper83_reg[8] = data;
4847         cony_set_prg(space.machine());
4848         cony_set_chr(space.machine());
4794         m_mapper83_reg[8] = data;
4795         cony_set_prg(machine());
4796         cony_set_chr(machine());
48494797         break;
48504798      case 0x0100:
4851         state->m_mmc_reg[0] = data & 0x80;
4799         m_mmc_reg[0] = data & 0x80;
48524800         switch (data & 0x03)
48534801         {
48544802         case 0:
4855            set_nt_mirroring(space.machine(), PPU_MIRROR_VERT);
4803            set_nt_mirroring(machine(), PPU_MIRROR_VERT);
48564804            break;
48574805         case 1:
4858            set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ);
4806            set_nt_mirroring(machine(), PPU_MIRROR_HORZ);
48594807            break;
48604808         case 2:
4861            set_nt_mirroring(space.machine(), PPU_MIRROR_LOW);
4809            set_nt_mirroring(machine(), PPU_MIRROR_LOW);
48624810            break;
48634811         case 3:
4864            set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH);
4812            set_nt_mirroring(machine(), PPU_MIRROR_HIGH);
48654813            break;
48664814         }
48674815         break;
48684816      case 0x0200:
4869         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
4817         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
48704818         break;
48714819      case 0x0201:
4872         state->m_IRQ_enable = state->m_mmc_reg[0];
4873         state->m_IRQ_count = (data << 8) | (state->m_IRQ_count & 0xff);
4820         m_IRQ_enable = m_mmc_reg[0];
4821         m_IRQ_count = (data << 8) | (m_IRQ_count & 0xff);
48744822         break;
48754823      case 0x0300:
4876         prg8_89(space.machine(), data);
4824         prg8_89(machine(), data);
48774825         break;
48784826      case 0x0301:
4879         prg8_ab(space.machine(), data);
4827         prg8_ab(machine(), data);
48804828         break;
48814829      case 0x0302:
4882         prg8_cd(space.machine(), data);
4830         prg8_cd(machine(), data);
48834831         break;
48844832      case 0x0312:
48854833      case 0x0313:
48864834      case 0x0314:
48874835      case 0x0315:
4888         state->m_mmc_latch2 = 1;
4836         m_mmc_latch2 = 1;
48894837      case 0x0310:
48904838      case 0x0311:
48914839      case 0x0316:
48924840      case 0x0317:
4893         state->m_mapper83_reg[offset - 0x0310] = data;
4894         cony_set_chr(space.machine());
4841         m_mapper83_reg[offset - 0x0310] = data;
4842         cony_set_chr(machine());
48954843         break;
48964844      case 0x0318:
4897         state->m_mapper83_reg[9] = data;
4898         cony_set_prg(space.machine());
4845         m_mapper83_reg[9] = data;
4846         cony_set_prg(machine());
48994847         break;
49004848   }
49014849}
r18063r18064
49134861
49144862 *************************************************************/
49154863
4916static WRITE8_HANDLER( yoko_l_w )
4864WRITE8_MEMBER(nes_state::yoko_l_w)
49174865{
4918   nes_state *state = space.machine().driver_data<nes_state>();
49194866   LOG_MMC(("cony_l_w, offset: %04x, data: %02x\n", offset, data));
49204867
49214868   if (offset >= 0x1300) // from 0x5400
4922      state->m_mapper83_low_reg[offset & 0x03] = data;
4869      m_mapper83_low_reg[offset & 0x03] = data;
49234870}
49244871
4925static READ8_HANDLER( yoko_l_r )
4872READ8_MEMBER(nes_state::yoko_l_r)
49264873{
4927   nes_state *state = space.machine().driver_data<nes_state>();
49284874   LOG_MMC(("cony_l_r, offset: %04x\n", offset));
49294875
49304876   if (offset >= 0x0f00 && offset < 0x1300)   // 0x5000
r18063r18064
49324878      // read dipswitch bit! - currently unimplemented
49334879   }
49344880   if (offset >= 0x1300) // from 0x5400
4935      return state->m_mapper83_low_reg[offset & 0x03];
4881      return m_mapper83_low_reg[offset & 0x03];
49364882   else
49374883      return 0x00;
49384884}
r18063r18064
49664912   chr2_6(machine, state->m_mapper83_reg[7], CHRROM);
49674913}
49684914
4969static WRITE8_HANDLER( yoko_w )
4915WRITE8_MEMBER(nes_state::yoko_w)
49704916{
4971   nes_state *state = space.machine().driver_data<nes_state>();
49724917   LOG_MMC(("yoko_w, offset: %04x, data: %02x\n", offset, data));
49734918
49744919   switch (offset & 0x0c17)
49754920   {
49764921      case 0x0000:
4977         state->m_mmc_reg[1] = data;
4978         yoko_set_prg(space.machine());
4922         m_mmc_reg[1] = data;
4923         yoko_set_prg(machine());
49794924         break;
49804925      case 0x400:
4981         state->m_mmc_reg[0] = data;
4926         m_mmc_reg[0] = data;
49824927         if (data & 1)
4983            set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ);
4928            set_nt_mirroring(machine(), PPU_MIRROR_HORZ);
49844929         else
4985            set_nt_mirroring(space.machine(), PPU_MIRROR_VERT);
4986         yoko_set_prg(space.machine());
4930            set_nt_mirroring(machine(), PPU_MIRROR_VERT);
4931         yoko_set_prg(machine());
49874932         break;
49884933      case 0x0800:
4989         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
4934         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
49904935         break;
49914936      case 0x0801:
4992         state->m_IRQ_enable = state->m_mmc_reg[0] & 0x80;
4993         state->m_IRQ_count = (data << 8) | (state->m_IRQ_count & 0xff);
4937         m_IRQ_enable = m_mmc_reg[0] & 0x80;
4938         m_IRQ_count = (data << 8) | (m_IRQ_count & 0xff);
49944939         break;
49954940      case 0x0c00:
49964941      case 0x0c01:
49974942      case 0x0c02:
4998         state->m_mapper83_reg[offset & 3] = data;
4999         yoko_set_prg(space.machine());
4943         m_mapper83_reg[offset & 3] = data;
4944         yoko_set_prg(machine());
50004945         break;
50014946      case 0x0c10:
50024947      case 0x0c11:
50034948      case 0x0c16:
50044949      case 0x0c17:
5005         state->m_mapper83_reg[4 + (offset & 3)] = data;
5006         yoko_set_chr(space.machine());
4950         m_mapper83_reg[4 + (offset & 3)] = data;
4951         yoko_set_chr(machine());
50074952         break;
50084953   }
50094954}
r18063r18064
50184963
50194964 *************************************************************/
50204965
5021static WRITE8_HANDLER( dreamtech_l_w )
4966WRITE8_MEMBER(nes_state::dreamtech_l_w)
50224967{
50234968   LOG_MMC(("dreamtech_l_w offset: %04x, data: %02x\n", offset, data));
50244969   offset += 0x100;
50254970
50264971   if (offset == 0x1020)   /* 0x5020 */
5027      prg16_89ab(space.machine(), data);
4972      prg16_89ab(machine(), data);
50284973}
50294974
50304975/*************************************************************
r18063r18064
50404985
50414986 *************************************************************/
50424987
5043static WRITE8_HANDLER( fukutake_l_w )
4988WRITE8_MEMBER(nes_state::fukutake_l_w)
50444989{
5045   nes_state *state = space.machine().driver_data<nes_state>();
50464990   LOG_MMC(("fukutake_l_w offset: %04x, data: %02x\n", offset, data));
50474991   offset += 0x100;
50484992
50494993   if (offset >= 0x200 && offset < 0x400)
50504994   {
50514995      if (offset & 1)
5052         prg16_89ab(space.machine(), data);
4996         prg16_89ab(machine(), data);
50534997      else
5054         wram_bank(space.machine(), data >> 6, NES_WRAM);
4998         wram_bank(machine(), data >> 6, NES_WRAM);
50554999   }
50565000   else if (offset >= 0x400 && offset < 0xf00)
5057      state->m_mapper_ram[offset - 0x400] = data;
5001      m_mapper_ram[offset - 0x400] = data;
50585002}
50595003
5060static READ8_HANDLER( fukutake_l_r )
5004READ8_MEMBER(nes_state::fukutake_l_r)
50615005{
5062   nes_state *state = space.machine().driver_data<nes_state>();
50635006   LOG_MMC(("fukutake_l_r offset: %04x\n", offset));
50645007   offset += 0x100;
50655008
r18063r18064
50735016         return 0xff;
50745017   }
50755018   else if (offset >= 0x400 && offset < 0xf00)
5076      return state->m_mapper_ram[offset - 0x400];
5019      return m_mapper_ram[offset - 0x400];
50775020
50785021   return 0;
50795022}
r18063r18064
51045047   }
51055048}
51065049
5107static WRITE8_HANDLER( futuremedia_w )
5050WRITE8_MEMBER(nes_state::futuremedia_w)
51085051{
5109   nes_state *state = space.machine().driver_data<nes_state>();
51105052   LOG_MMC(("futuremedia_w, offset: %04x, data: %02x\n", offset, data));
51115053
51125054   switch (offset)
51135055   {
51145056      case 0x0000:
5115         prg8_89(space.machine(), data);
5057         prg8_89(machine(), data);
51165058         break;
51175059      case 0x0001:
5118         prg8_ab(space.machine(), data);
5060         prg8_ab(machine(), data);
51195061         break;
51205062      case 0x0002:
5121         prg8_cd(space.machine(), data);
5063         prg8_cd(machine(), data);
51225064         break;
51235065      case 0x0003:
5124         prg8_ef(space.machine(), data);
5066         prg8_ef(machine(), data);
51255067         break;
51265068      case 0x2000:
51275069      case 0x2001:
r18063r18064
51315073      case 0x2005:
51325074      case 0x2006:
51335075      case 0x2007:
5134         chr1_x(space.machine(), offset & 0x07, data, CHRROM);
5076         chr1_x(machine(), offset & 0x07, data, CHRROM);
51355077         break;
51365078
51375079      case 0x5000:
5138         set_nt_mirroring(space.machine(), BIT(data, 0) ?  PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5080         set_nt_mirroring(machine(), BIT(data, 0) ?  PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
51395081         break;
51405082
51415083      case 0x4001:
5142         state->m_IRQ_count_latch = data;
5084         m_IRQ_count_latch = data;
51435085         break;
51445086      case 0x4002:
51455087         // IRQ cleared
51465088         break;
51475089      case 0x4003:
5148         state->m_IRQ_count = state->m_IRQ_count_latch;
5090         m_IRQ_count = m_IRQ_count_latch;
51495091         break;
51505092      case 0x6000:
5151         state->m_IRQ_enable = data & 0x01;
5093         m_IRQ_enable = data & 0x01;
51525094         break;
51535095   }
51545096}
r18063r18064
51675109
51685110 *************************************************************/
51695111
5170static WRITE8_HANDLER( gouder_sf4_l_w )
5112WRITE8_MEMBER(nes_state::gouder_sf4_l_w)
51715113{
5172   nes_state *state = space.machine().driver_data<nes_state>();
51735114   static const UINT8 conv_table[256] =
51745115   {
51755116      0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x49,0x19,0x09,0x59,0x49,0x19,0x09,
r18063r18064
51935134   LOG_MMC(("gouder_sf4_l_w, offset: %04x, data: %02x\n", offset, data));
51945135
51955136   if (!(offset < 0x1700))
5196      state->m_mmc_reg[offset & 0x03] = data ^ conv_table[state->m_mmc_reg[4]];
5137      m_mmc_reg[offset & 0x03] = data ^ conv_table[m_mmc_reg[4]];
51975138   else if (!(offset < 0xf00))
5198      state->m_mmc_reg[4] = data;
5139      m_mmc_reg[4] = data;
51995140   else if (!(offset < 0x700))
5200      prg32(space.machine(), ((data >> 3) & 0x02) | (data & 0x01));
5141      prg32(machine(), ((data >> 3) & 0x02) | (data & 0x01));
52015142}
52025143
5203static READ8_HANDLER( gouder_sf4_l_r )
5144READ8_MEMBER(nes_state::gouder_sf4_l_r)
52045145{
5205   nes_state *state = space.machine().driver_data<nes_state>();
52065146   LOG_MMC(("gouder_sf4_l_r, offset: %04x\n", offset));
52075147
52085148   if (!(offset < 0x1700))
5209      return state->m_mmc_reg[offset & 0x03];
5149      return m_mmc_reg[offset & 0x03];
52105150
52115151   return 0x00;
52125152}
r18063r18064
52345174
52355175 *************************************************************/
52365176
5237static WRITE8_HANDLER( henggedianzi_w )
5177WRITE8_MEMBER(nes_state::henggedianzi_w)
52385178{
52395179   LOG_MMC(("henggedianzi_w, offset: %04x, data: %02x\n", offset, data));
52405180
5241   prg32(space.machine(), data);
5242   set_nt_mirroring(space.machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5181   prg32(machine(), data);
5182   set_nt_mirroring(machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
52435183}
52445184
52455185/*************************************************************
r18063r18064
52575197
52585198 *************************************************************/
52595199
5260static WRITE8_HANDLER( heng_xjzb_l_w )
5200WRITE8_MEMBER(nes_state::heng_xjzb_l_w)
52615201{
52625202   LOG_MMC(("heng_xjzb_l_w, offset: %04x, data: %02x\n", offset, data));
52635203   offset += 0x4100;
52645204
52655205   if (offset & 0x5000)
5266      prg32(space.machine(), data >> 1);
5206      prg32(machine(), data >> 1);
52675207}
52685208
5269static WRITE8_HANDLER( heng_xjzb_w )
5209WRITE8_MEMBER(nes_state::heng_xjzb_w)
52705210{
52715211   LOG_MMC(("heng_xjzb_w, offset: %04x, data: %02x\n", offset, data));
52725212
5273   set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5213   set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
52745214}
52755215
52765216/*************************************************************
r18063r18064
52895229
52905230 *************************************************************/
52915231
5292static WRITE8_HANDLER( hes6in1_l_w )
5232WRITE8_MEMBER(nes_state::hes6in1_l_w)
52935233{
52945234   LOG_MMC(("hes6in1_l_w, offset: %04x, data: %02x\n", offset, data));
52955235
52965236   if (!(offset & 0x100))
52975237   {
5298      prg32(space.machine(), (data & 0x38) >> 3);
5299      chr8(space.machine(), (data & 0x07) | ((data & 0x40) >> 3), CHRROM);
5300      set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
5238      prg32(machine(), (data & 0x38) >> 3);
5239      chr8(machine(), (data & 0x07) | ((data & 0x40) >> 3), CHRROM);
5240      set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
53015241   }
53025242}
53035243
5304static WRITE8_HANDLER( hes_l_w )
5244WRITE8_MEMBER(nes_state::hes_l_w)
53055245{
53065246   LOG_MMC(("hes_l_w, offset: %04x, data: %02x\n", offset, data));
53075247
53085248   if (!(offset & 0x100))
53095249   {
5310      prg32(space.machine(), (data & 0x38) >> 3);
5311      chr8(space.machine(), (data & 0x07) | ((data & 0x40) >> 3), CHRROM);
5250      prg32(machine(), (data & 0x38) >> 3);
5251      chr8(machine(), (data & 0x07) | ((data & 0x40) >> 3), CHRROM);
53125252   }
53135253}
53145254
r18063r18064
53245264
53255265 *************************************************************/
53265266
5327static WRITE8_HANDLER( hosenkan_w )
5267WRITE8_MEMBER(nes_state::hosenkan_w)
53285268{
5329   nes_state *state = space.machine().driver_data<nes_state>();
53305269   LOG_MMC(("hosenkan_w, offset: %04x, data: %02x\n", offset, data));
53315270
53325271   switch (offset & 0x7003)
53335272   {
53345273      case 0x0001:
5335         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5274         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
53365275         break;
53375276      case 0x2000:
5338         state->m_mmc_latch1 = data;
5277         m_mmc_latch1 = data;
53395278         break;
53405279      case 0x4000:
5341         switch (state->m_mmc_latch1)
5280         switch (m_mmc_latch1)
53425281      {
53435282         case 0:
5344            chr2_0(space.machine(), data >> 1, CHRROM);
5283            chr2_0(machine(), data >> 1, CHRROM);
53455284            break;
53465285         case 1:
5347            chr1_5(space.machine(), data, CHRROM);
5286            chr1_5(machine(), data, CHRROM);
53485287            break;
53495288         case 2:
5350            chr2_2(space.machine(), data >> 1, CHRROM);
5289            chr2_2(machine(), data >> 1, CHRROM);
53515290            break;
53525291         case 3:
5353            chr1_7(space.machine(), data, CHRROM);
5292            chr1_7(machine(), data, CHRROM);
53545293            break;
53555294         case 4:
5356            prg8_89(space.machine(), data);
5295            prg8_89(machine(), data);
53575296            break;
53585297         case 5:
5359            prg8_ab(space.machine(), data);
5298            prg8_ab(machine(), data);
53605299            break;
53615300         case 6:
5362            chr1_4(space.machine(), data, CHRROM);
5301            chr1_4(machine(), data, CHRROM);
53635302            break;
53645303         case 7:
5365            chr1_6(space.machine(), data, CHRROM);
5304            chr1_6(machine(), data, CHRROM);
53665305            break;
53675306      }
53685307         break;
53695308      case 0x6003:
53705309         if (data)
53715310         {
5372            state->m_IRQ_count = data;
5373            state->m_IRQ_enable = 1;
5311            m_IRQ_count = data;
5312            m_IRQ_enable = 1;
53745313         }
53755314         else
5376            state->m_IRQ_enable = 0;
5315            m_IRQ_enable = 0;
53775316         break;
53785317   }
53795318}
r18063r18064
53945333
53955334 *************************************************************/
53965335
5397static WRITE8_HANDLER( ks7058_w )
5336WRITE8_MEMBER(nes_state::ks7058_w)
53985337{
53995338   LOG_MMC(("ks7058_w, offset: %04x, data: %02x\n", offset, data));
54005339
54015340   switch (offset & 0x7080)
54025341   {
54035342      case 0x7000:
5404         chr4_0(space.machine(), data, CHRROM);
5343         chr4_0(machine(), data, CHRROM);
54055344         break;
54065345      case 0x7080:
5407         chr4_4(space.machine(), data, CHRROM);
5346         chr4_4(machine(), data, CHRROM);
54085347         break;
54095348   }
54105349}
r18063r18064
54215360
54225361 *************************************************************/
54235362
5424static WRITE8_HANDLER( ks7022_w )
5363WRITE8_MEMBER(nes_state::ks7022_w)
54255364{
5426   nes_state *state = space.machine().driver_data<nes_state>();
54275365   LOG_MMC(("ks7022_w, offset: %04x, data: %02x\n", offset, data));
54285366
54295367   if (offset == 0)
5430      set_nt_mirroring(space.machine(), BIT(data, 2) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5368      set_nt_mirroring(machine(), BIT(data, 2) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
54315369
54325370   if (offset == 0x2000)
5433      state->m_mmc_latch1 = data & 0x0f;
5371      m_mmc_latch1 = data & 0x0f;
54345372}
54355373
5436static READ8_HANDLER( ks7022_r )
5374READ8_MEMBER(nes_state::ks7022_r)
54375375{
5438   nes_state *state = space.machine().driver_data<nes_state>();
54395376   LOG_MMC(("ks7022_r, offset: %04x\n", offset));
54405377
54415378   if (offset == 0x7ffc)
54425379   {
5443      chr8(space.machine(), state->m_mmc_latch1, CHRROM);
5444      prg16_89ab(space.machine(), state->m_mmc_latch1);
5445      prg16_cdef(space.machine(), state->m_mmc_latch1);
5380      chr8(machine(), m_mmc_latch1, CHRROM);
5381      prg16_89ab(machine(), m_mmc_latch1);
5382      prg16_cdef(machine(), m_mmc_latch1);
54465383   }
54475384
5448   return mmc_hi_access_rom(space.machine(), offset);
5385   return mmc_hi_access_rom(machine(), offset);
54495386}
54505387
54515388/*************************************************************
r18063r18064
54875424   }
54885425}
54895426
5490static WRITE8_HANDLER( ks7032_w )
5427WRITE8_MEMBER(nes_state::ks7032_w)
54915428{
5492   nes_state *state = space.machine().driver_data<nes_state>();
54935429   LOG_MMC(("ks7032_w, offset: %04x, data: %02x\n", offset, data));
54945430
54955431   switch (offset & 0x7000)
54965432   {
54975433      case 0x0000:
5498         state->m_IRQ_count = (state->m_IRQ_count & 0xfff0) | (data & 0x0f);
5434         m_IRQ_count = (m_IRQ_count & 0xfff0) | (data & 0x0f);
54995435         break;
55005436      case 0x1000:
5501         state->m_IRQ_count = (state->m_IRQ_count & 0xff0f) | ((data & 0x0f) << 4);
5437         m_IRQ_count = (m_IRQ_count & 0xff0f) | ((data & 0x0f) << 4);
55025438         break;
55035439      case 0x2000:
5504         state->m_IRQ_count = (state->m_IRQ_count & 0xf0ff) | ((data & 0x0f) << 8);
5440         m_IRQ_count = (m_IRQ_count & 0xf0ff) | ((data & 0x0f) << 8);
55055441         break;
55065442      case 0x3000:
5507         state->m_IRQ_count = (state->m_IRQ_count & 0x0fff) | ((data & 0x0f) << 12);
5443         m_IRQ_count = (m_IRQ_count & 0x0fff) | ((data & 0x0f) << 12);
55085444         break;
55095445      case 0x4000:
5510         state->m_IRQ_enable = 1;
5446         m_IRQ_enable = 1;
55115447         break;
55125448      case 0x6000:
5513         state->m_mmc_latch1 = data & 0x07;
5449         m_mmc_latch1 = data & 0x07;
55145450         break;
55155451      case 0x7000:
5516         state->m_mmc_reg[state->m_mmc_latch1] = data;
5517         ks7032_prg_update(space.machine());
5452         m_mmc_reg[m_mmc_latch1] = data;
5453         ks7032_prg_update(machine());
55185454         break;
55195455   }
55205456}
r18063r18064
55325468 *************************************************************/
55335469
55345470
5535static WRITE8_HANDLER( ks202_w )
5471WRITE8_MEMBER(nes_state::ks202_w)
55365472{
5537   nes_state *state = space.machine().driver_data<nes_state>();
55385473   LOG_MMC(("ks202_w, offset: %04x, data: %02x\n", offset, data));
55395474
55405475   switch (offset & 0x7000)
55415476   {
55425477      case 0x0000:
5543         state->m_IRQ_count = (state->m_IRQ_count & 0xfff0) | (data & 0x0f);
5478         m_IRQ_count = (m_IRQ_count & 0xfff0) | (data & 0x0f);
55445479         break;
55455480      case 0x1000:
5546         state->m_IRQ_count = (state->m_IRQ_count & 0xff0f) | ((data & 0x0f) << 4);
5481         m_IRQ_count = (m_IRQ_count & 0xff0f) | ((data & 0x0f) << 4);
55475482         break;
55485483      case 0x2000:
5549         state->m_IRQ_count = (state->m_IRQ_count & 0xf0ff) | ((data & 0x0f) << 8);
5484         m_IRQ_count = (m_IRQ_count & 0xf0ff) | ((data & 0x0f) << 8);
55505485         break;
55515486      case 0x3000:
5552         state->m_IRQ_count = (state->m_IRQ_count & 0x0fff) | ((data & 0x0f) << 12);
5487         m_IRQ_count = (m_IRQ_count & 0x0fff) | ((data & 0x0f) << 12);
55535488         break;
55545489      case 0x4000:
5555         state->m_IRQ_enable = 1;
5490         m_IRQ_enable = 1;
55565491         break;
55575492      case 0x6000:
5558         state->m_mmc_latch1 = data & 0x07;
5493         m_mmc_latch1 = data & 0x07;
55595494         break;
55605495      case 0x7000:
5561         state->m_mmc_reg[state->m_mmc_latch1] = data;
5562         ks7032_prg_update(space.machine());
5496         m_mmc_reg[m_mmc_latch1] = data;
5497         ks7032_prg_update(machine());
55635498         switch (offset & 0xc00)
55645499         {
55655500         case 0x800:
5566            set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
5501            set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
55675502            break;
55685503         case 0xc00:
5569            chr1_x(space.machine(), offset & 0x07, data, CHRROM);
5504            chr1_x(machine(), offset & 0x07, data, CHRROM);
55705505            break;
55715506         }
55725507         break;
r18063r18064
56025537   }
56035538}
56045539
5605static WRITE8_HANDLER( ks7017_l_w )
5540WRITE8_MEMBER(nes_state::ks7017_l_w)
56065541{
5607   nes_state *state = space.machine().driver_data<nes_state>();
56085542   LOG_MMC(("ks7022_w, offset: %04x, data: %02x\n", offset, data));
56095543
56105544   offset += 0x100;
56115545
56125546   if (offset >= 0xa00 && offset < 0xb00)
5613      state->m_mmc_latch1 = ((offset >> 2) & 0x03) | ((offset >> 4) & 0x04);
5547      m_mmc_latch1 = ((offset >> 2) & 0x03) | ((offset >> 4) & 0x04);
56145548
56155549   if (offset >= 0x1000 && offset < 0x1100)
5616      prg16_89ab(space.machine(), state->m_mmc_latch1);
5550      prg16_89ab(machine(), m_mmc_latch1);
56175551}
56185552
5619WRITE8_HANDLER( ks7017_extra_w )
5553WRITE8_MEMBER(nes_state::ks7017_extra_w)
56205554{
5621   nes_state *state = space.machine().driver_data<nes_state>();
56225555   LOG_MMC(("ks7017_extra_w, offset: %04x, data: %02x\n", offset, data));
56235556
56245557   offset += 0x20;
56255558
56265559   if (offset == 0x0020) /* 0x4020 */
5627      state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
5560      m_IRQ_count = (m_IRQ_count & 0xff00) | data;
56285561
56295562   if (offset == 0x0021) /* 0x4021 */
5630      state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
5563      m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
56315564
56325565   if (offset == 0x0025) /* 0x4025 */
5633      set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5566      set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
56345567}
56355568
5636READ8_HANDLER( ks7017_extra_r )
5569READ8_MEMBER(nes_state::ks7017_extra_r)
56375570{
5638   nes_state *state = space.machine().driver_data<nes_state>();
56395571   LOG_MMC(("ks7017_extra_r, offset: %04x\n", offset));
56405572
5641   state->m_IRQ_status &= ~0x01;
5642   return state->m_IRQ_status;
5573   m_IRQ_status &= ~0x01;
5574   return m_IRQ_status;
56435575}
56445576
56455577/*************************************************************
r18063r18064
56575589
56585590 *************************************************************/
56595591
5660static WRITE8_HANDLER( kay_pp_l_w )
5592WRITE8_MEMBER(nes_state::kay_pp_l_w)
56615593{
5662   nes_state *state = space.machine().driver_data<nes_state>();
56635594   LOG_MMC(("kay_pp_l_w, offset: %04x, data: %02x\n", offset, data));
56645595   offset += 0x100;
56655596
r18063r18064
56695600      {
56705601         case 0x00:
56715602         case 0x01:
5672            state->m_mmc_reg[0] = 0x83;
5603            m_mmc_reg[0] = 0x83;
56735604            break;
56745605         case 0x02:
5675            state->m_mmc_reg[0] = 0x42;
5606            m_mmc_reg[0] = 0x42;
56765607            break;
56775608         case 0x03:
5678            state->m_mmc_reg[0] = 0x00;
5609            m_mmc_reg[0] = 0x00;
56795610            break;
56805611      }
56815612   }
56825613}
56835614
5684static READ8_HANDLER( kay_pp_l_r )
5615READ8_MEMBER(nes_state::kay_pp_l_r)
56855616{
5686   nes_state *state = space.machine().driver_data<nes_state>();
56875617   LOG_MMC(("kay_pp_l_r, offset: %04x\n", offset));
56885618   offset += 0x100;
56895619
56905620   if (offset >= 0x1000)
5691      return state->m_mmc_reg[0];
5621      return m_mmc_reg[0];
56925622   else
56935623      return 0xff;
56945624}
r18063r18064
57615691   chr1_x(machine, start, bank, source);
57625692}
57635693
5764static WRITE8_HANDLER( kay_pp_w )
5694WRITE8_MEMBER(nes_state::kay_pp_w)
57655695{
5766   nes_state *state = space.machine().driver_data<nes_state>();
57675696   LOG_MMC(("kay_pp_w, offset: %04x, data: %02x\n", offset, data));
57685697
57695698   switch (offset & 0x6003)
57705699   {
57715700      case 0x0000:
57725701         txrom_w(space, offset, data, mem_mask);
5773         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
5702         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
57745703         break;
57755704
57765705      case 0x0001:
5777         state->m_mmc_reg[6] = (BIT(data, 0) << 5) | (BIT(data, 1) << 4) | (BIT(data, 2) << 3)
5706         m_mmc_reg[6] = (BIT(data, 0) << 5) | (BIT(data, 1) << 4) | (BIT(data, 2) << 3)
57785707                        | (BIT(data, 3) << 2) | (BIT(data, 4) << 1) | BIT(data, 5);
5779         if (!state->m_mmc_reg[7])
5780            kay_pp_update_regs(space.machine());
5708         if (!m_mmc_reg[7])
5709            kay_pp_update_regs(machine());
57815710         txrom_w(space, offset, data, mem_mask);
5782         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
5711         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
57835712         break;
57845713
57855714      case 0x0003:
5786         state->m_mmc_reg[5] = data;
5787         kay_pp_update_regs(space.machine());
5715         m_mmc_reg[5] = data;
5716         kay_pp_update_regs(machine());
57885717         txrom_w(space, 0x0000, data, mem_mask);
5789         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
5718         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
57905719         break;
57915720
57925721      default:
r18063r18064
58195748      prg8_x(machine, start, bank);
58205749}
58215750
5822static WRITE8_HANDLER( kasing_m_w )
5751WRITE8_MEMBER(nes_state::kasing_m_w)
58235752{
5824   nes_state *state = space.machine().driver_data<nes_state>();
58255753   LOG_MMC(("kasing_m_w, offset: %04x, data: %02x\n", offset, data));
58265754
58275755   switch (offset & 0x01)
58285756   {
58295757      case 0x00:
5830         state->m_mmc_reg[0] = data;
5831         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
5758         m_mmc_reg[0] = data;
5759         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
58325760         break;
58335761      case 0x01:
5834         state->m_mmc_chr_base = (data & 0x01) ? 0x100 : 0x000;
5835         mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
5762         m_mmc_chr_base = (data & 0x01) ? 0x100 : 0x000;
5763         mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
58365764         break;
58375765   }
58385766}
r18063r18064
58525780
58535781 *************************************************************/
58545782
5855static WRITE8_HANDLER( magics_md_w )
5783WRITE8_MEMBER(nes_state::magics_md_w)
58565784{
58575785   LOG_MMC(("magics_md_w, offset: %04x, data: %02x\n", offset, data));
58585786
5859   prg32(space.machine(), data >> 1);
5860   chr8(space.machine(), data, CHRROM);
5787   prg32(machine(), data >> 1);
5788   chr8(machine(), data, CHRROM);
58615789}
58625790
58635791/*************************************************************
r18063r18064
58935821
58945822}
58955823
5896static WRITE8_HANDLER( nanjing_l_w )
5824WRITE8_MEMBER(nes_state::nanjing_l_w)
58975825{
5898   nes_state *state = space.machine().driver_data<nes_state>();
58995826   LOG_MMC(("nanjing_l_w, offset: %04x, data: %02x\n", offset, data));
59005827
59015828   offset += 0x100;
r18063r18064
59065833   if (offset == 0x1100)   // 0x5100
59075834   {
59085835      if (data == 6)
5909         prg32(space.machine(), 3);
5836         prg32(machine(), 3);
59105837      return;
59115838   }
59125839
59135840   if (offset == 0x1101)   // 0x5101
59145841   {
5915      UINT8 temp = state->m_mmc_count;
5916      state->m_mmc_count = data;
5842      UINT8 temp = m_mmc_count;
5843      m_mmc_count = data;
59175844
59185845      if (temp & !data)
5919         state->m_mmc_latch2 ^= 0xff;
5846         m_mmc_latch2 ^= 0xff;
59205847   }
59215848
59225849   switch (offset & 0x300)
59235850   {
59245851      case 0x000:
59255852      case 0x200:
5926         state->m_mmc_reg[BIT(offset, 9)] = data;
5927         if (!BIT(state->m_mmc_reg[0], 7) && state->m_ppu->get_current_scanline() <= 127)
5928            chr8(space.machine(), 0, CHRRAM);
5853         m_mmc_reg[BIT(offset, 9)] = data;
5854         if (!BIT(m_mmc_reg[0], 7) && m_ppu->get_current_scanline() <= 127)
5855            chr8(machine(), 0, CHRRAM);
59295856         break;
59305857      case 0x300:
5931         state->m_mmc_latch1 = data;
5858         m_mmc_latch1 = data;
59325859         break;
59335860   }
59345861
5935   prg32(space.machine(), (state->m_mmc_reg[0] & 0x0f) | ((state->m_mmc_reg[1] & 0x0f) << 4));
5862   prg32(machine(), (m_mmc_reg[0] & 0x0f) | ((m_mmc_reg[1] & 0x0f) << 4));
59365863}
59375864
5938static READ8_HANDLER( nanjing_l_r )
5865READ8_MEMBER(nes_state::nanjing_l_r)
59395866{
5940   nes_state *state = space.machine().driver_data<nes_state>();
59415867   UINT8 value = 0;
59425868   LOG_MMC(("nanjing_l_r, offset: %04x\n", offset));
59435869
r18063r18064
59495875   switch (offset & 0x700)
59505876   {
59515877      case 0x100:
5952         value = state->m_mmc_latch1;
5878         value = m_mmc_latch1;
59535879         break;
59545880      case 0x500:
5955         value = state->m_mmc_latch2 & state->m_mmc_latch1;
5881         value = m_mmc_latch2 & m_mmc_latch1;
59565882         break;
59575883      case 0x000:
59585884      case 0x200:
r18063r18064
59815907
59825908 *************************************************************/
59835909
5984static WRITE8_HANDLER( nitra_w )
5910WRITE8_MEMBER(nes_state::nitra_w)
59855911{
59865912   LOG_MMC(("nitra_w, offset: %04x, data: %02x\n", offset, data));
59875913
r18063r18064
60015927
60025928 *************************************************************/
60035929
6004static WRITE8_HANDLER( ntdec_asder_w )
5930WRITE8_MEMBER(nes_state::ntdec_asder_w)
60055931{
6006   nes_state *state = space.machine().driver_data<nes_state>();
60075932   LOG_MMC(("ntdec_asder_w, offset: %04x, data: %02x\n", offset, data));
60085933
60095934   switch (offset)
60105935   {
60115936      case 0x0000:
6012         state->m_mmc_latch1 = data & 0x07;
5937         m_mmc_latch1 = data & 0x07;
60135938         break;
60145939      case 0x2000:
6015         switch (state->m_mmc_latch1)
5940         switch (m_mmc_latch1)
60165941      {
60175942         case 0:
6018            prg8_89(space.machine(), data);
5943            prg8_89(machine(), data);
60195944            break;
60205945         case 1:
6021            prg8_ab(space.machine(), data);
5946            prg8_ab(machine(), data);
60225947            break;
60235948         case 2:
60245949            data &= 0xfe;
6025            chr1_0(space.machine(), data, CHRROM);
6026            chr1_1(space.machine(), data + 1, CHRROM);
5950            chr1_0(machine(), data, CHRROM);
5951            chr1_1(machine(), data + 1, CHRROM);
60275952            break;
60285953         case 3:
60295954            data &= 0xfe;
6030            chr1_2(space.machine(), data, CHRROM);
6031            chr1_3(space.machine(), data + 1, CHRROM);
5955            chr1_2(machine(), data, CHRROM);
5956            chr1_3(machine(), data + 1, CHRROM);
60325957            break;
60335958         case 4:
6034            chr1_4(space.machine(), data, CHRROM);
5959            chr1_4(machine(), data, CHRROM);
60355960            break;
60365961         case 5:
6037            chr1_5(space.machine(), data, CHRROM);
5962            chr1_5(machine(), data, CHRROM);
60385963            break;
60395964         case 6:
6040            chr1_6(space.machine(), data, CHRROM);
5965            chr1_6(machine(), data, CHRROM);
60415966            break;
60425967         case 7:
6043            chr1_7(space.machine(), data, CHRROM);
5968            chr1_7(machine(), data, CHRROM);
60445969            break;
60455970      }
60465971         break;
60475972      case 0x6000:
6048         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
5973         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
60495974         break;
60505975   }
60515976}
r18063r18064
60655990
60665991 *************************************************************/
60675992
6068static WRITE8_HANDLER( ntdec_fh_m_w )
5993WRITE8_MEMBER(nes_state::ntdec_fh_m_w)
60695994{
60705995   LOG_MMC(("ntdec_fh_m_w, offset: %04x, data: %02x\n", offset, data));
60715996
60725997   switch (offset & 0x03)
60735998   {
60745999      case 0:
6075         chr4_0(space.machine(), data >> 2, CHRROM);
6000         chr4_0(machine(), data >> 2, CHRROM);
60766001         break;
60776002      case 1:
6078         chr2_4(space.machine(), data >> 1, CHRROM);
6003         chr2_4(machine(), data >> 1, CHRROM);
60796004         break;
60806005      case 2:
6081         chr2_6(space.machine(), data >> 1 , CHRROM);
6006         chr2_6(machine(), data >> 1 , CHRROM);
60826007         break;
60836008      case 3:
6084         prg8_89(space.machine(), data);
6009         prg8_89(machine(), data);
60856010         break;
60866011   }
60876012}
r18063r18064
61016026
61026027 *************************************************************/
61036028
6104static WRITE8_HANDLER( daou306_w )
6029WRITE8_MEMBER(nes_state::daou306_w)
61056030{
6106   nes_state *state = space.machine().driver_data<nes_state>();
61076031   LOG_MMC(("daou306_w, offset: %04x, data: %02x\n", offset, data));
61086032   int reg = BIT(offset, 2) ? 8 : 0;
61096033
r18063r18064
61116035   {
61126036      case 0x4000:
61136037      case 0x4004:
6114         state->m_mmc_reg[reg + 0] = data;
6115         chr1_0(space.machine(), state->m_mmc_reg[0] | (state->m_mmc_reg[8] << 8), CHRROM);
6038         m_mmc_reg[reg + 0] = data;
6039         chr1_0(machine(), m_mmc_reg[0] | (m_mmc_reg[8] << 8), CHRROM);
61166040         break;
61176041      case 0x4001:
61186042      case 0x4005:
6119         state->m_mmc_reg[reg + 1] = data;
6120         chr1_1(space.machine(), state->m_mmc_reg[1] | (state->m_mmc_reg[9] << 8), CHRROM);
6043         m_mmc_reg[reg + 1] = data;
6044         chr1_1(machine(), m_mmc_reg[1] | (m_mmc_reg[9] << 8), CHRROM);
61216045         break;
61226046      case 0x4002:
61236047      case 0x4006:
6124         state->m_mmc_reg[reg + 2] = data;
6125         chr1_2(space.machine(), state->m_mmc_reg[2] | (state->m_mmc_reg[10] << 8), CHRROM);
6048         m_mmc_reg[reg + 2] = data;
6049         chr1_2(machine(), m_mmc_reg[2] | (m_mmc_reg[10] << 8), CHRROM);
61266050         break;
61276051      case 0x4003:
61286052      case 0x4007:
6129         state->m_mmc_reg[reg + 3] = data;
6130         chr1_3(space.machine(), state->m_mmc_reg[3] | (state->m_mmc_reg[11] << 8), CHRROM);
6053         m_mmc_reg[reg + 3] = data;
6054         chr1_3(machine(), m_mmc_reg[3] | (m_mmc_reg[11] << 8), CHRROM);
61316055         break;
61326056      case 0x4008:
61336057      case 0x400c:
6134         state->m_mmc_reg[reg + 4] = data;
6135         chr1_4(space.machine(), state->m_mmc_reg[4] | (state->m_mmc_reg[12] << 8), CHRROM);
6058         m_mmc_reg[reg + 4] = data;
6059         chr1_4(machine(), m_mmc_reg[4] | (m_mmc_reg[12] << 8), CHRROM);
61366060         break;
61376061      case 0x4009:
61386062      case 0x400d:
6139         state->m_mmc_reg[reg + 5] = data;
6140         chr1_5(space.machine(), state->m_mmc_reg[5] | (state->m_mmc_reg[13] << 8), CHRROM);
6063         m_mmc_reg[reg + 5] = data;
6064         chr1_5(machine(), m_mmc_reg[5] | (m_mmc_reg[13] << 8), CHRROM);
61416065         break;
61426066      case 0x400a:
61436067      case 0x400e:
6144         state->m_mmc_reg[reg + 6] = data;
6145         chr1_6(space.machine(), state->m_mmc_reg[6] | (state->m_mmc_reg[14] << 8), CHRROM);
6068         m_mmc_reg[reg + 6] = data;
6069         chr1_6(machine(), m_mmc_reg[6] | (m_mmc_reg[14] << 8), CHRROM);
61466070         break;
61476071      case 0x400b:
61486072      case 0x400f:
6149         state->m_mmc_reg[reg + 7] = data;
6150         chr1_7(space.machine(), state->m_mmc_reg[7] | (state->m_mmc_reg[15] << 8), CHRROM);
6073         m_mmc_reg[reg + 7] = data;
6074         chr1_7(machine(), m_mmc_reg[7] | (m_mmc_reg[15] << 8), CHRROM);
61516075         break;
61526076      case 0x4010:
6153         prg16_89ab(space.machine(), data);
6077         prg16_89ab(machine(), data);
61546078         break;
61556079      case 0x4014:
61566080         if (data & 1)
6157            set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ);
6081            set_nt_mirroring(machine(), PPU_MIRROR_HORZ);
61586082         else
6159            set_nt_mirroring(space.machine(), PPU_MIRROR_VERT);
6083            set_nt_mirroring(machine(), PPU_MIRROR_VERT);
61606084         break;
61616085   }
61626086}
r18063r18064
61766100
61776101 *************************************************************/
61786102
6179static WRITE8_HANDLER( gs2015_w )
6103WRITE8_MEMBER(nes_state::gs2015_w)
61806104{
6181   nes_state *state = space.machine().driver_data<nes_state>();
61826105   LOG_MMC(("gs2015_w, offset: %04x, data: %02x\n", offset, data));
61836106
6184   prg32(space.machine(), offset);
6185   chr8(space.machine(), offset >> 1, state->m_mmc_chr_source);
6107   prg32(machine(), offset);
6108   chr8(machine(), offset >> 1, m_mmc_chr_source);
61866109}
61876110
61886111/*************************************************************
r18063r18064
62036126
62046127 *************************************************************/
62056128
6206static WRITE8_HANDLER( rcm_tf_w )
6129WRITE8_MEMBER(nes_state::rcm_tf_w)
62076130{
62086131   LOG_MMC(("rcm_tf_w, offset: %04x, data: %02x\n", offset, data));
62096132
r18063r18064
62116134   {
62126135      case 0x00:
62136136      case 0x30:
6214         prg32(space.machine(), offset & 0x0f);
6137         prg32(machine(), offset & 0x0f);
62156138         break;
62166139      case 0x10:
62176140      case 0x20:
6218         prg16_89ab(space.machine(), ((offset & 0x0f) << 1) | ((offset & 0x20) >> 4));
6219         prg16_cdef(space.machine(), ((offset & 0x0f) << 1) | ((offset & 0x20) >> 4));
6141         prg16_89ab(machine(), ((offset & 0x0f) << 1) | ((offset & 0x20) >> 4));
6142         prg16_cdef(machine(), ((offset & 0x0f) << 1) | ((offset & 0x20) >> 4));
62206143         break;
62216144   }
6222   set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6145   set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
62236146}
62246147
62256148/*************************************************************
r18063r18064
62366159
62376160 *************************************************************/
62386161
6239static WRITE8_HANDLER( rex_dbz_l_w )
6162WRITE8_MEMBER(nes_state::rex_dbz_l_w)
62406163{
6241   nes_state *state = space.machine().driver_data<nes_state>();
62426164   LOG_MMC(("rex_dbz_l_w, offset: %04x, data: %02x\n", offset, data));
62436165
6244   state->m_mmc_reg[0] = data;
6245   mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6166   m_mmc_reg[0] = data;
6167   mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
62466168}
62476169
62486170/* we would need to use this read handler in 0x6000-0x7fff as well */
6249static READ8_HANDLER( rex_dbz_l_r )
6171READ8_MEMBER(nes_state::rex_dbz_l_r)
62506172{
62516173   LOG_MMC(("rex_dbz_l_r, offset: %04x\n", offset));
62526174   return 0x01;
r18063r18064
63286250   chr1_x(machine, chr_page ^ 7, chr_base2[7] | (bank[7] & chr_mask), chr);
63296251}
63306252
6331static WRITE8_HANDLER( rex_sl1632_w )
6253WRITE8_MEMBER(nes_state::rex_sl1632_w)
63326254{
6333   nes_state *state = space.machine().driver_data<nes_state>();
63346255   UINT8 map14_helper1, map14_helper2, mmc_helper, cmd;
63356256   LOG_MMC(("rex_sl1632_w, offset: %04x, data: %02x\n", offset, data));
63366257
63376258   if (offset == 0x2131)
63386259   {
6339      state->m_mmc_reg[0] = data;
6340      rex_sl1632_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
6341      rex_sl1632_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6260      m_mmc_reg[0] = data;
6261      rex_sl1632_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
6262      rex_sl1632_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
63426263
6343      if (!(state->m_mmc_reg[0] & 0x02))
6344         set_nt_mirroring(space.machine(), BIT(state->m_mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6264      if (!(m_mmc_reg[0] & 0x02))
6265         set_nt_mirroring(machine(), BIT(m_mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
63456266   }
63466267
6347   if (state->m_mmc_reg[0] & 0x02)
6268   if (m_mmc_reg[0] & 0x02)
63486269   {
63496270      switch (offset & 0x6001)
63506271      {
63516272         case 0x0000:
6352            mmc_helper = state->m_mmc3_latch ^ data;
6353            state->m_mmc3_latch = data;
6273            mmc_helper = m_mmc3_latch ^ data;
6274            m_mmc3_latch = data;
63546275
63556276            /* Has PRG Mode changed? */
63566277            if (mmc_helper & 0x40)
6357               rex_sl1632_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
6278               rex_sl1632_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
63586279
63596280            /* Has CHR Mode changed? */
63606281            if (mmc_helper & 0x80)
6361               rex_sl1632_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6282               rex_sl1632_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
63626283            break;
63636284
63646285         case 0x0001:
6365            cmd = state->m_mmc3_latch & 0x07;
6286            cmd = m_mmc3_latch & 0x07;
63666287            switch (cmd)
63676288            {
63686289            case 0: case 1:   // these have to be changed due to the different way rex_sl1632_set_chr works (it handles 1k banks)!
6369               state->m_mmc_vrom_bank[2 * cmd] = data;
6370               state->m_mmc_vrom_bank[2 * cmd + 1] = data;
6371               rex_sl1632_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6290               m_mmc_vrom_bank[2 * cmd] = data;
6291               m_mmc_vrom_bank[2 * cmd + 1] = data;
6292               rex_sl1632_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
63726293               break;
63736294            case 2: case 3: case 4: case 5:
6374               state->m_mmc_vrom_bank[cmd + 2] = data;
6375               rex_sl1632_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6295               m_mmc_vrom_bank[cmd + 2] = data;
6296               rex_sl1632_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
63766297               break;
63776298            case 6:
63786299            case 7:
6379               state->m_mmc_prg_bank[cmd - 6] = data;
6380               rex_sl1632_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
6300               m_mmc_prg_bank[cmd - 6] = data;
6301               rex_sl1632_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
63816302               break;
63826303            }
63836304            break;
63846305
63856306         case 0x2000:
6386            set_nt_mirroring(space.machine(), BIT(state->m_mmc_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
6307            set_nt_mirroring(machine(), BIT(m_mmc_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
63876308            break;
63886309
63896310         default:
r18063r18064
63956316   {
63966317      map14_helper1 = (offset & 0x01) << 2;
63976318      offset = ((offset & 0x02) | (offset >> 10)) >> 1;
6398      map14_helper2 = ((offset + 2) & 0x07) + 4; // '+4' because first 4 state->m_mmc_extra_banks are for PRG!
6399      state->m_mmc_extra_bank[map14_helper2] = (state->m_mmc_extra_bank[map14_helper2] & (0xf0 >> map14_helper1)) | ((data & 0x0f) << map14_helper1);
6400      rex_sl1632_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6319      map14_helper2 = ((offset + 2) & 0x07) + 4; // '+4' because first 4 m_mmc_extra_banks are for PRG!
6320      m_mmc_extra_bank[map14_helper2] = (m_mmc_extra_bank[map14_helper2] & (0xf0 >> map14_helper1)) | ((data & 0x0f) << map14_helper1);
6321      rex_sl1632_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
64016322   }
64026323   else
64036324   {
r18063r18064
64056326      {
64066327         case 0x0000:
64076328         case 0x2000:
6408            state->m_mmc_extra_bank[offset >> 13] = data;
6409            rex_sl1632_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
6329            m_mmc_extra_bank[offset >> 13] = data;
6330            rex_sl1632_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
64106331            break;
64116332
64126333         case 0x1000:
6413            state->m_mmc_reg[1] = data;
6414            set_nt_mirroring(space.machine(), BIT(state->m_mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6334            m_mmc_reg[1] = data;
6335            set_nt_mirroring(machine(), BIT(m_mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
64156336            break;
64166337      }
64176338   }
r18063r18064
64296350
64306351 *************************************************************/
64316352
6432static WRITE8_HANDLER( rumblestation_m_w )
6353WRITE8_MEMBER(nes_state::rumblestation_m_w)
64336354{
6434   nes_state *state = space.machine().driver_data<nes_state>();
64356355   LOG_MMC(("rumblestation_m_w, offset: %04x, data: %02x\n", offset, data));
64366356
6437   state->m_mmc_prg_bank[0] = (state->m_mmc_prg_bank[0] & 0x01) | ((data & 0x0f) << 1);
6438   state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & 0x07) | ((data & 0xf0) >> 1);
6439   prg32(space.machine(), state->m_mmc_prg_bank[0]);
6440   chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6357   m_mmc_prg_bank[0] = (m_mmc_prg_bank[0] & 0x01) | ((data & 0x0f) << 1);
6358   m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & 0x07) | ((data & 0xf0) >> 1);
6359   prg32(machine(), m_mmc_prg_bank[0]);
6360   chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
64416361}
64426362
6443static WRITE8_HANDLER( rumblestation_w )
6363WRITE8_MEMBER(nes_state::rumblestation_w)
64446364{
6445   nes_state *state = space.machine().driver_data<nes_state>();
64466365   LOG_MMC(("rumblestation_w, offset: %04x, data: %02x\n", offset, data));
64476366
6448   state->m_mmc_prg_bank[0] = (state->m_mmc_prg_bank[0] & ~0x01) | (data & 0x01);
6449   state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x07) | ((data & 0x70) >> 4);
6450   prg32(space.machine(), state->m_mmc_prg_bank[0]);
6451   chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6367   m_mmc_prg_bank[0] = (m_mmc_prg_bank[0] & ~0x01) | (data & 0x01);
6368   m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x07) | ((data & 0x70) >> 4);
6369   prg32(machine(), m_mmc_prg_bank[0]);
6370   chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
64526371}
64536372
64546373/*************************************************************
r18063r18064
64856404   }
64866405}
64876406
6488static WRITE8_HANDLER( sachen_74x374_l_w )
6407WRITE8_MEMBER(nes_state::sachen_74x374_l_w)
64896408{
6490   nes_state *state = space.machine().driver_data<nes_state>();
64916409   LOG_MMC(("sachen_74x374_l_w, offset: %04x, data: %02x\n", offset, data));
64926410
64936411   /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
64946412   if (!(offset & 0x100))
64956413   {
64966414      if (!(offset & 0x01))
6497         state->m_mmc_latch1 = data & 0x07;
6415         m_mmc_latch1 = data & 0x07;
64986416      else
64996417      {
6500         switch (state->m_mmc_latch1)
6418         switch (m_mmc_latch1)
65016419         {
65026420            case 0x02:
6503               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x08) | ((data << 3) & 0x08);
6504               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6505               prg32(space.machine(), data & 0x01);
6421               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x08) | ((data << 3) & 0x08);
6422               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
6423               prg32(machine(), data & 0x01);
65066424               break;
65076425            case 0x04:
6508               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x04) | ((data << 2) & 0x04);
6509               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6426               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x04) | ((data << 2) & 0x04);
6427               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
65106428               break;
65116429            case 0x05:
6512               prg32(space.machine(), data & 0x07);
6430               prg32(machine(), data & 0x07);
65136431               break;
65146432            case 0x06:
6515               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x03) | ((data << 0) & 0x03);
6516               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6433               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x03) | ((data << 0) & 0x03);
6434               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
65176435               break;
65186436            case 0x07:
6519               sachen_set_mirror(space.machine(), (data >> 1) & 0x03);
6437               sachen_set_mirror(machine(), (data >> 1) & 0x03);
65206438               break;
65216439            default:
65226440               break;
r18063r18064
65256443   }
65266444}
65276445
6528static READ8_HANDLER( sachen_74x374_l_r )
6446READ8_MEMBER(nes_state::sachen_74x374_l_r)
65296447{
6530   nes_state *state = space.machine().driver_data<nes_state>();
65316448   LOG_MMC(("sachen_74x374_l_r, offset: %04x", offset));
65326449
65336450   /* read  happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
65346451   if (!(offset & 0x100))
6535      return (~state->m_mmc_latch1 & 0x3f) /* ^ dips*/;   // we would need to check the Dips here
6452      return (~m_mmc_latch1 & 0x3f) /* ^ dips*/;   // we would need to check the Dips here
65366453   else
65376454      return 0;
65386455}
65396456
6540static WRITE8_HANDLER( sachen_74x374a_l_w )
6457WRITE8_MEMBER(nes_state::sachen_74x374a_l_w)
65416458{
6542   nes_state *state = space.machine().driver_data<nes_state>();
65436459   LOG_MMC(("sachen_74x374a_l_w, offset: %04x, data: %02x\n", offset, data));
65446460
65456461   /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
65466462   if (!(offset & 0x100))
65476463   {
65486464      if (!(offset & 0x01))
6549         state->m_mmc_latch1 = data;
6465         m_mmc_latch1 = data;
65506466      else
65516467      {
6552         switch (state->m_mmc_latch1 & 0x07)
6468         switch (m_mmc_latch1 & 0x07)
65536469         {
65546470            case 0x00:
6555               prg32(space.machine(), 0);
6556               chr8(space.machine(), 3, CHRROM);
6471               prg32(machine(), 0);
6472               chr8(machine(), 3, CHRROM);
65576473               break;
65586474            case 0x02:
6559               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x08) | ((data << 3) & 0x08);
6560               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6475               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x08) | ((data << 3) & 0x08);
6476               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
65616477               break;
65626478            case 0x04:
6563               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x01) | ((data << 0) & 0x01);
6564               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6479               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x01) | ((data << 0) & 0x01);
6480               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
65656481               break;
65666482            case 0x05:
6567               prg32(space.machine(), data & 0x01);
6483               prg32(machine(), data & 0x01);
65686484               break;
65696485            case 0x06:
6570               state->m_mmc_vrom_bank[0] = (state->m_mmc_vrom_bank[0] & ~0x06) | ((data << 1) & 0x06);
6571               chr8(space.machine(), state->m_mmc_vrom_bank[0], CHRROM);
6486               m_mmc_vrom_bank[0] = (m_mmc_vrom_bank[0] & ~0x06) | ((data << 1) & 0x06);
6487               chr8(machine(), m_mmc_vrom_bank[0], CHRROM);
65726488               break;
65736489            case 0x07:
6574               sachen_set_mirror(space.machine(), BIT(data, 0));
6490               sachen_set_mirror(machine(), BIT(data, 0));
65756491               break;
65766492            default:
65776493               break;
r18063r18064
66446560   }
66456561}
66466562
6647static WRITE8_HANDLER( s8259_l_w )
6563WRITE8_MEMBER(nes_state::s8259_l_w)
66486564{
6649   nes_state *state = space.machine().driver_data<nes_state>();
6650   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->m_pcb_id, offset, data));
6565   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", m_pcb_id, offset, data));
66516566
6652   common_s8259_write_handler(space, offset, data, state->m_pcb_id);
6567   common_s8259_write_handler(space, offset, data, m_pcb_id);
66536568}
66546569
6655static WRITE8_HANDLER( s8259_m_w )
6570WRITE8_MEMBER(nes_state::s8259_m_w)
66566571{
6657   nes_state *state = space.machine().driver_data<nes_state>();
6658   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->m_pcb_id, offset, data));
6572   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", m_pcb_id, offset, data));
66596573
6660   common_s8259_write_handler(space, (offset + 0x100) & 0xfff, data, state->m_pcb_id);
6574   common_s8259_write_handler(space, (offset + 0x100) & 0xfff, data, m_pcb_id);
66616575}
66626576
66636577
r18063r18064
66736587
66746588 *************************************************************/
66756589
6676static WRITE8_HANDLER( sa009_l_w )
6590WRITE8_MEMBER(nes_state::sa009_l_w)
66776591{
6678   nes_state *state = space.machine().driver_data<nes_state>();
66796592   LOG_MMC(("sa009_l_w, offset: %04x, data: %02x\n", offset, data));
66806593
6681   chr8(space.machine(), data, state->m_mmc_chr_source);
6594   chr8(machine(), data, m_mmc_chr_source);
66826595}
66836596
66846597/*************************************************************
r18063r18064
66936606
66946607 *************************************************************/
66956608
6696static WRITE8_HANDLER( sa0036_w )
6609WRITE8_MEMBER(nes_state::sa0036_w)
66976610{
66986611   LOG_MMC(("sa0036_w, offset: %04x, data: %02x\n", offset, data));
66996612
6700   chr8(space.machine(), data >> 7, CHRROM);
6613   chr8(machine(), data >> 7, CHRROM);
67016614}
67026615
67036616/*************************************************************
r18063r18064
67126625
67136626 *************************************************************/
67146627
6715static WRITE8_HANDLER( sa0037_w )
6628WRITE8_MEMBER(nes_state::sa0037_w)
67166629{
67176630   LOG_MMC(("sa0037_w, offset: %04x, data: %02x\n", offset, data));
67186631
6719   prg32(space.machine(), data >> 3);
6720   chr8(space.machine(), data, CHRROM);
6632   prg32(machine(), data >> 3);
6633   chr8(machine(), data, CHRROM);
67216634}
67226635
67236636/*************************************************************
r18063r18064
67326645
67336646 *************************************************************/
67346647
6735static WRITE8_HANDLER( sa72007_l_w )
6648WRITE8_MEMBER(nes_state::sa72007_l_w)
67366649{
67376650   LOG_MMC(("sa72007_l_w, offset: %04x, data: %02x\n", offset, data));
67386651
67396652   /* only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
67406653   if (!(offset & 0x100))
6741      chr8(space.machine(), data >> 7, CHRROM);
6654      chr8(machine(), data >> 7, CHRROM);
67426655}
67436656
67446657/*************************************************************
r18063r18064
67536666
67546667 *************************************************************/
67556668
6756static WRITE8_HANDLER( sa72008_l_w )
6669WRITE8_MEMBER(nes_state::sa72008_l_w)
67576670{
67586671   LOG_MMC(("sa72008_l_w, offset: %04x, data: %02x\n", offset, data));
67596672
6760   prg32(space.machine(), data >> 2);
6761   chr8(space.machine(), data, CHRROM);
6673   prg32(machine(), data >> 2);
6674   chr8(machine(), data, CHRROM);
67626675}
67636676
67646677/*************************************************************
r18063r18064
67736686
67746687 *************************************************************/
67756688
6776static READ8_HANDLER( tca01_l_r )
6689READ8_MEMBER(nes_state::tca01_l_r)
67776690{
67786691   LOG_MMC(("tca01_l_r, offset: %04x\n", offset));
67796692
r18063r18064
67966709
67976710 *************************************************************/
67986711
6799static WRITE8_HANDLER( tcu01_l_w )
6712WRITE8_MEMBER(nes_state::tcu01_l_w)
68006713{
68016714   LOG_MMC(("tcu01_l_w, offset: %04x, data: %02x\n", offset, data));
68026715
68036716   if ((offset & 0x103) == 0x002)
68046717   {
6805      prg32(space.machine(), ((data >> 6) & 0x02) | ((data >> 2) & 0x01));
6806      chr8(space.machine(), data >> 3, CHRROM);
6718      prg32(machine(), ((data >> 6) & 0x02) | ((data >> 2) & 0x01));
6719      chr8(machine(), data >> 3, CHRROM);
68076720   }
68086721}
68096722
6810static WRITE8_HANDLER( tcu01_m_w )
6723WRITE8_MEMBER(nes_state::tcu01_m_w)
68116724{
68126725   LOG_MMC(("tcu01_m_w, offset: %04x, data: %02x\n", offset, data));
68136726
68146727   tcu01_l_w(space, (offset + 0x100) & 0xfff, data, mem_mask);
68156728}
68166729
6817static WRITE8_HANDLER( tcu01_w )
6730WRITE8_MEMBER(nes_state::tcu01_w)
68186731{
68196732   LOG_MMC(("tcu01_w, offset: %04x, data: %02x\n", offset, data));
68206733
r18063r18064
68336746
68346747 *************************************************************/
68356748
6836static WRITE8_HANDLER( tcu02_l_w )
6749WRITE8_MEMBER(nes_state::tcu02_l_w)
68376750{
6838   nes_state *state = space.machine().driver_data<nes_state>();
68396751   LOG_MMC(("tcu02_l_w, offset: %04x, data: %02x\n", offset, data));
68406752
68416753   if ((offset & 0x103) == 0x002)
68426754   {
6843      state->m_mmc_latch1 = (data & 0x30) | ((data + 3) & 0x0f);
6844      chr8(space.machine(), state->m_mmc_latch1, CHRROM);
6755      m_mmc_latch1 = (data & 0x30) | ((data + 3) & 0x0f);
6756      chr8(machine(), m_mmc_latch1, CHRROM);
68456757   }
68466758}
68476759
6848static READ8_HANDLER( tcu02_l_r )
6760READ8_MEMBER(nes_state::tcu02_l_r)
68496761{
6850   nes_state *state = space.machine().driver_data<nes_state>();
68516762   LOG_MMC(("tcu02_l_r, offset: %04x\n", offset));
68526763
68536764   if ((offset & 0x103) == 0x000)
6854      return state->m_mmc_latch1 | 0x40;
6765      return m_mmc_latch1 | 0x40;
68556766   else
68566767      return 0x00;
68576768}
r18063r18064
68656776
68666777 *************************************************************/
68676778
6868static WRITE8_HANDLER( subor0_w )
6779WRITE8_MEMBER(nes_state::subor0_w)
68696780{
6870   nes_state *state = space.machine().driver_data<nes_state>();
68716781   UINT8 subor_helper1, subor_helper2;
68726782   LOG_MMC(("subor0_w, offset: %04x, data: %02x\n", offset, data));
68736783
6874   state->m_subor_reg[(offset >> 13) & 0x03] = data;
6875   subor_helper1 = ((state->m_subor_reg[0] ^ state->m_subor_reg[1]) << 1) & 0x20;
6876   subor_helper2 = ((state->m_subor_reg[2] ^ state->m_subor_reg[3]) << 0) & 0x1f;
6784   m_subor_reg[(offset >> 13) & 0x03] = data;
6785   subor_helper1 = ((m_subor_reg[0] ^ m_subor_reg[1]) << 1) & 0x20;
6786   subor_helper2 = ((m_subor_reg[2] ^ m_subor_reg[3]) << 0) & 0x1f;
68776787
6878   if (state->m_subor_reg[1] & 0x08)
6788   if (m_subor_reg[1] & 0x08)
68796789   {
68806790      subor_helper1 += subor_helper2 & 0xfe;
68816791      subor_helper2 = subor_helper1;
68826792      subor_helper1 += 1;
68836793   }
6884   else if (state->m_subor_reg[1] & 0x04)
6794   else if (m_subor_reg[1] & 0x04)
68856795   {
68866796      subor_helper2 += subor_helper1;
68876797      subor_helper1 = 0x1f;
r18063r18064
68926802      subor_helper2 = 0x20;
68936803   }
68946804
6895   prg16_89ab(space.machine(), subor_helper1);
6896   prg16_cdef(space.machine(), subor_helper2);
6805   prg16_89ab(machine(), subor_helper1);
6806   prg16_cdef(machine(), subor_helper2);
68976807}
68986808
68996809/*************************************************************
r18063r18064
69046814
69056815 *************************************************************/
69066816
6907static WRITE8_HANDLER( subor1_w )
6817WRITE8_MEMBER(nes_state::subor1_w)
69086818{
6909   nes_state *state = space.machine().driver_data<nes_state>();
69106819   UINT8 subor_helper1, subor_helper2;
69116820   LOG_MMC(("subor1_w, offset: %04x, data: %02x\n", offset, data));
69126821
6913   state->m_subor_reg[(offset >> 13) & 0x03] = data;
6914   subor_helper1 = ((state->m_subor_reg[0] ^ state->m_subor_reg[1]) << 1) & 0x20;
6915   subor_helper2 = ((state->m_subor_reg[2] ^ state->m_subor_reg[3]) << 0) & 0x1f;
6822   m_subor_reg[(offset >> 13) & 0x03] = data;
6823   subor_helper1 = ((m_subor_reg[0] ^ m_subor_reg[1]) << 1) & 0x20;
6824   subor_helper2 = ((m_subor_reg[2] ^ m_subor_reg[3]) << 0) & 0x1f;
69166825
6917   if (state->m_subor_reg[1] & 0x08)
6826   if (m_subor_reg[1] & 0x08)
69186827   {
69196828      subor_helper1 += subor_helper2 & 0xfe;
69206829      subor_helper2 = subor_helper1;
69216830      subor_helper2 += 1;
69226831   }
6923   else if (state->m_subor_reg[1] & 0x04)
6832   else if (m_subor_reg[1] & 0x04)
69246833   {
69256834      subor_helper2 += subor_helper1;
69266835      subor_helper1 = 0x1f;
r18063r18064
69316840      subor_helper2 = 0x07;
69326841   }
69336842
6934   prg16_89ab(space.machine(), subor_helper1);
6935   prg16_cdef(space.machine(), subor_helper2);
6843   prg16_89ab(machine(), subor_helper1);
6844   prg16_cdef(machine(), subor_helper2);
69366845}
69376846
69386847/*************************************************************
r18063r18064
69886897      mmc3_set_prg(machine, state->m_mmc_prg_base, state->m_mmc_prg_mask);
69896898}
69906899
6991static WRITE8_HANDLER( sgame_boog_l_w )
6900WRITE8_MEMBER(nes_state::sgame_boog_l_w)
69926901{
6993   nes_state *state = space.machine().driver_data<nes_state>();
69946902   LOG_MMC(("sgame_boog_l_w, offset: %04x, data: %02x\n", offset, data));
69956903   offset += 0x100;
69966904
69976905   if (offset == 0x1000)
69986906   {
6999      state->m_mmc_reg[0] = data;
7000      sgame_boog_set_prg(space.machine());
6907      m_mmc_reg[0] = data;
6908      sgame_boog_set_prg(machine());
70016909   }
70026910   else if (offset == 0x1001)
70036911   {
7004      state->m_mmc_reg[1] = data;
7005      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6912      m_mmc_reg[1] = data;
6913      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
70066914   }
70076915   else if (offset == 0x1007)
70086916   {
7009      state->m_mmc3_latch = 0;
7010      state->m_mmc_reg[2] = data;
7011      sgame_boog_set_prg(space.machine());
7012      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6917      m_mmc3_latch = 0;
6918      m_mmc_reg[2] = data;
6919      sgame_boog_set_prg(machine());
6920      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
70136921   }
70146922}
70156923
7016static WRITE8_HANDLER( sgame_boog_m_w )
6924WRITE8_MEMBER(nes_state::sgame_boog_m_w)
70176925{
7018   nes_state *state = space.machine().driver_data<nes_state>();
70196926   LOG_MMC(("sgame_boog_m_w, offset: %04x, data: %02x\n", offset, data));
70206927
70216928   if (offset == 0x0000)
70226929   {
7023      state->m_mmc_reg[0] = data;
7024      sgame_boog_set_prg(space.machine());
6930      m_mmc_reg[0] = data;
6931      sgame_boog_set_prg(machine());
70256932   }
70266933   else if (offset == 0x0001)
70276934   {
7028      state->m_mmc_reg[1] = data;
7029      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6935      m_mmc_reg[1] = data;
6936      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
70306937   }
70316938   else if (offset == 0x0007)
70326939   {
7033      state->m_mmc3_latch = 0;
7034      state->m_mmc_reg[2] = data;
7035      sgame_boog_set_prg(space.machine());
7036      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
6940      m_mmc3_latch = 0;
6941      m_mmc_reg[2] = data;
6942      sgame_boog_set_prg(machine());
6943      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
70376944   }
70386945}
70396946
7040static WRITE8_HANDLER( sgame_boog_w )
6947WRITE8_MEMBER(nes_state::sgame_boog_w)
70416948{
7042   nes_state *state = space.machine().driver_data<nes_state>();
70436949   static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4};
70446950   LOG_MMC(("sgame_boog_w, offset: %04x, data: %02x\n", offset, data));
70456951
70466952   switch (offset & 0x6001)
70476953   {
70486954      case 0x0000:
7049         if (!state->m_mmc_reg[2])
6955         if (!m_mmc_reg[2])
70506956            txrom_w(space, 0x0000, data, mem_mask);
70516957         break;
70526958
70536959      case 0x0001:
7054         if (!state->m_mmc_reg[2])
6960         if (!m_mmc_reg[2])
70556961            txrom_w(space, 0x0001, data, mem_mask);
7056         else if (state->m_mmc_reg[3] && ((state->m_mmc_reg[0] & 0x80) == 0 || (state->m_mmc_latch1 & 0x07) < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
6962         else if (m_mmc_reg[3] && ((m_mmc_reg[0] & 0x80) == 0 || (m_mmc_latch1 & 0x07) < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
70576963         {
7058            state->m_mmc_reg[3] = 0;
6964            m_mmc_reg[3] = 0;
70596965            txrom_w(space, 0x0001, data, mem_mask);
70606966         }
70616967         break;
70626968
70636969      case 0x2000:
7064         if (!state->m_mmc_reg[2])
6970         if (!m_mmc_reg[2])
70656971            txrom_w(space, 0x2000, data, mem_mask);
70666972         else
70676973         {
70686974            data = (data & 0xc0) | conv_table[data & 0x07];
7069            state->m_mmc_reg[3] = 1;
6975            m_mmc_reg[3] = 1;
70706976            txrom_w(space, 0x0000, data, mem_mask);
70716977            break;
70726978         }
70736979         break;
70746980
70756981      case 0x4000:
7076         if (!state->m_mmc_reg[2])
6982         if (!m_mmc_reg[2])
70776983            txrom_w(space, 0x4000, data, mem_mask);
70786984         else
7079            set_nt_mirroring(space.machine(), ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6985            set_nt_mirroring(machine(), ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
70806986         break;
70816987
70826988      case 0x4001:
7083         if (!state->m_mmc_reg[2])
6989         if (!m_mmc_reg[2])
70846990            txrom_w(space, 0x4001, data, mem_mask);
70856991         else
70866992            txrom_w(space, 0x6001, data, mem_mask);
70876993         break;
70886994
70896995      case 0x6001:
7090         if (!state->m_mmc_reg[2])
6996         if (!m_mmc_reg[2])
70916997            txrom_w(space, 0x6001, data, mem_mask);
70926998         else
70936999         {
r18063r18064
71167022
71177023 *************************************************************/
71187024
7119static WRITE8_HANDLER( sgame_lion_m_w )
7025WRITE8_MEMBER(nes_state::sgame_lion_m_w)
71207026{
7121   nes_state *state = space.machine().driver_data<nes_state>();
71227027   LOG_MMC(("sgame_lion_m_w, offset: %04x, data: %02x\n", offset, data));
71237028
7124   state->m_map114_reg = data;
7029   m_map114_reg = data;
71257030
7126   if (state->m_map114_reg & 0x80)
7031   if (m_map114_reg & 0x80)
71277032   {
7128      prg16_89ab(space.machine(), data & 0x1f);
7129      prg16_cdef(space.machine(), data & 0x1f);
7033      prg16_89ab(machine(), data & 0x1f);
7034      prg16_cdef(machine(), data & 0x1f);
71307035   }
71317036   else
7132      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
7037      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
71337038
71347039}
71357040
7136static WRITE8_HANDLER( sgame_lion_w )
7041WRITE8_MEMBER(nes_state::sgame_lion_w)
71377042{
7138   nes_state *state = space.machine().driver_data<nes_state>();
71397043   static const UINT8 conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4};
71407044   LOG_MMC(("sgame_lion_w, offset: %04x, data: %02x\n", offset, data));
71417045
r18063r18064
71447048      switch (offset & 0x6000)
71457049      {
71467050         case 0x0000:
7147            set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
7051            set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
71487052            break;
71497053         case 0x2000:
7150            state->m_map114_reg_enabled = 1;
7054            m_map114_reg_enabled = 1;
71517055            data = (data & 0xc0) | conv_table[data & 0x07];
71527056            txrom_w(space, 0x0000, data, mem_mask);
71537057            break;
71547058         case 0x4000:
7155            if (state->m_map114_reg_enabled && (state->m_map114_reg & 0x80) == 0)
7059            if (m_map114_reg_enabled && (m_map114_reg & 0x80) == 0)
71567060            {
7157               state->m_map114_reg_enabled = 0;
7061               m_map114_reg_enabled = 0;
71587062               txrom_w(space, 0x0001, data, mem_mask);
71597063            }
71607064            break;
r18063r18064
71867090
71877091 *************************************************************/
71887092
7189static WRITE8_HANDLER( tengen_800008_w )
7093WRITE8_MEMBER(nes_state::tengen_800008_w)
71907094{
71917095   LOG_MMC(("tengen_800008_w, offset: %04x, data: %02x\n", offset, data));
71927096
7193   prg32(space.machine(), data >> 3);
7194   chr8(space.machine(), data, CHRROM);
7097   prg32(machine(), data >> 3);
7098   chr8(machine(), data, CHRROM);
71957099}
71967100
71977101/*************************************************************
r18063r18064
73007204   chr1_x(machine, 7 ^ chr_page, state->m_mmc_vrom_bank[5], CHRROM);
73017205}
73027206
7303static WRITE8_HANDLER( tengen_800032_w )
7207WRITE8_MEMBER(nes_state::tengen_800032_w)
73047208{
7305   nes_state *state = space.machine().driver_data<nes_state>();
73067209   UINT8 map64_helper, cmd;
73077210   LOG_MMC(("tengen_800032_w, offset: %04x, data: %02x\n", offset, data));
73087211
73097212   switch (offset & 0x6001)
73107213   {
73117214      case 0x0000:
7312         map64_helper = state->m_mmc_latch1 ^ data;
7313         state->m_mmc_latch1 = data;
7215         map64_helper = m_mmc_latch1 ^ data;
7216         m_mmc_latch1 = data;
73147217
73157218         /* Has PRG Mode changed? */
73167219         if (map64_helper & 0x40)
7317            tengen_800032_set_prg(space.machine());
7220            tengen_800032_set_prg(machine());
73187221
73197222         /* Has CHR Mode changed? */
73207223         if (map64_helper & 0xa0)
7321            tengen_800032_set_chr(space.machine());
7224            tengen_800032_set_chr(machine());
73227225         break;
73237226
73247227      case 0x0001:
7325         cmd = state->m_mmc_latch1 & 0x0f;
7228         cmd = m_mmc_latch1 & 0x0f;
73267229         switch (cmd)
73277230      {
73287231         case 0: case 1:
73297232         case 2: case 3:
73307233         case 4: case 5:
7331            state->m_mmc_vrom_bank[cmd] = data;
7332            tengen_800032_set_chr(space.machine());
7234            m_mmc_vrom_bank[cmd] = data;
7235            tengen_800032_set_chr(machine());
73337236            break;
73347237         case 6: case 7:
7335            state->m_mmc_prg_bank[cmd - 6] = data;
7336            tengen_800032_set_prg(space.machine());
7238            m_mmc_prg_bank[cmd - 6] = data;
7239            tengen_800032_set_prg(machine());
73377240            break;
73387241         case 8: case 9:
7339            state->m_mmc_vrom_bank[cmd - 2] = data;
7340            tengen_800032_set_chr(space.machine());
7242            m_mmc_vrom_bank[cmd - 2] = data;
7243            tengen_800032_set_chr(machine());
73417244            break;
73427245         case 0x0f:
7343            state->m_mmc_prg_bank[2] = data;
7344            tengen_800032_set_prg(space.machine());
7246            m_mmc_prg_bank[2] = data;
7247            tengen_800032_set_prg(machine());
73457248            break;
73467249      }
73477250         break;
73487251
73497252      case 0x2000:
7350         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
7253         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
73517254         break;
73527255
73537256      case 0x4000:
7354         state->m_IRQ_count_latch = data;
7257         m_IRQ_count_latch = data;
73557258         break;
73567259
73577260      case 0x4001: /* $c001 - IRQ scanline latch */
7358         state->m_IRQ_mode = data & 0x01;
7359         state->m_IRQ_reset = 1;
7261         m_IRQ_mode = data & 0x01;
7262         m_IRQ_reset = 1;
73607263         break;
73617264
73627265      case 0x6000:
7363         state->m_IRQ_enable = 0;
7266         m_IRQ_enable = 0;
73647267         break;
73657268
73667269      case 0x6001:
7367         state->m_IRQ_enable = 1;
7270         m_IRQ_enable = 1;
73687271         break;
73697272
73707273      default:
r18063r18064
73977300   set_nt_page(machine, 3, ROM, state->m_mmc_vrom_bank[nt_mode ? 5 : 1], 0);
73987301}
73997302
7400static WRITE8_HANDLER( tengen_800037_w )
7303WRITE8_MEMBER(nes_state::tengen_800037_w)
74017304{
7402   nes_state *state = space.machine().driver_data<nes_state>();
74037305   UINT8 map158_helper, cmd;
74047306   LOG_MMC(("tengen_800037_w, offset: %04x, data: %02x\n", offset, data));
74057307
74067308   switch (offset & 0x6001)
74077309   {
74087310      case 0x0000:
7409         map158_helper = state->m_mmc_latch1 ^ data;
7410         state->m_mmc_latch1 = data;
7311         map158_helper = m_mmc_latch1 ^ data;
7312         m_mmc_latch1 = data;
74117313
74127314         /* Has PRG Mode changed? */
74137315         if (map158_helper & 0x40)
7414            tengen_800032_set_prg(space.machine());
7316            tengen_800032_set_prg(machine());
74157317
74167318         /* Has CHR Mode changed? */
74177319         if (map158_helper & 0xa0)
74187320         {
7419            tengen_800032_set_chr(space.machine());
7420            tengen_800037_set_mirror(space.machine());
7321            tengen_800032_set_chr(machine());
7322            tengen_800037_set_mirror(machine());
74217323         }
74227324         break;
74237325
74247326      case 0x0001:
7425         cmd = state->m_mmc_latch1 & 0x0f;
7327         cmd = m_mmc_latch1 & 0x0f;
74267328         switch (cmd)
74277329      {
74287330         case 0: case 1:
74297331         case 2: case 3:
74307332         case 4: case 5:
7431            state->m_mmc_vrom_bank[cmd] = data;
7432            tengen_800032_set_chr(space.machine());
7433            tengen_800037_set_mirror(space.machine());
7333            m_mmc_vrom_bank[cmd] = data;
7334            tengen_800032_set_chr(machine());
7335            tengen_800037_set_mirror(machine());
74347336            break;
74357337         case 6: case 7:
7436            state->m_mmc_prg_bank[cmd - 6] = data;
7437            tengen_800032_set_prg(space.machine());
7338            m_mmc_prg_bank[cmd - 6] = data;
7339            tengen_800032_set_prg(machine());
74387340            break;
74397341         case 8: case 9:
7440            state->m_mmc_vrom_bank[cmd - 2] = data;
7441            tengen_800032_set_chr(space.machine());
7442            tengen_800037_set_mirror(space.machine());
7342            m_mmc_vrom_bank[cmd - 2] = data;
7343            tengen_800032_set_chr(machine());
7344            tengen_800037_set_mirror(machine());
74437345            break;
74447346         case 0x0f:
7445            state->m_mmc_prg_bank[2] = data;
7446            tengen_800032_set_prg(space.machine());
7347            m_mmc_prg_bank[2] = data;
7348            tengen_800032_set_prg(machine());
74477349            break;
74487350      }
74497351         break;
r18063r18064
74737375
74747376 *************************************************************/
74757377
7476static WRITE8_HANDLER( txc_22211_l_w )
7378WRITE8_MEMBER(nes_state::txc_22211_l_w)
74777379{
7478   nes_state *state = space.machine().driver_data<nes_state>();
74797380   LOG_MMC(("txc_22211_l_w, offset: %04x, data: %02x\n", offset, data));
74807381
74817382   if (offset < 4)
7482      state->m_txc_reg[offset & 0x03] = data;
7383      m_txc_reg[offset & 0x03] = data;
74837384}
74847385
7485static READ8_HANDLER( txc_22211_l_r )
7386READ8_MEMBER(nes_state::txc_22211_l_r)
74867387{
7487   nes_state *state = space.machine().driver_data<nes_state>();
74887388   LOG_MMC(("txc_22211_l_r, offset: %04x\n", offset));
74897389
74907390   if (offset == 0x0000)
7491      return (state->m_txc_reg[1] ^ state->m_txc_reg[2]) | 0x40;
7391      return (m_txc_reg[1] ^ m_txc_reg[2]) | 0x40;
74927392   else
74937393      return 0x00;
74947394}
74957395
7496static WRITE8_HANDLER( txc_22211_w )
7396WRITE8_MEMBER(nes_state::txc_22211_w)
74977397{
7498   nes_state *state = space.machine().driver_data<nes_state>();
74997398   LOG_MMC(("txc_22211_w, offset: %04x, data: %02x\n", offset, data));
75007399
7501   prg32(space.machine(), state->m_txc_reg[2] >> 2);
7502   chr8(space.machine(), state->m_txc_reg[2], CHRROM);
7400   prg32(machine(), m_txc_reg[2] >> 2);
7401   chr8(machine(), m_txc_reg[2], CHRROM);
75037402}
75047403
75057404/*************************************************************
r18063r18064
75177416
75187417 *************************************************************/
75197418
7520static WRITE8_HANDLER( txc_22211b_w )
7419WRITE8_MEMBER(nes_state::txc_22211b_w)
75217420{
7522   nes_state *state = space.machine().driver_data<nes_state>();
75237421   LOG_MMC(("txc_22211b_w, offset: %04x, data: %02x\n", offset, data));
75247422
7525   prg32(space.machine(), state->m_txc_reg[2] >> 2);
7526   chr8(space.machine(), (((data ^ state->m_txc_reg[2]) >> 3) & 0x02) | (((data ^ state->m_txc_reg[2]) >> 5) & 0x01), CHRROM);
7423   prg32(machine(), m_txc_reg[2] >> 2);
7424   chr8(machine(), (((data ^ m_txc_reg[2]) >> 3) & 0x02) | (((data ^ m_txc_reg[2]) >> 5) & 0x01), CHRROM);
75277425}
75287426
75297427/*************************************************************
r18063r18064
75417439
75427440 *************************************************************/
75437441
7544static READ8_HANDLER( txc_22211c_l_r )
7442READ8_MEMBER(nes_state::txc_22211c_l_r)
75457443{
7546   nes_state *state = space.machine().driver_data<nes_state>();
75477444   LOG_MMC(("txc_22211c_l_r, offset: %04x\n", offset));
75487445
75497446   if (offset == 0x0000)
7550      return (state->m_txc_reg[1] ^ state->m_txc_reg[2]) | 0x41;
7447      return (m_txc_reg[1] ^ m_txc_reg[2]) | 0x41;
75517448   else
75527449      return 0x00;
75537450}
r18063r18064
75667463
75677464 *************************************************************/
75687465
7569static WRITE8_HANDLER( txc_tw_l_w )
7466WRITE8_MEMBER(nes_state::txc_tw_l_w)
75707467{
75717468   LOG_MMC(("txctw_l_w, offset: %04x, data: %02x\n", offset, data));
75727469
7573   prg32(space.machine(), (data >> 4) | data);
7470   prg32(machine(), (data >> 4) | data);
75747471}
75757472
7576static WRITE8_HANDLER( txc_tw_m_w )
7473WRITE8_MEMBER(nes_state::txc_tw_m_w)
75777474{
75787475   LOG_MMC(("txctw_m_w, offset: %04x, data: %04x\n", offset, data));
75797476
r18063r18064
76007497
76017498 *************************************************************/
76027499
7603static WRITE8_HANDLER( txc_strikewolf_w )
7500WRITE8_MEMBER(nes_state::txc_strikewolf_w)
76047501{
76057502   LOG_MMC(("txc_strikewolf_w, offset: %04x, data: %02x\n", offset, data));
76067503
76077504   if ((offset >= 0x400) && (offset < 0x7fff))
76087505   {
7609      prg32(space.machine(), data >> 4);
7610      chr8(space.machine(), data & 0x0f, CHRROM);
7506      prg32(machine(), data >> 4);
7507      chr8(machine(), data & 0x0f, CHRROM);
76117508   }
76127509}
76137510
r18063r18064
76277524
76287525 *************************************************************/
76297526
7630static READ8_HANDLER( txc_mxmdhtwo_l_r )
7527READ8_MEMBER(nes_state::txc_mxmdhtwo_l_r)
76317528{
76327529   return 0x50;
76337530}
76347531
7635static WRITE8_HANDLER( txc_mxmdhtwo_w )
7532WRITE8_MEMBER(nes_state::txc_mxmdhtwo_w)
76367533{
76377534   LOG_MMC(("txc_mxmdhtwo_w, offset: %04x, data: %02x\n", offset, data));
76387535
7639   prg32(space.machine(), data);
7536   prg32(machine(), data);
76407537}
76417538
76427539/*************************************************************
r18063r18064
76917588   chr1_x(machine, start, bank, chr_src);
76927589}
76937590
7694static WRITE8_HANDLER( waixing_a_w )
7591WRITE8_MEMBER(nes_state::waixing_a_w)
76957592{
76967593   LOG_MMC(("waixing_a_w, offset: %04x, data: %02x\n", offset, data));
76977594
76987595   switch (offset & 0x6001)
76997596   {
77007597      case 0x2000:
7701         waixing_set_mirror(space.machine(), data);   //maybe data & 0x03?
7598         waixing_set_mirror(machine(), data);   //maybe data & 0x03?
77027599         break;
77037600
77047601      case 0x2001:
r18063r18064
78137710
78147711 *************************************************************/
78157712
7816static WRITE8_HANDLER( waixing_f_w )
7713WRITE8_MEMBER(nes_state::waixing_f_w)
78177714{
7818   nes_state *state = space.machine().driver_data<nes_state>();
78197715   UINT8 cmd;
78207716   LOG_MMC(("waixing_f_w, offset: %04x, data: %02x\n", offset, data));
78217717
78227718   switch (offset & 0x6001)
78237719   {
78247720      case 0x0001:
7825         cmd = state->m_mmc_latch1 & 0x07;
7721         cmd = m_mmc_latch1 & 0x07;
78267722         if (cmd >= 6)
78277723         {
7828            state->m_mmc_prg_bank[cmd - 6] = data & ((data > 0x3f) ? 0x4f : 0x3f);
7829            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
7724            m_mmc_prg_bank[cmd - 6] = data & ((data > 0x3f) ? 0x4f : 0x3f);
7725            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
78307726         }
78317727         else
78327728            waixing_a_w(space, offset, data, mem_mask);
r18063r18064
78747770   state->m_mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->m_mmc_vrom_bank[5] & chr_mask), state->m_mmc_chr_source);
78757771}
78767772
7877static WRITE8_HANDLER( waixing_g_w )
7773WRITE8_MEMBER(nes_state::waixing_g_w)
78787774{
7879   nes_state *state = space.machine().driver_data<nes_state>();
78807775   UINT8 MMC3_helper, cmd;
78817776   LOG_MMC(("waixing_g_w, offset: %04x, data: %02x\n", offset, data));
78827777
78837778   switch (offset & 0x6001)
78847779   {
78857780      case 0x0000:
7886         MMC3_helper = state->m_mmc_latch1 ^ data;
7887         state->m_mmc_latch1 = data;
7781         MMC3_helper = m_mmc_latch1 ^ data;
7782         m_mmc_latch1 = data;
78887783
78897784         /* Has PRG Mode changed? */
78907785         if (MMC3_helper & 0x40)
7891            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
7786            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
78927787
78937788         /* Has CHR Mode changed? */
78947789         if (MMC3_helper & 0x80)
7895            waixing_g_set_chr(space.machine(), state->m_mmc_chr_base, state->m_mmc_chr_mask);
7790            waixing_g_set_chr(machine(), m_mmc_chr_base, m_mmc_chr_mask);
78967791         break;
78977792
78987793      case 0x0001:
7899         cmd = state->m_mmc_latch1 & 0x0f;
7794         cmd = m_mmc_latch1 & 0x0f;
79007795         switch (cmd)
79017796         {
79027797         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
79037798         case 2: case 3: case 4: case 5:
7904            state->m_mmc_vrom_bank[cmd] = data;
7905            waixing_g_set_chr(space.machine(), state->m_mmc_chr_base, state->m_mmc_chr_mask);
7799            m_mmc_vrom_bank[cmd] = data;
7800            waixing_g_set_chr(machine(), m_mmc_chr_base, m_mmc_chr_mask);
79067801            break;
79077802         case 6:
79087803         case 7:
79097804         case 8:
79107805         case 9:
7911            state->m_mmc_prg_bank[cmd - 6] = data;
7912            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
7806            m_mmc_prg_bank[cmd - 6] = data;
7807            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
79137808            break;
79147809         case 0x0a: case 0x0b:
7915            state->m_mmc_vrom_bank[cmd - 4] = data;
7916            waixing_g_set_chr(space.machine(), state->m_mmc_chr_base, state->m_mmc_chr_mask);
7810            m_mmc_vrom_bank[cmd - 4] = data;
7811            waixing_g_set_chr(machine(), m_mmc_chr_base, m_mmc_chr_mask);
79177812            break;
79187813         }
79197814         break;
r18063r18064
79457840      chr1_x(machine, start, bank, source);
79467841}
79477842
7948static WRITE8_HANDLER( waixing_h_w )
7843WRITE8_MEMBER(nes_state::waixing_h_w)
79497844{
7950   nes_state *state = space.machine().driver_data<nes_state>();
79517845   UINT8 cmd;
79527846   LOG_MMC(("waixing_h_w, offset: %04x, data: %02x\n", offset, data));
79537847
79547848   switch (offset & 0x6001)
79557849   {
79567850      case 0x0001:
7957         cmd = state->m_mmc3_latch & 0x07;
7851         cmd = m_mmc3_latch & 0x07;
79587852         switch (cmd)
79597853         {
7960         case 0:    // in this case we set prg_base in addition to state->m_mmc_vrom_bank!
7961            state->m_mmc_prg_base = (data << 5) & 0x40;
7962            state->m_mmc_prg_mask = 0x3f;
7963            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
7854         case 0:    // in this case we set prg_base in addition to m_mmc_vrom_bank!
7855            m_mmc_prg_base = (data << 5) & 0x40;
7856            m_mmc_prg_mask = 0x3f;
7857            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
79647858            txrom_w(space, offset, data, mem_mask);
79657859         default:
79667860            txrom_w(space, offset, data, mem_mask);
r18063r18064
79917885
79927886 *************************************************************/
79937887
7994static WRITE8_HANDLER( waixing_sgz_w )
7888WRITE8_MEMBER(nes_state::waixing_sgz_w)
79957889{
7996   nes_state *state = space.machine().driver_data<nes_state>();
79977890   UINT8 mmc_helper, bank;
79987891   LOG_MMC(("waixing_sgz_w, offset: %04x, data: %02x\n", offset, data));
79997892
80007893   switch (offset & 0x7000)
80017894   {
80027895      case 0x0000:
8003         prg8_89(space.machine(), data);
7896         prg8_89(machine(), data);
80047897         break;
80057898      case 0x2000:
8006         prg8_ab(space.machine(), data);
7899         prg8_ab(machine(), data);
80077900         break;
80087901      case 0x3000:
80097902      case 0x4000:
r18063r18064
80127905         bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0008) >> 3);
80137906         mmc_helper = offset & 0x04;
80147907         if (mmc_helper)
8015            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f) << 4);
7908            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f) << 4);
80167909         else
8017            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8018         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
7910            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
7911         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
80197912         break;
80207913      case 0x7000:
80217914         switch (offset & 0x0c)
80227915         {
80237916         case 0x00:
8024            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xf0) | (data & 0x0f);
7917            m_IRQ_count_latch = (m_IRQ_count_latch & 0xf0) | (data & 0x0f);
80257918            break;
80267919         case 0x04:
8027            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
7920            m_IRQ_count_latch = (m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
80287921            break;
80297922         case 0x08:
8030            state->m_IRQ_enable = data & 0x02;
8031            state->m_IRQ_enable_latch = data & 0x01;
7923            m_IRQ_enable = data & 0x02;
7924            m_IRQ_enable_latch = data & 0x01;
80327925            if (data & 0x02)
8033               state->m_IRQ_count = state->m_IRQ_count_latch;
7926               m_IRQ_count = m_IRQ_count_latch;
80347927            break;
80357928         case 0x0c:
8036            state->m_IRQ_enable = state->m_IRQ_enable_latch;
7929            m_IRQ_enable = m_IRQ_enable_latch;
80377930            break;
80387931         }
80397932         break;
r18063r18064
80547947
80557948 *************************************************************/
80567949
8057static WRITE8_HANDLER( waixing_sgzlz_l_w )
7950WRITE8_MEMBER(nes_state::waixing_sgzlz_l_w)
80587951{
8059   nes_state *state = space.machine().driver_data<nes_state>();
80607952   LOG_MMC(("waixing_sgzlz_l_w, offset: %04x, data: %02x\n", offset, data));
80617953
80627954   switch (offset)
80637955   {
80647956      case 0x700:
8065         set_nt_mirroring(space.machine(), data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
7957         set_nt_mirroring(machine(), data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
80667958         break;
80677959      case 0x701:
8068         state->m_mmc_latch1 = (state->m_mmc_latch1 & 0x0c) | ((data >> 1) & 0x03);
8069         prg32(space.machine(), state->m_mmc_latch1);
7960         m_mmc_latch1 = (m_mmc_latch1 & 0x0c) | ((data >> 1) & 0x03);
7961         prg32(machine(), m_mmc_latch1);
80707962         break;
80717963      case 0x702:
8072         state->m_mmc_latch1 = (state->m_mmc_latch1 & 0x03) | ((data << 2) & 0x0c);
7964         m_mmc_latch1 = (m_mmc_latch1 & 0x03) | ((data << 2) & 0x0c);
80737965         break;
80747966   }
80757967}
r18063r18064
80877979
80887980 *************************************************************/
80897981
8090static WRITE8_HANDLER( waixing_ffv_l_w )
7982WRITE8_MEMBER(nes_state::waixing_ffv_l_w)
80917983{
8092   nes_state *state = space.machine().driver_data<nes_state>();
80937984   UINT8 mmc_helper;
80947985   LOG_MMC(("waixing_ffv_l_w, offset: %04x, data: %02x\n", offset, data));
80957986   offset += 0x100; /* the checks work better on addresses */
80967987
80977988   if (0x1000 == (offset & 0x1200))
80987989   {
8099      state->m_mmc_reg[BIT(offset, 8)] = data;
8100      mmc_helper = BIT(state->m_mmc_reg[1], 0) << 5;
8101      switch (state->m_mmc_reg[0] & 0x70)
7990      m_mmc_reg[BIT(offset, 8)] = data;
7991      mmc_helper = BIT(m_mmc_reg[1], 0) << 5;
7992      switch (m_mmc_reg[0] & 0x70)
81027993      {
81037994         case 0x00:
81047995         case 0x20:
81057996         case 0x40:
81067997         case 0x60:
8107            prg16_89ab(space.machine(), mmc_helper | ((state->m_mmc_reg[0] >> 1) & 0x10) | (state->m_mmc_reg[0] & 0x0f));
8108            prg16_cdef(space.machine(), mmc_helper & 0x1f);
7998            prg16_89ab(machine(), mmc_helper | ((m_mmc_reg[0] >> 1) & 0x10) | (m_mmc_reg[0] & 0x0f));
7999            prg16_cdef(machine(), mmc_helper & 0x1f);
81098000            break;
81108001         case 0x50:
8111            prg32(space.machine(), (mmc_helper >> 1) | (state->m_mmc_reg[0] & 0x0f));
8002            prg32(machine(), (mmc_helper >> 1) | (m_mmc_reg[0] & 0x0f));
81128003            break;
81138004         case 0x70:
8114            prg16_89ab(space.machine(), mmc_helper | ((state->m_mmc_reg[0] << 1) & 0x10) | (state->m_mmc_reg[0] & 0x0f));
8115            prg16_cdef(space.machine(), mmc_helper & 0x1f);
8005            prg16_89ab(machine(), mmc_helper | ((m_mmc_reg[0] << 1) & 0x10) | (m_mmc_reg[0] & 0x0f));
8006            prg16_cdef(machine(), mmc_helper & 0x1f);
81168007            break;
81178008      }
81188009   }
r18063r18064
81378028
81388029 *************************************************************/
81398030
8140static WRITE8_HANDLER( waixing_zs_w )
8031WRITE8_MEMBER(nes_state::waixing_zs_w)
81418032{
81428033   LOG_MMC(("waixing_zs_w, offset: %04x, data: %02x\n", offset, data));
81438034
8144   prg32(space.machine(), offset >> 3);
8035   prg32(machine(), offset >> 3);
81458036
81468037   switch (data & 0x03)
81478038   {
8148      case 0: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
8149      case 1: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
8150      case 2: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
8151      case 3: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
8039      case 0: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
8040      case 1: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
8041      case 2: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
8042      case 3: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
81528043   }
81538044}
81548045
r18063r18064
81678058
81688059 *************************************************************/
81698060
8170static WRITE8_HANDLER( waixing_dq8_w )
8061WRITE8_MEMBER(nes_state::waixing_dq8_w)
81718062{
81728063   LOG_MMC(("waixing_dq8_w, offset: %04x, data: %02x\n", offset, data));
81738064
8174   prg32(space.machine(), offset >> 3);
8065   prg32(machine(), offset >> 3);
81758066}
81768067
81778068
r18063r18064
81878078
81888079 *************************************************************/
81898080
8190static WRITE8_HANDLER( waixing_ps2_w )
8081WRITE8_MEMBER(nes_state::waixing_ps2_w)
81918082{
81928083   UINT8 map15_flip = (data & 0x80) >> 7;
81938084   UINT8 map15_helper = (data & 0x7f) << 1;
81948085
81958086   LOG_MMC(("waixing_ps2_w, offset: %04x, data: %02x\n", offset, data));
81968087
8197   set_nt_mirroring(space.machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8088   set_nt_mirroring(machine(), BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
81988089
81998090   switch (offset & 0x0fff)
82008091   {
82018092      case 0x000:
8202         prg8_89(space.machine(), (map15_helper + 0) ^ map15_flip);
8203         prg8_ab(space.machine(), (map15_helper + 1) ^ map15_flip);
8204         prg8_cd(space.machine(), (map15_helper + 2) ^ map15_flip);
8205         prg8_ef(space.machine(), (map15_helper + 3) ^ map15_flip);
8093         prg8_89(machine(), (map15_helper + 0) ^ map15_flip);
8094         prg8_ab(machine(), (map15_helper + 1) ^ map15_flip);
8095         prg8_cd(machine(), (map15_helper + 2) ^ map15_flip);
8096         prg8_ef(machine(), (map15_helper + 3) ^ map15_flip);
82068097         break;
82078098      case 0x001:
82088099         map15_helper |= map15_flip;
8209         prg8_89(space.machine(), map15_helper);
8210         prg8_ab(space.machine(), map15_helper + 1);
8211         prg8_cd(space.machine(), map15_helper + 1);
8212         prg8_ef(space.machine(), map15_helper + 1);
8100         prg8_89(machine(), map15_helper);
8101         prg8_ab(machine(), map15_helper + 1);
8102         prg8_cd(machine(), map15_helper + 1);
8103         prg8_ef(machine(), map15_helper + 1);
82138104         break;
82148105      case 0x002:
82158106         map15_helper |= map15_flip;
8216         prg8_89(space.machine(), map15_helper);
8217         prg8_ab(space.machine(), map15_helper);
8218         prg8_cd(space.machine(), map15_helper);
8219         prg8_ef(space.machine(), map15_helper);
8107         prg8_89(machine(), map15_helper);
8108         prg8_ab(machine(), map15_helper);
8109         prg8_cd(machine(), map15_helper);
8110         prg8_ef(machine(), map15_helper);
82208111         break;
82218112      case 0x003:
82228113         map15_helper |= map15_flip;
8223         prg8_89(space.machine(), map15_helper);
8224         prg8_ab(space.machine(), map15_helper + 1);
8225         prg8_cd(space.machine(), map15_helper);
8226         prg8_ef(space.machine(), map15_helper + 1);
8114         prg8_89(machine(), map15_helper);
8115         prg8_ab(machine(), map15_helper + 1);
8116         prg8_cd(machine(), map15_helper);
8117         prg8_ef(machine(), map15_helper + 1);
82278118         break;
82288119   }
82298120}
r18063r18064
82648155   chr1_x(machine, start, bank, source);
82658156}
82668157
8267static WRITE8_HANDLER( waixing_sec_l_w )
8158WRITE8_MEMBER(nes_state::waixing_sec_l_w)
82688159{
8269   nes_state *state = space.machine().driver_data<nes_state>();
82708160   LOG_MMC(("waixing_sec_l_w, offset: %04x, data: %02x\n", offset, data));
82718161
82728162   offset += 0x100;
82738163
82748164   if (offset == 0x1000)
82758165   {
8276      state->m_mmc_reg[0] = data & 0x02;
8277      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
8278      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
8166      m_mmc_reg[0] = data & 0x02;
8167      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
8168      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
82798169   }
82808170}
82818171
r18063r18064
83018191   chr4_4(machine, state->m_mmc_reg[1], state->m_mmc_reg[1] ? CHRRAM : CHRROM);
83028192}
83038193
8304READ8_HANDLER( waixing_sh2_chr_r )
8194READ8_MEMBER(nes_state::waixing_sh2_chr_r)
83058195{
8306   nes_state *state = space.machine().driver_data<nes_state>();
83078196   int bank = offset >> 10;
8308   UINT8 val = state->m_chr_map[bank].access[offset & 0x3ff];   // this would be usual return value
8197   UINT8 val = m_chr_map[bank].access[offset & 0x3ff];   // this would be usual return value
83098198   int chr_helper;
83108199
83118200   switch (offset & 0xff8)
r18063r18064
83158204      default: return val;
83168205   }
83178206
8318   state->m_mmc_reg[offset >> 12] = chr_helper;
8207   m_mmc_reg[offset >> 12] = chr_helper;
83198208   if (offset & 0x1000)
8320      chr4_4(space.machine(), state->m_mmc_reg[1], state->m_mmc_reg[1] ? CHRRAM : CHRROM);
8209      chr4_4(machine(), m_mmc_reg[1], m_mmc_reg[1] ? CHRRAM : CHRROM);
83218210   else
8322      chr4_0(space.machine(), state->m_mmc_reg[0], state->m_mmc_reg[0] ? CHRRAM : CHRROM);
8211      chr4_0(machine(), m_mmc_reg[0], m_mmc_reg[0] ? CHRRAM : CHRROM);
83238212
83248213   return val;
83258214}
r18063r18064
83528241   chr1_x(machine, start, bank, source);
83538242}
83548243
8355static WRITE8_HANDLER( unl_8237_l_w )
8244WRITE8_MEMBER(nes_state::unl_8237_l_w)
83568245{
8357   nes_state *state = space.machine().driver_data<nes_state>();
83588246   LOG_MMC(("unl_8237_l_w offset: %04x, data: %02x\n", offset, data));
83598247   offset += 0x100;
83608248
83618249   if (offset == 0x1000)
83628250   {
8363      state->m_mmc_reg[0] = data;
8364      if (state->m_mmc_reg[0] & 0x80)
8251      m_mmc_reg[0] = data;
8252      if (m_mmc_reg[0] & 0x80)
83658253      {
8366         if (state->m_mmc_reg[0] & 0x20)
8367            prg32(space.machine(), (state->m_mmc_reg[0] & 0x0f) >> 1);
8254         if (m_mmc_reg[0] & 0x20)
8255            prg32(machine(), (m_mmc_reg[0] & 0x0f) >> 1);
83688256         else
83698257         {
8370            prg16_89ab(space.machine(), state->m_mmc_reg[0] & 0x1f);
8371            prg16_cdef(space.machine(), state->m_mmc_reg[0] & 0x1f);
8258            prg16_89ab(machine(), m_mmc_reg[0] & 0x1f);
8259            prg16_cdef(machine(), m_mmc_reg[0] & 0x1f);
83728260         }
83738261      }
83748262      else
8375         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
8263         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
83768264   }
83778265
83788266   if (offset == 0x1001)
83798267   {
8380      state->m_mmc_reg[1] = data;
8381      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
8268      m_mmc_reg[1] = data;
8269      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
83828270   }
83838271}
83848272
8385static WRITE8_HANDLER( unl_8237_w )
8273WRITE8_MEMBER(nes_state::unl_8237_w)
83868274{
8387   nes_state *state = space.machine().driver_data<nes_state>();
83888275   static const UINT8 conv_table[8] = {0, 2, 6, 1, 7, 3, 4, 5};
83898276   LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data));
83908277
r18063r18064
83928279   {
83938280      case 0x0000:
83948281      case 0x1000:
8395         set_nt_mirroring(space.machine(), (data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8282         set_nt_mirroring(machine(), (data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
83968283         break;
83978284
83988285      case 0x2000:
83998286      case 0x3000:
8400         state->m_mmc_reg[2] = 1;
8287         m_mmc_reg[2] = 1;
84018288         data = (data & 0xc0) | conv_table[data & 0x07];
84028289         txrom_w(space, 0x0000, data, mem_mask);
84038290         break;
84048291
84058292      case 0x4000:
84068293      case 0x5000:
8407         if (state->m_mmc_reg[2])
8294         if (m_mmc_reg[2])
84088295         {
8409            state->m_mmc_reg[2] = 0;
8296            m_mmc_reg[2] = 0;
84108297            txrom_w(space, 0x0001, data, mem_mask);
84118298         }
84128299         break;
r18063r18064
84398326   prg8_ab(machine, state->m_mmc_prg_bank[1]);
84408327}
84418328
8442static WRITE8_HANDLER( unl_ax5705_w )
8329WRITE8_MEMBER(nes_state::unl_ax5705_w)
84438330{
8444   nes_state *state = space.machine().driver_data<nes_state>();
84458331   UINT8 bank;
84468332   LOG_MMC(("unl_ax5705_w offset: %04x, data: %02x\n", offset, data));
84478333
84488334   switch (offset & 0x700f)
84498335   {
84508336      case 0x0000:
8451         state->m_mmc_prg_bank[0] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
8452         unl_ax5705_set_prg(space.machine());
8337         m_mmc_prg_bank[0] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
8338         unl_ax5705_set_prg(machine());
84538339         break;
84548340      case 0x0008:
8455         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8341         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
84568342         break;
84578343      case 0x2000:
8458         state->m_mmc_prg_bank[1] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
8459         unl_ax5705_set_prg(space.machine());
8344         m_mmc_prg_bank[1] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
8345         unl_ax5705_set_prg(machine());
84608346         break;
84618347         /* CHR banks 0, 1, 4, 5 */
84628348      case 0x2008:
r18063r18064
84648350      case 0x4008:
84658351      case 0x400a:
84668352         bank = ((offset & 0x4000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
8467         state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8468         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
8353         m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8354         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
84698355         break;
84708356      case 0x2009:
84718357      case 0x200b:
84728358      case 0x4009:
84738359      case 0x400b:
84748360         bank = ((offset & 0x4000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
8475         state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
8476         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
8361         m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
8362         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
84778363         break;
84788364         /* CHR banks 2, 3, 6, 7 */
84798365      case 0x4000:
r18063r18064
84818367      case 0x6000:
84828368      case 0x6002:
84838369         bank = 2 + ((offset & 0x2000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
8484         state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8485         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
8370         m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8371         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
84868372         break;
84878373      case 0x4001:
84888374      case 0x4003:
84898375      case 0x6001:
84908376      case 0x6003:
84918377         bank = 2 + ((offset & 0x2000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
8492         state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
8493         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], CHRROM);
8378         m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
8379         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], CHRROM);
84948380         break;
84958381   }
84968382}
r18063r18064
85058391
85068392 *************************************************************/
85078393
8508static WRITE8_HANDLER( unl_cc21_w )
8394WRITE8_MEMBER(nes_state::unl_cc21_w)
85098395{
85108396   LOG_MMC(("unl_cc21_w offset: %04x, data: %02x\n", offset, data));
85118397
8512   set_nt_mirroring(space.machine(), BIT(data, 1) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
8513   chr8(space.machine(), (offset & 0x01), CHRROM);
8398   set_nt_mirroring(machine(), BIT(data, 1) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
8399   chr8(machine(), (offset & 0x01), CHRROM);
85148400}
85158401
85168402/*************************************************************
r18063r18064
85308416   return ((data >> 1) & 0x01) | ((data >> 4) & 0x02) | ((data << 2) & 0x04) | ((data >> 0) & 0xd8) | ((data << 3) & 0x20);
85318417}
85328418
8533static WRITE8_HANDLER( unl_kof97_w )
8419WRITE8_MEMBER(nes_state::unl_kof97_w)
85348420{
85358421   LOG_MMC(("unl_kof97_w offset: %04x, data: %02x\n", offset, data));
85368422
r18063r18064
85868472
85878473 *************************************************************/
85888474
8589static WRITE8_HANDLER( ks7057_w )
8475WRITE8_MEMBER(nes_state::ks7057_w)
85908476{
85918477   LOG_MMC(("ks7057_w, offset: %04x, data: %02x\n", offset, data));
85928478   offset = (BIT(offset, 0) << 1) | BIT(offset, 1) | (offset & ~0x03);
r18063r18064
86038489
86048490 *************************************************************/
86058491
8606static WRITE8_HANDLER( unl_t230_w )
8492WRITE8_MEMBER(nes_state::unl_t230_w)
86078493{
8608   nes_state *state = space.machine().driver_data<nes_state>();
86098494   UINT8 bank;
86108495   LOG_MMC(("unl_t230_w offset: %04x, data: %02x\n", offset, data));
86118496
r18063r18064
86148499      case 0x0000:
86158500         break;
86168501      case 0x2000:
8617         prg16_89ab(space.machine(), data);
8502         prg16_89ab(machine(), data);
86188503         break;
86198504
86208505      // the part below works like VRC-2. how was the original board wired up?
r18063r18064
86258510      case 0x100c:
86268511         switch (data & 0x03)
86278512         {
8628         case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
8629         case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
8630         case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
8631         case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
8513         case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
8514         case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
8515         case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
8516         case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
86328517         }
86338518         break;
86348519
r18063r18064
86508535      case 0x600c:
86518536         bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0008) >> 2);
86528537         if (offset & 0x0004)
8653            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0x0f) | (data << 4);
8538            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0x0f) | (data << 4);
86548539         else
8655            state->m_mmc_vrom_bank[bank] = (state->m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8540            m_mmc_vrom_bank[bank] = (m_mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
86568541
8657         chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[bank], state->m_mmc_chr_source);
8542         chr1_x(machine(), bank, m_mmc_vrom_bank[bank], m_mmc_chr_source);
86588543         break;
86598544      case 0x7000:
8660         state->m_IRQ_count_latch &= ~0x0f;
8661         state->m_IRQ_count_latch |= data & 0x0f;
8545         m_IRQ_count_latch &= ~0x0f;
8546         m_IRQ_count_latch |= data & 0x0f;
86628547         break;
86638548      case 0x7004:
8664         state->m_IRQ_count_latch &= ~0xf0;
8665         state->m_IRQ_count_latch |= (data << 4) & 0xf0;
8549         m_IRQ_count_latch &= ~0xf0;
8550         m_IRQ_count_latch |= (data << 4) & 0xf0;
86668551         break;
86678552      case 0x7008:
8668         state->m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
8669         state->m_IRQ_enable = data & 0x02;
8670         state->m_IRQ_enable_latch = data & 0x01;
8553         m_IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
8554         m_IRQ_enable = data & 0x02;
8555         m_IRQ_enable_latch = data & 0x01;
86718556         if (data & 0x02)
8672            state->m_IRQ_count = state->m_IRQ_count_latch;
8557            m_IRQ_count = m_IRQ_count_latch;
86738558         break;
86748559
86758560      default:
r18063r18064
87128597   chr1_x(machine, start, bank, source);
87138598}
87148599
8715static WRITE8_HANDLER( kof96_l_w )
8600WRITE8_MEMBER(nes_state::kof96_l_w)
87168601{
8717   nes_state *state = space.machine().driver_data<nes_state>();
87188602   UINT8 new_bank;
87198603   LOG_MMC(("kof96_l_w, offset: %04x, data: %02x\n", offset, data));
87208604   offset += 0x100;
87218605
87228606   if (offset == 0x1000)
87238607   {
8724      state->m_mmc_reg[0] = data;
8608      m_mmc_reg[0] = data;
87258609
8726      if (state->m_mmc_reg[0] & 0x80)
8610      if (m_mmc_reg[0] & 0x80)
87278611      {
8728         new_bank = (state->m_mmc_reg[0] & 0x1f);
8612         new_bank = (m_mmc_reg[0] & 0x1f);
87298613
8730         if (state->m_mmc_reg[0] & 0x20)
8731            prg32(space.machine(), new_bank >> 2);
8614         if (m_mmc_reg[0] & 0x20)
8615            prg32(machine(), new_bank >> 2);
87328616         else
87338617         {
8734            prg16_89ab(space.machine(), new_bank);
8735            prg16_cdef(space.machine(), new_bank);
8618            prg16_89ab(machine(), new_bank);
8619            prg16_cdef(machine(), new_bank);
87368620         }
87378621      }
87388622      else
8739         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
8623         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
87408624   }
87418625
87428626   if (offset >= 0x1000)
r18063r18064
87458629      {
87468630         case 0x00:
87478631         case 0x01:
8748            state->m_mmc_reg[1] = 0x83;
8632            m_mmc_reg[1] = 0x83;
87498633            break;
87508634         case 0x02:
8751            state->m_mmc_reg[1] = 0x42;
8635            m_mmc_reg[1] = 0x42;
87528636            break;
87538637         case 0x03:
8754            state->m_mmc_reg[1] = 0x00;
8638            m_mmc_reg[1] = 0x00;
87558639            break;
87568640      }
87578641
87588642   }
87598643
8760   if (!state->m_mmc_reg[3] && offset > 0x1000)
8644   if (!m_mmc_reg[3] && offset > 0x1000)
87618645   {
8762      state->m_mmc_reg[3] = 1;
8646      m_mmc_reg[3] = 1;
87638647      space.write_byte(0x4017, 0x40);
87648648   }
87658649}
87668650
8767static READ8_HANDLER( kof96_l_r )
8651READ8_MEMBER(nes_state::kof96_l_r)
87688652{
8769   nes_state *state = space.machine().driver_data<nes_state>();
87708653   LOG_MMC(("kof96_l_r, offset: %04x\n", offset));
87718654   offset += 0x100;
87728655
87738656   if (!(offset < 0x1000))
8774      return state->m_mmc_reg[1];
8657      return m_mmc_reg[1];
87758658   else
87768659      return 0;
87778660}
87788661
8779static WRITE8_HANDLER( kof96_w )
8662WRITE8_MEMBER(nes_state::kof96_w)
87808663{
8781   nes_state *state = space.machine().driver_data<nes_state>();
87828664   LOG_MMC(("kof96_w, offset: %04x, data: %02x\n", offset, data));
87838665
87848666   switch (offset & 0x6003)
87858667   {
87868668      case 0x0000:
8787         state->m_mmc_reg[2] = 1;
8669         m_mmc_reg[2] = 1;
87888670         txrom_w(space, 0x0000, data, mem_mask);
87898671         break;
87908672
87918673      case 0x0001:
8792         if (state->m_mmc_reg[2])
8674         if (m_mmc_reg[2])
87938675            txrom_w(space, 0x0001, data, mem_mask);
87948676         break;
87958677
r18063r18064
87978679         break;
87988680
87998681      case 0x0003:
8800         state->m_mmc_reg[2] = 0;
8682         m_mmc_reg[2] = 0;
88018683
88028684         if (data == 0x28)
8803            prg8_cd(space.machine(), 0x17);
8685            prg8_cd(machine(), 0x17);
88048686         else if (data == 0x2a)
8805            prg8_ab(space.machine(), 0x0f);
8687            prg8_ab(machine(), 0x0f);
88068688         break;
88078689
88088690      default:
r18063r18064
88278709
88288710 *************************************************************/
88298711
8830static WRITE8_HANDLER( mk2_m_w )
8712WRITE8_MEMBER(nes_state::mk2_m_w)
88318713{
8832   nes_state *state = space.machine().driver_data<nes_state>();
88338714   LOG_MMC(("mk2_m_w, offset: %04x, data: %02x\n", offset, data));
88348715
88358716   switch (offset & 0x1000)
r18063r18064
88378718      case 0x0000:
88388719         switch (offset & 0x03)
88398720         {
8840         case 0x00: chr2_0(space.machine(), data, CHRROM); break;
8841         case 0x01: chr2_2(space.machine(), data, CHRROM); break;
8842         case 0x02: chr2_4(space.machine(), data, CHRROM); break;
8843         case 0x03: chr2_6(space.machine(), data, CHRROM); break;
8721         case 0x00: chr2_0(machine(), data, CHRROM); break;
8722         case 0x01: chr2_2(machine(), data, CHRROM); break;
8723         case 0x02: chr2_4(machine(), data, CHRROM); break;
8724         case 0x03: chr2_6(machine(), data, CHRROM); break;
88448725         }
88458726         break;
88468727      case 0x1000:
88478728         switch (offset & 0x03)
88488729         {
8849         case 0x00: prg8_89(space.machine(), data); break;
8850         case 0x01: prg8_ab(space.machine(), data); break;
8851         case 0x02: state->m_IRQ_enable = 0; state->m_IRQ_count = 0; break;
8852         case 0x03: state->m_IRQ_enable = 1; state->m_IRQ_count = 7; break;
8730         case 0x00: prg8_89(machine(), data); break;
8731         case 0x01: prg8_ab(machine(), data); break;
8732         case 0x02: m_IRQ_enable = 0; m_IRQ_count = 0; break;
8733         case 0x03: m_IRQ_enable = 1; m_IRQ_count = 7; break;
88538734         }
88548735         break;
88558736      default:
r18063r18064
88838764   prg16_cdef(machine, map221_helper2 | ((reg1 & 0x70) >> 1));
88848765}
88858766
8886static WRITE8_HANDLER( n625092_w )
8767WRITE8_MEMBER(nes_state::n625092_w)
88878768{
8888   nes_state *state = space.machine().driver_data<nes_state>();
88898769   LOG_MMC(("n625092_w, offset: %04x, data: %02x\n", offset, data));
88908770
88918771   if (offset < 0x4000)
88928772   {
8893      set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8773      set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
88948774      offset = (offset >> 1) & 0xff;
88958775
8896      if (state->m_mmc_latch1 != offset)
8776      if (m_mmc_latch1 != offset)
88978777      {
8898         state->m_mmc_latch1 = offset;
8899         n625092_set_prg(space.machine(), state->m_mmc_latch1, state->m_mmc_latch2);
8778         m_mmc_latch1 = offset;
8779         n625092_set_prg(machine(), m_mmc_latch1, m_mmc_latch2);
89008780      }
89018781   }
89028782   else
89038783   {
89048784      offset &= 0x07;
89058785
8906      if (state->m_mmc_latch2 != offset)
8786      if (m_mmc_latch2 != offset)
89078787      {
8908         state->m_mmc_latch2 = offset;
8909         n625092_set_prg(space.machine(), state->m_mmc_latch1, state->m_mmc_latch2);
8788         m_mmc_latch2 = offset;
8789         n625092_set_prg(machine(), m_mmc_latch1, m_mmc_latch2);
89108790      }
89118791   }
89128792}
r18063r18064
89418821   }
89428822}
89438823
8944static WRITE8_HANDLER( sc127_w )
8824WRITE8_MEMBER(nes_state::sc127_w)
89458825{
8946   nes_state *state = space.machine().driver_data<nes_state>();
89478826   LOG_MMC(("sc127_w, offset: %04x, data: %02x\n", offset, data));
89488827
89498828   switch (offset)
89508829   {
89518830      case 0x0000:
8952         prg8_89(space.machine(), data);
8831         prg8_89(machine(), data);
89538832         break;
89548833      case 0x0001:
8955         prg8_ab(space.machine(), data);
8834         prg8_ab(machine(), data);
89568835         break;
89578836      case 0x0002:
8958         //      state->m_mmc_prg_bank[offset & 0x02] = data;
8959         prg8_cd(space.machine(), data);
8837         //      m_mmc_prg_bank[offset & 0x02] = data;
8838         prg8_cd(machine(), data);
89608839         break;
89618840      case 0x1000:
89628841      case 0x1001:
r18063r18064
89668845      case 0x1005:
89678846      case 0x1006:
89688847      case 0x1007:
8969         //      state->m_mmc_vrom_bank[offset & 0x07] = data;
8970         chr1_x(space.machine(), offset & 0x07, data, CHRROM);
8848         //      m_mmc_vrom_bank[offset & 0x07] = data;
8849         chr1_x(machine(), offset & 0x07, data, CHRROM);
89718850         break;
89728851      case 0x4002:
8973         state->m_IRQ_enable = 0;
8852         m_IRQ_enable = 0;
89748853         break;
89758854      case 0x4003:
8976         state->m_IRQ_enable = 1;
8855         m_IRQ_enable = 1;
89778856         break;
89788857      case 0x4005:
8979         state->m_IRQ_count = data;
8858         m_IRQ_count = data;
89808859         break;
89818860      case 0x5001:
8982         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8861         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
89838862         break;
89848863   }
89858864}
r18063r18064
89978876
89988877 *************************************************************/
89998878
9000static WRITE8_HANDLER( smb2j_w )
8879WRITE8_MEMBER(nes_state::smb2j_w)
90018880{
9002   nes_state *state = space.machine().driver_data<nes_state>();
90038881   int bank = (((offset >> 8) & 0x03) * 0x20) + (offset & 0x1f);
90048882
90058883   LOG_MMC(("smb2j_w, offset: %04x, data: %02x\n", offset, data));
90068884
9007   set_nt_mirroring(space.machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8885   set_nt_mirroring(machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
90088886
90098887   if (offset & 0x0800)
90108888   {
90118889      if (offset & 0x1000)
90128890      {
9013         if (bank * 2 >= state->m_prg_chunks)
8891         if (bank * 2 >= m_prg_chunks)
90148892         {
9015            state->membank("bank3")->set_base(state->m_wram);
9016            state->membank("bank4")->set_base(state->m_wram);
8893            membank("bank3")->set_base(m_wram);
8894            membank("bank4")->set_base(m_wram);
90178895         }
90188896         else
90198897         {
90208898            LOG_MMC(("smb2j_w, selecting upper 16KB bank of #%02x\n", bank));
9021            prg16_cdef(space.machine(), 2 * bank + 1);
8899            prg16_cdef(machine(), 2 * bank + 1);
90228900         }
90238901      }
90248902      else
90258903      {
9026         if (bank * 2 >= state->m_prg_chunks)
8904         if (bank * 2 >= m_prg_chunks)
90278905         {
9028            state->membank("bank1")->set_base(state->m_wram);
9029            state->membank("bank2")->set_base(state->m_wram);
8906            membank("bank1")->set_base(m_wram);
8907            membank("bank2")->set_base(m_wram);
90308908         }
90318909         else
90328910         {
90338911            LOG_MMC(("smb2j_w, selecting lower 16KB bank of #%02x\n", bank));
9034            prg16_89ab(space.machine(), 2 * bank);
8912            prg16_89ab(machine(), 2 * bank);
90358913         }
90368914      }
90378915   }
90388916   else
90398917   {
9040      if (bank * 2 >= state->m_prg_chunks)
8918      if (bank * 2 >= m_prg_chunks)
90418919      {
9042         state->membank("bank1")->set_base(state->m_wram);
9043         state->membank("bank2")->set_base(state->m_wram);
9044         state->membank("bank3")->set_base(state->m_wram);
9045         state->membank("bank4")->set_base(state->m_wram);
8920         membank("bank1")->set_base(m_wram);
8921         membank("bank2")->set_base(m_wram);
8922         membank("bank3")->set_base(m_wram);
8923         membank("bank4")->set_base(m_wram);
90468924      }
90478925      else
90488926      {
90498927         LOG_MMC(("smb2j_w, selecting 32KB bank #%02x\n", bank));
9050         prg32(space.machine(), bank);
8928         prg32(machine(), bank);
90518929      }
90528930   }
90538931}
r18063r18064
90858963   }
90868964}
90878965
9088static WRITE8_HANDLER( smb2jb_l_w )
8966WRITE8_MEMBER(nes_state::smb2jb_l_w)
90898967{
9090   nes_state *state = space.machine().driver_data<nes_state>();
90918968   UINT8 prg;
90928969   LOG_MMC(("smb2jb_l_w, offset: %04x, data: %02x\n", offset, data));
90938970   offset += 0x100;
r18063r18064
90968973   {
90978974      case 0x020:
90988975         prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2);
9099         prg8_cd(space.machine(), prg);
8976         prg8_cd(machine(), prg);
91008977         break;
91018978      case 0x120:
9102         state->m_IRQ_enable = data & 0x01;
8979         m_IRQ_enable = data & 0x01;
91038980         break;
91048981   }
91058982}
91068983
91078984/* This goes to 0x4020-0x403f */
9108WRITE8_HANDLER( smb2jb_extra_w )
8985WRITE8_MEMBER(nes_state::smb2jb_extra_w)
91098986{
91108987   UINT8 prg;
91118988   LOG_MMC(("smb2jb_extra_w, offset: %04x, data: %02x\n", offset, data));
91128989
91138990   prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2);
9114   prg8_cd(space.machine(), prg);
8991   prg8_cd(machine(), prg);
91158992}
91168993
91178994/*************************************************************
r18063r18064
91349011   chr2_6(machine, chr_base | (state->m_mmc_vrom_bank[2] & chr_mask), chr_source);
91359012}
91369013
9137static WRITE8_HANDLER( unl_sf3_w )
9014WRITE8_MEMBER(nes_state::unl_sf3_w)
91389015{
9139   nes_state *state = space.machine().driver_data<nes_state>();
91409016   UINT8 mmc_helper, cmd;
91419017   LOG_MMC(("unl_sf3_w, offset: %04x, data: %02x\n", offset, data));
91429018
91439019   switch (offset & 0x6001)
91449020   {
91459021      case 0x0000:
9146         mmc_helper = state->m_mmc3_latch ^ data;
9147         state->m_mmc3_latch = data;
9022         mmc_helper = m_mmc3_latch ^ data;
9023         m_mmc3_latch = data;
91489024
91499025         /* Has PRG Mode changed? */
91509026         if (mmc_helper & 0x40)
9151            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
9027            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
91529028
91539029         /* Has CHR Mode changed? */
91549030         if (mmc_helper & 0x80)
9155            unl_sf3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
9031            unl_sf3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
91569032         break;
91579033
91589034      case 0x0001:
9159         cmd = state->m_mmc3_latch & 0x0f;
9035         cmd = m_mmc3_latch & 0x0f;
91609036         switch (cmd)
91619037         {
91629038         case 0: case 2: case 4:
9163            state->m_mmc_vrom_bank[cmd >> 1] = data;
9164            unl_sf3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
9039            m_mmc_vrom_bank[cmd >> 1] = data;
9040            unl_sf3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
91659041            break;
91669042         case 6:
91679043         case 7:
9168            state->m_mmc_prg_bank[cmd - 6] = data;
9169            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
9044            m_mmc_prg_bank[cmd - 6] = data;
9045            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
91709046            break;
91719047         }
91729048         break;
r18063r18064
91929068
91939069 *************************************************************/
91949070
9195static WRITE8_HANDLER( unl_xzy_l_w )
9071WRITE8_MEMBER(nes_state::unl_xzy_l_w)
91969072{
91979073   LOG_MMC(("unl_xzy_l_w, offset: %04x, data: %02x\n", offset, data));
91989074
91999075   switch (offset)
92009076   {
92019077      case 0x1ef1:   /* 0x5ff1 */
9202         prg32(space.machine(), data >> 1);
9078         prg32(machine(), data >> 1);
92039079         break;
92049080      case 0x1ef2:   /* 0x5ff2 */
9205         chr8(space.machine(), data, CHRROM);
9081         chr8(machine(), data, CHRROM);
92069082         break;
92079083   }
92089084}
r18063r18064
92239099   prg16_89ab(machine, state->m_mmc_latch1 >> 1);
92249100}
92259101
9226static WRITE8_HANDLER( unl_racmate_w )
9102WRITE8_MEMBER(nes_state::unl_racmate_w)
92279103{
9228   nes_state *state = space.machine().driver_data<nes_state>();
92299104   LOG_MMC(("unl_racmate_w offset: %04x, data: %02x\n", offset, data));
92309105
92319106   if (offset == 0x3000)
92329107   {
9233      state->m_mmc_latch1 = data;
9234      racmate_update_banks(space.machine());
9108      m_mmc_latch1 = data;
9109      racmate_update_banks(machine());
92359110   }
92369111}
92379112
r18063r18064
92489123
92499124 *************************************************************/
92509125
9251static WRITE8_HANDLER( unl_fs304_l_w )
9126WRITE8_MEMBER(nes_state::unl_fs304_l_w)
92529127{
9253   nes_state *state = space.machine().driver_data<nes_state>();
92549128   LOG_MMC(("unl_fs304_l_w, offset: %04x, data: %02x\n", offset, data));
92559129   int bank;
92569130   offset += 0x100;
92579131
92589132   if (offset >= 0x1000)
92599133   {
9260      state->m_mmc_reg[(offset >> 8) & 3] = data;
9261      bank = ((state->m_mmc_reg[2] & 0x0f) << 4) | BIT(state->m_mmc_reg[1], 1) | (state->m_mmc_reg[0] & 0x0e);
9262      prg32(space.machine(), bank);
9263      chr8(space.machine(), 0, CHRRAM);
9134      m_mmc_reg[(offset >> 8) & 3] = data;
9135      bank = ((m_mmc_reg[2] & 0x0f) << 4) | BIT(m_mmc_reg[1], 1) | (m_mmc_reg[0] & 0x0e);
9136      prg32(machine(), bank);
9137      chr8(machine(), 0, CHRRAM);
92649138   }
92659139}
92669140
r18063r18064
92869160
92879161 *************************************************************/
92889162
9289static WRITE8_HANDLER( btl_smb11_w )
9163WRITE8_MEMBER(nes_state::btl_smb11_w)
92909164{
92919165   LOG_MMC(("btl_smb11_w, offset: %04x, data: %02x\n", offset, data));
92929166
r18063r18064
93069180 *************************************************************/
93079181
93089182// is the code fine for ai senshi nicol?!?
9309static WRITE8_HANDLER( btl_mariobaby_w )
9183WRITE8_MEMBER(nes_state::btl_mariobaby_w)
93109184{
9311   nes_state *state = space.machine().driver_data<nes_state>();
93129185   LOG_MMC(("btl_mariobaby_w, offset: %04x, data: %02x\n", offset, data));
93139186
93149187   if (offset >= 0x7000)
r18063r18064
93169189      switch (offset & 0x03)
93179190      {
93189191         case 0x00:
9319            prg8_67(space.machine(), data);
9192            prg8_67(machine(), data);
93209193            break;
93219194         case 0x01:
9322            set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9195            set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
93239196            break;
93249197         case 0x02:
93259198            /* Check if IRQ is being enabled */
9326            if (!state->m_IRQ_enable && (data & 0x02))
9199            if (!m_IRQ_enable && (data & 0x02))
93279200            {
9328               state->m_IRQ_enable = 1;
9329               state->m_irq_timer->adjust(downcast<cpu_device *>(state->m_maincpu)->cycles_to_attotime(24576));
9201               m_IRQ_enable = 1;
9202               m_irq_timer->adjust(downcast<cpu_device *>(m_maincpu)->cycles_to_attotime(24576));
93309203            }
93319204            if (!(data & 0x02))
93329205            {
9333               state->m_IRQ_enable = 0;
9334               state->m_irq_timer->adjust(attotime::never);
9206               m_IRQ_enable = 0;
9207               m_irq_timer->adjust(attotime::never);
93359208            }
93369209            break;
93379210      }
r18063r18064
93679240   }
93689241}
93699242
9370static WRITE8_HANDLER( btl_smb2a_w )
9243WRITE8_MEMBER(nes_state::btl_smb2a_w)
93719244{
9372   nes_state *state = space.machine().driver_data<nes_state>();
93739245   LOG_MMC(("btl_smb2a_w, offset: %04x, data: %02x\n", offset, data));
93749246
93759247   switch (offset & 0x6000)
93769248   {
93779249      case 0x0000:
9378         state->m_IRQ_enable = 0;
9379         state->m_IRQ_count = 0;
9250         m_IRQ_enable = 0;
9251         m_IRQ_count = 0;
93809252         break;
93819253      case 0x2000:
9382         state->m_IRQ_enable = 1;
9254         m_IRQ_enable = 1;
93839255         break;
93849256      case 0x6000:
9385         prg8_cd(space.machine(), data);
9257         prg8_cd(machine(), data);
93869258         break;
93879259   }
93889260}
r18063r18064
93999271
94009272 *************************************************************/
94019273
9402static WRITE8_HANDLER( whirl2706_w )
9274WRITE8_MEMBER(nes_state::whirl2706_w)
94039275{
94049276   LOG_MMC(("whirl2706_w, offset: %04x, data: %02x\n", offset, data));
9405   prg8_67(space.machine(), data);
9277   prg8_67(machine(), data);
94069278}
94079279
94089280/*************************************************************
r18063r18064
94179289
94189290 *************************************************************/
94199291
9420static WRITE8_HANDLER( btl_tobi_l_w )
9292WRITE8_MEMBER(nes_state::btl_tobi_l_w)
94219293{
94229294   LOG_MMC(("btl_tobi_l_w, offset: %04x, data: %02x\n", offset, data));
94239295   offset += 0x100;
94249296
94259297   if ((offset & 0x43c0) == 0x41c0)
9426      prg8_67(space.machine(), data & 0x07);
9298      prg8_67(machine(), data & 0x07);
94279299}
94289300
94299301/*************************************************************
r18063r18064
94549326   }
94559327}
94569328
9457static WRITE8_HANDLER( btl_smb3_w )
9329WRITE8_MEMBER(nes_state::btl_smb3_w)
94589330{
9459   nes_state *state = space.machine().driver_data<nes_state>();
94609331   LOG_MMC(("btl_smb3_w, offset: %04x, data: %02x\n", offset, data));
94619332   switch (offset & 0x0f)
94629333   {
94639334      case 0x00:
94649335      case 0x02:
9465         chr1_x(space.machine(), offset & 0x07, data & 0xfe, CHRROM);
9336         chr1_x(machine(), offset & 0x07, data & 0xfe, CHRROM);
94669337         break;
94679338      case 0x01:
94689339      case 0x03:
9469         chr1_x(space.machine(), offset & 0x07, data | 0x01, CHRROM);
9340         chr1_x(machine(), offset & 0x07, data | 0x01, CHRROM);
94709341         break;
94719342      case 0x04: case 0x05:
94729343      case 0x06: case 0x07:
9473         chr1_x(space.machine(), offset & 0x07, data, CHRROM);
9344         chr1_x(machine(), offset & 0x07, data, CHRROM);
94749345         break;
94759346      case 0x08:
9476         prg8_89(space.machine(), data | 0x10);
9347         prg8_89(machine(), data | 0x10);
94779348         break;
94789349      case 0x09:
9479         prg8_ab(space.machine(), data);
9350         prg8_ab(machine(), data);
94809351         break;
94819352      case 0x0a:
9482         prg8_cd(space.machine(), data);
9353         prg8_cd(machine(), data);
94839354         break;
94849355      case 0x0b:
9485         prg8_ef(space.machine(), data | 0x10);
9356         prg8_ef(machine(), data | 0x10);
94869357         break;
94879358      case 0x0c:
9488         set_nt_mirroring(space.machine(), BIT(data, 0) ?  PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9359         set_nt_mirroring(machine(), BIT(data, 0) ?  PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
94899360         break;
94909361      case 0x0d:
9491         state->m_IRQ_count = 0;
9492         state->m_IRQ_enable = 0;
9362         m_IRQ_count = 0;
9363         m_IRQ_enable = 0;
94939364         break;
94949365      case 0x0e:
9495         state->m_IRQ_count = (state->m_IRQ_count & 0xff00) | data;
9366         m_IRQ_count = (m_IRQ_count & 0xff00) | data;
94969367         break;
94979368      case 0x0f:
9498         state->m_IRQ_count = (state->m_IRQ_count & 0x00ff) | (data << 8);
9499         state->m_IRQ_enable = 1;
9369         m_IRQ_count = (m_IRQ_count & 0x00ff) | (data << 8);
9370         m_IRQ_enable = 1;
95009371         break;
95019372   }
95029373}
r18063r18064
95299400   }
95309401}
95319402
9532static WRITE8_HANDLER( btl_dn_w )
9403WRITE8_MEMBER(nes_state::btl_dn_w)
95339404{
9534   nes_state *state = space.machine().driver_data<nes_state>();
95359405   UINT8 bank;
95369406   LOG_MMC(("btl_dn_w, offset: %04x, data: %02x\n", offset, data));
95379407
95389408   switch (offset & 0x7003)
95399409   {
95409410      case 0x0000:
9541         prg8_89(space.machine(), data);
9411         prg8_89(machine(), data);
95429412         break;
95439413      case 0x1000:
9544         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9414         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
95459415         break;
95469416      case 0x2000:
9547         prg8_ab(space.machine(), data);
9417         prg8_ab(machine(), data);
95489418         break;
95499419      case 0x3000:
95509420      case 0x3002:
r18063r18064
95559425      case 0x6000:
95569426      case 0x6002:
95579427         bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0002) >> 3);
9558         chr1_x(space.machine(), bank, data, CHRROM);
9428         chr1_x(machine(), bank, data, CHRROM);
95599429         break;
95609430      case 0x7000:
9561         state->m_IRQ_count = data;
9431         m_IRQ_count = data;
95629432         break;
95639433   }
95649434}
r18063r18064
95759445
95769446 *************************************************************/
95779447
9578static WRITE8_HANDLER( btl_pika_y2k_w )
9448WRITE8_MEMBER(nes_state::btl_pika_y2k_w)
95799449{
9580   nes_state *state = space.machine().driver_data<nes_state>();
95819450   LOG_MMC(("btl_pika_y2k_w, offset: %04x, data: %02x\n", offset, data));
95829451
95839452   switch (offset & 0x6001)
95849453   {
95859454      case 0x2001:
9586         state->m_mmc_latch2 = data;
9455         m_mmc_latch2 = data;
95879456         break;
95889457
95899458      case 0x2000:
9590         state->m_mmc_reg[0] = 0;
9459         m_mmc_reg[0] = 0;
95919460      default:
95929461         txrom_w(space, offset, data, mem_mask);
95939462         break;
r18063r18064
95959464}
95969465
95979466// strange WRAM usage: it is protected at start, and gets unprotected after the first write to 0xa000
9598static WRITE8_HANDLER( btl_pika_y2k_m_w )
9467WRITE8_MEMBER(nes_state::btl_pika_y2k_m_w)
95999468{
9600   nes_state *state = space.machine().driver_data<nes_state>();
96019469   LOG_MMC(("btl_pika_y2k_m_w, offset: %04x, data: %02x\n", offset, data));
96029470
9603   state->m_wram[offset] = data;
9471   m_wram[offset] = data;
96049472}
96059473
9606static READ8_HANDLER( btl_pika_y2k_m_r )
9474READ8_MEMBER(nes_state::btl_pika_y2k_m_r)
96079475{
9608   nes_state *state = space.machine().driver_data<nes_state>();
96099476   LOG_MMC(("btl_pika_y2k_m_r, offset: %04x\n", offset));
96109477
9611   return   state->m_wram[offset] ^ (state->m_mmc_latch2 & state->m_mmc_reg[0]);
9478   return   m_wram[offset] ^ (m_mmc_latch2 & m_mmc_reg[0]);
96129479}
96139480
96149481/*************************************************************
r18063r18064
97149581   }
97159582}
97169583
9717static WRITE8_HANDLER( fk23c_l_w )
9584WRITE8_MEMBER(nes_state::fk23c_l_w)
97189585{
9719   nes_state *state = space.machine().driver_data<nes_state>();
97209586   LOG_MMC(("fk23c_l_w, offset: %04x, data: %02x\n", offset, data));
97219587   offset += 0x100;
97229588
97239589   if (offset >= 0x1000)
97249590   {
9725      if (offset & (1 << 4))   // here it should be (4 + state->m_mmc_dipsetting)
9591      if (offset & (1 << 4))   // here it should be (4 + m_mmc_dipsetting)
97269592      {
9727         state->m_mmc_reg[offset & 0x03] = data;
9593         m_mmc_reg[offset & 0x03] = data;
97289594
9729         fk23c_set_prg(space.machine());
9730         fk23c_set_chr(space.machine());
9595         fk23c_set_prg(machine());
9596         fk23c_set_chr(machine());
97319597      }
97329598   }
97339599}
97349600
9735static WRITE8_HANDLER( fk23c_w )
9601WRITE8_MEMBER(nes_state::fk23c_w)
97369602{
9737   nes_state *state = space.machine().driver_data<nes_state>();
97389603   LOG_MMC(("fk23c_w, offset: %04x, data: %02x\n", offset, data));
97399604
9740   if (state->m_mmc_reg[0] & 0x40)
9605   if (m_mmc_reg[0] & 0x40)
97419606   {
9742      if (state->m_mmc_reg[0] & 0x30)
9743         state->m_mmc_cmd1 = 0;
9607      if (m_mmc_reg[0] & 0x30)
9608         m_mmc_cmd1 = 0;
97449609      else
97459610      {
9746         state->m_mmc_cmd1 = data & 0x03;
9747         fk23c_set_chr(space.machine());
9611         m_mmc_cmd1 = data & 0x03;
9612         fk23c_set_chr(machine());
97489613      }
97499614   }
97509615   else
r18063r18064
97529617      switch (offset & 0x6001)
97539618      {
97549619         case 0x0001:
9755            if ((state->m_mmc_reg[3] & 0x02) && (state->m_mmc3_latch & 0x08))
9620            if ((m_mmc_reg[3] & 0x02) && (m_mmc3_latch & 0x08))
97569621            {
9757               state->m_mmc_reg[4 | (state->m_mmc3_latch & 0x03)] = data;
9758               fk23c_set_prg(space.machine());
9759               fk23c_set_chr(space.machine());
9622               m_mmc_reg[4 | (m_mmc3_latch & 0x03)] = data;
9623               fk23c_set_prg(machine());
9624               fk23c_set_chr(machine());
97609625            }
97619626            else
97629627               txrom_w(space, offset, data, mem_mask);
97639628            break;
97649629
97659630         case 0x2000:
9766            set_nt_mirroring(space.machine(), data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9631            set_nt_mirroring(machine(), data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
97679632            break;
97689633
97699634         default:
r18063r18064
98049669      prg16_cdef(machine, helper2);
98059670}
98069671
9807static WRITE8_HANDLER( bmc_64in1nr_l_w )
9672WRITE8_MEMBER(nes_state::bmc_64in1nr_l_w)
98089673{
9809   nes_state *state = space.machine().driver_data<nes_state>();
98109674   LOG_MMC(("bmc_64in1nr_l_w offset: %04x, data: %02x\n", offset, data));
98119675   offset += 0x100;
98129676
r18063r18064
98169680      case 0x1001:
98179681      case 0x1002:
98189682      case 0x1003:
9819         state->m_mmc_reg[offset & 0x03] = data;
9820         bmc_64in1nr_set_prg(space.machine());
9821         chr8(space.machine(), ((state->m_mmc_reg[0] >> 1) & 0x03) | (state->m_mmc_reg[2] << 2), CHRROM);
9683         m_mmc_reg[offset & 0x03] = data;
9684         bmc_64in1nr_set_prg(machine());
9685         chr8(machine(), ((m_mmc_reg[0] >> 1) & 0x03) | (m_mmc_reg[2] << 2), CHRROM);
98229686         break;
98239687   }
98249688   if (offset == 0x1000)   /* reg[0] also sets mirroring */
9825      set_nt_mirroring(space.machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9689      set_nt_mirroring(machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
98269690}
98279691
9828static WRITE8_HANDLER( bmc_64in1nr_w )
9692WRITE8_MEMBER(nes_state::bmc_64in1nr_w)
98299693{
9830   nes_state *state = space.machine().driver_data<nes_state>();
98319694   LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data));
98329695
9833   state->m_mmc_reg[3] = data;   // reg[3] is currently unused?!?
9696   m_mmc_reg[3] = data;   // reg[3] is currently unused?!?
98349697}
98359698
98369699/*************************************************************
r18063r18064
98439706
98449707 *************************************************************/
98459708
9846static WRITE8_HANDLER( bmc_190in1_w )
9709WRITE8_MEMBER(nes_state::bmc_190in1_w)
98479710{
98489711   LOG_MMC(("bmc_190in1_w offset: %04x, data: %02x\n", offset, data));
98499712
9850   set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9713   set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
98519714   offset >>= 2;
9852   prg16_89ab(space.machine(), offset);
9853   prg16_cdef(space.machine(), offset);
9854   chr8(space.machine(), offset, CHRROM);
9715   prg16_89ab(machine(), offset);
9716   prg16_cdef(machine(), offset);
9717   chr8(machine(), offset, CHRROM);
98559718}
98569719
98579720/*************************************************************
r18063r18064
98649727
98659728 *************************************************************/
98669729
9867static WRITE8_HANDLER( bmc_a65as_w )
9730WRITE8_MEMBER(nes_state::bmc_a65as_w)
98689731{
98699732   UINT8 helper = (data & 0x30) >> 1;
98709733   LOG_MMC(("bmc_a65as_w offset: %04x, data: %02x\n", offset, data));
98719734
98729735   if (data & 0x80)
9873      set_nt_mirroring(space.machine(), BIT(data, 5) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
9736      set_nt_mirroring(machine(), BIT(data, 5) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
98749737   else
9875      set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9738      set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
98769739
98779740   if (data & 0x40)
9878      prg32(space.machine(), data >> 1);
9741      prg32(machine(), data >> 1);
98799742   else
98809743   {
9881      prg16_89ab(space.machine(), helper | (data & 0x07));
9882      prg16_cdef(space.machine(), helper | 0x07);
9744      prg16_89ab(machine(), helper | (data & 0x07));
9745      prg16_cdef(machine(), helper | 0x07);
98839746   }
98849747}
98859748
r18063r18064
98949757
98959758 *************************************************************/
98969759
9897static WRITE8_HANDLER( bmc_gs2004_w )
9760WRITE8_MEMBER(nes_state::bmc_gs2004_w)
98989761{
98999762   LOG_MMC(("bmc_gs2004_w offset: %04x, data: %02x\n", offset, data));
99009763
9901   prg32(space.machine(), data);
9764   prg32(machine(), data);
99029765}
99039766
99049767/*************************************************************
r18063r18064
99129775
99139776 *************************************************************/
99149777
9915static WRITE8_HANDLER( bmc_gs2013_w )
9778WRITE8_MEMBER(nes_state::bmc_gs2013_w)
99169779{
99179780   LOG_MMC(("bmc_gs2013_w offset: %04x, data: %02x\n", offset, data));
99189781
99199782   if (data & 0x08)
9920      prg32(space.machine(), data & 0x09);
9783      prg32(machine(), data & 0x09);
99219784   else
9922      prg32(space.machine(), data & 0x07);
9785      prg32(machine(), data & 0x07);
99239786}
99249787
99259788/*************************************************************
r18063r18064
99529815   chr1_x(machine, start, chr_base | bank, chr);
99539816}
99549817
9955static WRITE8_HANDLER( bmc_s24in1sc03_l_w )
9818WRITE8_MEMBER(nes_state::bmc_s24in1sc03_l_w)
99569819{
9957   nes_state *state = space.machine().driver_data<nes_state>();
99589820   LOG_MMC(("bmc_s24in1sc03_l_w offset: %04x, data: %02x\n", offset, data));
99599821   offset += 0x100;
99609822
99619823   if (offset == 0x1ff0)
99629824   {
9963      state->m_mmc_reg[0] = data;
9964      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
9965      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
9825      m_mmc_reg[0] = data;
9826      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
9827      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
99669828   }
99679829
99689830   if (offset == 0x1ff1)
99699831   {
9970      state->m_mmc_reg[1] = data;
9971      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
9832      m_mmc_reg[1] = data;
9833      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
99729834   }
99739835
99749836   if (offset == 0x1ff2)
99759837   {
9976      state->m_mmc_reg[2] = data;
9977      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
9838      m_mmc_reg[2] = data;
9839      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
99789840   }
99799841}
99809842
r18063r18064
99889850
99899851 *************************************************************/
99909852
9991static WRITE8_HANDLER( bmc_t262_w )
9853WRITE8_MEMBER(nes_state::bmc_t262_w)
99929854{
9993   nes_state *state = space.machine().driver_data<nes_state>();
99949855   UINT8 mmc_helper;
99959856   LOG_MMC(("bmc_t262_w offset: %04x, data: %02x\n", offset, data));
99969857
9997   if (state->m_mmc_latch2 || offset == 0)
9858   if (m_mmc_latch2 || offset == 0)
99989859   {
9999      state->m_mmc_latch1 = (state->m_mmc_latch1 & 0x38) | (data & 0x07);
10000      prg16_89ab(space.machine(), state->m_mmc_latch1);
9860      m_mmc_latch1 = (m_mmc_latch1 & 0x38) | (data & 0x07);
9861      prg16_89ab(machine(), m_mmc_latch1);
100019862   }
100029863   else
100039864   {
10004      state->m_mmc_latch2 = 1;
10005      set_nt_mirroring(space.machine(), BIT(data, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9865      m_mmc_latch2 = 1;
9866      set_nt_mirroring(machine(), BIT(data, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
100069867      mmc_helper = ((offset >> 3) & 0x20) | ((offset >> 2) & 0x18);
10007      state->m_mmc_latch1 = mmc_helper | (state->m_mmc_latch1 & 0x07);
10008      prg16_89ab(space.machine(), state->m_mmc_latch1);
10009      prg16_cdef(space.machine(), mmc_helper | 0x07);
9868      m_mmc_latch1 = mmc_helper | (m_mmc_latch1 & 0x07);
9869      prg16_89ab(machine(), m_mmc_latch1);
9870      prg16_cdef(machine(), mmc_helper | 0x07);
100109871   }
100119872}
100129873
r18063r18064
100219882
100229883 *************************************************************/
100239884
10024static WRITE8_HANDLER( bmc_ws_m_w )
9885WRITE8_MEMBER(nes_state::bmc_ws_m_w)
100259886{
10026   nes_state *state = space.machine().driver_data<nes_state>();
100279887   UINT8 mmc_helper;
100289888   LOG_MMC(("bmc_ws_m_w offset: %04x, data: %02x\n", offset, data));
100299889
r18063r18064
100329892      switch (offset & 0x01)
100339893      {
100349894         case 0:
10035            if (!state->m_mmc_latch1)
9895            if (!m_mmc_latch1)
100369896            {
10037               state->m_mmc_latch1 = data & 0x20;
10038               set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9897               m_mmc_latch1 = data & 0x20;
9898               set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
100399899               mmc_helper = (~data & 0x08) >> 3;
10040               prg16_89ab(space.machine(), data & ~mmc_helper);
10041               prg16_cdef(space.machine(), data |  mmc_helper);
9900               prg16_89ab(machine(), data & ~mmc_helper);
9901               prg16_cdef(machine(), data |  mmc_helper);
100429902            }
100439903            break;
100449904         case 1:
10045            if (!state->m_mmc_latch1)
9905            if (!m_mmc_latch1)
100469906            {
10047               chr8(space.machine(), data, CHRROM);
9907               chr8(machine(), data, CHRROM);
100489908            }
100499909            break;
100509910      }
r18063r18064
100689928 *************************************************************/
100699929
100709930// Are this correct or should they work the same?
10071static WRITE8_HANDLER( novel1_w )
9931WRITE8_MEMBER(nes_state::novel1_w)
100729932{
100739933   LOG_MMC(("novel1_w, offset: %04x, data: %02x\n", offset, data));
100749934
10075   prg32(space.machine(), offset & 0x03);
10076   chr8(space.machine(), offset & 0x07, CHRROM);
9935   prg32(machine(), offset & 0x03);
9936   chr8(machine(), offset & 0x07, CHRROM);
100779937}
100789938
10079static WRITE8_HANDLER( novel2_w )
9939WRITE8_MEMBER(nes_state::novel2_w)
100809940{
100819941   LOG_MMC(("novel2_w, offset: %04x, data: %02x\n", offset, data));
100829942
10083   prg32(space.machine(), offset >> 1);
10084   chr8(space.machine(), offset >> 3, CHRROM);
9943   prg32(machine(), offset >> 1);
9944   chr8(machine(), offset >> 3, CHRROM);
100859945}
100869946
100879947/*************************************************************
r18063r18064
100979957
100989958 *************************************************************/
100999959
10100static WRITE8_HANDLER( bmc_gka_w )
9960WRITE8_MEMBER(nes_state::bmc_gka_w)
101019961{
10102   nes_state *state = space.machine().driver_data<nes_state>();
101039962   LOG_MMC(("bmc_gka_w, offset: %04x, data: %02x\n", offset, data));
101049963
101059964   if (offset & 0x0800)
10106      state->m_mmc_latch2 = data;
9965      m_mmc_latch2 = data;
101079966   else
10108      state->m_mmc_latch1 = data;
9967      m_mmc_latch1 = data;
101099968
10110   if (state->m_mmc_latch2 & 0x80)
10111      prg32(space.machine(), 2 | (state->m_mmc_latch2 >> 6));
9969   if (m_mmc_latch2 & 0x80)
9970      prg32(machine(), 2 | (m_mmc_latch2 >> 6));
101129971   else
101139972   {
10114      prg16_89ab(space.machine(), (state->m_mmc_latch2 >> 5) & 0x03);
10115      prg16_cdef(space.machine(), (state->m_mmc_latch2 >> 5) & 0x03);
9973      prg16_89ab(machine(), (m_mmc_latch2 >> 5) & 0x03);
9974      prg16_cdef(machine(), (m_mmc_latch2 >> 5) & 0x03);
101169975   }
101179976
10118   set_nt_mirroring(space.machine(), (state->m_mmc_latch2 & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9977   set_nt_mirroring(machine(), (m_mmc_latch2 & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
101199978
10120   chr8(space.machine(), (state->m_mmc_latch1 & 0x03) | (state->m_mmc_latch2 & 0x07) | ((state->m_mmc_latch2 & 0x10) >> 1), CHRROM);
9979   chr8(machine(), (m_mmc_latch1 & 0x03) | (m_mmc_latch2 & 0x07) | ((m_mmc_latch2 & 0x10) >> 1), CHRROM);
101219980}
101229981
101239982
r18063r18064
101349993
101359994 *************************************************************/
101369995
10137static WRITE8_HANDLER( sng32_w )
9996WRITE8_MEMBER(nes_state::sng32_w)
101389997{
101399998   LOG_MMC(("sng32_w, offset: %04x, data: %02x\n", offset, data));
10140   prg32(space.machine(), data);
9999   prg32(machine(), data);
1014110000}
1014210001
1014310002/*************************************************************
r18063r18064
1015310012
1015410013 *************************************************************/
1015510014
10156static WRITE8_HANDLER( bmc_gkb_w )
10015WRITE8_MEMBER(nes_state::bmc_gkb_w)
1015710016{
10158   nes_state *state = space.machine().driver_data<nes_state>();
1015910017   UINT8 bank = (offset & 0x40) ? 0 : 1;
1016010018   LOG_MMC(("bmc_gkb_w, offset: %04x, data: %02x\n", offset, data));
1016110019
10162   prg16_89ab(space.machine(), offset & ~bank);
10163   prg16_cdef(space.machine(), offset | bank);
10164   chr8(space.machine(), offset >> 3, state->m_mmc_chr_source);
10165   set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10020   prg16_89ab(machine(), offset & ~bank);
10021   prg16_cdef(machine(), offset | bank);
10022   chr8(machine(), offset >> 3, m_mmc_chr_source);
10023   set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1016610024}
1016710025
1016810026/*************************************************************
r18063r18064
1017810036
1017910037 *************************************************************/
1018010038
10181static WRITE8_HANDLER( bmc_super700in1_w )
10039WRITE8_MEMBER(nes_state::bmc_super700in1_w)
1018210040{
1018310041   LOG_MMC(("bmc_super700in1_w, offset :%04x, data: %02x\n", offset, data));
1018410042
10185   chr8(space.machine(), ((offset & 0x1f) << 2) | (data & 0x03), CHRROM);
10043   chr8(machine(), ((offset & 0x1f) << 2) | (data & 0x03), CHRROM);
1018610044
1018710045   if (offset & 0x20)
1018810046   {
10189      prg16_89ab(space.machine(), (offset & 0x40) | ((offset >> 8) & 0x3f));
10190      prg16_cdef(space.machine(), (offset & 0x40) | ((offset >> 8) & 0x3f));
10047      prg16_89ab(machine(), (offset & 0x40) | ((offset >> 8) & 0x3f));
10048      prg16_cdef(machine(), (offset & 0x40) | ((offset >> 8) & 0x3f));
1019110049   }
1019210050   else
1019310051   {
10194      prg32(space.machine(), ((offset & 0x40) | ((offset >> 8) & 0x3f)) >> 1);
10052      prg32(machine(), ((offset & 0x40) | ((offset >> 8) & 0x3f)) >> 1);
1019510053   }
1019610054
10197   set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10055   set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1019810056}
1019910057
1020010058/*************************************************************
r18063r18064
1021010068
1021110069 *************************************************************/
1021210070
10213static WRITE8_HANDLER( bmc_36in1_w )
10071WRITE8_MEMBER(nes_state::bmc_36in1_w)
1021410072{
1021510073   LOG_MMC(("bmc_36in1_w, offset: %04x, data: %02x\n", offset, data));
1021610074
10217   prg16_89ab(space.machine(), offset & 0x07);
10218   prg16_cdef(space.machine(), offset & 0x07);
10219   chr8(space.machine(), offset & 0x07, CHRROM);
10075   prg16_89ab(machine(), offset & 0x07);
10076   prg16_cdef(machine(), offset & 0x07);
10077   chr8(machine(), offset & 0x07, CHRROM);
1022010078
10221   set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10079   set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1022210080}
1022310081
1022410082/*************************************************************
r18063r18064
1023410092
1023510093 *************************************************************/
1023610094
10237static WRITE8_HANDLER( bmc_21in1_w )
10095WRITE8_MEMBER(nes_state::bmc_21in1_w)
1023810096{
1023910097   LOG_MMC(("bmc_21in1_w, offset: %04x, data: %02x\n", offset, data));
1024010098
10241   prg32(space.machine(), offset & 0x03);
10242   chr8(space.machine(), offset & 0x03, CHRROM);
10099   prg32(machine(), offset & 0x03);
10100   chr8(machine(), offset & 0x03, CHRROM);
1024310101}
1024410102
1024510103/*************************************************************
r18063r18064
1025510113
1025610114 *************************************************************/
1025710115
10258static WRITE8_HANDLER( bmc_150in1_w )
10116WRITE8_MEMBER(nes_state::bmc_150in1_w)
1025910117{
1026010118   int bank = (offset >> 1) & 0x07;
1026110119
1026210120   LOG_MMC(("bmc_150in1_w, offset: %04x, data: %02x\n", offset, data));
1026310121
10264   prg16_89ab(space.machine(), bank);
10265   prg16_cdef(space.machine(), bank + (((bank & 0x06) == 0x06) ? 1 : 0));
10266   chr8(space.machine(), bank, CHRROM);
10122   prg16_89ab(machine(), bank);
10123   prg16_cdef(machine(), bank + (((bank & 0x06) == 0x06) ? 1 : 0));
10124   chr8(machine(), bank, CHRROM);
1026710125
10268   set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
10126   set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
1026910127}
1027010128
1027110129/*************************************************************
r18063r18064
1028110139
1028210140 *************************************************************/
1028310141
10284static WRITE8_HANDLER( bmc_35in1_w )
10142WRITE8_MEMBER(nes_state::bmc_35in1_w)
1028510143{
1028610144   LOG_MMC(("bmc_35in1_w, offset: %04x, data: %02x\n", offset, data));
1028710145
10288   prg16_89ab(space.machine(), (data >> 2) & 0x03);
10289   prg16_cdef(space.machine(), (data >> 2) & 0x03);
10290   chr8(space.machine(), data & 0x03, CHRROM);
10146   prg16_89ab(machine(), (data >> 2) & 0x03);
10147   prg16_cdef(machine(), (data >> 2) & 0x03);
10148   chr8(machine(), data & 0x03, CHRROM);
1029110149}
1029210150
1029310151/*************************************************************
r18063r18064
1030310161
1030410162 *************************************************************/
1030510163
10306static WRITE8_HANDLER( bmc_64in1_w )
10164WRITE8_MEMBER(nes_state::bmc_64in1_w)
1030710165{
1030810166   int bank = (offset >> 1) & (offset >> 2) & 0x01;
1030910167
1031010168   LOG_MMC(("bmc_64in1_w, offset: %04x, data: %02x\n", offset, data));
1031110169
10312   prg16_89ab(space.machine(), offset & ~bank);
10313   prg16_cdef(space.machine(), offset | bank);
10314   chr8(space.machine(), offset & ~bank, CHRROM);
10170   prg16_89ab(machine(), offset & ~bank);
10171   prg16_cdef(machine(), offset | bank);
10172   chr8(machine(), offset & ~bank, CHRROM);
1031510173
10316   set_nt_mirroring(space.machine(), BIT(data, 4) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
10174   set_nt_mirroring(machine(), BIT(data, 4) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
1031710175}
1031810176
1031910177/*************************************************************
r18063r18064
1032910187
1033010188 *************************************************************/
1033110189
10332static WRITE8_HANDLER( bmc_15in1_m_w )
10190WRITE8_MEMBER(nes_state::bmc_15in1_m_w)
1033310191{
10334   nes_state *state = space.machine().driver_data<nes_state>();
1033510192   LOG_MMC(("bmc_15in1_m_w, offset: %04x, data: %02x\n", offset, data));
1033610193
1033710194   if (offset & 0x0800)
1033810195   {
10339      state->m_mmc_prg_base = (data & 0x03) << 4;
10340      state->m_mmc_prg_mask = (data & 0x02) ? 0x0f : 0x1f;
10341      state->m_mmc_chr_base = (data & 0x03) << 7;
10342      state->m_mmc_chr_mask = (data & 0x02) ? 0x7f : 0xff;
10343      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10344      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10196      m_mmc_prg_base = (data & 0x03) << 4;
10197      m_mmc_prg_mask = (data & 0x02) ? 0x0f : 0x1f;
10198      m_mmc_chr_base = (data & 0x03) << 7;
10199      m_mmc_chr_mask = (data & 0x02) ? 0x7f : 0xff;
10200      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10201      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1034510202   }
1034610203}
1034710204
r18063r18064
1035810215
1035910216 *************************************************************/
1036010217
10361static WRITE8_HANDLER( bmc_hik300_w )
10218WRITE8_MEMBER(nes_state::bmc_hik300_w)
1036210219{
1036310220   LOG_MMC(("bmc_hik300_w, offset: %04x, data: %02x\n", offset, data));
1036410221
10365   set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10366   chr8(space.machine(), offset, CHRROM);
10222   set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10223   chr8(machine(), offset, CHRROM);
1036710224
1036810225   if (offset < 0x4000)
1036910226   {
10370      prg16_89ab(space.machine(), offset);
10371      prg16_cdef(space.machine(), offset);
10227      prg16_89ab(machine(), offset);
10228      prg16_cdef(machine(), offset);
1037210229   }
1037310230   else
10374      prg32(space.machine(), offset >> 1);
10231      prg32(machine(), offset >> 1);
1037510232}
1037610233
1037710234/*************************************************************
r18063r18064
1038710244
1038810245 *************************************************************/
1038910246
10390static WRITE8_HANDLER( supergun20in1_w )
10247WRITE8_MEMBER(nes_state::supergun20in1_w)
1039110248{
1039210249   LOG_MMC(("supergun20in1_w, offset: %04x, data: %02x\n", offset, data));
1039310250
10394   prg16_89ab(space.machine(), offset >> 2);
10395   prg16_cdef(space.machine(), offset >> 2);
10396   chr8(space.machine(), offset, CHRROM);
10251   prg16_89ab(machine(), offset >> 2);
10252   prg16_cdef(machine(), offset >> 2);
10253   chr8(machine(), offset, CHRROM);
1039710254}
1039810255
1039910256/*************************************************************
r18063r18064
1040910266
1041010267 *************************************************************/
1041110268
10412static WRITE8_HANDLER( bmc_72in1_w )
10269WRITE8_MEMBER(nes_state::bmc_72in1_w)
1041310270{
1041410271   int hi_bank;
1041510272   int size_16;
r18063r18064
1041710274
1041810275   LOG_MMC(("bmc_72in1_w, offset: %04x, data: %02x\n", offset, data));
1041910276
10420   chr8(space.machine(), offset, CHRROM);
10421   set_nt_mirroring(space.machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10277   chr8(machine(), offset, CHRROM);
10278   set_nt_mirroring(machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1042210279
1042310280   hi_bank = offset & 0x40;
1042410281   size_16 = offset & 0x1000;
r18063r18064
1042910286      if (hi_bank)
1043010287         bank ++;
1043110288
10432      prg16_89ab(space.machine(), bank);
10433      prg16_cdef(space.machine(), bank);
10289      prg16_89ab(machine(), bank);
10290      prg16_cdef(machine(), bank);
1043410291   }
1043510292   else
10436      prg32(space.machine(), bank);
10293      prg32(machine(), bank);
1043710294}
1043810295
1043910296/*************************************************************
r18063r18064
1045010307 *************************************************************/
1045110308
1045210309// does this work for super42in1 as well?!?
10453static WRITE8_HANDLER( bmc_76in1_w )
10310WRITE8_MEMBER(nes_state::bmc_76in1_w)
1045410311{
10455   nes_state *state = space.machine().driver_data<nes_state>();
1045610312   int hi_bank;
1045710313   int size_16;
1045810314   int bank;
r18063r18064
1046010316   LOG_MMC(("bmc_76in1_w, offset: %04x, data: %02x\n", offset, data));
1046110317
1046210318   if (offset & 0x01)
10463      state->m_mmc_latch2 = data;
10319      m_mmc_latch2 = data;
1046410320   else
10465      state->m_mmc_latch1 = data;
10321      m_mmc_latch1 = data;
1046610322
10467   set_nt_mirroring(space.machine(), BIT(state->m_mmc_latch1, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10323   set_nt_mirroring(machine(), BIT(m_mmc_latch1, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1046810324
10469   hi_bank = state->m_mmc_latch1 & 0x01;
10470   size_16 = state->m_mmc_latch1 & 0x20;
10471   bank = ((state->m_mmc_latch1 & 0x1e) >> 1) | ((state->m_mmc_latch1 & 0x80) >> 3) | ((state->m_mmc_latch2 & 0x01) << 5);
10325   hi_bank = m_mmc_latch1 & 0x01;
10326   size_16 = m_mmc_latch1 & 0x20;
10327   bank = ((m_mmc_latch1 & 0x1e) >> 1) | ((m_mmc_latch1 & 0x80) >> 3) | ((m_mmc_latch2 & 0x01) << 5);
1047210328
1047310329   if (size_16)
1047410330   {
r18063r18064
1047610332      if (hi_bank)
1047710333         bank ++;
1047810334
10479      prg16_89ab(space.machine(), bank);
10480      prg16_cdef(space.machine(), bank);
10335      prg16_89ab(machine(), bank);
10336      prg16_cdef(machine(), bank);
1048110337   }
1048210338   else
10483      prg32(space.machine(), bank);
10339      prg32(machine(), bank);
1048410340}
1048510341
1048610342/*************************************************************
r18063r18064
1049610352
1049710353 *************************************************************/
1049810354
10499static WRITE8_HANDLER( bmc_1200in1_w )
10355WRITE8_MEMBER(nes_state::bmc_1200in1_w)
1050010356{
1050110357   int hi_bank;
1050210358   int size_32;
r18063r18064
1051310369      if (hi_bank)
1051410370         bank ++;
1051510371
10516      prg16_89ab(space.machine(), bank);
10517      prg16_cdef(space.machine(), bank);
10372      prg16_89ab(machine(), bank);
10373      prg16_cdef(machine(), bank);
1051810374   }
1051910375   else
10520      prg32(space.machine(), bank);
10376      prg32(machine(), bank);
1052110377
1052210378   if (!(offset & 0x80))
1052310379   {
1052410380      if (offset & 0x200)
10525         prg16_cdef(space.machine(), ((bank << 1) & 0x38) + 7);
10381         prg16_cdef(machine(), ((bank << 1) & 0x38) + 7);
1052610382      else
10527         prg16_cdef(space.machine(), ((bank << 1) & 0x38));
10383         prg16_cdef(machine(), ((bank << 1) & 0x38));
1052810384   }
1052910385
10530   set_nt_mirroring(space.machine(), BIT(data, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10386   set_nt_mirroring(machine(), BIT(data, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1053110387}
1053210388
1053310389/*************************************************************
r18063r18064
1054310399
1054410400 *************************************************************/
1054510401
10546static WRITE8_HANDLER( bmc_31in1_w )
10402WRITE8_MEMBER(nes_state::bmc_31in1_w)
1054710403{
1054810404   LOG_MMC(("bmc_31in1_w, offset: %04x, data: %02x\n", offset, data));
1054910405
10550   set_nt_mirroring(space.machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10551   chr8(space.machine(), offset, CHRROM);
10406   set_nt_mirroring(machine(), BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10407   chr8(machine(), offset, CHRROM);
1055210408
1055310409   if ((offset & 0x1e) == 0)
1055410410   {
10555      prg16_89ab(space.machine(), 0);
10556      prg16_89ab(space.machine(), 1);
10411      prg16_89ab(machine(), 0);
10412      prg16_89ab(machine(), 1);
1055710413   }
1055810414   else
1055910415   {
10560      prg16_89ab(space.machine(), offset & 0x1f);
10561      prg16_89ab(space.machine(), offset & 0x1f);
10416      prg16_89ab(machine(), offset & 0x1f);
10417      prg16_89ab(machine(), offset & 0x1f);
1056210418   }
1056310419}
1056410420
r18063r18064
1057610432
1057710433 *************************************************************/
1057810434
10579static WRITE8_HANDLER( bmc_22g_w )
10435WRITE8_MEMBER(nes_state::bmc_22g_w)
1058010436{
1058110437   LOG_MMC(("bmc_22g_w, offset: %04x, data: %02x\n", offset, data));
1058210438
1058310439   if (1)   // this should flip at reset
1058410440   {
10585      prg16_89ab(space.machine(), data & 0x07);
10441      prg16_89ab(machine(), data & 0x07);
1058610442   }
1058710443   else
1058810444   {
1058910445      if (data & 0x20)
1059010446      {
10591         prg16_89ab(space.machine(), (data & 0x1f) + 8);
10592         prg16_cdef(space.machine(), (data & 0x1f) + 8);
10447         prg16_89ab(machine(), (data & 0x1f) + 8);
10448         prg16_cdef(machine(), (data & 0x1f) + 8);
1059310449      }
1059410450      else
1059510451      {
10596         prg16_89ab(space.machine(), (data & 0x1f) + 8);
10597         prg16_cdef(space.machine(), (data & 0x1f) + 9);
10452         prg16_89ab(machine(), (data & 0x1f) + 8);
10453         prg16_cdef(machine(), (data & 0x1f) + 9);
1059810454      }
10599      set_nt_mirroring(space.machine(), BIT(data, 6) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
10455      set_nt_mirroring(machine(), BIT(data, 6) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
1060010456   }
1060110457}
1060210458
r18063r18064
1061310469
1061410470 *************************************************************/
1061510471
10616static WRITE8_HANDLER( bmc_20in1_w )
10472WRITE8_MEMBER(nes_state::bmc_20in1_w)
1061710473{
1061810474   LOG_MMC(("bmc_20in1_w, offset: %04x, data: %02x\n", offset, data));
1061910475
10620   set_nt_mirroring(space.machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10476   set_nt_mirroring(machine(), BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1062110477
10622   prg16_89ab(space.machine(), (offset & 0x1e));
10623   prg16_cdef(space.machine(), (offset & 0x1e) | ((offset & 0x20) ? 1 : 0));
10478   prg16_89ab(machine(), (offset & 0x1e));
10479   prg16_cdef(machine(), (offset & 0x1e) | ((offset & 0x20) ? 1 : 0));
1062410480}
1062510481
1062610482/*************************************************************
r18063r18064
1063610492
1063710493 *************************************************************/
1063810494
10639static WRITE8_HANDLER( bmc_110in1_w )
10495WRITE8_MEMBER(nes_state::bmc_110in1_w)
1064010496{
1064110497   UINT8 map255_helper1 = (offset >> 12) ? 0 : 1;
1064210498   UINT8 map255_helper2 = ((offset >> 8) & 0x40) | ((offset >> 6) & 0x3f);
1064310499
1064410500   LOG_MMC(("bmc_110in1_w, offset: %04x, data: %02x\n", offset, data));
1064510501
10646   set_nt_mirroring(space.machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10647   prg16_89ab(space.machine(), map255_helper1 & ~map255_helper2);
10648   prg16_cdef(space.machine(), map255_helper1 | map255_helper2);
10649   chr8(space.machine(), ((offset >> 8) & 0x40) | (offset & 0x3f), CHRROM);
10502   set_nt_mirroring(machine(), (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10503   prg16_89ab(machine(), map255_helper1 & ~map255_helper2);
10504   prg16_cdef(machine(), map255_helper1 | map255_helper2);
10505   chr8(machine(), ((offset >> 8) & 0x40) | (offset & 0x3f), CHRROM);
1065010506}
1065110507
1065210508/*************************************************************
r18063r18064
1066210518
1066310519 *************************************************************/
1066410520
10665static WRITE8_HANDLER( bmc_sbig7_w )
10521WRITE8_MEMBER(nes_state::bmc_sbig7_w)
1066610522{
10667   nes_state *state = space.machine().driver_data<nes_state>();
1066810523   UINT8 page;
1066910524   LOG_MMC(("bmc_sbig7_w, offset: %04x, data: %02x\n", offset, data));
1067010525
r18063r18064
1067510530         if (page > 6)
1067610531            page = 6;
1067710532
10678         state->m_mmc_prg_base = page << 4;
10679         state->m_mmc_prg_mask = (page > 5) ? 0x1f : 0x0f;
10680         state->m_mmc_chr_base = page << 7;
10681         state->m_mmc_chr_mask = (page > 5) ? 0xff : 0x7f;
10682         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10683         mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10533         m_mmc_prg_base = page << 4;
10534         m_mmc_prg_mask = (page > 5) ? 0x1f : 0x0f;
10535         m_mmc_chr_base = page << 7;
10536         m_mmc_chr_mask = (page > 5) ? 0xff : 0x7f;
10537         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10538         mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1068410539         break;
1068510540
1068610541      default:
r18063r18064
1070210557
1070310558 *************************************************************/
1070410559
10705static WRITE8_HANDLER( bmc_hik8_m_w )
10560WRITE8_MEMBER(nes_state::bmc_hik8_m_w)
1070610561{
10707   nes_state *state = space.machine().driver_data<nes_state>();
1070810562   LOG_MMC(("bmc_hik8_m_w, offset: %04x, data: %02x\n", offset, data));
1070910563
1071010564   /* This bit is the "register lock". Once register are locked, writes go to WRAM
1071110565     and there is no way to unlock them (except by resetting the machine) */
10712   if ((state->m_mmc_reg[3] & 0x40) && state->m_wram != NULL)
10713      state->m_wram[offset] = data;
10566   if ((m_mmc_reg[3] & 0x40) && m_wram != NULL)
10567      m_wram[offset] = data;
1071410568   else
1071510569   {
10716      state->m_mmc_reg[state->m_mmc_count] = data;
10717      state->m_mmc_count = (state->m_mmc_count + 1) & 0x03;
10570      m_mmc_reg[m_mmc_count] = data;
10571      m_mmc_count = (m_mmc_count + 1) & 0x03;
1071810572
10719      if (!state->m_mmc_count)
10573      if (!m_mmc_count)
1072010574      {
10721         LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->m_mmc_reg[3],
10722                state->m_mmc_reg[2], state->m_mmc_reg[1], state->m_mmc_reg[0]));
10575         LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", m_mmc_reg[3],
10576                m_mmc_reg[2], m_mmc_reg[1], m_mmc_reg[0]));
1072310577
10724         state->m_mmc_prg_base = state->m_mmc_reg[1];
10725         state->m_mmc_prg_mask = 0x3f ^ (state->m_mmc_reg[3] & 0x3f);
10726         state->m_mmc_chr_base = ((state->m_mmc_reg[2] & 0xf0) << 4) | state->m_mmc_reg[0];
10727         if (BIT(state->m_mmc_reg[2], 3))
10728            state->m_mmc_chr_mask = (1 << ((state->m_mmc_reg[2] & 7) + 1)) - 1;
10729         else if (state->m_mmc_reg[2])
10730            state->m_mmc_chr_mask = 0;
10578         m_mmc_prg_base = m_mmc_reg[1];
10579         m_mmc_prg_mask = 0x3f ^ (m_mmc_reg[3] & 0x3f);
10580         m_mmc_chr_base = ((m_mmc_reg[2] & 0xf0) << 4) | m_mmc_reg[0];
10581         if (BIT(m_mmc_reg[2], 3))
10582            m_mmc_chr_mask = (1 << ((m_mmc_reg[2] & 7) + 1)) - 1;
10583         else if (m_mmc_reg[2])
10584            m_mmc_chr_mask = 0;
1073110585         else
10732            state->m_mmc_chr_mask = 0xff;   // i.e. we use the vrom_bank with no masking
10586            m_mmc_chr_mask = 0xff;   // i.e. we use the vrom_bank with no masking
1073310587
10734         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10735         mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10588         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10589         mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1073610590      }
1073710591   }
1073810592}
r18063r18064
1075010604
1075110605 *************************************************************/
1075210606
10753static WRITE8_HANDLER( bmc_hik4in1_m_w )
10607WRITE8_MEMBER(nes_state::bmc_hik4in1_m_w)
1075410608{
10755   nes_state *state = space.machine().driver_data<nes_state>();
1075610609   LOG_MMC(("bmc_hik4in1_m_w, offset: %04x, data: %02x\n", offset, data));
1075710610
1075810611   /* mid writes only work when WRAM is enabled. not sure if I should
10759     change the condition to state->m_mmc_latch2==0x80 (i.e. what is the effect of
10612     change the condition to m_mmc_latch2==0x80 (i.e. what is the effect of
1076010613     the read-only bit?) */
10761   if (state->m_mmc3_wram_protect & 0x80)
10614   if (m_mmc3_wram_protect & 0x80)
1076210615   {
1076310616      if (data & 0x01)   /* if this is 0, then we have 32k PRG blocks */
1076410617      {
10765         state->m_mmc_prg_base = (data & 0xc0) >> 2;
10766         state->m_mmc_prg_mask = 0x0f;
10767         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10618         m_mmc_prg_base = (data & 0xc0) >> 2;
10619         m_mmc_prg_mask = 0x0f;
10620         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1076810621      }
1076910622      else
10770         prg32(space.machine(), (data & 0x30) >> 4);
10623         prg32(machine(), (data & 0x30) >> 4);
1077110624
10772      state->m_mmc_chr_base = (data & 0xc0) << 1;
10773      state->m_mmc_chr_mask = 0x7f;
10774      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10625      m_mmc_chr_base = (data & 0xc0) << 1;
10626      m_mmc_chr_mask = 0x7f;
10627      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1077510628   }
1077610629}
1077710630
r18063r18064
1080410657   }
1080510658}
1080610659
10807static WRITE8_HANDLER( bmc_ball11_m_w )
10660WRITE8_MEMBER(nes_state::bmc_ball11_m_w)
1080810661{
10809   nes_state *state = space.machine().driver_data<nes_state>();
1081010662
1081110663   LOG_MMC(("bmc_ball11_m_w, offset: %04x, data: %02x\n", offset, data));
1081210664
10813   state->m_mmc_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02);
10814   bmc_ball11_set_banks(space.machine());
10665   m_mmc_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02);
10666   bmc_ball11_set_banks(machine());
1081510667}
1081610668
10817static WRITE8_HANDLER( bmc_ball11_w )
10669WRITE8_MEMBER(nes_state::bmc_ball11_w)
1081810670{
10819   nes_state *state = space.machine().driver_data<nes_state>();
1082010671
1082110672   LOG_MMC(("bmc_ball11_w, offset: %04x, data: %02x\n", offset, data));
1082210673
1082310674   switch (offset & 0x6000)
1082410675   {
1082510676      case 0x4000:   // here we also update reg[0] upper bit
10826         state->m_mmc_reg[0] = (state->m_mmc_reg[0] & 0x01) | ((data >> 3) & 0x02);
10677         m_mmc_reg[0] = (m_mmc_reg[0] & 0x01) | ((data >> 3) & 0x02);
1082710678      case 0x0000:
1082810679      case 0x2000:
1082910680      case 0x6000:
10830         state->m_mmc_reg[1] = data & 0x0f;
10831         bmc_ball11_set_banks(space.machine());
10681         m_mmc_reg[1] = data & 0x0f;
10682         bmc_ball11_set_banks(machine());
1083210683         break;
1083310684   }
1083410685}
r18063r18064
1084810699
1084910700 *************************************************************/
1085010701
10851static WRITE8_HANDLER( bmc_mario7in1_m_w )
10702WRITE8_MEMBER(nes_state::bmc_mario7in1_m_w)
1085210703{
10853   nes_state *state = space.machine().driver_data<nes_state>();
1085410704   UINT8 map52_helper1, map52_helper2;
1085510705   LOG_MMC(("bmc_mario7in1_m_w, offset: %04x, data: %02x\n", offset, data));
1085610706
1085710707   /* mid writes only work when WRAM is enabled. not sure if I should
10858     change the condition to state->m_map52_reg_written == 0x80 (i.e. what is the effect of
10708     change the condition to m_map52_reg_written == 0x80 (i.e. what is the effect of
1085910709     the read-only bit?) and it only can happen once! */
10860   if ((state->m_mmc3_wram_protect & 0x80) && !state->m_map52_reg_written)
10710   if ((m_mmc3_wram_protect & 0x80) && !m_map52_reg_written)
1086110711   {
1086210712      map52_helper1 = (data & 0x08);
1086310713      map52_helper2 = (data & 0x40);
1086410714
10865      state->m_mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4);
10866      state->m_mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f;
10867      state->m_mmc_chr_base = ((data & 0x20) << 4) | ((data & 0x04) << 6) | (map52_helper2 ? ((data & 0x10) << 3) : 0);
10868      state->m_mmc_chr_mask = map52_helper2 ? 0x7f : 0xff;
10869      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10870      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10715      m_mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4);
10716      m_mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f;
10717      m_mmc_chr_base = ((data & 0x20) << 4) | ((data & 0x04) << 6) | (map52_helper2 ? ((data & 0x10) << 3) : 0);
10718      m_mmc_chr_mask = map52_helper2 ? 0x7f : 0xff;
10719      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10720      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1087110721
10872      state->m_map52_reg_written = 1;
10722      m_map52_reg_written = 1;
1087310723   }
1087410724   else
10875      state->m_wram[offset] = data;
10725      m_wram[offset] = data;
1087610726}
1087710727
1087810728/*************************************************************
r18063r18064
1089110741
1089210742 *************************************************************/
1089310743
10894static WRITE8_HANDLER( bmc_gold7in1_m_w )
10744WRITE8_MEMBER(nes_state::bmc_gold7in1_m_w)
1089510745{
10896   nes_state *state = space.machine().driver_data<nes_state>();
1089710746   UINT8 map52_helper1, map52_helper2;
1089810747   LOG_MMC(("bmc_gold7in1_m_w, offset: %04x, data: %02x\n", offset, data));
1089910748
10900   if ((state->m_mmc3_wram_protect & 0x80) && !state->m_map52_reg_written)
10749   if ((m_mmc3_wram_protect & 0x80) && !m_map52_reg_written)
1090110750   {
1090210751      map52_helper1 = (data & 0x08);
1090310752      map52_helper2 = (data & 0x40);
1090410753
10905      state->m_mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4);
10906      state->m_mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f;
10907      state->m_mmc_chr_base = ((data & 0x20) << 3) | ((data & 0x04) << 7) | (map52_helper2 ? ((data & 0x10) << 3) : 0);
10908      state->m_mmc_chr_mask = map52_helper2 ? 0x7f : 0xff;
10909      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10910      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10754      m_mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4);
10755      m_mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f;
10756      m_mmc_chr_base = ((data & 0x20) << 3) | ((data & 0x04) << 7) | (map52_helper2 ? ((data & 0x10) << 3) : 0);
10757      m_mmc_chr_mask = map52_helper2 ? 0x7f : 0xff;
10758      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10759      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1091110760
10912      state->m_map52_reg_written = BIT(data, 7);   // mc_2hikg & mc_s3nt3 write here multiple time
10761      m_map52_reg_written = BIT(data, 7);   // mc_2hikg & mc_s3nt3 write here multiple time
1091310762   }
1091410763   else
10915      state->m_wram[offset] = data;
10764      m_wram[offset] = data;
1091610765}
1091710766
1091810767/*************************************************************
r18063r18064
1096110810   chr1_x(machine, chr_page ^ 7, chr_base | (state->m_mmc_vrom_bank[5] & chr_mask), chr);
1096210811}
1096310812
10964static WRITE8_HANDLER( bmc_gc6in1_l_w )
10813WRITE8_MEMBER(nes_state::bmc_gc6in1_l_w)
1096510814{
10966   nes_state *state = space.machine().driver_data<nes_state>();
1096710815   UINT8 bank;
1096810816   LOG_MMC(("bmc_gc6in1_l_w, offset: %04x, data: %02x\n", offset, data));
1096910817   offset += 0x100;
1097010818
1097110819   if (offset == 0x1000)
1097210820   {
10973      state->m_mmc_reg[0] = data;
10821      m_mmc_reg[0] = data;
1097410822      if (data & 0x80)
1097510823      {
10976         bank = (data & 0x0f) | ((state->m_mmc_reg[1] & 0x03) << 4);
10977         prg16_89ab(space.machine(), bank);
10978         prg16_cdef(space.machine(), bank);
10824         bank = (data & 0x0f) | ((m_mmc_reg[1] & 0x03) << 4);
10825         prg16_89ab(machine(), bank);
10826         prg16_cdef(machine(), bank);
1097910827      }
1098010828      else
10981         bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10829         bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1098210830   }
1098310831   else if (offset == 0x1001)
1098410832   {
10985      state->m_mmc_reg[1] = data;
10986      bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10833      m_mmc_reg[1] = data;
10834      bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1098710835   }
1098810836   else if (offset == 0x1007)
1098910837   {
10990      state->m_mmc_reg[2] = data;
10838      m_mmc_reg[2] = data;
1099110839   }
1099210840}
1099310841
10994static WRITE8_HANDLER( bmc_gc6in1_w )
10842WRITE8_MEMBER(nes_state::bmc_gc6in1_w)
1099510843{
10996   nes_state *state = space.machine().driver_data<nes_state>();
1099710844   UINT8 mmc_helper, cmd;
1099810845   static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1};
1099910846   LOG_MMC(("bmc_gc6in1_w, offset: %04x, data: %02x\n", offset, data));
1100010847
11001   if (!state->m_mmc_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
10848   if (!m_mmc_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
1100210849   {
1100310850      switch (offset & 0x6001)
1100410851      {
1100510852         case 0x0000:
11006            mmc_helper = state->m_mmc3_latch ^ data;
11007            state->m_mmc3_latch = data;
10853            mmc_helper = m_mmc3_latch ^ data;
10854            m_mmc3_latch = data;
1100810855
1100910856            /* Has PRG Mode changed? */
1101010857            if (mmc_helper & 0x40)
11011               bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10858               bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1101210859
1101310860            /* Has CHR Mode changed? */
1101410861            if (mmc_helper & 0x80)
11015               bmc_gc6in1_set_chr(space.machine(), state->m_mmc_chr_source);
10862               bmc_gc6in1_set_chr(machine(), m_mmc_chr_source);
1101610863            break;
1101710864
1101810865         case 0x0001:
11019            cmd = state->m_mmc3_latch & 0x07;
10866            cmd = m_mmc3_latch & 0x07;
1102010867            switch (cmd)
1102110868         {
1102210869            case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
1102310870            case 2: case 3: case 4: case 5:
11024               state->m_mmc_vrom_bank[cmd] = data;
11025               bmc_gc6in1_set_chr(space.machine(), state->m_mmc_chr_source);
10871               m_mmc_vrom_bank[cmd] = data;
10872               bmc_gc6in1_set_chr(machine(), m_mmc_chr_source);
1102610873               break;
1102710874            case 6:
1102810875            case 7:
11029               state->m_mmc_prg_bank[cmd - 6] = data;
11030               bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10876               m_mmc_prg_bank[cmd - 6] = data;
10877               bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1103110878               break;
1103210879         }
1103310880            break;
r18063r18064
1104710894
1104810895         case 0x0001:
1104910896            data = (data & 0xc0) | conv_table[data & 0x07];
11050            mmc_helper = state->m_mmc3_latch ^ data;
11051            state->m_mmc3_latch = data;
10897            mmc_helper = m_mmc3_latch ^ data;
10898            m_mmc3_latch = data;
1105210899
1105310900            /* Has PRG Mode changed? */
1105410901            if (mmc_helper & 0x40)
11055               bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10902               bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1105610903
1105710904            /* Has CHR Mode changed? */
1105810905            if (mmc_helper & 0x80)
11059               bmc_gc6in1_set_chr(space.machine(), state->m_mmc_chr_source);
10906               bmc_gc6in1_set_chr(machine(), m_mmc_chr_source);
1106010907
11061            state->m_mmc_reg[3] = 1;
10908            m_mmc_reg[3] = 1;
1106210909            break;
1106310910
1106410911         case 0x2000:
11065            cmd = state->m_mmc3_latch & 0x07;
11066            if (state->m_mmc_reg[3])
10912            cmd = m_mmc3_latch & 0x07;
10913            if (m_mmc_reg[3])
1106710914            {
11068               state->m_mmc_reg[3] = 0;
10915               m_mmc_reg[3] = 0;
1106910916               switch (cmd)
1107010917               {
1107110918                  case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
1107210919                  case 2: case 3: case 4: case 5:
11073                     state->m_mmc_vrom_bank[cmd] = data;
11074                     bmc_gc6in1_set_chr(space.machine(), state->m_mmc_chr_source);
10920                     m_mmc_vrom_bank[cmd] = data;
10921                     bmc_gc6in1_set_chr(machine(), m_mmc_chr_source);
1107510922                     break;
1107610923                  case 6:
1107710924                  case 7:
11078                     state->m_mmc_prg_bank[cmd - 6] = data;
11079                     bmc_gc6in1_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
10925                     m_mmc_prg_bank[cmd - 6] = data;
10926                     bmc_gc6in1_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1108010927                     break;
1108110928               }
1108210929            }
r18063r18064
1108410931
1108510932
1108610933         case 0x2001:
11087            set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10934            set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1108810935            break;
1108910936
1109010937         default:
r18063r18064
1110910956
1111010957 *************************************************************/
1111110958
11112static WRITE8_HANDLER( bmc_family4646_m_w )
10959WRITE8_MEMBER(nes_state::bmc_family4646_m_w)
1111310960{
11114   nes_state *state = space.machine().driver_data<nes_state>();
1111510961   LOG_MMC(("bmc_family4646_m_w, offset: %04x, data: %02x\n", offset, data));
1111610962
1111710963   if (offset == 0x01)
1111810964   {
11119      state->m_mmc_prg_base = (data & 0x02) << 4;
11120      state->m_mmc_prg_mask = 0x1f;
11121      state->m_mmc_chr_base = (data & 0x20) << 3;
11122      state->m_mmc_chr_mask = 0xff;
11123      mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
11124      mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
10965      m_mmc_prg_base = (data & 0x02) << 4;
10966      m_mmc_prg_mask = 0x1f;
10967      m_mmc_chr_base = (data & 0x20) << 3;
10968      m_mmc_chr_mask = 0xff;
10969      mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
10970      mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1112510971   }
1112610972}
1112710973
r18063r18064
1113110977
1113210978 *************************************************************/
1113310979
11134static WRITE8_HANDLER( bmc_vt5201_w )
10980WRITE8_MEMBER(nes_state::bmc_vt5201_w)
1113510981{
11136   nes_state *state = space.machine().driver_data<nes_state>();
1113710982   LOG_MMC(("bmc_vt5201_w, offset: %04x, data: %02x\n", offset, data));
1113810983
11139   state->m_mmc_latch1 = BIT(offset, 8);
10984   m_mmc_latch1 = BIT(offset, 8);
1114010985
1114110986   // not sure about this mirroring bit!!
1114210987   // without it TN 95 in 1 has glitches in Lunar Ball; with it TN 95 in 1 has glitches in Galaxian!
11143   set_nt_mirroring(space.machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10988   set_nt_mirroring(machine(), BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1114410989   if (BIT(offset, 7))
1114510990   {
11146      prg16_89ab(space.machine(), (offset >> 4) & 0x07);
11147      prg16_cdef(space.machine(), (offset >> 4) & 0x07);
10991      prg16_89ab(machine(), (offset >> 4) & 0x07);
10992      prg16_cdef(machine(), (offset >> 4) & 0x07);
1114810993   }
1114910994   else
11150      prg32(space.machine(), (offset >> 5) & 0x03);
11151   chr8(space.machine(), offset, CHRROM);
10995      prg32(machine(), (offset >> 5) & 0x03);
10996   chr8(machine(), offset, CHRROM);
1115210997}
1115310998
11154static READ8_HANDLER( bmc_vt5201_r )
10999READ8_MEMBER(nes_state::bmc_vt5201_r)
1115511000{
11156   nes_state *state = space.machine().driver_data<nes_state>();
1115711001   LOG_MMC(("bmc_vt5201_r, offset: %04x\n", offset));
11158   //  state->m_mmc_dipsetting = state->ioport("CARTDIPS")->read();
11002   //  m_mmc_dipsetting = ioport("CARTDIPS")->read();
1115911003
11160   if (state->m_mmc_latch1)
11161      return state->m_mmc_dipsetting; // cart mode, depending on the Dip Switches (always zero atm, given we have no way to add cart-based DIPs)
11004   if (m_mmc_latch1)
11005      return m_mmc_dipsetting; // cart mode, depending on the Dip Switches (always zero atm, given we have no way to add cart-based DIPs)
1116211006   else
11163      return mmc_hi_access_rom(space.machine(), offset);
11007      return mmc_hi_access_rom(machine(), offset);
1116411008}
1116511009
1116611010/*************************************************************
r18063r18064
1118511029   chr2_6(machine, state->m_mmc_vrom_bank[3], CHRROM);
1118611030}
1118711031
11188static WRITE8_HANDLER( bmc_bs5_w )
11032WRITE8_MEMBER(nes_state::bmc_bs5_w)
1118911033{
11190   nes_state *state = space.machine().driver_data<nes_state>();
1119111034   UINT8 bs5_helper = (offset & 0xc00) >> 10;
1119211035   LOG_MMC(("bmc_bs5_w, offset: %04x, data: %02x\n", offset, data));
11193//  state->m_mmc_dipsetting = state->ioport("CARTDIPS")->read();
11036//  m_mmc_dipsetting = ioport("CARTDIPS")->read();
1119411037
1119511038   switch (offset & 0x7000)
1119611039   {
1119711040      case 0x0000:
11198         state->m_mmc_vrom_bank[bs5_helper] = offset & 0x1f;
11041         m_mmc_vrom_bank[bs5_helper] = offset & 0x1f;
1119911042         break;
1120011043      case 0x2000:
11201         if (BIT(offset, state->m_mmc_dipsetting + 4))   // mmc_dipsetting is always zero atm, given we have no way to add cart-based DIPs
11202            state->m_mmc_prg_bank[bs5_helper] = offset & 0x0f;
11044         if (BIT(offset, m_mmc_dipsetting + 4))   // mmc_dipsetting is always zero atm, given we have no way to add cart-based DIPs
11045            m_mmc_prg_bank[bs5_helper] = offset & 0x0f;
1120311046         break;
1120411047   }
11205   bmc_bs5_update_banks(space.machine());
11048   bmc_bs5_update_banks(machine());
1120611049}
1120711050
1120811051/*************************************************************
r18063r18064
1121311056
1121411057 *************************************************************/
1121511058
11216static WRITE8_HANDLER( bmc_810544_w )
11059WRITE8_MEMBER(nes_state::bmc_810544_w)
1121711060{
1121811061   UINT8 bank = (offset >> 7);
1121911062   LOG_MMC(("bmc_810544_w, offset: %04x, data: %02x\n", offset, data));
1122011063
1122111064   if (!BIT(offset, 6))
1122211065   {
11223      prg16_89ab(space.machine(), (bank << 1) | BIT(offset, 5));
11224      prg16_cdef(space.machine(), (bank << 1) | BIT(offset, 5));
11066      prg16_89ab(machine(), (bank << 1) | BIT(offset, 5));
11067      prg16_cdef(machine(), (bank << 1) | BIT(offset, 5));
1122511068   }
1122611069   else
11227      prg32(space.machine(), bank);
11070      prg32(machine(), bank);
1122811071
11229   set_nt_mirroring(space.machine(), BIT(offset, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
11072   set_nt_mirroring(machine(), BIT(offset, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1123011073
11231   chr8(space.machine(), offset & 0x0f, CHRROM);
11074   chr8(machine(), offset & 0x0f, CHRROM);
1123211075}
1123311076
1123411077/*************************************************************
r18063r18064
1123711080
1123811081 *************************************************************/
1123911082
11240static WRITE8_HANDLER( bmc_ntd03_w )
11083WRITE8_MEMBER(nes_state::bmc_ntd03_w)
1124111084{
1124211085   UINT8 pbank, cbank;
1124311086   LOG_MMC(("bmc_ntd03_w, offset: %04x, data: %02x\n", offset, data));
r18063r18064
1124711090
1124811091   if (BIT(offset, 7))
1124911092   {
11250      prg16_89ab(space.machine(), pbank | BIT(offset, 6));
11251      prg16_cdef(space.machine(), pbank | BIT(offset, 6));
11093      prg16_89ab(machine(), pbank | BIT(offset, 6));
11094      prg16_cdef(machine(), pbank | BIT(offset, 6));
1125211095   }
1125311096   else
11254      prg32(space.machine(), pbank >> 1);
11097      prg32(machine(), pbank >> 1);
1125511098
11256   set_nt_mirroring(space.machine(), BIT(offset, 10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
11099   set_nt_mirroring(machine(), BIT(offset, 10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1125711100
11258   chr8(space.machine(), cbank, CHRROM);
11101   chr8(machine(), cbank, CHRROM);
1125911102}
1126011103
1126111104/*************************************************************
r18063r18064
1128611129//      chr8(machine, 0, CHRROM);
1128711130}
1128811131
11289static WRITE8_HANDLER( bmc_gb63_w )
11132WRITE8_MEMBER(nes_state::bmc_gb63_w)
1129011133{
11291   nes_state *state = space.machine().driver_data<nes_state>();
1129211134   LOG_MMC(("bmc_gb63_w, offset: %04x, data: %02x\n", offset, data));
1129311135
11294   state->m_mmc_reg[offset & 1] = data;
11295   state->m_mmc_latch1 = BIT(state->m_mmc_reg[0], 7) | (BIT(state->m_mmc_reg[1], 0) << 1);
11136   m_mmc_reg[offset & 1] = data;
11137   m_mmc_latch1 = BIT(m_mmc_reg[0], 7) | (BIT(m_mmc_reg[1], 0) << 1);
1129611138
1129711139}
1129811140
11299static READ8_HANDLER( bmc_gb63_r )
11141READ8_MEMBER(nes_state::bmc_gb63_r)
1130011142{
11301   nes_state *state = space.machine().driver_data<nes_state>();
1130211143   LOG_MMC(("bmc_gb63_r, offset: %04x\n", offset));
11303   //  state->m_mmc_dipsetting = state->ioport("CARTDIPS")->read();
11144   //  m_mmc_dipsetting = ioport("CARTDIPS")->read();
1130411145
11305   if (state->m_mmc_latch1 == 1)
11146   if (m_mmc_latch1 == 1)
1130611147      return 0xff;   // open bus
1130711148   else
11308      return mmc_hi_access_rom(space.machine(), offset);
11149      return mmc_hi_access_rom(machine(), offset);
1130911150}
1131011151
1131111152/*************************************************************
r18063r18064
1131411155
1131511156 *************************************************************/
1131611157
11317static WRITE8_HANDLER( edu2k_w )
11158WRITE8_MEMBER(nes_state::edu2k_w)
1131811159{
1131911160   LOG_MMC(("edu2k_w, offset: %04x, data: %02x\n", offset, data));
1132011161
11321   prg32(space.machine(), data & 0x1f);
11322   wram_bank(space.machine(), (data & 0xc0) >> 6, NES_WRAM);
11162   prg32(machine(), data & 0x1f);
11163   wram_bank(machine(), (data & 0xc0) >> 6, NES_WRAM);
1132311164}
1132411165
1132511166/*************************************************************
r18063r18064
1133611177      prg8_x(machine, start, bank);
1133711178}
1133811179
11339static WRITE8_HANDLER( h2288_l_w )
11180WRITE8_MEMBER(nes_state::h2288_l_w)
1134011181{
11341   nes_state *state = space.machine().driver_data<nes_state>();
1134211182   LOG_MMC(("h2288_l_w offset: %04x, data: %02x\n", offset, data));
1134311183   offset += 0x100;
1134411184
1134511185   if (offset >= 0x1800)
1134611186   {
11347      state->m_mmc_reg[offset & 1] = data;
11348      if (state->m_mmc_reg[0] & 0x40)
11187      m_mmc_reg[offset & 1] = data;
11188      if (m_mmc_reg[0] & 0x40)
1134911189      {
11350         UINT8 helper1 = (state->m_mmc_reg[0] & 0x05) | ((state->m_mmc_reg[0] >> 2) & 0x0a);
11351         UINT8 helper2 = BIT(state->m_mmc_reg[0], 1);
11352         prg16_89ab(space.machine(), helper1 & ~helper2);
11353         prg16_cdef(space.machine(), helper1 |  helper2);
11190         UINT8 helper1 = (m_mmc_reg[0] & 0x05) | ((m_mmc_reg[0] >> 2) & 0x0a);
11191         UINT8 helper2 = BIT(m_mmc_reg[0], 1);
11192         prg16_89ab(machine(), helper1 & ~helper2);
11193         prg16_cdef(machine(), helper1 |  helper2);
1135411194      }
1135511195      else
11356         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
11196         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1135711197   }
1135811198}
1135911199
11360static READ8_HANDLER( h2288_l_r )
11200READ8_MEMBER(nes_state::h2288_l_r)
1136111201{
1136211202   LOG_MMC(("h2288_l_r offset: %04x\n", offset));
1136311203   offset += 0x100;
r18063r18064
1137411214   return 0;
1137511215}
1137611216
11377static WRITE8_HANDLER( h2288_w )
11217WRITE8_MEMBER(nes_state::h2288_w)
1137811218{
1137911219   static const UINT8 conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4};
1138011220   LOG_MMC(("h2288_w, offset: %04x, data: %02x\n", offset, data));
r18063r18064
1144211282   }
1144311283}
1144411284
11445static WRITE8_HANDLER( shjy3_w )
11285WRITE8_MEMBER(nes_state::shjy3_w)
1144611286{
11447   nes_state *state = space.machine().driver_data<nes_state>();
1144811287   UINT8 mmc_helper, shift;
1144911288   LOG_MMC(("shjy3_w, offset: %04x, data: %02x\n", offset, data));
1145011289
r18063r18064
1145511294      mmc_helper &= 7;
1145611295      shift = offset & 4;
1145711296
11458      state->m_mmc_vrom_bank[mmc_helper] = (state->m_mmc_vrom_bank[mmc_helper] & (0xf0 >> shift)) | ((data & 0x0f) << shift);
11297      m_mmc_vrom_bank[mmc_helper] = (m_mmc_vrom_bank[mmc_helper] & (0xf0 >> shift)) | ((data & 0x0f) << shift);
1145911298      if (shift)
11460         state->m_mmc_extra_bank[mmc_helper] = data >> 4;
11299         m_mmc_extra_bank[mmc_helper] = data >> 4;
1146111300   }
1146211301   else
1146311302   {
1146411303      switch (offset)
1146511304      {
1146611305         case 0x0010:
11467            state->m_mmc_prg_bank[0] = data;
11306            m_mmc_prg_bank[0] = data;
1146811307            break;
1146911308         case 0x2010:
11470            state->m_mmc_prg_bank[1] = data;
11309            m_mmc_prg_bank[1] = data;
1147111310            break;
1147211311         case 0x1400:
1147311312            switch (data & 0x03)
1147411313            {
11475               case 0: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
11476               case 1: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
11477               case 2: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
11478               case 3: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
11314               case 0: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
11315               case 1: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
11316               case 2: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
11317               case 3: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
1147911318            }
1148011319            break;
1148111320         case 0x7000:
11482            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0xf0) | (data & 0x0f);
11321            m_IRQ_count_latch = (m_IRQ_count_latch & 0xf0) | (data & 0x0f);
1148311322            break;
1148411323         case 0x7004:
11485            state->m_IRQ_count_latch = (state->m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
11324            m_IRQ_count_latch = (m_IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4);
1148611325            break;
1148711326         case 0x7008:
11488            state->m_IRQ_enable = data & 0x03;
11489            if (state->m_IRQ_enable & 0x02)
11490               state->m_IRQ_count = state->m_IRQ_count_latch;
11327            m_IRQ_enable = data & 0x03;
11328            if (m_IRQ_enable & 0x02)
11329               m_IRQ_count = m_IRQ_count_latch;
1149111330            break;
1149211331      }
1149311332   }
11494   shjy3_update(space.machine());
11333   shjy3_update(machine());
1149511334}
1149611335
1149711336/*************************************************************
r18063r18064
1150411343
1150511344 *************************************************************/
1150611345
11507WRITE8_HANDLER( unl_6035052_extra_w )
11346WRITE8_MEMBER(nes_state::unl_6035052_extra_w)
1150811347{
11509   nes_state *state = space.machine().driver_data<nes_state>();
1151011348   LOG_MMC(("unl_6035052_extra_w, offset: %04x, data: %02x\n", offset, data));
11511   state->m_mmc_latch1 = data & 0x03;
11512   if (state->m_mmc_latch1 == 1)
11513      state->m_mmc_latch1 = 2;
11349   m_mmc_latch1 = data & 0x03;
11350   if (m_mmc_latch1 == 1)
11351      m_mmc_latch1 = 2;
1151411352}
1151511353
11516READ8_HANDLER( unl_6035052_extra_r )
11354READ8_MEMBER(nes_state::unl_6035052_extra_r)
1151711355{
11518   nes_state *state = space.machine().driver_data<nes_state>();
1151911356   LOG_MMC(("unl_6035052_extra_r, offset: %04x\n", offset));
11520   return state->m_mmc_latch1;
11357   return m_mmc_latch1;
1152111358}
1152211359
1152311360
r18063r18064
1157011407   state->m_mmc_chr_mask = BIT(state->m_mmc_reg[0], 7) ? 0x7f : 0xff;
1157111408}
1157211409
11573static WRITE8_HANDLER( pjoy84_m_w )
11410WRITE8_MEMBER(nes_state::pjoy84_m_w)
1157411411{
11575   nes_state *state = space.machine().driver_data<nes_state>();
1157611412   LOG_MMC(("pjoy84_m_w offset: %04x, data: %02x\n", offset, data));
1157711413
1157811414   switch (offset & 0x03)
1157911415   {
1158011416      case 0x00:
1158111417      case 0x03:
11582         if (state->m_mmc_reg[3] & 0x80)
11418         if (m_mmc_reg[3] & 0x80)
1158311419            return;   // else we act as if offset & 3 = 1,2
1158411420      case 0x01:
1158511421      case 0x02:
11586         state->m_mmc_reg[offset & 0x03] = data;
11587         pjoy84_set_base_mask(space.machine());
11588         if (state->m_mmc_reg[3] & 0x10)
11589            chr8(space.machine(), (state->m_mmc_chr_base >> 3) | (state->m_mmc_reg[2] & 0x0f), state->m_mmc_chr_source);
11422         m_mmc_reg[offset & 0x03] = data;
11423         pjoy84_set_base_mask(machine());
11424         if (m_mmc_reg[3] & 0x10)
11425            chr8(machine(), (m_mmc_chr_base >> 3) | (m_mmc_reg[2] & 0x0f), m_mmc_chr_source);
1159011426         else
11591            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
11592         mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
11427            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
11428         mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1159311429         break;
1159411430   }
1159511431}
r18063r18064
1165011486      chr8(machine, (state->m_mmc_reg[1] & 0x1f) >> 1, state->m_mmc_chr_source);
1165111487}
1165211488
11653static WRITE8_HANDLER( someri_mmc1_w )
11489WRITE8_MEMBER(nes_state::someri_mmc1_w)
1165411490{
11655   nes_state *state = space.machine().driver_data<nes_state>();
1165611491
11657   assert(state->m_mmc_cmd1 == 2);
11492   assert(m_mmc_cmd1 == 2);
1165811493
1165911494   if (data & 0x80)
1166011495   {
11661      state->m_mmc1_count = 0;
11662      state->m_mmc1_latch = 0;
11496      m_mmc1_count = 0;
11497      m_mmc1_latch = 0;
1166311498
11664      state->m_mmc_reg[0] |= 0x0c;
11665      someri_mmc1_set_prg(space.machine());
11499      m_mmc_reg[0] |= 0x0c;
11500      someri_mmc1_set_prg(machine());
1166611501      return;
1166711502   }
1166811503
11669   if (state->m_mmc1_count < 5)
11504   if (m_mmc1_count < 5)
1167011505   {
11671      if (state->m_mmc1_count == 0) state->m_mmc1_latch = 0;
11672      state->m_mmc1_latch >>= 1;
11673      state->m_mmc1_latch |= (data & 0x01) ? 0x10 : 0x00;
11674      state->m_mmc1_count++;
11506      if (m_mmc1_count == 0) m_mmc1_latch = 0;
11507      m_mmc1_latch >>= 1;
11508      m_mmc1_latch |= (data & 0x01) ? 0x10 : 0x00;
11509      m_mmc1_count++;
1167511510   }
1167611511
11677   if (state->m_mmc1_count == 5)
11512   if (m_mmc1_count == 5)
1167811513   {
1167911514      switch (offset & 0x6000)
1168011515      {
1168111516         case 0x0000:
11682            state->m_mmc_reg[0] = state->m_mmc1_latch;
11683            switch (state->m_mmc_reg[0] & 0x03)
11517            m_mmc_reg[0] = m_mmc1_latch;
11518            switch (m_mmc_reg[0] & 0x03)
1168411519            {
11685            case 0: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
11686            case 1: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
11687            case 2: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
11688            case 3: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
11520            case 0: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
11521            case 1: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
11522            case 2: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
11523            case 3: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
1168911524            }
11690            someri_mmc1_set_chr(space.machine());
11691            someri_mmc1_set_prg(space.machine());
11525            someri_mmc1_set_chr(machine());
11526            someri_mmc1_set_prg(machine());
1169211527            break;
1169311528         case 0x2000:
11694            state->m_mmc_reg[1] = state->m_mmc1_latch;
11695            someri_mmc1_set_chr(space.machine());
11696            someri_mmc1_set_prg(space.machine());
11529            m_mmc_reg[1] = m_mmc1_latch;
11530            someri_mmc1_set_chr(machine());
11531            someri_mmc1_set_prg(machine());
1169711532            break;
1169811533         case 0x4000:
11699            state->m_mmc_reg[2] = state->m_mmc1_latch;
11700            someri_mmc1_set_chr(space.machine());
11534            m_mmc_reg[2] = m_mmc1_latch;
11535            someri_mmc1_set_chr(machine());
1170111536            break;
1170211537         case 0x6000:
11703            state->m_mmc_reg[3] = state->m_mmc1_latch;
11704            someri_mmc1_set_prg(space.machine());
11538            m_mmc_reg[3] = m_mmc1_latch;
11539            someri_mmc1_set_prg(machine());
1170511540            break;
1170611541      }
1170711542
11708      state->m_mmc1_count = 0;
11543      m_mmc1_count = 0;
1170911544   }
1171011545}
1171111546
1171211547// MMC3 Mode emulation
11713static WRITE8_HANDLER( someri_mmc3_w )
11548WRITE8_MEMBER(nes_state::someri_mmc3_w)
1171411549{
11715   nes_state *state = space.machine().driver_data<nes_state>();
1171611550   UINT8 mmc_helper, cmd;
1171711551
11718   assert(state->m_mmc_cmd1 == 1);
11552   assert(m_mmc_cmd1 == 1);
1171911553   switch (offset & 0x6001)
1172011554   {
1172111555      case 0x0000:
11722         mmc_helper = state->m_mmc3_latch ^ data;
11723         state->m_mmc3_latch = data;
11556         mmc_helper = m_mmc3_latch ^ data;
11557         m_mmc3_latch = data;
1172411558
1172511559         if (mmc_helper & 0x40)
11726            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
11560            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1172711561
1172811562         if (mmc_helper & 0x80)
11729            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
11563            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1173011564         break;
1173111565
1173211566      case 0x0001:
11733         cmd = state->m_mmc3_latch & 0x07;
11567         cmd = m_mmc3_latch & 0x07;
1173411568         switch (cmd)
1173511569         {
1173611570         case 0: case 1:
1173711571         case 2: case 3: case 4: case 5:
11738            state->m_mmc_vrom_bank[cmd] = data;
11739            mmc3_set_chr(space.machine(), state->m_mmc_chr_source, state->m_mmc_chr_base, state->m_mmc_chr_mask);
11572            m_mmc_vrom_bank[cmd] = data;
11573            mmc3_set_chr(machine(), m_mmc_chr_source, m_mmc_chr_base, m_mmc_chr_mask);
1174011574            break;
1174111575         case 6:
1174211576         case 7:
11743            state->m_mmc_prg_bank[cmd - 6] = data;
11744            mmc3_set_prg(space.machine(), state->m_mmc_prg_base, state->m_mmc_prg_mask);
11577            m_mmc_prg_bank[cmd - 6] = data;
11578            mmc3_set_prg(machine(), m_mmc_prg_base, m_mmc_prg_mask);
1174511579            break;
1174611580         }
1174711581         break;
1174811582
1174911583      case 0x2000:
11750         set_nt_mirroring(space.machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
11584         set_nt_mirroring(machine(), BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1175111585         break;
1175211586      case 0x2001: break;
11753      case 0x4000: state->m_IRQ_count_latch = data; break;
11754      case 0x4001: state->m_IRQ_count = 0; break;
11755      case 0x6000: state->m_IRQ_enable = 0; break;
11756      case 0x6001: state->m_IRQ_enable = 1; break;
11587      case 0x4000: m_IRQ_count_latch = data; break;
11588      case 0x4001: m_IRQ_count = 0; break;
11589      case 0x6000: m_IRQ_enable = 0; break;
11590      case 0x6001: m_IRQ_enable = 1; break;
1175711591   }
1175811592}
1175911593
1176011594// VRC2 Mode emulation
11761static WRITE8_HANDLER( someri_vrc2_w )
11595WRITE8_MEMBER(nes_state::someri_vrc2_w)
1176211596{
11763   nes_state *state = space.machine().driver_data<nes_state>();
1176411597   UINT8 bank, shift;
1176511598
11766   assert(state->m_mmc_cmd1 == 0);
11599   assert(m_mmc_cmd1 == 0);
1176711600
1176811601   if (offset < 0x1000)
1176911602   {
11770      state->m_mmc_prg_bank[4] = data;
11771      prg8_89(space.machine(), state->m_mmc_prg_bank[4]);
11603      m_mmc_prg_bank[4] = data;
11604      prg8_89(machine(), m_mmc_prg_bank[4]);
1177211605   }
1177311606   else if (offset < 0x2000)
1177411607   {
1177511608      switch (data & 0x03)
1177611609      {
11777         case 0x00: set_nt_mirroring(space.machine(), PPU_MIRROR_VERT); break;
11778         case 0x01: set_nt_mirroring(space.machine(), PPU_MIRROR_HORZ); break;
11779         case 0x02: set_nt_mirroring(space.machine(), PPU_MIRROR_LOW); break;
11780         case 0x03: set_nt_mirroring(space.machine(), PPU_MIRROR_HIGH); break;
11610         case 0x00: set_nt_mirroring(machine(), PPU_MIRROR_VERT); break;
11611         case 0x01: set_nt_mirroring(machine(), PPU_MIRROR_HORZ); break;
11612         case 0x02: set_nt_mirroring(machine(), PPU_MIRROR_LOW); break;
11613         case 0x03: set_nt_mirroring(machine(), PPU_MIRROR_HIGH); break;
1178111614      }
1178211615   }
1178311616   else if (offset < 0x3000)
1178411617   {
11785      state->m_mmc_prg_bank[5] = data;
11786      prg8_ab(space.machine(), state->m_mmc_prg_bank[5]);
11618      m_mmc_prg_bank[5] = data;
11619      prg8_ab(machine(), m_mmc_prg_bank[5]);
1178711620   }
1178811621   else if (offset < 0x7000)
1178911622   {
1179011623      bank = ((offset & 0x7000) - 0x3000) / 0x0800 + BIT(offset, 1);
1179111624      shift = BIT(offset, 2) * 4;
1179211625      data = (data & 0x0f) << shift;
11793      state->m_mmc_vrom_bank[6 + bank] = data | state->m_mmc_chr_base;
11794      chr1_x(space.machine(), bank, state->m_mmc_vrom_bank[6 + bank], CHRROM);
11626      m_mmc_vrom_bank[6 + bank] = data | m_mmc_chr_base;
11627      chr1_x(machine(), bank, m_mmc_vrom_bank[6 + bank], CHRROM);
1179511628   }
1179611629}
1179711630
11798static WRITE8_HANDLER( someri_w )
11631WRITE8_MEMBER(nes_state::someri_w)
1179911632{
11800   nes_state *state = space.machine().driver_data<nes_state>();
11801   LOG_MMC(("someri_w mode %d, offset: %04x, data: %02x\n", state->m_mmc_cmd1, offset, data));
11633   LOG_MMC(("someri_w mode %d, offset: %04x, data: %02x\n", m_mmc_cmd1, offset, data));
1180211634
11803   switch (state->m_mmc_cmd1)
11635   switch (m_mmc_cmd1)
1180411636   {
1180511637      case 0x00: someri_vrc2_w(space, offset, data, mem_mask); break;
1180611638      case 0x01: someri_mmc3_w(space, offset, data, mem_mask); break;
r18063r18064
1183211664   }
1183311665}
1183411666
11835static WRITE8_HANDLER( someri_l_w )
11667WRITE8_MEMBER(nes_state::someri_l_w)
1183611668{
11837   nes_state *state = space.machine().driver_data<nes_state>();
1183811669   LOG_MMC(("someri_l_w, offset: %04x, data: %02x\n", offset, data));
1183911670   offset += 0x100;
1184011671
1184111672   if (offset & 0x100)
1184211673   {
11843      state->m_mmc_cmd1 = data & 0x03;
11844      state->m_mmc_chr_base = ((state->m_mmc_cmd1 & 0x04) << 6);
11845      if (state->m_mmc_cmd1 != 1)
11846         state->m_IRQ_enable = 0;
11847      someri_mode_update(space.machine());
11674      m_mmc_cmd1 = data & 0x03;
11675      m_mmc_chr_base = ((m_mmc_cmd1 & 0x04) << 6);
11676      if (m_mmc_cmd1 != 1)
11677         m_IRQ_enable = 0;
11678      someri_mode_update(machine());
1184811679   }
1184911680}
1185011681
r18063r18064
1185711688
1185811689 *************************************************************/
1185911690
11860static WRITE8_HANDLER( fujiya_m_w )
11691WRITE8_MEMBER(nes_state::fujiya_m_w)
1186111692{
11862   nes_state *state = space.machine().driver_data<nes_state>();
1186311693   LOG_MMC(("fujiya_m_w, offset: %04x, data: %02x\n", offset, data));
1186411694   offset += 0x6000;
1186511695
1186611696   if (offset == 0x6502 || offset == 0x7000)
11867      state->m_mmc_latch1 = (data & 0x40) << 1;
11697      m_mmc_latch1 = (data & 0x40) << 1;
1186811698}
1186911699
11870static READ8_HANDLER( fujiya_m_r )
11700READ8_MEMBER(nes_state::fujiya_m_r)
1187111701{
11872   nes_state *state = space.machine().driver_data<nes_state>();
1187311702   LOG_MMC(("fujiya_m_r, offset: %04x\n", offset));
1187411703   offset += 0x6000;
1187511704
1187611705   if (offset == 0x7001 || offset == 0x7777)
11877      return state->m_mmc_latch1 | ((offset >> 8) & 0x7f);
11706      return m_mmc_latch1 | ((offset >> 8) & 0x7f);
1187811707
1187911708   return 0;
1188011709}
r18063r18064
1188711716
1188811717struct nes_memory_accessor
1188911718{
11890   write8_space_func write;
11891   const char        *write_name;
11892   read8_space_func  read;
11893   const char        *read_name;
11719   write8_delegate    write;
11720   read8_delegate  read;
1189411721};
1189511722
1189611723struct nes_pcb_intf
r18063r18064
1190411731   ppu2c0x_hblank_cb      mmc_hblank;
1190511732};
1190611733
11734
1190711735#define NES_NOACCESS \
11908{FUNC_NULL, FUNC_NULL}
11736{write8_delegate(), read8_delegate()}
1190911737
1191011738#define NES_READONLY(a) \
11911{FUNC_NULL, FUNC(a)}
11739{write8_delegate(), read8_delegate(FUNC(a),(nes_state *)0)}
1191211740
1191311741#define NES_WRITEONLY(a) \
11914{FUNC(a), FUNC_NULL}
11742{write8_delegate(FUNC(a),(nes_state *)0), read8_delegate()}
1191511743
11916static WRITE8_HANDLER( dummy_l_w )
11744WRITE8_MEMBER(nes_state::dummy_l_w)
1191711745{
1191811746   logerror("write access, offset: %04x, data: %02x\n", offset + 0x4100, data);
1191911747}
1192011748
11921static WRITE8_HANDLER( dummy_m_w )
11749WRITE8_MEMBER(nes_state::dummy_m_w)
1192211750{
1192311751   logerror("write access, offset: %04x, data: %02x\n", offset + 0x6000, data);
1192411752}
1192511753
11926static WRITE8_HANDLER( dummy_w )
11754WRITE8_MEMBER(nes_state::dummy_w)
1192711755{
1192811756   logerror("write access, offset: %04x, data: %02x\n", offset + 0x8000, data);
1192911757}
1193011758
11931static READ8_HANDLER( dummy_l_r )
11759READ8_MEMBER(nes_state::dummy_l_r)
1193211760{
1193311761   logerror("read access, offset: %04x\n", offset + 0x4100);
1193411762   return 0x00;
1193511763}
1193611764
11937static READ8_HANDLER( dummy_m_r )
11765READ8_MEMBER(nes_state::dummy_m_r)
1193811766{
1193911767   logerror("read access, offset: %04x\n", offset + 0x6000);
1194011768   return 0x00;
1194111769}
1194211770
11943static READ8_HANDLER( dummy_r )
11771READ8_MEMBER(nes_state::dummy_r)
1194411772{
1194511773   logerror("read access, offset: %04x\n", offset + 0x8000);
1194611774   return 0x00;
r18063r18064
1195111779   { STD_NROM,             NES_NOACCESS, NES_NOACCESS, NES_NOACCESS,                         NULL, NULL, NULL },
1195211780   { HVC_FAMBASIC,         NES_NOACCESS, NES_NOACCESS, NES_NOACCESS,                         NULL, NULL, NULL },
1195311781   { GG_NROM,              NES_NOACCESS, NES_NOACCESS, NES_NOACCESS,                         NULL, NULL, NULL },
11954   { STD_UXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(uxrom_w),               NULL, NULL, NULL },
11955   { STD_UN1ROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(un1rom_w),              NULL, NULL, NULL },
11956   { STD_CPROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(cprom_w),               NULL, NULL, NULL },
11957   { STD_CNROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(cnrom_w),               NULL, NULL, NULL },
11958   { BANDAI_PT554,         NES_NOACCESS, NES_WRITEONLY(bandai_pt554_m_w), NES_WRITEONLY(cnrom_w), NULL, NULL, NULL },
11959   { STD_AXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(axrom_w),               NULL, NULL, NULL },
11960   { STD_PXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(pxrom_w),               mmc2_latch, NULL, NULL },
11961   { STD_FXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(fxrom_w),               mmc2_latch, NULL, NULL },
11962   { STD_BXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bxrom_w),               NULL, NULL, NULL },
11963   { STD_GXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(gxrom_w),               NULL, NULL, NULL },
11964   { STD_MXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(gxrom_w),               NULL, NULL, NULL },
11965   { STD_NXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ntbrom_w),              NULL, NULL, NULL },
11966   { SUNSOFT_DCS,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ntbrom_w),              NULL, NULL, NULL },
11967   { STD_JXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(jxrom_w),               NULL, NULL, jxrom_irq },
11968   { STD_SXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
11969   { STD_SOROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
11970   { STD_SXROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
11971   { STD_SOROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
11972   { STD_TXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
11973   { STD_TVROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
11974   { STD_TKROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
11975   { STD_HKROM,            NES_NOACCESS, {FUNC(hkrom_m_w), FUNC(hkrom_m_r)}, NES_WRITEONLY(hkrom_w),     NULL, NULL, mmc3_irq },
11976   { STD_TQROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tqrom_w),               NULL, NULL, mmc3_irq },
11977   { STD_TXSROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txsrom_w),              NULL, NULL, mmc3_irq },
11978   { STD_DXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w),               NULL, NULL, NULL },
11979   { STD_DRROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w),               NULL, NULL, NULL },
11980   { NAMCOT_34X3,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w),               NULL, NULL, NULL },
11981   { NAMCOT_3425,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(namcot3425_w),          NULL, NULL, NULL },
11982   { NAMCOT_3446,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(namcot3446_w),          NULL, NULL, NULL },
11983   { NAMCOT_3453,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(namcot3453_w),          NULL, NULL, NULL },
11984   { STD_EXROM,            {FUNC(exrom_l_w), FUNC(exrom_l_r)}, NES_NOACCESS, NES_NOACCESS,               NULL, NULL, mmc5_irq },
11985   { NES_QJ,               NES_NOACCESS, NES_WRITEONLY(qj_m_w), NES_WRITEONLY(txrom_w),      NULL, NULL, mmc3_irq },
11986   { PAL_ZZ,               NES_NOACCESS, NES_WRITEONLY(zz_m_w), NES_WRITEONLY(txrom_w),      NULL, NULL, mmc3_irq },
11987   { UXROM_CC,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(uxrom_cc_w),            NULL, NULL, NULL },
11782   { STD_UXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::uxrom_w),               NULL, NULL, NULL },
11783   { STD_UN1ROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::un1rom_w),              NULL, NULL, NULL },
11784   { STD_CPROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::cprom_w),               NULL, NULL, NULL },
11785   { STD_CNROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::cnrom_w),               NULL, NULL, NULL },
11786   { BANDAI_PT554,         NES_NOACCESS, NES_WRITEONLY(nes_state::bandai_pt554_m_w), NES_WRITEONLY(nes_state::cnrom_w), NULL, NULL, NULL },
11787   { STD_AXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::axrom_w),               NULL, NULL, NULL },
11788   { STD_PXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::pxrom_w),               mmc2_latch, NULL, NULL },
11789   { STD_FXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::fxrom_w),               mmc2_latch, NULL, NULL },
11790   { STD_BXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bxrom_w),               NULL, NULL, NULL },
11791   { STD_GXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::gxrom_w),               NULL, NULL, NULL },
11792   { STD_MXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::gxrom_w),               NULL, NULL, NULL },
11793   { STD_NXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ntbrom_w),              NULL, NULL, NULL },
11794   { SUNSOFT_DCS,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ntbrom_w),              NULL, NULL, NULL },
11795   { STD_JXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::jxrom_w),               NULL, NULL, jxrom_irq },
11796   { STD_SXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sxrom_w),               NULL, NULL, NULL },
11797   { STD_SOROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sxrom_w),               NULL, NULL, NULL },
11798   { STD_SXROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sxrom_w),               NULL, NULL, NULL },
11799   { STD_SOROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sxrom_w),               NULL, NULL, NULL },
11800   { STD_TXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },
11801   { STD_TVROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },
11802   { STD_TKROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },
11803   { STD_HKROM,            NES_NOACCESS, {write8_delegate(FUNC(nes_state::hkrom_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::hkrom_m_r),(nes_state *)0)}, NES_WRITEONLY(nes_state::hkrom_w),     NULL, NULL, mmc3_irq },
11804   { STD_TQROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tqrom_w),               NULL, NULL, mmc3_irq },
11805   { STD_TXSROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txsrom_w),              NULL, NULL, mmc3_irq },
11806   { STD_DXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::dxrom_w),               NULL, NULL, NULL },
11807   { STD_DRROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::dxrom_w),               NULL, NULL, NULL },
11808   { NAMCOT_34X3,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::dxrom_w),               NULL, NULL, NULL },
11809   { NAMCOT_3425,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::namcot3425_w),          NULL, NULL, NULL },
11810   { NAMCOT_3446,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::namcot3446_w),          NULL, NULL, NULL },
11811   { NAMCOT_3453,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::namcot3453_w),          NULL, NULL, NULL },
11812   { STD_EXROM,            {write8_delegate(FUNC(nes_state::exrom_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::exrom_l_r),(nes_state *)0)}, NES_NOACCESS, NES_NOACCESS,               NULL, NULL, mmc5_irq },
11813   { NES_QJ,               NES_NOACCESS, NES_WRITEONLY(nes_state::qj_m_w), NES_WRITEONLY(nes_state::txrom_w),      NULL, NULL, mmc3_irq },
11814   { PAL_ZZ,               NES_NOACCESS, NES_WRITEONLY(nes_state::zz_m_w), NES_WRITEONLY(nes_state::txrom_w),      NULL, NULL, mmc3_irq },
11815   { UXROM_CC,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::uxrom_cc_w),            NULL, NULL, NULL },
1198811816   //
11989   { DIS_74X139X74,        NES_NOACCESS, NES_WRITEONLY(dis_74x139x74_m_w), NES_NOACCESS,     NULL, NULL, NULL },
11990   { DIS_74X377,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dis_74x377_w),          NULL, NULL, NULL },
11991   { DIS_74X161X161X32,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dis_74x161x161x32_w),   NULL, NULL, NULL },
11992   { DIS_74X161X138,       NES_NOACCESS, NES_WRITEONLY(dis_74x161x138_m_w), NES_NOACCESS,    NULL, NULL, NULL },
11993   { BANDAI_LZ93,          NES_NOACCESS, NES_WRITEONLY(lz93d50_m_w), NES_WRITEONLY(lz93d50_w), NULL, NULL, bandai_lz_irq },
11994   { BANDAI_LZ93EX,        NES_NOACCESS, NES_WRITEONLY(lz93d50_m_w), NES_WRITEONLY(lz93d50_w), NULL, NULL, bandai_lz_irq },
11995   { BANDAI_FCG,           NES_NOACCESS, NES_WRITEONLY(lz93d50_m_w), NES_WRITEONLY(lz93d50_w), NULL, NULL, bandai_lz_irq },
11996   { BANDAI_DATACH,        NES_NOACCESS, NES_WRITEONLY(lz93d50_m_w), NES_WRITEONLY(lz93d50_w), NULL, NULL, bandai_lz_irq },
11997   { BANDAI_JUMP2,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(fjump2_w),              NULL, NULL, bandai_lz_irq },
11998   { BANDAI_KARAOKE,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bandai_ks_w),           NULL, NULL, NULL },
11999   { BANDAI_OEKAKIDS,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bandai_ok_w),           NULL, NULL, NULL },
12000   { IREM_G101,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(g101_w),                NULL, NULL, NULL },
12001   { IREM_LROG017,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(lrog017_w),             NULL, NULL, NULL },
12002   { IREM_H3001,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(h3001_w),               NULL, NULL, h3001_irq },
12003   { IREM_TAM_S1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tam_s1_w),              NULL, NULL, NULL },
12004   { IREM_HOLYDIV,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(irem_hd_w),             NULL, NULL, NULL },
12005   { JALECO_SS88006,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ss88006_w),             NULL, NULL, ss88006_irq },
12006   { JALECO_JF11,          NES_NOACCESS, NES_WRITEONLY(jf11_m_w), NES_NOACCESS,              NULL, NULL, NULL },
12007   { JALECO_JF13,          NES_NOACCESS, NES_WRITEONLY(jf13_m_w), NES_NOACCESS,              NULL, NULL, NULL },
12008   { JALECO_JF16,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(jf16_w),                NULL, NULL, NULL },
12009   { JALECO_JF17,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(jf17_w),                NULL, NULL, NULL },
12010   { JALECO_JF19,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(jf19_w),                NULL, NULL, NULL },
12011   { KONAMI_VRC1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc1_w),         NULL, NULL, NULL },
12012   { KONAMI_VRC2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc2_w),         NULL, NULL, NULL },
12013   { KONAMI_VRC3,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc3_w),         NULL, NULL, konami_irq },
12014   { KONAMI_VRC4,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc4_w),         NULL, NULL, konami_irq },
12015   { KONAMI_VRC6,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc6_w),         NULL, NULL, konami_irq },
12016   { KONAMI_VRC7,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(konami_vrc7_w),         NULL, NULL, konami_irq },
12017   { NAMCOT_163,           {FUNC(namcot163_l_w), FUNC(namcot163_l_r) }, NES_NOACCESS, NES_WRITEONLY(namcot163_w), NULL, NULL, namcot_irq },
12018   { SUNSOFT_1,            NES_NOACCESS, NES_WRITEONLY(sunsoft1_m_w), NES_NOACCESS,          NULL, NULL, NULL },
12019   { SUNSOFT_2,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sunsoft2_w),            NULL, NULL, NULL },
12020   { SUNSOFT_3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sunsoft3_w),            NULL, NULL, sunsoft3_irq },
12021   { TAITO_TC0190FMC,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tc0190fmc_w),           NULL, NULL, NULL },
12022   { TAITO_TC0190FMCP,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tc0190fmc_p16_w),       NULL, NULL, mmc3_irq },
12023   { TAITO_X1_005,         NES_NOACCESS, {FUNC(x1005_m_w), FUNC(x1005_m_r)}, NES_NOACCESS,               NULL, NULL, NULL },
12024   { TAITO_X1_005_A,       NES_NOACCESS, {FUNC(x1005a_m_w), FUNC(x1005_m_r)}, NES_NOACCESS,              NULL, NULL, NULL },
12025   { TAITO_X1_017,         NES_NOACCESS, {FUNC(x1017_m_w), FUNC(x1017_m_r)}, NES_NOACCESS,               NULL, NULL, NULL },
11817   { DIS_74X139X74,        NES_NOACCESS, NES_WRITEONLY(nes_state::dis_74x139x74_m_w), NES_NOACCESS,     NULL, NULL, NULL },
11818   { DIS_74X377,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::dis_74x377_w),          NULL, NULL, NULL },
11819   { DIS_74X161X161X32,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::dis_74x161x161x32_w),   NULL, NULL, NULL },
11820   { DIS_74X161X138,       NES_NOACCESS, NES_WRITEONLY(nes_state::dis_74x161x138_m_w), NES_NOACCESS,    NULL, NULL, NULL },
11821   { BANDAI_LZ93,          NES_NOACCESS, NES_WRITEONLY(nes_state::lz93d50_m_w), NES_WRITEONLY(nes_state::lz93d50_w), NULL, NULL, bandai_lz_irq },
11822   { BANDAI_LZ93EX,        NES_NOACCESS, NES_WRITEONLY(nes_state::lz93d50_m_w), NES_WRITEONLY(nes_state::lz93d50_w), NULL, NULL, bandai_lz_irq },
11823   { BANDAI_FCG,           NES_NOACCESS, NES_WRITEONLY(nes_state::lz93d50_m_w), NES_WRITEONLY(nes_state::lz93d50_w), NULL, NULL, bandai_lz_irq },
11824   { BANDAI_DATACH,        NES_NOACCESS, NES_WRITEONLY(nes_state::lz93d50_m_w), NES_WRITEONLY(nes_state::lz93d50_w), NULL, NULL, bandai_lz_irq },
11825   { BANDAI_JUMP2,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::fjump2_w),              NULL, NULL, bandai_lz_irq },
11826   { BANDAI_KARAOKE,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bandai_ks_w),           NULL, NULL, NULL },
11827   { BANDAI_OEKAKIDS,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bandai_ok_w),           NULL, NULL, NULL },
11828   { IREM_G101,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::g101_w),                NULL, NULL, NULL },
11829   { IREM_LROG017,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::lrog017_w),             NULL, NULL, NULL },
11830   { IREM_H3001,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::h3001_w),               NULL, NULL, h3001_irq },
11831   { IREM_TAM_S1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tam_s1_w),              NULL, NULL, NULL },
11832   { IREM_HOLYDIV,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::irem_hd_w),             NULL, NULL, NULL },
11833   { JALECO_SS88006,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ss88006_w),             NULL, NULL, ss88006_irq },
11834   { JALECO_JF11,          NES_NOACCESS, NES_WRITEONLY(nes_state::jf11_m_w), NES_NOACCESS,              NULL, NULL, NULL },
11835   { JALECO_JF13,          NES_NOACCESS, NES_WRITEONLY(nes_state::jf13_m_w), NES_NOACCESS,              NULL, NULL, NULL },
11836   { JALECO_JF16,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::jf16_w),                NULL, NULL, NULL },
11837   { JALECO_JF17,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::jf17_w),                NULL, NULL, NULL },
11838   { JALECO_JF19,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::jf19_w),                NULL, NULL, NULL },
11839   { KONAMI_VRC1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc1_w),         NULL, NULL, NULL },
11840   { KONAMI_VRC2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc2_w),         NULL, NULL, NULL },
11841   { KONAMI_VRC3,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc3_w),         NULL, NULL, konami_irq },
11842   { KONAMI_VRC4,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc4_w),         NULL, NULL, konami_irq },
11843   { KONAMI_VRC6,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc6_w),         NULL, NULL, konami_irq },
11844   { KONAMI_VRC7,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::konami_vrc7_w),         NULL, NULL, konami_irq },
11845   { NAMCOT_163,           {write8_delegate(FUNC(nes_state::namcot163_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::namcot163_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::namcot163_w), NULL, NULL, namcot_irq },
11846   { SUNSOFT_1,            NES_NOACCESS, NES_WRITEONLY(nes_state::sunsoft1_m_w), NES_NOACCESS,          NULL, NULL, NULL },
11847   { SUNSOFT_2,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sunsoft2_w),            NULL, NULL, NULL },
11848   { SUNSOFT_3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sunsoft3_w),            NULL, NULL, sunsoft3_irq },
11849   { TAITO_TC0190FMC,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tc0190fmc_w),           NULL, NULL, NULL },
11850   { TAITO_TC0190FMCP,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tc0190fmc_p16_w),       NULL, NULL, mmc3_irq },
11851   { TAITO_X1_005,         NES_NOACCESS, {write8_delegate(FUNC(nes_state::x1005_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::x1005_m_r),(nes_state *)0)}, NES_NOACCESS,               NULL, NULL, NULL },
11852   { TAITO_X1_005_A,       NES_NOACCESS, {write8_delegate(FUNC(nes_state::x1005a_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::x1005_m_r),(nes_state *)0)}, NES_NOACCESS,              NULL, NULL, NULL },
11853   { TAITO_X1_017,         NES_NOACCESS, {write8_delegate(FUNC(nes_state::x1017_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::x1017_m_r),(nes_state *)0)}, NES_NOACCESS,               NULL, NULL, NULL },
1202611854   //
12027   { AGCI_50282,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(agci_50282_w),          NULL, NULL, NULL },
12028   { ACTENT_ACT52,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ae_act52_w),            NULL, NULL, NULL },
12029   { AVE_NINA01,           NES_NOACCESS, NES_WRITEONLY(nina01_m_w), NES_NOACCESS,            NULL, NULL, NULL },
12030   { AVE_NINA06,           NES_WRITEONLY(nina06_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, NULL },
12031   { CNE_DECATHLON,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(cne_decathl_w),         NULL, NULL, NULL },
12032   { CNE_FSB,              NES_NOACCESS, NES_WRITEONLY(cne_fsb_m_w), NES_NOACCESS,           NULL, NULL, NULL },
12033   { CNE_SHLZ,             NES_WRITEONLY(cne_shlz_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, NULL },
12034   { CALTRON_6IN1,         NES_NOACCESS, NES_WRITEONLY(caltron6in1_m_w), NES_WRITEONLY(caltron6in1_w),      NULL, NULL, NULL },
12035   { CAMERICA_BF9093,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bf9093_w),              NULL, NULL, NULL },
12036   { CAMERICA_BF9097,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bf9093_w),              NULL, NULL, NULL },
12037   { CAMERICA_BF9096,      NES_NOACCESS, NES_WRITEONLY(bf9096_w), NES_WRITEONLY(bf9096_w),   NULL, NULL, NULL },
12038   { CAMERICA_GOLDENFIVE,  NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(golden5_w),             NULL, NULL, NULL },
12039   { CONY_BOARD,           {FUNC(cony_l_w), FUNC(cony_l_r)}, NES_NOACCESS, NES_WRITEONLY(cony_w),        NULL, NULL, sunsoft3_irq },
12040   { YOKO_BOARD,           {FUNC(yoko_l_w), FUNC(yoko_l_r)}, NES_NOACCESS, NES_WRITEONLY(yoko_w),        NULL, NULL, sunsoft3_irq },
12041   { DREAMTECH_BOARD,      NES_WRITEONLY(dreamtech_l_w), NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
12042   { FUTUREMEDIA_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(futuremedia_w),         NULL, NULL, futuremedia_irq },
12043   { FUKUTAKE_BOARD,       {FUNC(fukutake_l_w), FUNC(fukutake_l_r)}, NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
12044   { GOUDER_37017,         {FUNC(gouder_sf4_l_w), FUNC(gouder_sf4_l_r)}, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12045   { HENGEDIANZI_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(henggedianzi_w),        NULL, NULL, NULL },
12046   { HENGEDIANZI_XJZB,     NES_WRITEONLY(heng_xjzb_l_w), NES_NOACCESS, NES_WRITEONLY(heng_xjzb_w), NULL, NULL, NULL },
12047   { HES6IN1_BOARD,        NES_WRITEONLY(hes6in1_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
12048   { HES_BOARD,            NES_WRITEONLY(hes_l_w), NES_NOACCESS, NES_NOACCESS,               NULL, NULL, NULL },
12049   { HOSENKAN_BOARD,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(hosenkan_w),            NULL, NULL, mmc3_irq },
12050   { KAISER_KS7058,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks7058_w),              NULL, NULL, NULL },
12051   { KAISER_KS7022,        NES_NOACCESS, NES_NOACCESS, {FUNC(ks7022_w), FUNC(ks7022_r)},                 NULL, NULL, NULL },
12052   { KAISER_KS7032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks7032_w),              NULL, NULL, ks7032_irq },
12053   { KAISER_KS202,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks202_w),               NULL, NULL, ks7032_irq },
12054   { KAISER_KS7017,      NES_WRITEONLY(ks7017_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, mmc_fds_irq },
12055   { KAY_PANDAPRINCE,      {FUNC(kay_pp_l_w), FUNC(kay_pp_l_r)}, NES_NOACCESS, NES_WRITEONLY(kay_pp_w),  NULL, NULL, mmc3_irq },
12056   { KASING_BOARD,         NES_NOACCESS, NES_WRITEONLY(kasing_m_w), NES_WRITEONLY(txrom_w),  NULL, NULL, mmc3_irq },
12057   { SACHEN_74LS374,       {FUNC(sachen_74x374_l_w), FUNC(sachen_74x374_l_r)}, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL },
12058   { SACHEN_74LS374_A,     NES_WRITEONLY(sachen_74x374a_l_w), NES_NOACCESS, NES_NOACCESS,    NULL, NULL, NULL },
12059   { SACHEN_8259A,         NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
12060   { SACHEN_8259B,         NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
12061   { SACHEN_8259C,         NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
12062   { SACHEN_8259D,         NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
12063   { SACHEN_SA009,         NES_WRITEONLY(sa009_l_w), NES_NOACCESS, NES_NOACCESS,             NULL, NULL, NULL },
12064   { SACHEN_SA0036,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sa0036_w),              NULL, NULL, NULL },
12065   { SACHEN_SA0037,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sa0037_w),              NULL, NULL, NULL },
12066   { SACHEN_SA72007,       NES_WRITEONLY(sa72007_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
12067   { SACHEN_SA72008,       NES_WRITEONLY(sa72008_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
12068   { SACHEN_TCA01,         NES_READONLY(tca01_l_r), NES_NOACCESS, NES_NOACCESS,              NULL, NULL, NULL },
12069   { SACHEN_TCU01,         NES_WRITEONLY(tcu01_l_w), NES_WRITEONLY(tcu01_m_w), NES_WRITEONLY(tcu01_w), NULL, NULL, NULL },
12070   { SACHEN_TCU02,         {FUNC(tcu02_l_w), FUNC(tcu02_l_r)}, NES_NOACCESS, NES_NOACCESS,               NULL, NULL, NULL },
12071   { SUBOR_TYPE0,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(subor0_w),              NULL, NULL, NULL },
12072   { SUBOR_TYPE1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(subor1_w),              NULL, NULL, NULL },
12073   { MAGICSERIES_MD,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(magics_md_w),           NULL, NULL, NULL },
12074   { NANJING_BOARD,        {FUNC(nanjing_l_w), FUNC(nanjing_l_r)}, NES_NOACCESS, NES_NOACCESS,           NULL, NULL, nanjing_irq },
12075   { NITRA_TDA,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nitra_w),               NULL, NULL, mmc3_irq },
12076   { NTDEC_ASDER,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ntdec_asder_w),         NULL, NULL, NULL },
12077   { NTDEC_FIGHTINGHERO,   NES_NOACCESS, NES_WRITEONLY(ntdec_fh_m_w), NES_NOACCESS,          NULL, NULL, NULL },
12078   { OPENCORP_DAOU306,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(daou306_w),             NULL, NULL, NULL },
12079   { RCM_GS2015,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(gs2015_w),              NULL, NULL, NULL },
12080   { RCM_TETRISFAMILY,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rcm_tf_w),              NULL, NULL, NULL },
12081   { REXSOFT_DBZ5,         {FUNC(rex_dbz_l_w), FUNC(rex_dbz_l_r)}, NES_READONLY(rex_dbz_l_r), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12082   { REXSOFT_SL1632,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rex_sl1632_w),          NULL, NULL, mmc3_irq },
12083   { RUMBLESTATION_BOARD,  NES_NOACCESS, NES_WRITEONLY(rumblestation_m_w), NES_WRITEONLY(rumblestation_w),      NULL, NULL, NULL },
12084   { SOMERI_SL12,          NES_WRITEONLY(someri_l_w), NES_NOACCESS, NES_WRITEONLY(someri_w), NULL, NULL, mmc3_irq },
12085   { SUPERGAME_BOOGERMAN,  NES_WRITEONLY(sgame_boog_l_w), NES_WRITEONLY(sgame_boog_m_w), NES_WRITEONLY(sgame_boog_w), NULL, NULL, mmc3_irq },
12086   { SUPERGAME_LIONKING,   NES_NOACCESS, NES_WRITEONLY(sgame_lion_m_w), NES_WRITEONLY(sgame_lion_w), NULL, NULL, mmc3_irq },
12087   { TENGEN_800008,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800008_w),       NULL, NULL, NULL },
12088   { TENGEN_800032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800032_w),       NULL, NULL, tengen_800032_irq },
12089   { TENGEN_800037,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800037_w),       NULL, NULL, tengen_800032_irq },
12090   { TXC_22211A,           {FUNC(txc_22211_l_w), FUNC(txc_22211_l_r)}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
12091   { TXC_22211B,           {FUNC(txc_22211_l_w), FUNC(txc_22211_l_r)}, NES_NOACCESS, NES_WRITEONLY(txc_22211b_w), NULL, NULL, NULL },
12092   { TXC_22211C,           {FUNC(txc_22211_l_w), FUNC(txc_22211c_l_r)}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
12093   { TXC_TW,               NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12094   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w),      NULL, NULL, NULL },
12095   { TXC_MXMDHTWO,         NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL },
12096   { WAIXING_TYPE_A,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12097   { WAIXING_TYPE_A_1,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12098   { WAIXING_TYPE_B,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12099   { WAIXING_TYPE_C,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12100   { WAIXING_TYPE_D,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12101   { WAIXING_TYPE_E,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
12102   { WAIXING_TYPE_F,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_f_w),           NULL, NULL, mmc3_irq },
12103   { WAIXING_TYPE_G,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_g_w),           NULL, NULL, mmc3_irq },
12104   { WAIXING_TYPE_H,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_h_w),           NULL, NULL, mmc3_irq },
12105   { WAIXING_TYPE_I,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
12106   { WAIXING_TYPE_J,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
12107   { WAIXING_SGZ,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_sgz_w),         NULL, NULL, konami_irq },
12108   { WAIXING_SGZLZ,        NES_WRITEONLY(waixing_sgzlz_l_w), NES_NOACCESS, NES_NOACCESS,     NULL, NULL, NULL },
12109   { WAIXING_FFV,          NES_WRITEONLY(waixing_ffv_l_w), NES_NOACCESS, NES_NOACCESS,       NULL, NULL, NULL },
12110   { WAIXING_ZS,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_zs_w),          NULL, NULL, NULL },
12111   { WAIXING_DQ8,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_dq8_w),         NULL, NULL, NULL },
12112   { WAIXING_SECURITY,     NES_WRITEONLY(waixing_sec_l_w), NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12113   { WAIXING_SH2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
12114   { WAIXING_PS2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_ps2_w),         NULL, NULL, NULL },
12115   { UNL_8237,             NES_WRITEONLY(unl_8237_l_w), NES_NOACCESS, NES_WRITEONLY(unl_8237_w),      NULL, NULL, mmc3_irq },
12116   { UNL_AX5705,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_ax5705_w),          NULL, NULL, NULL },
12117   { UNL_CC21,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_cc21_w),            NULL, NULL, NULL },
12118   { UNL_KOF97,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_kof97_w),           NULL, NULL, mmc3_irq },
12119   { UNL_KS7057,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks7057_w),              NULL, NULL, mmc3_irq },
12120   { UNL_T230,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_t230_w),            NULL, NULL, konami_irq },
12121   { UNL_KOF96,            {FUNC(kof96_l_w), FUNC(kof96_l_r)}, NES_NOACCESS, NES_WRITEONLY(kof96_w),     NULL, NULL, mmc3_irq },
12122   { UNL_MK2,              NES_NOACCESS, NES_WRITEONLY(mk2_m_w), NES_NOACCESS,               NULL, NULL, mmc3_irq },
12123   { UNL_N625092,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(n625092_w),             NULL, NULL, NULL },
12124   { UNL_SC127,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sc127_w),               NULL, NULL, sc127_irq },
12125   { UNL_SMB2J,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(smb2j_w),               NULL, NULL, NULL },
12126   { UNL_SUPERFIGHTER3,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_sf3_w),             NULL, NULL, mmc3_irq },
12127   { UNL_XZY,              NES_WRITEONLY(unl_xzy_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
12128   { UNL_RACERMATE,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_racmate_w),         NULL, NULL, NULL },
12129   { UNL_STUDYNGAME,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sng32_w),               NULL, NULL, NULL },
12130   { UNL_603_5052,         {FUNC(unl_6035052_extra_w), FUNC(unl_6035052_extra_r)}, {FUNC(unl_6035052_extra_w), FUNC(unl_6035052_extra_r)}, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12131   { UNL_EDU2K,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(edu2k_w),               NULL, NULL, NULL },
12132   { UNL_SHJY3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(shjy3_w),               NULL, NULL, shjy3_irq },
12133   { UNL_H2288,            {FUNC(h2288_l_w), FUNC(h2288_l_r)}, NES_NOACCESS, NES_WRITEONLY(h2288_w),     NULL, NULL, mmc3_irq },
12134   { UNL_FS304,            NES_WRITEONLY(unl_fs304_l_w), NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
11855   { AGCI_50282,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::agci_50282_w),          NULL, NULL, NULL },
11856   { ACTENT_ACT52,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ae_act52_w),            NULL, NULL, NULL },
11857   { AVE_NINA01,           NES_NOACCESS, NES_WRITEONLY(nes_state::nina01_m_w), NES_NOACCESS,            NULL, NULL, NULL },
11858   { AVE_NINA06,           NES_WRITEONLY(nes_state::nina06_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, NULL },
11859   { CNE_DECATHLON,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::cne_decathl_w),         NULL, NULL, NULL },
11860   { CNE_FSB,              NES_NOACCESS, NES_WRITEONLY(nes_state::cne_fsb_m_w), NES_NOACCESS,           NULL, NULL, NULL },
11861   { CNE_SHLZ,             NES_WRITEONLY(nes_state::cne_shlz_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, NULL },
11862   { CALTRON_6IN1,         NES_NOACCESS, NES_WRITEONLY(nes_state::caltron6in1_m_w), NES_WRITEONLY(nes_state::caltron6in1_w),      NULL, NULL, NULL },
11863   { CAMERICA_BF9093,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bf9093_w),              NULL, NULL, NULL },
11864   { CAMERICA_BF9097,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bf9093_w),              NULL, NULL, NULL },
11865   { CAMERICA_BF9096,      NES_NOACCESS, NES_WRITEONLY(nes_state::bf9096_w), NES_WRITEONLY(nes_state::bf9096_w),   NULL, NULL, NULL },
11866   { CAMERICA_GOLDENFIVE,  NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::golden5_w),             NULL, NULL, NULL },
11867   { CONY_BOARD,           {write8_delegate(FUNC(nes_state::cony_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::cony_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::cony_w),        NULL, NULL, sunsoft3_irq },
11868   { YOKO_BOARD,           {write8_delegate(FUNC(nes_state::yoko_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::yoko_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::yoko_w),        NULL, NULL, sunsoft3_irq },
11869   { DREAMTECH_BOARD,      NES_WRITEONLY(nes_state::dreamtech_l_w), NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
11870   { FUTUREMEDIA_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::futuremedia_w),         NULL, NULL, futuremedia_irq },
11871   { FUKUTAKE_BOARD,       {write8_delegate(FUNC(nes_state::fukutake_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::fukutake_l_r),(nes_state *)0)}, NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
11872   { GOUDER_37017,         {write8_delegate(FUNC(nes_state::gouder_sf4_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::gouder_sf4_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
11873   { HENGEDIANZI_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::henggedianzi_w),        NULL, NULL, NULL },
11874   { HENGEDIANZI_XJZB,     NES_WRITEONLY(nes_state::heng_xjzb_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::heng_xjzb_w), NULL, NULL, NULL },
11875   { HES6IN1_BOARD,        NES_WRITEONLY(nes_state::hes6in1_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
11876   { HES_BOARD,            NES_WRITEONLY(nes_state::hes_l_w), NES_NOACCESS, NES_NOACCESS,               NULL, NULL, NULL },
11877   { HOSENKAN_BOARD,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::hosenkan_w),            NULL, NULL, mmc3_irq },
11878   { KAISER_KS7058,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ks7058_w),              NULL, NULL, NULL },
11879   { KAISER_KS7022,        NES_NOACCESS, NES_NOACCESS, {write8_delegate(FUNC(nes_state::ks7022_w),(nes_state *)0), read8_delegate(FUNC(nes_state::ks7022_r),(nes_state *)0)},                 NULL, NULL, NULL },
11880   { KAISER_KS7032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ks7032_w),              NULL, NULL, ks7032_irq },
11881   { KAISER_KS202,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ks202_w),               NULL, NULL, ks7032_irq },
11882   { KAISER_KS7017,      NES_WRITEONLY(nes_state::ks7017_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, mmc_fds_irq },
11883   { KAY_PANDAPRINCE,      {write8_delegate(FUNC(nes_state::kay_pp_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::kay_pp_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::kay_pp_w),  NULL, NULL, mmc3_irq },
11884   { KASING_BOARD,         NES_NOACCESS, NES_WRITEONLY(nes_state::kasing_m_w), NES_WRITEONLY(nes_state::txrom_w),  NULL, NULL, mmc3_irq },
11885   { SACHEN_74LS374,       {write8_delegate(FUNC(nes_state::sachen_74x374_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::sachen_74x374_l_r),(nes_state *)0)}, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL },
11886   { SACHEN_74LS374_A,     NES_WRITEONLY(nes_state::sachen_74x374a_l_w), NES_NOACCESS, NES_NOACCESS,    NULL, NULL, NULL },
11887   { SACHEN_8259A,         NES_WRITEONLY(nes_state::s8259_l_w), NES_WRITEONLY(nes_state::s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
11888   { SACHEN_8259B,         NES_WRITEONLY(nes_state::s8259_l_w), NES_WRITEONLY(nes_state::s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
11889   { SACHEN_8259C,         NES_WRITEONLY(nes_state::s8259_l_w), NES_WRITEONLY(nes_state::s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
11890   { SACHEN_8259D,         NES_WRITEONLY(nes_state::s8259_l_w), NES_WRITEONLY(nes_state::s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
11891   { SACHEN_SA009,         NES_WRITEONLY(nes_state::sa009_l_w), NES_NOACCESS, NES_NOACCESS,             NULL, NULL, NULL },
11892   { SACHEN_SA0036,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sa0036_w),              NULL, NULL, NULL },
11893   { SACHEN_SA0037,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sa0037_w),              NULL, NULL, NULL },
11894   { SACHEN_SA72007,       NES_WRITEONLY(nes_state::sa72007_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
11895   { SACHEN_SA72008,       NES_WRITEONLY(nes_state::sa72008_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
11896   { SACHEN_TCA01,         NES_READONLY(nes_state::tca01_l_r), NES_NOACCESS, NES_NOACCESS,              NULL, NULL, NULL },
11897   { SACHEN_TCU01,         NES_WRITEONLY(nes_state::tcu01_l_w), NES_WRITEONLY(nes_state::tcu01_m_w), NES_WRITEONLY(nes_state::tcu01_w), NULL, NULL, NULL },
11898   { SACHEN_TCU02,         {write8_delegate(FUNC(nes_state::tcu02_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::tcu02_l_r),(nes_state *)0)}, NES_NOACCESS, NES_NOACCESS,               NULL, NULL, NULL },
11899   { SUBOR_TYPE0,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::subor0_w),              NULL, NULL, NULL },
11900   { SUBOR_TYPE1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::subor1_w),              NULL, NULL, NULL },
11901   { MAGICSERIES_MD,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::magics_md_w),           NULL, NULL, NULL },
11902   { NANJING_BOARD,        {write8_delegate(FUNC(nes_state::nanjing_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::nanjing_l_r),(nes_state *)0)}, NES_NOACCESS, NES_NOACCESS,           NULL, NULL, nanjing_irq },
11903   { NITRA_TDA,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::nitra_w),               NULL, NULL, mmc3_irq },
11904   { NTDEC_ASDER,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ntdec_asder_w),         NULL, NULL, NULL },
11905   { NTDEC_FIGHTINGHERO,   NES_NOACCESS, NES_WRITEONLY(nes_state::ntdec_fh_m_w), NES_NOACCESS,          NULL, NULL, NULL },
11906   { OPENCORP_DAOU306,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::daou306_w),             NULL, NULL, NULL },
11907   { RCM_GS2015,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::gs2015_w),              NULL, NULL, NULL },
11908   { RCM_TETRISFAMILY,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::rcm_tf_w),              NULL, NULL, NULL },
11909   { REXSOFT_DBZ5,         {write8_delegate(FUNC(nes_state::rex_dbz_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::rex_dbz_l_r),(nes_state *)0)}, NES_READONLY(nes_state::rex_dbz_l_r), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
11910   { REXSOFT_SL1632,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::rex_sl1632_w),          NULL, NULL, mmc3_irq },
11911   { RUMBLESTATION_BOARD,  NES_NOACCESS, NES_WRITEONLY(nes_state::rumblestation_m_w), NES_WRITEONLY(nes_state::rumblestation_w),      NULL, NULL, NULL },
11912   { SOMERI_SL12,          NES_WRITEONLY(nes_state::someri_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::someri_w), NULL, NULL, mmc3_irq },
11913   { SUPERGAME_BOOGERMAN,  NES_WRITEONLY(nes_state::sgame_boog_l_w), NES_WRITEONLY(nes_state::sgame_boog_m_w), NES_WRITEONLY(nes_state::sgame_boog_w), NULL, NULL, mmc3_irq },
11914   { SUPERGAME_LIONKING,   NES_NOACCESS, NES_WRITEONLY(nes_state::sgame_lion_m_w), NES_WRITEONLY(nes_state::sgame_lion_w), NULL, NULL, mmc3_irq },
11915   { TENGEN_800008,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tengen_800008_w),       NULL, NULL, NULL },
11916   { TENGEN_800032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tengen_800032_w),       NULL, NULL, tengen_800032_irq },
11917   { TENGEN_800037,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::tengen_800037_w),       NULL, NULL, tengen_800032_irq },
11918   { TXC_22211A,           {write8_delegate(FUNC(nes_state::txc_22211_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::txc_22211_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::txc_22211_w), NULL, NULL, NULL },
11919   { TXC_22211B,           {write8_delegate(FUNC(nes_state::txc_22211_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::txc_22211_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::txc_22211b_w), NULL, NULL, NULL },
11920   { TXC_22211C,           {write8_delegate(FUNC(nes_state::txc_22211_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::txc_22211c_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::txc_22211_w), NULL, NULL, NULL },
11921   { TXC_TW,               NES_WRITEONLY(nes_state::txc_tw_l_w), NES_WRITEONLY(nes_state::txc_tw_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
11922   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txc_strikewolf_w),      NULL, NULL, NULL },
11923   { TXC_MXMDHTWO,         NES_READONLY(nes_state::txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(nes_state::txc_mxmdhtwo_w), NULL, NULL, NULL },
11924   { WAIXING_TYPE_A,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11925   { WAIXING_TYPE_A_1,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11926   { WAIXING_TYPE_B,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11927   { WAIXING_TYPE_C,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11928   { WAIXING_TYPE_D,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11929   { WAIXING_TYPE_E,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_a_w),           NULL, NULL, mmc3_irq },
11930   { WAIXING_TYPE_F,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_f_w),           NULL, NULL, mmc3_irq },
11931   { WAIXING_TYPE_G,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_g_w),           NULL, NULL, mmc3_irq },
11932   { WAIXING_TYPE_H,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_h_w),           NULL, NULL, mmc3_irq },
11933   { WAIXING_TYPE_I,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
11934   { WAIXING_TYPE_J,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
11935   { WAIXING_SGZ,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_sgz_w),         NULL, NULL, konami_irq },
11936   { WAIXING_SGZLZ,        NES_WRITEONLY(nes_state::waixing_sgzlz_l_w), NES_NOACCESS, NES_NOACCESS,     NULL, NULL, NULL },
11937   { WAIXING_FFV,          NES_WRITEONLY(nes_state::waixing_ffv_l_w), NES_NOACCESS, NES_NOACCESS,       NULL, NULL, NULL },
11938   { WAIXING_ZS,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_zs_w),          NULL, NULL, NULL },
11939   { WAIXING_DQ8,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_dq8_w),         NULL, NULL, NULL },
11940   { WAIXING_SECURITY,     NES_WRITEONLY(nes_state::waixing_sec_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
11941   { WAIXING_SH2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w),               NULL, NULL, mmc3_irq },   // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff
11942   { WAIXING_PS2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::waixing_ps2_w),         NULL, NULL, NULL },
11943   { UNL_8237,             NES_WRITEONLY(nes_state::unl_8237_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::unl_8237_w),      NULL, NULL, mmc3_irq },
11944   { UNL_AX5705,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_ax5705_w),          NULL, NULL, NULL },
11945   { UNL_CC21,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_cc21_w),            NULL, NULL, NULL },
11946   { UNL_KOF97,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_kof97_w),           NULL, NULL, mmc3_irq },
11947   { UNL_KS7057,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::ks7057_w),              NULL, NULL, mmc3_irq },
11948   { UNL_T230,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_t230_w),            NULL, NULL, konami_irq },
11949   { UNL_KOF96,            {write8_delegate(FUNC(nes_state::kof96_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::kof96_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::kof96_w),     NULL, NULL, mmc3_irq },
11950   { UNL_MK2,              NES_NOACCESS, NES_WRITEONLY(nes_state::mk2_m_w), NES_NOACCESS,               NULL, NULL, mmc3_irq },
11951   { UNL_N625092,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::n625092_w),             NULL, NULL, NULL },
11952   { UNL_SC127,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sc127_w),               NULL, NULL, sc127_irq },
11953   { UNL_SMB2J,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::smb2j_w),               NULL, NULL, NULL },
11954   { UNL_SUPERFIGHTER3,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_sf3_w),             NULL, NULL, mmc3_irq },
11955   { UNL_XZY,              NES_WRITEONLY(nes_state::unl_xzy_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
11956   { UNL_RACERMATE,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::unl_racmate_w),         NULL, NULL, NULL },
11957   { UNL_STUDYNGAME,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::sng32_w),               NULL, NULL, NULL },
11958   { UNL_603_5052,         {write8_delegate(FUNC(nes_state::unl_6035052_extra_w),(nes_state *)0), read8_delegate(FUNC(nes_state::unl_6035052_extra_r),(nes_state *)0)}, {write8_delegate(FUNC(nes_state::unl_6035052_extra_w),(nes_state *)0), read8_delegate(FUNC(nes_state::unl_6035052_extra_r),(nes_state *)0)}, NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
11959   { UNL_EDU2K,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::edu2k_w),               NULL, NULL, NULL },
11960   { UNL_SHJY3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::shjy3_w),               NULL, NULL, shjy3_irq },
11961   { UNL_H2288,            {write8_delegate(FUNC(nes_state::h2288_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::h2288_l_r),(nes_state *)0)}, NES_NOACCESS, NES_WRITEONLY(nes_state::h2288_w),     NULL, NULL, mmc3_irq },
11962   { UNL_FS304,            NES_WRITEONLY(nes_state::unl_fs304_l_w), NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
1213511963   //
12136   { BTL_AISENSHINICOL,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_mariobaby_w),       NULL, NULL, NULL },
12137   { BTL_DRAGONNINJA,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_dn_w),              NULL, NULL, btl_dn_irq },
12138   { BTL_MARIOBABY,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_mariobaby_w),       NULL, NULL, NULL },
12139   { BTL_SMB2A,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb2a_w),           NULL, NULL, btl_smb2a_irq },
12140   { BTL_SMB2B,            NES_WRITEONLY(smb2jb_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, smb2jb_irq },
12141   { BTL_SMB3,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb3_w),            NULL, NULL, btl_smb3_irq },
12142   { BTL_SUPERBROS11,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb11_w),           NULL, NULL, mmc3_irq },
12143   { BTL_TOBIDASE,         NES_WRITEONLY(btl_tobi_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, NULL },
12144   { BTL_PIKACHUY2K,       NES_NOACCESS, {FUNC(btl_pika_y2k_m_w), FUNC(btl_pika_y2k_m_r)}, NES_WRITEONLY(btl_pika_y2k_w),  NULL, NULL, mmc3_irq },
12145   { WHIRLWIND_2706,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(whirl2706_w),           NULL, NULL, NULL },
11964   { BTL_AISENSHINICOL,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_mariobaby_w),       NULL, NULL, NULL },
11965   { BTL_DRAGONNINJA,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_dn_w),              NULL, NULL, btl_dn_irq },
11966   { BTL_MARIOBABY,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_mariobaby_w),       NULL, NULL, NULL },
11967   { BTL_SMB2A,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_smb2a_w),           NULL, NULL, btl_smb2a_irq },
11968   { BTL_SMB2B,            NES_WRITEONLY(nes_state::smb2jb_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, smb2jb_irq },
11969   { BTL_SMB3,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_smb3_w),            NULL, NULL, btl_smb3_irq },
11970   { BTL_SUPERBROS11,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::btl_smb11_w),           NULL, NULL, mmc3_irq },
11971   { BTL_TOBIDASE,         NES_WRITEONLY(nes_state::btl_tobi_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, NULL },
11972   { BTL_PIKACHUY2K,       NES_NOACCESS, {write8_delegate(FUNC(nes_state::btl_pika_y2k_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::btl_pika_y2k_m_r),(nes_state *)0)}, NES_WRITEONLY(nes_state::btl_pika_y2k_w),  NULL, NULL, mmc3_irq },
11973   { WHIRLWIND_2706,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::whirl2706_w),           NULL, NULL, NULL },
1214611974   //
12147   { BMC_190IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_190in1_w),          NULL, NULL, NULL },
12148   { BMC_A65AS,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_a65as_w),           NULL, NULL, NULL },
12149   { BMC_GS2004,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_gs2004_w),          NULL, NULL, NULL },
12150   { BMC_GS2013,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_gs2013_w),          NULL, NULL, NULL },
12151   { BMC_NOVELDIAMOND,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(novel1_w),              NULL, NULL, NULL },
12152   { BMC_9999999IN1,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(novel2_w),              NULL, NULL, NULL },
12153   { BMC_T262,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_t262_w),            NULL, NULL, NULL },
12154   { BMC_WS,               NES_NOACCESS, NES_WRITEONLY(bmc_ws_m_w), NES_NOACCESS,            NULL, NULL, NULL },
12155   { BMC_GKA,              NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_gka_w),             NULL, NULL, NULL },
12156   { BMC_GKB,              NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_gkb_w),             NULL, NULL, NULL },
12157   { BMC_SUPER_700IN1,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_super700in1_w),     NULL, NULL, NULL },
12158   { BMC_36IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_36in1_w),           NULL, NULL, NULL },
12159   { BMC_21IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_21in1_w),           NULL, NULL, NULL },
12160   { BMC_150IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_150in1_w),          NULL, NULL, NULL },
12161   { BMC_35IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_35in1_w),           NULL, NULL, NULL },
12162   { BMC_64IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_64in1_w),           NULL, NULL, NULL },
12163   { BMC_SUPERHIK_300IN1,  NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_hik300_w),          NULL, NULL, NULL },
12164   { BMC_SUPERGUN_20IN1,   NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(supergun20in1_w),       NULL, NULL, NULL },
12165   { BMC_72IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_72in1_w),           NULL, NULL, NULL },
12166   { BMC_76IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_76in1_w),           NULL, NULL, NULL },
12167   { BMC_SUPER_42IN1,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_76in1_w),           NULL, NULL, NULL },
12168   { BMC_1200IN1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_1200in1_w),         NULL, NULL, NULL },
12169   { BMC_31IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_31in1_w),           NULL, NULL, NULL },
12170   { BMC_22GAMES,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_22g_w),             NULL, NULL, NULL },
12171   { BMC_20IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_20in1_w),           NULL, NULL, NULL },
12172   { BMC_110IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_110in1_w),          NULL, NULL, NULL },
12173   { BMC_64IN1NR,          NES_WRITEONLY(bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_64in1nr_w), NULL, NULL, NULL },
12174   { BMC_S24IN1SC03,       NES_WRITEONLY(bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12175   { BMC_HIK8IN1,          NES_NOACCESS, NES_WRITEONLY(bmc_hik8_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12176   { BMC_SUPERHIK_4IN1,    NES_NOACCESS, NES_WRITEONLY(bmc_hik4in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12177   { BMC_SUPERBIG_7IN1,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_sbig7_w),           NULL, NULL, mmc3_irq },
12178   { BMC_MARIOPARTY_7IN1,  NES_NOACCESS, NES_WRITEONLY(bmc_mario7in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12179   { BMC_GOLD_7IN1,        NES_NOACCESS, NES_WRITEONLY(bmc_gold7in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12180   { BMC_FAMILY_4646B,     NES_NOACCESS, NES_WRITEONLY(bmc_family4646_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12181   { BMC_15IN1,            NES_NOACCESS, NES_WRITEONLY(bmc_15in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
12182   { BMC_BALLGAMES_11IN1,  NES_NOACCESS, NES_WRITEONLY(bmc_ball11_m_w), NES_WRITEONLY(bmc_ball11_w), NULL, NULL, NULL },
12183   { BMC_GOLDENCARD_6IN1,  NES_WRITEONLY(bmc_gc6in1_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_gc6in1_w), NULL, NULL, mmc3_irq },
12184   { BMC_VT5201,           NES_NOACCESS, NES_NOACCESS, {FUNC(bmc_vt5201_w), FUNC(bmc_vt5201_r)},         NULL, NULL, NULL },
12185   { BMC_BENSHENG_BS5,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_bs5_w),             NULL, NULL, NULL },
12186   { BMC_810544,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_810544_w),          NULL, NULL, NULL },
12187   { BMC_NTD_03,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_ntd03_w),           NULL, NULL, NULL },
12188   { BMC_G63IN1,           NES_NOACCESS, NES_NOACCESS, {FUNC(bmc_gb63_w), FUNC(bmc_gb63_r)},             NULL, NULL, NULL },
12189   { BMC_FK23C,            NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w),   NULL, NULL, mmc3_irq },
12190   { BMC_FK23CA,           NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w),   NULL, NULL, mmc3_irq },
12191   { BMC_PJOY84,           NES_NOACCESS, NES_WRITEONLY(pjoy84_m_w), NES_WRITEONLY(txrom_w),  NULL, NULL, mmc3_irq },
11975   { BMC_190IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_190in1_w),          NULL, NULL, NULL },
11976   { BMC_A65AS,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_a65as_w),           NULL, NULL, NULL },
11977   { BMC_GS2004,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gs2004_w),          NULL, NULL, NULL },
11978   { BMC_GS2013,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gs2013_w),          NULL, NULL, NULL },
11979   { BMC_NOVELDIAMOND,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::novel1_w),              NULL, NULL, NULL },
11980   { BMC_9999999IN1,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::novel2_w),              NULL, NULL, NULL },
11981   { BMC_T262,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_t262_w),            NULL, NULL, NULL },
11982   { BMC_WS,               NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_ws_m_w), NES_NOACCESS,            NULL, NULL, NULL },
11983   { BMC_GKA,              NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gka_w),             NULL, NULL, NULL },
11984   { BMC_GKB,              NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gkb_w),             NULL, NULL, NULL },
11985   { BMC_SUPER_700IN1,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_super700in1_w),     NULL, NULL, NULL },
11986   { BMC_36IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_36in1_w),           NULL, NULL, NULL },
11987   { BMC_21IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_21in1_w),           NULL, NULL, NULL },
11988   { BMC_150IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_150in1_w),          NULL, NULL, NULL },
11989   { BMC_35IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_35in1_w),           NULL, NULL, NULL },
11990   { BMC_64IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_64in1_w),           NULL, NULL, NULL },
11991   { BMC_SUPERHIK_300IN1,  NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_hik300_w),          NULL, NULL, NULL },
11992   { BMC_SUPERGUN_20IN1,   NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::supergun20in1_w),       NULL, NULL, NULL },
11993   { BMC_72IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_72in1_w),           NULL, NULL, NULL },
11994   { BMC_76IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_76in1_w),           NULL, NULL, NULL },
11995   { BMC_SUPER_42IN1,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_76in1_w),           NULL, NULL, NULL },
11996   { BMC_1200IN1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_1200in1_w),         NULL, NULL, NULL },
11997   { BMC_31IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_31in1_w),           NULL, NULL, NULL },
11998   { BMC_22GAMES,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_22g_w),             NULL, NULL, NULL },
11999   { BMC_20IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_20in1_w),           NULL, NULL, NULL },
12000   { BMC_110IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_110in1_w),          NULL, NULL, NULL },
12001   { BMC_64IN1NR,          NES_WRITEONLY(nes_state::bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_64in1nr_w), NULL, NULL, NULL },
12002   { BMC_S24IN1SC03,       NES_WRITEONLY(nes_state::bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12003   { BMC_HIK8IN1,          NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_hik8_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12004   { BMC_SUPERHIK_4IN1,    NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_hik4in1_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12005   { BMC_SUPERBIG_7IN1,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_sbig7_w),           NULL, NULL, mmc3_irq },
12006   { BMC_MARIOPARTY_7IN1,  NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_mario7in1_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12007   { BMC_GOLD_7IN1,        NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gold7in1_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12008   { BMC_FAMILY_4646B,     NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_family4646_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12009   { BMC_15IN1,            NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_15in1_m_w), NES_WRITEONLY(nes_state::txrom_w), NULL, NULL, mmc3_irq },
12010   { BMC_BALLGAMES_11IN1,  NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_ball11_m_w), NES_WRITEONLY(nes_state::bmc_ball11_w), NULL, NULL, NULL },
12011   { BMC_GOLDENCARD_6IN1,  NES_WRITEONLY(nes_state::bmc_gc6in1_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_gc6in1_w), NULL, NULL, mmc3_irq },
12012   { BMC_VT5201,           NES_NOACCESS, NES_NOACCESS, {write8_delegate(FUNC(nes_state::bmc_vt5201_w),(nes_state *)0), read8_delegate(FUNC(nes_state::bmc_vt5201_r),(nes_state *)0)},         NULL, NULL, NULL },
12013   { BMC_BENSHENG_BS5,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_bs5_w),             NULL, NULL, NULL },
12014   { BMC_810544,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_810544_w),          NULL, NULL, NULL },
12015   { BMC_NTD_03,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::bmc_ntd03_w),           NULL, NULL, NULL },
12016   { BMC_G63IN1,           NES_NOACCESS, NES_NOACCESS, {write8_delegate(FUNC(nes_state::bmc_gb63_w),(nes_state *)0), read8_delegate(FUNC(nes_state::bmc_gb63_r),(nes_state *)0)},             NULL, NULL, NULL },
12017   { BMC_FK23C,            NES_WRITEONLY(nes_state::fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::fk23c_w),   NULL, NULL, mmc3_irq },
12018   { BMC_FK23CA,           NES_WRITEONLY(nes_state::fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::fk23c_w),   NULL, NULL, mmc3_irq },
12019   { BMC_PJOY84,           NES_NOACCESS, NES_WRITEONLY(nes_state::pjoy84_m_w), NES_WRITEONLY(nes_state::txrom_w),  NULL, NULL, mmc3_irq },
1219212020   //
12193   { FFE_MAPPER6,          NES_WRITEONLY(mapper6_l_w), NES_NOACCESS, NES_WRITEONLY(mapper6_w), NULL, NULL, ffe_irq },
12194   { FFE_MAPPER8,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(mapper8_w),             NULL, NULL, NULL },
12195   { FFE_MAPPER17,         NES_WRITEONLY(mapper17_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, ffe_irq },
12021   { FFE_MAPPER6,          NES_WRITEONLY(nes_state::mapper6_l_w), NES_NOACCESS, NES_WRITEONLY(nes_state::mapper6_w), NULL, NULL, ffe_irq },
12022   { FFE_MAPPER8,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nes_state::mapper8_w),             NULL, NULL, NULL },
12023   { FFE_MAPPER17,         NES_WRITEONLY(nes_state::mapper17_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, ffe_irq },
1219612024   // for debug and development
12197   { UNKNOWN_BOARD,        {FUNC(dummy_l_w), FUNC(dummy_l_r)}, {FUNC(dummy_m_w), FUNC(dummy_m_r)}, {FUNC(dummy_w), FUNC(dummy_r)}, NULL, NULL, NULL },
12025   { UNKNOWN_BOARD,        {write8_delegate(FUNC(nes_state::dummy_l_w),(nes_state *)0), read8_delegate(FUNC(nes_state::dummy_l_r),(nes_state *)0)}, {write8_delegate(FUNC(nes_state::dummy_m_w),(nes_state *)0), read8_delegate(FUNC(nes_state::dummy_m_r),(nes_state *)0)}, {write8_delegate(FUNC(nes_state::dummy_w),(nes_state *)0), read8_delegate(FUNC(nes_state::dummy_r),(nes_state *)0)}, NULL, NULL, NULL },
1219812026   //
1219912027   { UNSUPPORTED_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_NOACCESS,                         NULL, NULL, NULL },
1220012028   //
r18063r18064
1222012048      fatalerror("Missing PCB interface\n");
1222112049
1222212050   if (intf)
12223   {
12051   {   
1222412052      state->m_mmc_write_low = intf->mmc_l.write;
12225      state->m_mmc_write_low_name = intf->mmc_l.write_name;
12053      if (!state->m_mmc_write_low.isnull()) state->m_mmc_write_low.late_bind(*state);
1222612054      state->m_mmc_write_mid = intf->mmc_m.write;
12227      state->m_mmc_write_mid_name = intf->mmc_m.write_name;
12055      if (!state->m_mmc_write_mid.isnull()) state->m_mmc_write_mid.late_bind(*state);
1222812056      state->m_mmc_write = intf->mmc_h.write;
12229      state->m_mmc_write_name = intf->mmc_h.write_name;
12057      if (!state->m_mmc_write.isnull()) state->m_mmc_write.late_bind(*state);
1223012058      state->m_mmc_read_low = intf->mmc_l.read;
12231      state->m_mmc_read_low_name = intf->mmc_l.read_name;
12059      if (!state->m_mmc_read_low.isnull()) state->m_mmc_read_low.late_bind(*state);
1223212060      state->m_mmc_read_mid = intf->mmc_m.read;   // in progress
12233      state->m_mmc_read_mid_name = intf->mmc_m.read_name;
12061      if (!state->m_mmc_read_mid.isnull()) state->m_mmc_read_mid.late_bind(*state);
1223412062      state->m_mmc_read = intf->mmc_h.read;   // in progress
12235      state->m_mmc_read_name = intf->mmc_h.read_name;
12063      if (!state->m_mmc_read.isnull()) state->m_mmc_read.late_bind(*state);
1223612064      state->m_ppu->set_latch(intf->mmc_ppu_latch);
1223712065   }
1223812066   else
1223912067   {
1224012068      logerror("PCB %d is not yet supported, defaulting to no mapper.\n", state->m_pcb_id);
12241      state->m_mmc_write_low = NULL;
12242      state->m_mmc_write_mid = NULL;
12243      state->m_mmc_write = NULL;
12244      state->m_mmc_read_low = NULL;
12245      state->m_mmc_read_mid = NULL;   // in progress
12246      state->m_mmc_read = NULL;   // in progress
12069      state->m_mmc_write_low = write8_delegate();
12070      state->m_mmc_write_mid = write8_delegate();
12071      state->m_mmc_write = write8_delegate();
12072      state->m_mmc_read_low = read8_delegate();
12073      state->m_mmc_read_mid = read8_delegate();   // in progress
12074      state->m_mmc_read = read8_delegate();   // in progress
1224712075      state->m_ppu->set_latch(NULL);
1224812076   }
1224912077
trunk/src/mess/includes/nes.h
r18063r18064
108108   int m_last_frame_flip;
109109
110110   /* misc */
111   write8_space_func   m_mmc_write_low;
112   const char        *m_mmc_write_low_name;
113   write8_space_func   m_mmc_write_mid;
114   const char        *m_mmc_write_mid_name;
115   write8_space_func   m_mmc_write;
116   const char        *m_mmc_write_name;
117   read8_space_func    m_mmc_read_low;
118   const char        *m_mmc_read_low_name;
119   read8_space_func    m_mmc_read_mid;
120   const char        *m_mmc_read_mid_name;
121   read8_space_func    m_mmc_read;
122   const char        *m_mmc_read_name;
111   write8_delegate   m_mmc_write_low;
112   write8_delegate   m_mmc_write_mid;
113   write8_delegate   m_mmc_write;
114   read8_delegate    m_mmc_read_low;
115   read8_delegate    m_mmc_read_mid;
116   read8_delegate    m_mmc_read;
123117   emu_timer           *m_irq_timer;
124118
125119   nes_prg_callback    m_mmc3_prg_cb;   // these are used to simplify a lot emulation of some MMC3 pirate clones
r18063r18064
260254   virtual void video_start();
261255   virtual void palette_init();
262256   UINT32 screen_update_nes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
257   DECLARE_WRITE8_MEMBER(mapper6_l_w);
258   DECLARE_WRITE8_MEMBER(mapper6_w);
259   DECLARE_WRITE8_MEMBER(mapper8_w);
260   DECLARE_WRITE8_MEMBER(mapper17_l_w);
261   DECLARE_WRITE8_MEMBER(nes_chr_w);
262   DECLARE_READ8_MEMBER(nes_chr_r);
263   DECLARE_WRITE8_MEMBER(nes_nt_w);
264   DECLARE_READ8_MEMBER(nes_nt_r);
265   DECLARE_WRITE8_MEMBER(nes_low_mapper_w);
266   DECLARE_READ8_MEMBER(nes_low_mapper_r);
267   DECLARE_WRITE8_MEMBER(uxrom_w);
268   DECLARE_WRITE8_MEMBER(uxrom_cc_w);
269   DECLARE_WRITE8_MEMBER(un1rom_w);
270   DECLARE_WRITE8_MEMBER(cnrom_w);
271   DECLARE_WRITE8_MEMBER(bandai_pt554_m_w);
272   DECLARE_WRITE8_MEMBER(cprom_w);
273   DECLARE_WRITE8_MEMBER(axrom_w);
274   DECLARE_WRITE8_MEMBER(bxrom_w);
275   DECLARE_WRITE8_MEMBER(gxrom_w);
276   DECLARE_WRITE8_MEMBER(sxrom_w);
277   DECLARE_WRITE8_MEMBER(pxrom_w);
278   DECLARE_WRITE8_MEMBER(fxrom_w);
279   DECLARE_WRITE8_MEMBER(txrom_w);
280   DECLARE_WRITE8_MEMBER(hkrom_m_w);
281   DECLARE_READ8_MEMBER(hkrom_m_r);
282   DECLARE_WRITE8_MEMBER(hkrom_w);
283   DECLARE_WRITE8_MEMBER(txsrom_w);
284   DECLARE_WRITE8_MEMBER(tqrom_w);
285   DECLARE_WRITE8_MEMBER(zz_m_w);
286   DECLARE_WRITE8_MEMBER(qj_m_w);
287   DECLARE_READ8_MEMBER(exrom_l_r);
288   DECLARE_WRITE8_MEMBER(exrom_l_w);
289   DECLARE_WRITE8_MEMBER(ntbrom_w);
290   DECLARE_WRITE8_MEMBER(jxrom_w);
291   DECLARE_WRITE8_MEMBER(dxrom_w);
292   DECLARE_WRITE8_MEMBER(namcot3453_w);
293   DECLARE_WRITE8_MEMBER(namcot3446_w);
294   DECLARE_WRITE8_MEMBER(namcot3425_w);
295   DECLARE_WRITE8_MEMBER(dis_74x377_w);
296   DECLARE_WRITE8_MEMBER(dis_74x139x74_m_w);
297   DECLARE_WRITE8_MEMBER(dis_74x161x138_m_w);
298   DECLARE_WRITE8_MEMBER(dis_74x161x161x32_w);
299   DECLARE_WRITE8_MEMBER(lz93d50_w);
300   DECLARE_WRITE8_MEMBER(lz93d50_m_w);
301   DECLARE_WRITE8_MEMBER(fjump2_w);
302   DECLARE_WRITE8_MEMBER(bandai_ks_w);
303   DECLARE_WRITE8_MEMBER(bandai_ok_w);
304   DECLARE_WRITE8_MEMBER(lrog017_w);
305   DECLARE_WRITE8_MEMBER(irem_hd_w);
306   DECLARE_WRITE8_MEMBER(tam_s1_w);
307   DECLARE_WRITE8_MEMBER(g101_w);
308   DECLARE_WRITE8_MEMBER(h3001_w);
309   DECLARE_WRITE8_MEMBER(ss88006_w);
310   DECLARE_WRITE8_MEMBER(jf11_m_w);
311   DECLARE_WRITE8_MEMBER(jf13_m_w);
312   DECLARE_WRITE8_MEMBER(jf16_w);
313   DECLARE_WRITE8_MEMBER(jf17_w);
314   DECLARE_WRITE8_MEMBER(jf19_w);
315   DECLARE_WRITE8_MEMBER(konami_vrc1_w);
316   DECLARE_WRITE8_MEMBER(konami_vrc2_w);
317   DECLARE_WRITE8_MEMBER(konami_vrc3_w);
318   DECLARE_WRITE8_MEMBER(konami_vrc4_w);
319   DECLARE_WRITE8_MEMBER(konami_vrc6_w);
320   DECLARE_WRITE8_MEMBER(konami_vrc7_w);
321   DECLARE_WRITE8_MEMBER(namcot163_l_w);
322   DECLARE_READ8_MEMBER(namcot163_l_r);
323   DECLARE_WRITE8_MEMBER(namcot163_w);
324   DECLARE_WRITE8_MEMBER(sunsoft1_m_w);
325   DECLARE_WRITE8_MEMBER(sunsoft2_w);
326   DECLARE_WRITE8_MEMBER(sunsoft3_w);
327   DECLARE_WRITE8_MEMBER(tc0190fmc_w);
328   DECLARE_WRITE8_MEMBER(tc0190fmc_p16_w);
329   DECLARE_WRITE8_MEMBER(x1005_m_w);
330   DECLARE_READ8_MEMBER(x1005_m_r);
331   DECLARE_WRITE8_MEMBER(x1005a_m_w);
332   DECLARE_WRITE8_MEMBER(x1017_m_w);
333   DECLARE_READ8_MEMBER(x1017_m_r);
334   DECLARE_WRITE8_MEMBER(agci_50282_w);
335   DECLARE_WRITE8_MEMBER(nina01_m_w);
336   DECLARE_WRITE8_MEMBER(nina06_l_w);
337   DECLARE_WRITE8_MEMBER(ae_act52_w);
338   DECLARE_WRITE8_MEMBER(cne_decathl_w);
339   DECLARE_WRITE8_MEMBER(cne_fsb_m_w);
340   DECLARE_WRITE8_MEMBER(cne_shlz_l_w);
341   DECLARE_WRITE8_MEMBER(caltron6in1_m_w);
342   DECLARE_WRITE8_MEMBER(caltron6in1_w);
343   DECLARE_WRITE8_MEMBER(bf9093_w);
344   DECLARE_WRITE8_MEMBER(bf9096_w);
345   DECLARE_WRITE8_MEMBER(golden5_w);
346   DECLARE_WRITE8_MEMBER(cony_l_w);
347   DECLARE_READ8_MEMBER(cony_l_r);
348   DECLARE_WRITE8_MEMBER(cony_w);
349   DECLARE_WRITE8_MEMBER(yoko_l_w);
350   DECLARE_READ8_MEMBER(yoko_l_r);
351   DECLARE_WRITE8_MEMBER(yoko_w);
352   DECLARE_WRITE8_MEMBER(dreamtech_l_w);
353   DECLARE_WRITE8_MEMBER(fukutake_l_w);
354   DECLARE_READ8_MEMBER(fukutake_l_r);
355   DECLARE_WRITE8_MEMBER(futuremedia_w);
356   DECLARE_WRITE8_MEMBER(gouder_sf4_l_w);
357   DECLARE_READ8_MEMBER(gouder_sf4_l_r);
358   DECLARE_WRITE8_MEMBER(henggedianzi_w);
359   DECLARE_WRITE8_MEMBER(heng_xjzb_l_w);
360   DECLARE_WRITE8_MEMBER(heng_xjzb_w);
361   DECLARE_WRITE8_MEMBER(hes6in1_l_w);
362   DECLARE_WRITE8_MEMBER(hes_l_w);
363   DECLARE_WRITE8_MEMBER(hosenkan_w);
364   DECLARE_WRITE8_MEMBER(ks7058_w);
365   DECLARE_WRITE8_MEMBER(ks7022_w);
366   DECLARE_READ8_MEMBER(ks7022_r);
367   DECLARE_WRITE8_MEMBER(ks7032_w);
368   DECLARE_WRITE8_MEMBER(ks202_w);
369   DECLARE_WRITE8_MEMBER(ks7017_l_w);
370   DECLARE_WRITE8_MEMBER(ks7017_extra_w);
371   DECLARE_READ8_MEMBER(ks7017_extra_r);
372   DECLARE_WRITE8_MEMBER(kay_pp_l_w);
373   DECLARE_READ8_MEMBER(kay_pp_l_r);
374   DECLARE_WRITE8_MEMBER(kay_pp_w);
375   DECLARE_WRITE8_MEMBER(kasing_m_w);
376   DECLARE_WRITE8_MEMBER(magics_md_w);
377   DECLARE_WRITE8_MEMBER(nanjing_l_w);
378   DECLARE_READ8_MEMBER(nanjing_l_r);
379   DECLARE_WRITE8_MEMBER(nitra_w);
380   DECLARE_WRITE8_MEMBER(ntdec_asder_w);
381   DECLARE_WRITE8_MEMBER(ntdec_fh_m_w);
382   DECLARE_WRITE8_MEMBER(daou306_w);
383   DECLARE_WRITE8_MEMBER(gs2015_w);
384   DECLARE_WRITE8_MEMBER(rcm_tf_w);
385   DECLARE_WRITE8_MEMBER(rex_dbz_l_w);
386   DECLARE_READ8_MEMBER(rex_dbz_l_r);
387   DECLARE_WRITE8_MEMBER(rex_sl1632_w);
388   DECLARE_WRITE8_MEMBER(rumblestation_m_w);
389   DECLARE_WRITE8_MEMBER(rumblestation_w);
390   DECLARE_WRITE8_MEMBER(sachen_74x374_l_w);
391   DECLARE_READ8_MEMBER(sachen_74x374_l_r);
392   DECLARE_WRITE8_MEMBER(sachen_74x374a_l_w);
393   DECLARE_WRITE8_MEMBER(s8259_l_w);
394   DECLARE_WRITE8_MEMBER(s8259_m_w);
395   DECLARE_WRITE8_MEMBER(sa009_l_w);
396   DECLARE_WRITE8_MEMBER(sa0036_w);
397   DECLARE_WRITE8_MEMBER(sa0037_w);
398   DECLARE_WRITE8_MEMBER(sa72007_l_w);
399   DECLARE_WRITE8_MEMBER(sa72008_l_w);
400   DECLARE_READ8_MEMBER(tca01_l_r);
401   DECLARE_WRITE8_MEMBER(tcu01_l_w);
402   DECLARE_WRITE8_MEMBER(tcu01_m_w);
403   DECLARE_WRITE8_MEMBER(tcu01_w);
404   DECLARE_WRITE8_MEMBER(tcu02_l_w);
405   DECLARE_READ8_MEMBER(tcu02_l_r);
406   DECLARE_WRITE8_MEMBER(subor0_w);
407   DECLARE_WRITE8_MEMBER(subor1_w);
408   DECLARE_WRITE8_MEMBER(sgame_boog_l_w);
409   DECLARE_WRITE8_MEMBER(sgame_boog_m_w);
410   DECLARE_WRITE8_MEMBER(sgame_boog_w);
411   DECLARE_WRITE8_MEMBER(sgame_lion_m_w);
412   DECLARE_WRITE8_MEMBER(sgame_lion_w);
413   DECLARE_WRITE8_MEMBER(tengen_800008_w);
414   DECLARE_WRITE8_MEMBER(tengen_800032_w);
415   DECLARE_WRITE8_MEMBER(tengen_800037_w);
416   DECLARE_WRITE8_MEMBER(txc_22211_l_w);
417   DECLARE_READ8_MEMBER(txc_22211_l_r);
418   DECLARE_WRITE8_MEMBER(txc_22211_w);
419   DECLARE_WRITE8_MEMBER(txc_22211b_w);
420   DECLARE_READ8_MEMBER(txc_22211c_l_r);
421   DECLARE_WRITE8_MEMBER(txc_tw_l_w);
422   DECLARE_WRITE8_MEMBER(txc_tw_m_w);
423   DECLARE_WRITE8_MEMBER(txc_strikewolf_w);
424   DECLARE_READ8_MEMBER(txc_mxmdhtwo_l_r);
425   DECLARE_WRITE8_MEMBER(txc_mxmdhtwo_w);
426   DECLARE_WRITE8_MEMBER(waixing_a_w);
427   DECLARE_WRITE8_MEMBER(waixing_f_w);
428   DECLARE_WRITE8_MEMBER(waixing_g_w);
429   DECLARE_WRITE8_MEMBER(waixing_h_w);
430   DECLARE_WRITE8_MEMBER(waixing_sgz_w);
431   DECLARE_WRITE8_MEMBER(waixing_sgzlz_l_w);
432   DECLARE_WRITE8_MEMBER(waixing_ffv_l_w);
433   DECLARE_WRITE8_MEMBER(waixing_zs_w);
434   DECLARE_WRITE8_MEMBER(waixing_dq8_w);
435   DECLARE_WRITE8_MEMBER(waixing_ps2_w);
436   DECLARE_WRITE8_MEMBER(waixing_sec_l_w);
437   DECLARE_READ8_MEMBER(waixing_sh2_chr_r);
438   DECLARE_WRITE8_MEMBER(unl_8237_l_w);
439   DECLARE_WRITE8_MEMBER(unl_8237_w);
440   DECLARE_WRITE8_MEMBER(unl_ax5705_w);
441   DECLARE_WRITE8_MEMBER(unl_cc21_w);
442   DECLARE_WRITE8_MEMBER(unl_kof97_w);
443   DECLARE_WRITE8_MEMBER(ks7057_w);
444   DECLARE_WRITE8_MEMBER(unl_t230_w);
445   DECLARE_WRITE8_MEMBER(kof96_l_w);
446   DECLARE_READ8_MEMBER(kof96_l_r);
447   DECLARE_WRITE8_MEMBER(kof96_w);
448   DECLARE_WRITE8_MEMBER(mk2_m_w);
449   DECLARE_WRITE8_MEMBER(n625092_w);
450   DECLARE_WRITE8_MEMBER(sc127_w);
451   DECLARE_WRITE8_MEMBER(smb2j_w);
452   DECLARE_WRITE8_MEMBER(smb2jb_l_w);
453   DECLARE_WRITE8_MEMBER(smb2jb_extra_w);
454   DECLARE_WRITE8_MEMBER(unl_sf3_w);
455   DECLARE_WRITE8_MEMBER(unl_xzy_l_w);
456   DECLARE_WRITE8_MEMBER(unl_racmate_w);
457   DECLARE_WRITE8_MEMBER(unl_fs304_l_w);
458   DECLARE_WRITE8_MEMBER(btl_smb11_w);
459   DECLARE_WRITE8_MEMBER(btl_mariobaby_w);
460   DECLARE_WRITE8_MEMBER(btl_smb2a_w);
461   DECLARE_WRITE8_MEMBER(whirl2706_w);
462   DECLARE_WRITE8_MEMBER(btl_tobi_l_w);
463   DECLARE_WRITE8_MEMBER(btl_smb3_w);
464   DECLARE_WRITE8_MEMBER(btl_dn_w);
465   DECLARE_WRITE8_MEMBER(btl_pika_y2k_w);
466   DECLARE_WRITE8_MEMBER(btl_pika_y2k_m_w);
467   DECLARE_READ8_MEMBER(btl_pika_y2k_m_r);
468   DECLARE_WRITE8_MEMBER(fk23c_l_w);
469   DECLARE_WRITE8_MEMBER(fk23c_w);
470   DECLARE_WRITE8_MEMBER(bmc_64in1nr_l_w);
471   DECLARE_WRITE8_MEMBER(bmc_64in1nr_w);
472   DECLARE_WRITE8_MEMBER(bmc_190in1_w);
473   DECLARE_WRITE8_MEMBER(bmc_a65as_w);
474   DECLARE_WRITE8_MEMBER(bmc_gs2004_w);
475   DECLARE_WRITE8_MEMBER(bmc_gs2013_w);
476   DECLARE_WRITE8_MEMBER(bmc_s24in1sc03_l_w);
477   DECLARE_WRITE8_MEMBER(bmc_t262_w);
478   DECLARE_WRITE8_MEMBER(bmc_ws_m_w);
479   DECLARE_WRITE8_MEMBER(novel1_w);
480   DECLARE_WRITE8_MEMBER(novel2_w);
481   DECLARE_WRITE8_MEMBER(bmc_gka_w);
482   DECLARE_WRITE8_MEMBER(sng32_w);
483   DECLARE_WRITE8_MEMBER(bmc_gkb_w);
484   DECLARE_WRITE8_MEMBER(bmc_super700in1_w);
485   DECLARE_WRITE8_MEMBER(bmc_36in1_w);
486   DECLARE_WRITE8_MEMBER(bmc_21in1_w);
487   DECLARE_WRITE8_MEMBER(bmc_150in1_w);
488   DECLARE_WRITE8_MEMBER(bmc_35in1_w);
489   DECLARE_WRITE8_MEMBER(bmc_64in1_w);
490   DECLARE_WRITE8_MEMBER(bmc_15in1_m_w);
491   DECLARE_WRITE8_MEMBER(bmc_hik300_w);
492   DECLARE_WRITE8_MEMBER(supergun20in1_w);
493   DECLARE_WRITE8_MEMBER(bmc_72in1_w);
494   DECLARE_WRITE8_MEMBER(bmc_76in1_w);
495   DECLARE_WRITE8_MEMBER(bmc_1200in1_w);
496   DECLARE_WRITE8_MEMBER(bmc_31in1_w);
497   DECLARE_WRITE8_MEMBER(bmc_22g_w);
498   DECLARE_WRITE8_MEMBER(bmc_20in1_w);
499   DECLARE_WRITE8_MEMBER(bmc_110in1_w);
500   DECLARE_WRITE8_MEMBER(bmc_sbig7_w);
501   DECLARE_WRITE8_MEMBER(bmc_hik8_m_w);
502   DECLARE_WRITE8_MEMBER(bmc_hik4in1_m_w);
503   DECLARE_WRITE8_MEMBER(bmc_ball11_m_w);
504   DECLARE_WRITE8_MEMBER(bmc_ball11_w);
505   DECLARE_WRITE8_MEMBER(bmc_mario7in1_m_w);
506   DECLARE_WRITE8_MEMBER(bmc_gold7in1_m_w);
507   DECLARE_WRITE8_MEMBER(bmc_gc6in1_l_w);
508   DECLARE_WRITE8_MEMBER(bmc_gc6in1_w);
509   DECLARE_WRITE8_MEMBER(bmc_family4646_m_w);
510   DECLARE_WRITE8_MEMBER(bmc_vt5201_w);
511   DECLARE_READ8_MEMBER(bmc_vt5201_r);
512   DECLARE_WRITE8_MEMBER(bmc_bs5_w);
513   DECLARE_WRITE8_MEMBER(bmc_810544_w);
514   DECLARE_WRITE8_MEMBER(bmc_ntd03_w);
515   DECLARE_WRITE8_MEMBER(bmc_gb63_w);
516   DECLARE_READ8_MEMBER(bmc_gb63_r);
517   DECLARE_WRITE8_MEMBER(edu2k_w);
518   DECLARE_WRITE8_MEMBER(h2288_l_w);
519   DECLARE_READ8_MEMBER(h2288_l_r);
520   DECLARE_WRITE8_MEMBER(h2288_w);
521   DECLARE_WRITE8_MEMBER(shjy3_w);
522   DECLARE_WRITE8_MEMBER(unl_6035052_extra_w);
523   DECLARE_READ8_MEMBER(unl_6035052_extra_r);
524   DECLARE_WRITE8_MEMBER(pjoy84_m_w);
525   DECLARE_WRITE8_MEMBER(someri_mmc1_w);
526   DECLARE_WRITE8_MEMBER(someri_mmc3_w);
527   DECLARE_WRITE8_MEMBER(someri_vrc2_w);
528   DECLARE_WRITE8_MEMBER(someri_w);
529   DECLARE_WRITE8_MEMBER(someri_l_w);
530   DECLARE_WRITE8_MEMBER(fujiya_m_w);
531   DECLARE_READ8_MEMBER(fujiya_m_r);
532   DECLARE_WRITE8_MEMBER(dummy_l_w);
533   DECLARE_WRITE8_MEMBER(dummy_m_w);
534   DECLARE_WRITE8_MEMBER(dummy_w);
535   DECLARE_READ8_MEMBER(dummy_l_r);
536   DECLARE_READ8_MEMBER(dummy_m_r);
537   DECLARE_READ8_MEMBER(dummy_r);   
538   void init_nes_core();
263539};
264540
265541/*----------- defined in machine/nes.c -----------*/
trunk/src/mess/drivers/nes.c
r18063r18064
5050   AM_RANGE(0x4016, 0x4016) AM_READWRITE(nes_IN0_r, nes_IN0_w)         /* IN0 - input port 1 */
5151   AM_RANGE(0x4017, 0x4017) AM_READ(nes_IN1_r)                     /* IN1 - input port 2 */
5252   AM_RANGE(0x4017, 0x4017) AM_DEVWRITE_LEGACY("nessound", psg_4017_w)      /* PSG second control register */
53   AM_RANGE(0x4100, 0x5fff) AM_READWRITE_LEGACY(nes_low_mapper_r, nes_low_mapper_w)   /* Perform unholy acts on the machine */
53   AM_RANGE(0x4100, 0x5fff) AM_READWRITE(nes_low_mapper_r, nes_low_mapper_w)   /* Perform unholy acts on the machine */
5454ADDRESS_MAP_END
5555
5656
r18063r18064
544544   MCFG_SOFTWARE_LIST_ADD("flop_list","famicom_flop")
545545MACHINE_CONFIG_END
546546
547//static MACHINE_CONFIG_DERIVED( nes_test, nes )
548//MACHINE_CONFIG_END
547549
550
548551/* rom regions are just place-holders: they get removed and re-allocated when a cart is loaded */
549552ROM_START( nes )
550553   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )  /* Main RAM */
r18063r18064
596599   ROM_REGION( 0x800,   "ciram", ROMREGION_ERASE00 )  /* CI RAM */
597600ROM_END
598601
602//#define rom_nes_test rom_nes
603
599604/***************************************************************************
600605
601606  Game driver(s)
r18063r18064
610615CONS( 198?, m82,       nes,    0,     nes,      nes, driver_device,     0,       "Nintendo",  "M82 Display Unit", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
611616CONS( 1996, drpcjr,    nes,    0,     famicom,  famicom, nes_state, famicom, "Bung",      "Doctor PC Jr", GAME_IMPERFECT_GRAPHICS )
612617CONS( 1992, dendy,     nes,    0,     dendy,    nes, driver_device,     0,       "Steepler",  "Dendy Classic", GAME_IMPERFECT_GRAPHICS )
618
619//CONS( 1985, nes_test,  0,      0,     nes_test, nes, driver_device,     0,       "Nintendo",  "Nintendo Entertainment System (Testdriver)", GAME_IMPERFECT_GRAPHICS )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team