Previous 199869 Revisions Next

r30617 Friday 23rd May, 2014 at 11:18:43 UTC by David Haywood
push the bootlegs through a common code path (nw)
[src/mame/drivers]galspnbl.c
[src/mame/includes]galspnbl.h
[src/mame/video]galspnbl.c tecmo_spr.c tecmo_spr.h

trunk/src/mame/drivers/galspnbl.c
r30616r30617
236236   MCFG_SCREEN_UPDATE_DRIVER(galspnbl_state, screen_update_galspnbl)
237237   MCFG_SCREEN_PALETTE("palette")
238238
239   MCFG_VIDEO_START_OVERRIDE(galspnbl_state,galspnbl)
239240
240241   MCFG_GFXDECODE_ADD("gfxdecode", "palette", galspnbl)
241242
r30616r30617
245246
246247   MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0)
247248   MCFG_TECMO_SPRITE_GFX_REGION(1)
249   MCFG_TECMO_SPRITE_BOOTLEG(1)
248250
249251   /* sound hardware */
250252   MCFG_SPEAKER_STANDARD_MONO("mono")
trunk/src/mame/includes/galspnbl.h
r30616r30617
2121      m_maincpu(*this, "maincpu"),
2222      m_gfxdecode(*this, "gfxdecode"),
2323      m_palette(*this, "palette"),
24      m_sprgen(*this, "spritegen")
24      m_sprgen(*this, "spritegen"),
25      m_screen(*this, "screen")
2526      { }
2627
2728   /* memory pointers */
r30616r30617
4344   required_device<gfxdecode_device> m_gfxdecode;
4445   required_device<palette_device> m_palette;
4546   required_device<tecmo_spr_device> m_sprgen;
47   required_device<screen_device> m_screen;
48   bitmap_ind16 m_sprite_bitmap;
49   DECLARE_VIDEO_START(galspnbl);
4650
51   void mix_sprite_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
52
4753};
trunk/src/mame/video/galspnbl.c
r30616r30617
2828   }
2929}
3030
31VIDEO_START_MEMBER(galspnbl_state,galspnbl)
32{
33   /* allocate bitmaps */
34   m_screen->register_screen_bitmap(m_sprite_bitmap);
35}
3136
37void galspnbl_state::mix_sprite_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri)
38{
39   for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
40   {
41      UINT16 *dd = &bitmap.pix16(y);
42      UINT16 *sd2 = &m_sprite_bitmap.pix16(y);
43
44      for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
45      {
46         UINT16 sprpixel = (sd2[x]);
47         //UINT16 sprpri = (sprpixel >> 8) & 3;
48         UINT16 sprpri = (sprpixel >> 9) & 1; // only upper priority bit matters on the bootleg hw?
49         
50         sprpixel &= 0xff;
51
52         if (sprpixel & 0xf)
53         {
54            if (sprpri == pri)
55               dd[x] = sprpixel;
56         }
57
58         //   UINT16 sprbln = (sprpixel >> 10) & 1; // we handle 'blending' from the original as a simple on/off flicker in the bootleg sprite function, I don't think the bootleg hw can blend
59      }
60   }
61}
62
3263UINT32 galspnbl_state::screen_update_galspnbl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
3364{
3465   int offs;
66   m_sprite_bitmap.fill(0, cliprect);
67   m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, cliprect, m_spriteram, 0, 0, flip_screen(), m_sprite_bitmap);
3568
69
3670   draw_background(bitmap, cliprect);
3771
38   m_sprgen->galspnbl_draw_sprites(screen, m_gfxdecode, bitmap, cliprect, 0,  m_spriteram, m_spriteram.bytes());
72   mix_sprite_layer(screen, bitmap, cliprect, 0);
3973
4074   for (offs = 0; offs < 0x1000 / 2; offs++)
4175   {
r30616r30617
4781      sx = offs % 64;
4882      sy = offs / 64;
4983
50      /* What is this? A priority/half transparency marker? */
84      /* What is this? A priority/half transparency marker? */ // leftover blend flags from original spbactn game
5185      if (!(attr & 0x0008))
5286      {
5387         m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
r30616r30617
5993      }
6094   }
6195
62   m_sprgen->galspnbl_draw_sprites(screen, m_gfxdecode, bitmap, cliprect, 1, m_spriteram, m_spriteram.bytes());
96   mix_sprite_layer(screen, bitmap, cliprect, 1);
97
98
6399   return 0;
64100}
trunk/src/mame/video/tecmo_spr.c
r30616r30617
11/* Various Tecmo Sprite implementations
2 - for unifying and converting to a device
32
43 - check wc90.c, tecmo.c, tbowl.c others? - they seem more significantly different but are they close to each other
54   (but at the same time use the same 'layout' table as this implementation)
r30616r30617
1918tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
2019   : device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__),
2120      device_video_interface(mconfig, *this),
22      m_gfxregion(0)
21m_gfxregion(0),
22m_bootleg(0)
2323{
2424}
2525
r30616r30617
3939   dev.m_gfxregion = gfxregion;
4040}
4141
42void tecmo_spr_device::set_bootleg(device_t &device, int bootleg)
43{
44   tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device);
45   dev.m_bootleg = bootleg;
46}
4247
48
4349static const UINT8 layout[8][8] =
4450{
45   { 0, 1, 4, 5,16,17,20,21},
46   { 2, 3, 6, 7,18,19,22,23},
47   { 8, 9,12,13,24,25,28,29},
48   {10,11,14,15,26,27,30,31},
49   {32,33,36,37,48,49,52,53},
50   {34,35,38,39,50,51,54,55},
51   {40,41,44,45,56,57,60,61},
52   {42,43,46,47,58,59,62,63}
51   { 0, 1, 4, 5, 16, 17, 20, 21 },
52   { 2, 3, 6, 7, 18, 19, 22, 23 },
53   { 8, 9, 12, 13, 24, 25, 28, 29 },
54   { 10, 11, 14, 15, 26, 27, 30, 31 },
55   { 32, 33, 36, 37, 48, 49, 52, 53 },
56   { 34, 35, 38, 39, 50, 51, 54, 55 },
57   { 40, 41, 44, 45, 56, 57, 60, 61 },
58   { 42, 43, 46, 47, 58, 59, 62, 63 }
5359};
5460
5561
r30616r30617
7480
7581#define NUM_SPRITES 256
7682
77void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, bitmap_ind16 &sprite_bitmap )
83void tecmo_spr_device::gaiden_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, bitmap_ind16 &sprite_bitmap)
7884{
7985   gfx_element *gfx = gfxdecode->gfx(m_gfxregion);
8086   UINT16 *source;
r30616r30617
9399   int colour_word = 2;
94100   int yposition_word = 3;
95101   int xposition_word = 4;
96   int enable_word = attributes_word;
97102
98103   int xmask;
99104
r30616r30617
106111   while (count--)
107112   {
108113      UINT32 attributes = source[attributes_word];
109      int col,row;
114      int col, row;
110115
111      if (source[enable_word] & 0x04)
116      int enabled = source[attributes_word] & 0x04;
117
118      if (enabled)
119      {
120         if (m_bootleg == 1)
121         {
122            // I don't think the galspinbl / hotpinbl bootlegs have blending, instead they use this bit to flicker sprites on/off each frame, so handle it here (we can't handle it in the mixing)
123            // alternatively these sprites could just be disabled like the tiles marked with the 'mix' bit appear to be (they're only used for ball / flipper trails afaik)
124            if (source[attributes_word] & 0x0040)
125            {
126               int frame = screen.frame_number() & 1;
127               if (frame==1)
128                  enabled = 0;
129            }
130
131         }
132      }
133
134      if (enabled)
112135      {           
113136         UINT32 flipx = (attributes & 1);
114137         UINT32 flipy = (attributes & 2);
r30616r30617
184207   }
185208}
186209
187// comad bootleg of spbactn
188
189/* sprite format (galspnbl):
190 *
191 *  word        bit                 usage
192 * --------+-fedcba9876543210-+----------------
193 *    0    | ---------------x | flip x
194 *         | --------------x- | flip y
195 *         | -------------x-- | enable
196 *         | ----------xx---- | priority?
197 *         | ---------x------ | flicker?
198 *    1    | xxxxxxxxxxxxxxxx | code
199 *    2    | --------xxxx---- | color
200 *         | --------------xx | size: 8x8, 16x16, 32x32, 64x64
201 *    3    | xxxxxxxxxxxxxxxx | y position
202 *    4    | xxxxxxxxxxxxxxxx | x position
203 *    5,6,7|                  | unused
204 */
205
206void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes )
207{
208   int offs;
209
210
211   for (offs = (spriteram_bytes - 16) / 2; offs >= 0; offs -= 8)
212   {
213      int sx, sy, code, color, size, attr, flipx, flipy;
214      int col, row;
215
216      attr = spriteram[offs];
217      if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (screen.frame_number() & 1))
218//              && ((attr & 0x0030) >> 4) == priority)
219            && ((attr & 0x0020) >> 5) == priority)
220      {
221         code = spriteram[offs + 1];
222         color = spriteram[offs + 2];
223         size = 1 << (color & 0x0003); // 1,2,4,8
224         color = (color & 0x00f0) >> 4;
225//          sx = spriteram[offs + 4] + screenscroll;
226         sx = spriteram[offs + 4];
227         sy = spriteram[offs + 3];
228         flipx = attr & 0x0001;
229         flipy = attr & 0x0002;
230
231         for (row = 0; row < size; row++)
232         {
233            for (col = 0; col < size; col++)
234            {
235               int x = sx + 8 * (flipx ? (size - 1 - col) : col);
236               int y = sy + 8 * (flipy ? (size - 1 - row) : row);
237               gfxdecode->gfx(m_gfxregion)->transpen(bitmap,cliprect,
238                  code + layout[row][col],
239                  color,
240                  flipx,flipy,
241                  x,y,0);
242
243            }
244         }
245      }
246   }
247}
trunk/src/mame/video/tecmo_spr.h
r30616r30617
88public:
99   tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
1010   static void set_gfx_region(device_t &device, int gfxregion);
11   static void set_bootleg(device_t &device, int bootleg);
1112
12   void galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes );
1313   void gaiden_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, bitmap_ind16 &sprite_bitmap);
1414
1515protected:
r30616r30617
1717   virtual void device_reset();
1818
1919   UINT8 m_gfxregion;
20   int m_bootleg; // for Gals Pinball / Hot Pinball
2021
2122private:
2223};
r30616r30617
2728#define MCFG_TECMO_SPRITE_GFX_REGION(_region) \
2829   tecmo_spr_device::set_gfx_region(*device, _region);
2930
31#define MCFG_TECMO_SPRITE_BOOTLEG(_bootleg) \
32   tecmo_spr_device::set_bootleg(*device, _bootleg);
33
34
35

Previous 199869 Revisions Next


© 1997-2024 The MAME Team