trunk/src/mame/drivers/atarigx2.c
| r24781 | r24782 | |
| 103 | 103 | if (ACCESSING_BITS_24_31) |
| 104 | 104 | { |
| 105 | 105 | /* bits 13-11 are the MO control bits */ |
| 106 | | atarirle_control_w(m_rle, (data >> 27) & 7); |
| 106 | m_rle->control_write(space, offset, (data >> 27) & 7); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /* lower byte */ |
| r24781 | r24782 | |
| 116 | 116 | { |
| 117 | 117 | COMBINE_DATA(m_mo_command); |
| 118 | 118 | if (ACCESSING_BITS_0_15) |
| 119 | | atarirle_command_w(m_rle, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); |
| 119 | m_rle->command_write(space, offset, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| r24781 | r24782 | |
| 1139 | 1139 | AM_RANGE(0xd40000, 0xd40fff) AM_RAM_WRITE(paletteram32_666_w) AM_SHARE("paletteram") |
| 1140 | 1140 | AM_RANGE(0xd72000, 0xd75fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield") |
| 1141 | 1141 | AM_RANGE(0xd76000, 0xd76fff) AM_DEVWRITE("alpha", tilemap_device, write) AM_SHARE("alpha") |
| 1142 | | AM_RANGE(0xd78000, 0xd78fff) AM_DEVREADWRITE_LEGACY("rle", atarirle_spriteram32_r, atarirle_spriteram32_w) |
| 1142 | AM_RANGE(0xd78000, 0xd78fff) AM_RAM AM_SHARE("rle") |
| 1143 | 1143 | AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_SHARE("mo_command") |
| 1144 | 1144 | AM_RANGE(0xd70000, 0xd7ffff) AM_RAM |
| 1145 | 1145 | AM_RANGE(0xd80000, 0xd9ffff) AM_WRITE16(eeprom_enable_w, 0xffffffff) |
| r24781 | r24782 | |
| 1356 | 1356 | GFXDECODE_ENTRY( "gfx1", 0, pftoplayout, 0x000, 64 ) |
| 1357 | 1357 | GFXDECODE_END |
| 1358 | 1358 | |
| 1359 | | static const atarirle_desc modesc_0x200 = |
| 1359 | static const atari_rle_objects_config modesc_0x200 = |
| 1360 | 1360 | { |
| 1361 | | "gfx3", /* region where the GFX data lives */ |
| 1362 | | 256, /* number of entries in sprite RAM */ |
| 1363 | 1361 | 0, /* left clip coordinate */ |
| 1364 | 1362 | 0, /* right clip coordinate */ |
| 1365 | | |
| 1366 | 1363 | 0x200, /* base palette entry */ |
| 1367 | | 0x400, /* maximum number of colors */ |
| 1368 | 1364 | |
| 1369 | 1365 | {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */ |
| 1370 | 1366 | {{ 0,0x01f0,0,0,0,0,0,0 }}, /* mask for the color */ |
| r24781 | r24782 | |
| 1377 | 1373 | {{ 0 }} /* mask for the VRAM target */ |
| 1378 | 1374 | }; |
| 1379 | 1375 | |
| 1380 | | static const atarirle_desc modesc_0x400 = |
| 1376 | static const atari_rle_objects_config modesc_0x400 = |
| 1381 | 1377 | { |
| 1382 | | "gfx3", /* region where the GFX data lives */ |
| 1383 | | 256, /* number of entries in sprite RAM */ |
| 1384 | 1378 | 0, /* left clip coordinate */ |
| 1385 | 1379 | 0, /* right clip coordinate */ |
| 1386 | | |
| 1387 | 1380 | 0x400, /* base palette entry */ |
| 1388 | | 0x400, /* maximum number of colors */ |
| 1389 | 1381 | |
| 1390 | 1382 | {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */ |
| 1391 | 1383 | {{ 0,0x03f0,0,0,0,0,0,0 }}, /* mask for the color */ |
| r24781 | r24782 | |
| 1429 | 1421 | /* the board uses a pair of GALs to determine H and V parameters */ |
| 1430 | 1422 | MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240) |
| 1431 | 1423 | MCFG_SCREEN_UPDATE_DRIVER(atarigx2_state, screen_update_atarigx2) |
| 1432 | | MCFG_SCREEN_VBLANK_DRIVER(atarigx2_state, screen_eof_atarigx2) |
| 1433 | 1424 | |
| 1434 | 1425 | MCFG_VIDEO_START_OVERRIDE(atarigx2_state,atarigx2) |
| 1435 | 1426 | |
| r24781 | r24782 | |
| 1444 | 1435 | |
| 1445 | 1436 | |
| 1446 | 1437 | static MACHINE_CONFIG_DERIVED( atarigx2_0x200, atarigx2 ) |
| 1447 | | MCFG_ATARIRLE_ADD( "rle", modesc_0x200 ) |
| 1438 | MCFG_ATARIRLE_ADD("rle", modesc_0x200) |
| 1448 | 1439 | MACHINE_CONFIG_END |
| 1449 | 1440 | |
| 1450 | 1441 | static MACHINE_CONFIG_DERIVED( atarigx2_0x400, atarigx2 ) |
| 1451 | | MCFG_ATARIRLE_ADD( "rle", modesc_0x400 ) |
| 1442 | MCFG_ATARIRLE_ADD("rle", modesc_0x400) |
| 1452 | 1443 | MACHINE_CONFIG_END |
| 1453 | 1444 | |
| 1454 | 1445 | |
| r24781 | r24782 | |
| 1478 | 1469 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1479 | 1470 | ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */ |
| 1480 | 1471 | |
| 1481 | | ROM_REGION16_BE( 0x600000, "gfx3", 0 ) |
| 1472 | ROM_REGION16_BE( 0x600000, "rle", 0 ) |
| 1482 | 1473 | ROM_LOAD16_BYTE( "136095.41b", 0x000000, 0x80000, CRC(02ce7e07) SHA1(a48a6930c8ca4e2d0e4bc77a558730fa790be3b5) ) |
| 1483 | 1474 | ROM_LOAD16_BYTE( "136095.40b", 0x000001, 0x80000, CRC(abb80720) SHA1(0e02688454f59b90d38d548808f794294f5c9e7e) ) |
| 1484 | 1475 | ROM_LOAD16_BYTE( "136095.43b", 0x100000, 0x80000, CRC(26526345) SHA1(30ef83f63aca3a846dfc2828e3147208e3e350ca) ) |
| r24781 | r24782 | |
| 1524 | 1515 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1525 | 1516 | ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */ |
| 1526 | 1517 | |
| 1527 | | ROM_REGION16_BE( 0x600000, "gfx3", 0 ) |
| 1518 | ROM_REGION16_BE( 0x600000, "rle", 0 ) |
| 1528 | 1519 | ROM_LOAD16_BYTE( "136095.41b", 0x000000, 0x80000, CRC(02ce7e07) SHA1(a48a6930c8ca4e2d0e4bc77a558730fa790be3b5) ) |
| 1529 | 1520 | ROM_LOAD16_BYTE( "136095.40b", 0x000001, 0x80000, CRC(abb80720) SHA1(0e02688454f59b90d38d548808f794294f5c9e7e) ) |
| 1530 | 1521 | ROM_LOAD16_BYTE( "136095.43b", 0x100000, 0x80000, CRC(26526345) SHA1(30ef83f63aca3a846dfc2828e3147208e3e350ca) ) |
| r24781 | r24782 | |
| 1570 | 1561 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1571 | 1562 | ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */ |
| 1572 | 1563 | |
| 1573 | | ROM_REGION16_BE( 0x600000, "gfx3", 0 ) |
| 1564 | ROM_REGION16_BE( 0x600000, "rle", 0 ) |
| 1574 | 1565 | ROM_LOAD16_BYTE( "136095.41a", 0x000000, 0x80000, CRC(5f9743ee) SHA1(fa521572f8dd2eda566f90d1345adba3d0b8c48f) ) |
| 1575 | 1566 | ROM_LOAD16_BYTE( "136095.40a", 0x000001, 0x80000, CRC(99b26863) SHA1(21682771d310c73d4431dde5e72398a69a6f3d53) ) |
| 1576 | 1567 | ROM_LOAD16_BYTE( "136095.43a", 0x100000, 0x80000, CRC(9c0e09a5) SHA1(039dc52318935f686230f57a7b39b9c62280cbf9) ) |
| r24781 | r24782 | |
| 1616 | 1607 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1617 | 1608 | ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */ |
| 1618 | 1609 | |
| 1619 | | ROM_REGION16_BE( 0x600000, "gfx3", 0 ) |
| 1610 | ROM_REGION16_BE( 0x600000, "rle", 0 ) |
| 1620 | 1611 | ROM_LOAD16_BYTE( "136095.41a", 0x000000, 0x80000, CRC(5f9743ee) SHA1(fa521572f8dd2eda566f90d1345adba3d0b8c48f) ) |
| 1621 | 1612 | ROM_LOAD16_BYTE( "136095.40a", 0x000001, 0x80000, CRC(99b26863) SHA1(21682771d310c73d4431dde5e72398a69a6f3d53) ) |
| 1622 | 1613 | ROM_LOAD16_BYTE( "136095.43a", 0x100000, 0x80000, CRC(9c0e09a5) SHA1(039dc52318935f686230f57a7b39b9c62280cbf9) ) |
| r24781 | r24782 | |
| 1662 | 1653 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1663 | 1654 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1664 | 1655 | |
| 1665 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1656 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1666 | 1657 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1667 | 1658 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1668 | 1659 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1710 | 1701 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1711 | 1702 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1712 | 1703 | |
| 1713 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1704 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1714 | 1705 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1715 | 1706 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1716 | 1707 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1762 | 1753 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1763 | 1754 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1764 | 1755 | |
| 1765 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1756 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1766 | 1757 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1767 | 1758 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1768 | 1759 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1811 | 1802 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1812 | 1803 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1813 | 1804 | |
| 1814 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1805 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1815 | 1806 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1816 | 1807 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1817 | 1808 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1860 | 1851 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1861 | 1852 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1862 | 1853 | |
| 1863 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1854 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1864 | 1855 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1865 | 1856 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1866 | 1857 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1908 | 1899 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1909 | 1900 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1910 | 1901 | |
| 1911 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1902 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1912 | 1903 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1913 | 1904 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1914 | 1905 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 1956 | 1947 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1957 | 1948 | ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */ |
| 1958 | 1949 | |
| 1959 | | ROM_REGION16_BE( 0x700000, "gfx3", 0 ) |
| 1950 | ROM_REGION16_BE( 0x700000, "rle", 0 ) |
| 1960 | 1951 | ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) ) |
| 1961 | 1952 | ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) ) |
| 1962 | 1953 | ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) ) |
| r24781 | r24782 | |
| 2000 | 1991 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 2001 | 1992 | ROM_LOAD( "alpha.13n", 0x000000, 0x20000, CRC(f2efbd66) SHA1(d5339f0b3de7a102d659f7459b5f4800cab31829) ) /* alphanumerics */ |
| 2002 | 1993 | |
| 2003 | | ROM_REGION16_BE( 0x500000, "gfx3", 0 ) |
| 1994 | ROM_REGION16_BE( 0x500000, "rle", 0 ) |
| 2004 | 1995 | ROM_LOAD16_BYTE( "mo0h.31n", 0x000000, 0x80000, CRC(fc2755d5) SHA1(e24319161307efbb3828b21a6250869051f1ccc1) ) |
| 2005 | 1996 | ROM_LOAD16_BYTE( "mo0l.31l", 0x000001, 0x80000, CRC(f9f6bfe3) SHA1(c7e1479bb86646691d5ca7ee9127553cfd86571e) ) |
| 2006 | 1997 | ROM_LOAD16_BYTE( "rrmo1h.33n", 0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) ) |
| r24781 | r24782 | |
| 2066 | 2057 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 2067 | 2058 | ROM_LOAD( "alpha.13n", 0x000000, 0x20000, CRC(f2efbd66) SHA1(d5339f0b3de7a102d659f7459b5f4800cab31829) ) /* alphanumerics */ |
| 2068 | 2059 | |
| 2069 | | ROM_REGION16_BE( 0x500000, "gfx3", 0 ) |
| 2060 | ROM_REGION16_BE( 0x500000, "rle", 0 ) |
| 2070 | 2061 | ROM_LOAD16_BYTE( "mo0h.31n", 0x000000, 0x80000, CRC(fc2755d5) SHA1(e24319161307efbb3828b21a6250869051f1ccc1) ) |
| 2071 | 2062 | ROM_LOAD16_BYTE( "mo0l.31l", 0x000001, 0x80000, CRC(f9f6bfe3) SHA1(c7e1479bb86646691d5ca7ee9127553cfd86571e) ) |
| 2072 | 2063 | ROM_LOAD16_BYTE( "rrmo1h.33n", 0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) ) |
| r24781 | r24782 | |
| 2126 | 2117 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 2127 | 2118 | ROM_LOAD( "rralalph.13n", 0x000000, 0x20000, CRC(7ca93790) SHA1(5e2f069be4b15d63f418c8693e8550eb0ae22381) ) /* alphanumerics */ |
| 2128 | 2119 | |
| 2129 | | ROM_REGION16_BE( 0x500000, "gfx3", 0 ) |
| 2120 | ROM_REGION16_BE( 0x500000, "rle", 0 ) |
| 2130 | 2121 | ROM_LOAD16_BYTE( "rrmo0h.31n", 0x000000, 0x80000, CRC(9b7e0315) SHA1(856804e89f586a4e777da5f47dc29c4e34175f44) ) |
| 2131 | 2122 | ROM_LOAD16_BYTE( "rrmo0l.31l", 0x000001, 0x80000, CRC(10478697) SHA1(9682e82cfbdc20f63d5c49303265c598a334c15b) ) |
| 2132 | 2123 | ROM_LOAD16_BYTE( "rrmo1h.33n", 0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) ) |
trunk/src/mame/drivers/atarig1.c
| r24781 | r24782 | |
| 58 | 58 | * |
| 59 | 59 | *************************************/ |
| 60 | 60 | |
| 61 | | WRITE16_MEMBER(atarig1_state::mo_control_w) |
| 62 | | { |
| 63 | | if (ACCESSING_BITS_0_7) |
| 64 | | { |
| 65 | | atarirle_control_w(m_rle, data & 7); |
| 66 | | } |
| 67 | | } |
| 68 | | |
| 69 | | |
| 70 | 61 | WRITE16_MEMBER(atarig1_state::mo_command_w) |
| 71 | 62 | { |
| 72 | 63 | COMBINE_DATA(m_mo_command); |
| 73 | | atarirle_command_w(m_rle, (data == 0 && m_is_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); |
| 64 | m_rle->command_write(space, offset, (data == 0 && m_is_pitfight) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW); |
| 74 | 65 | } |
| 75 | 66 | |
| 76 | 67 | |
| r24781 | r24782 | |
| 203 | 194 | AM_RANGE(0xf88000, 0xf8ffff) AM_WRITE(eeprom_enable_w) |
| 204 | 195 | AM_RANGE(0xf90000, 0xf90001) AM_DEVWRITE8("jsa", atari_jsa_ii_device, main_command_w, 0xff00) |
| 205 | 196 | AM_RANGE(0xf98000, 0xf98001) AM_DEVWRITE("jsa", atari_jsa_ii_device, sound_reset_w) |
| 206 | | AM_RANGE(0xfa0000, 0xfa0001) AM_WRITE(mo_control_w) |
| 197 | AM_RANGE(0xfa0000, 0xfa0001) AM_DEVWRITE8("rle", atari_rle_objects_device, control_write, 0x00ff) |
| 207 | 198 | AM_RANGE(0xfb0000, 0xfb0001) AM_WRITE(video_int_ack_w) |
| 208 | 199 | AM_RANGE(0xfc0000, 0xfc0001) AM_READ(special_port0_r) |
| 209 | 200 | AM_RANGE(0xfc8000, 0xfc8007) AM_READWRITE(a2d_data_r, a2d_select_w) |
| r24781 | r24782 | |
| 211 | 202 | AM_RANGE(0xfd8000, 0xfdffff) AM_READWRITE(eeprom_r, eeprom_w) AM_SHARE("eeprom") |
| 212 | 203 | /* AM_RANGE(0xfe0000, 0xfe7fff) AM_READ(from_r)*/ |
| 213 | 204 | AM_RANGE(0xfe8000, 0xfe89ff) AM_RAM_WRITE(paletteram_666_w) AM_SHARE("paletteram") |
| 214 | | AM_RANGE(0xff0000, 0xff0fff) AM_DEVREADWRITE_LEGACY("rle", atarirle_spriteram_r, atarirle_spriteram_w) |
| 205 | AM_RANGE(0xff0000, 0xff0fff) AM_RAM AM_SHARE("rle") |
| 215 | 206 | AM_RANGE(0xff2000, 0xff2001) AM_WRITE(mo_command_w) AM_SHARE("mo_command") |
| 216 | 207 | AM_RANGE(0xff4000, 0xff5fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield") |
| 217 | 208 | AM_RANGE(0xff6000, 0xff6fff) AM_DEVWRITE("alpha", tilemap_device, write) AM_SHARE("alpha") |
| r24781 | r24782 | |
| 388 | 379 | |
| 389 | 380 | |
| 390 | 381 | |
| 391 | | static const atarirle_desc modesc_hydra = |
| 382 | static const atari_rle_objects_config modesc_hydra = |
| 392 | 383 | { |
| 393 | | "gfx3", /* region where the GFX data lives */ |
| 394 | | 256, /* number of entries in sprite RAM */ |
| 395 | 384 | 0, /* left clip coordinate */ |
| 396 | 385 | 255, /* right clip coordinate */ |
| 397 | | |
| 398 | 386 | 0x200, /* base palette entry */ |
| 399 | | 0x100, /* maximum number of colors */ |
| 400 | 387 | |
| 401 | 388 | {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */ |
| 402 | 389 | {{ 0,0x00f0,0,0,0,0,0,0 }}, /* mask for the color */ |
| r24781 | r24782 | |
| 409 | 396 | {{ 0 }} /* mask for the VRAM target */ |
| 410 | 397 | }; |
| 411 | 398 | |
| 412 | | static const atarirle_desc modesc_pitfight = |
| 399 | static const atari_rle_objects_config modesc_pitfight = |
| 413 | 400 | { |
| 414 | | "gfx3", /* region where the GFX data lives */ |
| 415 | | 256, /* number of entries in sprite RAM */ |
| 416 | 401 | 40, /* left clip coordinate */ |
| 417 | 402 | 295, /* right clip coordinate */ |
| 418 | | |
| 419 | 403 | 0x200, /* base palette entry */ |
| 420 | | 0x100, /* maximum number of colors */ |
| 421 | 404 | |
| 422 | 405 | {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */ |
| 423 | 406 | {{ 0,0x00f0,0,0,0,0,0,0 }}, /* mask for the color */ |
| r24781 | r24782 | |
| 460 | 443 | /* note: these parameters are from published specs, not derived */ |
| 461 | 444 | MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240) |
| 462 | 445 | MCFG_SCREEN_UPDATE_DRIVER(atarig1_state, screen_update_atarig1) |
| 463 | | MCFG_SCREEN_VBLANK_DRIVER(atarig1_state, screen_eof_atarig1) |
| 464 | 446 | |
| 465 | 447 | MCFG_VIDEO_START_OVERRIDE(atarig1_state,atarig1) |
| 466 | 448 | |
| r24781 | r24782 | |
| 473 | 455 | MACHINE_CONFIG_END |
| 474 | 456 | |
| 475 | 457 | static MACHINE_CONFIG_DERIVED( hydra, atarig1 ) |
| 476 | | MCFG_ATARIRLE_ADD( "rle", modesc_hydra ) |
| 458 | MCFG_ATARIRLE_ADD("rle", modesc_hydra) |
| 477 | 459 | MACHINE_CONFIG_END |
| 478 | 460 | |
| 479 | 461 | static MACHINE_CONFIG_DERIVED( pitfight, atarig1 ) |
| 480 | | MCFG_ATARIRLE_ADD( "rle", modesc_pitfight ) |
| 462 | MCFG_ATARIRLE_ADD("rle", modesc_pitfight) |
| 481 | 463 | MACHINE_CONFIG_END |
| 482 | 464 | |
| 483 | 465 | |
| r24781 | r24782 | |
| 517 | 499 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 518 | 500 | ROM_LOAD( "136079-1027.bin", 0x000000, 0x20000, CRC(f9135b9b) SHA1(48c0ad0d3e592d191d1385e30530bdb69a095452) ) /* alphanumerics */ |
| 519 | 501 | |
| 520 | | ROM_REGION16_BE( 0x100000, "gfx3", 0 ) |
| 502 | ROM_REGION16_BE( 0x100000, "rle", 0 ) |
| 521 | 503 | ROM_LOAD16_BYTE( "136079-1001.bin", 0x00001, 0x10000, CRC(3f757a53) SHA1(be2b7f8b907ef9ea24b24b7210ead70cdbad3506) ) |
| 522 | 504 | ROM_LOAD16_BYTE( "136079-1002.bin", 0x00000, 0x10000, CRC(a1169469) SHA1(b5ab65ca9d98ef1e79518eaa519fba0cee92c86e) ) |
| 523 | 505 | ROM_LOAD16_BYTE( "136079-1003.bin", 0x20001, 0x10000, CRC(aa21ec33) SHA1(dec65b670c64b3630f6ccbbcc3212f6771908de9) ) |
| r24781 | r24782 | |
| 577 | 559 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 578 | 560 | ROM_LOAD( "hydalph.bin", 0x000000, 0x20000, CRC(7dd2b062) SHA1(789b35b1e8cce73e2314d1b6688b5066df91b604) ) /* alphanumerics */ |
| 579 | 561 | |
| 580 | | ROM_REGION16_BE( 0x100000, "gfx3", 0 ) |
| 562 | ROM_REGION16_BE( 0x100000, "rle", 0 ) |
| 581 | 563 | ROM_LOAD16_BYTE( "hydmhi0.bin", 0x00001, 0x10000, CRC(3c83b42d) SHA1(3c6de7e6aab08a673227f06b04e000714a9111b1) ) |
| 582 | 564 | ROM_LOAD16_BYTE( "hydmlo0.bin", 0x00000, 0x10000, CRC(6d49650c) SHA1(97f9dbdfa5cc620705eec1da2398b2ac63cef30f) ) |
| 583 | 565 | ROM_LOAD16_BYTE( "hydmhi1.bin", 0x20001, 0x10000, CRC(689b3376) SHA1(85ffa31f10483317db615cf8e520a8c8a40d6013) ) |
| r24781 | r24782 | |
| 637 | 619 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 638 | 620 | ROM_LOAD( "136079-1027.bin", 0x000000, 0x20000, CRC(f9135b9b) SHA1(48c0ad0d3e592d191d1385e30530bdb69a095452) ) /* alphanumerics */ |
| 639 | 621 | |
| 640 | | ROM_REGION16_BE( 0x100000, "gfx3", 0 ) |
| 622 | ROM_REGION16_BE( 0x100000, "rle", 0 ) |
| 641 | 623 | ROM_LOAD16_BYTE( "136079-1001.bin", 0x00001, 0x10000, BAD_DUMP CRC(3f757a53) SHA1(be2b7f8b907ef9ea24b24b7210ead70cdbad3506) ) // not dumped from this pcb, rom taken from another set instead |
| 642 | 624 | ROM_LOAD16_BYTE( "136079-1002.bin", 0x00000, 0x10000, BAD_DUMP CRC(a1169469) SHA1(b5ab65ca9d98ef1e79518eaa519fba0cee92c86e) ) // " |
| 643 | 625 | ROM_LOAD16_BYTE( "136079-1003.bin", 0x20001, 0x10000, BAD_DUMP CRC(aa21ec33) SHA1(dec65b670c64b3630f6ccbbcc3212f6771908de9) ) // " |
| r24781 | r24782 | |
| 721 | 703 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 722 | 704 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 723 | 705 | |
| 724 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 706 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 725 | 707 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 726 | 708 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 727 | 709 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
| r24781 | r24782 | |
| 817 | 799 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 818 | 800 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 819 | 801 | |
| 820 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 802 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 821 | 803 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 822 | 804 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 823 | 805 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
| r24781 | r24782 | |
| 880 | 862 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 881 | 863 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 882 | 864 | |
| 883 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 865 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 884 | 866 | ROM_LOAD16_BYTE( "136081-1065.65r", 0x000001, 0x80000, CRC(6d3a834f) SHA1(6e153fee39b6a932aeb101e69e3557355a637c76) ) /* Same data as other sets, but in four mask roms */ |
| 885 | 867 | ROM_LOAD16_BYTE( "136081-1066.65n", 0x000000, 0x80000, CRC(0f7f5117) SHA1(e9d3d0db388a5f7d76de363018d92fa59bf8113a) ) |
| 886 | 868 | ROM_LOAD16_BYTE( "136081-1067.70r", 0x100001, 0x80000, CRC(ca4f75a8) SHA1(f8b8b03df4ad043a48970a0f8a4c3b85c7140493) ) |
| r24781 | r24782 | |
| 931 | 913 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 932 | 914 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 933 | 915 | |
| 934 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 916 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 935 | 917 | ROM_LOAD16_BYTE( "136081-1065.65r", 0x000001, 0x80000, CRC(6d3a834f) SHA1(6e153fee39b6a932aeb101e69e3557355a637c76) ) /* Same data as other sets, but in four mask roms */ |
| 936 | 918 | ROM_LOAD16_BYTE( "136081-1066.65n", 0x000000, 0x80000, CRC(0f7f5117) SHA1(e9d3d0db388a5f7d76de363018d92fa59bf8113a) ) |
| 937 | 919 | ROM_LOAD16_BYTE( "136081-1067.70r", 0x100001, 0x80000, CRC(ca4f75a8) SHA1(f8b8b03df4ad043a48970a0f8a4c3b85c7140493) ) |
| r24781 | r24782 | |
| 982 | 964 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 983 | 965 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 984 | 966 | |
| 985 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 967 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 986 | 968 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 987 | 969 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 988 | 970 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
| r24781 | r24782 | |
| 1045 | 1027 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1046 | 1028 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 1047 | 1029 | |
| 1048 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 1030 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 1049 | 1031 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 1050 | 1032 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 1051 | 1033 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
| r24781 | r24782 | |
| 1108 | 1090 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1109 | 1091 | ROM_LOAD( "136081-1427.dat", 0x000000, 0x20000, CRC(b2c51dff) SHA1(7ad82a6a55d3a68e39d113c92f9e89a43408b5b2) ) /* alphanumerics */ |
| 1110 | 1092 | |
| 1111 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 1093 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 1112 | 1094 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 1113 | 1095 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 1114 | 1096 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
| r24781 | r24782 | |
| 1171 | 1153 | ROM_REGION( 0x020000, "gfx2", 0 ) |
| 1172 | 1154 | ROM_LOAD( "136081-1027.15l", 0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */ |
| 1173 | 1155 | |
| 1174 | | ROM_REGION16_BE( 0x200000, "gfx3", 0 ) |
| 1156 | ROM_REGION16_BE( 0x200000, "rle", 0 ) |
| 1175 | 1157 | ROM_LOAD16_BYTE( "136081-1001.65r", 0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) ) |
| 1176 | 1158 | ROM_LOAD16_BYTE( "136081-1002.65n", 0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) ) |
| 1177 | 1159 | ROM_LOAD16_BYTE( "136081-1003.70r", 0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) ) |
trunk/src/mame/video/atarirle.c
| r24781 | r24782 | |
| 20 | 20 | |
| 21 | 21 | #include "emu.h" |
| 22 | 22 | #include "atarirle.h" |
| 23 | | #include "devlegcy.h" |
| 24 | 23 | |
| 25 | 24 | |
| 26 | | /*************************************************************************** |
| 27 | | TYPES & STRUCTURES |
| 28 | | ***************************************************************************/ |
| 25 | //************************************************************************** |
| 26 | // CONSTANTS |
| 27 | //************************************************************************** |
| 29 | 28 | |
| 30 | | /* internal structure containing a word index, shift and mask */ |
| 31 | | struct atarirle_mask |
| 32 | | { |
| 33 | | int word; /* word index */ |
| 34 | | int shift; /* shift amount */ |
| 35 | | int mask; /* final mask */ |
| 36 | | }; |
| 29 | const device_type ATARI_RLE_OBJECTS = &device_creator<atari_rle_objects_device>; |
| 37 | 30 | |
| 38 | | /* internal structure for sorting the motion objects */ |
| 39 | | struct mo_sort_entry |
| 40 | | { |
| 41 | | mo_sort_entry * next; |
| 42 | | int entry; |
| 43 | | }; |
| 44 | | |
| 45 | | /* internal structure describing each object in the ROMs */ |
| 46 | | struct atarirle_info |
| 47 | | { |
| 48 | | INT16 width; |
| 49 | | INT16 height; |
| 50 | | INT16 xoffs; |
| 51 | | INT16 yoffs; |
| 52 | | UINT8 bpp; |
| 53 | | const UINT16 * table; |
| 54 | | const UINT16 * data; |
| 55 | | }; |
| 56 | | |
| 57 | | /* internal structure containing the state of the motion objects */ |
| 58 | | struct atarirle_data |
| 59 | | { |
| 60 | | int bitmapwidth; /* width of the full playfield bitmap */ |
| 61 | | int bitmapheight; /* height of the full playfield bitmap */ |
| 62 | | int bitmapxmask; /* x coordinate mask for the playfield bitmap */ |
| 63 | | int bitmapymask; /* y coordinate mask for the playfield bitmap */ |
| 64 | | |
| 65 | | int spriterammask; /* combined mask when accessing sprite RAM with raw addresses */ |
| 66 | | int spriteramsize; /* total size of sprite RAM, in entries */ |
| 67 | | |
| 68 | | int palettebase; /* base palette entry */ |
| 69 | | int maxcolors; /* maximum number of colors */ |
| 70 | | |
| 71 | | rectangle cliprect; /* clipping rectangle */ |
| 72 | | |
| 73 | | atarirle_mask codemask; /* mask for the code index */ |
| 74 | | atarirle_mask colormask; /* mask for the color */ |
| 75 | | atarirle_mask xposmask; /* mask for the X position */ |
| 76 | | atarirle_mask yposmask; /* mask for the Y position */ |
| 77 | | atarirle_mask scalemask; /* mask for the scale factor */ |
| 78 | | atarirle_mask hflipmask; /* mask for the horizontal flip */ |
| 79 | | atarirle_mask ordermask; /* mask for the order */ |
| 80 | | atarirle_mask prioritymask; /* mask for the priority */ |
| 81 | | atarirle_mask vrammask; /* mask for the VRAM target */ |
| 82 | | |
| 83 | | const UINT16 * rombase; /* pointer to the base of the GFX ROM */ |
| 84 | | int romlength; /* length of the GFX ROM */ |
| 85 | | int objectcount; /* number of objects in the ROM */ |
| 86 | | atarirle_info * info; /* list of info records */ |
| 87 | | atarirle_entry *spriteram; /* pointer to sprite RAM */ |
| 88 | | |
| 89 | | bitmap_ind16 * vram[2][2]; /* pointers to VRAM bitmaps and backbuffers */ |
| 90 | | int partial_scanline; /* partial update scanline */ |
| 91 | | |
| 92 | | UINT8 control_bits; /* current control bits */ |
| 93 | | UINT8 command; /* current command */ |
| 94 | | UINT8 is32bit; /* 32-bit or 16-bit? */ |
| 95 | | UINT16 checksums[256]; /* checksums for each 0x40000 bytes */ |
| 96 | | UINT16 ram[0x1000/2]; |
| 97 | | }; |
| 98 | | |
| 99 | | |
| 100 | | |
| 101 | | /*************************************************************************** |
| 102 | | MACROS |
| 103 | | ***************************************************************************/ |
| 104 | | |
| 105 | | /* data extraction */ |
| 106 | | #define EXTRACT_DATA(_input, _mask) (((_input)->data[(_mask).word] >> (_mask).shift) & (_mask).mask) |
| 107 | | |
| 108 | | |
| 109 | 31 | enum { atarirle_hilite_index = -1 }; |
| 110 | 32 | |
| 111 | 33 | |
| 112 | 34 | |
| 113 | | /*************************************************************************** |
| 114 | | STATIC VARIABLES |
| 115 | | ***************************************************************************/ |
| 35 | //************************************************************************** |
| 36 | // INLINE FUNCTIONS |
| 37 | //************************************************************************** |
| 116 | 38 | |
| 117 | | static UINT8 rle_bpp[8]; |
| 118 | | static UINT16 *rle_table[8]; |
| 39 | //------------------------------------------------- |
| 40 | // round_to_powerof2: Rounds a number up to the |
| 41 | // nearest power of 2. Even powers of 2 are |
| 42 | // rounded up to the next greatest power |
| 43 | // (e.g., 4 returns 8). |
| 44 | //------------------------------------------------- |
| 119 | 45 | |
| 120 | | |
| 121 | | |
| 122 | | /*************************************************************************** |
| 123 | | STATIC FUNCTION DECLARATIONS |
| 124 | | ***************************************************************************/ |
| 125 | | |
| 126 | | static void build_rle_tables(running_machine &machine); |
| 127 | | static int count_objects(const UINT16 *base, int length); |
| 128 | | static void prescan_rle(const atarirle_data *mo, int which); |
| 129 | | static void sort_and_render(running_machine &machine, atarirle_data *mo); |
| 130 | | static void compute_checksum(atarirle_data *mo); |
| 131 | | static void draw_rle(atarirle_data *mo, bitmap_ind16 &bitmap, int code, int color, int hflip, int vflip, |
| 132 | | int x, int y, int xscale, int yscale, const rectangle &clip); |
| 133 | | static void draw_rle_zoom(bitmap_ind16 &bitmap, const atarirle_info *gfx, |
| 134 | | UINT32 palette, int sx, int sy, int scalex, int scaley, |
| 135 | | const rectangle &clip); |
| 136 | | static void draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const atarirle_info *gfx, |
| 137 | | UINT32 palette, int sx, int sy, int scalex, int scaley, |
| 138 | | const rectangle &clip); |
| 139 | | |
| 140 | | |
| 141 | | |
| 142 | | /*************************************************************************** |
| 143 | | INLINE FUNCTIONS |
| 144 | | ***************************************************************************/ |
| 145 | | |
| 146 | | INLINE atarirle_data *get_safe_token(device_t *device) |
| 46 | inline int atari_rle_objects_device::round_to_powerof2(int value) |
| 147 | 47 | { |
| 148 | | assert(device != NULL); |
| 149 | | assert(device->type() == ATARIRLE); |
| 150 | | |
| 151 | | return (atarirle_data *)downcast<atarirle_device *>(device)->token(); |
| 152 | | } |
| 153 | | |
| 154 | | |
| 155 | | /*--------------------------------------------------------------- |
| 156 | | compute_log: Computes the number of bits necessary to |
| 157 | | hold a given value. The input must be an even power of |
| 158 | | two. |
| 159 | | ---------------------------------------------------------------*/ |
| 160 | | |
| 161 | | #ifdef UNUSED_FUNCTION |
| 162 | | INLINE int compute_log(int value) |
| 163 | | { |
| 164 | 48 | int log = 0; |
| 165 | 49 | |
| 166 | 50 | if (value == 0) |
| 167 | | return -1; |
| 168 | | while (!(value & 1)) |
| 169 | | log++, value >>= 1; |
| 170 | | if (value != 1) |
| 171 | | return -1; |
| 172 | | return log; |
| 173 | | } |
| 174 | | #endif |
| 175 | | |
| 176 | | /*--------------------------------------------------------------- |
| 177 | | round_to_powerof2: Rounds a number up to the nearest |
| 178 | | power of 2. Even powers of 2 are rounded up to the |
| 179 | | next greatest power (e.g., 4 returns 8). |
| 180 | | ---------------------------------------------------------------*/ |
| 181 | | |
| 182 | | INLINE int round_to_powerof2(int value) |
| 183 | | { |
| 184 | | int log = 0; |
| 185 | | |
| 186 | | if (value == 0) |
| 187 | 51 | return 1; |
| 188 | 52 | while ((value >>= 1) != 0) |
| 189 | 53 | log++; |
| r24781 | r24782 | |
| 191 | 55 | } |
| 192 | 56 | |
| 193 | 57 | |
| 194 | | /*--------------------------------------------------------------- |
| 195 | | collapse_bits: Moving right-to-left, for each 1 bit in |
| 196 | | the mask, copy the corresponding bit from the input |
| 197 | | value into the result, packing the bits along the way. |
| 198 | | ---------------------------------------------------------------*/ |
| 199 | 58 | |
| 200 | | #ifdef UNUSED_FUNCTION |
| 201 | | INLINE int collapse_bits(int value, int mask) |
| 202 | | { |
| 203 | | int testmask, ormask; |
| 204 | | int result = 0; |
| 59 | //************************************************************************** |
| 60 | // CORE DEVICE IMPLEMENTATION |
| 61 | //************************************************************************** |
| 205 | 62 | |
| 206 | | for (testmask = ormask = 1; testmask != 0; testmask <<= 1) |
| 207 | | if (mask & testmask) |
| 208 | | { |
| 209 | | if (value & testmask) |
| 210 | | result |= ormask; |
| 211 | | ormask <<= 1; |
| 212 | | } |
| 213 | | return result; |
| 214 | | } |
| 215 | | #endif |
| 63 | //------------------------------------------------- |
| 64 | // atari_rle_objects_device: Constructor |
| 65 | //------------------------------------------------- |
| 216 | 66 | |
| 217 | | /*--------------------------------------------------------------- |
| 218 | | convert_mask: Converts a 4-word mask into a word index, |
| 219 | | shift, and adjusted mask. Returns 0 if invalid. |
| 220 | | ---------------------------------------------------------------*/ |
| 221 | | |
| 222 | | INLINE int convert_mask(const atarirle_entry *input, atarirle_mask *result) |
| 67 | atari_rle_objects_device::atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 68 | : device_t(mconfig, ATARI_RLE_OBJECTS, "Atari RLE Motion Objects", tag, owner, clock, "atari_rle", __FILE__), |
| 69 | device_video_interface(mconfig, *this) |
| 223 | 70 | { |
| 224 | | int i, temp; |
| 225 | | |
| 226 | | /* determine the word and make sure it's only 1 */ |
| 227 | | result->word = -1; |
| 228 | | for (i = 0; i < 8; i++) |
| 229 | | if (input->data[i]) |
| 230 | | { |
| 231 | | if (result->word == -1) |
| 232 | | result->word = i; |
| 233 | | else |
| 234 | | return 0; |
| 235 | | } |
| 236 | | |
| 237 | | /* if all-zero, it's valid */ |
| 238 | | if (result->word == -1) |
| 239 | | { |
| 240 | | result->word = result->shift = result->mask = 0; |
| 241 | | return 1; |
| 242 | | } |
| 243 | | |
| 244 | | /* determine the shift and final mask */ |
| 245 | | result->shift = 0; |
| 246 | | temp = input->data[result->word]; |
| 247 | | while (!(temp & 1)) |
| 248 | | { |
| 249 | | result->shift++; |
| 250 | | temp >>= 1; |
| 251 | | } |
| 252 | | result->mask = temp; |
| 253 | | return 1; |
| 254 | 71 | } |
| 255 | 72 | |
| 256 | 73 | |
| 257 | | |
| 258 | | /*************************************************************************** |
| 259 | | GLOBAL FUNCTIONS |
| 260 | | ***************************************************************************/ |
| 261 | | |
| 262 | | /*--------------------------------------------------------------- |
| 263 | | atarirle_init: Configures the motion objects using the input |
| 264 | | description. Allocates all memory necessary and generates |
| 265 | | the attribute lookup table. |
| 266 | | ---------------------------------------------------------------*/ |
| 267 | | |
| 268 | | static DEVICE_START( atarirle ) |
| 269 | | { |
| 270 | | atarirle_data *mo = get_safe_token(device); |
| 271 | | running_machine &machine = device->machine(); |
| 272 | | const atarirle_desc *desc = (const atarirle_desc *)device->static_config(); |
| 273 | | const UINT16 *base = (const UINT16 *)machine.root_device().memregion(desc->region)->base(); |
| 274 | | int i, width, height; |
| 275 | | |
| 276 | | /* build and allocate the generic tables */ |
| 277 | | build_rle_tables(machine); |
| 278 | | |
| 279 | | /* determine the masks first */ |
| 280 | | convert_mask(&desc->codemask, &mo->codemask); |
| 281 | | convert_mask(&desc->colormask, &mo->colormask); |
| 282 | | convert_mask(&desc->xposmask, &mo->xposmask); |
| 283 | | convert_mask(&desc->yposmask, &mo->yposmask); |
| 284 | | convert_mask(&desc->scalemask, &mo->scalemask); |
| 285 | | convert_mask(&desc->hflipmask, &mo->hflipmask); |
| 286 | | convert_mask(&desc->ordermask, &mo->ordermask); |
| 287 | | convert_mask(&desc->prioritymask, &mo->prioritymask); |
| 288 | | convert_mask(&desc->vrammask, &mo->vrammask); |
| 289 | | |
| 290 | | /* copy in the basic data */ |
| 291 | | mo->bitmapwidth = round_to_powerof2(mo->xposmask.mask); |
| 292 | | mo->bitmapheight = round_to_powerof2(mo->yposmask.mask); |
| 293 | | mo->bitmapxmask = mo->bitmapwidth - 1; |
| 294 | | mo->bitmapymask = mo->bitmapheight - 1; |
| 295 | | |
| 296 | | mo->spriteramsize = desc->spriteramentries; |
| 297 | | mo->spriterammask = desc->spriteramentries - 1; |
| 298 | | |
| 299 | | mo->palettebase = desc->palettebase; |
| 300 | | mo->maxcolors = desc->maxcolors / 16; |
| 301 | | |
| 302 | | mo->rombase = base; |
| 303 | | mo->romlength = machine.root_device().memregion(desc->region)->bytes(); |
| 304 | | mo->objectcount = count_objects(base, mo->romlength); |
| 305 | | |
| 306 | | mo->cliprect = machine.primary_screen->visible_area(); |
| 307 | | if (desc->rightclip) |
| 308 | | { |
| 309 | | mo->cliprect.min_x = desc->leftclip; |
| 310 | | mo->cliprect.max_x = desc->rightclip; |
| 311 | | } |
| 312 | | |
| 313 | | /* compute the checksums */ |
| 314 | | memset(mo->checksums, 0, sizeof(mo->checksums)); |
| 315 | | for (i = 0; i < mo->romlength / 0x20000; i++) |
| 316 | | { |
| 317 | | const UINT16 *csbase = &mo->rombase[0x10000 * i]; |
| 318 | | int cursum = 0, j; |
| 319 | | for (j = 0; j < 0x10000; j++) |
| 320 | | cursum += *csbase++; |
| 321 | | mo->checksums[i] = cursum; |
| 322 | | } |
| 323 | | |
| 324 | | /* allocate the object info */ |
| 325 | | mo->info = auto_alloc_array_clear(machine, atarirle_info, mo->objectcount); |
| 326 | | |
| 327 | | /* fill in the data */ |
| 328 | | for (i = 0; i < mo->objectcount; i++) |
| 329 | | prescan_rle(mo, i); |
| 330 | | |
| 331 | | /* allocate the spriteram */ |
| 332 | | mo->spriteram = auto_alloc_array_clear(machine, atarirle_entry, mo->spriteramsize); |
| 333 | | |
| 334 | | /* allocate bitmaps */ |
| 335 | | width = machine.primary_screen->width(); |
| 336 | | height = machine.primary_screen->height(); |
| 337 | | |
| 338 | | mo->vram[0][0] = auto_bitmap_ind16_alloc(machine, width, height); |
| 339 | | mo->vram[0][1] = auto_bitmap_ind16_alloc(machine, width, height); |
| 340 | | mo->vram[0][0]->fill(0); |
| 341 | | mo->vram[0][1]->fill(0); |
| 342 | | |
| 343 | | /* allocate alternate bitmaps if needed */ |
| 344 | | if (mo->vrammask.mask != 0) |
| 345 | | { |
| 346 | | mo->vram[1][0] = auto_bitmap_ind16_alloc(machine, width, height); |
| 347 | | mo->vram[1][1] = auto_bitmap_ind16_alloc(machine, width, height); |
| 348 | | mo->vram[1][0]->fill(0); |
| 349 | | mo->vram[1][1]->fill(0); |
| 350 | | } |
| 351 | | |
| 352 | | mo->partial_scanline = -1; |
| 353 | | |
| 354 | | /* register for save states */ |
| 355 | | device->save_pointer(NAME(mo->spriteram[0].data), ARRAY_LENGTH(mo->spriteram[0].data) * mo->spriteramsize); |
| 356 | | device->save_item(NAME(*mo->vram[0][0])); |
| 357 | | device->save_item(NAME(*mo->vram[0][1])); |
| 358 | | if (mo->vrammask.mask != 0) |
| 359 | | { |
| 360 | | device->save_item(NAME(*mo->vram[1][0])); |
| 361 | | device->save_item(NAME(*mo->vram[1][1])); |
| 362 | | } |
| 363 | | device->save_item(NAME(mo->partial_scanline)); |
| 364 | | device->save_item(NAME(mo->control_bits)); |
| 365 | | device->save_item(NAME(mo->command)); |
| 366 | | device->save_item(NAME(mo->is32bit)); |
| 367 | | device->save_item(NAME(mo->checksums)); |
| 368 | | } |
| 369 | | |
| 370 | | |
| 371 | | const device_type ATARIRLE = &device_creator<atarirle_device>; |
| 372 | | |
| 373 | | atarirle_device::atarirle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 374 | | : device_t(mconfig, ATARIRLE, "Atari RLE", tag, owner, clock, "atari_rle", __FILE__) |
| 375 | | { |
| 376 | | m_token = global_alloc_clear(atarirle_data); |
| 377 | | } |
| 378 | | |
| 379 | 74 | //------------------------------------------------- |
| 380 | | // device_config_complete - perform any |
| 381 | | // operations now that the configuration is |
| 382 | | // complete |
| 75 | // static_set_config: Set the tag of the |
| 76 | // sound CPU |
| 383 | 77 | //------------------------------------------------- |
| 384 | 78 | |
| 385 | | void atarirle_device::device_config_complete() |
| 79 | void atari_rle_objects_device::static_set_config(device_t &device, const atari_rle_objects_config &config) |
| 386 | 80 | { |
| 81 | atari_rle_objects_device &target = downcast<atari_rle_objects_device &>(device); |
| 82 | static_cast<atari_rle_objects_config &>(target) = config; |
| 387 | 83 | } |
| 388 | 84 | |
| 85 | |
| 389 | 86 | //------------------------------------------------- |
| 390 | | // device_start - device-specific startup |
| 87 | // control_write: Write handler for MO control |
| 88 | // bits. |
| 391 | 89 | //------------------------------------------------- |
| 392 | 90 | |
| 393 | | void atarirle_device::device_start() |
| 91 | WRITE8_MEMBER(atari_rle_objects_device::control_write) |
| 394 | 92 | { |
| 395 | | DEVICE_START_NAME( atarirle )(this); |
| 396 | | } |
| 397 | | |
| 398 | | |
| 399 | | |
| 400 | | /*--------------------------------------------------------------- |
| 401 | | atarirle_control_w: Write handler for MO control bits. |
| 402 | | ---------------------------------------------------------------*/ |
| 403 | | |
| 404 | | void atarirle_control_w(device_t *device, UINT8 bits) |
| 405 | | { |
| 406 | | atarirle_data *mo = get_safe_token(device); |
| 407 | | screen_device *screen = device->machine().first_screen(); |
| 408 | | int scanline = screen->vpos(); |
| 409 | | int oldbits = mo->control_bits; |
| 410 | | |
| 411 | 93 | //logerror("atarirle_control_w(%d)\n", bits); |
| 412 | 94 | |
| 413 | | /* do nothing if nothing changed */ |
| 414 | | if (oldbits == bits) |
| 95 | // do nothing if nothing changed |
| 96 | int oldbits = m_control_bits; |
| 97 | if (oldbits == data) |
| 415 | 98 | return; |
| 416 | 99 | |
| 417 | | /* force a partial update first */ |
| 418 | | screen->update_partial(scanline); |
| 100 | // force a partial update first |
| 101 | int scanline = m_screen->vpos(); |
| 102 | m_screen->update_partial(scanline); |
| 419 | 103 | |
| 420 | | /* if the erase flag was set, erase the front map */ |
| 421 | | if (oldbits & ATARIRLE_CONTROL_ERASE) |
| 104 | // if the erase flag was set, erase the front map |
| 105 | if ((oldbits & ATARIRLE_CONTROL_ERASE) != 0) |
| 422 | 106 | { |
| 423 | | rectangle cliprect = mo->cliprect; |
| 424 | | |
| 425 | | /* compute the top and bottom of the rect */ |
| 426 | | if (mo->partial_scanline + 1 > cliprect.min_y) |
| 427 | | cliprect.min_y = mo->partial_scanline + 1; |
| 107 | // compute the top and bottom of the rect |
| 108 | rectangle cliprect = m_cliprect; |
| 109 | if (m_partial_scanline + 1 > cliprect.min_y) |
| 110 | cliprect.min_y = m_partial_scanline + 1; |
| 428 | 111 | if (scanline < cliprect.max_y) |
| 429 | 112 | cliprect.max_y = scanline; |
| 430 | 113 | |
| 431 | 114 | //logerror(" partial erase %d-%d (frame %d)\n", cliprect.min_y, cliprect.max_y, (oldbits & ATARIRLE_CONTROL_FRAME) >> 2); |
| 432 | 115 | |
| 433 | | /* erase the bitmap */ |
| 434 | | mo->vram[0][(oldbits & ATARIRLE_CONTROL_FRAME) >> 2]->fill(0, cliprect); |
| 435 | | if (mo->vrammask.mask != 0) |
| 436 | | mo->vram[1][(oldbits & ATARIRLE_CONTROL_FRAME) >> 2]->fill(0, cliprect); |
| 116 | // erase the bitmap |
| 117 | m_vram[0][(oldbits & ATARIRLE_CONTROL_FRAME) >> 2].fill(0, cliprect); |
| 118 | if (m_vrammask.mask() != 0) |
| 119 | m_vram[1][(oldbits & ATARIRLE_CONTROL_FRAME) >> 2].fill(0, cliprect); |
| 437 | 120 | } |
| 438 | 121 | |
| 439 | | /* update the bits */ |
| 440 | | mo->control_bits = bits; |
| 122 | // update the bits |
| 123 | m_control_bits = data; |
| 441 | 124 | |
| 442 | | /* if mogo is set, do a render on the rising edge */ |
| 443 | | if (!(oldbits & ATARIRLE_CONTROL_MOGO) && (bits & ATARIRLE_CONTROL_MOGO)) |
| 125 | // if mogo is set, do a render on the rising edge |
| 126 | if ((oldbits & ATARIRLE_CONTROL_MOGO) == 0 && (data & ATARIRLE_CONTROL_MOGO) != 0) |
| 444 | 127 | { |
| 445 | | if (mo->command == ATARIRLE_COMMAND_DRAW) |
| 446 | | sort_and_render(device->machine(), mo); |
| 447 | | else if (mo->command == ATARIRLE_COMMAND_CHECKSUM) |
| 448 | | compute_checksum(mo); |
| 128 | if (m_command == ATARIRLE_COMMAND_DRAW) |
| 129 | sort_and_render(); |
| 130 | else if (m_command == ATARIRLE_COMMAND_CHECKSUM) |
| 131 | compute_checksum(); |
| 449 | 132 | } |
| 450 | 133 | |
| 451 | | /* remember where we left off */ |
| 452 | | mo->partial_scanline = scanline; |
| 134 | // remember where we left off |
| 135 | m_partial_scanline = scanline; |
| 453 | 136 | } |
| 454 | 137 | |
| 455 | 138 | |
| 139 | //------------------------------------------------- |
| 140 | // command_write: Write handler for MO command |
| 141 | // bits. |
| 142 | //------------------------------------------------- |
| 456 | 143 | |
| 457 | | /*--------------------------------------------------------------- |
| 458 | | atarirle_command_w: Write handler for MO command bits. |
| 459 | | ---------------------------------------------------------------*/ |
| 460 | | |
| 461 | | void atarirle_command_w(device_t *device, UINT8 command) |
| 144 | WRITE8_MEMBER(atari_rle_objects_device::command_write) |
| 462 | 145 | { |
| 463 | | atarirle_data *mo = get_safe_token(device); |
| 464 | | mo->command = command; |
| 146 | m_command = data; |
| 465 | 147 | } |
| 466 | 148 | |
| 467 | 149 | |
| 150 | //------------------------------------------------- |
| 151 | // vblank_callback: VBLANK callback. |
| 152 | //------------------------------------------------- |
| 468 | 153 | |
| 469 | | /*--------------------------------------------------------------- |
| 470 | | atarirle_eof: Flush remaining changes. |
| 471 | | ---------------------------------------------------------------*/ |
| 472 | | |
| 473 | | void atarirle_eof(device_t *device) |
| 154 | void atari_rle_objects_device::vblank_callback(screen_device &screen, bool state) |
| 474 | 155 | { |
| 156 | // on the rising edge, if the erase flag is set, erase to the end of the screen |
| 157 | if (state) |
| 475 | 158 | { |
| 476 | | atarirle_data *mo = get_safe_token(device); |
| 477 | | |
| 478 | | /* if the erase flag is set, erase to the end of the screen */ |
| 479 | | if (mo->control_bits & ATARIRLE_CONTROL_ERASE) |
| 159 | if (m_control_bits & ATARIRLE_CONTROL_ERASE) |
| 480 | 160 | { |
| 481 | | rectangle cliprect = mo->cliprect; |
| 161 | // compute top only; bottom is equal to visible_area |
| 162 | rectangle cliprect = m_cliprect; |
| 163 | if (m_partial_scanline + 1 > cliprect.min_y) |
| 164 | cliprect.min_y = m_partial_scanline + 1; |
| 482 | 165 | |
| 483 | | /* compute top only; bottom is equal to visible_area */ |
| 484 | | if (mo->partial_scanline + 1 > cliprect.min_y) |
| 485 | | cliprect.min_y = mo->partial_scanline + 1; |
| 166 | //logerror(" partial erase %d-%d (frame %d)\n", cliprect.min_y, cliprect.max_y, (m_control_bits & ATARIRLE_CONTROL_FRAME) >> 2); |
| 486 | 167 | |
| 487 | | //logerror(" partial erase %d-%d (frame %d)\n", cliprect.min_y, cliprect.max_y, (mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2); |
| 488 | | |
| 489 | | /* erase the bitmap */ |
| 490 | | mo->vram[0][(mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2]->fill(0, cliprect); |
| 491 | | if (mo->vrammask.mask != 0) |
| 492 | | mo->vram[1][(mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2]->fill(0, cliprect); |
| 168 | // erase the bitmap |
| 169 | m_vram[0][(m_control_bits & ATARIRLE_CONTROL_FRAME) >> 2].fill(0, cliprect); |
| 170 | if (m_vrammask.mask() != 0) |
| 171 | m_vram[1][(m_control_bits & ATARIRLE_CONTROL_FRAME) >> 2].fill(0, cliprect); |
| 493 | 172 | } |
| 494 | 173 | |
| 495 | | /* reset the partial scanline to -1 so we can detect full updates */ |
| 496 | | mo->partial_scanline = -1; |
| 174 | // reset the partial scanline to -1 so we can detect full updates |
| 175 | m_partial_scanline = -1; |
| 497 | 176 | } |
| 498 | 177 | } |
| 499 | 178 | |
| 500 | 179 | |
| 180 | //------------------------------------------------- |
| 181 | // device_start: Configures the motion objects |
| 182 | // using the input description. Allocates all |
| 183 | // memory necessary and generates the attribute |
| 184 | // lookup table. |
| 185 | //------------------------------------------------- |
| 501 | 186 | |
| 502 | | /*--------------------------------------------------------------- |
| 503 | | atarirle_spriteram_r: Read handler for the spriteram. |
| 504 | | ---------------------------------------------------------------*/ |
| 505 | | |
| 506 | | READ16_DEVICE_HANDLER( atarirle_spriteram_r ) |
| 187 | void atari_rle_objects_device::device_start() |
| 507 | 188 | { |
| 508 | | atarirle_data *mo = get_safe_token(device); |
| 189 | // resolve our memory |
| 190 | memory_share *share = owner()->memshare(tag()); |
| 191 | if (share == NULL) |
| 192 | throw emu_fatalerror("Error: unable to find memory share '%s' needed for Atari RLE device", tag()); |
| 193 | m_ram.set(*share, 2); |
| 509 | 194 | |
| 510 | | return mo->ram[offset]; |
| 511 | | } |
| 195 | // register a VBLANK callback |
| 196 | m_screen->register_vblank_callback(vblank_state_delegate(FUNC(atari_rle_objects_device::vblank_callback), this)); |
| 512 | 197 | |
| 198 | // build and allocate the generic tables |
| 199 | build_rle_tables(); |
| 513 | 200 | |
| 201 | // determine the masks first |
| 202 | m_codemask.set(m_code_entry); |
| 203 | m_colormask.set(m_color_entry); |
| 204 | m_xposmask.set(m_xpos_entry); |
| 205 | m_yposmask.set(m_ypos_entry); |
| 206 | m_scalemask.set(m_scale_entry); |
| 207 | m_hflipmask.set(m_hflip_entry); |
| 208 | m_ordermask.set(m_order_entry); |
| 209 | m_prioritymask.set(m_priority_entry); |
| 210 | m_vrammask.set(m_vram_entry); |
| 514 | 211 | |
| 515 | | /*--------------------------------------------------------------- |
| 516 | | atarirle_spriteram_w: Write handler for the spriteram. |
| 517 | | ---------------------------------------------------------------*/ |
| 212 | // copy in the basic data |
| 213 | m_bitmapwidth = round_to_powerof2(m_xposmask.mask()); |
| 214 | m_bitmapheight = round_to_powerof2(m_yposmask.mask()); |
| 215 | m_bitmapxmask = m_bitmapwidth - 1; |
| 216 | m_bitmapymask = m_bitmapheight - 1; |
| 518 | 217 | |
| 519 | | WRITE16_DEVICE_HANDLER( atarirle_spriteram_w ) |
| 520 | | { |
| 521 | | atarirle_data *mo = get_safe_token(device); |
| 522 | | int entry = (offset >> 3) & mo->spriterammask; |
| 523 | | int idx = offset & 7; |
| 218 | // set up the graphics ROM |
| 219 | m_rombase = reinterpret_cast<UINT16 *>(m_region->base()); |
| 220 | m_romlength = m_region->bytes(); |
| 221 | m_objectcount = count_objects(); |
| 524 | 222 | |
| 525 | | /* combine raw data */ |
| 526 | | COMBINE_DATA(&mo->ram[offset]); |
| 223 | // set up a cliprect |
| 224 | m_cliprect = m_screen->visible_area(); |
| 225 | if (m_rightclip != 0) |
| 226 | { |
| 227 | m_cliprect.min_x = m_leftclip; |
| 228 | m_cliprect.max_x = m_rightclip; |
| 229 | } |
| 527 | 230 | |
| 528 | | /* store a copy in our local spriteram */ |
| 529 | | mo->spriteram[entry].data[idx] = mo->ram[offset]; |
| 530 | | mo->is32bit = 0; |
| 531 | | } |
| 231 | // compute the checksums |
| 232 | memset(m_checksums, 0, sizeof(m_checksums)); |
| 233 | for (int sumchunk = 0; sumchunk < m_romlength / 0x20000; sumchunk++) |
| 234 | { |
| 235 | const UINT16 *csbase = &m_rombase[0x10000 * sumchunk]; |
| 236 | int cursum = 0; |
| 237 | for (int word = 0; word < 0x10000; word++) |
| 238 | cursum += *csbase++; |
| 239 | m_checksums[sumchunk] = cursum; |
| 240 | } |
| 532 | 241 | |
| 242 | // allocate the object info and scan the objects |
| 243 | m_info.resize(m_objectcount); |
| 244 | for (int objnum = 0; objnum < m_objectcount; objnum++) |
| 245 | prescan_rle(objnum); |
| 533 | 246 | |
| 247 | // register the bitmaps with the target screen |
| 248 | m_screen->register_screen_bitmap(m_vram[0][0]); |
| 249 | m_screen->register_screen_bitmap(m_vram[0][1]); |
| 250 | m_vram[0][0].fill(0); |
| 251 | m_vram[0][1].fill(0); |
| 534 | 252 | |
| 535 | | /*--------------------------------------------------------------- |
| 536 | | atarirle_spriteram32_r: Read handler for the spriteram. |
| 537 | | ---------------------------------------------------------------*/ |
| 253 | // allocate alternate bitmaps if needed |
| 254 | if (m_vrammask.mask() != 0) |
| 255 | { |
| 256 | m_screen->register_screen_bitmap(m_vram[1][0]); |
| 257 | m_screen->register_screen_bitmap(m_vram[1][1]); |
| 258 | m_vram[1][0].fill(0); |
| 259 | m_vram[1][1].fill(0); |
| 260 | } |
| 538 | 261 | |
| 539 | | READ32_DEVICE_HANDLER( atarirle_spriteram32_r ) |
| 540 | | { |
| 541 | | atarirle_data *mo = get_safe_token(device); |
| 542 | | UINT32 *ram = (UINT32 *)mo->ram; |
| 543 | | |
| 544 | | return ram[offset]; |
| 262 | // register for save states |
| 263 | save_item(NAME(m_vram[0][0])); |
| 264 | save_item(NAME(m_vram[0][1])); |
| 265 | if (m_vrammask.mask() != 0) |
| 266 | { |
| 267 | save_item(NAME(m_vram[1][0])); |
| 268 | save_item(NAME(m_vram[1][1])); |
| 269 | } |
| 270 | save_item(NAME(m_partial_scanline)); |
| 271 | save_item(NAME(m_control_bits)); |
| 272 | save_item(NAME(m_command)); |
| 545 | 273 | } |
| 546 | 274 | |
| 547 | 275 | |
| 276 | //------------------------------------------------- |
| 277 | // device_reset: Reset the state of the device. |
| 278 | //------------------------------------------------- |
| 548 | 279 | |
| 549 | | /*--------------------------------------------------------------- |
| 550 | | atarirle_spriteram32_w: Write handler for the spriteram. |
| 551 | | ---------------------------------------------------------------*/ |
| 552 | | |
| 553 | | WRITE32_DEVICE_HANDLER( atarirle_spriteram32_w ) |
| 280 | void atari_rle_objects_device::device_reset() |
| 554 | 281 | { |
| 555 | | atarirle_data *mo = get_safe_token(device); |
| 556 | | UINT32 *ram = (UINT32 *)mo->ram; |
| 557 | | int entry = (offset >> 2) & mo->spriterammask; |
| 558 | | int idx = 2 * (offset & 3); |
| 559 | | |
| 560 | | /* combine raw data */ |
| 561 | | COMBINE_DATA(&ram[offset]); |
| 562 | | |
| 563 | | /* store a copy in our local spriteram */ |
| 564 | | mo->spriteram[entry].data[idx+0] = ram[offset] >> 16; |
| 565 | | mo->spriteram[entry].data[idx+1] = ram[offset]; |
| 566 | | mo->is32bit = 1; |
| 282 | m_partial_scanline = -1; |
| 567 | 283 | } |
| 568 | 284 | |
| 569 | 285 | |
| 286 | //------------------------------------------------- |
| 287 | // build_rle_tables: Builds internal table for |
| 288 | // RLE mapping. |
| 289 | //------------------------------------------------- |
| 570 | 290 | |
| 571 | | /*--------------------------------------------------------------- |
| 572 | | atarirle_get_vram: Return the VRAM bitmap. |
| 573 | | ---------------------------------------------------------------*/ |
| 574 | | |
| 575 | | bitmap_ind16 *atarirle_get_vram(device_t *device, int idx) |
| 291 | void atari_rle_objects_device::build_rle_tables() |
| 576 | 292 | { |
| 577 | | atarirle_data *mo = get_safe_token(device); |
| 578 | | //logerror("atarirle_get_vram (frame %d)\n", (mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2); |
| 579 | | return mo->vram[idx][(mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2]; |
| 580 | | } |
| 293 | // assign the tables |
| 294 | m_rle_table[0] = &m_rle_table_data[0x000]; |
| 295 | m_rle_table[1] = &m_rle_table_data[0x100]; |
| 296 | m_rle_table[2] = m_rle_table[3] = &m_rle_table_data[0x200]; |
| 297 | m_rle_table[4] = m_rle_table[6] = &m_rle_table_data[0x300]; |
| 298 | m_rle_table[5] = m_rle_table[7] = &m_rle_table_data[0x400]; |
| 581 | 299 | |
| 300 | // set the bpps |
| 301 | m_rle_bpp[0] = 4; |
| 302 | m_rle_bpp[1] = m_rle_bpp[2] = m_rle_bpp[3] = 5; |
| 303 | m_rle_bpp[4] = m_rle_bpp[5] = m_rle_bpp[6] = m_rle_bpp[7] = 6; |
| 582 | 304 | |
| 305 | // build the 4bpp table |
| 306 | for (int i = 0; i < 256; i++) |
| 307 | m_rle_table[0][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 583 | 308 | |
| 584 | | /*--------------------------------------------------------------- |
| 585 | | build_rle_tables: Builds internal table for RLE mapping. |
| 586 | | ---------------------------------------------------------------*/ |
| 309 | // build the 5bpp table |
| 310 | for (int i = 0; i < 256; i++) |
| 311 | m_rle_table[2][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f); |
| 587 | 312 | |
| 588 | | static void build_rle_tables(running_machine &machine) |
| 589 | | { |
| 590 | | UINT16 *base; |
| 591 | | int i; |
| 592 | | |
| 593 | | /* allocate all 5 tables */ |
| 594 | | base = auto_alloc_array(machine, UINT16, 0x500); |
| 595 | | |
| 596 | | /* assign the tables */ |
| 597 | | rle_table[0] = &base[0x000]; |
| 598 | | rle_table[1] = &base[0x100]; |
| 599 | | rle_table[2] = rle_table[3] = &base[0x200]; |
| 600 | | rle_table[4] = rle_table[6] = &base[0x300]; |
| 601 | | rle_table[5] = rle_table[7] = &base[0x400]; |
| 602 | | |
| 603 | | /* set the bpps */ |
| 604 | | rle_bpp[0] = 4; |
| 605 | | rle_bpp[1] = rle_bpp[2] = rle_bpp[3] = 5; |
| 606 | | rle_bpp[4] = rle_bpp[5] = rle_bpp[6] = rle_bpp[7] = 6; |
| 607 | | |
| 608 | | /* build the 4bpp table */ |
| 609 | | for (i = 0; i < 256; i++) |
| 610 | | rle_table[0][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 611 | | |
| 612 | | /* build the 5bpp table */ |
| 613 | | for (i = 0; i < 256; i++) |
| 614 | | rle_table[2][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f); |
| 615 | | |
| 616 | | /* build the special 5bpp table */ |
| 617 | | for (i = 0; i < 256; i++) |
| 313 | // build the special 5bpp table |
| 314 | for (int i = 0; i < 256; i++) |
| 618 | 315 | { |
| 619 | 316 | if ((i & 0x0f) == 0) |
| 620 | | rle_table[1][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 317 | m_rle_table[1][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 621 | 318 | else |
| 622 | | rle_table[1][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f); |
| 319 | m_rle_table[1][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f); |
| 623 | 320 | } |
| 624 | 321 | |
| 625 | | /* build the 6bpp table */ |
| 626 | | for (i = 0; i < 256; i++) |
| 627 | | rle_table[5][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f); |
| 322 | // build the 6bpp table |
| 323 | for (int i = 0; i < 256; i++) |
| 324 | m_rle_table[5][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f); |
| 628 | 325 | |
| 629 | | /* build the special 6bpp table */ |
| 630 | | for (i = 0; i < 256; i++) |
| 326 | // build the special 6bpp table |
| 327 | for (int i = 0; i < 256; i++) |
| 631 | 328 | { |
| 632 | 329 | if ((i & 0x0f) == 0) |
| 633 | | rle_table[4][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 330 | m_rle_table[4][i] = (((i & 0xf0) + 0x10) << 4) | (i & 0x0f); |
| 634 | 331 | else |
| 635 | | rle_table[4][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f); |
| 332 | m_rle_table[4][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f); |
| 636 | 333 | } |
| 637 | 334 | } |
| 638 | 335 | |
| 639 | 336 | |
| 640 | 337 | |
| 641 | | /*--------------------------------------------------------------- |
| 642 | | count_objects: Determines the number of objects in the |
| 643 | | motion object ROM. |
| 644 | | ---------------------------------------------------------------*/ |
| 338 | //------------------------------------------------- |
| 339 | // count_objects: Determines the number of objects in the |
| 340 | // motion object ROM. |
| 341 | //------------------------------------------------- |
| 645 | 342 | |
| 646 | | int count_objects(const UINT16 *base, int length) |
| 343 | int atari_rle_objects_device::count_objects() |
| 647 | 344 | { |
| 648 | | int lowest_address = length; |
| 649 | | int i; |
| 650 | | |
| 651 | | /* first determine the lowest address of all objects */ |
| 652 | | for (i = 0; i < lowest_address; i += 4) |
| 345 | // first determine the lowest address of all objects |
| 346 | int lowest_address = m_romlength; |
| 347 | for (int objoffset = 0; objoffset < lowest_address; objoffset += 4) |
| 653 | 348 | { |
| 654 | | int offset = ((base[i + 2] & 0xff) << 16) | base[i + 3]; |
| 655 | | //logerror("count_objects: i=%d offset=%08X\n", i, offset); |
| 656 | | if (offset > i && offset < lowest_address) |
| 349 | int offset = ((m_rombase[objoffset + 2] & 0xff) << 16) | m_rombase[objoffset + 3]; |
| 350 | //logerror("count_objects: objoffset=%d offset=%08X\n", objoffset, offset); |
| 351 | if (offset > objoffset && offset < lowest_address) |
| 657 | 352 | lowest_address = offset; |
| 658 | 353 | } |
| 659 | 354 | |
| 660 | | /* that determines how many objects */ |
| 355 | // that determines how many objects |
| 661 | 356 | return lowest_address / 4; |
| 662 | 357 | } |
| 663 | 358 | |
| 664 | 359 | |
| 360 | //------------------------------------------------- |
| 361 | // prescan_rle: Prescans an RLE object, computing the |
| 362 | // width, height, and other goodies. |
| 363 | //------------------------------------------------- |
| 665 | 364 | |
| 666 | | /*--------------------------------------------------------------- |
| 667 | | prescan_rle: Prescans an RLE object, computing the |
| 668 | | width, height, and other goodies. |
| 669 | | ---------------------------------------------------------------*/ |
| 670 | | |
| 671 | | static void prescan_rle(const atarirle_data *mo, int which) |
| 365 | void atari_rle_objects_device::prescan_rle(int which) |
| 672 | 366 | { |
| 673 | | atarirle_info *rledata = &mo->info[which]; |
| 674 | | UINT16 *base = (UINT16 *)&mo->rombase[which * 4]; |
| 675 | | const UINT16 *end = mo->rombase + mo->romlength / 2; |
| 676 | | int width = 0, height, flags, offset; |
| 677 | | const UINT16 *table; |
| 367 | object_info &info = m_info[which]; |
| 678 | 368 | |
| 679 | | /* look up the offset */ |
| 680 | | rledata->xoffs = (INT16)base[0]; |
| 681 | | rledata->yoffs = (INT16)base[1]; |
| 369 | // look up the offset |
| 370 | UINT16 *base = (UINT16 *)&m_rombase[which * 4]; |
| 371 | const UINT16 *end = m_rombase + m_romlength / 2; |
| 372 | info.xoffs = (INT16)base[0]; |
| 373 | info.yoffs = (INT16)base[1]; |
| 682 | 374 | |
| 683 | | /* determine the depth and table */ |
| 684 | | flags = base[2]; |
| 685 | | rledata->bpp = rle_bpp[(flags >> 8) & 7]; |
| 686 | | table = rledata->table = rle_table[(flags >> 8) & 7]; |
| 375 | // determine the depth and table |
| 376 | int flags = base[2]; |
| 377 | info.bpp = m_rle_bpp[(flags >> 8) & 7]; |
| 378 | const UINT16 *table = info.table = m_rle_table[(flags >> 8) & 7]; |
| 687 | 379 | |
| 688 | | /* determine the starting offset */ |
| 689 | | offset = ((base[2] & 0xff) << 16) | base[3]; |
| 690 | | rledata->data = base = (UINT16 *)&mo->rombase[offset]; |
| 380 | // determine the starting offset |
| 381 | int offset = ((base[2] & 0xff) << 16) | base[3]; |
| 382 | info.data = base = (UINT16 *)&m_rombase[offset]; |
| 691 | 383 | |
| 692 | | /* make sure it's valid */ |
| 693 | | if (offset < which * 4 || offset >= mo->romlength) |
| 384 | // make sure it's valid |
| 385 | if (offset < which * 4 || offset >= m_romlength) |
| 694 | 386 | { |
| 695 | | memset(rledata, 0, sizeof(*rledata)); |
| 387 | info.data = NULL; |
| 696 | 388 | return; |
| 697 | 389 | } |
| 698 | 390 | |
| 699 | | /* first pre-scan to determine the width and height */ |
| 391 | // first pre-scan to determine the width and height |
| 392 | int width = 0; |
| 393 | int height; |
| 700 | 394 | for (height = 0; height < 1024 && base < end; height++) |
| 701 | 395 | { |
| 702 | 396 | int tempwidth = 0; |
| 703 | 397 | int entry_count = *base++; |
| 704 | 398 | |
| 705 | | /* if the high bit is set, assume we're inverted */ |
| 399 | // if the high bit is set, assume we're inverted |
| 706 | 400 | if (entry_count & 0x8000) |
| 707 | 401 | { |
| 708 | 402 | entry_count ^= 0xffff; |
| 709 | 403 | |
| 710 | | /* also change the ROM data so we don't have to do this again at runtime */ |
| 404 | // also change the ROM data so we don't have to do this again at runtime |
| 711 | 405 | base[-1] ^= 0xffff; |
| 712 | 406 | } |
| 713 | 407 | |
| 714 | | /* we're done when we hit 0 */ |
| 408 | // we're done when we hit 0 |
| 715 | 409 | if (entry_count == 0) |
| 716 | 410 | break; |
| 717 | 411 | |
| 718 | | /* track the width */ |
| 412 | // track the width |
| 719 | 413 | while (entry_count-- && base < end) |
| 720 | 414 | { |
| 721 | 415 | int word = *base++; |
| 722 | 416 | int count/*, value*/; |
| 723 | 417 | |
| 724 | | /* decode the low byte first */ |
| 418 | // decode the low byte first |
| 725 | 419 | count = table[word & 0xff]; |
| 726 | 420 | //value = count & 0xff; |
| 727 | 421 | tempwidth += count >> 8; |
| 728 | 422 | |
| 729 | | /* decode the upper byte second */ |
| 423 | // decode the upper byte second |
| 730 | 424 | count = table[word >> 8]; |
| 731 | 425 | //value = count & 0xff; |
| 732 | 426 | tempwidth += count >> 8; |
| 733 | 427 | } |
| 734 | 428 | |
| 735 | | /* only remember the max */ |
| 429 | // only remember the max |
| 736 | 430 | if (tempwidth > width) |
| 737 | 431 | width = tempwidth; |
| 738 | 432 | } |
| 739 | 433 | |
| 740 | | /* fill in the data */ |
| 741 | | rledata->width = width; |
| 742 | | rledata->height = height; |
| 434 | // fill in the data |
| 435 | info.width = width; |
| 436 | info.height = height; |
| 743 | 437 | } |
| 744 | 438 | |
| 745 | 439 | |
| 746 | 440 | |
| 747 | | /*--------------------------------------------------------------- |
| 748 | | compute_checksum: Compute the checksum values on the ROMs. |
| 749 | | ---------------------------------------------------------------*/ |
| 441 | //------------------------------------------------- |
| 442 | // compute_checksum: Compute the checksum values |
| 443 | // on the ROMs. |
| 444 | //------------------------------------------------- |
| 750 | 445 | |
| 751 | | static void compute_checksum(atarirle_data *mo) |
| 446 | void atari_rle_objects_device::compute_checksum() |
| 752 | 447 | { |
| 753 | | int reqsums = mo->spriteram[0].data[0] + 1; |
| 754 | | int i; |
| 755 | | |
| 756 | | /* number of checksums is in the first word */ |
| 448 | // number of checksums is in the first word |
| 449 | int reqsums = m_ram.read(0) + 1; |
| 757 | 450 | if (reqsums > 256) |
| 758 | 451 | reqsums = 256; |
| 759 | 452 | |
| 760 | | /* stuff them back */ |
| 761 | | if (!mo->is32bit) |
| 762 | | { |
| 763 | | for (i = 0; i < reqsums; i++) |
| 764 | | mo->ram[i] = mo->checksums[i]; |
| 765 | | } |
| 766 | | else |
| 767 | | { |
| 768 | | UINT32 *ram = (UINT32 *)mo->ram; |
| 769 | | for (i = 0; i < reqsums; i++) |
| 770 | | if (i & 1) |
| 771 | | ram[i/2] = (ram[i/2] & 0xffff0000) | mo->checksums[i]; |
| 772 | | else |
| 773 | | ram[i/2] = (ram[i/2] & 0x0000ffff) | (mo->checksums[i] << 16); |
| 774 | | } |
| 453 | // stuff them back |
| 454 | for (int i = 0; i < reqsums; i++) |
| 455 | m_ram.write(i, m_checksums[i]); |
| 775 | 456 | } |
| 776 | 457 | |
| 777 | 458 | |
| 778 | | /*--------------------------------------------------------------- |
| 779 | | sort_and_render: Render all motion objects in order. |
| 780 | | ---------------------------------------------------------------*/ |
| 781 | 459 | |
| 782 | | static void sort_and_render(running_machine &machine, atarirle_data *mo) |
| 783 | | { |
| 784 | | bitmap_ind16 *bitmap1 = mo->vram[0][(~mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2]; |
| 785 | | bitmap_ind16 *bitmap2 = mo->vram[1][(~mo->control_bits & ATARIRLE_CONTROL_FRAME) >> 2]; |
| 786 | | atarirle_entry *obj = mo->spriteram; |
| 787 | | mo_sort_entry sort_entry[256]; |
| 788 | | mo_sort_entry *list_head[256]; |
| 789 | | mo_sort_entry *current; |
| 790 | | int i; |
| 460 | //------------------------------------------------- |
| 461 | // sort_and_render: Render all motion objects in |
| 462 | // order. |
| 463 | //------------------------------------------------- |
| 791 | 464 | |
| 792 | | atarirle_entry *hilite = NULL; |
| 793 | | int count = 0; |
| 465 | void atari_rle_objects_device::sort_and_render() |
| 466 | { |
| 467 | // struct for sorting |
| 468 | struct sort_entry_t |
| 469 | { |
| 470 | sort_entry_t * next; |
| 471 | int entry; |
| 472 | }; |
| 794 | 473 | |
| 795 | | /* sort the motion objects into their proper priorities */ |
| 796 | | memset(list_head, 0, sizeof(list_head)); |
| 797 | | for (i = 0; i < 256; i++, obj++) |
| 474 | // sort the motion objects into their proper priorities |
| 475 | sort_entry_t *list_head[256] = { 0 }; |
| 476 | sort_entry_t sort_entry[256]; |
| 477 | for (int objnum = 0; objnum < 256; objnum++) |
| 798 | 478 | { |
| 799 | | int order = EXTRACT_DATA(obj, mo->ordermask); |
| 800 | | sort_entry[i].entry = i; |
| 801 | | sort_entry[i].next = list_head[order]; |
| 802 | | list_head[order] = &sort_entry[i]; |
| 479 | int order = m_ordermask.extract(m_ram, objnum * 8); |
| 480 | sort_entry[objnum].entry = objnum * 8; |
| 481 | sort_entry[objnum].next = list_head[order]; |
| 482 | list_head[order] = &sort_entry[objnum]; |
| 803 | 483 | } |
| 804 | 484 | |
| 805 | | /* now loop back and process */ |
| 806 | | count = 0; |
| 807 | | for (i = 1; i < 256; i++) |
| 808 | | for (current = list_head[i]; current; current = current->next) |
| 485 | // now loop back and process |
| 486 | int bitmap_index = (~m_control_bits & ATARIRLE_CONTROL_FRAME) >> 2; |
| 487 | int count = 0; |
| 488 | int hilite = -1; |
| 489 | for (int order = 1; order < 256; order++) |
| 490 | for (sort_entry_t *current = list_head[order]; current != NULL; current = current->next) |
| 809 | 491 | { |
| 810 | | int scale, code; |
| 492 | // extract scale and code |
| 493 | int scale = m_scalemask.extract(m_ram, current->entry); |
| 494 | int code = m_codemask.extract(m_ram, current->entry); |
| 811 | 495 | |
| 812 | | /* extract scale and code */ |
| 813 | | obj = &mo->spriteram[current->entry]; |
| 814 | | scale = EXTRACT_DATA(obj, mo->scalemask); |
| 815 | | code = EXTRACT_DATA(obj, mo->codemask); |
| 816 | | |
| 817 | | /* make sure they are in range */ |
| 818 | | if (scale > 0 && code < mo->objectcount) |
| 496 | // make sure they are in range |
| 497 | if (scale > 0 && code < m_objectcount) |
| 819 | 498 | { |
| 820 | | int hflip = EXTRACT_DATA(obj, mo->hflipmask); |
| 821 | | int color = EXTRACT_DATA(obj, mo->colormask); |
| 822 | | int priority = EXTRACT_DATA(obj, mo->prioritymask); |
| 823 | | int x = EXTRACT_DATA(obj, mo->xposmask); |
| 824 | | int y = EXTRACT_DATA(obj, mo->yposmask); |
| 825 | | int which = EXTRACT_DATA(obj, mo->vrammask); |
| 499 | int hflip = m_hflipmask.extract(m_ram, current->entry); |
| 500 | int color = m_colormask.extract(m_ram, current->entry); |
| 501 | int priority = m_prioritymask.extract(m_ram, current->entry); |
| 502 | int x = m_xposmask.extract(m_ram, current->entry); |
| 503 | int y = m_yposmask.extract(m_ram, current->entry); |
| 504 | int which = m_vrammask.extract(m_ram, current->entry); |
| 826 | 505 | |
| 827 | 506 | if (count++ == atarirle_hilite_index) |
| 828 | | hilite = obj; |
| 507 | hilite = current->entry; |
| 829 | 508 | |
| 830 | | if (x & ((mo->xposmask.mask + 1) >> 1)) |
| 831 | | x = (INT16)(x | ~mo->xposmask.mask); |
| 832 | | if (y & ((mo->yposmask.mask + 1) >> 1)) |
| 833 | | y = (INT16)(y | ~mo->yposmask.mask); |
| 834 | | x += mo->cliprect.min_x; |
| 509 | if (x & ((m_xposmask.mask() + 1) >> 1)) |
| 510 | x = (INT16)(x | ~m_xposmask.mask()); |
| 511 | if (y & ((m_yposmask.mask() + 1) >> 1)) |
| 512 | y = (INT16)(y | ~m_yposmask.mask()); |
| 513 | x += m_cliprect.min_x; |
| 835 | 514 | |
| 836 | | /* merge priority and color */ |
| 515 | // merge priority and color |
| 837 | 516 | color = (color << 4) | (priority << ATARIRLE_PRIORITY_SHIFT); |
| 838 | 517 | |
| 839 | | /* render to one or both bitmaps */ |
| 840 | | if (which == 0) |
| 841 | | draw_rle(mo, *bitmap1, code, color, hflip, 0, x, y, scale, scale, mo->cliprect); |
| 842 | | if (bitmap2 && which != 0) |
| 843 | | draw_rle(mo, *bitmap2, code, color, hflip, 0, x, y, scale, scale, mo->cliprect); |
| 518 | // render to one or both bitmaps |
| 519 | bitmap_ind16 &bitmap = m_vram[which][bitmap_index]; |
| 520 | draw_rle(bitmap, m_cliprect, code, color, hflip, 0, x, y, scale, scale); |
| 844 | 521 | } |
| 845 | 522 | } |
| 846 | 523 | |
| 847 | | if (hilite) |
| 848 | | { |
| 849 | | int scale, code/*, which*/; |
| 850 | | |
| 851 | | /* extract scale and code */ |
| 852 | | obj = hilite; |
| 853 | | scale = EXTRACT_DATA(obj, mo->scalemask); |
| 854 | | code = EXTRACT_DATA(obj, mo->codemask); |
| 855 | | //which = EXTRACT_DATA(obj, mo->vrammask); |
| 856 | | |
| 857 | | /* make sure they are in range */ |
| 858 | | if (scale > 0 && code < mo->objectcount) |
| 859 | | { |
| 860 | | int hflip = EXTRACT_DATA(obj, mo->hflipmask); |
| 861 | | int color = EXTRACT_DATA(obj, mo->colormask); |
| 862 | | int priority = EXTRACT_DATA(obj, mo->prioritymask); |
| 863 | | int x = EXTRACT_DATA(obj, mo->xposmask); |
| 864 | | int y = EXTRACT_DATA(obj, mo->yposmask); |
| 865 | | int scaled_xoffs, scaled_yoffs; |
| 866 | | const atarirle_info *info; |
| 867 | | |
| 868 | | if (x & ((mo->xposmask.mask + 1) >> 1)) |
| 869 | | x = (INT16)(x | ~mo->xposmask.mask); |
| 870 | | if (y & ((mo->yposmask.mask + 1) >> 1)) |
| 871 | | y = (INT16)(y | ~mo->yposmask.mask); |
| 872 | | x += mo->cliprect.min_x; |
| 873 | | |
| 874 | | /* merge priority and color */ |
| 875 | | color = (color << 4) | (priority << ATARIRLE_PRIORITY_SHIFT); |
| 876 | | |
| 877 | | info = &mo->info[code]; |
| 878 | | scaled_xoffs = (scale * info->xoffs) >> 12; |
| 879 | | scaled_yoffs = (scale * info->yoffs) >> 12; |
| 880 | | |
| 881 | | /* we're hflipped, account for it */ |
| 882 | | if (hflip) |
| 883 | | scaled_xoffs = ((scale * info->width) >> 12) - scaled_xoffs; |
| 884 | | |
| 885 | | /* adjust for the x and y offsets */ |
| 886 | | x -= scaled_xoffs; |
| 887 | | y -= scaled_yoffs; |
| 888 | | |
| 889 | | do |
| 890 | | { |
| 891 | | const rectangle &visarea = machine.primary_screen->visible_area(); |
| 892 | | int scaled_width = (scale * info->width + 0x7fff) >> 12; |
| 893 | | int scaled_height = (scale * info->height + 0x7fff) >> 12; |
| 894 | | int ex, ey, sx = x, sy = y, tx, ty; |
| 895 | | |
| 896 | | /* make sure we didn't end up with 0 */ |
| 897 | | if (scaled_width == 0) scaled_width = 1; |
| 898 | | if (scaled_height == 0) scaled_height = 1; |
| 899 | | |
| 900 | | /* compute the remaining parameters */ |
| 901 | | ex = sx + scaled_width - 1; |
| 902 | | ey = sy + scaled_height - 1; |
| 903 | | |
| 904 | | /* left edge clip */ |
| 905 | | if (sx < visarea.min_x) |
| 906 | | sx = visarea.min_x; |
| 907 | | if (sx > visarea.max_x) |
| 908 | | break; |
| 909 | | |
| 910 | | /* right edge clip */ |
| 911 | | if (ex > visarea.max_x) |
| 912 | | ex = visarea.max_x; |
| 913 | | else if (ex < visarea.min_x) |
| 914 | | break; |
| 915 | | |
| 916 | | /* top edge clip */ |
| 917 | | if (sy < visarea.min_y) |
| 918 | | sy = visarea.min_y; |
| 919 | | else if (sy > visarea.max_y) |
| 920 | | break; |
| 921 | | |
| 922 | | /* bottom edge clip */ |
| 923 | | if (ey > visarea.max_y) |
| 924 | | ey = visarea.max_y; |
| 925 | | else if (ey < visarea.min_y) |
| 926 | | break; |
| 927 | | |
| 928 | | for (ty = sy; ty <= ey; ty++) |
| 929 | | { |
| 930 | | bitmap1->pix16(ty, sx) = machine.rand() & 0xff; |
| 931 | | bitmap1->pix16(ty, ex) = machine.rand() & 0xff; |
| 932 | | } |
| 933 | | for (tx = sx; tx <= ex; tx++) |
| 934 | | { |
| 935 | | bitmap1->pix16(sy, tx) = machine.rand() & 0xff; |
| 936 | | bitmap1->pix16(ey, tx) = machine.rand() & 0xff; |
| 937 | | } |
| 938 | | } while (0); |
| 939 | | fprintf(stderr, " Sprite: c=%04X l=%04X h=%d X=%4d (o=%4d w=%3d) Y=%4d (o=%4d h=%d) s=%04X\n", |
| 940 | | code, color, hflip, |
| 941 | | x, -scaled_xoffs, (scale * info->width) >> 12, |
| 942 | | y, -scaled_yoffs, (scale * info->height) >> 12, scale); |
| 943 | | } |
| 944 | | |
| 524 | if (hilite != -1) |
| 525 | hilite_object(m_vram[0][bitmap_index], hilite); |
| 945 | 526 | } |
| 946 | | } |
| 947 | 527 | |
| 948 | 528 | |
| 529 | //------------------------------------------------- |
| 530 | // draw_rle: Render a single RLE-compressed motion |
| 531 | // object. |
| 532 | //------------------------------------------------- |
| 949 | 533 | |
| 950 | | /*--------------------------------------------------------------- |
| 951 | | draw_rle: Render a single RLE-compressed motion |
| 952 | | object. |
| 953 | | ---------------------------------------------------------------*/ |
| 954 | | |
| 955 | | void draw_rle(atarirle_data *mo, bitmap_ind16 &bitmap, int code, int color, int hflip, int vflip, |
| 956 | | int x, int y, int xscale, int yscale, const rectangle &clip) |
| 534 | void atari_rle_objects_device::draw_rle(bitmap_ind16 &bitmap, const rectangle &clip, int code, int color, int hflip, int vflip, int x, int y, int xscale, int yscale) |
| 957 | 535 | { |
| 958 | | UINT32 palettebase = mo->palettebase + color; |
| 959 | | const atarirle_info *info = &mo->info[code]; |
| 960 | | int scaled_xoffs = (xscale * info->xoffs) >> 12; |
| 961 | | int scaled_yoffs = (yscale * info->yoffs) >> 12; |
| 536 | // bail on a NULL object |
| 537 | const object_info &info = m_info[code]; |
| 538 | if (info.data == NULL) |
| 539 | return; |
| 962 | 540 | |
| 963 | | /* we're hflipped, account for it */ |
| 541 | // |
| 542 | int scaled_xoffs = (xscale * info.xoffs) >> 12; |
| 543 | int scaled_yoffs = (yscale * info.yoffs) >> 12; |
| 544 | |
| 545 | // we're hflipped, account for it |
| 964 | 546 | if (hflip) |
| 965 | | scaled_xoffs = ((xscale * info->width) >> 12) - scaled_xoffs; |
| 547 | scaled_xoffs = ((xscale * info.width) >> 12) - scaled_xoffs; |
| 966 | 548 | |
| 967 | | //if (clip.min_y == Machine->primary_screen->visible_area().min_y) |
| 549 | //if (clip.min_y == m_screen->visible_area().min_y) |
| 968 | 550 | //logerror(" Sprite: c=%04X l=%04X h=%d X=%4d (o=%4d w=%3d) Y=%4d (o=%4d h=%d) s=%04X\n", |
| 969 | 551 | // code, color, hflip, |
| 970 | | // x, -scaled_xoffs, (xscale * info->width) >> 12, |
| 971 | | // y, -scaled_yoffs, (yscale * info->height) >> 12, xscale); |
| 552 | // x, -scaled_xoffs, (xscale * info.width) >> 12, |
| 553 | // y, -scaled_yoffs, (yscale * info.height) >> 12, xscale); |
| 972 | 554 | |
| 973 | | /* adjust for the x and y offsets */ |
| 555 | // adjust for the x and y offsets |
| 974 | 556 | x -= scaled_xoffs; |
| 975 | 557 | y -= scaled_yoffs; |
| 976 | 558 | |
| 977 | | /* bail on a NULL object */ |
| 978 | | if (!info->data) |
| 979 | | return; |
| 980 | | |
| 981 | | /* 16-bit case */ |
| 982 | | assert(bitmap.bpp() == 16); |
| 559 | // draw it with appropriate flipping |
| 560 | UINT32 palettebase = m_palettebase + color; |
| 983 | 561 | if (!hflip) |
| 984 | | draw_rle_zoom(bitmap, info, palettebase, x, y, xscale << 4, yscale << 4, clip); |
| 562 | draw_rle_zoom(bitmap, clip, info, palettebase, x, y, xscale << 4, yscale << 4); |
| 985 | 563 | else |
| 986 | | draw_rle_zoom_hflip(bitmap, info, palettebase, x, y, xscale << 4, yscale << 4, clip); |
| 564 | draw_rle_zoom_hflip(bitmap, clip, info, palettebase, x, y, xscale << 4, yscale << 4); |
| 987 | 565 | } |
| 988 | 566 | |
| 989 | 567 | |
| 990 | 568 | |
| 991 | | /*--------------------------------------------------------------- |
| 992 | | draw_rle_zoom: Draw an RLE-compressed object to a 16-bit |
| 993 | | bitmap. |
| 994 | | ---------------------------------------------------------------*/ |
| 569 | //------------------------------------------------- |
| 570 | // draw_rle_zoom: Draw an RLE-compressed object to |
| 571 | // a 16-bit bitmap. |
| 572 | //------------------------------------------------- |
| 995 | 573 | |
| 996 | | void draw_rle_zoom(bitmap_ind16 &bitmap, const atarirle_info *gfx, |
| 997 | | UINT32 palette, int sx, int sy, int scalex, int scaley, |
| 998 | | const rectangle &clip) |
| 574 | void atari_rle_objects_device::draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, UINT32 palette, int sx, int sy, int scalex, int scaley) |
| 999 | 575 | { |
| 1000 | | const UINT16 *row_start = gfx->data; |
| 1001 | | const UINT16 *table = gfx->table; |
| 1002 | | volatile int current_row = 0; |
| 1003 | | |
| 1004 | | int scaled_width = (scalex * gfx->width + 0x7fff) >> 16; |
| 1005 | | int scaled_height = (scaley * gfx->height + 0x7fff) >> 16; |
| 1006 | | |
| 1007 | | int pixels_to_skip = 0, xclipped = 0; |
| 1008 | | int dx, dy, ex, ey; |
| 1009 | | int y, sourcey; |
| 1010 | | |
| 1011 | | /* make sure we didn't end up with 0 */ |
| 576 | // determine scaled size; make sure we didn't end up with 0 |
| 577 | int scaled_width = (scalex * info.width + 0x7fff) >> 16; |
| 578 | int scaled_height = (scaley * info.height + 0x7fff) >> 16; |
| 1012 | 579 | if (scaled_width == 0) scaled_width = 1; |
| 1013 | 580 | if (scaled_height == 0) scaled_height = 1; |
| 1014 | 581 | |
| 1015 | | /* compute the remaining parameters */ |
| 1016 | | dx = (gfx->width << 16) / scaled_width; |
| 1017 | | dy = (gfx->height << 16) / scaled_height; |
| 1018 | | ex = sx + scaled_width - 1; |
| 1019 | | ey = sy + scaled_height - 1; |
| 1020 | | sourcey = dy / 2; |
| 582 | // compute the remaining parameters |
| 583 | int dx = (info.width << 16) / scaled_width; |
| 584 | int dy = (info.height << 16) / scaled_height; |
| 585 | int ex = sx + scaled_width - 1; |
| 586 | int ey = sy + scaled_height - 1; |
| 587 | int sourcey = dy / 2; |
| 1021 | 588 | |
| 1022 | | /* left edge clip */ |
| 589 | // left edge clip |
| 590 | int pixels_to_skip = 0; |
| 591 | bool xclipped = false; |
| 1023 | 592 | if (sx < clip.min_x) |
| 1024 | | pixels_to_skip = clip.min_x - sx, xclipped = 1; |
| 593 | pixels_to_skip = clip.min_x - sx, xclipped = true; |
| 1025 | 594 | if (sx > clip.max_x) |
| 1026 | 595 | return; |
| 1027 | 596 | |
| 1028 | | /* right edge clip */ |
| 597 | // right edge clip |
| 1029 | 598 | if (ex > clip.max_x) |
| 1030 | | ex = clip.max_x, xclipped = 1; |
| 599 | ex = clip.max_x, xclipped = true; |
| 1031 | 600 | else if (ex < clip.min_x) |
| 1032 | 601 | return; |
| 1033 | 602 | |
| 1034 | | /* top edge clip */ |
| 603 | // top edge clip |
| 1035 | 604 | if (sy < clip.min_y) |
| 1036 | 605 | { |
| 1037 | 606 | sourcey += (clip.min_y - sy) * dy; |
| r24781 | r24782 | |
| 1040 | 609 | else if (sy > clip.max_y) |
| 1041 | 610 | return; |
| 1042 | 611 | |
| 1043 | | /* bottom edge clip */ |
| 612 | // bottom edge clip |
| 1044 | 613 | if (ey > clip.max_y) |
| 1045 | 614 | ey = clip.max_y; |
| 1046 | 615 | else if (ey < clip.min_y) |
| 1047 | 616 | return; |
| 1048 | 617 | |
| 1049 | | /* loop top to bottom */ |
| 1050 | | for (y = sy; y <= ey; y++, sourcey += dy) |
| 618 | // loop top to bottom |
| 619 | const UINT16 *row_start = info.data; |
| 620 | const UINT16 *table = info.table; |
| 621 | int current_row = 0; |
| 622 | for (int y = sy; y <= ey; y++, sourcey += dy) |
| 1051 | 623 | { |
| 1052 | 624 | UINT16 *dest = &bitmap.pix16(y, sx); |
| 1053 | | int j, sourcex = dx / 2, rle_end = 0; |
| 1054 | | const UINT16 *base; |
| 1055 | | int entry_count; |
| 625 | int sourcex = dx / 2, rle_end = 0; |
| 1056 | 626 | |
| 1057 | | /* loop until we hit the row we're on */ |
| 627 | // loop until we hit the row we're on |
| 1058 | 628 | for ( ; current_row != (sourcey >> 16); current_row++) |
| 1059 | 629 | row_start += 1 + *row_start; |
| 1060 | 630 | |
| 1061 | | /* grab our starting parameters from this row */ |
| 1062 | | base = row_start; |
| 1063 | | entry_count = *base++; |
| 631 | // grab our starting parameters from this row |
| 632 | const UINT16 *base = row_start; |
| 633 | int entry_count = *base++; |
| 1064 | 634 | |
| 1065 | | /* non-clipped case */ |
| 635 | // non-clipped case |
| 1066 | 636 | if (!xclipped) |
| 1067 | 637 | { |
| 1068 | | /* decode the pixels */ |
| 1069 | | for (j = 0; j < entry_count; j++) |
| 638 | // decode the pixels |
| 639 | for (int entry = 0; entry < entry_count; entry++) |
| 1070 | 640 | { |
| 641 | // decode the low byte first |
| 1071 | 642 | int word = *base++; |
| 1072 | | int count, value; |
| 1073 | | |
| 1074 | | /* decode the low byte first */ |
| 1075 | | count = table[word & 0xff]; |
| 1076 | | value = count & 0xff; |
| 643 | int count = table[word & 0xff]; |
| 644 | int value = count & 0xff; |
| 1077 | 645 | rle_end += (count & 0xff00) << 8; |
| 1078 | 646 | |
| 1079 | | /* store copies of the value until we pass the end of this chunk */ |
| 647 | // store copies of the value until we pass the end of this chunk |
| 1080 | 648 | if (value) |
| 1081 | 649 | { |
| 1082 | 650 | value += palette; |
| r24781 | r24782 | |
| 1089 | 657 | dest++, sourcex += dx; |
| 1090 | 658 | } |
| 1091 | 659 | |
| 1092 | | /* decode the upper byte second */ |
| 660 | // decode the upper byte second |
| 1093 | 661 | count = table[word >> 8]; |
| 1094 | 662 | value = count & 0xff; |
| 1095 | 663 | rle_end += (count & 0xff00) << 8; |
| 1096 | 664 | |
| 1097 | | /* store copies of the value until we pass the end of this chunk */ |
| 665 | // store copies of the value until we pass the end of this chunk |
| 1098 | 666 | if (value) |
| 1099 | 667 | { |
| 1100 | 668 | value += palette; |
| r24781 | r24782 | |
| 1109 | 677 | } |
| 1110 | 678 | } |
| 1111 | 679 | |
| 1112 | | /* clipped case */ |
| 680 | // clipped case |
| 1113 | 681 | else |
| 1114 | 682 | { |
| 1115 | 683 | const UINT16 *end = &bitmap.pix16(y, ex); |
| 1116 | 684 | int to_be_skipped = pixels_to_skip; |
| 1117 | 685 | |
| 1118 | | /* decode the pixels */ |
| 1119 | | for (j = 0; j < entry_count && dest <= end; j++) |
| 686 | // decode the pixels |
| 687 | for (int entry = 0; entry < entry_count && dest <= end; entry++) |
| 1120 | 688 | { |
| 689 | // decode the low byte first |
| 1121 | 690 | int word = *base++; |
| 1122 | | int count, value; |
| 1123 | | |
| 1124 | | /* decode the low byte first */ |
| 1125 | | count = table[word & 0xff]; |
| 1126 | | value = count & 0xff; |
| 691 | int count = table[word & 0xff]; |
| 692 | int value = count & 0xff; |
| 1127 | 693 | rle_end += (count & 0xff00) << 8; |
| 1128 | 694 | |
| 1129 | | /* store copies of the value until we pass the end of this chunk */ |
| 695 | // store copies of the value until we pass the end of this chunk |
| 1130 | 696 | if (to_be_skipped) |
| 1131 | 697 | { |
| 1132 | 698 | while (to_be_skipped && sourcex < rle_end) |
| r24781 | r24782 | |
| 1146 | 712 | } |
| 1147 | 713 | |
| 1148 | 714 | next3: |
| 1149 | | /* decode the upper byte second */ |
| 715 | // decode the upper byte second |
| 1150 | 716 | count = table[word >> 8]; |
| 1151 | 717 | value = count & 0xff; |
| 1152 | 718 | rle_end += (count & 0xff00) << 8; |
| 1153 | 719 | |
| 1154 | | /* store copies of the value until we pass the end of this chunk */ |
| 720 | // store copies of the value until we pass the end of this chunk |
| 1155 | 721 | if (to_be_skipped) |
| 1156 | 722 | { |
| 1157 | 723 | while (to_be_skipped && sourcex < rle_end) |
| r24781 | r24782 | |
| 1178 | 744 | |
| 1179 | 745 | |
| 1180 | 746 | |
| 1181 | | /*--------------------------------------------------------------- |
| 1182 | | draw_rle_zoom_hflip: Draw an RLE-compressed object to a |
| 1183 | | 16-bit bitmap with horizontal flip. |
| 1184 | | ---------------------------------------------------------------*/ |
| 747 | //------------------------------------------------- |
| 748 | // draw_rle_zoom_hflip: Draw an RLE-compressed |
| 749 | // object to a 16-bit bitmap with horizontal |
| 750 | // flip. |
| 751 | //------------------------------------------------- |
| 1185 | 752 | |
| 1186 | | void draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const atarirle_info *gfx, |
| 1187 | | UINT32 palette, int sx, int sy, int scalex, int scaley, |
| 1188 | | const rectangle &clip) |
| 753 | void atari_rle_objects_device::draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, UINT32 palette, int sx, int sy, int scalex, int scaley) |
| 1189 | 754 | { |
| 1190 | | const UINT16 *row_start = gfx->data; |
| 1191 | | const UINT16 *table = gfx->table; |
| 1192 | | volatile int current_row = 0; |
| 1193 | | |
| 1194 | | int scaled_width = (scalex * gfx->width + 0x7fff) >> 16; |
| 1195 | | int scaled_height = (scaley * gfx->height + 0x7fff) >> 16; |
| 1196 | | int pixels_to_skip = 0, xclipped = 0; |
| 1197 | | int dx, dy, ex, ey; |
| 1198 | | int y, sourcey; |
| 1199 | | |
| 1200 | | /* make sure we didn't end up with 0 */ |
| 755 | // determine scaled size; make sure we didn't end up with 0 |
| 756 | int scaled_width = (scalex * info.width + 0x7fff) >> 16; |
| 757 | int scaled_height = (scaley * info.height + 0x7fff) >> 16; |
| 1201 | 758 | if (scaled_width == 0) scaled_width = 1; |
| 1202 | 759 | if (scaled_height == 0) scaled_height = 1; |
| 1203 | 760 | |
| 1204 | | /* compute the remaining parameters */ |
| 1205 | | dx = (gfx->width << 16) / scaled_width; |
| 1206 | | dy = (gfx->height << 16) / scaled_height; |
| 1207 | | ex = sx + scaled_width - 1; |
| 1208 | | ey = sy + scaled_height - 1; |
| 1209 | | sourcey = dy / 2; |
| 761 | // compute the remaining parameters |
| 762 | int dx = (info.width << 16) / scaled_width; |
| 763 | int dy = (info.height << 16) / scaled_height; |
| 764 | int ex = sx + scaled_width - 1; |
| 765 | int ey = sy + scaled_height - 1; |
| 766 | int sourcey = dy / 2; |
| 1210 | 767 | |
| 1211 | | /* left edge clip */ |
| 768 | // left edge clip |
| 769 | int pixels_to_skip = 0; |
| 770 | bool xclipped = false; |
| 1212 | 771 | if (sx < clip.min_x) |
| 1213 | | sx = clip.min_x, xclipped = 1; |
| 772 | sx = clip.min_x, xclipped = true; |
| 1214 | 773 | if (sx > clip.max_x) |
| 1215 | 774 | return; |
| 1216 | 775 | |
| 1217 | | /* right edge clip */ |
| 776 | // right edge clip |
| 1218 | 777 | if (ex > clip.max_x) |
| 1219 | | pixels_to_skip = ex - clip.max_x, xclipped = 1; |
| 778 | pixels_to_skip = ex - clip.max_x, xclipped = true; |
| 1220 | 779 | else if (ex < clip.min_x) |
| 1221 | 780 | return; |
| 1222 | 781 | |
| 1223 | | /* top edge clip */ |
| 782 | // top edge clip |
| 1224 | 783 | if (sy < clip.min_y) |
| 1225 | 784 | { |
| 1226 | 785 | sourcey += (clip.min_y - sy) * dy; |
| r24781 | r24782 | |
| 1229 | 788 | else if (sy > clip.max_y) |
| 1230 | 789 | return; |
| 1231 | 790 | |
| 1232 | | /* bottom edge clip */ |
| 791 | // bottom edge clip |
| 1233 | 792 | if (ey > clip.max_y) |
| 1234 | 793 | ey = clip.max_y; |
| 1235 | 794 | else if (ey < clip.min_y) |
| 1236 | 795 | return; |
| 1237 | 796 | |
| 1238 | | /* loop top to bottom */ |
| 1239 | | for (y = sy; y <= ey; y++, sourcey += dy) |
| 797 | // loop top to bottom |
| 798 | const UINT16 *row_start = info.data; |
| 799 | const UINT16 *table = info.table; |
| 800 | int current_row = 0; |
| 801 | for (int y = sy; y <= ey; y++, sourcey += dy) |
| 1240 | 802 | { |
| 1241 | 803 | UINT16 *dest = &bitmap.pix16(y, ex); |
| 1242 | | int j, sourcex = dx / 2, rle_end = 0; |
| 1243 | | const UINT16 *base; |
| 1244 | | int entry_count; |
| 804 | int sourcex = dx / 2, rle_end = 0; |
| 1245 | 805 | |
| 1246 | | /* loop until we hit the row we're on */ |
| 806 | // loop until we hit the row we're on |
| 1247 | 807 | for ( ; current_row != (sourcey >> 16); current_row++) |
| 1248 | 808 | row_start += 1 + *row_start; |
| 1249 | 809 | |
| 1250 | | /* grab our starting parameters from this row */ |
| 1251 | | base = row_start; |
| 1252 | | entry_count = *base++; |
| 810 | // grab our starting parameters from this row |
| 811 | const UINT16 *base = row_start; |
| 812 | int entry_count = *base++; |
| 1253 | 813 | |
| 1254 | | /* non-clipped case */ |
| 814 | // non-clipped case |
| 1255 | 815 | if (!xclipped) |
| 1256 | 816 | { |
| 1257 | | /* decode the pixels */ |
| 1258 | | for (j = 0; j < entry_count; j++) |
| 817 | // decode the pixels |
| 818 | for (int entry = 0; entry < entry_count; entry++) |
| 1259 | 819 | { |
| 820 | // decode the low byte first |
| 1260 | 821 | int word = *base++; |
| 1261 | | int count, value; |
| 1262 | | |
| 1263 | | /* decode the low byte first */ |
| 1264 | | count = table[word & 0xff]; |
| 1265 | | value = count & 0xff; |
| 822 | int count = table[word & 0xff]; |
| 823 | int value = count & 0xff; |
| 1266 | 824 | rle_end += (count & 0xff00) << 8; |
| 1267 | 825 | |
| 1268 | | /* store copies of the value until we pass the end of this chunk */ |
| 826 | // store copies of the value until we pass the end of this chunk |
| 1269 | 827 | if (value) |
| 1270 | 828 | { |
| 1271 | 829 | value += palette; |
| r24781 | r24782 | |
| 1278 | 836 | dest--, sourcex += dx; |
| 1279 | 837 | } |
| 1280 | 838 | |
| 1281 | | /* decode the upper byte second */ |
| 839 | // decode the upper byte second |
| 1282 | 840 | count = table[word >> 8]; |
| 1283 | 841 | value = count & 0xff; |
| 1284 | 842 | rle_end += (count & 0xff00) << 8; |
| 1285 | 843 | |
| 1286 | | /* store copies of the value until we pass the end of this chunk */ |
| 844 | // store copies of the value until we pass the end of this chunk |
| 1287 | 845 | if (value) |
| 1288 | 846 | { |
| 1289 | 847 | value += palette; |
| r24781 | r24782 | |
| 1298 | 856 | } |
| 1299 | 857 | } |
| 1300 | 858 | |
| 1301 | | /* clipped case */ |
| 859 | // clipped case |
| 1302 | 860 | else |
| 1303 | 861 | { |
| 1304 | 862 | const UINT16 *start = &bitmap.pix16(y, sx); |
| 1305 | 863 | int to_be_skipped = pixels_to_skip; |
| 1306 | 864 | |
| 1307 | | /* decode the pixels */ |
| 1308 | | for (j = 0; j < entry_count && dest >= start; j++) |
| 865 | // decode the pixels |
| 866 | for (int entry = 0; entry < entry_count && dest >= start; entry++) |
| 1309 | 867 | { |
| 868 | // decode the low byte first |
| 1310 | 869 | int word = *base++; |
| 1311 | | int count, value; |
| 1312 | | |
| 1313 | | /* decode the low byte first */ |
| 1314 | | count = table[word & 0xff]; |
| 1315 | | value = count & 0xff; |
| 870 | int count = table[word & 0xff]; |
| 871 | int value = count & 0xff; |
| 1316 | 872 | rle_end += (count & 0xff00) << 8; |
| 1317 | 873 | |
| 1318 | | /* store copies of the value until we pass the end of this chunk */ |
| 874 | // store copies of the value until we pass the end of this chunk |
| 1319 | 875 | if (to_be_skipped) |
| 1320 | 876 | { |
| 1321 | 877 | while (to_be_skipped && sourcex < rle_end) |
| r24781 | r24782 | |
| 1335 | 891 | } |
| 1336 | 892 | |
| 1337 | 893 | next3: |
| 1338 | | /* decode the upper byte second */ |
| 894 | // decode the upper byte second |
| 1339 | 895 | count = table[word >> 8]; |
| 1340 | 896 | value = count & 0xff; |
| 1341 | 897 | rle_end += (count & 0xff00) << 8; |
| 1342 | 898 | |
| 1343 | | /* store copies of the value until we pass the end of this chunk */ |
| 899 | // store copies of the value until we pass the end of this chunk |
| 1344 | 900 | if (to_be_skipped) |
| 1345 | 901 | { |
| 1346 | 902 | while (to_be_skipped && sourcex < rle_end) |
| r24781 | r24782 | |
| 1366 | 922 | } |
| 1367 | 923 | |
| 1368 | 924 | |
| 925 | //------------------------------------------------- |
| 926 | // hilite_object: Hilight an object by drawing a |
| 927 | // flashing box around it |
| 928 | //------------------------------------------------- |
| 929 | |
| 930 | void atari_rle_objects_device::hilite_object(bitmap_ind16 &bitmap, int hilite) |
| 931 | { |
| 932 | // extract scale and code |
| 933 | int scale = m_scalemask.extract(m_ram, hilite); |
| 934 | int code = m_codemask.extract(m_ram, hilite); |
| 935 | |
| 936 | // make sure they are in range |
| 937 | if (scale > 0 && code < m_objectcount) |
| 938 | { |
| 939 | int hflip = m_hflipmask.extract(m_ram, hilite); |
| 940 | int color = m_colormask.extract(m_ram, hilite); |
| 941 | int priority = m_prioritymask.extract(m_ram, hilite); |
| 942 | int x = m_xposmask.extract(m_ram, hilite); |
| 943 | int y = m_yposmask.extract(m_ram, hilite); |
| 944 | |
| 945 | if (x & ((m_xposmask.mask() + 1) >> 1)) |
| 946 | x = (INT16)(x | ~m_xposmask.mask()); |
| 947 | if (y & ((m_yposmask.mask() + 1) >> 1)) |
| 948 | y = (INT16)(y | ~m_yposmask.mask()); |
| 949 | x += m_cliprect.min_x; |
| 950 | |
| 951 | // merge priority and color |
| 952 | color = (color << 4) | (priority << ATARIRLE_PRIORITY_SHIFT); |
| 953 | |
| 954 | const object_info &info = m_info[code]; |
| 955 | int scaled_xoffs = (scale * info.xoffs) >> 12; |
| 956 | int scaled_yoffs = (scale * info.yoffs) >> 12; |
| 957 | |
| 958 | // we're hflipped, account for it |
| 959 | if (hflip) |
| 960 | scaled_xoffs = ((scale * info.width) >> 12) - scaled_xoffs; |
| 961 | |
| 962 | // adjust for the x and y offsets |
| 963 | x -= scaled_xoffs; |
| 964 | y -= scaled_yoffs; |
| 965 | |
| 966 | do |
| 967 | { |
| 968 | // make sure we didn't end up with 0 |
| 969 | int scaled_width = (scale * info.width + 0x7fff) >> 12; |
| 970 | int scaled_height = (scale * info.height + 0x7fff) >> 12; |
| 971 | if (scaled_width == 0) scaled_width = 1; |
| 972 | if (scaled_height == 0) scaled_height = 1; |
| 973 | |
| 974 | // compute the remaining parameters |
| 975 | int sx = x; |
| 976 | int sy = y; |
| 977 | int ex = sx + scaled_width - 1; |
| 978 | int ey = sy + scaled_height - 1; |
| 979 | |
| 980 | // left edge clip |
| 981 | const rectangle &visarea = m_screen->visible_area(); |
| 982 | if (sx < visarea.min_x) |
| 983 | sx = visarea.min_x; |
| 984 | if (sx > visarea.max_x) |
| 985 | break; |
| 986 | |
| 987 | // right edge clip |
| 988 | if (ex > visarea.max_x) |
| 989 | ex = visarea.max_x; |
| 990 | else if (ex < visarea.min_x) |
| 991 | break; |
| 992 | |
| 993 | // top edge clip |
| 994 | if (sy < visarea.min_y) |
| 995 | sy = visarea.min_y; |
| 996 | else if (sy > visarea.max_y) |
| 997 | break; |
| 998 | |
| 999 | // bottom edge clip |
| 1000 | if (ey > visarea.max_y) |
| 1001 | ey = visarea.max_y; |
| 1002 | else if (ey < visarea.min_y) |
| 1003 | break; |
| 1004 | |
| 1005 | for (int ty = sy; ty <= ey; ty++) |
| 1006 | { |
| 1007 | bitmap.pix16(ty, sx) = machine().rand() & 0xff; |
| 1008 | bitmap.pix16(ty, ex) = machine().rand() & 0xff; |
| 1009 | } |
| 1010 | for (int tx = sx; tx <= ex; tx++) |
| 1011 | { |
| 1012 | bitmap.pix16(sy, tx) = machine().rand() & 0xff; |
| 1013 | bitmap.pix16(ey, tx) = machine().rand() & 0xff; |
| 1014 | } |
| 1015 | } while (0); |
| 1016 | fprintf(stderr, " Sprite: c=%04X l=%04X h=%d X=%4d (o=%4d w=%3d) Y=%4d (o=%4d h=%d) s=%04X\n", |
| 1017 | code, color, hflip, |
| 1018 | x, -scaled_xoffs, (scale * info.width) >> 12, |
| 1019 | y, -scaled_yoffs, (scale * info.height) >> 12, scale); |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | //************************************************************************** |
| 1026 | // SPRITE PARAMETER |
| 1027 | //************************************************************************** |
| 1028 | |
| 1029 | //------------------------------------------------- |
| 1030 | // sprite_parameter: Constructor |
| 1031 | //------------------------------------------------- |
| 1032 | |
| 1033 | atari_rle_objects_device::sprite_parameter::sprite_parameter() |
| 1034 | : m_word(0), |
| 1035 | m_shift(0), |
| 1036 | m_mask(0) |
| 1037 | { |
| 1038 | } |
| 1039 | |
| 1040 | |
| 1041 | //------------------------------------------------- |
| 1042 | // set: Sets the mask via an input 4-word mask. |
| 1043 | //------------------------------------------------- |
| 1044 | |
| 1045 | bool atari_rle_objects_device::sprite_parameter::set(const UINT16 input[8]) |
| 1046 | { |
| 1047 | // determine the word and make sure it's only 1 |
| 1048 | m_word = 0xffff; |
| 1049 | for (int i = 0; i < 8; i++) |
| 1050 | if (input[i]) |
| 1051 | { |
| 1052 | if (m_word == 0xffff) |
| 1053 | m_word = i; |
| 1054 | else |
| 1055 | return false; |
| 1056 | } |
| 1057 | |
| 1058 | // if all-zero, it's valid |
| 1059 | if (m_word == 0xffff) |
| 1060 | { |
| 1061 | m_word = m_shift = m_mask = 0; |
| 1062 | return true; |
| 1063 | } |
| 1064 | |
| 1065 | // determine the shift and final mask |
| 1066 | m_shift = 0; |
| 1067 | UINT16 temp = input[m_word]; |
| 1068 | while (!(temp & 1)) |
| 1069 | { |
| 1070 | m_shift++; |
| 1071 | temp >>= 1; |
| 1072 | } |
| 1073 | m_mask = temp; |
| 1074 | return true; |
| 1075 | } |
| 1076 | |
| 1077 | |
| 1078 | |
| 1079 | |
| 1369 | 1080 | /*************************************************************************** |
| 1370 | 1081 | |
| 1371 | 1082 | The mapping of the bits from the PROMs is like this: |