Previous 15994 Revisions Next

r8747 Monday 9th August, 2010 at 13:03:36 UTC by Robbbert
[GAMECOM] small tidyup
[src/mess/machine]gamecom.c

src/mess/machine/gamecom.c
r8746r8747
4040   int enabled;
4141   int state_count;
4242   int state_limit;
43   int counter;
4443   int check_value;
4544} GAMECOM_TIMER;
4645
r8746r8747
206205      break;
207206   case SM8521_TM0D:
208207      gamecom_timer[0].check_value = data;
209      break;
208      return;
210209   case SM8521_TM0C:
211210      gamecom_timer[0].enabled = data & 0x80;
212211      gamecom_timer[0].state_limit = gamecom_timer_limit[data & 0x07];
213212      gamecom_timer[0].state_count = 0;
214      gamecom_timer[0].counter = 0;
213      RAM[SM8521_TM0D] = 0;
215214      break;
216215   case SM8521_TM1D:
217216      gamecom_timer[1].check_value = data;
218      break;
217      return;
219218   case SM8521_TM1C:
220219      gamecom_timer[1].enabled = data & 0x80;
221220      gamecom_timer[1].state_limit = gamecom_timer_limit[data & 0x07];
222221      gamecom_timer[1].state_count = 0;
223      gamecom_timer[1].counter = 0;
222      RAM[SM8521_TM1D] = 0;
224223      break;
225224   case SM8521_CLKT:   /* bit 6-7 */
226225      if ( data & 0x80 )
r8746r8747
334333
335334READ8_HANDLER( gamecom_internal_r )
336335{
337   /* NPW 22-Dec-2008 - Shouldn't this entire function be moved to an internal memory map of the CPU core? */
338336   UINT8 * RAM = memory_region(space->machine, "maincpu");
339   offset += 0x20;
340   UINT8 data = RAM[offset];
341   switch( offset )
342   {
343   case SM8521_TM0D:   return gamecom_timer[0].counter;
344   case SM8521_TM1D:   return gamecom_timer[1].counter;
345//  case SM8521_CLKT:   /* bit 0-5 read only, 6-7 read/write */
346//          return ( RAM[offset] & 0xC0 ) | ( clock_timer_val & 0x3F );
347   }
348   return data;
337   return RAM[offset + 0x20];
349338}
350339
351340WRITE8_HANDLER( gamecom_pio_w )
r8746r8747
629618
630619void gamecom_update_timers( running_device *device, int cycles )
631620{
621   UINT8 * RAM = memory_region(device->machine, "maincpu");
632622   if ( gamecom_timer[0].enabled )
633623   {
634624      gamecom_timer[0].state_count += cycles;
635625      while ( gamecom_timer[0].state_count >= gamecom_timer[0].state_limit )
636626      {
637627         gamecom_timer[0].state_count -= gamecom_timer[0].state_limit;
638         gamecom_timer[0].counter++;
639         if ( gamecom_timer[0].counter == gamecom_timer[0].check_value )
628         RAM[SM8521_TM0D]++;
629         if ( RAM[SM8521_TM0D] >= gamecom_timer[0].check_value )
640630         {
641            gamecom_timer[0].counter = 0;
631            RAM[SM8521_TM0D] = 0;
642632            cputag_set_input_line(device->machine, "maincpu", TIM0_INT, ASSERT_LINE );
643633         }
644634      }
r8746r8747
649639      while ( gamecom_timer[1].state_count >= gamecom_timer[1].state_limit )
650640      {
651641         gamecom_timer[1].state_count -= gamecom_timer[1].state_limit;
652         gamecom_timer[1].counter++;
653         if ( gamecom_timer[1].counter == gamecom_timer[1].check_value )
642         RAM[SM8521_TM1D]++;
643         if ( RAM[SM8521_TM1D] >= gamecom_timer[1].check_value )
654644         {
655            gamecom_timer[1].counter = 0;
645            RAM[SM8521_TM1D] = 0;
656646            cputag_set_input_line(device->machine, "maincpu", TIM1_INT, ASSERT_LINE );
657647         }
658648      }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team