Previous 199869 Revisions Next

r33410 Sunday 16th November, 2014 at 09:19:09 UTC by Alex W. Jackson
drawgfx.h: Long-overdue documentation about how to use priority-masked
drawing (aka pdrawgfx); add some useful constants. [Alex Jackson]

(nw)
prehisle.c: Fix issues introduced by pdrawgfx conversion; use
required_region_ptr instead of runtime tag lookup; give gfx regions
more meaningful names; remove superfluous "prehisle"'s and "16"'s
from member names (it's been many years since you could accidentally
plug a handler of the wrong width into an address map and not have
the core catch you at compile time)
[src/emu]drawgfx.h
[src/mame/drivers]prehisle.c
[src/mame/includes]prehisle.h
[src/mame/video]prehisle.c

trunk/src/emu/drawgfx.h
r241921r241922
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
99
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
10113*********************************************************************/
11114
12115#pragma once
r241921r241922
30133   DRAWMODE_SHADOW
31134};
32135
136enum
137{
138   GFX_PMASK_1  = 0xaaaa,
139   GFX_PMASK_2  = 0xcccc,
140   GFX_PMASK_4  = 0xf0f0,
141   GFX_PMASK_8  = 0xff00
142};
33143
34144
35145/***************************************************************************
trunk/src/mame/drivers/prehisle.c
r241921r241922
1616
1717/******************************************************************************/
1818
19WRITE16_MEMBER(prehisle_state::prehisle_sound16_w)
19WRITE16_MEMBER(prehisle_state::soundcmd_w)
2020{
2121   soundlatch_byte_w(space, 0, data & 0xff);
2222   m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
r241921r241922
2727static ADDRESS_MAP_START( prehisle_map, AS_PROGRAM, 16, prehisle_state )
2828   AM_RANGE(0x000000, 0x03ffff) AM_ROM
2929   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")
3131   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")
3333   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)
3737ADDRESS_MAP_END
3838
3939/******************************************************************************/
r241921r241922
182182};
183183
184184static 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 )
189189GFXDECODE_END
190190
191191/******************************************************************************/
r241921r241922
243243   ROM_REGION( 0x10000, "audiocpu", 0 )    /* Sound CPU */
244244   ROM_LOAD( "gt1.1",  0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) )
245245
246   ROM_REGION( 0x008000, "gfx1", 0 )
246   ROM_REGION( 0x008000, "chars", 0 )
247247   ROM_LOAD( "gt15.b15",   0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) )
248248
249   ROM_REGION( 0x040000, "gfx2", 0 )
249   ROM_REGION( 0x040000, "bgtiles", 0 )
250250   ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) )
251251
252   ROM_REGION( 0x040000, "gfx3", 0 )
252   ROM_REGION( 0x040000, "fgtiles", 0 )
253253   ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) )
254254
255   ROM_REGION( 0x0a0000, "gfx4", 0 )
255   ROM_REGION( 0x0a0000, "sprites", 0 )
256256   ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) )
257257   ROM_LOAD( "gt5.5",      0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) )
258258
259   ROM_REGION( 0x10000, "gfx5", 0 )    /* background tilemaps */
259   ROM_REGION( 0x10000, "bgtilemap", 0 )    /* background tilemaps */
260260   ROM_LOAD( "gt11.11",  0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) )
261261
262262   ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */
r241921r241922
271271   ROM_REGION( 0x10000, "audiocpu", 0 )    /* Sound CPU */
272272   ROM_LOAD( "gt1.1",  0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) )
273273
274   ROM_REGION( 0x008000, "gfx1", 0 )
274   ROM_REGION( 0x008000, "chars", 0 )
275275   ROM_LOAD( "gt15.b15",   0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) )
276276
277   ROM_REGION( 0x040000, "gfx2", 0 )
277   ROM_REGION( 0x040000, "bgtiles", 0 )
278278   ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) )
279279
280   ROM_REGION( 0x040000, "gfx3", 0 )
280   ROM_REGION( 0x040000, "fgtiles", 0 )
281281   ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) )
282282
283   ROM_REGION( 0x0a0000, "gfx4", 0 )
283   ROM_REGION( 0x0a0000, "sprites", 0 )
284284   ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) )
285285   ROM_LOAD( "gt5.5",      0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) )
286286
287   ROM_REGION( 0x10000, "gfx5", 0 )    /* background tilemaps */
287   ROM_REGION( 0x10000, "bgtilemap", 0 )    /* background tilemaps */
288288   ROM_LOAD( "gt11.11",  0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) )
289289
290290   ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */
r241921r241922
299299   ROM_REGION( 0x10000, "audiocpu", 0 )    /* Sound CPU */
300300   ROM_LOAD( "gt1.1",  0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) )
301301
302   ROM_REGION( 0x008000, "gfx1", 0 )
302   ROM_REGION( 0x008000, "chars", 0 )
303303   ROM_LOAD( "gt15.b15",   0x000000, 0x08000, BAD_DUMP CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) ) // not dumped, missing korean text
304304
305   ROM_REGION( 0x040000, "gfx2", 0 )
305   ROM_REGION( 0x040000, "bgtiles", 0 )
306306   ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) )
307307
308   ROM_REGION( 0x040000, "gfx3", 0 )
308   ROM_REGION( 0x040000, "fgtiles", 0 )
309309   ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) )
310310
311   ROM_REGION( 0x0a0000, "gfx4", 0 )
311   ROM_REGION( 0x0a0000, "sprites", 0 )
312312   ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) )
313313   ROM_LOAD( "gt5.5",      0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) )
314314
315   ROM_REGION( 0x10000, "gfx5", 0 )    /* background tilemaps */
315   ROM_REGION( 0x10000, "bgtilemap", 0 )    /* background tilemaps */
316316   ROM_LOAD( "gt11.11",  0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) )
317317
318318   ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */
r241921r241922
327327   ROM_REGION( 0x10000, "audiocpu", 0 )    /* Sound CPU */
328328   ROM_LOAD( "gt1.1",  0x000000, 0x10000, CRC(80a4c093) SHA1(abe59e43259eb80b504bd5541f58cd0e5eb998ab) )
329329
330   ROM_REGION( 0x008000, "gfx1", 0 )
330   ROM_REGION( 0x008000, "chars", 0 )
331331   ROM_LOAD( "gt15.b15",   0x000000, 0x08000, CRC(ac652412) SHA1(916c04c3a8a7bfb961313ab73c0a27d7f5e48de1) )
332332
333   ROM_REGION( 0x040000, "gfx2", 0 )
333   ROM_REGION( 0x040000, "bgtiles", 0 )
334334   ROM_LOAD( "pi8914.b14", 0x000000, 0x40000, CRC(207d6187) SHA1(505dfd1424b894e7b898f91b89f021ddde433c48) )
335335
336   ROM_REGION( 0x040000, "gfx3", 0 )
336   ROM_REGION( 0x040000, "fgtiles", 0 )
337337   ROM_LOAD( "pi8916.h16", 0x000000, 0x40000, CRC(7cffe0f6) SHA1(aba08617964fc425418b098be5167021768bd47c) )
338338
339   ROM_REGION( 0x0a0000, "gfx4", 0 )
339   ROM_REGION( 0x0a0000, "sprites", 0 )
340340   ROM_LOAD( "pi8910.k14", 0x000000, 0x80000, CRC(5a101b0b) SHA1(9645ab1f8d058cf2c6c42ccb4ce92a9b5db10c51) )
341341   ROM_LOAD( "gt5.5",      0x080000, 0x20000, CRC(3d3ab273) SHA1(b5706ada9eb2c22fcc0ac8ede2d2ee02ee853191) )
342342
343   ROM_REGION( 0x10000, "gfx5", 0 )    /* background tilemaps */
343   ROM_REGION( 0x10000, "bgtilemap", 0 )    /* background tilemaps */
344344   ROM_LOAD( "gt11.11",  0x000000, 0x10000, CRC(b4f0fcf0) SHA1(b81cc0b6e3e6f5616789bb3e77807dc0ef718a38) )
345345
346346   ROM_REGION( 0x20000, "upd", 0 ) /* ADPCM samples */
trunk/src/mame/includes/prehisle.h
r241921r241922
55public:
66   prehisle_state(const machine_config &mconfig, device_type type, const char *tag)
77      : driver_device(mconfig, type, tag),
8      m_videoram(*this, "videoram"),
8      m_tx_vram(*this, "tx_vram"),
99      m_spriteram(*this, "spriteram"),
10      m_bg_videoram16(*this, "bg_videoram16"),
10      m_fg_vram(*this, "fg_vram"),
11      m_tilemap_rom(*this, "bgtilemap"),
1112      m_maincpu(*this, "maincpu"),
1213      m_audiocpu(*this, "audiocpu"),
1314      m_upd7759(*this, "upd"),
r241921r241922
1516      m_palette(*this, "palette") { }
1617
1718
18   required_shared_ptr<UINT16> m_videoram;
19   required_shared_ptr<UINT16> m_tx_vram;
1920   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;
2123   UINT16 m_invert_controls;
2224
23   tilemap_t *m_bg2_tilemap;
2425   tilemap_t *m_bg_tilemap;
2526   tilemap_t *m_fg_tilemap;
27   tilemap_t *m_tx_tilemap;
2628
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);
3234   DECLARE_WRITE8_MEMBER(D7759_write_port_0_w);
3335   DECLARE_WRITE8_MEMBER(D7759_upd_reset_w);
34   TILE_GET_INFO_MEMBER(get_bg2_tile_info);
3536   TILE_GET_INFO_MEMBER(get_bg_tile_info);
3637   TILE_GET_INFO_MEMBER(get_fg_tile_info);
38   TILE_GET_INFO_MEMBER(get_tx_tile_info);
3739   virtual void video_start();
3840   UINT32 screen_update_prehisle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3941   void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
trunk/src/mame/video/prehisle.c
r241921r241922
1010#include "includes/prehisle.h"
1111
1212
13WRITE16_MEMBER(prehisle_state::prehisle_bg_videoram16_w)
13WRITE16_MEMBER(prehisle_state::fg_vram_w)
1414{
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);
1717}
1818
19WRITE16_MEMBER(prehisle_state::prehisle_fg_videoram16_w)
19WRITE16_MEMBER(prehisle_state::tx_vram_w)
2020{
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);
2323}
2424
25READ16_MEMBER(prehisle_state::prehisle_control16_r)
25READ16_MEMBER(prehisle_state::control_r)
2626{
2727   switch (offset)
2828   {
r241921r241922
3535   }
3636}
3737
38WRITE16_MEMBER(prehisle_state::prehisle_control16_w)
38WRITE16_MEMBER(prehisle_state::control_w)
3939{
4040   int scroll = 0;
4141
r241921r241922
4343
4444   switch (offset)
4545   {
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;
5050   case 0x23: m_invert_controls = data ? 0x00ff : 0x0000; break;
5151   case 0x28: coin_counter_w(machine(), 0, data & 1); break;
5252   case 0x29: coin_counter_w(machine(), 1, data & 1); break;
r241921r241922
60600  .....xxx  gfx code high bits
61611  xxxxxxxx  gfx code low bits
6262*/
63TILE_GET_INFO_MEMBER(prehisle_state::get_bg2_tile_info)
63TILE_GET_INFO_MEMBER(prehisle_state::get_bg_tile_info)
6464{
65   UINT8 const *const tilerom = memregion("gfx5")->base();
66
6765   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;
7068   int const color = attr >> 12;
7169   int const flags = (attr & 0x800) ? TILE_FLIPX : 0;
7270
r241921r241922
78760  ....x... ........  flip y
79770  .....xxx xxxxxxxx  gfx code
8078*/
81TILE_GET_INFO_MEMBER(prehisle_state::get_bg_tile_info)
79TILE_GET_INFO_MEMBER(prehisle_state::get_fg_tile_info)
8280{
83   int const attr = m_bg_videoram16[tile_index];
81   int const attr = m_fg_vram[tile_index];
8482   int const code = attr & 0x7ff;
8583   int const color = attr >> 12;
8684   int const flags = (attr & 0x800) ? TILE_FLIPY : 0;
r241921r241922
92900  xxxx.... ........  color
93910  ....xxxx xxxxxxxx  gfx code
9492*/
95TILE_GET_INFO_MEMBER(prehisle_state::get_fg_tile_info)
93TILE_GET_INFO_MEMBER(prehisle_state::get_tx_tile_info)
9694{
97   int const attr = m_videoram[tile_index];
95   int const attr = m_tx_vram[tile_index];
9896   int const code = attr & 0xfff;
9997   int const color = attr >> 12;
10098
r241921r241922
104102void prehisle_state::video_start()
105103{
106104   // ROM-based background layer
107   m_bg2_tilemap = &machine().tilemap().create(
105   m_bg_tilemap = &machine().tilemap().create(
108106         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),
110108         TILEMAP_SCAN_COLS,      // scan order
111109         16, 16,                 // tile size
112110         1024, 32);              // tilemap size
113111
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(
116114         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),
118116         TILEMAP_SCAN_COLS,      // scan order
119117         16, 16,                 // tile size
120118         256, 32);               // tilemap size
121   m_bg_tilemap->set_transparent_pen(15);
119   m_fg_tilemap->set_transparent_pen(15);
122120
123121   // text layer
124   m_fg_tilemap = &machine().tilemap().create(
122   m_tx_tilemap = &machine().tilemap().create(
125123         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),
127125         TILEMAP_SCAN_ROWS,      // scan order
128126         8, 8,                   // tile size
129127         32, 32);                // tilemap size
130   m_fg_tilemap->set_transparent_pen(15);
128   m_tx_tilemap->set_transparent_pen(15);
131129
132130   /* register for saving */
133131   save_item(NAME(m_invert_controls));
r241921r241922
147145{
148146   UINT16 const *const spriteram16 = m_spriteram;
149147
150   for (int offs = 0; offs < 1024; offs += 4)
148   for (int offs = 1024 - 4; offs >= 0; offs -= 4)
151149   {
152150      int const attr = spriteram16[offs + 2];
153151      int const code = attr & 0x1fff;
154152      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?
156154      bool flipx = attr & 0x4000;
157155      bool flipy = attr & 0x8000;
158156      int sx = spriteram16[offs + 1] & 0x1ff;
r241921r241922
184182{
185183   screen.priority().fill(0, cliprect);
186184
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);
190187   draw_sprites(screen, bitmap, cliprect);
191
188   m_tx_tilemap->draw(screen, bitmap, cliprect, 0);
192189   return 0;
193190}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team