trunk/src/mame/video/stvvdp2.c
| r20753 | r20754 | |
| 2438 | 2438 | ); |
| 2439 | 2439 | } |
| 2440 | 2440 | |
| 2441 | static void stv_vdp2_drawgfxzoom_rgb555( |
| 2442 | bitmap_rgb32 &dest_bmp,const rectangle &clip,running_machine &machine, |
| 2443 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 2444 | int transparency,int transparent_color,int scalex, int scaley, |
| 2445 | int sprite_screen_width, int sprite_screen_height, int alpha) |
| 2446 | { |
| 2447 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2448 | rectangle myclip; |
| 2449 | UINT8* gfxdata; |
| 2450 | |
| 2451 | gfxdata = state->m_vdp2.gfx_decode + code * 0x20; |
| 2452 | |
| 2453 | if (!scalex || !scaley) return; |
| 2454 | |
| 2455 | #if 0 |
| 2456 | if (gfx->has_pen_usage() && transparency == STV_TRANSPARENCY_PEN) |
| 2457 | { |
| 2458 | int transmask = 0; |
| 2459 | |
| 2460 | transmask = 1 << (transparent_color & 0xff); |
| 2461 | |
| 2462 | if ((gfx->pen_usage(code) & ~transmask) == 0) |
| 2463 | /* character is totally transparent, no need to draw */ |
| 2464 | return; |
| 2465 | else if ((gfx->pen_usage(code) & transmask) == 0) |
| 2466 | /* character is totally opaque, can disable transparency */ |
| 2467 | transparency = STV_TRANSPARENCY_NONE; |
| 2468 | } |
| 2469 | #endif |
| 2470 | |
| 2471 | /* |
| 2472 | scalex and scaley are 16.16 fixed point numbers |
| 2473 | 1<<15 : shrink to 50% |
| 2474 | 1<<16 : uniform scale |
| 2475 | 1<<17 : double to 200% |
| 2476 | */ |
| 2477 | |
| 2478 | |
| 2479 | /* KW 991012 -- Added code to force clip to bitmap boundary */ |
| 2480 | myclip = clip; |
| 2481 | myclip &= dest_bmp.cliprect(); |
| 2482 | |
| 2483 | // if( gfx ) |
| 2484 | { |
| 2485 | // const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 2486 | |
| 2487 | //int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16; |
| 2488 | //int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16; |
| 2489 | |
| 2490 | if (sprite_screen_width && sprite_screen_height) |
| 2491 | { |
| 2492 | /* compute sprite increment per screen pixel */ |
| 2493 | //int dx = (gfx->width()<<16)/sprite_screen_width; |
| 2494 | //int dy = (gfx->height()<<16)/sprite_screen_height; |
| 2495 | int dx = stv2_current_tilemap.incx; |
| 2496 | int dy = stv2_current_tilemap.incy; |
| 2497 | |
| 2498 | int ex = sx+sprite_screen_width; |
| 2499 | int ey = sy+sprite_screen_height; |
| 2500 | |
| 2501 | int x_index_base; |
| 2502 | int y_index; |
| 2503 | |
| 2504 | if( flipx ) |
| 2505 | { |
| 2506 | x_index_base = (sprite_screen_width-1)*dx; |
| 2507 | dx = -dx; |
| 2508 | } |
| 2509 | else |
| 2510 | { |
| 2511 | x_index_base = 0; |
| 2512 | } |
| 2513 | |
| 2514 | if( flipy ) |
| 2515 | { |
| 2516 | y_index = (sprite_screen_height-1)*dy; |
| 2517 | dy = -dy; |
| 2518 | } |
| 2519 | else |
| 2520 | { |
| 2521 | y_index = 0; |
| 2522 | } |
| 2523 | |
| 2524 | if( sx < myclip.min_x) |
| 2525 | { /* clip left */ |
| 2526 | int pixels = myclip.min_x-sx; |
| 2527 | sx += pixels; |
| 2528 | x_index_base += pixels*dx; |
| 2529 | } |
| 2530 | if( sy < myclip.min_y ) |
| 2531 | { /* clip top */ |
| 2532 | int pixels = myclip.min_y-sy; |
| 2533 | sy += pixels; |
| 2534 | y_index += pixels*dy; |
| 2535 | } |
| 2536 | /* NS 980211 - fixed incorrect clipping */ |
| 2537 | if( ex > myclip.max_x+1 ) |
| 2538 | { /* clip right */ |
| 2539 | int pixels = ex-myclip.max_x-1; |
| 2540 | ex -= pixels; |
| 2541 | } |
| 2542 | if( ey > myclip.max_y+1 ) |
| 2543 | { /* clip bottom */ |
| 2544 | int pixels = ey-myclip.max_y-1; |
| 2545 | ey -= pixels; |
| 2546 | } |
| 2547 | |
| 2548 | if( ex>sx ) |
| 2549 | { /* skip if inner loop doesn't draw anything */ |
| 2550 | int y; |
| 2551 | |
| 2552 | /* case 0: STV_TRANSPARENCY_NONE */ |
| 2553 | if (transparency == STV_TRANSPARENCY_NONE) |
| 2554 | { |
| 2555 | for( y=sy; y<ey; y++ ) |
| 2556 | { |
| 2557 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2558 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2559 | int r,g,b,data; |
| 2560 | |
| 2561 | int x, x_index = x_index_base; |
| 2562 | for( x=sx; x<ex; x++ ) |
| 2563 | { |
| 2564 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2565 | b = pal5bit((data & 0x7c00) >> 10); |
| 2566 | g = pal5bit((data & 0x03e0) >> 5); |
| 2567 | r = pal5bit( data & 0x001f); |
| 2568 | dest[x] = MAKE_RGB(r, g, b); |
| 2569 | x_index += dx; |
| 2570 | } |
| 2571 | |
| 2572 | y_index += dy; |
| 2573 | } |
| 2574 | } |
| 2575 | |
| 2576 | /* case 1: STV_TRANSPARENCY_PEN */ |
| 2577 | if (transparency == STV_TRANSPARENCY_PEN) |
| 2578 | { |
| 2579 | for( y=sy; y<ey; y++ ) |
| 2580 | { |
| 2581 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2582 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2583 | int r,g,b,data; |
| 2584 | |
| 2585 | int x, x_index = x_index_base; |
| 2586 | for( x=sx; x<ex; x++ ) |
| 2587 | { |
| 2588 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2589 | b = pal5bit((data & 0x7c00) >> 10); |
| 2590 | g = pal5bit((data & 0x03e0) >> 5); |
| 2591 | r = pal5bit( data & 0x001f); |
| 2592 | if( data ) dest[x] = MAKE_RGB(r, g, b); |
| 2593 | x_index += dx; |
| 2594 | } |
| 2595 | |
| 2596 | y_index += dy; |
| 2597 | } |
| 2598 | } |
| 2599 | |
| 2600 | /* case 6: STV_TRANSPARENCY_ALPHA */ |
| 2601 | if (transparency == STV_TRANSPARENCY_ALPHA) |
| 2602 | { |
| 2603 | for( y=sy; y<ey; y++ ) |
| 2604 | { |
| 2605 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2606 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2607 | int r,g,b,data; |
| 2608 | |
| 2609 | int x, x_index = x_index_base; |
| 2610 | for( x=sx; x<ex; x++ ) |
| 2611 | { |
| 2612 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2613 | b = pal5bit((data & 0x7c00) >> 10); |
| 2614 | g = pal5bit((data & 0x03e0) >> 5); |
| 2615 | r = pal5bit( data & 0x001f); |
| 2616 | if( data ) dest[x] = alpha_blend_r32(dest[x], MAKE_RGB(r, g, b), alpha); |
| 2617 | x_index += dx; |
| 2618 | } |
| 2619 | |
| 2620 | y_index += dy; |
| 2621 | } |
| 2622 | } |
| 2623 | |
| 2624 | /* case : STV_TRANSPARENCY_ADD_BLEND */ |
| 2625 | if (transparency == STV_TRANSPARENCY_ADD_BLEND ) |
| 2626 | { |
| 2627 | for( y=sy; y<ey; y++ ) |
| 2628 | { |
| 2629 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2630 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2631 | int r,g,b,data; |
| 2632 | |
| 2633 | int x, x_index = x_index_base; |
| 2634 | for( x=sx; x<ex; x++ ) |
| 2635 | { |
| 2636 | data = (source[(x_index*2+0)>>16]<<0)|(source[(x_index*2+1)>>16]<<8); |
| 2637 | b = pal5bit((data & 0x7c00) >> 10); |
| 2638 | g = pal5bit((data & 0x03e0) >> 5); |
| 2639 | r = pal5bit( data & 0x001f); |
| 2640 | if( data ) dest[x] = stv_add_blend(dest[x], MAKE_RGB(r, g, b)); |
| 2641 | x_index += dx; |
| 2642 | } |
| 2643 | |
| 2644 | y_index += dy; |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | } |
| 2649 | } |
| 2650 | } |
| 2651 | |
| 2652 | } |
| 2653 | |
| 2441 | 2654 | static void stv_vdp2_drawgfxzoom( |
| 2442 | 2655 | bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 2443 | 2656 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| r20753 | r20754 | |
| 3784 | 3997 | #define SCR_TILESIZE_Y1(starty) (((drawypos + (starty) + tilesizey) >> 16) - ((drawypos + (starty))>>16)) |
| 3785 | 3998 | if (stv2_current_tilemap.tile_size==1) |
| 3786 | 3999 | { |
| 3787 | | /* normal */ |
| 3788 | | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 3789 | | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 3790 | | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 3791 | | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 3792 | | |
| 4000 | if ( stv2_current_tilemap.colour_depth == 4 ) |
| 4001 | { |
| 4002 | popmessage("Unsupported tilemap gfx zoom color depth = 4, tile size = 1, contact MAMEdev"); |
| 4003 | } |
| 4004 | else if ( stv2_current_tilemap.colour_depth == 3 ) |
| 4005 | { |
| 4006 | /* RGB555 */ |
| 4007 | stv_vdp2_drawgfxzoom_rgb555(bitmap,cliprect,machine,tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4008 | stv_vdp2_drawgfxzoom_rgb555(bitmap,cliprect,machine,tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4009 | stv_vdp2_drawgfxzoom_rgb555(bitmap,cliprect,machine,tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 4010 | stv_vdp2_drawgfxzoom_rgb555(bitmap,cliprect,machine,tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 4011 | } |
| 4012 | else |
| 4013 | { |
| 4014 | /* normal */ |
| 4015 | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4016 | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4017 | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 4018 | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha); |
| 4019 | } |
| 3793 | 4020 | } |
| 3794 | 4021 | else |
| 3795 | 4022 | { |
| 3796 | | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4023 | if ( stv2_current_tilemap.colour_depth == 4 ) |
| 4024 | popmessage("Unsupported tilemap gfx zoom color depth = 4, tile size = 0, contact MAMEdev"); |
| 4025 | else if ( stv2_current_tilemap.colour_depth == 3) |
| 4026 | { |
| 4027 | stv_vdp2_drawgfxzoom_rgb555(bitmap,cliprect,machine,tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 4028 | } |
| 4029 | else |
| 4030 | stv_vdp2_drawgfxzoom(bitmap,cliprect,machine.gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y,stv2_current_tilemap.alpha); |
| 3797 | 4031 | } |
| 3798 | 4032 | } |
| 3799 | 4033 | else |
| r20753 | r20754 | |
| 3810 | 4044 | stv_vdp2_drawgfx_rgb888(bitmap,cliprect,machine,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3811 | 4045 | stv_vdp2_drawgfx_rgb888(bitmap,cliprect,machine,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3812 | 4046 | stv_vdp2_drawgfx_rgb888(bitmap,cliprect,machine,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3813 | | |
| 3814 | 4047 | } |
| 3815 | 4048 | else if ( stv2_current_tilemap.colour_depth == 3 ) |
| 3816 | 4049 | { |
| r20753 | r20754 | |
| 3819 | 4052 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3820 | 4053 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3821 | 4054 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3822 | | |
| 3823 | 4055 | } |
| 3824 | 4056 | else if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA) |
| 3825 | 4057 | { |
| r20753 | r20754 | |
| 3828 | 4060 | drawgfx_alpha(bitmap,cliprect,machine.gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,0,stv2_current_tilemap.alpha); |
| 3829 | 4061 | drawgfx_alpha(bitmap,cliprect,machine.gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,0,stv2_current_tilemap.alpha); |
| 3830 | 4062 | drawgfx_alpha(bitmap,cliprect,machine.gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,0,stv2_current_tilemap.alpha); |
| 3831 | | |
| 3832 | 4063 | } |
| 3833 | 4064 | else |
| 3834 | 4065 | { |
| r20753 | r20754 | |
| 3837 | 4068 | drawgfx_transpen(bitmap,cliprect,machine.gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,(stv2_current_tilemap.transparency==STV_TRANSPARENCY_PEN)?0:-1); |
| 3838 | 4069 | drawgfx_transpen(bitmap,cliprect,machine.gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,(stv2_current_tilemap.transparency==STV_TRANSPARENCY_PEN)?0:-1); |
| 3839 | 4070 | drawgfx_transpen(bitmap,cliprect,machine.gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,(stv2_current_tilemap.transparency==STV_TRANSPARENCY_PEN)?0:-1); |
| 3840 | | |
| 3841 | 4071 | } |
| 3842 | 4072 | } |
| 3843 | 4073 | else |