4
4
5
5
SNK NeoGeo Pocket driver
6
6
7
+ After setting the initial console settings power cycle the unit at least once,
8
+ otherwise the settings will not be saved properly.
9
+
10
+
7
11
The NeoGeo Pocket (Color) contains one big chip which contains the following
8
12
components:
9
13
- Toshiba TLCS-900/H cpu core with 64KB ROM
@@ -98,6 +102,7 @@ the Neogeo Pocket.
98
102
99
103
100
104
#include " emu.h"
105
+ #include " k1ge.h"
101
106
102
107
#include " bus/generic/slot.h"
103
108
#include " bus/generic/carts.h"
@@ -106,7 +111,7 @@ the Neogeo Pocket.
106
111
#include " sound/t6w28.h"
107
112
#include " sound/dac.h"
108
113
109
- #include " k1ge .h"
114
+ #include " dirtc .h"
110
115
#include " screen.h"
111
116
#include " softlist_dev.h"
112
117
#include " speaker.h"
@@ -128,13 +133,15 @@ enum flash_state
128
133
};
129
134
130
135
131
- class ngp_state : public driver_device , public device_nvram_interface
136
+ class ngp_state : public driver_device , public device_nvram_interface , device_rtc_interface
132
137
{
133
138
public:
134
139
ngp_state (const machine_config &mconfig, device_type type, const char *tag) :
135
140
driver_device (mconfig, type, tag),
136
141
device_nvram_interface (mconfig, *this ),
142
+ device_rtc_interface (mconfig, *this ),
137
143
m_maincpu (*this , " maincpu" ),
144
+ m_screen (*this , " screen" ),
138
145
m_z80 (*this , " soundcpu" ),
139
146
m_t6w28 (*this , " t6w28" ),
140
147
m_ldac (*this , " ldac" ),
@@ -155,6 +162,7 @@ class ngp_state : public driver_device, public device_nvram_interface
155
162
protected:
156
163
virtual void machine_start () override ATTR_COLD;
157
164
virtual void machine_reset () override ATTR_COLD;
165
+ virtual void rtc_clock_updated (int year, int month, int day, int day_of_week, int hour, int minute, int second) override ATTR_COLD;
158
166
159
167
private:
160
168
@@ -173,6 +181,7 @@ class ngp_state : public driver_device, public device_nvram_interface
173
181
} m_flash_chip[2 ];
174
182
175
183
required_device<tmp95c061_device> m_maincpu;
184
+ required_device<screen_device> m_screen;
176
185
required_device<cpu_device> m_z80;
177
186
required_device<t6w28_device> m_t6w28;
178
187
required_device<dac_byte_interface> m_ldac;
@@ -219,34 +228,7 @@ class ngp_state : public driver_device, public device_nvram_interface
219
228
220
229
TIMER_CALLBACK_MEMBER (ngp_state::ngp_seconds_callback)
221
230
{
222
- m_io_reg[0x16 ] += 1 ;
223
- if ((m_io_reg[0x16 ] & 0x0f ) == 0x0a )
224
- {
225
- m_io_reg[0x16 ] += 0x06 ;
226
- }
227
-
228
- if (m_io_reg[0x16 ] >= 0x60 )
229
- {
230
- m_io_reg[0x16 ] = 0 ;
231
- m_io_reg[0x15 ] += 1 ;
232
- if ((m_io_reg[0x15 ] & 0x0f ) == 0x0a ) {
233
- m_io_reg[0x15 ] += 0x06 ;
234
- }
235
-
236
- if (m_io_reg[0x15 ] >= 0x60 )
237
- {
238
- m_io_reg[0x15 ] = 0 ;
239
- m_io_reg[0x14 ] += 1 ;
240
- if ((m_io_reg[0x14 ] & 0x0f ) == 0x0a ) {
241
- m_io_reg[0x14 ] += 0x06 ;
242
- }
243
-
244
- if (m_io_reg[0x14 ] == 0x24 )
245
- {
246
- m_io_reg[0x14 ] = 0 ;
247
- }
248
- }
249
- }
231
+ advance_seconds ();
250
232
}
251
233
252
234
@@ -256,12 +238,23 @@ uint8_t ngp_state::ngp_io_r(offs_t offset)
256
238
257
239
switch (offset)
258
240
{
259
- case 0x30 : /* Read controls */
260
- data = m_io_controls->read ();
261
- break ;
241
+ case 0x11 : // year
242
+ return convert_to_bcd (get_clock_register (RTC_YEAR) % 100 );
243
+ case 0x12 : // month
244
+ return convert_to_bcd (get_clock_register (RTC_MONTH));
245
+ case 0x13 : // day
246
+ return convert_to_bcd (get_clock_register (RTC_DAY));
247
+ case 0x14 : // hour
248
+ return convert_to_bcd (get_clock_register (RTC_HOUR));
249
+ case 0x15 : // minute
250
+ return convert_to_bcd (get_clock_register (RTC_MINUTE));
251
+ case 0x16 : // second
252
+ return convert_to_bcd (get_clock_register (RTC_SECOND));
253
+ case 0x30 : // Read controls
254
+ return m_io_controls->read ();
262
255
case 0x31 :
263
256
data = m_io_power->read () & 0x01 ;
264
- /* Sub-battery OK */
257
+ // Sub-battery OK
265
258
data |= 0x02 ;
266
259
break ;
267
260
}
@@ -273,52 +266,67 @@ void ngp_state::ngp_io_w(offs_t offset, uint8_t data)
273
266
{
274
267
switch (offset)
275
268
{
276
- case 0x20 : /* t6w28 "right" */
277
- case 0x21 : /* t6w28 "left" */
269
+ case 0x11 : // year
270
+ set_clock_register (RTC_YEAR, bcd_to_integer (data));
271
+ break ;
272
+ case 0x12 : // month
273
+ set_clock_register (RTC_MONTH, bcd_to_integer (data));
274
+ break ;
275
+ case 0x13 : // day
276
+ set_clock_register (RTC_DAY, bcd_to_integer (data));
277
+ break ;
278
+ case 0x14 : // hour
279
+ set_clock_register (RTC_HOUR, bcd_to_integer (data));
280
+ break ;
281
+ case 0x15 : // minute
282
+ set_clock_register (RTC_MINUTE, bcd_to_integer (data));
283
+ break ;
284
+ case 0x16 : // second
285
+ set_clock_register (RTC_SECOND, bcd_to_integer (data));
286
+ break ;
287
+ case 0x20 : // t6w28 "right"
288
+ case 0x21 : // t6w28 "left"
278
289
if (m_io_reg[0x38 ] == 0x55 && m_io_reg[0x39 ] == 0xAA )
279
- {
280
290
m_t6w28->write (0 , data);
281
- }
282
291
break ;
283
292
284
- case 0x22 : /* DAC right */
293
+ case 0x22 : // DAC right
285
294
m_rdac->write (data);
286
295
break ;
287
- case 0x23 : /* DAC left */
296
+ case 0x23 : // DAC left
288
297
m_ldac->write (data);
289
298
break ;
290
299
291
- /* Internal eeprom related? */
292
- case 0x36 :
300
+ case 0x36 : // 50 written when system powers down, 05 written when system starts up
293
301
case 0x37 :
294
302
break ;
295
- case 0x38 : /* Sound enable/disable. */
303
+ case 0x38 : // Sound enable/disable.
296
304
switch (data)
297
305
{
298
- case 0x55 : /* Enabled sound */
306
+ case 0x55 : // Enabled sound
299
307
m_t6w28->set_enable (true );
300
308
break ;
301
- case 0xAA : /* Disable sound */
309
+ case 0xAA : // Disable sound
302
310
m_t6w28->set_enable (false );
303
311
break ;
304
312
}
305
313
break ;
306
314
307
- case 0x39 : /* Z80 enable/disable. */
315
+ case 0x39 : // Z80 enable/disable.
308
316
switch (data)
309
317
{
310
- case 0x55 : /* Enable Z80 */
318
+ case 0x55 : // Enable Z80
311
319
m_z80->resume (SUSPEND_REASON_HALT);
312
320
m_z80->reset ();
313
321
m_z80->set_input_line (0 , CLEAR_LINE);
314
322
break ;
315
- case 0xAA : /* Disable Z80 */
323
+ case 0xAA : // Disable Z80
316
324
m_z80->suspend (SUSPEND_REASON_HALT, 1 );
317
325
break ;
318
326
}
319
327
break ;
320
328
321
- case 0x3a : /* Trigger Z80 NMI */
329
+ case 0x3a : // Trigger Z80 NMI
322
330
m_z80->pulse_input_line (INPUT_LINE_NMI, attotime::zero);
323
331
break ;
324
332
}
@@ -605,10 +613,8 @@ void ngp_state::z80_io(address_map &map)
605
613
606
614
INPUT_CHANGED_MEMBER (ngp_state::power_callback)
607
615
{
608
- if (m_io_reg[0x33 ] & 0x04 )
609
- {
610
- m_maincpu->set_input_line (TLCS900_NMI, (m_io_power->read () & 0x01 ) ? CLEAR_LINE : ASSERT_LINE);
611
- }
616
+ if (BIT (m_io_reg[0x33 ], 2 ))
617
+ m_maincpu->set_input_line (TLCS900_NMI, (BIT (m_io_power->read (), 0 ) ? CLEAR_LINE : ASSERT_LINE));
612
618
}
613
619
614
620
@@ -643,7 +649,8 @@ void ngp_state::ngp_hblank_pin_w(int state)
643
649
void ngp_state::ngp_tlcs900_porta (offs_t offset, uint8_t data)
644
650
{
645
651
int to3 = BIT (data,3 );
646
- if (to3 && ! m_old_to3)
652
+
653
+ if (to3 && !m_old_to3)
647
654
m_z80->set_input_line (0 , ASSERT_LINE);
648
655
649
656
m_old_to3 = to3;
@@ -805,9 +812,20 @@ void ngp_state::nvram_default()
805
812
806
813
bool ngp_state::nvram_read (util::read_stream &file)
807
814
{
808
- auto const [err, actual] = read (file, m_mainram, 0x3000 );
809
- if (!err && (actual == 0x3000 ))
815
+ u8 data[0x3000 + 0x20 ];
816
+
817
+ auto const [err, actual] = read (file, data, 0x3000 + 0x20 );
818
+ if (!err && (actual == 0x3000 + 0x20 ))
810
819
{
820
+ for (int i = 0 ; i < 0x3000 ; i++)
821
+ m_mainram[i] = data[i];
822
+ for (int i = 0 ; i < 0x20 ; i++)
823
+ m_io_reg[i] = data[0x3000 + i];
824
+
825
+ system_time curtime;
826
+ machine ().current_datetime (curtime);
827
+ set_current_time (curtime);
828
+
811
829
m_nvram_loaded = true ;
812
830
return true ;
813
831
}
@@ -817,11 +835,29 @@ bool ngp_state::nvram_read(util::read_stream &file)
817
835
818
836
bool ngp_state::nvram_write (util::write_stream &file)
819
837
{
820
- auto const [err, actual] = write (file, m_mainram, 0x3000 );
838
+ u8 data[0x3000 + 0x20 ];
839
+
840
+ for (int i = 0 ; i < 0x3000 ; i++)
841
+ data[i] = m_mainram[i];
842
+ for (int i = 0 ; i < 0x20 ; i++)
843
+ data[0x3000 + i] = m_io_reg[i];
844
+
845
+ auto const [err, actual] = write (file, data, 0x3000 + 0x20 );
821
846
return !err;
822
847
}
823
848
824
849
850
+ void ngp_state::rtc_clock_updated (int year, int month, int day, int day_of_week, int hour, int minute, int second)
851
+ {
852
+ m_io_reg[0x16 ] = convert_to_bcd (second);
853
+ m_io_reg[0x15 ] = convert_to_bcd (minute);
854
+ m_io_reg[0x14 ] = convert_to_bcd (hour);
855
+ m_io_reg[0x13 ] = convert_to_bcd (day);
856
+ m_io_reg[0x12 ] = convert_to_bcd (month);
857
+ m_io_reg[0x11 ] = convert_to_bcd (year % 100 );
858
+ }
859
+
860
+
825
861
void ngp_state::ngp_common (machine_config &config)
826
862
{
827
863
TMP95C061 (config, m_maincpu, 6 .144_MHz_XTAL);
@@ -834,9 +870,9 @@ void ngp_state::ngp_common(machine_config &config)
834
870
soundcpu.set_addrmap (AS_PROGRAM, &ngp_state::z80_mem);
835
871
soundcpu.set_addrmap (AS_IO, &ngp_state::z80_io);
836
872
837
- screen_device & screen ( SCREEN (config, " screen " , SCREEN_TYPE_LCD) );
838
- screen. set_raw (6 .144_MHz_XTAL, 515 , 0 , 160 /* 480*/ , 199 , 0 , 152 );
839
- screen. set_screen_update (FUNC (ngp_state::screen_update_ngp));
873
+ SCREEN (config, m_screen , SCREEN_TYPE_LCD);
874
+ m_screen-> set_raw (6 .144_MHz_XTAL, 515 , 0 , 160 /* 480*/ , 199 , 0 , 152 );
875
+ m_screen-> set_screen_update (FUNC (ngp_state::screen_update_ngp));
840
876
841
877
/* sound hardware */
842
878
SPEAKER (config, " lspeaker" ).front_left ();
@@ -855,17 +891,16 @@ void ngp_state::ngp(machine_config &config)
855
891
{
856
892
ngp_common (config);
857
893
858
- K1GE (config, m_k1ge, 6 .144_MHz_XTAL, " screen " );
894
+ K1GE (config, m_k1ge, 6 .144_MHz_XTAL, m_screen );
859
895
m_k1ge->vblank_callback ().set (FUNC (ngp_state::ngp_vblank_pin_w));
860
896
m_k1ge->hblank_callback ().set (FUNC (ngp_state::ngp_hblank_pin_w));
861
897
862
- subdevice<screen_device>( " screen " ) ->set_palette (" k1ge:palette" );
898
+ m_screen ->set_palette (" k1ge:palette" );
863
899
864
900
generic_cartslot_device &cartslot (GENERIC_CARTSLOT (config, " cartslot" , generic_plain_slot, " ngp_cart" , " bin,ngp,npc,ngc" ));
865
901
cartslot.set_device_load (FUNC (ngp_state::load_ngp_cart));
866
902
cartslot.set_device_unload (FUNC (ngp_state::unload_ngp_cart));
867
903
868
- /* software lists */
869
904
SOFTWARE_LIST (config, " cart_list" ).set_original (" ngp" );
870
905
SOFTWARE_LIST (config, " ngpc_list" ).set_compatible (" ngpc" );
871
906
}
@@ -874,17 +909,16 @@ void ngp_state::ngp(machine_config &config)
874
909
void ngp_state::ngpc (machine_config &config)
875
910
{
876
911
ngp_common (config);
877
- K2GE (config, m_k1ge, 6 .144_MHz_XTAL, " screen " );
912
+ K2GE (config, m_k1ge, 6 .144_MHz_XTAL, m_screen );
878
913
m_k1ge->vblank_callback ().set (FUNC (ngp_state::ngp_vblank_pin_w));
879
914
m_k1ge->hblank_callback ().set (FUNC (ngp_state::ngp_hblank_pin_w));
880
915
881
- subdevice<screen_device>( " screen " ) ->set_palette (" k1ge:palette" );
916
+ m_screen ->set_palette (" k1ge:palette" );
882
917
883
918
generic_cartslot_device &cartslot (GENERIC_CARTSLOT (config, " cartslot" , generic_plain_slot, " ngp_cart" , " bin,ngp,npc,ngc" ));
884
919
cartslot.set_device_load (FUNC (ngp_state::load_ngp_cart));
885
920
cartslot.set_device_unload (FUNC (ngp_state::unload_ngp_cart));
886
921
887
- /* software lists */
888
922
SOFTWARE_LIST (config, " cart_list" ).set_original (" ngpc" );
889
923
SOFTWARE_LIST (config, " ngp_list" ).set_compatible (" ngp" );
890
924
}
0 commit comments