@@ -33,16 +33,33 @@ void nmk004_device::port4_w(uint8_t data)
3333 m_reset_cb (BIT (data, 0 ) ? ASSERT_LINE : CLEAR_LINE);
3434}
3535
36- void nmk004_device::oki0_bankswitch_w ( uint8_t data )
36+ uint8_t nmk004_device::ym_r ( offs_t offset )
3737{
38- data &= 3 ;
39- membank (" :okibank1" )->set_entry (data);
38+ return m_ym_read_cb (offset);
39+ }
40+
41+ void nmk004_device::ym_w (offs_t offset, uint8_t data)
42+ {
43+ m_ym_write_cb (offset, data);
44+ }
45+
46+ template <unsigned Which>
47+ uint8_t nmk004_device::oki_r ()
48+ {
49+ return m_oki_read_cb[Which]();
50+ }
51+
52+ template <unsigned Which>
53+ void nmk004_device::oki_w (uint8_t data)
54+ {
55+ m_oki_write_cb[Which](data);
4056}
4157
42- void nmk004_device::oki1_bankswitch_w (uint8_t data)
58+ template <unsigned Which>
59+ void nmk004_device::oki_bankswitch_w (uint8_t data)
4360{
4461 data &= 3 ;
45- membank ( " :okibank2 " ) ->set_entry (data);
62+ m_okibank[Which] ->set_entry (data);
4663}
4764
4865uint8_t nmk004_device::tonmk004_r ()
@@ -63,18 +80,18 @@ void nmk004_device::ym2203_irq_handler(int irq)
6380 m_cpu->set_input_line (0 , irq ? ASSERT_LINE : CLEAR_LINE);
6481}
6582
66- void nmk004_device::nmk004_sound_mem_map (address_map &map)
83+ void nmk004_device::mem_map (address_map &map)
6784{
6885 // map(0x0000, 0x1fff).rom(); /* 0x0000 - 0x1fff = internal ROM */
69- map (0x2000 , 0xefff ).rom ().region (" :audiocpu " , 0x2000 );
86+ map (0x2000 , 0xefff ).rom ().region (DEVICE_SELF , 0x2000 );
7087 map (0xf000 , 0xf7ff ).ram ();
71- map (0xf800 , 0xf801 ).rw (" :ymsnd " , FUNC (ym2203_device::read ), FUNC (ym2203_device::write ));
72- map (0xf900 , 0xf900 ).rw (" :oki1 " , FUNC (okim6295_device::read ), FUNC (okim6295_device::write ));
73- map (0xfa00 , 0xfa00 ).rw (" :oki2 " , FUNC (okim6295_device::read ), FUNC (okim6295_device::write ));
88+ map (0xf800 , 0xf801 ).rw (FUNC (nmk004_device::ym_r ), FUNC (nmk004_device::ym_w ));
89+ map (0xf900 , 0xf900 ).rw (FUNC (nmk004_device::oki_r< 0 > ), FUNC (nmk004_device::oki_w< 0 > ));
90+ map (0xfa00 , 0xfa00 ).rw (FUNC (nmk004_device::oki_r< 1 > ), FUNC (nmk004_device::oki_w< 1 > ));
7491 map (0xfb00 , 0xfb00 ).r (FUNC (nmk004_device::tonmk004_r)); // from main cpu
7592 map (0xfc00 , 0xfc00 ).w (FUNC (nmk004_device::tomain_w)); // to main cpu
76- map (0xfc01 , 0xfc01 ).w (FUNC (nmk004_device::oki0_bankswitch_w ));
77- map (0xfc02 , 0xfc02 ).w (FUNC (nmk004_device::oki1_bankswitch_w ));
93+ map (0xfc01 , 0xfc01 ).w (FUNC (nmk004_device::oki_bankswitch_w< 0 > ));
94+ map (0xfc02 , 0xfc02 ).w (FUNC (nmk004_device::oki_bankswitch_w< 1 > ));
7895}
7996
8097
@@ -87,11 +104,17 @@ ROM_END
87104DEFINE_DEVICE_TYPE(NMK004, nmk004_device, " nmk004" , " NMK004" )
88105
89106nmk004_device::nmk004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
90- : device_t(mconfig, NMK004, tag, owner, clock),
91- m_cpu(*this , " mcu" ),
92- m_reset_cb(*this ),
93- to_nmk004(0xff ),
94- to_main(0xff )
107+ : device_t(mconfig, NMK004, tag, owner, clock)
108+ , m_cpu(*this , " mcu" )
109+ , m_okirom(*this , {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG})
110+ , m_okibank(*this , {finder_base::DUMMY_TAG, finder_base::DUMMY_TAG})
111+ , m_reset_cb(*this )
112+ , m_ym_read_cb(*this , 0 )
113+ , m_ym_write_cb(*this )
114+ , m_oki_read_cb{{*this , 0 }, {*this , 0 }}
115+ , m_oki_write_cb{{*this }, {*this }}
116+ , to_nmk004(0xff )
117+ , to_main(0xff )
95118{
96119}
97120
@@ -104,8 +127,10 @@ void nmk004_device::device_start()
104127 save_item (NAME (to_main));
105128 save_item (NAME (to_nmk004));
106129
107- membank (" :okibank1" )->configure_entries (0 , 4 , memregion (" :oki1" )->base () + 0x20000 , 0x20000 );
108- membank (" :okibank2" )->configure_entries (0 , 4 , memregion (" :oki2" )->base () + 0x20000 , 0x20000 );
130+ for (int i = 0 ; i < 2 ; i++)
131+ {
132+ m_okibank[i]->configure_entries (0 , 4 , m_okirom[i] + 0x20000 , 0x20000 );
133+ }
109134}
110135
111136// -------------------------------------------------
@@ -114,7 +139,7 @@ void nmk004_device::device_start()
114139void nmk004_device::device_add_mconfig (machine_config &config)
115140{
116141 TMP90840 (config, m_cpu, DERIVED_CLOCK (1 ,1 )); // Toshiba TMP90C840AF in QFP64 package with 8Kbyte internal ROM
117- m_cpu->set_addrmap (AS_PROGRAM, &nmk004_device::nmk004_sound_mem_map );
142+ m_cpu->set_addrmap (AS_PROGRAM, &nmk004_device::mem_map );
118143 m_cpu->port_write <4 >().set (FUNC (nmk004_device::port4_w));
119144}
120145
@@ -124,5 +149,5 @@ void nmk004_device::device_add_mconfig(machine_config &config)
124149// -------------------------------------------------
125150const tiny_rom_entry *nmk004_device::device_rom_region () const
126151{
127- return ROM_NAME (nmk004 );
152+ return ROM_NAME (nmk004);
128153}
0 commit comments