Previous 15994 Revisions Next

r2829 Friday 6th June, 2008 at 20:03:52 UTC by Wilbert Pol
[POKEMINI] Added preliminary EEPROM support.
[src/mess/drivers]pokemini.c
[src/mess/machine]pokemini.c

src/mess/machine/pokemini.c
r2828r2829
77
88
99#include "driver.h"
10#include "sound/speaker.h"
11#include "machine/i2cmem.h"
1012#include "includes/pokemini.h"
1113#include "cpu/minx/minx.h"
1214
r2828r2829
189191
190192   if ( vector )
191193   {
192      logerror("Triggering IRQ with vector %02x\n", vector );
194      //logerror("Triggering IRQ with vector %02x\n", vector );
193195      /* Trigger interrupt and set vector */
194196      cpunum_set_input_line_and_vector( machine, 0, 0, ASSERT_LINE, vector );
195197   }
r2828r2829
200202}
201203
202204
205static void pokemini_update_sound( running_machine *machine )
206{
207   /* Check if sound should be muted */
208   if ( pm_reg[0x70] & 0x03 )
209   {
210      speaker_level_w( 0, 0 );
211   }
212   else
213   {
214      static const int levels[4] = { 0, 1, 1, 2 };
215      int level = levels[ pm_reg[0x71] & 0x03 ];
216
217//      if ( ( ( pm_reg[0x48] & 0x80 ) && ( pm_reg[0x4E] | ( pm_reg[0x4F] << 8 ) ) > ( pm_reg[0x4C] | ( pm_reg[0x4D] << 8 ) ) )
218//        || ( ( pm_reg[0x48] & 0x80 ) && pm_reg[0x4F] > pm_reg[0x4D] ) )
219//      {
220         level = 0;
221//      }
222
223      speaker_level_w( 0, level );
224   }
225}
226
227
203228static TIMER_CALLBACK(pokemini_seconds_timer_callback)
204229{
205230   if ( pm_reg[0x08] & 0x01 )
r2828r2829
356381         pm_reg[0x4E] = pm_reg[0x4A];
357382      }
358383   }
384
385   if ( pm_reg[0x48] & 0x80 )
386   {
387      if (  ( pm_reg[0x4E] == pm_reg[0x4C] ) && ( pm_reg[0x4F] == pm_reg[0x4D] ) )
388      {
389         pm_reg[0x27] |= 0x01;
390         pokemini_check_irqs( machine );
391      }
392      pokemini_update_sound( machine );
393   }
359394}
360395
361396
r2828r2829
369404      pokemini_check_irqs( machine );
370405      pm_reg[0x4F] = pm_reg[0x4B];
371406   }
407
408   if ( ! ( pm_reg[0x48] & 0x80 ) )
409   {
410      if( pm_reg[0x4F] == pm_reg[0x4D] )
411      {
412         pm_reg[0x27] |= 0x01;
413         pokemini_check_irqs( machine );
414      }
415      pokemini_update_sound( machine );
416   }
372417}
373418
374419
r2828r2829
377422   static const int timer_to_cycles_fast[8] = { 2, 8, 32, 64, 128, 256, 1024, 4096 };
378423   static const int timer_to_cycles_slow[8] = { 128, 256, 512, 1024, 2048, 4096, 8192, 16384 };
379424
380   logerror( "%0X: Write to hardware address: %02X, %02X\n", activecpu_get_pc(), offset, data );
425   //logerror( "%0X: Write to hardware address: %02X, %02X\n", activecpu_get_pc(), offset, data );
381426
382427   switch( offset )
383428   {
r2828r2829
10761121      {
10771122         timer_enable( timers.timer3_hi, 0 );
10781123      }
1124      pm_reg[0x48] = data;
1125      pokemini_update_sound( machine );
10791126      break;
10801127   case 0x49:   /* Timer 3 control 2
10811128            Bit 0   R/W Unknown
r2828r2829
11001147      {
11011148         timer_enable( timers.timer3_hi, 0 );
11021149      }
1150      pm_reg[0x49] = data;
1151      pokemini_update_sound( machine );
11031152      break;
11041153   case 0x4A:   /* Timer 3 preset value (low)
11051154            Bit 0-7 R/W Timer 3 preset value bit 0-7
11061155         */
1156      pm_reg[0x4A] = data;
1157      pokemini_update_sound( machine );
11071158      break;
11081159   case 0x4B:   /* Timer 3 preset value (high)
11091160            Bit 0-7 R/W Timer 3 preset value bit 8-15
11101161         */
1162      pm_reg[0x4B] = data;
1163      pokemini_update_sound( machine );
11111164      break;
11121165   case 0x4C:   /* Timer 3 sound-pivot (low)
11131166            Bit 0-7 R/W Timer 3 sound-pivot value bit 0-7
11141167         */
1168      pm_reg[0x4C] = data;
1169      pokemini_update_sound( machine );
1170      break;
11151171   case 0x4D:   /* Timer 3 sound-pivot (high)
11161172            Bit 0-7 R/W Timer 3 sound-pivot value bit 8-15
11171173
r2828r2829
11201176            Pulse-Width of 50% = Half of preset-value
11211177            Pulse-Width of 100% = Same as preset-value
11221178         */
1123      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", activecpu_get_pc(), offset, data );
1179      pm_reg[0x4D] = data;
1180      pokemini_update_sound( machine );
11241181      break;
11251182   case 0x4E:   /* Timer 3 counter (low), read only
11261183            Bit 0-7 R/W Timer 3 counter value bit 0-7
r2828r2829
11511208            Bit 6   R/W Unknown
11521209            Bit 7   R/W Unknown
11531210         */
1211      break;
11541212   case 0x61:   /* I/O peripheral status control
11551213            Bit 0   R/W IR received bit (if device not selected: 0)
11561214            Bit 1   R/W IR transmit (if device not selected: 0)
r2828r2829
11611219            Bit 6       Always 1
11621220            Bit 7   R/W IR received bit (mirror, if device not selected: 0)
11631221         */
1222      if ( pm_reg[0x60] & 0x04 )
1223         i2cmem_write( 0, I2CMEM_SDA, ( data & 0x04 ) ? 1 : 0 );
1224
1225      if ( pm_reg[0x60] & 0x08 )
1226         i2cmem_write( 0, I2CMEM_SCL, ( data & 0x08 ) ? 1 : 0 );
1227      break;
1228   case 0x70:   /* Sound related */
1229      pm_reg[0x70] = data;
1230      pokemini_update_sound( machine );
1231      break;
11641232   case 0x71:   /* Sound volume
11651233            Bit 0-1 R/W Sound volume
11661234                        00 - 0%
r2828r2829
11701238            Bit 2   R/W Always set to 0
11711239            Bit 3-7     Unused
11721240         */
1173      logerror( "%0X: Write to unknown hardware address: %02X, %02X\n", activecpu_get_pc(), offset, data );
1241      pm_reg[0x71] = data;
1242      pokemini_update_sound( machine );
11741243      break;
11751244   case 0x80:   /* LCD control
11761245            Bit 0   R/W Invert colors; 0 - normal, 1 - inverted
r2828r2829
13071376
13081377READ8_HANDLER( pokemini_hwreg_r )
13091378{
1379   UINT8 data = pm_reg[offset];
1380
13101381   switch( offset )
13111382   {
13121383   case 0x52:   return input_port_read(machine, "INPUTS");
1384   case 0x61:
1385      if ( ! ( pm_reg[0x60] & 0x04 ) )
1386      {
1387         data = ( data & ~ 0x04 ) | ( i2cmem_read( 0, I2CMEM_SDA ) ? 0x04 : 0x00 );
1388      }
1389
1390      if ( ! ( pm_reg[0x60] & 0x08 ) )
1391      {
1392         data &= ~0x08;
1393      }
1394      break;
13131395   case 0x81:   return ( pm_reg[offset] & 0x0F ) | ( prc.frame_count << 4 );
13141396   case 0x8A:   return prc.count;
13151397   }
1316   return pm_reg[offset];
1398   return data;
13171399}
13181400
13191401DEVICE_START( pokemini_cart )
r2828r2829
13561438{
13571439   prc.count++;
13581440
1359logerror("prc.count is %02x\n", prc.count);
13601441   /* Check for overflow */
13611442   if ( prc.count >= 0x42 )
13621443   {
src/mess/drivers/pokemini.c
r2828r2829
88********************************************************************/
99
1010#include "driver.h"
11#include "sound/speaker.h"
12#include "machine/i2cmem.h"
1113#include "includes/pokemini.h"
1214#include "cpu/minx/minx.h"
1315#include "devices/cartslot.h"
r2828r2829
5153}
5254
5355
56static const struct Speaker_interface speaker_interface =
57{
58   3,            /* optional: number of different levels */
59   NULL         /* optional: level lookup table */
60};
61
62
5463static MACHINE_DRIVER_START( pokemini )
5564   /* basic machine hardware */
5665   MDRV_CPU_ADD_TAG( "main", MINX, 4000000 )
r2828r2829
6069
6170   MDRV_MACHINE_RESET( pokemini )
6271
72   MDRV_NVRAM_HANDLER( i2cmem_0 )
73
6374   /* video hardware */
6475   MDRV_VIDEO_START( generic_bitmapped )
6576   MDRV_VIDEO_UPDATE( generic_bitmapped )
r2828r2829
7485   MDRV_SCREEN_REFRESH_RATE( 72 )
7586
7687   /* sound hardware */
77#if 0   
78   MDRV_SPEAKER_STANDARD_STEREO( "left", "right" )
79   MDRV_SOUND_ROUTE( 0, "left", 0.50 )
80   MDRV_SOUND_ROUTE( 0, "right", 0.50 )
81#endif
88   MDRV_SPEAKER_STANDARD_MONO("mono")
89   MDRV_SOUND_ADD(SPEAKER, 0)
90   MDRV_SOUND_CONFIG(speaker_interface)
91   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
8292MACHINE_DRIVER_END
8393
8494
95static DRIVER_INIT( pokemini )
96{
97   i2cmem_init( 0, I2CMEM_SLAVE_ADDRESS, 0, 0x2000, NULL);
98}
99
100
85101static void pokemini_cartslot_getinfo( const mess_device_class *devclass, UINT32 state, union devinfo *info )
86102{
87103   switch( state )
r2828r2829
107123ROM_END
108124
109125
110CONS( 1999, pokemini, 0, 0, pokemini, pokemini, 0, pokemini, "Nintendo", "Pokemon Mini", GAME_NOT_WORKING )
126CONS( 1999, pokemini, 0, 0, pokemini, pokemini, pokemini, pokemini, "Nintendo", "Pokemon Mini", GAME_NOT_WORKING )
111127

Previous 15994 Revisions Next


© 1998-2018 The MESS Team