Previous 199869 Revisions Next

r24782 Wednesday 7th August, 2013 at 03:18:59 UTC by Aaron Giles
Moved tilemap_memory into a generic memory_array class, since it is
more generally useful than just in tilemaps. Code is now in memarray.*

Converted the Atari RLE motion objects device from a half-assed
device into a full-assed device, leveraging the memory_array class.
[src/emu]emu.h emu.mak memarray.c* memarray.h* tilemap.c tilemap.h
[src/mame/drivers]atarig1.c atarig42.c atarigt.c atarigx2.c
[src/mame/includes]atarig1.h atarig42.h atarigt.h atarigx2.h
[src/mame/video]atarig1.c atarig42.c atarigt.c atarigx2.c atarirle.c atarirle.h

trunk/src/mame/drivers/atarigx2.c
r24781r24782
103103   if (ACCESSING_BITS_24_31)
104104   {
105105      /* 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);
107107   }
108108
109109   /* lower byte */
r24781r24782
116116{
117117   COMBINE_DATA(m_mo_command);
118118   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);
120120}
121121
122122
r24781r24782
11391139   AM_RANGE(0xd40000, 0xd40fff) AM_RAM_WRITE(paletteram32_666_w) AM_SHARE("paletteram")
11401140   AM_RANGE(0xd72000, 0xd75fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield")
11411141   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")
11431143   AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_SHARE("mo_command")
11441144   AM_RANGE(0xd70000, 0xd7ffff) AM_RAM
11451145   AM_RANGE(0xd80000, 0xd9ffff) AM_WRITE16(eeprom_enable_w, 0xffffffff)
r24781r24782
13561356   GFXDECODE_ENTRY( "gfx1", 0, pftoplayout, 0x000, 64 )
13571357GFXDECODE_END
13581358
1359static const atarirle_desc modesc_0x200 =
1359static const atari_rle_objects_config modesc_0x200 =
13601360{
1361   "gfx3",     /* region where the GFX data lives */
1362   256,        /* number of entries in sprite RAM */
13631361   0,          /* left clip coordinate */
13641362   0,          /* right clip coordinate */
1365
13661363   0x200,      /* base palette entry */
1367   0x400,      /* maximum number of colors */
13681364
13691365   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
13701366   {{ 0,0x01f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
13771373   {{ 0 }}                     /* mask for the VRAM target */
13781374};
13791375
1380static const atarirle_desc modesc_0x400 =
1376static const atari_rle_objects_config modesc_0x400 =
13811377{
1382   "gfx3",     /* region where the GFX data lives */
1383   256,        /* number of entries in sprite RAM */
13841378   0,          /* left clip coordinate */
13851379   0,          /* right clip coordinate */
1386
13871380   0x400,      /* base palette entry */
1388   0x400,      /* maximum number of colors */
13891381
13901382   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
13911383   {{ 0,0x03f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
14291421   /* the board uses a pair of GALs to determine H and V parameters */
14301422   MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240)
14311423   MCFG_SCREEN_UPDATE_DRIVER(atarigx2_state, screen_update_atarigx2)
1432   MCFG_SCREEN_VBLANK_DRIVER(atarigx2_state, screen_eof_atarigx2)
14331424
14341425   MCFG_VIDEO_START_OVERRIDE(atarigx2_state,atarigx2)
14351426
r24781r24782
14441435
14451436
14461437static MACHINE_CONFIG_DERIVED( atarigx2_0x200, atarigx2 )
1447   MCFG_ATARIRLE_ADD( "rle", modesc_0x200 )
1438   MCFG_ATARIRLE_ADD("rle", modesc_0x200)
14481439MACHINE_CONFIG_END
14491440
14501441static MACHINE_CONFIG_DERIVED( atarigx2_0x400, atarigx2 )
1451   MCFG_ATARIRLE_ADD( "rle", modesc_0x400 )
1442   MCFG_ATARIRLE_ADD("rle", modesc_0x400)
14521443MACHINE_CONFIG_END
14531444
14541445
r24781r24782
14781469   ROM_REGION( 0x020000, "gfx2", 0 )
14791470   ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */
14801471
1481   ROM_REGION16_BE( 0x600000, "gfx3", 0 )
1472   ROM_REGION16_BE( 0x600000, "rle", 0 )
14821473   ROM_LOAD16_BYTE( "136095.41b", 0x000000, 0x80000, CRC(02ce7e07) SHA1(a48a6930c8ca4e2d0e4bc77a558730fa790be3b5) )
14831474   ROM_LOAD16_BYTE( "136095.40b", 0x000001, 0x80000, CRC(abb80720) SHA1(0e02688454f59b90d38d548808f794294f5c9e7e) )
14841475   ROM_LOAD16_BYTE( "136095.43b", 0x100000, 0x80000, CRC(26526345) SHA1(30ef83f63aca3a846dfc2828e3147208e3e350ca) )
r24781r24782
15241515   ROM_REGION( 0x020000, "gfx2", 0 )
15251516   ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */
15261517
1527   ROM_REGION16_BE( 0x600000, "gfx3", 0 )
1518   ROM_REGION16_BE( 0x600000, "rle", 0 )
15281519   ROM_LOAD16_BYTE( "136095.41b", 0x000000, 0x80000, CRC(02ce7e07) SHA1(a48a6930c8ca4e2d0e4bc77a558730fa790be3b5) )
15291520   ROM_LOAD16_BYTE( "136095.40b", 0x000001, 0x80000, CRC(abb80720) SHA1(0e02688454f59b90d38d548808f794294f5c9e7e) )
15301521   ROM_LOAD16_BYTE( "136095.43b", 0x100000, 0x80000, CRC(26526345) SHA1(30ef83f63aca3a846dfc2828e3147208e3e350ca) )
r24781r24782
15701561   ROM_REGION( 0x020000, "gfx2", 0 )
15711562   ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */
15721563
1573   ROM_REGION16_BE( 0x600000, "gfx3", 0 )
1564   ROM_REGION16_BE( 0x600000, "rle", 0 )
15741565   ROM_LOAD16_BYTE( "136095.41a", 0x000000, 0x80000, CRC(5f9743ee) SHA1(fa521572f8dd2eda566f90d1345adba3d0b8c48f) )
15751566   ROM_LOAD16_BYTE( "136095.40a", 0x000001, 0x80000, CRC(99b26863) SHA1(21682771d310c73d4431dde5e72398a69a6f3d53) )
15761567   ROM_LOAD16_BYTE( "136095.43a", 0x100000, 0x80000, CRC(9c0e09a5) SHA1(039dc52318935f686230f57a7b39b9c62280cbf9) )
r24781r24782
16161607   ROM_REGION( 0x020000, "gfx2", 0 )
16171608   ROM_LOAD( "136095.25a", 0x000000, 0x20000, CRC(1669496e) SHA1(005deaafd6156505e3a27966123e58928837ad9f) ) /* alphanumerics */
16181609
1619   ROM_REGION16_BE( 0x600000, "gfx3", 0 )
1610   ROM_REGION16_BE( 0x600000, "rle", 0 )
16201611   ROM_LOAD16_BYTE( "136095.41a", 0x000000, 0x80000, CRC(5f9743ee) SHA1(fa521572f8dd2eda566f90d1345adba3d0b8c48f) )
16211612   ROM_LOAD16_BYTE( "136095.40a", 0x000001, 0x80000, CRC(99b26863) SHA1(21682771d310c73d4431dde5e72398a69a6f3d53) )
16221613   ROM_LOAD16_BYTE( "136095.43a", 0x100000, 0x80000, CRC(9c0e09a5) SHA1(039dc52318935f686230f57a7b39b9c62280cbf9) )
r24781r24782
16621653   ROM_REGION( 0x020000, "gfx2", 0 )
16631654   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
16641655
1665   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1656   ROM_REGION16_BE( 0x700000, "rle", 0 )
16661657   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
16671658   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
16681659   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
17101701   ROM_REGION( 0x020000, "gfx2", 0 )
17111702   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
17121703
1713   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1704   ROM_REGION16_BE( 0x700000, "rle", 0 )
17141705   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
17151706   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
17161707   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
17621753   ROM_REGION( 0x020000, "gfx2", 0 )
17631754   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
17641755
1765   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1756   ROM_REGION16_BE( 0x700000, "rle", 0 )
17661757   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
17671758   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
17681759   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
18111802   ROM_REGION( 0x020000, "gfx2", 0 )
18121803   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
18131804
1814   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1805   ROM_REGION16_BE( 0x700000, "rle", 0 )
18151806   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
18161807   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
18171808   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
18601851   ROM_REGION( 0x020000, "gfx2", 0 )
18611852   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
18621853
1863   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1854   ROM_REGION16_BE( 0x700000, "rle", 0 )
18641855   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
18651856   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
18661857   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
19081899   ROM_REGION( 0x020000, "gfx2", 0 )
19091900   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
19101901
1911   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1902   ROM_REGION16_BE( 0x700000, "rle", 0 )
19121903   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
19131904   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
19141905   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
19561947   ROM_REGION( 0x020000, "gfx2", 0 )
19571948   ROM_LOAD( "136094-0025a.13n", 0x000000, 0x20000, CRC(6ab762ad) SHA1(c52dd207ff5adaffa458e020e7d452a1d1e65194) ) /* alphanumerics */
19581949
1959   ROM_REGION16_BE( 0x700000, "gfx3", 0 )
1950   ROM_REGION16_BE( 0x700000, "rle", 0 )
19601951   ROM_LOAD16_BYTE( "136094-0041a.31n", 0x000000, 0x80000, CRC(474770e9) SHA1(507dac654d1c350ab530892e3ec19793629d3a07) )
19611952   ROM_LOAD16_BYTE( "136094-0040a.31l", 0x000001, 0x80000, CRC(cb777468) SHA1(aa199bc02ab966b9f270057857aec50add8d684c) )
19621953   ROM_LOAD16_BYTE( "136094-0043a.33n", 0x100000, 0x80000, CRC(353d2dc3) SHA1(82c2c862404ea4c94c9baee1d0ac32696fcf78bd) )
r24781r24782
20001991   ROM_REGION( 0x020000, "gfx2", 0 )
20011992   ROM_LOAD( "alpha.13n", 0x000000, 0x20000, CRC(f2efbd66) SHA1(d5339f0b3de7a102d659f7459b5f4800cab31829) ) /* alphanumerics */
20021993
2003   ROM_REGION16_BE( 0x500000, "gfx3", 0 )
1994   ROM_REGION16_BE( 0x500000, "rle", 0 )
20041995   ROM_LOAD16_BYTE( "mo0h.31n",    0x000000, 0x80000, CRC(fc2755d5) SHA1(e24319161307efbb3828b21a6250869051f1ccc1) )
20051996   ROM_LOAD16_BYTE( "mo0l.31l",    0x000001, 0x80000, CRC(f9f6bfe3) SHA1(c7e1479bb86646691d5ca7ee9127553cfd86571e) )
20061997   ROM_LOAD16_BYTE( "rrmo1h.33n",  0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) )
r24781r24782
20662057   ROM_REGION( 0x020000, "gfx2", 0 )
20672058   ROM_LOAD( "alpha.13n", 0x000000, 0x20000, CRC(f2efbd66) SHA1(d5339f0b3de7a102d659f7459b5f4800cab31829) ) /* alphanumerics */
20682059
2069   ROM_REGION16_BE( 0x500000, "gfx3", 0 )
2060   ROM_REGION16_BE( 0x500000, "rle", 0 )
20702061   ROM_LOAD16_BYTE( "mo0h.31n",   0x000000, 0x80000, CRC(fc2755d5) SHA1(e24319161307efbb3828b21a6250869051f1ccc1) )
20712062   ROM_LOAD16_BYTE( "mo0l.31l",   0x000001, 0x80000, CRC(f9f6bfe3) SHA1(c7e1479bb86646691d5ca7ee9127553cfd86571e) )
20722063   ROM_LOAD16_BYTE( "rrmo1h.33n", 0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) )
r24781r24782
21262117   ROM_REGION( 0x020000, "gfx2", 0 )
21272118   ROM_LOAD( "rralalph.13n", 0x000000, 0x20000, CRC(7ca93790) SHA1(5e2f069be4b15d63f418c8693e8550eb0ae22381) ) /* alphanumerics */
21282119
2129   ROM_REGION16_BE( 0x500000, "gfx3", 0 )
2120   ROM_REGION16_BE( 0x500000, "rle", 0 )
21302121   ROM_LOAD16_BYTE( "rrmo0h.31n", 0x000000, 0x80000, CRC(9b7e0315) SHA1(856804e89f586a4e777da5f47dc29c4e34175f44) )
21312122   ROM_LOAD16_BYTE( "rrmo0l.31l", 0x000001, 0x80000, CRC(10478697) SHA1(9682e82cfbdc20f63d5c49303265c598a334c15b) )
21322123   ROM_LOAD16_BYTE( "rrmo1h.33n", 0x100000, 0x80000, CRC(c7a48389) SHA1(a263aa4829cb243440ebe0496dd4f0158d97e2cc) )
trunk/src/mame/drivers/atarigt.c
r24781r24782
219219   if (ACCESSING_BITS_24_31)
220220   {
221221      /* bits 13-11 are the MO control bits */
222      atarirle_control_w(m_rle, (data >> 27) & 7);
222      m_rle->control_write(space, offset, (data >> 27) & 7);
223223   }
224224
225225   if (ACCESSING_BITS_16_23)
r24781r24782
235235{
236236   COMBINE_DATA(m_mo_command);
237237   if (ACCESSING_BITS_0_15)
238      atarirle_command_w(m_rle, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
238      m_rle->command_write(space, offset, ((data & 0xffff) == 2) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
239239}
240240
241241
r24781r24782
620620   AM_RANGE(0xd40000, 0xd4ffff) AM_WRITE16(eeprom_enable_w, 0xffffffff)
621621   AM_RANGE(0xd72000, 0xd75fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield")
622622   AM_RANGE(0xd76000, 0xd76fff) AM_DEVWRITE("alpha", tilemap_device, write) AM_SHARE("alpha")
623   AM_RANGE(0xd78000, 0xd78fff) AM_DEVREADWRITE_LEGACY("rle", atarirle_spriteram32_r, atarirle_spriteram32_w)
623   AM_RANGE(0xd78000, 0xd78fff) AM_RAM AM_SHARE("rle")
624624   AM_RANGE(0xd7a200, 0xd7a203) AM_WRITE(mo_command_w) AM_SHARE("mo_command")
625625   AM_RANGE(0xd70000, 0xd7ffff) AM_RAM
626626   AM_RANGE(0xd80000, 0xdfffff) AM_READWRITE(colorram_protection_r, colorram_protection_w) AM_SHARE("colorram")
r24781r24782
790790GFXDECODE_END
791791
792792
793static const atarirle_desc modesc =
793static const atari_rle_objects_config modesc =
794794{
795   "gfx3",     /* region where the GFX data lives */
796   256,        /* number of entries in sprite RAM */
797795   0,          /* left clip coordinate */
798796   0,          /* right clip coordinate */
799
800797   0x0000,     /* base palette entry */
801   0x1000,     /* maximum number of colors */
802798
803799   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
804800   {{ 0,0x0ff0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
843839   /* the board uses a pair of GALs to determine H and V parameters */
844840   MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240)
845841   MCFG_SCREEN_UPDATE_DRIVER(atarigt_state, screen_update_atarigt)
846   MCFG_SCREEN_VBLANK_DRIVER(atarigt_state, screen_eof_atarigt)
847842
848843   MCFG_VIDEO_START_OVERRIDE(atarigt_state,atarigt)
849844
r24781r24782
891886   ROM_REGION( 0x020000, "gfx2", 0 )
892887   ROM_LOAD( "0045a", 0x000000, 0x20000, CRC(057a5304) SHA1(d44c0cf885a1324888b7e8118f124c0dae616859) ) /* alphanumerics */
893888
894   ROM_REGION16_BE( 0x1000000, "gfx3", 0 )
889   ROM_REGION16_BE( 0x1000000, "rle", 0 )
895890   ROM_LOAD16_BYTE( "0300", 0x000001, 0x100000, CRC(8367ddac) SHA1(9ca77962259284cef8a261b652ab1327817ee8d0) )
896891   ROM_LOAD16_BYTE( "0301", 0x000000, 0x100000, CRC(94524b5b) SHA1(db401fd7ba56658fcb614406672c02569d845930) )
897892   ROM_LOAD16_BYTE( "0302", 0x200001, 0x100000, CRC(c03f1aa7) SHA1(c68b52280d0695629c843b9c90f7a39713e063b0) )
r24781r24782
946941   ROM_REGION( 0x020000, "gfx2", 0 )
947942   ROM_LOAD( "0045a", 0x000000, 0x20000, CRC(057a5304) SHA1(d44c0cf885a1324888b7e8118f124c0dae616859) ) /* alphanumerics */
948943
949   ROM_REGION16_BE( 0x1000000, "gfx3", 0 )
944   ROM_REGION16_BE( 0x1000000, "rle", 0 )
950945   ROM_LOAD16_BYTE( "0300", 0x000001, 0x100000, CRC(8367ddac) SHA1(9ca77962259284cef8a261b652ab1327817ee8d0) )
951946   ROM_LOAD16_BYTE( "0301", 0x000000, 0x100000, CRC(94524b5b) SHA1(db401fd7ba56658fcb614406672c02569d845930) )
952947   ROM_LOAD16_BYTE( "0302", 0x200001, 0x100000, CRC(c03f1aa7) SHA1(c68b52280d0695629c843b9c90f7a39713e063b0) )
r24781r24782
1001996   ROM_REGION( 0x020000, "gfx2", 0 )
1002997   ROM_LOAD( "0045a", 0x000000, 0x20000, CRC(057a5304) SHA1(d44c0cf885a1324888b7e8118f124c0dae616859) ) /* alphanumerics */
1003998
1004   ROM_REGION16_BE( 0x1000000, "gfx3", 0 )
999   ROM_REGION16_BE( 0x1000000, "rle", 0 )
10051000   ROM_LOAD16_BYTE( "0300", 0x000001, 0x100000, CRC(8367ddac) SHA1(9ca77962259284cef8a261b652ab1327817ee8d0) )
10061001   ROM_LOAD16_BYTE( "0301", 0x000000, 0x100000, CRC(94524b5b) SHA1(db401fd7ba56658fcb614406672c02569d845930) )
10071002   ROM_LOAD16_BYTE( "0302", 0x200001, 0x100000, CRC(c03f1aa7) SHA1(c68b52280d0695629c843b9c90f7a39713e063b0) )
r24781r24782
10561051   ROM_REGION( 0x020000, "gfx2", 0 )
10571052   ROM_LOAD( "0045a", 0x000000, 0x20000, CRC(057a5304) SHA1(d44c0cf885a1324888b7e8118f124c0dae616859) ) /* alphanumerics */
10581053
1059   ROM_REGION16_BE( 0x1000000, "gfx3", 0 )
1054   ROM_REGION16_BE( 0x1000000, "rle", 0 )
10601055   ROM_LOAD16_BYTE( "0300", 0x000001, 0x100000, CRC(8367ddac) SHA1(9ca77962259284cef8a261b652ab1327817ee8d0) )
10611056   ROM_LOAD16_BYTE( "0301", 0x000000, 0x100000, CRC(94524b5b) SHA1(db401fd7ba56658fcb614406672c02569d845930) )
10621057   ROM_LOAD16_BYTE( "0302", 0x200001, 0x100000, CRC(c03f1aa7) SHA1(c68b52280d0695629c843b9c90f7a39713e063b0) )
r24781r24782
11111106   ROM_REGION( 0x020000, "gfx2", 0 )
11121107   ROM_LOAD( "alpha", 0x000000, 0x20000, CRC(8f57a604) SHA1(f076636430ff73ea11e4687ef7b21a7bac1d8e34) ) /* alphanumerics */
11131108
1114   ROM_REGION16_BE( 0x1000000, "gfx3", 0 )
1109   ROM_REGION16_BE( 0x1000000, "rle", 0 )
11151110   ROM_LOAD16_BYTE( "0300", 0x000001, 0x100000, CRC(8367ddac) SHA1(9ca77962259284cef8a261b652ab1327817ee8d0) )
11161111   ROM_LOAD16_BYTE( "0301", 0x000000, 0x100000, CRC(94524b5b) SHA1(db401fd7ba56658fcb614406672c02569d845930) )
11171112   ROM_LOAD16_BYTE( "0302", 0x200001, 0x100000, CRC(c03f1aa7) SHA1(c68b52280d0695629c843b9c90f7a39713e063b0) )
r24781r24782
11581153   ROM_REGION( 0x020000, "gfx2", 0 )
11591154   ROM_LOAD( "136102-1045b.23p", 0x000000, 0x20000, CRC(1d3260bf) SHA1(85d9db8499cbe180c8d52710f3cfe64453a530ff) ) /* alphanumerics */
11601155
1161   ROM_REGION16_BE( 0x2000000, "gfx3", 0 )
1156   ROM_REGION16_BE( 0x2000000, "rle", 0 )
11621157   ROM_LOAD16_BYTE( "136102-1100a.2v",    0x0000001, 0x080000, CRC(6e9c80b5) SHA1(ec724011527dd8707c733211b1a6c51b22f580c7) )
11631158   ROM_LOAD16_BYTE( "136102-1101a.2w",    0x0000000, 0x080000, CRC(bb7ee624) SHA1(0de6385aee7d25b41fd5bf232e44e5da536504ac) )
11641159   ROM_LOAD16_BYTE( "136102-0332.mol1.0", 0x0800001, 0x100000, CRC(610cfcb4) SHA1(bed1bd0d11c0a7cc48d020fc0acec34daf48c5ac) )
r24781r24782
12441239   ROM_REGION( 0x020000, "gfx2", 0 )
12451240   ROM_LOAD( "136102-0045a.23p", 0x000000, 0x20000, CRC(c8b39b1c) SHA1(836c0ccf96b2beccacf6d8ac23981fc2d1f09803) ) /* alphanumerics */
12461241
1247   ROM_REGION16_BE( 0x2000000, "gfx3", 0 )
1242   ROM_REGION16_BE( 0x2000000, "rle", 0 )
12481243   ROM_LOAD16_BYTE( "136102-0100a.2v",    0x0000001, 0x080000, CRC(5299fb2a) SHA1(791378215ab6ffff3ab2ae7192ce9f88dae4090d) )
12491244   ROM_LOAD16_BYTE( "136102-0101a.2w",    0x0000000, 0x080000, CRC(3e234711) SHA1(6a9f19db2b4c8c34d3d7b4984206e3d5c4398d7f) )
12501245   ROM_LOAD16_BYTE( "136102-0332.mol1.0", 0x0800001, 0x100000, CRC(610cfcb4) SHA1(bed1bd0d11c0a7cc48d020fc0acec34daf48c5ac) )
trunk/src/mame/drivers/atarig1.c
r24781r24782
5858 *
5959 *************************************/
6060
61WRITE16_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
7061WRITE16_MEMBER(atarig1_state::mo_command_w)
7162{
7263   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);
7465}
7566
7667
r24781r24782
203194   AM_RANGE(0xf88000, 0xf8ffff) AM_WRITE(eeprom_enable_w)
204195   AM_RANGE(0xf90000, 0xf90001) AM_DEVWRITE8("jsa", atari_jsa_ii_device, main_command_w, 0xff00)
205196   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)
207198   AM_RANGE(0xfb0000, 0xfb0001) AM_WRITE(video_int_ack_w)
208199   AM_RANGE(0xfc0000, 0xfc0001) AM_READ(special_port0_r)
209200   AM_RANGE(0xfc8000, 0xfc8007) AM_READWRITE(a2d_data_r, a2d_select_w)
r24781r24782
211202   AM_RANGE(0xfd8000, 0xfdffff) AM_READWRITE(eeprom_r, eeprom_w) AM_SHARE("eeprom")
212203/*  AM_RANGE(0xfe0000, 0xfe7fff) AM_READ(from_r)*/
213204   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")
215206   AM_RANGE(0xff2000, 0xff2001) AM_WRITE(mo_command_w) AM_SHARE("mo_command")
216207   AM_RANGE(0xff4000, 0xff5fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield")
217208   AM_RANGE(0xff6000, 0xff6fff) AM_DEVWRITE("alpha", tilemap_device, write) AM_SHARE("alpha")
r24781r24782
388379
389380
390381
391static const atarirle_desc modesc_hydra =
382static const atari_rle_objects_config modesc_hydra =
392383{
393   "gfx3",     /* region where the GFX data lives */
394   256,        /* number of entries in sprite RAM */
395384   0,          /* left clip coordinate */
396385   255,        /* right clip coordinate */
397
398386   0x200,      /* base palette entry */
399   0x100,      /* maximum number of colors */
400387
401388   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
402389   {{ 0,0x00f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
409396   {{ 0 }}                     /* mask for the VRAM target */
410397};
411398
412static const atarirle_desc modesc_pitfight =
399static const atari_rle_objects_config modesc_pitfight =
413400{
414   "gfx3",     /* region where the GFX data lives */
415   256,        /* number of entries in sprite RAM */
416401   40,         /* left clip coordinate */
417402   295,        /* right clip coordinate */
418
419403   0x200,      /* base palette entry */
420   0x100,      /* maximum number of colors */
421404
422405   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
423406   {{ 0,0x00f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
460443   /* note: these parameters are from published specs, not derived */
461444   MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240)
462445   MCFG_SCREEN_UPDATE_DRIVER(atarig1_state, screen_update_atarig1)
463   MCFG_SCREEN_VBLANK_DRIVER(atarig1_state, screen_eof_atarig1)
464446
465447   MCFG_VIDEO_START_OVERRIDE(atarig1_state,atarig1)
466448
r24781r24782
473455MACHINE_CONFIG_END
474456
475457static MACHINE_CONFIG_DERIVED( hydra, atarig1 )
476   MCFG_ATARIRLE_ADD( "rle", modesc_hydra )
458   MCFG_ATARIRLE_ADD("rle", modesc_hydra)
477459MACHINE_CONFIG_END
478460
479461static MACHINE_CONFIG_DERIVED( pitfight, atarig1 )
480   MCFG_ATARIRLE_ADD( "rle", modesc_pitfight )
462   MCFG_ATARIRLE_ADD("rle", modesc_pitfight)
481463MACHINE_CONFIG_END
482464
483465
r24781r24782
517499   ROM_REGION( 0x020000, "gfx2", 0 )
518500   ROM_LOAD( "136079-1027.bin",  0x000000, 0x20000, CRC(f9135b9b) SHA1(48c0ad0d3e592d191d1385e30530bdb69a095452) ) /* alphanumerics */
519501
520   ROM_REGION16_BE( 0x100000, "gfx3", 0 )
502   ROM_REGION16_BE( 0x100000, "rle", 0 )
521503   ROM_LOAD16_BYTE( "136079-1001.bin", 0x00001, 0x10000, CRC(3f757a53) SHA1(be2b7f8b907ef9ea24b24b7210ead70cdbad3506) )
522504   ROM_LOAD16_BYTE( "136079-1002.bin", 0x00000, 0x10000, CRC(a1169469) SHA1(b5ab65ca9d98ef1e79518eaa519fba0cee92c86e) )
523505   ROM_LOAD16_BYTE( "136079-1003.bin", 0x20001, 0x10000, CRC(aa21ec33) SHA1(dec65b670c64b3630f6ccbbcc3212f6771908de9) )
r24781r24782
577559   ROM_REGION( 0x020000, "gfx2", 0 )
578560   ROM_LOAD( "hydalph.bin",   0x000000, 0x20000, CRC(7dd2b062) SHA1(789b35b1e8cce73e2314d1b6688b5066df91b604) ) /* alphanumerics */
579561
580   ROM_REGION16_BE( 0x100000, "gfx3", 0 )
562   ROM_REGION16_BE( 0x100000, "rle", 0 )
581563   ROM_LOAD16_BYTE( "hydmhi0.bin", 0x00001, 0x10000, CRC(3c83b42d) SHA1(3c6de7e6aab08a673227f06b04e000714a9111b1) )
582564   ROM_LOAD16_BYTE( "hydmlo0.bin", 0x00000, 0x10000, CRC(6d49650c) SHA1(97f9dbdfa5cc620705eec1da2398b2ac63cef30f) )
583565   ROM_LOAD16_BYTE( "hydmhi1.bin", 0x20001, 0x10000, CRC(689b3376) SHA1(85ffa31f10483317db615cf8e520a8c8a40d6013) )
r24781r24782
637619   ROM_REGION( 0x020000, "gfx2", 0 )
638620   ROM_LOAD( "136079-1027.bin",  0x000000, 0x20000, CRC(f9135b9b) SHA1(48c0ad0d3e592d191d1385e30530bdb69a095452) ) /* alphanumerics */
639621
640   ROM_REGION16_BE( 0x100000, "gfx3", 0 )
622   ROM_REGION16_BE( 0x100000, "rle", 0 )
641623   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
642624   ROM_LOAD16_BYTE( "136079-1002.bin", 0x00000, 0x10000, BAD_DUMP CRC(a1169469) SHA1(b5ab65ca9d98ef1e79518eaa519fba0cee92c86e) ) // "
643625   ROM_LOAD16_BYTE( "136079-1003.bin", 0x20001, 0x10000, BAD_DUMP CRC(aa21ec33) SHA1(dec65b670c64b3630f6ccbbcc3212f6771908de9) ) // "
r24781r24782
721703   ROM_REGION( 0x020000, "gfx2", 0 )
722704   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
723705
724   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
706   ROM_REGION16_BE( 0x200000, "rle", 0 )
725707   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
726708   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
727709   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
r24781r24782
817799   ROM_REGION( 0x020000, "gfx2", 0 )
818800   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
819801
820   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
802   ROM_REGION16_BE( 0x200000, "rle", 0 )
821803   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
822804   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
823805   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
r24781r24782
880862   ROM_REGION( 0x020000, "gfx2", 0 )
881863   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
882864
883   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
865   ROM_REGION16_BE( 0x200000, "rle", 0 )
884866   ROM_LOAD16_BYTE( "136081-1065.65r", 0x000001, 0x80000, CRC(6d3a834f) SHA1(6e153fee39b6a932aeb101e69e3557355a637c76) ) /* Same data as other sets, but in four mask roms */
885867   ROM_LOAD16_BYTE( "136081-1066.65n", 0x000000, 0x80000, CRC(0f7f5117) SHA1(e9d3d0db388a5f7d76de363018d92fa59bf8113a) )
886868   ROM_LOAD16_BYTE( "136081-1067.70r", 0x100001, 0x80000, CRC(ca4f75a8) SHA1(f8b8b03df4ad043a48970a0f8a4c3b85c7140493) )
r24781r24782
931913   ROM_REGION( 0x020000, "gfx2", 0 )
932914   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
933915
934   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
916   ROM_REGION16_BE( 0x200000, "rle", 0 )
935917   ROM_LOAD16_BYTE( "136081-1065.65r", 0x000001, 0x80000, CRC(6d3a834f) SHA1(6e153fee39b6a932aeb101e69e3557355a637c76) ) /* Same data as other sets, but in four mask roms */
936918   ROM_LOAD16_BYTE( "136081-1066.65n", 0x000000, 0x80000, CRC(0f7f5117) SHA1(e9d3d0db388a5f7d76de363018d92fa59bf8113a) )
937919   ROM_LOAD16_BYTE( "136081-1067.70r", 0x100001, 0x80000, CRC(ca4f75a8) SHA1(f8b8b03df4ad043a48970a0f8a4c3b85c7140493) )
r24781r24782
982964   ROM_REGION( 0x020000, "gfx2", 0 )
983965   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
984966
985   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
967   ROM_REGION16_BE( 0x200000, "rle", 0 )
986968   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
987969   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
988970   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
r24781r24782
10451027   ROM_REGION( 0x020000, "gfx2", 0 )
10461028   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
10471029
1048   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
1030   ROM_REGION16_BE( 0x200000, "rle", 0 )
10491031   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
10501032   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
10511033   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
r24781r24782
11081090   ROM_REGION( 0x020000, "gfx2", 0 )
11091091   ROM_LOAD( "136081-1427.dat",  0x000000, 0x20000, CRC(b2c51dff) SHA1(7ad82a6a55d3a68e39d113c92f9e89a43408b5b2) ) /* alphanumerics */
11101092
1111   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
1093   ROM_REGION16_BE( 0x200000, "rle", 0 )
11121094   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
11131095   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
11141096   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
r24781r24782
11711153   ROM_REGION( 0x020000, "gfx2", 0 )
11721154   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
11731155
1174   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
1156   ROM_REGION16_BE( 0x200000, "rle", 0 )
11751157   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
11761158   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
11771159   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
trunk/src/mame/drivers/atarig42.c
r24781r24782
9393      asic65_reset(machine(), (~data >> 14) & 1);
9494
9595      /* bits 13-11 are the MO control bits */
96      atarirle_control_w(m_rle, (data >> 11) & 7);
96      m_rle->control_write(space, 0, (data >> 11) & 7);
9797   }
9898
9999   /* lower byte */
r24781r24782
114114WRITE16_MEMBER(atarig42_state::mo_command_w)
115115{
116116   COMBINE_DATA(m_mo_command);
117   atarirle_command_w(m_rle, (data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
117   m_rle->command_write(space, offset, (data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
118118}
119119
120120
r24781r24782
347347   AM_RANGE(0xf80000, 0xf80003) AM_WRITE_LEGACY(asic65_data_w)
348348   AM_RANGE(0xfa0000, 0xfa0fff) AM_READWRITE(eeprom_r, eeprom_w) AM_SHARE("eeprom")
349349   AM_RANGE(0xfc0000, 0xfc0fff) AM_RAM_WRITE(paletteram_666_w) AM_SHARE("paletteram")
350   AM_RANGE(0xff0000, 0xff0fff) AM_DEVREADWRITE_LEGACY("rle", atarirle_spriteram_r, atarirle_spriteram_w)
350   AM_RANGE(0xff0000, 0xff0fff) AM_RAM AM_SHARE("rle")
351351   AM_RANGE(0xff2000, 0xff5fff) AM_DEVWRITE("playfield", tilemap_device, write) AM_SHARE("playfield")
352352   AM_RANGE(0xff6000, 0xff6fff) AM_DEVWRITE("alpha", tilemap_device, write) AM_SHARE("alpha")
353353   AM_RANGE(0xff7000, 0xff7001) AM_WRITE(mo_command_w) AM_SHARE("mo_command")
r24781r24782
487487GFXDECODE_END
488488
489489
490static const atarirle_desc modesc_0x200 =
490static const atari_rle_objects_config modesc_0x200 =
491491{
492   "gfx3",     /* region where the GFX data lives */
493   256,        /* number of entries in sprite RAM */
494492   0,          /* left clip coordinate */
495493   0,          /* right clip coordinate */
496
497494   0x200,      /* base palette entry */
498   0x400,      /* maximum number of colors */
499495
500496   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
501497   {{ 0,0x01f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
509505};
510506
511507
512static const atarirle_desc modesc_0x400 =
508static const atari_rle_objects_config modesc_0x400 =
513509{
514   "gfx3",     /* region where the GFX data lives */
515   256,        /* number of entries in sprite RAM */
516510   0,          /* left clip coordinate */
517511   0,          /* right clip coordinate */
518
519512   0x400,      /* base palette entry */
520   0x400,      /* maximum number of colors */
521513
522514   {{ 0x7fff,0,0,0,0,0,0,0 }}, /* mask for the code index */
523515   {{ 0,0x03f0,0,0,0,0,0,0 }}, /* mask for the color */
r24781r24782
565557   /* the board uses an SOS chip to generate video signals */
566558   MCFG_SCREEN_RAW_PARAMS(ATARI_CLOCK_14MHz/2, 456, 0, 336, 262, 0, 240)
567559   MCFG_SCREEN_UPDATE_DRIVER(atarig42_state, screen_update_atarig42)
568   MCFG_SCREEN_VBLANK_DRIVER(atarig42_state, screen_eof_atarig42)
569560
570561   MCFG_VIDEO_START_OVERRIDE(atarig42_state,atarig42)
571562
r24781r24782
578569MACHINE_CONFIG_END
579570
580571static MACHINE_CONFIG_DERIVED( atarig42_0x200, atarig42 )
581   MCFG_ATARIRLE_ADD( "rle", modesc_0x200 )
572   MCFG_ATARIRLE_ADD("rle", modesc_0x200)
582573MACHINE_CONFIG_END
583574
584575static MACHINE_CONFIG_DERIVED( atarig42_0x400, atarig42 )
585   MCFG_ATARIRLE_ADD( "rle", modesc_0x400 )
576   MCFG_ATARIRLE_ADD("rle", modesc_0x400)
586577MACHINE_CONFIG_END
587578
588579
r24781r24782
619610   ROM_REGION( 0x020000, "gfx2", 0 )
620611   ROM_LOAD( "136089-1046.22j",    0x000000, 0x20000, CRC(0005bab0) SHA1(257e1b23eea117fe6701a67134b96d9d9fe10caf) ) /* alphanumerics */
621612
622   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
613   ROM_REGION16_BE( 0x200000, "rle", 0 )
623614   ROM_LOAD16_BYTE( "136089-1018.2s", 0x000000, 0x20000, CRC(19590a94) SHA1(e375b7e01a8b1f366bb4e7750e33f0b6d9ae2042) )
624615   ROM_LOAD16_BYTE( "136089-1017.2p", 0x000001, 0x20000, CRC(c2bf3f69) SHA1(f822359070b1907973ee7ee35469f4a59f720830) )
625616   ROM_LOAD16_BYTE( "136089-1020.3s", 0x040000, 0x20000, CRC(bab110e4) SHA1(0c4e3521474249517e7832df1bc63aca6d6a6c91) )
r24781r24782
677668   ROM_REGION( 0x020000, "gfx2", 0 )
678669   ROM_LOAD( "136089-1046.22j",    0x000000, 0x20000, CRC(0005bab0) SHA1(257e1b23eea117fe6701a67134b96d9d9fe10caf) ) /* alphanumerics */
679670
680   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
671   ROM_REGION16_BE( 0x200000, "rle", 0 )
681672   ROM_LOAD16_BYTE( "136089-1018.2s", 0x000000, 0x20000, CRC(19590a94) SHA1(e375b7e01a8b1f366bb4e7750e33f0b6d9ae2042) )
682673   ROM_LOAD16_BYTE( "136089-1017.2p", 0x000001, 0x20000, CRC(c2bf3f69) SHA1(f822359070b1907973ee7ee35469f4a59f720830) )
683674   ROM_LOAD16_BYTE( "136089-1020.3s", 0x040000, 0x20000, CRC(bab110e4) SHA1(0c4e3521474249517e7832df1bc63aca6d6a6c91) )
r24781r24782
733724   ROM_REGION( 0x020000, "gfx2", 0 )
734725   ROM_LOAD( "136092-0030.23k",   0x000000, 0x20000, CRC(0fd7baa1) SHA1(7802d732e5173291628ed498ad0fab71aeef4688) ) /* alphanumerics */
735726
736   ROM_REGION16_BE( 0x600000, "gfx3", 0 )
727   ROM_REGION16_BE( 0x600000, "rle", 0 )
737728   ROM_LOAD16_BYTE( "136092-0041.2s",  0x000000, 0x80000, CRC(a2a5ae08) SHA1(d99f925bbc9a72432e13328ee8422fde615db90f) )
738729   ROM_LOAD16_BYTE( "136092-0040.2p",  0x000001, 0x80000, CRC(ef95132e) SHA1(288de1d15956a612b7d19ceb2cf853490bf42b05) )
739730   ROM_LOAD16_BYTE( "136092-0043.3s",  0x100000, 0x80000, CRC(6438b8e4) SHA1(ee1446209fbcab8b17c88c53b65e754a85f279d1) )
trunk/src/mame/includes/atarigt.h
r24781r24782
2121         m_colorram(*this, "colorram", 32),
2222         m_playfield_tilemap(*this, "playfield"),
2323         m_alpha_tilemap(*this, "alpha"),
24         m_rle(*this, "rle"),
2425         m_mo_command(*this, "mo_command") { }
2526
2627   UINT8           m_is_primrage;
r24781r24782
2829
2930   required_device<tilemap_device> m_playfield_tilemap;
3031   required_device<tilemap_device> m_alpha_tilemap;
32   required_device<atari_rle_objects_device> m_rle;
3133
3234   bitmap_ind16 *      m_pf_bitmap;
3335   bitmap_ind16 *      m_an_bitmap;
r24781r24782
5254   UINT16          m_protresult;
5355   UINT8           m_protdata[0x800];
5456
55   device_t *      m_rle;
5657   virtual void update_interrupts();
5758   virtual void scanline_update(screen_device &screen, int scanline);
5859   DECLARE_READ32_MEMBER(special_port2_r);
r24781r24782
7980   DECLARE_MACHINE_RESET(atarigt);
8081   DECLARE_VIDEO_START(atarigt);
8182   UINT32 screen_update_atarigt(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
82   void screen_eof_atarigt(screen_device &screen, bool state);
8383private:
8484   void tmek_update_mode(offs_t offset);
8585   void tmek_protection_w(address_space &space, offs_t offset, UINT16 data);
trunk/src/mame/includes/atarig42.h
r24781r24782
1717         m_jsa(*this, "jsa"),
1818         m_playfield_tilemap(*this, "playfield"),
1919         m_alpha_tilemap(*this, "alpha"),
20         m_rle(*this, "rle"),
2021         m_mo_command(*this, "mo_command") { }
2122
2223   required_device<cpu_device> m_maincpu;
r24781r24782
2425
2526   required_device<tilemap_device> m_playfield_tilemap;
2627   required_device<tilemap_device> m_alpha_tilemap;
28   required_device<atari_rle_objects_device> m_rle;
2729
2830   UINT16          m_playfield_base;
2931
r24781r24782
4244   int             m_sloop_state;
4345   UINT16 *        m_sloop_base;
4446
45   device_t *      m_rle;
4647   UINT32          m_last_accesses[8];
4748   virtual void update_interrupts();
4849   virtual void scanline_update(screen_device &screen, int scanline);
trunk/src/mame/includes/atarigx2.h
r24781r24782
1616         m_mo_command(*this, "mo_command"),
1717         m_protection_base(*this, "protection_base"),
1818         m_playfield_tilemap(*this, "playfield"),
19         m_alpha_tilemap(*this, "alpha") { }
19         m_alpha_tilemap(*this, "alpha"),
20         m_rle(*this, "rle") { }
2021
2122   UINT16          m_playfield_base;
2223
r24781r24782
2728
2829   required_device<tilemap_device> m_playfield_tilemap;
2930   required_device<tilemap_device> m_alpha_tilemap;
31   required_device<atari_rle_objects_device> m_rle;
3032
3133   UINT16          m_current_control;
3234   UINT8           m_playfield_tile_bank;
r24781r24782
3739   UINT16          m_last_write;
3840   UINT16          m_last_write_offset;
3941
40   device_t *      m_rle;
4142   virtual void update_interrupts();
4243   virtual void scanline_update(screen_device &screen, int scanline);
4344   DECLARE_READ32_MEMBER(special_port2_r);
r24781r24782
5859   DECLARE_MACHINE_RESET(atarigx2);
5960   DECLARE_VIDEO_START(atarigx2);
6061   UINT32 screen_update_atarigx2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
61   void screen_eof_atarigx2(screen_device &screen, bool state);
6262   DECLARE_WRITE16_MEMBER( atarigx2_mo_control_w );
6363};
trunk/src/mame/includes/atarig1.h
r24781r24782
1717         m_jsa(*this, "jsa"),
1818         m_playfield_tilemap(*this, "playfield"),
1919         m_alpha_tilemap(*this, "alpha"),
20         m_rle(*this, "rle"),
2021         m_mo_command(*this, "mo_command") { }
2122
2223   required_device<cpu_device> m_maincpu;
2324   required_device<atari_jsa_ii_device> m_jsa;
2425   required_device<tilemap_device> m_playfield_tilemap;
2526   required_device<tilemap_device> m_alpha_tilemap;
27   required_device<atari_rle_objects_device> m_rle;
2628
2729   bool            m_is_pitfight;
2830
r24781r24782
4042   UINT16          m_playfield_xscroll;
4143   UINT16          m_playfield_yscroll;
4244
43   device_t *      m_rle;
4445   virtual void device_post_load();
4546   virtual void update_interrupts();
4647   virtual void scanline_update(screen_device &screen, int scanline);
r24781r24782
6465   DECLARE_MACHINE_RESET(atarig1);
6566   DECLARE_VIDEO_START(atarig1);
6667   UINT32 screen_update_atarig1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
67   void screen_eof_atarig1(screen_device &screen, bool state);
6868private:
6969   void init_common(offs_t slapstic_base, int slapstic, bool is_pitfight);
7070   void pitfightb_cheap_slapstic_init();
trunk/src/mame/video/atarigx2.c
r24781r24782
7070   /* blend the playfields and free the temporary one */
7171   blend_gfx(0, 2, 0x0f, 0x30);
7272
73   /* initialize the motion objects */
74   m_rle = machine().device("rle");
75
7673   /* save states */
7774   save_item(NAME(m_current_control));
7875   save_item(NAME(m_playfield_tile_bank));
r24781r24782
182179
183180   /* copy the motion objects on top */
184181   {
185      bitmap_ind16 *mo_bitmap = atarirle_get_vram(m_rle, 0);
182      bitmap_ind16 &mo_bitmap = m_rle->vram(0);
186183      int left    = cliprect.min_x;
187184      int top     = cliprect.min_y;
188185      int right   = cliprect.max_x + 1;
r24781r24782
193190      for (y = top; y < bottom; y++)
194191      {
195192         UINT16 *pf = &bitmap.pix16(y);
196         UINT16 *mo = &mo_bitmap->pix16(y);
193         UINT16 *mo = &mo_bitmap.pix16(y);
197194         UINT8 *pri = &priority_bitmap.pix8(y);
198195         for (x = left; x < right; x++)
199196            if (mo[x] && (mo[x] >> ATARIRLE_PRIORITY_SHIFT) >= pri[x])
r24781r24782
205202   m_alpha_tilemap->draw(screen, bitmap, cliprect, 0, 0);
206203   return 0;
207204}
208
209void atarigx2_state::screen_eof_atarigx2(screen_device &screen, bool state)
210{
211   // rising edge
212   if (state)
213   {
214      atarirle_eof(m_rle);
215   }
216}
trunk/src/mame/video/atarig1.c
r24781r24782
4747   /* blend the playfields and free the temporary one */
4848   blend_gfx(0, 2, 0x0f, 0x10);
4949
50   /* initialize the motion objects */
51   m_rle = machine().device("rle");
52
5350   /* reset statics */
5451   m_pfscroll_xoffset = m_is_pitfight ? 2 : 0;
5552
r24781r24782
134131   m_playfield_tilemap->draw(screen, bitmap, cliprect, 0, 0);
135132
136133   /* copy the motion objects on top */
137   copybitmap_trans(bitmap, *atarirle_get_vram(m_rle, 0), 0, 0, 0, 0, cliprect, 0);
134   copybitmap_trans(bitmap, m_rle->vram(0), 0, 0, 0, 0, cliprect, 0);
138135
139136   /* add the alpha on top */
140137   m_alpha_tilemap->draw(screen, bitmap, cliprect, 0, 0);
141138   return 0;
142139}
143
144void atarig1_state::screen_eof_atarig1(screen_device &screen, bool state)
145{
146   // rising edge
147   if (state)
148   {
149      atarirle_eof(m_rle);
150   }
151}
trunk/src/mame/video/atarirle.c
r24781r24782
2020
2121#include "emu.h"
2222#include "atarirle.h"
23#include "devlegcy.h"
2423
2524
26/***************************************************************************
27    TYPES & STRUCTURES
28***************************************************************************/
25//**************************************************************************
26//  CONSTANTS
27//**************************************************************************
2928
30/* internal structure containing a word index, shift and mask */
31struct atarirle_mask
32{
33   int             word;               /* word index */
34   int             shift;              /* shift amount */
35   int             mask;               /* final mask */
36};
29const device_type ATARI_RLE_OBJECTS = &device_creator<atari_rle_objects_device>;
3730
38/* internal structure for sorting the motion objects */
39struct mo_sort_entry
40{
41   mo_sort_entry * next;
42   int             entry;
43};
44
45/* internal structure describing each object in the ROMs */
46struct 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 */
58struct 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
10931enum { atarirle_hilite_index = -1 };
11032
11133
11234
113/***************************************************************************
114    STATIC VARIABLES
115***************************************************************************/
35//**************************************************************************
36//  INLINE FUNCTIONS
37//**************************************************************************
11638
117static UINT8 rle_bpp[8];
118static 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//-------------------------------------------------
11945
120
121
122/***************************************************************************
123    STATIC FUNCTION DECLARATIONS
124***************************************************************************/
125
126static void build_rle_tables(running_machine &machine);
127static int count_objects(const UINT16 *base, int length);
128static void prescan_rle(const atarirle_data *mo, int which);
129static void sort_and_render(running_machine &machine, atarirle_data *mo);
130static void compute_checksum(atarirle_data *mo);
131static 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);
133static 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);
136static 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
146INLINE atarirle_data *get_safe_token(device_t *device)
46inline int atari_rle_objects_device::round_to_powerof2(int value)
14747{
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
162INLINE int compute_log(int value)
163{
16448   int log = 0;
16549
16650   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
182INLINE int round_to_powerof2(int value)
183{
184   int log = 0;
185
186   if (value == 0)
18751      return 1;
18852   while ((value >>= 1) != 0)
18953      log++;
r24781r24782
19155}
19256
19357
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---------------------------------------------------------------*/
19958
200#ifdef UNUSED_FUNCTION
201INLINE int collapse_bits(int value, int mask)
202{
203   int testmask, ormask;
204   int result = 0;
59//**************************************************************************
60//  CORE DEVICE IMPLEMENTATION
61//**************************************************************************
20562
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//-------------------------------------------------
21666
217/*---------------------------------------------------------------
218    convert_mask: Converts a 4-word mask into a word index,
219    shift, and adjusted mask. Returns 0 if invalid.
220---------------------------------------------------------------*/
221
222INLINE int convert_mask(const atarirle_entry *input, atarirle_mask *result)
67atari_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)
22370{
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;
25471}
25572
25673
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
268static 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
371const device_type ATARIRLE = &device_creator<atarirle_device>;
372
373atarirle_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
37974//-------------------------------------------------
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
38377//-------------------------------------------------
38478
385void atarirle_device::device_config_complete()
79void atari_rle_objects_device::static_set_config(device_t &device, const atari_rle_objects_config &config)
38680{
81   atari_rle_objects_device &target = downcast<atari_rle_objects_device &>(device);
82   static_cast<atari_rle_objects_config &>(target) = config;
38783}
38884
85
38986//-------------------------------------------------
390//  device_start - device-specific startup
87//  control_write: Write handler for MO control
88//   bits.
39189//-------------------------------------------------
39290
393void atarirle_device::device_start()
91WRITE8_MEMBER(atari_rle_objects_device::control_write)
39492{
395   DEVICE_START_NAME( atarirle )(this);
396}
397
398
399
400/*---------------------------------------------------------------
401    atarirle_control_w: Write handler for MO control bits.
402---------------------------------------------------------------*/
403
404void 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
41193//logerror("atarirle_control_w(%d)\n", bits);
41294
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)
41598      return;
41699
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);
419103
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)
422106   {
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;
428111      if (scanline < cliprect.max_y)
429112         cliprect.max_y = scanline;
430113
431114//logerror("  partial erase %d-%d (frame %d)\n", cliprect.min_y, cliprect.max_y, (oldbits & ATARIRLE_CONTROL_FRAME) >> 2);
432115
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);
437120   }
438121
439   /* update the bits */
440   mo->control_bits = bits;
122   // update the bits
123   m_control_bits = data;
441124
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)
444127   {
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();
449132   }
450133
451   /* remember where we left off */
452   mo->partial_scanline = scanline;
134   // remember where we left off
135   m_partial_scanline = scanline;
453136}
454137
455138
139//-------------------------------------------------
140//  command_write: Write handler for MO command
141//   bits.
142//-------------------------------------------------
456143
457/*---------------------------------------------------------------
458    atarirle_command_w: Write handler for MO command bits.
459---------------------------------------------------------------*/
460
461void atarirle_command_w(device_t *device, UINT8 command)
144WRITE8_MEMBER(atari_rle_objects_device::command_write)
462145{
463   atarirle_data *mo = get_safe_token(device);
464   mo->command = command;
146   m_command = data;
465147}
466148
467149
150//-------------------------------------------------
151//  vblank_callback: VBLANK callback.
152//-------------------------------------------------
468153
469/*---------------------------------------------------------------
470    atarirle_eof: Flush remaining changes.
471---------------------------------------------------------------*/
472
473void atarirle_eof(device_t *device)
154void atari_rle_objects_device::vblank_callback(screen_device &screen, bool state)
474155{
156   // on the rising edge, if the erase flag is set, erase to the end of the screen
157   if (state)
475158   {
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)
480160      {
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;
482165
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);
486167
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);
493172      }
494173
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;
497176   }
498177}
499178
500179
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//-------------------------------------------------
501186
502/*---------------------------------------------------------------
503    atarirle_spriteram_r: Read handler for the spriteram.
504---------------------------------------------------------------*/
505
506READ16_DEVICE_HANDLER( atarirle_spriteram_r )
187void atari_rle_objects_device::device_start()
507188{
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);
509194
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));
512197
198   // build and allocate the generic tables
199   build_rle_tables();
513200
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);
514211
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;
518217
519WRITE16_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();
524222
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   }
527230
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   }
532241
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);
533246
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);
534252
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   }
538261
539READ32_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));
545273}
546274
547275
276//-------------------------------------------------
277//  device_reset: Reset the state of the device.
278//-------------------------------------------------
548279
549/*---------------------------------------------------------------
550    atarirle_spriteram32_w: Write handler for the spriteram.
551---------------------------------------------------------------*/
552
553WRITE32_DEVICE_HANDLER( atarirle_spriteram32_w )
280void atari_rle_objects_device::device_reset()
554281{
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;
567283}
568284
569285
286//-------------------------------------------------
287//  build_rle_tables: Builds internal table for
288//  RLE mapping.
289//-------------------------------------------------
570290
571/*---------------------------------------------------------------
572    atarirle_get_vram: Return the VRAM bitmap.
573---------------------------------------------------------------*/
574
575bitmap_ind16 *atarirle_get_vram(device_t *device, int idx)
291void atari_rle_objects_device::build_rle_tables()
576292{
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];
581299
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;
582304
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);
583308
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);
587312
588static 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++)
618315   {
619316      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);
621318      else
622         rle_table[1][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f);
319         m_rle_table[1][i] = (((i & 0xe0) + 0x20) << 3) | (i & 0x1f);
623320   }
624321
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);
628325
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++)
631328   {
632329      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);
634331      else
635         rle_table[4][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f);
332         m_rle_table[4][i] = (((i & 0xc0) + 0x40) << 2) | (i & 0x3f);
636333   }
637334}
638335
639336
640337
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//-------------------------------------------------
645342
646int count_objects(const UINT16 *base, int length)
343int atari_rle_objects_device::count_objects()
647344{
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)
653348   {
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)
657352         lowest_address = offset;
658353   }
659354
660   /* that determines how many objects */
355   // that determines how many objects
661356   return lowest_address / 4;
662357}
663358
664359
360//-------------------------------------------------
361//  prescan_rle: Prescans an RLE object, computing the
362//  width, height, and other goodies.
363//-------------------------------------------------
665364
666/*---------------------------------------------------------------
667    prescan_rle: Prescans an RLE object, computing the
668    width, height, and other goodies.
669---------------------------------------------------------------*/
670
671static void prescan_rle(const atarirle_data *mo, int which)
365void atari_rle_objects_device::prescan_rle(int which)
672366{
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];
678368
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];
682374
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];
687379
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];
691383
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)
694386   {
695      memset(rledata, 0, sizeof(*rledata));
387      info.data = NULL;
696388      return;
697389   }
698390
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;
700394   for (height = 0; height < 1024 && base < end; height++)
701395   {
702396      int tempwidth = 0;
703397      int entry_count = *base++;
704398
705      /* if the high bit is set, assume we're inverted */
399      // if the high bit is set, assume we're inverted
706400      if (entry_count & 0x8000)
707401      {
708402         entry_count ^= 0xffff;
709403
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
711405         base[-1] ^= 0xffff;
712406      }
713407
714      /* we're done when we hit 0 */
408      // we're done when we hit 0
715409      if (entry_count == 0)
716410         break;
717411
718      /* track the width */
412      // track the width
719413      while (entry_count-- && base < end)
720414      {
721415         int word = *base++;
722416         int count/*, value*/;
723417
724         /* decode the low byte first */
418         // decode the low byte first
725419         count = table[word & 0xff];
726420         //value = count & 0xff;
727421         tempwidth += count >> 8;
728422
729         /* decode the upper byte second */
423         // decode the upper byte second
730424         count = table[word >> 8];
731425         //value = count & 0xff;
732426         tempwidth += count >> 8;
733427      }
734428
735      /* only remember the max */
429      // only remember the max
736430      if (tempwidth > width)
737431         width = tempwidth;
738432   }
739433
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;
743437}
744438
745439
746440
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//-------------------------------------------------
750445
751static void compute_checksum(atarirle_data *mo)
446void atari_rle_objects_device::compute_checksum()
752447{
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;
757450   if (reqsums > 256)
758451      reqsums = 256;
759452
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]);
775456}
776457
777458
778/*---------------------------------------------------------------
779    sort_and_render: Render all motion objects in order.
780---------------------------------------------------------------*/
781459
782static 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//-------------------------------------------------
791464
792atarirle_entry *hilite = NULL;
793int count = 0;
465void 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   };
794473
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++)
798478   {
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];
803483   }
804484
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;
488int hilite = -1;
489   for (int order = 1; order < 256; order++)
490      for (sort_entry_t *current = list_head[order]; current != NULL; current = current->next)
809491      {
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);
811495
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)
819498         {
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);
826505
827506if (count++ == atarirle_hilite_index)
828   hilite = obj;
507   hilite = current->entry;
829508
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;
835514
836            /* merge priority and color */
515            // merge priority and color
837516            color = (color << 4) | (priority << ATARIRLE_PRIORITY_SHIFT);
838517
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);
844521         }
845522      }
846523
847if (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);
939fprintf(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);
945526}
946}
947527
948528
529//-------------------------------------------------
530//  draw_rle: Render a single RLE-compressed motion
531//  object.
532//-------------------------------------------------
949533
950/*---------------------------------------------------------------
951    draw_rle: Render a single RLE-compressed motion
952    object.
953---------------------------------------------------------------*/
954
955void 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)
534void 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)
957535{
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;
962540
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
964546   if (hflip)
965      scaled_xoffs = ((xscale * info->width) >> 12) - scaled_xoffs;
547      scaled_xoffs = ((xscale * info.width) >> 12) - scaled_xoffs;
966548
967//if (clip.min_y == Machine->primary_screen->visible_area().min_y)
549//if (clip.min_y == m_screen->visible_area().min_y)
968550//logerror("   Sprite: c=%04X l=%04X h=%d X=%4d (o=%4d w=%3d) Y=%4d (o=%4d h=%d) s=%04X\n",
969551//  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);
972554
973   /* adjust for the x and y offsets */
555   // adjust for the x and y offsets
974556   x -= scaled_xoffs;
975557   y -= scaled_yoffs;
976558
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;
983561   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);
985563   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);
987565}
988566
989567
990568
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//-------------------------------------------------
995573
996void 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)
574void 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)
999575{
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;
1012579   if (scaled_width == 0) scaled_width = 1;
1013580   if (scaled_height == 0) scaled_height = 1;
1014581
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;
1021588
1022   /* left edge clip */
589   // left edge clip
590   int pixels_to_skip = 0;
591   bool xclipped = false;
1023592   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;
1025594   if (sx > clip.max_x)
1026595      return;
1027596
1028   /* right edge clip */
597   // right edge clip
1029598   if (ex > clip.max_x)
1030      ex = clip.max_x, xclipped = 1;
599      ex = clip.max_x, xclipped = true;
1031600   else if (ex < clip.min_x)
1032601      return;
1033602
1034   /* top edge clip */
603   // top edge clip
1035604   if (sy < clip.min_y)
1036605   {
1037606      sourcey += (clip.min_y - sy) * dy;
r24781r24782
1040609   else if (sy > clip.max_y)
1041610      return;
1042611
1043   /* bottom edge clip */
612   // bottom edge clip
1044613   if (ey > clip.max_y)
1045614      ey = clip.max_y;
1046615   else if (ey < clip.min_y)
1047616      return;
1048617
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)
1051623   {
1052624      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;
1056626
1057      /* loop until we hit the row we're on */
627      // loop until we hit the row we're on
1058628      for ( ; current_row != (sourcey >> 16); current_row++)
1059629         row_start += 1 + *row_start;
1060630
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++;
1064634
1065      /* non-clipped case */
635      // non-clipped case
1066636      if (!xclipped)
1067637      {
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++)
1070640         {
641            // decode the low byte first
1071642            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;
1077645            rle_end += (count & 0xff00) << 8;
1078646
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
1080648            if (value)
1081649            {
1082650               value += palette;
r24781r24782
1089657                  dest++, sourcex += dx;
1090658            }
1091659
1092            /* decode the upper byte second */
660            // decode the upper byte second
1093661            count = table[word >> 8];
1094662            value = count & 0xff;
1095663            rle_end += (count & 0xff00) << 8;
1096664
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
1098666            if (value)
1099667            {
1100668               value += palette;
r24781r24782
1109677         }
1110678      }
1111679
1112      /* clipped case */
680      // clipped case
1113681      else
1114682      {
1115683         const UINT16 *end = &bitmap.pix16(y, ex);
1116684         int to_be_skipped = pixels_to_skip;
1117685
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++)
1120688         {
689            // decode the low byte first
1121690            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;
1127693            rle_end += (count & 0xff00) << 8;
1128694
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
1130696            if (to_be_skipped)
1131697            {
1132698               while (to_be_skipped && sourcex < rle_end)
r24781r24782
1146712            }
1147713
1148714         next3:
1149            /* decode the upper byte second */
715            // decode the upper byte second
1150716            count = table[word >> 8];
1151717            value = count & 0xff;
1152718            rle_end += (count & 0xff00) << 8;
1153719
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
1155721            if (to_be_skipped)
1156722            {
1157723               while (to_be_skipped && sourcex < rle_end)
r24781r24782
1178744
1179745
1180746
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//-------------------------------------------------
1185752
1186void 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)
753void 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)
1189754{
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;
1201758   if (scaled_width == 0) scaled_width = 1;
1202759   if (scaled_height == 0) scaled_height = 1;
1203760
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;
1210767
1211   /* left edge clip */
768   // left edge clip
769   int pixels_to_skip = 0;
770   bool xclipped = false;
1212771   if (sx < clip.min_x)
1213      sx = clip.min_x, xclipped = 1;
772      sx = clip.min_x, xclipped = true;
1214773   if (sx > clip.max_x)
1215774      return;
1216775
1217   /* right edge clip */
776   // right edge clip
1218777   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;
1220779   else if (ex < clip.min_x)
1221780      return;
1222781
1223   /* top edge clip */
782   // top edge clip
1224783   if (sy < clip.min_y)
1225784   {
1226785      sourcey += (clip.min_y - sy) * dy;
r24781r24782
1229788   else if (sy > clip.max_y)
1230789      return;
1231790
1232   /* bottom edge clip */
791   // bottom edge clip
1233792   if (ey > clip.max_y)
1234793      ey = clip.max_y;
1235794   else if (ey < clip.min_y)
1236795      return;
1237796
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)
1240802   {
1241803      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;
1245805
1246      /* loop until we hit the row we're on */
806      // loop until we hit the row we're on
1247807      for ( ; current_row != (sourcey >> 16); current_row++)
1248808         row_start += 1 + *row_start;
1249809
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++;
1253813
1254      /* non-clipped case */
814      // non-clipped case
1255815      if (!xclipped)
1256816      {
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++)
1259819         {
820            // decode the low byte first
1260821            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;
1266824            rle_end += (count & 0xff00) << 8;
1267825
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
1269827            if (value)
1270828            {
1271829               value += palette;
r24781r24782
1278836                  dest--, sourcex += dx;
1279837            }
1280838
1281            /* decode the upper byte second */
839            // decode the upper byte second
1282840            count = table[word >> 8];
1283841            value = count & 0xff;
1284842            rle_end += (count & 0xff00) << 8;
1285843
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
1287845            if (value)
1288846            {
1289847               value += palette;
r24781r24782
1298856         }
1299857      }
1300858
1301      /* clipped case */
859      // clipped case
1302860      else
1303861      {
1304862         const UINT16 *start = &bitmap.pix16(y, sx);
1305863         int to_be_skipped = pixels_to_skip;
1306864
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++)
1309867         {
868            // decode the low byte first
1310869            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;
1316872            rle_end += (count & 0xff00) << 8;
1317873
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
1319875            if (to_be_skipped)
1320876            {
1321877               while (to_be_skipped && sourcex < rle_end)
r24781r24782
1335891            }
1336892
1337893         next3:
1338            /* decode the upper byte second */
894            // decode the upper byte second
1339895            count = table[word >> 8];
1340896            value = count & 0xff;
1341897            rle_end += (count & 0xff00) << 8;
1342898
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
1344900            if (to_be_skipped)
1345901            {
1346902               while (to_be_skipped && sourcex < rle_end)
r24781r24782
1366922}
1367923
1368924
925//-------------------------------------------------
926//  hilite_object: Hilight an object by drawing a
927//   flashing box around it
928//-------------------------------------------------
929
930void 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
1033atari_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
1045bool 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
13691080/***************************************************************************
13701081
13711082    The mapping of the bits from the PROMs is like this:
trunk/src/mame/video/atarirle.h
r24781r24782
55    Common RLE-based motion object management functions for early 90's
66    Atari raster games.
77
8****************************************************************************
9
10    Copyright Aaron Giles
11    All rights reserved.
12
13    Redistribution and use in source and binary forms, with or without
14    modification, are permitted provided that the following conditions are
15    met:
16
17        * Redistributions of source code must retain the above copyright
18          notice, this list of conditions and the following disclaimer.
19        * Redistributions in binary form must reproduce the above copyright
20          notice, this list of conditions and the following disclaimer in
21          the documentation and/or other materials provided with the
22          distribution.
23        * Neither the name 'MAME' nor the names of its contributors may be
24          used to endorse or promote products derived from this software
25          without specific prior written permission.
26
27    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
28    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
31    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37    POSSIBILITY OF SUCH DAMAGE.
38
839***************************************************************************/
940
1041#ifndef __ATARIRLE__
1142#define __ATARIRLE__
1243
1344
14/***************************************************************************
15    CONSTANTS
16***************************************************************************/
45//**************************************************************************
46//  DEVICE CONFIGURATION MACROS
47//**************************************************************************
1748
49#define MCFG_ATARIRLE_ADD(_tag, _interface) \
50   MCFG_DEVICE_ADD(_tag, ATARI_RLE_OBJECTS, 0) \
51   atari_rle_objects_device::static_set_config(*device, _interface);
52
53
54
55//**************************************************************************
56//  CONSTANTS
57//**************************************************************************
58
1859#define ATARIRLE_PRIORITY_SHIFT     12
1960#define ATARIRLE_BANK_SHIFT         15
2061#define ATARIRLE_PRIORITY_MASK      ((~0 << ATARIRLE_PRIORITY_SHIFT) & 0xffff)
r24781r24782
3071
3172
3273
33/***************************************************************************
34    TYPES & STRUCTURES
35***************************************************************************/
74//**************************************************************************
75//  TYPES & STRUCTURES
76//**************************************************************************
3677
37/* description for an eight-word mask */
38struct atarirle_entry
78// description of the motion objects
79struct atari_rle_objects_config
3980{
40   UINT16          data[8];
41};
81   struct entry { UINT16 data[8]; };
4282
43/* description of the motion objects */
44struct atarirle_desc
45{
46   const char *    region;             /* region where the GFX data lives */
47   UINT16          spriteramentries;   /* number of entries in sprite RAM */
48   UINT16          leftclip;           /* left clip coordinate */
49   UINT16          rightclip;          /* right clip coordinate */
83   UINT16          m_leftclip;           // left clip coordinate
84   UINT16          m_rightclip;          // right clip coordinate
85   UINT16          m_palettebase;        // base palette entry
5086
51   UINT16          palettebase;        /* base palette entry */
52   UINT16          maxcolors;          /* maximum number of colors */
53
54   atarirle_entry  codemask;           /* mask for the code index */
55   atarirle_entry  colormask;          /* mask for the color */
56   atarirle_entry  xposmask;           /* mask for the X position */
57   atarirle_entry  yposmask;           /* mask for the Y position */
58   atarirle_entry  scalemask;          /* mask for the scale factor */
59   atarirle_entry  hflipmask;          /* mask for the horizontal flip */
60   atarirle_entry  ordermask;          /* mask for the order */
61   atarirle_entry  prioritymask;       /* mask for the priority */
62   atarirle_entry  vrammask;           /* mask for the VRAM target */
87   entry         m_code_entry;           // mask for the code index
88   entry         m_color_entry;          // mask for the color
89   entry         m_xpos_entry;           // mask for the X position
90   entry         m_ypos_entry;           // mask for the Y position
91   entry         m_scale_entry;          // mask for the scale factor
92   entry         m_hflip_entry;          // mask for the horizontal flip
93   entry         m_order_entry;          // mask for the order
94   entry         m_priority_entry;       // mask for the priority
95   entry         m_vram_entry;           // mask for the VRAM target
6396};
6497
6598
99// ======================> atari_rle_objects_device
66100
67/***************************************************************************
68    FUNCTION PROTOTYPES
69***************************************************************************/
101// device type definition
102extern const device_type ATARI_RLE_OBJECTS;
70103
71class atarirle_device : public device_t
104class atari_rle_objects_device : public device_t,
105                         public device_video_interface,
106                         public atari_rle_objects_config
72107{
73108public:
74   atarirle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
75   ~atarirle_device() { global_free(m_token); }
109   // construction/destruction
110   atari_rle_objects_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
76111
77   // access to legacy token
78   void *token() const { assert(m_token != NULL); return m_token; }
112   // static configuration helpers
113   static void static_set_config(device_t &device, const atari_rle_objects_config &config);
114   
115   // control handlers
116   DECLARE_WRITE8_MEMBER(control_write);
117   DECLARE_WRITE8_MEMBER(command_write);
118
119   // render helpers
120   void vblank_callback(screen_device &screen, bool state);
121   
122   // getters
123   bitmap_ind16 &vram(int idx) { return m_vram[idx][(m_control_bits & ATARIRLE_CONTROL_FRAME) >> 2]; }
124
79125protected:
80126   // device-level overrides
81   virtual void device_config_complete();
82127   virtual void device_start();
128   virtual void device_reset();
129
83130private:
84   // internal state
85   void *m_token;
86};
131   // a sprite parameter, which is a word index + shift + mask
132   class sprite_parameter
133   {
134   public:
135      sprite_parameter();
136      bool set(const atari_rle_objects_config::entry &input) { return set(input.data); }
137      bool set(const UINT16 input[8]);
138      UINT16 extract(memory_array &array, int offset) const { return (array.read(offset + m_word) >> m_shift) & m_mask; }
139      UINT16 shift() const { return m_shift; }
140      UINT16 mask() const { return m_mask; }
87141
88extern const device_type ATARIRLE;
142   private:
143      UINT16         m_word;            // word index
144      UINT16          m_shift;         // shift amount
145      UINT16          m_mask;            // final mask
146   };
89147
90#define MCFG_ATARIRLE_ADD(_tag, _interface) \
91   MCFG_DEVICE_ADD(_tag, ATARIRLE, 0) \
92   MCFG_DEVICE_CONFIG(_interface)
148   // internal structure describing each object in the ROMs
149   struct object_info
150   {
151      INT16           width;
152      INT16           height;
153      INT16           xoffs;
154      INT16           yoffs;
155      UINT8           bpp;
156      const UINT16 *  table;
157      const UINT16 *  data;
158   };
159   
160   // internal helpers
161   inline int round_to_powerof2(int value);
162   void build_rle_tables();
163   int count_objects();
164   void prescan_rle(int which);
165   void compute_checksum();
166   void sort_and_render();
167   void draw_rle(bitmap_ind16 &bitmap, const rectangle &clip, int code, int color, int hflip, int vflip, int x, int y, int xscale, int yscale);
168   void draw_rle_zoom(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, UINT32 palette, int sx, int sy, int scalex, int scaley);
169   void draw_rle_zoom_hflip(bitmap_ind16 &bitmap, const rectangle &clip, const object_info &info, UINT32 palette, int sx, int sy, int scalex, int scaley);
170   void hilite_object(bitmap_ind16 &bitmap, int hilite);
93171
172   // derived state
173   int             m_bitmapwidth;        // width of the full playfield bitmap
174   int             m_bitmapheight;       // height of the full playfield bitmap
175   int             m_bitmapxmask;        // x coordinate mask for the playfield bitmap
176   int             m_bitmapymask;        // y coordinate mask for the playfield bitmap
177   rectangle       m_cliprect;           // clipping rectangle
94178
95/* control handlers */
96void atarirle_control_w(device_t *device, UINT8 bits);
97void atarirle_command_w(device_t *device, UINT8 command);
179   // masks
180   sprite_parameter      m_codemask;           // mask for the code index
181   sprite_parameter      m_colormask;          // mask for the color
182   sprite_parameter      m_xposmask;           // mask for the X position
183   sprite_parameter      m_yposmask;           // mask for the Y position
184   sprite_parameter      m_scalemask;          // mask for the scale factor
185   sprite_parameter      m_hflipmask;          // mask for the horizontal flip
186   sprite_parameter      m_ordermask;          // mask for the order
187   sprite_parameter      m_prioritymask;       // mask for the priority
188   sprite_parameter      m_vrammask;           // mask for the VRAM target
98189
99/* read/write handlers */
100DECLARE_READ16_DEVICE_HANDLER( atarirle_spriteram_r );
101DECLARE_READ32_DEVICE_HANDLER( atarirle_spriteram32_r );
102DECLARE_WRITE16_DEVICE_HANDLER( atarirle_spriteram_w );
103DECLARE_WRITE32_DEVICE_HANDLER( atarirle_spriteram32_w );
190   // ROM information
191   const UINT16 *     m_rombase;            // pointer to the base of the GFX ROM
192   int                m_romlength;          // length of the GFX ROM
193   int                m_objectcount;        // number of objects in the ROM
194   dynamic_array<object_info> m_info;        // list of info records
104195
105/* render helpers */
106void atarirle_eof(device_t *device);
107bitmap_ind16 *atarirle_get_vram(device_t *device, int idx);
196   // rendering state
197   bitmap_ind16      m_vram[2][2];         // pointers to VRAM bitmaps and backbuffers
198   int                m_partial_scanline;   // partial update scanline
108199
200   // control state
201   UINT8              m_control_bits;       // current control bits
202   UINT8              m_command;            // current command
203   UINT16             m_checksums[256];     // checksums for each 0x40000 bytes
204   memory_array      m_ram;
205
206   // tables
207   UINT8            m_rle_bpp[8];
208   UINT16 *         m_rle_table[8];
209   UINT16            m_rle_table_data[0x500];
210};
211
212
213
109214#endif
trunk/src/mame/video/atarig42.c
r24781r24782
7070   /* blend the playfields and free the temporary one */
7171   blend_gfx(0, 2, 0x0f, 0x30);
7272
73   /* initialize the motion objects */
74   m_rle = machine().device("rle");
75
7673   /* save states */
7774   save_item(NAME(m_current_control));
7875   save_item(NAME(m_playfield_tile_bank));
r24781r24782
174171
175172   /* copy the motion objects on top */
176173   {
177      bitmap_ind16 *mo_bitmap = atarirle_get_vram(m_rle, 0);
174      bitmap_ind16 &mo_bitmap = m_rle->vram(0);
178175      int left    = cliprect.min_x;
179176      int top     = cliprect.min_y;
180177      int right   = cliprect.max_x + 1;
r24781r24782
185182      for (y = top; y < bottom; y++)
186183      {
187184         UINT16 *pf = &bitmap.pix16(y);
188         UINT16 *mo = &mo_bitmap->pix16(y);
185         UINT16 *mo = &mo_bitmap.pix16(y);
189186         UINT8 *pri = &priority_bitmap.pix8(y);
190187         for (x = left; x < right; x++)
191188            if (mo[x])
r24781r24782
202199   m_alpha_tilemap->draw(screen, bitmap, cliprect, 0, 0);
203200   return 0;
204201}
205
206void atarig42_state::screen_eof_atarig42(screen_device &screen, bool state)
207{
208   // rising edge
209   if (state)
210   {
211      atarirle_eof(m_rle);
212   }
213}
trunk/src/mame/video/atarigt.c
r24781r24782
8282   /* blend the playfields and free the temporary one */
8383   blend_gfx(0, 2, 0x0f, 0x30);
8484
85   /* initialize the motion objects */
86   m_rle = machine().device("rle");
87
8885   /* allocate temp bitmaps */
8986   width = m_screen->width();
9087   height = m_screen->height();
r24781r24782
499496
500497UINT32 atarigt_state::screen_update_atarigt(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
501498{
502   bitmap_ind16 *mo_bitmap = atarirle_get_vram(m_rle, 0);
503   bitmap_ind16 *tm_bitmap = atarirle_get_vram(m_rle, 1);
499   bitmap_ind16 &mo_bitmap = m_rle->vram(0);
500   bitmap_ind16 &tm_bitmap = m_rle->vram(1);
504501   UINT16 *cram, *tram;
505502   int color_latch;
506503   UINT32 *mram;
r24781r24782
523520   {
524521      UINT16 *an = &m_an_bitmap->pix16(y);
525522      UINT16 *pf = &m_pf_bitmap->pix16(y);
526      UINT16 *mo = &mo_bitmap->pix16(y);
527      UINT16 *tm = &tm_bitmap->pix16(y);
523      UINT16 *mo = &mo_bitmap.pix16(y);
524      UINT16 *tm = &tm_bitmap.pix16(y);
528525      UINT32 *dst = &bitmap.pix32(y);
529526
530527      /* Primal Rage: no TRAM, slightly different priorities */
r24781r24782
621618   }
622619   return 0;
623620}
624
625void atarigt_state::screen_eof_atarigt(screen_device &screen, bool state)
626{
627   // rising edge
628   if (state)
629   {
630      atarirle_eof(m_rle);
631   }
632}
trunk/src/emu/memarray.c
r0r24782
1/***************************************************************************
2
3    memarray.c
4
5    Generic memory array accessor helper.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#include "emu.h"
41
42
43//**************************************************************************
44//  MEMORY ARRAY HELPER
45//**************************************************************************
46
47//-------------------------------------------------
48//  memory_array - constructor
49//-------------------------------------------------
50
51memory_array::memory_array()
52   : m_base(NULL),
53      m_bytes(0),
54      m_membits(0),
55      m_bytes_per_entry(0)
56{
57}
58
59
60//-------------------------------------------------
61//  set - configure the parameters
62//-------------------------------------------------
63
64void memory_array::set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe)
65{
66   // validate inputs
67   assert(base != NULL);
68   assert(bytes > 0);
69   assert(membits == 8 || membits == 16 || membits == 32 || membits == 64);
70   assert(bpe == 1 || bpe == 2 || bpe == 4);
71
72   // populate direct data
73   m_base = base;
74   m_bytes = bytes;
75   m_membits = membits;
76   m_endianness = endianness;
77   m_bytes_per_entry = bpe;
78
79   // derive data
80   switch (bpe*1000 + membits*10 + endianness)
81   {
82      case 1*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &memory_array::read8_from_8;       m_writer = &memory_array::write8_to_8;        break;
83      case 1*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &memory_array::read8_from_8;       m_writer = &memory_array::write8_to_8;        break;
84      case 1*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read8_from_16le;    m_writer = &memory_array::write8_to_16le;     break;
85      case 1*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read8_from_16be;    m_writer = &memory_array::write8_to_16be;     break;
86      case 1*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read8_from_32le;    m_writer = &memory_array::write8_to_32le;     break;
87      case 1*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read8_from_32be;    m_writer = &memory_array::write8_to_32be;     break;
88      case 1*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read8_from_64le;    m_writer = &memory_array::write8_to_64le;     break;
89      case 1*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read8_from_64be;    m_writer = &memory_array::write8_to_64be;     break;
90
91      case 2*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &memory_array::read16_from_8le;    m_writer = &memory_array::write16_to_8le;     break;
92      case 2*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &memory_array::read16_from_8be;    m_writer = &memory_array::write16_to_8be;     break;
93      case 2*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read16_from_16;     m_writer = &memory_array::write16_to_16;      break;
94      case 2*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read16_from_16;     m_writer = &memory_array::write16_to_16;      break;
95      case 2*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read16_from_32le;   m_writer = &memory_array::write16_to_32le;    break;
96      case 2*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read16_from_32be;   m_writer = &memory_array::write16_to_32be;    break;
97      case 2*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read16_from_64le;   m_writer = &memory_array::write16_to_64le;    break;
98      case 2*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read16_from_64be;   m_writer = &memory_array::write16_to_64be;    break;
99
100      case 4*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &memory_array::read32_from_8le;    m_writer = &memory_array::write32_to_8le;     break;
101      case 4*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &memory_array::read32_from_8be;    m_writer = &memory_array::write32_to_8be;     break;
102      case 4*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read32_from_16le;   m_writer = &memory_array::write32_to_16le;    break;
103      case 4*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read32_from_16be;   m_writer = &memory_array::write32_to_16be;    break;
104      case 4*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read32_from_32;     m_writer = &memory_array::write32_to_32;      break;
105      case 4*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read32_from_32;     m_writer = &memory_array::write32_to_32;      break;
106      case 4*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &memory_array::read32_from_64le;   m_writer = &memory_array::write32_to_64le;    break;
107      case 4*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &memory_array::read32_from_64be;   m_writer = &memory_array::write32_to_64be;    break;
108
109      default:    throw emu_fatalerror("Illegal memory bits/bus width combo in memory_array");
110   }
111}
112
113
114//-------------------------------------------------
115//  set - additional setter variants
116//-------------------------------------------------
117
118void memory_array::set(const address_space &space, void *base, UINT32 bytes, int bpe)
119{
120   set(base, bytes, space.data_width(), space.endianness(), bpe);
121}
122
123void memory_array::set(const memory_share &share, int bpe)
124{
125   set(share.ptr(), share.bytes(), share.width(), share.endianness(), bpe);
126}
127
128void memory_array::set(const memory_array &helper)
129{
130   set(helper.base(), helper.bytes(), helper.membits(), helper.endianness(), helper.bytes_per_entry());
131}
132
133
134//-------------------------------------------------
135//  read8_from_*/write8_to_* - entry read/write
136//  heleprs for 1 byte-per-entry
137//-------------------------------------------------
138
139UINT32 memory_array::read8_from_8(int index) { return reinterpret_cast<UINT8 *>(m_base)[index]; }
140void memory_array::write8_to_8(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[index] = data; }
141
142UINT32 memory_array::read8_from_16le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_LE(index)]; }
143void memory_array::write8_to_16le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_LE(index)] = data; }
144UINT32 memory_array::read8_from_16be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_BE(index)]; }
145void memory_array::write8_to_16be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_BE(index)] = data; }
146
147UINT32 memory_array::read8_from_32le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)]; }
148void memory_array::write8_to_32le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
149UINT32 memory_array::read8_from_32be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)]; }
150void memory_array::write8_to_32be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
151
152UINT32 memory_array::read8_from_64le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)]; }
153void memory_array::write8_to_64le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)] = data; }
154UINT32 memory_array::read8_from_64be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)]; }
155void memory_array::write8_to_64be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)] = data; }
156
157
158//-------------------------------------------------
159//  read16_from_*/write16_to_* - entry read/write
160//  heleprs for 2 bytes-per-entry
161//-------------------------------------------------
162
163UINT32 memory_array::read16_from_8le(int index) { return read8_from_8(index*2) | (read8_from_8(index*2+1) << 8); }
164void memory_array::write16_to_8le(int index, UINT32 data) { write8_to_8(index*2, data); write8_to_8(index*2+1, data >> 8); }
165UINT32 memory_array::read16_from_8be(int index) { return (read8_from_8(index*2) << 8) | read8_from_8(index*2+1); }
166void memory_array::write16_to_8be(int index, UINT32 data) { write8_to_8(index*2, data >> 8); write8_to_8(index*2+1, data); }
167
168UINT32 memory_array::read16_from_16(int index) { return reinterpret_cast<UINT16 *>(m_base)[index]; }
169void memory_array::write16_to_16(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[index] = data; }
170
171UINT32 memory_array::read16_from_32le(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_LE(index)]; }
172void memory_array::write16_to_32le(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_LE(index)] = data; }
173UINT32 memory_array::read16_from_32be(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_BE(index)]; }
174void memory_array::write16_to_32be(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_BE(index)] = data; }
175
176UINT32 memory_array::read16_from_64le(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_LE(index)]; }
177void memory_array::write16_to_64le(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_LE(index)] = data; }
178UINT32 memory_array::read16_from_64be(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_BE(index)]; }
179void memory_array::write16_to_64be(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
180
181
182//-------------------------------------------------
183//  read32_from_*/write32_to_* - entry read/write
184//  heleprs for 4 bytes-per-entry
185//-------------------------------------------------
186
187UINT32 memory_array::read32_from_8le(int index) { return read16_from_8le(index*2) | (read16_from_8le(index*2+1) << 16); }
188void memory_array::write32_to_8le(int index, UINT32 data) { write16_to_8le(index*2, data); write16_to_8le(index*2+1, data >> 16); }
189UINT32 memory_array::read32_from_8be(int index) { return (read16_from_8be(index*2) << 16) | read16_from_8be(index*2+1); }
190void memory_array::write32_to_8be(int index, UINT32 data) { write16_to_8be(index*2, data >> 16); write16_to_8be(index*2+1, data); }
191
192UINT32 memory_array::read32_from_16le(int index) { return read16_from_16(index*2) | (read16_from_16(index*2+1) << 16); }
193void memory_array::write32_to_16le(int index, UINT32 data) { write16_to_16(index*2, data); write16_to_16(index*2+1, data >> 16); }
194UINT32 memory_array::read32_from_16be(int index) { return (read16_from_16(index*2) << 16) | read16_from_16(index*2+1); }
195void memory_array::write32_to_16be(int index, UINT32 data) { write16_to_16(index*2, data >> 16); write16_to_16(index*2+1, data); }
196
197UINT32 memory_array::read32_from_32(int index) { return reinterpret_cast<UINT32 *>(m_base)[index]; }
198void memory_array::write32_to_32(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[index] = data; }
199
200UINT32 memory_array::read32_from_64le(int index) { return reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_LE(index)]; }
201void memory_array::write32_to_64le(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_LE(index)] = data; }
202UINT32 memory_array::read32_from_64be(int index) { return reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_BE(index)]; }
203void memory_array::write32_to_64be(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_BE(index)] = data; }
Property changes on: trunk/src/emu/memarray.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/emu/memarray.h
r0r24782
1/***************************************************************************
2
3    memarray.h
4
5    Generic memory array accessor helper.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38****************************************************************************
39
40   A memory array in this case is an array of 8, 16, or 32-bit data
41   arranged logically.
42   
43   A memory array is stored in "natural" order, i.e., read/writes to it
44   are done via AM_RAM, or standard COMBINE_DATA, even if the width of
45   the CPU is different from the array width.
46   
47   The read_entry/write_entry functions serve to read/write entries of
48   the configured size regardless of the underlay width of the CPU's
49   memory system.
50
51***************************************************************************/
52
53#pragma once
54
55#ifndef __EMU_H__
56#error Dont include this file directly; include emu.h instead.
57#endif
58
59#ifndef __MEMARRAY_H__
60#define __MEMARRAY_H__
61
62
63//**************************************************************************
64//  TYPE DEFINITIONS
65//**************************************************************************
66
67
68// ======================> memory_array
69
70// memory information
71class memory_array
72{
73public:
74   // construction/destruction
75   memory_array();
76   memory_array(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe) { set(base, bytes, membits, endianness, bpe); }
77   memory_array(const address_space &space, void *base, UINT32 bytes, int bpe) { set(space, base, bytes, bpe); }
78   memory_array(const memory_share &share, int bpe) { set(share, bpe); }
79   memory_array(const memory_array &helper) { set(helper); }
80
81   // configuration
82   void set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe);
83   void set(const address_space &space, void *base, UINT32 bytes, int bpe);
84   void set(const memory_share &share, int bpe);
85   void set(const memory_array &helper);
86
87   // getters
88   void *base() const { return m_base; }
89   UINT32 bytes() const { return m_bytes; }
90   int membits() const { return m_membits; }
91   endianness_t endianness() const { return m_endianness; }
92   int bytes_per_entry() const { return m_bytes_per_entry; }
93
94   // readers and writers
95   UINT32 read(int index) { return (this->*m_reader)(index); }
96   void write(int index, UINT32 data) { (this->*m_writer)(index, data); }
97
98private:
99   // internal read/write helpers for 1 byte entries
100   UINT32 read8_from_8(int index);     void write8_to_8(int index, UINT32 data);
101   UINT32 read8_from_16le(int index);  void write8_to_16le(int index, UINT32 data);
102   UINT32 read8_from_16be(int index);  void write8_to_16be(int index, UINT32 data);
103   UINT32 read8_from_32le(int index);  void write8_to_32le(int index, UINT32 data);
104   UINT32 read8_from_32be(int index);  void write8_to_32be(int index, UINT32 data);
105   UINT32 read8_from_64le(int index);  void write8_to_64le(int index, UINT32 data);
106   UINT32 read8_from_64be(int index);  void write8_to_64be(int index, UINT32 data);
107
108   // internal read/write helpers for 2 byte entries
109   UINT32 read16_from_8le(int index);  void write16_to_8le(int index, UINT32 data);
110   UINT32 read16_from_8be(int index);  void write16_to_8be(int index, UINT32 data);
111   UINT32 read16_from_16(int index);   void write16_to_16(int index, UINT32 data);
112   UINT32 read16_from_32le(int index); void write16_to_32le(int index, UINT32 data);
113   UINT32 read16_from_32be(int index); void write16_to_32be(int index, UINT32 data);
114   UINT32 read16_from_64le(int index); void write16_to_64le(int index, UINT32 data);
115   UINT32 read16_from_64be(int index); void write16_to_64be(int index, UINT32 data);
116
117   // internal read/write helpers for 4 byte entries
118   UINT32 read32_from_8le(int index);  void write32_to_8le(int index, UINT32 data);
119   UINT32 read32_from_8be(int index);  void write32_to_8be(int index, UINT32 data);
120   UINT32 read32_from_16le(int index); void write32_to_16le(int index, UINT32 data);
121   UINT32 read32_from_16be(int index); void write32_to_16be(int index, UINT32 data);
122   UINT32 read32_from_32(int index);   void write32_to_32(int index, UINT32 data);
123   UINT32 read32_from_64le(int index); void write32_to_64le(int index, UINT32 data);
124   UINT32 read32_from_64be(int index); void write32_to_64be(int index, UINT32 data);
125
126   // internal state
127   void *              m_base;
128   UINT32              m_bytes;
129   int                 m_membits;
130   endianness_t        m_endianness;
131   int                 m_bytes_per_entry;
132   UINT32 (memory_array::*m_reader)(int);
133   void (memory_array::*m_writer)(int, UINT32);
134};
135
136
137
138#endif  // __MEMARRAY_H__
Property changes on: trunk/src/emu/memarray.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/emu.h
r24781r24782
6969// memory and address spaces
7070#include "memory.h"
7171#include "addrmap.h"
72#include "memarray.h"
7273
7374// machine-wide utilities
7475#include "romload.h"
trunk/src/emu/emu.mak
r24781r24782
8989   $(EMUOBJ)/mame.o \
9090   $(EMUOBJ)/machine.o \
9191   $(EMUOBJ)/mconfig.o \
92   $(EMUOBJ)/memarray.o \
9293   $(EMUOBJ)/memory.o \
9394   $(EMUOBJ)/network.o \
9495   $(EMUOBJ)/output.o \
trunk/src/emu/tilemap.c
r24781r24782
14911491
14921492
14931493//**************************************************************************
1494//  TILEMAP MEMORY HELPER
1495//**************************************************************************
1496
1497//-------------------------------------------------
1498//  tilemap_memory - constructor
1499//-------------------------------------------------
1500
1501tilemap_memory::tilemap_memory()
1502   : m_base(NULL),
1503      m_bytes(0),
1504      m_membits(0),
1505      m_bytes_per_entry(0)
1506{
1507}
1508
1509
1510//-------------------------------------------------
1511//  set - configure the parameters
1512//-------------------------------------------------
1513
1514void tilemap_memory::set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe)
1515{
1516   // validate inputs
1517   assert(base != NULL);
1518   assert(bytes > 0);
1519   assert(membits == 8 || membits == 16 || membits == 32 || membits == 64);
1520   assert(bpe == 1 || bpe == 2 || bpe == 4);
1521
1522   // populate direct data
1523   m_base = base;
1524   m_bytes = bytes;
1525   m_membits = membits;
1526   m_endianness = endianness;
1527   m_bytes_per_entry = bpe;
1528
1529   // derive data
1530   switch (bpe*1000 + membits*10 + endianness)
1531   {
1532      case 1*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &tilemap_memory::read8_from_8;       m_writer = &tilemap_memory::write8_to_8;        break;
1533      case 1*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &tilemap_memory::read8_from_8;       m_writer = &tilemap_memory::write8_to_8;        break;
1534      case 1*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read8_from_16le;    m_writer = &tilemap_memory::write8_to_16le;     break;
1535      case 1*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read8_from_16be;    m_writer = &tilemap_memory::write8_to_16be;     break;
1536      case 1*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read8_from_32le;    m_writer = &tilemap_memory::write8_to_32le;     break;
1537      case 1*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read8_from_32be;    m_writer = &tilemap_memory::write8_to_32be;     break;
1538      case 1*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read8_from_64le;    m_writer = &tilemap_memory::write8_to_64le;     break;
1539      case 1*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read8_from_64be;    m_writer = &tilemap_memory::write8_to_64be;     break;
1540
1541      case 2*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &tilemap_memory::read16_from_8le;    m_writer = &tilemap_memory::write16_to_8le;     break;
1542      case 2*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &tilemap_memory::read16_from_8be;    m_writer = &tilemap_memory::write16_to_8be;     break;
1543      case 2*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read16_from_16;     m_writer = &tilemap_memory::write16_to_16;      break;
1544      case 2*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read16_from_16;     m_writer = &tilemap_memory::write16_to_16;      break;
1545      case 2*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read16_from_32le;   m_writer = &tilemap_memory::write16_to_32le;    break;
1546      case 2*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read16_from_32be;   m_writer = &tilemap_memory::write16_to_32be;    break;
1547      case 2*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read16_from_64le;   m_writer = &tilemap_memory::write16_to_64le;    break;
1548      case 2*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read16_from_64be;   m_writer = &tilemap_memory::write16_to_64be;    break;
1549
1550      case 4*1000 + 8*10 + ENDIANNESS_LITTLE:     m_reader = &tilemap_memory::read32_from_8le;    m_writer = &tilemap_memory::write32_to_8le;     break;
1551      case 4*1000 + 8*10 + ENDIANNESS_BIG:        m_reader = &tilemap_memory::read32_from_8be;    m_writer = &tilemap_memory::write32_to_8be;     break;
1552      case 4*1000 + 16*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read32_from_16le;   m_writer = &tilemap_memory::write32_to_16le;    break;
1553      case 4*1000 + 16*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read32_from_16be;   m_writer = &tilemap_memory::write32_to_16be;    break;
1554      case 4*1000 + 32*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read32_from_32;     m_writer = &tilemap_memory::write32_to_32;      break;
1555      case 4*1000 + 32*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read32_from_32;     m_writer = &tilemap_memory::write32_to_32;      break;
1556      case 4*1000 + 64*10 + ENDIANNESS_LITTLE:    m_reader = &tilemap_memory::read32_from_64le;   m_writer = &tilemap_memory::write32_to_64le;    break;
1557      case 4*1000 + 64*10 + ENDIANNESS_BIG:       m_reader = &tilemap_memory::read32_from_64be;   m_writer = &tilemap_memory::write32_to_64be;    break;
1558
1559      default:    throw emu_fatalerror("Illegal memory bits/bus width combo in tilemap_memory");
1560   }
1561}
1562
1563
1564//-------------------------------------------------
1565//  set - additional setter variants
1566//-------------------------------------------------
1567
1568void tilemap_memory::set(const address_space &space, void *base, UINT32 bytes, int bpe)
1569{
1570   set(base, bytes, space.data_width(), space.endianness(), bpe);
1571}
1572
1573void tilemap_memory::set(const memory_share &share, int bpe)
1574{
1575   set(share.ptr(), share.bytes(), share.width(), share.endianness(), bpe);
1576}
1577
1578void tilemap_memory::set(const tilemap_memory &helper)
1579{
1580   set(helper.base(), helper.bytes(), helper.membits(), helper.endianness(), helper.bytes_per_entry());
1581}
1582
1583
1584//-------------------------------------------------
1585//  read8_from_*/write8_to_* - entry read/write
1586//  heleprs for 1 byte-per-entry
1587//-------------------------------------------------
1588
1589UINT32 tilemap_memory::read8_from_8(int index) { return reinterpret_cast<UINT8 *>(m_base)[index]; }
1590void tilemap_memory::write8_to_8(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[index] = data; }
1591
1592UINT32 tilemap_memory::read8_from_16le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_LE(index)]; }
1593void tilemap_memory::write8_to_16le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_LE(index)] = data; }
1594UINT32 tilemap_memory::read8_from_16be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_BE(index)]; }
1595void tilemap_memory::write8_to_16be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE_XOR_BE(index)] = data; }
1596
1597UINT32 tilemap_memory::read8_from_32le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)]; }
1598void tilemap_memory::write8_to_32le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
1599UINT32 tilemap_memory::read8_from_32be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)]; }
1600void tilemap_memory::write8_to_32be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
1601
1602UINT32 tilemap_memory::read8_from_64le(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)]; }
1603void tilemap_memory::write8_to_64le(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)] = data; }
1604UINT32 tilemap_memory::read8_from_64be(int index) { return reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)]; }
1605void tilemap_memory::write8_to_64be(int index, UINT32 data) { reinterpret_cast<UINT8 *>(m_base)[BYTE8_XOR_BE(index)] = data; }
1606
1607
1608//-------------------------------------------------
1609//  read16_from_*/write16_to_* - entry read/write
1610//  heleprs for 2 bytes-per-entry
1611//-------------------------------------------------
1612
1613UINT32 tilemap_memory::read16_from_8le(int index) { return read8_from_8(index*2) | (read8_from_8(index*2+1) << 8); }
1614void tilemap_memory::write16_to_8le(int index, UINT32 data) { write8_to_8(index*2, data); write8_to_8(index*2+1, data >> 8); }
1615UINT32 tilemap_memory::read16_from_8be(int index) { return (read8_from_8(index*2) << 8) | read8_from_8(index*2+1); }
1616void tilemap_memory::write16_to_8be(int index, UINT32 data) { write8_to_8(index*2, data >> 8); write8_to_8(index*2+1, data); }
1617
1618UINT32 tilemap_memory::read16_from_16(int index) { return reinterpret_cast<UINT16 *>(m_base)[index]; }
1619void tilemap_memory::write16_to_16(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[index] = data; }
1620
1621UINT32 tilemap_memory::read16_from_32le(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_LE(index)]; }
1622void tilemap_memory::write16_to_32le(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_LE(index)] = data; }
1623UINT32 tilemap_memory::read16_from_32be(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_BE(index)]; }
1624void tilemap_memory::write16_to_32be(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE_XOR_BE(index)] = data; }
1625
1626UINT32 tilemap_memory::read16_from_64le(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_LE(index)]; }
1627void tilemap_memory::write16_to_64le(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_LE(index)] = data; }
1628UINT32 tilemap_memory::read16_from_64be(int index) { return reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_BE(index)]; }
1629void tilemap_memory::write16_to_64be(int index, UINT32 data) { reinterpret_cast<UINT16 *>(m_base)[BYTE4_XOR_BE(index)] = data; }
1630
1631
1632//-------------------------------------------------
1633//  read32_from_*/write32_to_* - entry read/write
1634//  heleprs for 4 bytes-per-entry
1635//-------------------------------------------------
1636
1637UINT32 tilemap_memory::read32_from_8le(int index) { return read16_from_8le(index*2) | (read16_from_8le(index*2+1) << 16); }
1638void tilemap_memory::write32_to_8le(int index, UINT32 data) { write16_to_8le(index*2, data); write16_to_8le(index*2+1, data >> 16); }
1639UINT32 tilemap_memory::read32_from_8be(int index) { return (read16_from_8be(index*2) << 16) | read16_from_8be(index*2+1); }
1640void tilemap_memory::write32_to_8be(int index, UINT32 data) { write16_to_8be(index*2, data >> 16); write16_to_8be(index*2+1, data); }
1641
1642UINT32 tilemap_memory::read32_from_16le(int index) { return read16_from_16(index*2) | (read16_from_16(index*2+1) << 16); }
1643void tilemap_memory::write32_to_16le(int index, UINT32 data) { write16_to_16(index*2, data); write16_to_16(index*2+1, data >> 16); }
1644UINT32 tilemap_memory::read32_from_16be(int index) { return (read16_from_16(index*2) << 16) | read16_from_16(index*2+1); }
1645void tilemap_memory::write32_to_16be(int index, UINT32 data) { write16_to_16(index*2, data >> 16); write16_to_16(index*2+1, data); }
1646
1647UINT32 tilemap_memory::read32_from_32(int index) { return reinterpret_cast<UINT32 *>(m_base)[index]; }
1648void tilemap_memory::write32_to_32(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[index] = data; }
1649
1650UINT32 tilemap_memory::read32_from_64le(int index) { return reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_LE(index)]; }
1651void tilemap_memory::write32_to_64le(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_LE(index)] = data; }
1652UINT32 tilemap_memory::read32_from_64be(int index) { return reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_BE(index)]; }
1653void tilemap_memory::write32_to_64be(int index, UINT32 data) { reinterpret_cast<UINT32 *>(m_base)[BYTE_XOR_BE(index)] = data; }
1654
1655
1656
1657//**************************************************************************
16581494//  TILEMAP MANAGER
16591495//**************************************************************************
16601496
trunk/src/emu/tilemap.h
r24781r24782
434434   MCFG_TILEMAP_TRANSPARENT_PEN(_transpen)
435435
436436
437
437438//**************************************************************************
438439//  TYPE DEFINITIONS
439440//**************************************************************************
r24781r24782
485486typedef device_delegate<tilemap_memory_index (UINT32, UINT32, UINT32, UINT32)> tilemap_mapper_delegate;
486487
487488
488// ======================> tilemap_memory
489
490// memory information
491class tilemap_memory
492{
493   friend class tilemap_t;
494
495   // construction/destruction
496   tilemap_memory();
497
498public:
499   // configuration
500   void set(void *base, UINT32 bytes, int membits, endianness_t endianness, int bpe);
501   void set(const address_space &space, void *base, UINT32 bytes, int bpe);
502   void set(const memory_share &share, int bpe);
503   void set(const tilemap_memory &helper);
504
505   // getters
506   void *base() const { return m_base; }
507   UINT32 bytes() const { return m_bytes; }
508   int membits() const { return m_membits; }
509   endianness_t endianness() const { return m_endianness; }
510   int bytes_per_entry() const { return m_bytes_per_entry; }
511
512private:
513   // readers and writers
514   UINT32 read(int index) { return (this->*m_reader)(index); }
515   void write(int index, UINT32 data) { (this->*m_writer)(index, data); }
516
517   // internal read/write helpers for 1 byte entries
518   UINT32 read8_from_8(int index);     void write8_to_8(int index, UINT32 data);
519   UINT32 read8_from_16le(int index);  void write8_to_16le(int index, UINT32 data);
520   UINT32 read8_from_16be(int index);  void write8_to_16be(int index, UINT32 data);
521   UINT32 read8_from_32le(int index);  void write8_to_32le(int index, UINT32 data);
522   UINT32 read8_from_32be(int index);  void write8_to_32be(int index, UINT32 data);
523   UINT32 read8_from_64le(int index);  void write8_to_64le(int index, UINT32 data);
524   UINT32 read8_from_64be(int index);  void write8_to_64be(int index, UINT32 data);
525
526   // internal read/write helpers for 2 byte entries
527   UINT32 read16_from_8le(int index);  void write16_to_8le(int index, UINT32 data);
528   UINT32 read16_from_8be(int index);  void write16_to_8be(int index, UINT32 data);
529   UINT32 read16_from_16(int index);   void write16_to_16(int index, UINT32 data);
530   UINT32 read16_from_32le(int index); void write16_to_32le(int index, UINT32 data);
531   UINT32 read16_from_32be(int index); void write16_to_32be(int index, UINT32 data);
532   UINT32 read16_from_64le(int index); void write16_to_64le(int index, UINT32 data);
533   UINT32 read16_from_64be(int index); void write16_to_64be(int index, UINT32 data);
534
535   // internal read/write helpers for 4 byte entries
536   UINT32 read32_from_8le(int index);  void write32_to_8le(int index, UINT32 data);
537   UINT32 read32_from_8be(int index);  void write32_to_8be(int index, UINT32 data);
538   UINT32 read32_from_16le(int index); void write32_to_16le(int index, UINT32 data);
539   UINT32 read32_from_16be(int index); void write32_to_16be(int index, UINT32 data);
540   UINT32 read32_from_32(int index);   void write32_to_32(int index, UINT32 data);
541   UINT32 read32_from_64le(int index); void write32_to_64le(int index, UINT32 data);
542   UINT32 read32_from_64be(int index); void write32_to_64be(int index, UINT32 data);
543
544   // internal state
545   void *              m_base;
546   UINT32              m_bytes;
547   int                 m_membits;
548   endianness_t        m_endianness;
549   int                 m_bytes_per_entry;
550   UINT32 (tilemap_memory::*m_reader)(int);
551   void (tilemap_memory::*m_writer)(int, UINT32);
552};
553
554
555489// ======================> tilemap_t
556490
557491// core tilemap structure
r24781r24782
589523   tilemap_device *device() const { return m_device; }
590524   tilemap_t *next() const { return m_next; }
591525   void *user_data() const { return m_user_data; }
592   tilemap_memory &basemem() { return m_basemem; }
593   tilemap_memory &extmem() { return m_extmem; }
526   memory_array &basemem() { return m_basemem; }
527   memory_array &extmem() { return m_extmem; }
594528   UINT32 width() const { return m_width; }
595529   UINT32 height() const { return m_height; }
596530   bool enabled() const { return m_enable; }
r24781r24782
712646   void *                      m_user_data;            // user data value
713647
714648   // optional memory info
715   tilemap_memory              m_basemem;              // info about base memory
716   tilemap_memory              m_extmem;               // info about extension memory
649   memory_array                m_basemem;              // info about base memory
650   memory_array                m_extmem;               // info about extension memory
717651
718652   // basic tilemap metrics
719653   UINT32                      m_rows;                 // number of tile rows

Previous 199869 Revisions Next


© 1997-2024 The MAME Team