Previous 199869 Revisions Next

r33615 Monday 1st December, 2014 at 20:30:22 UTC by David Haywood
unify sprite handling between bionicc, tigeroad, supduck etc. (nw)
[src/mame]mame.mak
[src/mame/drivers]bionicc.c supduck.c tigeroad.c
[src/mame/includes]bionicc.h tigeroad.h
[src/mame/video]bionicc.c tigeroad.c tigeroad_spr.c* tigeroad_spr.h*

trunk/src/mame/drivers/bionicc.c
r242126r242127
366366   MCFG_SCREEN_PALETTE("palette")
367367
368368   MCFG_GFXDECODE_ADD("gfxdecode", "palette", bionicc)
369
370   MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
371
369372   MCFG_PALETTE_ADD("palette", 1024)
370373
371
372374   MCFG_BUFFERED_SPRITERAM16_ADD("spriteram")
373375
374376   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mame/drivers/supduck.c
r242126r242127
2424#include "cpu/m68000/m68000.h"
2525#include "sound/okim6295.h"
2626#include "video/bufsprite.h"
27#include "video/tigeroad_spr.h"
2728
2829class supduck_state : public driver_device
2930{
r242126r242127
3738         m_fore_videoram(*this, "forevideoram"),
3839         m_back_videoram(*this, "backvideoram"),
3940         m_gfxdecode(*this, "gfxdecode"),
40         m_palette(*this, "palette")
41         m_palette(*this, "palette"),
42         m_spritegen(*this, "spritegen")
4143   { }
4244
4345   // devices
r242126r242127
5254
5355   required_device<gfxdecode_device> m_gfxdecode;
5456   required_device<palette_device> m_palette;
57   required_device<tigeroad_spr_device> m_spritegen;
5558
5659   tilemap_t     *m_text_tilemap;
5760   tilemap_t     *m_fore_tilemap;
r242126r242127
7982
8083   virtual void video_start();
8184
82   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
8385   TILE_GET_INFO_MEMBER(get_text_tile_info);
8486   TILE_GET_INFO_MEMBER(get_fore_tile_info);
8587   TILE_GET_INFO_MEMBER(get_back_tile_info);
r242126r242127
124126   m_back_tilemap->draw(screen, bitmap, cliprect, 0, 0);
125127   m_fore_tilemap->draw(screen, bitmap, cliprect, 0, 0);
126128
129   m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 3, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 1 );
127130
128   draw_sprites(bitmap, cliprect, 0);
129   draw_sprites(bitmap, cliprect, 1); //draw priority sprites?
130
131131   m_text_tilemap->draw(screen, bitmap, cliprect, 0, 0);
132132   return 0;
133133}
r242126r242127
197197}
198198
199199
200void supduck_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
201{
202   UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4;
203   UINT16 *finish = m_spriteram->buffer();
204200
205   while (source >= finish)
206   {
207      int tile_number = source[0];
208
209      if (tile_number != 0xfff) {
210         int attr = source[1];
211         int sy = source[2] & 0x1ff;
212         int sx = source[3] & 0x1ff;
213
214         int flipx = attr & 0x02;
215         int flipy = attr & 0x01;
216         int color = (attr >> 2) & 0x0f;
217
218         if (sx > 0x100) sx -= 0x200;
219         if (sy > 0x100) sy -= 0x200;
220
221         if (flip_screen())
222         {
223            sx = 240 - sx;
224            sy = 240 - sy;
225            flipx = !flipx;
226            flipy = !flipy;
227         }
228
229
230            m_gfxdecode->gfx(3)->transpen(bitmap,cliprect,
231            tile_number,
232            color,
233            flipx, flipy,
234            sx, 240 - sy, 15);
235      }
236
237      source -= 4;
238   }
239}
240
241201WRITE16_MEMBER(supduck_state::supduck_4000_w)
242202{
243203}
r242126r242127
490450
491451   MCFG_GFXDECODE_ADD("gfxdecode", "palette", supduck)
492452
453   MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
454
493455   MCFG_PALETTE_ADD("palette", 0x800/2)
494456   MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit4)
495457
trunk/src/mame/drivers/tigeroad.c
r242126r242127
619619   MCFG_SCREEN_PALETTE("palette")
620620
621621   MCFG_GFXDECODE_ADD("gfxdecode", "palette", tigeroad)
622   
623   MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
622624
623625   MCFG_PALETTE_ADD("palette", 1024)
624626   MCFG_PALETTE_FORMAT(xxxxRRRRGGGGBBBB)
r242126r242127
680682
681683   MCFG_GFXDECODE_ADD("gfxdecode", "palette", tigeroad)
682684
685   MCFG_DEVICE_ADD("spritegen", TIGEROAD_SPRITE, 0)
686
683687   MCFG_PALETTE_ADD("palette", 1024)
684688   MCFG_PALETTE_FORMAT(xxxxRRRRGGGGBBBB)
685689
trunk/src/mame/includes/bionicc.h
r242126r242127
55***************************************************************************/
66
77#include "video/bufsprite.h"
8#include "video/tigeroad_spr.h"
89
910class bionicc_state : public driver_device
1011{
r242126r242127
1819      m_paletteram(*this, "paletteram"),
1920      m_maincpu(*this, "maincpu"),
2021      m_gfxdecode(*this, "gfxdecode"),
21      m_palette(*this, "palette") { }
22      m_palette(*this, "palette"),
23      m_spritegen(*this, "spritegen")   
24   { }
2225
2326   /* memory pointers */
2427   required_device<buffered_spriteram16_device> m_spriteram;
r242126r242127
5558   virtual void video_start();
5659   UINT32 screen_update_bionicc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5760   TIMER_DEVICE_CALLBACK_MEMBER(bionicc_scanline);
58   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect );
5961   required_device<cpu_device> m_maincpu;
6062   required_device<gfxdecode_device> m_gfxdecode;
6163   required_device<palette_device> m_palette;
64   required_device<tigeroad_spr_device> m_spritegen;
6265};
trunk/src/mame/includes/tigeroad.h
r242126r242127
55#include "sound/2203intf.h"
66#include "sound/msm5205.h"
77#include "cpu/m6805/m6805.h"
8#include "video/tigeroad_spr.h"
89
910class tigeroad_state : public driver_device
1011{
r242126r242127
2021      m_gfxdecode(*this, "gfxdecode"),
2122      m_palette(*this, "palette"),
2223      m_mcu(*this, "mcu"),
24      m_spritegen(*this, "spritegen"),
2325      m_has_coinlock(1)
2426   { }
2527
r242126r242127
4345   TILEMAP_MAPPER_MEMBER(tigeroad_tilemap_scan);
4446   virtual void video_start();
4547   UINT32 screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
46   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
4748   void f1dream_protection_w(address_space &space);
4849   DECLARE_WRITE_LINE_MEMBER(irqhandler);
4950   required_device<cpu_device> m_maincpu;
r242126r242127
5253   required_device<gfxdecode_device> m_gfxdecode;
5354   required_device<palette_device> m_palette;
5455   optional_device<cpu_device> m_mcu;
56   required_device<tigeroad_spr_device> m_spritegen;
5557
5658   UINT16     m_control[2];
5759
trunk/src/mame/mame.mak
r242126r242127
988988   $(DRIVERS)/alien.o \
989989   $(DRIVERS)/bionicc.o $(VIDEO)/bionicc.o \
990990   $(DRIVERS)/supduck.o \
991   $(VIDEO)/tigeroad_spr.o \
991992   $(DRIVERS)/blktiger.o $(VIDEO)/blktiger.o \
992993   $(DRIVERS)/cbasebal.o $(VIDEO)/cbasebal.o \
993994   $(DRIVERS)/commando.o $(VIDEO)/commando.o \
trunk/src/mame/video/bionicc.c
r242126r242127
185185
186186***************************************************************************/
187187
188void bionicc_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
189{
190   UINT16 *buffered_spriteram = m_spriteram->buffer();
191   int offs;
192   gfx_element *gfx = m_gfxdecode->gfx(3);
193188
194   for (offs = (m_spriteram->bytes() - 8) / 2; offs >= 0; offs -= 4)
195   {
196      int tile_number = buffered_spriteram[offs] & 0x7ff;
197      if( tile_number != 0x7ff )
198      {
199         int attr = buffered_spriteram[offs + 1];
200         int color = (attr & 0x3c) >> 2;
201         int flipx = attr & 0x02;
202         int flipy = 0;
203         int sx = (INT16)buffered_spriteram[offs + 3];   /* signed */
204         int sy = (INT16)buffered_spriteram[offs + 2];   /* signed */
205189
206         if (sy > 512 - 16)
207            sy -= 512;
208
209         if (flip_screen())
210         {
211            sx = 240 - sx;
212            sy = 240 - sy;
213            flipx = !flipx;
214            flipy = !flipy;
215         }
216
217         gfx->transpen(bitmap,cliprect,
218            tile_number,
219            color,
220            flipx,flipy,
221            sx,sy,15);
222      }
223   }
224}
225
226190UINT32 bionicc_state::screen_update_bionicc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
227191{
228192   bitmap.fill(m_palette->black_pen(), cliprect);
229193   m_fg_tilemap->draw(screen, bitmap, cliprect, 1 | TILEMAP_DRAW_LAYER1, 0);   /* nothing in FRONT */
230194   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
231195   m_fg_tilemap->draw(screen, bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER1, 0);
232   draw_sprites(bitmap, cliprect);
196   m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 3, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 0 );
233197   m_fg_tilemap->draw(screen, bitmap, cliprect, 0 | TILEMAP_DRAW_LAYER0, 0);
234198   m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0);
235199   return 0;
trunk/src/mame/video/tigeroad.c
r242126r242127
6666   }
6767}
6868
69void tigeroad_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority )
70{
71   UINT16 *source = &m_spriteram->buffer()[m_spriteram->bytes()/2] - 4;
72   UINT16 *finish = m_spriteram->buffer();
7369
74   while (source >= finish)
75   {
76      int tile_number = source[0];
7770
78      if (tile_number != 0xfff) {
79         int attr = source[1];
80         int sy = source[2] & 0x1ff;
81         int sx = source[3] & 0x1ff;
82
83         int flipx = attr & 0x02;
84         int flipy = attr & 0x01;
85         int color = (attr >> 2) & 0x0f;
86
87         if (sx > 0x100) sx -= 0x200;
88         if (sy > 0x100) sy -= 0x200;
89
90         if (flip_screen())
91         {
92            sx = 240 - sx;
93            sy = 240 - sy;
94            flipx = !flipx;
95            flipy = !flipy;
96         }
97
98
99            m_gfxdecode->gfx(2)->transpen(bitmap,cliprect,
100            tile_number,
101            color,
102            flipx, flipy,
103            sx, 240 - sy, 15);
104      }
105
106      source -= 4;
107   }
108}
109
11071TILE_GET_INFO_MEMBER(tigeroad_state::get_bg_tile_info)
11172{
11273   UINT8 *tilerom = memregion("bgmap")->base();
r242126r242127
156117UINT32 tigeroad_state::screen_update_tigeroad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
157118{
158119   m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
159   draw_sprites(bitmap, cliprect, 0);
120   m_spritegen->draw_sprites(bitmap, cliprect, m_gfxdecode, 2, m_spriteram->buffer(), m_spriteram->bytes(), flip_screen(), 1 );
160121   m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1);
161   //draw_sprites(bitmap, cliprect, 1); draw priority sprites?
162122   m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 2);
163123   return 0;
164124}
125
trunk/src/mame/video/tigeroad_spr.c
r0r242127
1/*
2
3   very simple sprite scheme, used by some Capcom games and hardware cloned from them
4
5   bionicc.c
6   tigeroad.c
7   supduck.c
8
9   it is unknown if this is handled by a custom chip, or simple logic.
10   y positions are inverted in Bionic Commando, but it seems otherwise the same as
11   Tiger Road
12
13*/
14
15
16#include "emu.h"
17#include "tigeroad_spr.h"
18
19
20const device_type TIGEROAD_SPRITE = &device_creator<tigeroad_spr_device>;
21
22tigeroad_spr_device::tigeroad_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, TIGEROAD_SPRITE, "Simple Capcom (Tiger Road) Sprite", tag, owner, clock, "tigeroad_spr", __FILE__)
24{
25}
26
27
28void tigeroad_spr_device::device_start()
29{
30}
31
32
33
34void tigeroad_spr_device::device_reset()
35{
36}
37
38/*
39   4  words per sprite
40
41   0  ---- ---t tttt tttt = tile number
42   
43   1  ---- ---- --cc cc-- = colour
44   1  ---- ---- ---- --x- = flip x
45   1  ---- ---- ---- ---y = flip y
46
47   2  ---- ---x xxxx xxxx = x pos (signed)
48
49   3  ---- ---y yyyy yyyy = y pos (signed)
50
51*/
52
53
54void tigeroad_spr_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int region, UINT16* ram, UINT32 size, int flip_screen, int rev_y )
55{
56   UINT16 *source = &ram[size/2] - 4;
57   UINT16 *finish = ram;
58
59   while (source >= finish)
60   {
61      int tile_number = source[0];
62
63      int attr = source[1];
64      int sy = source[2] & 0x1ff;
65      int sx = source[3] & 0x1ff;
66
67      int flipx = attr & 0x02;
68      int flipy = attr & 0x01;
69      int color = (attr >> 2) & 0x0f;
70
71      if (sx > 0x100) sx -= 0x200;
72      if (sy > 0x100) sy -= 0x200;
73
74      if (flip_screen)
75      {
76         sx = 240 - sx;
77         sy = 240 - sy;
78         flipx = !flipx;
79         flipy = !flipy;
80      }
81
82      if (rev_y)
83         sy = 240 - sy;
84
85
86      gfxdecode->gfx(region)->transpen(bitmap,cliprect,
87      tile_number,
88      color,
89      flipx, flipy,
90      sx, sy, 15);
91
92      source -= 4;
93   }
94}
trunk/src/mame/video/tigeroad_spr.h
r0r242127
1
2class tigeroad_spr_device : public device_t
3{
4public:
5   tigeroad_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
6
7   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int region, UINT16* ram, UINT32 size, int flip_screen, int rev_y);
8
9protected:
10
11   virtual void device_start();
12   virtual void device_reset();
13private:
14};
15
16extern const device_type TIGEROAD_SPRITE;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team