trunk/src/mame/video/deco_zoomspr.c
| r31061 | r31062 | |
| 51 | 51 | bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 52 | 52 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 53 | 53 | int transparent_color, |
| 54 | | int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height, UINT8 alpha ) |
| 54 | int scalex, int scaley,bitmap_ind8 *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height, UINT8 alpha, |
| 55 | bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap, |
| 56 | int priority) |
| 55 | 57 | { |
| 56 | 58 | rectangle myclip; |
| 57 | 59 | |
| r31061 | r31062 | |
| 66 | 68 | |
| 67 | 69 | /* KW 991012 -- Added code to force clip to bitmap boundary */ |
| 68 | 70 | myclip = clip; |
| 69 | | myclip &= dest_bmp.cliprect(); |
| 71 | myclip &= temp_bitmap.cliprect(); |
| 70 | 72 | |
| 71 | 73 | { |
| 72 | 74 | if( gfx ) |
| r31061 | r31062 | |
| 137 | 139 | /* case 1: no alpha */ |
| 138 | 140 | if (alpha == 0xff) |
| 139 | 141 | { |
| 140 | | if (pri_buffer) |
| 141 | 142 | { |
| 142 | 143 | for( y=sy; y<ey; y++ ) |
| 143 | 144 | { |
| 144 | 145 | const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes(); |
| 145 | | UINT32 *dest = &dest_bmp.pix32(y); |
| 146 | | UINT8 *pri = &pri_buffer->pix8(y); |
| 146 | UINT32 *dest = &temp_bitmap.pix32(y); |
| 147 | UINT8 *pri = &pri_bitmap.pix8(y); |
| 147 | 148 | |
| 149 | |
| 148 | 150 | int x, x_index = x_index_base; |
| 149 | 151 | for( x=sx; x<ex; x++ ) |
| 150 | 152 | { |
| 151 | 153 | int c = source[x_index>>16]; |
| 152 | | if( c != transparent_color ) |
| 154 | if (c != transparent_color) |
| 153 | 155 | { |
| 154 | | if (((1 << pri[x]) & pri_mask) == 0) |
| 156 | if (priority >= pri[x]) |
| 157 | { |
| 155 | 158 | dest[x] = pal[c]; |
| 156 | | pri[x] = 31; |
| 159 | dest[x] |= 0xff000000; |
| 160 | } |
| 161 | else // sprites can have a 'masking' effect on other sprites |
| 162 | { |
| 163 | dest[x] = 0x00000000; |
| 164 | } |
| 157 | 165 | } |
| 158 | | x_index += dx; |
| 159 | | } |
| 160 | 166 | |
| 161 | | y_index += dy; |
| 162 | | } |
| 163 | | } |
| 164 | | else |
| 165 | | { |
| 166 | | for( y=sy; y<ey; y++ ) |
| 167 | | { |
| 168 | | const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes(); |
| 169 | | UINT32 *dest = &dest_bmp.pix32(y); |
| 170 | | |
| 171 | | int x, x_index = x_index_base; |
| 172 | | for( x=sx; x<ex; x++ ) |
| 173 | | { |
| 174 | | int c = source[x_index>>16]; |
| 175 | | if( c != transparent_color ) dest[x] = pal[c]; |
| 176 | 167 | x_index += dx; |
| 177 | 168 | } |
| 178 | 169 | |
| r31061 | r31062 | |
| 184 | 175 | /* alpha-blended */ |
| 185 | 176 | else |
| 186 | 177 | { |
| 187 | | if (pri_buffer) |
| 188 | 178 | { |
| 189 | 179 | for( y=sy; y<ey; y++ ) |
| 190 | 180 | { |
| 191 | 181 | const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes(); |
| 192 | | UINT32 *dest = &dest_bmp.pix32(y); |
| 193 | | UINT8 *pri = &pri_buffer->pix8(y); |
| 182 | UINT32 *dest = &temp_bitmap.pix32(y); |
| 183 | UINT8 *pri = &pri_bitmap.pix8(y); |
| 184 | UINT32 *tmapcolor = &dest_bmp.pix32(y); |
| 194 | 185 | |
| 186 | |
| 195 | 187 | int x, x_index = x_index_base; |
| 196 | 188 | for( x=sx; x<ex; x++ ) |
| 197 | 189 | { |
| 198 | 190 | int c = source[x_index>>16]; |
| 199 | | if( c != transparent_color ) |
| 191 | if (c != transparent_color) |
| 200 | 192 | { |
| 201 | | if (((1 << pri[x]) & pri_mask) == 0) |
| 202 | | dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); |
| 203 | | pri[x] = 31; |
| 193 | if (priority >= pri[x]) |
| 194 | { |
| 195 | if ((dest[x] & 0xff000000) == 0x00000000) |
| 196 | dest[x] = alpha_blend_r32(tmapcolor[x] & 0x00ffffff, pal[c] & 0x00ffffff, alpha); // if nothing has been drawn pull the pixel from the tilemap to blend with |
| 197 | else |
| 198 | dest[x] = alpha_blend_r32(dest[x] & 0x00ffffff, pal[c] & 0x00ffffff, alpha); // otherwise blend with what was previously drawn |
| 199 | |
| 200 | dest[x] |= 0xff000000; |
| 201 | } |
| 202 | else // sprites can have a 'masking' effect on other sprites |
| 203 | { |
| 204 | dest[x] = 0x00000000; |
| 205 | } |
| 204 | 206 | } |
| 205 | | x_index += dx; |
| 206 | | } |
| 207 | 207 | |
| 208 | | y_index += dy; |
| 209 | | } |
| 210 | | } |
| 211 | | else |
| 212 | | { |
| 213 | | for( y=sy; y<ey; y++ ) |
| 214 | | { |
| 215 | | const UINT8 *source = code_base + (y_index>>16) * gfx->rowbytes(); |
| 216 | | UINT32 *dest = &dest_bmp.pix32(y); |
| 217 | | |
| 218 | | int x, x_index = x_index_base; |
| 219 | | for( x=sx; x<ex; x++ ) |
| 220 | | { |
| 221 | | int c = source[x_index>>16]; |
| 222 | | if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); |
| 223 | 208 | x_index += dx; |
| 224 | 209 | } |
| 225 | 210 | |
| r31061 | r31062 | |
| 233 | 218 | } |
| 234 | 219 | } |
| 235 | 220 | |
| 236 | | void deco_zoomspr_device::dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl ) |
| 221 | void deco_zoomspr_device::dragngun_draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap) |
| 237 | 222 | { |
| 238 | 223 | const UINT32 *layout_ram; |
| 239 | 224 | const UINT32 *lookup_ram; |
| 240 | 225 | int offs; |
| 226 | temp_bitmap.fill(0x00000000, cliprect); |
| 241 | 227 | |
| 242 | 228 | /* |
| 243 | 229 | Sprites are built from main control ram, which references tile |
| r31061 | r31062 | |
| 319 | 305 | |
| 320 | 306 | colour = spritedata[offs+6]&0x1f; |
| 321 | 307 | |
| 308 | int priority = (spritedata[offs + 6] & 0x60) >> 5; |
| 309 | /* |
| 310 | if (priority == 0) priority = 1; |
| 311 | else if (priority == 1) priority = 1; |
| 312 | else if (priority == 2) priority = 1; |
| 313 | else if (priority == 3) priority = 1; |
| 314 | */ |
| 315 | priority = 7; |
| 316 | |
| 322 | 317 | if (spritedata[offs+6]&0x80) |
| 323 | 318 | alpha=0x80; |
| 324 | 319 | else |
| r31061 | r31062 | |
| 378 | 373 | if (sprite&0x8000) bank=4; else bank=3; |
| 379 | 374 | sprite&=0x7fff; |
| 380 | 375 | |
| 381 | | if (zoomx!=0x10000 || zoomy!=0x10000) |
| 382 | 376 | dragngun_drawgfxzoom( |
| 383 | 377 | bitmap,cliprect,m_gfxdecode->gfx(bank), |
| 384 | 378 | sprite, |
| r31061 | r31062 | |
| 386 | 380 | fx,fy, |
| 387 | 381 | xpos>>16,ypos>>16, |
| 388 | 382 | 15,zoomx,zoomy,NULL,0, |
| 389 | | ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha ); |
| 390 | | else |
| 391 | | m_gfxdecode->gfx(bank)->alpha(bitmap,cliprect, |
| 392 | | sprite, |
| 393 | | colour, |
| 394 | | fx,fy, |
| 395 | | xpos>>16,ypos>>16, |
| 396 | | 15,alpha); |
| 383 | ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha, |
| 384 | pri_bitmap, temp_bitmap, |
| 385 | priority |
| 386 | ); |
| 397 | 387 | |
| 388 | |
| 398 | 389 | if (fx) |
| 399 | 390 | xpos-=zoomx<<4; |
| 400 | 391 | else |
| r31061 | r31062 | |
| 406 | 397 | ypos+=zoomy<<4; |
| 407 | 398 | } |
| 408 | 399 | } |
| 400 | |
| 401 | for (int y = cliprect.min_y; y <= cliprect.max_y; y++) |
| 402 | { |
| 403 | UINT32 *src = &temp_bitmap.pix32(y); |
| 404 | UINT32 *dst = &bitmap.pix32(y); |
| 405 | |
| 406 | for (int x = cliprect.min_x; x <= cliprect.max_x; x++) |
| 407 | { |
| 408 | UINT32 srcpix = src[x]; |
| 409 | |
| 410 | if ((srcpix & 0xff000000) == 0xff000000) |
| 411 | { |
| 412 | dst[x] = srcpix & 0x00ffffff; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | } |
| 417 | |
| 409 | 418 | } |
| 410 | 419 | |
trunk/src/mame/video/deco_zoomspr.h
| r31061 | r31062 | |
| 8 | 8 | static void static_set_palette_tag(device_t &device, const char *tag); |
| 9 | 9 | static void static_set_gfxdecode_tag(device_t &device, const char *tag); |
| 10 | 10 | |
| 11 | | void dragngun_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl); |
| 11 | void dragngun_draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, const UINT32 *spritedata, UINT32* dragngun_sprite_layout_0_ram, UINT32* dragngun_sprite_layout_1_ram, UINT32* dragngun_sprite_lookup_0_ram, UINT32* dragngun_sprite_lookup_1_ram, UINT32 dragngun_sprite_ctrl, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap); |
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | protected: |
| r31061 | r31062 | |
| 23 | 23 | bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx, |
| 24 | 24 | UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy, |
| 25 | 25 | int transparent_color, |
| 26 | | int scalex, int scaley, bitmap_ind8 *pri_buffer, UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height, UINT8 alpha); |
| 26 | int scalex, int scaley, bitmap_ind8 *pri_buffer, UINT32 pri_mask, int sprite_screen_width, int sprite_screen_height, UINT8 alpha, bitmap_ind8 &pri_bitmap, bitmap_rgb32 &temp_bitmap, |
| 27 | int priority); |
| 27 | 28 | |
| 28 | 29 | }; |
| 29 | 30 | |
trunk/src/mame/video/deco32.c
| r31061 | r31062 | |
| 159 | 159 | { |
| 160 | 160 | m_dirty_palette = auto_alloc_array(machine(), UINT8, 4096); |
| 161 | 161 | |
| 162 | |
| 163 | m_screen->register_screen_bitmap(m_temp_render_bitmap); |
| 164 | |
| 162 | 165 | memset(m_dirty_palette,0,4096); |
| 163 | 166 | |
| 164 | 167 | save_item(NAME(m_dragngun_sprite_ctrl)); |
| 165 | 168 | m_has_ace_ram=0; |
| 169 | |
| 170 | |
| 166 | 171 | } |
| 167 | 172 | |
| 168 | 173 | VIDEO_START_MEMBER(dragngun_state,lockload) |
| r31061 | r31062 | |
| 237 | 242 | |
| 238 | 243 | UINT32 dragngun_state::screen_update_dragngun(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 239 | 244 | { |
| 245 | screen.priority().fill(0, cliprect); |
| 240 | 246 | bitmap.fill(m_palette->black_pen(), cliprect); |
| 241 | 247 | |
| 242 | 248 | m_deco_tilegen1->pf_update(m_pf1_rowscroll, m_pf2_rowscroll); |
| r31061 | r31062 | |
| 244 | 250 | |
| 245 | 251 | //m_deco_tilegen1->set_pf3_8bpp_mode(1); // despite being 8bpp this doesn't require the same shifting as captaven, why not? |
| 246 | 252 | |
| 247 | | m_deco_tilegen2->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); // it uses pf3 in 8bpp mode instead, like captaven |
| 248 | | m_deco_tilegen2->tilemap_1_draw(screen, bitmap, cliprect, 0, 0); |
| 249 | | m_deco_tilegen1->tilemap_2_draw(screen, bitmap, cliprect, 0, 0); |
| 253 | m_deco_tilegen2->tilemap_2_draw(screen, bitmap, cliprect, 0, 1); // it uses pf3 in 8bpp mode instead, like captaven |
| 254 | m_deco_tilegen2->tilemap_1_draw(screen, bitmap, cliprect, 0, 2); |
| 255 | m_deco_tilegen1->tilemap_2_draw(screen, bitmap, cliprect, 0, 4); |
| 256 | m_deco_tilegen1->tilemap_1_draw(screen, bitmap, cliprect, 0, 8); |
| 250 | 257 | |
| 251 | 258 | // zooming sprite draw is very slow, and sprites are buffered.. however, one of the levels attempts to use |
| 252 | 259 | // partial updates for every line, which causes things to be very slow... the sprites appear to support |
| r31061 | r31062 | |
| 259 | 266 | { |
| 260 | 267 | rectangle clip(cliprect.min_x, cliprect.max_x, 8, 247); |
| 261 | 268 | |
| 262 | | m_sprgenzoom->dragngun_draw_sprites(bitmap,clip,m_spriteram->buffer(), m_dragngun_sprite_layout_0_ram, m_dragngun_sprite_layout_1_ram, m_dragngun_sprite_lookup_0_ram, m_dragngun_sprite_lookup_1_ram, m_dragngun_sprite_ctrl ); |
| 263 | | m_deco_tilegen1->tilemap_1_draw(screen, bitmap, clip, 0, 0); |
| 269 | m_sprgenzoom->dragngun_draw_sprites(bitmap,clip,m_spriteram->buffer(), m_dragngun_sprite_layout_0_ram, m_dragngun_sprite_layout_1_ram, m_dragngun_sprite_lookup_0_ram, m_dragngun_sprite_lookup_1_ram, m_dragngun_sprite_ctrl, screen.priority(), m_temp_render_bitmap ); |
| 264 | 270 | |
| 265 | 271 | } |
| 266 | 272 | |