trunk/src/emu/drawgfx.h
| r241921 | r241922 | |
| 7 | 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | 9 | |
| 10 | ********************************************************************** |
| 11 | |
| 12 | How to use priority-masked drawing (formerly pdrawgfx): |
| 13 | |
| 14 | There are two different standard ways to use the priority bitmap |
| 15 | and the priority-masked draw methods, depending on how many layers |
| 16 | of interest (tilemap or other layers that individual sprites can |
| 17 | be either "behind" or "in front of") your driver has. |
| 18 | |
| 19 | In the more common scheme, which you can use when the number of |
| 20 | layers of interest is four or fewer, the priority bitmap contains |
| 21 | a bitmask indicating which layers are opaque at each location. |
| 22 | To use this scheme, draw your tilemap layers this way, in order |
| 23 | from back to front: |
| 24 | |
| 25 | screen.priority().fill(0, cliprect); |
| 26 | m_tilemap1->draw(screen, bitmap, cliprect, tmap1flags, 1); |
| 27 | m_tilemap2->draw(screen, bitmap, cliprect, tmap2flags, 2); |
| 28 | m_tilemap3->draw(screen, bitmap, cliprect, tmap3flags, 4); |
| 29 | m_tilemap4->draw(screen, bitmap, cliprect, tmap4flags, 8); |
| 30 | |
| 31 | Now, when drawing your sprites, the pmask parameter for each |
| 32 | sprite should be the bitwise OR of all the GFX_PMASK_n constants |
| 33 | corresponding to layers that the sprite should be masked by. |
| 34 | For example, to draw a sprite that appears over tilemap1, but |
| 35 | under opaque pixels of tilemap2, tilemap3, and tilemap4: |
| 36 | |
| 37 | UINT32 pmask = GFX_PMASK_2 | GFX_PMASK_4 | GFX_PMASK_8; |
| 38 | gfx->prio_transpen(bitmap, cliprect, |
| 39 | code, color, |
| 40 | flipx, flipy, |
| 41 | sx, sy, |
| 42 | screen.priority(), |
| 43 | pmask, |
| 44 | trans_pen); |
| 45 | |
| 46 | This scheme does not require priority to be transitive: it is |
| 47 | perfectly possible for a sprite to be "under" tilemap1 but "over" |
| 48 | tilemap4, even though tilemap1 itself is "under" tilemap4. |
| 49 | |
| 50 | If you have more than four layers, you need to use a different |
| 51 | scheme, in which the priority bitmap contains the index of the |
| 52 | topmost opaque layer rather than a bitmask of all the opaque |
| 53 | layers. To use this scheme, draw your tilemaps this way, again |
| 54 | in order from back to front: |
| 55 | |
| 56 | screen.priority().fill(0, cliprect); |
| 57 | m_tilemap1->draw(screen, bitmap, cliprect, tmap1flags, 1, 0); |
| 58 | m_tilemap2->draw(screen, bitmap, cliprect, tmap2flags, 2, 0); |
| 59 | m_tilemap3->draw(screen, bitmap, cliprect, tmap3flags, 3, 0); |
| 60 | m_tilemap4->draw(screen, bitmap, cliprect, tmap4flags, 4, 0); |
| 61 | m_tilemap5->draw(screen, bitmap, cliprect, tmap5flags, 5, 0); |
| 62 | m_tilemap6->draw(screen, bitmap, cliprect, tmap6flags, 6, 0); |
| 63 | m_tilemap7->draw(screen, bitmap, cliprect, tmap7flags, 7, 0); |
| 64 | m_tilemap8->draw(screen, bitmap, cliprect, tmap8flags, 8, 0); |
| 65 | |
| 66 | Notice the additional 0 parameter to tilemap_t::draw(). This |
| 67 | parameter causes the new layer's priority code to replace that of |
| 68 | the underlying layer instead of being ORed with it (the parameter |
| 69 | is a mask to be ANDed with the previous contents of the priority |
| 70 | bitmap before the new code is ORed with it) |
| 71 | |
| 72 | You need to use a different pmask for your sprites with this |
| 73 | scheme than with the previous scheme. The pmask should be set to |
| 74 | ((~1) << n), where n is the index of the highest priority layer |
| 75 | that the sprite should *not* be masked by. For example, to draw |
| 76 | a sprite over the first four tilemaps but under the higher |
| 77 | numbered ones: |
| 78 | |
| 79 | UINT32 pmask = (~1) << 4; |
| 80 | gfx->prio_transpen(bitmap, cliprect, |
| 81 | code, color, |
| 82 | flipx, flipy, |
| 83 | sx, sy, |
| 84 | screen.priority(), |
| 85 | pmask, |
| 86 | trans_pen); |
| 87 | |
| 88 | Unlike the other scheme, this one does require priority to be |
| 89 | transitive, because the priority bitmap only contains information |
| 90 | about the topmost opaque pixel. |
| 91 | |
| 92 | These examples have used a different tilemap for each layer, but |
| 93 | the layers could just as easily be different tile categories or |
| 94 | pen layers from the same tilemap. |
| 95 | |
| 96 | If you have a layer that is behind all sprites, draw it with |
| 97 | priority 0, and if you have a layer that is in front of all |
| 98 | sprites, just draw it after the sprites. The bitmask scheme |
| 99 | can handle up to 6 layers if you count "behind all sprites" and |
| 100 | "in front of all sprites". |
| 101 | |
| 102 | An important thing to remember when using priority-masked drawing |
| 103 | is that the sprites are drawn from front to back. Sprite pixels |
| 104 | will not be drawn over already-drawn sprite pixels, even if the |
| 105 | previously-drawn pixel was masked by a background layer. |
| 106 | This reflects the fact that in most hardware, sprite-to-sprite |
| 107 | priority is unrelated to sprite-to-background priority. Your |
| 108 | sprites need to be pre-sorted by their sprite-to-sprite priority |
| 109 | (whether that be a field in the sprite attributes or simply their |
| 110 | order in sprite RAM) before drawing. |
| 111 | |
| 112 | |
| 10 | 113 | *********************************************************************/ |
| 11 | 114 | |
| 12 | 115 | #pragma once |
| r241921 | r241922 | |
| 30 | 133 | DRAWMODE_SHADOW |
| 31 | 134 | }; |
| 32 | 135 | |
| 136 | enum |
| 137 | { |
| 138 | GFX_PMASK_1 = 0xaaaa, |
| 139 | GFX_PMASK_2 = 0xcccc, |
| 140 | GFX_PMASK_4 = 0xf0f0, |
| 141 | GFX_PMASK_8 = 0xff00 |
| 142 | }; |
| 33 | 143 | |
| 34 | 144 | |
| 35 | 145 | /*************************************************************************** |
trunk/src/mame/drivers/prehisle.c
| r241921 | r241922 | |
| 16 | 16 | |
| 17 | 17 | /******************************************************************************/ |
| 18 | 18 | |
| 19 | | WRITE16_MEMBER(prehisle_state::prehisle_sound16_w) |
| 19 | WRITE16_MEMBER(prehisle_state::soundcmd_w) |
| 20 | 20 | { |
| 21 | 21 | soundlatch_byte_w(space, 0, data & 0xff); |
| 22 | 22 | m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| r241921 | r241922 | |
| 27 | 27 | static ADDRESS_MAP_START( prehisle_map, AS_PROGRAM, 16, prehisle_state ) |
| 28 | 28 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 29 | 29 | AM_RANGE(0x070000, 0x073fff) AM_RAM |
| 30 | | AM_RANGE(0x090000, 0x0907ff) AM_RAM_WRITE(prehisle_fg_videoram16_w) AM_SHARE("videoram") |
| 30 | AM_RANGE(0x090000, 0x0907ff) AM_RAM_WRITE(tx_vram_w) AM_SHARE("tx_vram") |
| 31 | 31 | AM_RANGE(0x0a0000, 0x0a07ff) AM_RAM AM_SHARE("spriteram") |
| 32 | | AM_RANGE(0x0b0000, 0x0b3fff) AM_RAM_WRITE(prehisle_bg_videoram16_w) AM_SHARE("bg_videoram16") |
| 32 | AM_RANGE(0x0b0000, 0x0b3fff) AM_RAM_WRITE(fg_vram_w) AM_SHARE("fg_vram") |
| 33 | 33 | AM_RANGE(0x0d0000, 0x0d07ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| 34 | | AM_RANGE(0x0e0000, 0x0e00ff) AM_READ(prehisle_control16_r) |
| 35 | | AM_RANGE(0x0f0070, 0x0ff071) AM_WRITE(prehisle_sound16_w) |
| 36 | | AM_RANGE(0x0f0000, 0x0ff0ff) AM_WRITE(prehisle_control16_w) |
| 34 | AM_RANGE(0x0e0000, 0x0e00ff) AM_READ(control_r) |
| 35 | AM_RANGE(0x0f0070, 0x0ff071) AM_WRITE(soundcmd_w) |
| 36 | AM_RANGE(0x0f0000, 0x0ff0ff) AM_WRITE(control_w) |
| 37 | 37 | ADDRESS_MAP_END |
| 38 | 38 | |
| 39 | 39 | /******************************************************************************/ |
| r241921 | r241922 | |
| 182 | 182 | }; |
| 183 | 183 | |
| 184 | 184 | static GFXDECODE_START( prehisle ) |
| 185 | | GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 ) |
| 186 | | GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 768, 16 ) |
| 187 | | GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 512, 16 ) |
| 188 | | GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 256, 16 ) |
| 185 | GFXDECODE_ENTRY( "chars", 0, charlayout, 0, 16 ) |
| 186 | GFXDECODE_ENTRY( "bgtiles", 0, tilelayout, 768, 16 ) |
| 187 | GFXDECODE_ENTRY( "fgtiles", 0, tilelayout, 512, 16 ) |
| 188 | GFXDECODE_ENTRY( "sprites", 0, spritelayout, 256, 16 ) |
| 189 | 189 | GFXDECODE_END |
| 190 | 190 | |
| 191 | 191 | /******************************************************************************/ |
| r241921 | r241922 | |
| 243 | 243 | ROM_REGION( 0x10000, "audiocpu", 0 ) /* Sound CPU */ |
| 244 | 244 | ROM_LOAD( "gt1.1", 0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) ) |
| 245 | 245 | |
| 246 | | ROM_REGION( 0x008000, "gfx1", 0 ) |
| 246 | ROM_REGION( 0x008000, "chars", 0 ) |
| 247 | 247 | ROM_LOAD( "gt15.b15", 0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) ) |
| 248 | 248 | |
| 249 | | ROM_REGION( 0x040000, "gfx2", 0 ) |
| 249 | ROM_REGION( 0x040000, "bgtiles", 0 ) |
| 250 | 250 | ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) ) |
| 251 | 251 | |
| 252 | | ROM_REGION( 0x040000, "gfx3", 0 ) |
| 252 | ROM_REGION( 0x040000, "fgtiles", 0 ) |
| 253 | 253 | ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) ) |
| 254 | 254 | |
| 255 | | ROM_REGION( 0x0a0000, "gfx4", 0 ) |
| 255 | ROM_REGION( 0x0a0000, "sprites", 0 ) |
| 256 | 256 | ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) ) |
| 257 | 257 | ROM_LOAD( "gt5.5", 0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) ) |
| 258 | 258 | |
| 259 | | ROM_REGION( 0x10000, "gfx5", 0 ) /* background tilemaps */ |
| 259 | ROM_REGION( 0x10000, "bgtilemap", 0 ) /* background tilemaps */ |
| 260 | 260 | ROM_LOAD( "gt11.11", 0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) ) |
| 261 | 261 | |
| 262 | 262 | ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */ |
| r241921 | r241922 | |
| 271 | 271 | ROM_REGION( 0x10000, "audiocpu", 0 ) /* Sound CPU */ |
| 272 | 272 | ROM_LOAD( "gt1.1", 0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) ) |
| 273 | 273 | |
| 274 | | ROM_REGION( 0x008000, "gfx1", 0 ) |
| 274 | ROM_REGION( 0x008000, "chars", 0 ) |
| 275 | 275 | ROM_LOAD( "gt15.b15", 0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) ) |
| 276 | 276 | |
| 277 | | ROM_REGION( 0x040000, "gfx2", 0 ) |
| 277 | ROM_REGION( 0x040000, "bgtiles", 0 ) |
| 278 | 278 | ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) ) |
| 279 | 279 | |
| 280 | | ROM_REGION( 0x040000, "gfx3", 0 ) |
| 280 | ROM_REGION( 0x040000, "fgtiles", 0 ) |
| 281 | 281 | ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) ) |
| 282 | 282 | |
| 283 | | ROM_REGION( 0x0a0000, "gfx4", 0 ) |
| 283 | ROM_REGION( 0x0a0000, "sprites", 0 ) |
| 284 | 284 | ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) ) |
| 285 | 285 | ROM_LOAD( "gt5.5", 0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) ) |
| 286 | 286 | |
| 287 | | ROM_REGION( 0x10000, "gfx5", 0 ) /* background tilemaps */ |
| 287 | ROM_REGION( 0x10000, "bgtilemap", 0 ) /* background tilemaps */ |
| 288 | 288 | ROM_LOAD( "gt11.11", 0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) ) |
| 289 | 289 | |
| 290 | 290 | ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */ |
| r241921 | r241922 | |
| 299 | 299 | ROM_REGION( 0x10000, "audiocpu", 0 ) /* Sound CPU */ |
| 300 | 300 | ROM_LOAD( "gt1.1", 0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) ) |
| 301 | 301 | |
| 302 | | ROM_REGION( 0x008000, "gfx1", 0 ) |
| 302 | ROM_REGION( 0x008000, "chars", 0 ) |
| 303 | 303 | ROM_LOAD( "gt15.b15", 0x000000, 0x08000, BAD_DUMP CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) ) // not dumped, missing korean text |
| 304 | 304 | |
| 305 | | ROM_REGION( 0x040000, "gfx2", 0 ) |
| 305 | ROM_REGION( 0x040000, "bgtiles", 0 ) |
| 306 | 306 | ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) ) |
| 307 | 307 | |
| 308 | | ROM_REGION( 0x040000, "gfx3", 0 ) |
| 308 | ROM_REGION( 0x040000, "fgtiles", 0 ) |
| 309 | 309 | ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) ) |
| 310 | 310 | |
| 311 | | ROM_REGION( 0x0a0000, "gfx4", 0 ) |
| 311 | ROM_REGION( 0x0a0000, "sprites", 0 ) |
| 312 | 312 | ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) ) |
| 313 | 313 | ROM_LOAD( "gt5.5", 0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) ) |
| 314 | 314 | |
| 315 | | ROM_REGION( 0x10000, "gfx5", 0 ) /* background tilemaps */ |
| 315 | ROM_REGION( 0x10000, "bgtilemap", 0 ) /* background tilemaps */ |
| 316 | 316 | ROM_LOAD( "gt11.11", 0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) ) |
| 317 | 317 | |
| 318 | 318 | ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */ |
| r241921 | r241922 | |
| 327 | 327 | ROM_REGION( 0x10000, "audiocpu", 0 ) /* Sound CPU */ |
| 328 | 328 | ROM_LOAD( "gt1.1", 0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) ) |
| 329 | 329 | |
| 330 | | ROM_REGION( 0x008000, "gfx1", 0 ) |
| 330 | ROM_REGION( 0x008000, "chars", 0 ) |
| 331 | 331 | ROM_LOAD( "gt15.b15", 0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) ) |
| 332 | 332 | |
| 333 | | ROM_REGION( 0x040000, "gfx2", 0 ) |
| 333 | ROM_REGION( 0x040000, "bgtiles", 0 ) |
| 334 | 334 | ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) ) |
| 335 | 335 | |
| 336 | | ROM_REGION( 0x040000, "gfx3", 0 ) |
| 336 | ROM_REGION( 0x040000, "fgtiles", 0 ) |
| 337 | 337 | ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) ) |
| 338 | 338 | |
| 339 | | ROM_REGION( 0x0a0000, "gfx4", 0 ) |
| 339 | ROM_REGION( 0x0a0000, "sprites", 0 ) |
| 340 | 340 | ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) ) |
| 341 | 341 | ROM_LOAD( "gt5.5", 0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) ) |
| 342 | 342 | |
| 343 | | ROM_REGION( 0x10000, "gfx5", 0 ) /* background tilemaps */ |
| 343 | ROM_REGION( 0x10000, "bgtilemap", 0 ) /* background tilemaps */ |
| 344 | 344 | ROM_LOAD( "gt11.11", 0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) ) |
| 345 | 345 | |
| 346 | 346 | ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */ |
trunk/src/mame/includes/prehisle.h
| r241921 | r241922 | |
| 5 | 5 | public: |
| 6 | 6 | prehisle_state(const machine_config &mconfig, device_type type, const char *tag) |
| 7 | 7 | : driver_device(mconfig, type, tag), |
| 8 | | m_videoram(*this, "videoram"), |
| 8 | m_tx_vram(*this, "tx_vram"), |
| 9 | 9 | m_spriteram(*this, "spriteram"), |
| 10 | | m_bg_videoram16(*this, "bg_videoram16"), |
| 10 | m_fg_vram(*this, "fg_vram"), |
| 11 | m_tilemap_rom(*this, "bgtilemap"), |
| 11 | 12 | m_maincpu(*this, "maincpu"), |
| 12 | 13 | m_audiocpu(*this, "audiocpu"), |
| 13 | 14 | m_upd7759(*this, "upd"), |
| r241921 | r241922 | |
| 15 | 16 | m_palette(*this, "palette") { } |
| 16 | 17 | |
| 17 | 18 | |
| 18 | | required_shared_ptr<UINT16> m_videoram; |
| 19 | required_shared_ptr<UINT16> m_tx_vram; |
| 19 | 20 | required_shared_ptr<UINT16> m_spriteram; |
| 20 | | required_shared_ptr<UINT16> m_bg_videoram16; |
| 21 | required_shared_ptr<UINT16> m_fg_vram; |
| 22 | required_region_ptr<UINT8> m_tilemap_rom; |
| 21 | 23 | UINT16 m_invert_controls; |
| 22 | 24 | |
| 23 | | tilemap_t *m_bg2_tilemap; |
| 24 | 25 | tilemap_t *m_bg_tilemap; |
| 25 | 26 | tilemap_t *m_fg_tilemap; |
| 27 | tilemap_t *m_tx_tilemap; |
| 26 | 28 | |
| 27 | | DECLARE_WRITE16_MEMBER(prehisle_sound16_w); |
| 28 | | DECLARE_WRITE16_MEMBER(prehisle_bg_videoram16_w); |
| 29 | | DECLARE_WRITE16_MEMBER(prehisle_fg_videoram16_w); |
| 30 | | DECLARE_READ16_MEMBER(prehisle_control16_r); |
| 31 | | DECLARE_WRITE16_MEMBER(prehisle_control16_w); |
| 29 | DECLARE_WRITE16_MEMBER(soundcmd_w); |
| 30 | DECLARE_WRITE16_MEMBER(fg_vram_w); |
| 31 | DECLARE_WRITE16_MEMBER(tx_vram_w); |
| 32 | DECLARE_READ16_MEMBER(control_r); |
| 33 | DECLARE_WRITE16_MEMBER(control_w); |
| 32 | 34 | DECLARE_WRITE8_MEMBER(D7759_write_port_0_w); |
| 33 | 35 | DECLARE_WRITE8_MEMBER(D7759_upd_reset_w); |
| 34 | | TILE_GET_INFO_MEMBER(get_bg2_tile_info); |
| 35 | 36 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 36 | 37 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 38 | TILE_GET_INFO_MEMBER(get_tx_tile_info); |
| 37 | 39 | virtual void video_start(); |
| 38 | 40 | UINT32 screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 39 | 41 | void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
trunk/src/mame/video/prehisle.c
| r241921 | r241922 | |
| 10 | 10 | #include "includes/prehisle.h" |
| 11 | 11 | |
| 12 | 12 | |
| 13 | | WRITE16_MEMBER(prehisle_state::prehisle_bg_videoram16_w) |
| 13 | WRITE16_MEMBER(prehisle_state::fg_vram_w) |
| 14 | 14 | { |
| 15 | | COMBINE_DATA(&m_bg_videoram16[offset]); |
| 16 | | m_bg_tilemap->mark_tile_dirty(offset); |
| 15 | COMBINE_DATA(&m_fg_vram[offset]); |
| 16 | m_fg_tilemap->mark_tile_dirty(offset); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | | WRITE16_MEMBER(prehisle_state::prehisle_fg_videoram16_w) |
| 19 | WRITE16_MEMBER(prehisle_state::tx_vram_w) |
| 20 | 20 | { |
| 21 | | COMBINE_DATA(&m_videoram[offset]); |
| 22 | | m_fg_tilemap->mark_tile_dirty(offset); |
| 21 | COMBINE_DATA(&m_tx_vram[offset]); |
| 22 | m_tx_tilemap->mark_tile_dirty(offset); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | | READ16_MEMBER(prehisle_state::prehisle_control16_r) |
| 25 | READ16_MEMBER(prehisle_state::control_r) |
| 26 | 26 | { |
| 27 | 27 | switch (offset) |
| 28 | 28 | { |
| r241921 | r241922 | |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | | WRITE16_MEMBER(prehisle_state::prehisle_control16_w) |
| 38 | WRITE16_MEMBER(prehisle_state::control_w) |
| 39 | 39 | { |
| 40 | 40 | int scroll = 0; |
| 41 | 41 | |
| r241921 | r241922 | |
| 43 | 43 | |
| 44 | 44 | switch (offset) |
| 45 | 45 | { |
| 46 | | case 0x00: m_bg_tilemap->set_scrolly(0, scroll); break; |
| 47 | | case 0x08: m_bg_tilemap->set_scrollx(0, scroll); break; |
| 48 | | case 0x10: m_bg2_tilemap->set_scrolly(0, scroll); break; |
| 49 | | case 0x18: m_bg2_tilemap->set_scrollx(0, scroll); break; |
| 46 | case 0x00: m_fg_tilemap->set_scrolly(0, scroll); break; |
| 47 | case 0x08: m_fg_tilemap->set_scrollx(0, scroll); break; |
| 48 | case 0x10: m_bg_tilemap->set_scrolly(0, scroll); break; |
| 49 | case 0x18: m_bg_tilemap->set_scrollx(0, scroll); break; |
| 50 | 50 | case 0x23: m_invert_controls = data ? 0x00ff : 0x0000; break; |
| 51 | 51 | case 0x28: coin_counter_w(machine(), 0, data & 1); break; |
| 52 | 52 | case 0x29: coin_counter_w(machine(), 1, data & 1); break; |
| r241921 | r241922 | |
| 60 | 60 | 0 .....xxx gfx code high bits |
| 61 | 61 | 1 xxxxxxxx gfx code low bits |
| 62 | 62 | */ |
| 63 | | TILE_GET_INFO_MEMBER(prehisle_state::get_bg2_tile_info) |
| 63 | TILE_GET_INFO_MEMBER(prehisle_state::get_bg_tile_info) |
| 64 | 64 | { |
| 65 | | UINT8 const *const tilerom = memregion("gfx5")->base(); |
| 66 | | |
| 67 | 65 | int const offs = tile_index * 2; |
| 68 | | int const attr = tilerom[offs + 1] + (tilerom[offs] << 8); |
| 69 | | int const code = (attr & 0x7ff) | 0x800; |
| 66 | int const attr = m_tilemap_rom[offs + 1] + (m_tilemap_rom[offs] << 8); |
| 67 | int const code = attr & 0x7ff; |
| 70 | 68 | int const color = attr >> 12; |
| 71 | 69 | int const flags = (attr & 0x800) ? TILE_FLIPX : 0; |
| 72 | 70 | |
| r241921 | r241922 | |
| 78 | 76 | 0 ....x... ........ flip y |
| 79 | 77 | 0 .....xxx xxxxxxxx gfx code |
| 80 | 78 | */ |
| 81 | | TILE_GET_INFO_MEMBER(prehisle_state::get_bg_tile_info) |
| 79 | TILE_GET_INFO_MEMBER(prehisle_state::get_fg_tile_info) |
| 82 | 80 | { |
| 83 | | int const attr = m_bg_videoram16[tile_index]; |
| 81 | int const attr = m_fg_vram[tile_index]; |
| 84 | 82 | int const code = attr & 0x7ff; |
| 85 | 83 | int const color = attr >> 12; |
| 86 | 84 | int const flags = (attr & 0x800) ? TILE_FLIPY : 0; |
| r241921 | r241922 | |
| 92 | 90 | 0 xxxx.... ........ color |
| 93 | 91 | 0 ....xxxx xxxxxxxx gfx code |
| 94 | 92 | */ |
| 95 | | TILE_GET_INFO_MEMBER(prehisle_state::get_fg_tile_info) |
| 93 | TILE_GET_INFO_MEMBER(prehisle_state::get_tx_tile_info) |
| 96 | 94 | { |
| 97 | | int const attr = m_videoram[tile_index]; |
| 95 | int const attr = m_tx_vram[tile_index]; |
| 98 | 96 | int const code = attr & 0xfff; |
| 99 | 97 | int const color = attr >> 12; |
| 100 | 98 | |
| r241921 | r241922 | |
| 104 | 102 | void prehisle_state::video_start() |
| 105 | 103 | { |
| 106 | 104 | // ROM-based background layer |
| 107 | | m_bg2_tilemap = &machine().tilemap().create( |
| 105 | m_bg_tilemap = &machine().tilemap().create( |
| 108 | 106 | m_gfxdecode, |
| 109 | | tilemap_get_info_delegate(FUNC(prehisle_state::get_bg2_tile_info), this), |
| 107 | tilemap_get_info_delegate(FUNC(prehisle_state::get_bg_tile_info), this), |
| 110 | 108 | TILEMAP_SCAN_COLS, // scan order |
| 111 | 109 | 16, 16, // tile size |
| 112 | 110 | 1024, 32); // tilemap size |
| 113 | 111 | |
| 114 | | // RAM-based background layer (overlays most sprites) |
| 115 | | m_bg_tilemap = &machine().tilemap().create( |
| 112 | // RAM-based foreground layer (overlays most sprites) |
| 113 | m_fg_tilemap = &machine().tilemap().create( |
| 116 | 114 | m_gfxdecode, |
| 117 | | tilemap_get_info_delegate(FUNC(prehisle_state::get_bg_tile_info), this), |
| 115 | tilemap_get_info_delegate(FUNC(prehisle_state::get_fg_tile_info), this), |
| 118 | 116 | TILEMAP_SCAN_COLS, // scan order |
| 119 | 117 | 16, 16, // tile size |
| 120 | 118 | 256, 32); // tilemap size |
| 121 | | m_bg_tilemap->set_transparent_pen(15); |
| 119 | m_fg_tilemap->set_transparent_pen(15); |
| 122 | 120 | |
| 123 | 121 | // text layer |
| 124 | | m_fg_tilemap = &machine().tilemap().create( |
| 122 | m_tx_tilemap = &machine().tilemap().create( |
| 125 | 123 | m_gfxdecode, |
| 126 | | tilemap_get_info_delegate(FUNC(prehisle_state::get_fg_tile_info), this), |
| 124 | tilemap_get_info_delegate(FUNC(prehisle_state::get_tx_tile_info), this), |
| 127 | 125 | TILEMAP_SCAN_ROWS, // scan order |
| 128 | 126 | 8, 8, // tile size |
| 129 | 127 | 32, 32); // tilemap size |
| 130 | | m_fg_tilemap->set_transparent_pen(15); |
| 128 | m_tx_tilemap->set_transparent_pen(15); |
| 131 | 129 | |
| 132 | 130 | /* register for saving */ |
| 133 | 131 | save_item(NAME(m_invert_controls)); |
| r241921 | r241922 | |
| 147 | 145 | { |
| 148 | 146 | UINT16 const *const spriteram16 = m_spriteram; |
| 149 | 147 | |
| 150 | | for (int offs = 0; offs < 1024; offs += 4) |
| 148 | for (int offs = 1024 - 4; offs >= 0; offs -= 4) |
| 151 | 149 | { |
| 152 | 150 | int const attr = spriteram16[offs + 2]; |
| 153 | 151 | int const code = attr & 0x1fff; |
| 154 | 152 | int const color = spriteram16[offs + 3] >> 12; |
| 155 | | int const priority = (color < 0x4) ? 0x04 : 0x06; |
| 153 | int const priority = (color < 0x4) ? 0 : GFX_PMASK_1; // correct? |
| 156 | 154 | bool flipx = attr & 0x4000; |
| 157 | 155 | bool flipy = attr & 0x8000; |
| 158 | 156 | int sx = spriteram16[offs + 1] & 0x1ff; |
| r241921 | r241922 | |
| 184 | 182 | { |
| 185 | 183 | screen.priority().fill(0, cliprect); |
| 186 | 184 | |
| 187 | | m_bg2_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 188 | | m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 1); |
| 189 | | m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 2); |
| 185 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 186 | m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 1); |
| 190 | 187 | draw_sprites(screen, bitmap, cliprect); |
| 191 | | |
| 188 | m_tx_tilemap->draw(screen, bitmap, cliprect, 0); |
| 192 | 189 | return 0; |
| 193 | 190 | } |