Previous 15994 Revisions Next

r2807 Tuesday 3rd June, 2008 at 17:30:38 UTC by Wilbert Pol
[POKEMINI] Rendering IRQs are now triggered at a more correct time. Added rendering of sprites.
[src/mess/machine]pokemini.c

src/mess/machine/pokemini.c
r2806r2807
13621362   {
13631363      prc.count = 0;
13641364      prc.frame_count++;
1365
1366      if ( prc.frame_count >= prc.max_frame_count )
1365   }
1366   else
1367   {
1368      if ( prc.count == 0x18 && prc.frame_count >= prc.max_frame_count )
13671369      {
13681370         prc.frame_count = 0;
13691371
r2806r2807
13851387         /* Check if the sprites should be drawn */
13861388         if ( prc.sprites_enabled )
13871389         {
1390            UINT16   spr;
1391
1392            for ( spr = 0x35C; spr >= 0x300; spr -= 4 )
1393            {
1394               int      spr_x = ( pokemini_ram[ spr + 0 ] & 0x7F ) - 16;
1395               int      spr_y = ( pokemini_ram[ spr + 1 ] & 0x7F ) - 16;
1396               UINT8   spr_tile = pokemini_ram[ spr + 2 ];
1397               UINT8   spr_flag = pokemini_ram[ spr + 3 ];
1398
1399               if ( spr_flag & 0x08 )
1400               {
1401                  UINT16   gfx, mask;
1402                  UINT32   spr_base = prc.spr_tiles + spr_tile * 64;
1403                  int      i, j;
1404
1405                  for ( i = 0; i < 16; i++ )
1406                  {
1407                     if ( spr_x + i >= 0 && spr_x + i < 96 )
1408                     {
1409                        int rel_x = ( spr_flag & 0x01 ) ? 15 - i : i;
1410                        UINT32   s = spr_base + ( ( rel_x & 0x08 ) << 2 ) + ( rel_x & 0x07 );
1411
1412                        mask = ~ ( program_read_byte( s ) | ( program_read_byte( s + 8 ) << 8 ) );
1413                        gfx = program_read_byte( s + 16 ) | ( program_read_byte( s + 24 ) << 8 );
1414
1415                        /* Are the colors inverted? */
1416                        if ( spr_flag & 0x04 )
1417                        {
1418                           gfx = ~gfx;
1419                        }
1420
1421                        for ( j = 0; j < 16; j++ )
1422                        {
1423                           if ( spr_y + j >= 0 && spr_y + j < 64 )
1424                           {
1425                              UINT16   ram_addr = ( ( ( spr_y + j ) >> 3 ) * 96 ) + spr_x + i;
1426
1427                              if ( spr_flag & 0x02 )
1428                              {
1429                                 if ( mask & 0x8000 || 1 )
1430                                 {
1431                                    pokemini_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
1432                                    if ( gfx & 0x8000 )
1433                                    {
1434                                       pokemini_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
1435                                    }
1436                                 }
1437                                 mask <<= 1;
1438                                 gfx <<= 1;
1439                              }
1440                              else
1441                              {
1442                                 if ( mask & 0x0001 || 1 )
1443                                 {
1444                                    pokemini_ram[ ram_addr ] &= ~ ( 1 << ( ( spr_y + j ) & 0x07 ) );
1445                                    if ( gfx & 0x0001 )
1446                                    {
1447                                       pokemini_ram[ ram_addr ] |= ( 1 << ( ( spr_y + j ) & 0x07 ) );
1448                                    }
1449                                 }
1450                                 mask >>= 1;
1451                                 gfx >>= 1;
1452                              }
1453                           }
1454                        }
1455                     }
1456                  }
1457               }
1458            }
13881459         }
13891460
13901461         /* Set PRC Render interrupt */
r2806r2807
14101481                  *BITMAP_ADDR16(tmpbitmap, y + 7, x) = ( data & 0x80 ) ? 3 : 0;
14111482               }
14121483            }
1484
1485            /* Set PRC Copy interrupt */
1486            pm_reg[0x27] |= 0x80;
1487            pokemini_check_irqs( machine );
14131488         }
1414
1415         /* Set PRC Copy interrupt */
1416         pm_reg[0x27] |= 0x80;
1417         pokemini_check_irqs( machine );
14181489      }
14191490
14201491      /* Set possible input irqs */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team