Previous 199869 Revisions Next

r36186 Monday 2nd March, 2015 at 17:27:30 UTC by Osso
jalblend.c: converted to be a device (nw)
[src/mame/drivers]argus.c psychic5.c
[src/mame/includes]argus.h psychic5.h
[src/mame/video]argus.c jalblend.c jalblend.h psychic5.c

trunk/src/mame/drivers/argus.c
r244697r244698
548548
549549   MCFG_GFXDECODE_ADD("gfxdecode", "palette", argus)
550550   MCFG_PALETTE_ADD("palette", 896)
551   
552   MCFG_DEVICE_ADD("blend", JALECO_BLEND, 0)
551553
552554   MCFG_VIDEO_START_OVERRIDE(argus_state,argus)
553555   MCFG_VIDEO_RESET_OVERRIDE(argus_state,argus)
r244697r244698
592594
593595   MCFG_GFXDECODE_ADD("gfxdecode", "palette", valtric)
594596   MCFG_PALETTE_ADD("palette", 768)
597   
598   MCFG_DEVICE_ADD("blend", JALECO_BLEND, 0)
595599
596600   MCFG_VIDEO_START_OVERRIDE(argus_state,valtric)
597601   MCFG_VIDEO_RESET_OVERRIDE(argus_state,valtric)
r244697r244698
636640
637641   MCFG_GFXDECODE_ADD("gfxdecode", "palette", butasan)
638642   MCFG_PALETTE_ADD("palette", 768)
643   
644   MCFG_DEVICE_ADD("blend", JALECO_BLEND, 0)
639645
640646   MCFG_VIDEO_START_OVERRIDE(argus_state,butasan)
641647   MCFG_VIDEO_RESET_OVERRIDE(argus_state,butasan)
trunk/src/mame/drivers/psychic5.c
r244697r244698
722722   MCFG_GFXDECODE_ADD("gfxdecode", "palette", psychic5)
723723   MCFG_PALETTE_ADD("palette", 768)
724724
725   MCFG_DEVICE_ADD("blend", JALECO_BLEND, 0)
726
725727   MCFG_VIDEO_START_OVERRIDE(psychic5_state,psychic5)
726728   MCFG_VIDEO_RESET_OVERRIDE(psychic5_state,psychic5)
727729
trunk/src/mame/includes/argus.h
r244697r244698
1#include "video/jalblend.h"
2
13class argus_state : public driver_device
24{
35public:
r244697r244698
810      m_gfxdecode(*this, "gfxdecode"),
911      m_screen(*this, "screen"),
1012      m_palette(*this, "palette"),
13      m_blend(*this, "blend"),
1114      m_bg0_scrollx(*this, "bg0_scrollx"),
1215      m_bg0_scrolly(*this, "bg0_scrolly"),
1316      m_bg1_scrollx(*this, "bg1_scrollx"),
r244697r244698
2326   required_device<gfxdecode_device> m_gfxdecode;
2427   required_device<screen_device> m_screen;
2528   required_device<palette_device> m_palette;
29   required_device<jaleco_blend_device> m_blend;
2630
2731   optional_shared_ptr<UINT8> m_bg0_scrollx;
2832   optional_shared_ptr<UINT8> m_bg0_scrolly;
trunk/src/mame/includes/psychic5.h
r244697r244698
11#include "machine/bankdev.h"
2#include "video/jalblend.h"
23
34class psychic5_state : public driver_device
45{
r244697r244698
1011      m_gfxdecode(*this, "gfxdecode"),
1112      m_palette(*this, "palette"),
1213      m_vrambank(*this, "vrambank"),
14      m_blend(*this, "blend"),
1315      m_spriteram(*this, "spriteram"),
1416      m_fg_videoram(*this, "fg_videoram"),
1517      m_bg_videoram(*this, "bg_videoram"),
r244697r244698
2527   required_device<gfxdecode_device> m_gfxdecode;
2628   required_device<palette_device> m_palette;
2729   optional_device<address_map_bank_device> m_vrambank;
30   optional_device<jaleco_blend_device> m_blend;
31   
2832   required_shared_ptr<UINT8> m_spriteram;
2933   required_shared_ptr<UINT8> m_fg_videoram;
3034   required_shared_ptr<UINT8> m_bg_videoram;
r244697r244698
8387   void change_bg_palette(int color, int lo_offs, int hi_offs);
8488   void set_background_palette_intensity();
8589   void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
86   void draw_background(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
90   void draw_background(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); //only used by psychic5
8791};
trunk/src/mame/video/argus.c
r244697r244698
114114***************************************************************************/
115115
116116#include "emu.h"
117#include "video/jalblend.h"
118117#include "includes/argus.h"
119118
120119
r244697r244698
271270   /* dummy RAM for back ground */
272271   m_dummy_bg0ram = auto_alloc_array(machine(), UINT8, 0x800);
273272
274   jal_blend_init(machine(), 1);
275   
276273   save_item(NAME(m_bg_status));
277274   save_item(NAME(m_flipscreen));
278275   save_item(NAME(m_palette_intensity));
r244697r244698
301298
302299   m_screen->register_screen_bitmap(m_mosaicbitmap);
303300
304   jal_blend_init(machine(), 1);
305   
306301   save_item(NAME(m_bg_status));
307302   save_item(NAME(m_flipscreen));
308303   save_item(NAME(m_palette_intensity));
r244697r244698
335330   m_butasan_txram      = &m_butasan_pagedram[1][0x000];
336331   m_butasan_txbackram  = &m_butasan_pagedram[1][0x800];
337332
338   jal_blend_init(machine(), 1);
339   
340333   save_item(NAME(m_bg_status));
341334   save_item(NAME(m_flipscreen));
342335   save_item(NAME(m_palette_intensity));
r244697r244698
390383{
391384   UINT8 lo = m_paletteram[lo_offs];
392385   UINT8 hi = m_paletteram[hi_offs];
393   jal_blend_set(color, hi & 0x0f);
386   m_blend->set(color, hi & 0x0f);
394387   m_palette->set_pen_color(color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
395388}
396389
r244697r244698
426419      rgb = rgb_t(r,g,b);
427420   }
428421
429   rgb = jal_blend_func(rgb,irgb,ix);
422   rgb = m_blend->func(rgb,irgb,ix);
430423
431424   m_palette->set_pen_color(color,rgb);
432425}
r244697r244698
832825         }
833826
834827         if (priority != pri)
835            jal_blend_drawgfx(m_palette,
828            m_blend->drawgfx(m_palette,
836829                     bitmap,cliprect,m_gfxdecode->gfx(0),
837830                     tile,
838831                     color,
r244697r244698
956949            flipy = !flipy;
957950         }
958951
959         jal_blend_drawgfx(m_palette,
952         m_blend->drawgfx(m_palette,
960953                  bitmap,cliprect,m_gfxdecode->gfx(0),
961954                  tile,
962955                  color,
r244697r244698
1004997
1005998         if ((offs >= 0x100 && offs <= 0x2ff) || (offs >= 0x400 && offs <= 0x57f))
1006999         {
1007            jal_blend_drawgfx(m_palette,
1000            m_blend->drawgfx(m_palette,
10081001                     bitmap,cliprect,m_gfxdecode->gfx(0),
10091002                     tile,
10101003                     color,
r244697r244698
10181011            {
10191012               td = (fx) ? (1 - i) : i;
10201013
1021               jal_blend_drawgfx(m_palette,
1014               m_blend->drawgfx(m_palette,
10221015                        bitmap,cliprect,m_gfxdecode->gfx(0),
10231016                        tile + td,
10241017                        color,
r244697r244698
10381031                  else
10391032                     td = (fx) ? (i * 2) + 1 - j : i * 2 + j;
10401033
1041                  jal_blend_drawgfx(m_palette,
1034                  m_blend->drawgfx(m_palette,
10421035                           bitmap,cliprect,m_gfxdecode->gfx(0),
10431036                           tile + td,
10441037                           color,
r244697r244698
10591052                  else
10601053                     td = (fx) ? (i * 4) + 3 - j : i * 4 + j;
10611054
1062                  jal_blend_drawgfx(m_palette,
1055                  m_blend->drawgfx(m_palette,
10631056                           bitmap,cliprect,m_gfxdecode->gfx(0),
10641057                           tile + td,
10651058                           color,
trunk/src/mame/video/jalblend.c
r244697r244698
1414#include "emu.h"
1515#include "jalblend.h"
1616
17/*****************************************************************************
18    DEVICE INTERFACE
19*****************************************************************************/
1720
18/* each palette entry contains a fourth 'alpha' value */
19static UINT8 *jal_blend_table;
2021
2122
22static void jal_blend_reset(running_machine &machine)
23const device_type JALECO_BLEND = &device_creator<jaleco_blend_device>;
24
25jaleco_blend_device::jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
26   : device_t(mconfig, JALECO_BLEND, "Jaleco Blending Device", tag, owner, clock, "jaleco_blend", __FILE__),
27   m_table(NULL)
2328{
24   memset(jal_blend_table, 0, 0xc00);
2529}
2630
27void jal_blend_init(running_machine &machine, int enable)
31//-------------------------------------------------
32//  device_start - device-specific startup
33//-------------------------------------------------
34
35void jaleco_blend_device::device_start()
2836{
29   if (enable)
30   {
31      jal_blend_table = auto_alloc_array_clear(machine, UINT8, 0xc00);
32      machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(jal_blend_reset), &machine));
33      machine.save().save_pointer(NAME(jal_blend_table), 0xc00);
34   }
35   else
36   {
37      jal_blend_table = NULL;
38   }
37   m_table = auto_alloc_array_clear(machine(), UINT8, 0xc00);
38   
39   save_pointer(NAME(m_table), 0xc00);
3940}
4041
41void jal_blend_set(int color, UINT8 val)
42//-------------------------------------------------
43//  device_reset - device-specific startup
44//-------------------------------------------------
45
46void jaleco_blend_device::device_reset()
4247{
43   if (jal_blend_table) jal_blend_table[color] = val;
48   memset(m_table, 0, 0xc00);
4449}
4550
51void jaleco_blend_device::set(int color, UINT8 val)
52{
53   m_table[color] = val;
54}
55
4656/*
4757 * 'Alpha' Format
4858 * ------------------
r244697r244698
5666 */
5767
5868/* basically an add/subtract function with clamping */
59rgb_t jal_blend_func(rgb_t dest, rgb_t addMe, UINT8 alpha)
69rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe, UINT8 alpha)
6070{
6171   int r, g, b;
6272   int ir, ig, ib;
r244697r244698
8696}
8797
8898template<class _BitmapClass>
89void jal_blend_drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
99void jaleco_blend_device::drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
90100                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
91101                     int transparent_color)
92102{
93   if (jal_blend_table == NULL)
94   {
95      gfx->transpen(dest_bmp,clip,code,color,flipx,flipy,offsx,offsy,transparent_color);
96      return;
97   }
98
99103   /* Start drawing */
100   if (gfx)
101   {
102      const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
103      const UINT8 *alpha = &jal_blend_table[gfx->granularity() * (color % gfx->colors())];
104      const UINT8 *source_base = gfx->get_data(code % gfx->elements());
105      int x_index_base, y_index, sx, sy, ex, ey;
106      int xinc, yinc;
104   const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
105   const UINT8 *alpha = &m_table[gfx->granularity() * (color % gfx->colors())];
106   const UINT8 *source_base = gfx->get_data(code % gfx->elements());
107   int x_index_base, y_index, sx, sy, ex, ey;
108   int xinc, yinc;
107109
108      xinc = flipx ? -1 : 1;
109      yinc = flipy ? -1 : 1;
110   xinc = flipx ? -1 : 1;
111   yinc = flipy ? -1 : 1;
110112
111      x_index_base = flipx ? gfx->width()-1 : 0;
112      y_index = flipy ? gfx->height()-1 : 0;
113   x_index_base = flipx ? gfx->width()-1 : 0;
114   y_index = flipy ? gfx->height()-1 : 0;
113115
114      // start coordinates
115      sx = offsx;
116      sy = offsy;
116   // start coordinates
117   sx = offsx;
118   sy = offsy;
117119
118      // end coordinates
119      ex = sx + gfx->width();
120      ey = sy + gfx->height();
120   // end coordinates
121   ex = sx + gfx->width();
122   ey = sy + gfx->height();
121123
122      if (sx < clip.min_x)
123      { // clip left
124         int pixels = clip.min_x-sx;
125         sx += pixels;
126         x_index_base += xinc*pixels;
127      }
128      if (sy < clip.min_y)
129      { // clip top
130         int pixels = clip.min_y-sy;
131         sy += pixels;
132         y_index += yinc*pixels;
133      }
134      // NS 980211 - fixed incorrect clipping
135      if (ex > clip.max_x+1)
136      { // clip right
137         ex = clip.max_x+1;
138      }
139      if (ey > clip.max_y+1)
140      { // clip bottom
141         ey = clip.max_y+1;
142      }
124   if (sx < clip.min_x)
125   { // clip left
126      int pixels = clip.min_x-sx;
127      sx += pixels;
128      x_index_base += xinc*pixels;
129   }
130   if (sy < clip.min_y)
131   { // clip top
132      int pixels = clip.min_y-sy;
133      sy += pixels;
134      y_index += yinc*pixels;
135   }
136   // NS 980211 - fixed incorrect clipping
137   if (ex > clip.max_x+1)
138   { // clip right
139      ex = clip.max_x+1;
140   }
141   if (ey > clip.max_y+1)
142   { // clip bottom
143      ey = clip.max_y+1;
144   }
143145
144      if (ex > sx)
145      { // skip if inner loop doesn't draw anything
146         int x, y;
146   if (ex > sx)
147   { // skip if inner loop doesn't draw anything
148      int x, y;
147149
148         // taken from case 7: TRANSPARENCY_ALPHARANGE
149         for (y = sy; y < ey; y++)
150      // taken from case 7: TRANSPARENCY_ALPHARANGE
151      for (y = sy; y < ey; y++)
152      {
153         const UINT8 *source = source_base + y_index*gfx->rowbytes();
154         typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y);
155         int x_index = x_index_base;
156         for (x = sx; x < ex; x++)
150157         {
151            const UINT8 *source = source_base + y_index*gfx->rowbytes();
152            typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y);
153            int x_index = x_index_base;
154            for (x = sx; x < ex; x++)
158            int c = source[x_index];
159            if (c != transparent_color)
155160            {
156               int c = source[x_index];
157               if (c != transparent_color)
161               if (alpha[c] & 8)
158162               {
159                  if (alpha[c] & 8)
160                  {
161                     // Comp with clamp
162                     dest[x] = jal_blend_func(dest[x], pal[c], alpha[c]);
163                  }
164                  else
165                  {
166                     // Skip the costly alpha step altogether
167                     dest[x] = pal[c];
168                  }
163                  // Comp with clamp
164                  dest[x] = jaleco_blend_device::func(dest[x], pal[c], alpha[c]);
169165               }
170               x_index += xinc;
166               else
167               {
168                  // Skip the costly alpha step altogether
169                  dest[x] = pal[c];
170               }
171171            }
172            y_index += yinc;
172            x_index += xinc;
173173         }
174         y_index += yinc;
174175      }
175176   }
176177}
177178
178void jal_blend_drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
179void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
179180                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
180181                     int transparent_color)
181{ jal_blend_drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
182void jal_blend_drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
182{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
183void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
183184                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
184185                     int transparent_color)
185{ jal_blend_drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
186{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
trunk/src/mame/video/jalblend.h
r244697r244698
1void jal_blend_init(running_machine &machine, int enable);
2void jal_blend_set(int color, UINT8 val);
3
4rgb_t jal_blend_func(rgb_t dest, rgb_t addMe, UINT8 alpha);
5void jal_blend_drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
1class jaleco_blend_device : public device_t
2{
3public:
4   jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5   ~jaleco_blend_device() {}
6   
7   void set(int color, UINT8 val);
8   rgb_t func(rgb_t dest, rgb_t addMe, UINT8 alpha);
9   void drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
610                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
711                     int transparent_color);
8void jal_blend_drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
12   void drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
913                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
1014                     int transparent_color);
15
16protected:
17   // device-level overrides
18   virtual void device_start();
19   virtual void device_reset();
20
21private:   
22   /* each palette entry contains a fourth 'alpha' value */
23   UINT8 *m_table;
24   
25   template<class _BitmapClass>
26   void drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
27                     UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
28                     int transparent_color);
29};
30
31extern const device_type JALECO_BLEND;
No newline at end of file
trunk/src/mame/video/psychic5.c
r244697r244698
77***************************************************************************/
88
99#include "emu.h"
10#include "video/jalblend.h"
1110#include "includes/psychic5.h"
1211
1312
r244697r244698
2524   UINT8 hi = palram[(offset) | 1];
2625
2726   int color = offset >> 1;
28
29   jal_blend_set(palbase + color, hi & 0x0f);
27   
28   if (m_blend)
29      m_blend->set(palbase + color, hi & 0x0f);
30   
3031   m_palette->set_pen_color(palbase + color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
3132}
3233
r244697r244698
5657   {
5758      UINT8 val = (r + g + b) / 3;        /* Grey */
5859      /* Just leave plain grey */
59      m_palette->set_pen_color(color,jal_blend_func(rgb_t(val,val,val),irgb,ix));
60      m_palette->set_pen_color(color,m_blend->func(rgb_t(val,val,val),irgb,ix));
6061   }
6162   else
6263   {
r244697r244698
6465      if (!(m_title_screen & 1))
6566      {
6667         /* Leave the world as-is */
67         m_palette->set_pen_color(color,jal_blend_func(rgb_t(r,g,b),irgb,ix));
68         m_palette->set_pen_color(color,m_blend->func(rgb_t(r,g,b),irgb,ix));
6869      }
6970   }
7071}
r244697r244698
191192   m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(psychic5_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 32);
192193   m_fg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(psychic5_state::get_fg_tile_info),this), TILEMAP_SCAN_COLS,  8,  8, 32, 32);
193194   m_fg_tilemap->set_transparent_pen(15);
194   jal_blend_init(machine(), 1);
195195   
196196   save_item(NAME(m_title_screen));
197197
r244697r244698
204204   m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(psychic5_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 128, 32);
205205   m_fg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(psychic5_state::get_fg_tile_info),this), TILEMAP_SCAN_COLS,  8,  8,  32, 32);
206206   m_fg_tilemap->set_transparent_pen(15);
207   jal_blend_init(machine(), 0);
208207   
209208   save_item(NAME(m_bombsa_unknown));
210209}
r244697r244698
223222  Screen refresh
224223***************************************************************************/
225224
226#define DRAW_SPRITE(code, sx, sy) jal_blend_drawgfx(m_palette, bitmap, cliprect, m_gfxdecode->gfx(0), code, color, flipx, flipy, sx, sy, 15);
225#define DRAW_SPRITE(code, sx, sy) \
226   if (m_blend) \
227      m_blend->drawgfx(m_palette, bitmap, cliprect, m_gfxdecode->gfx(0), code, color, flipx, flipy, sx, sy, 15); \
228   else \
229      m_gfxdecode->gfx(0)->transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, 15);
227230
228231void psychic5_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
229232{


Previous 199869 Revisions Next


© 1997-2024 The MAME Team