trunk/src/emu/video/stvvdp2.c
| r21122 | r21123 | |
| 2576 | 2576 | |
| 2577 | 2577 | gfxdata = m_vdp2.gfx_decode + code * 0x20; |
| 2578 | 2578 | |
| 2579 | | if(stv2_current_tilemap.window_control & 6) |
| 2579 | if(stv2_current_tilemap.window_control.enabled[0] || |
| 2580 | stv2_current_tilemap.window_control.enabled[1]) |
| 2580 | 2581 | popmessage("Window Enabled for RGB555 Zoom"); |
| 2581 | 2582 | |
| 2582 | 2583 | if (!scalex || !scaley) return; |
| r21122 | r21123 | |
| 2802 | 2803 | gfxdata = m_vdp2.gfx_decode + code * 0x20; |
| 2803 | 2804 | sprite_screen_width = sprite_screen_height = 8; |
| 2804 | 2805 | |
| 2805 | | if(stv2_current_tilemap.window_control & 6) |
| 2806 | | popmessage("Window Enabled for RGB555"); |
| 2806 | if(stv2_current_tilemap.window_control.enabled[0] || |
| 2807 | stv2_current_tilemap.window_control.enabled[1]) |
| 2808 | popmessage("Window Enabled for RGB555 tiles"); |
| 2807 | 2809 | |
| 2808 | 2810 | /* KW 991012 -- Added code to force clip to bitmap boundary */ |
| 2809 | 2811 | myclip = clip; |
| r21122 | r21123 | |
| 2915 | 2917 | gfxdata = m_vdp2.gfx_decode + code * 0x20; |
| 2916 | 2918 | sprite_screen_width = sprite_screen_height = 8; |
| 2917 | 2919 | |
| 2918 | | if(stv2_current_tilemap.window_control & 6) |
| 2919 | | popmessage("Window Enabled for RGB888"); |
| 2920 | if(stv2_current_tilemap.window_control.enabled[0] || |
| 2921 | stv2_current_tilemap.window_control.enabled[1]) |
| 2922 | popmessage("Window Enabled for RGB888 tiles"); |
| 2920 | 2923 | |
| 2921 | 2924 | /* KW 991012 -- Added code to force clip to bitmap boundary */ |
| 2922 | 2925 | myclip = clip; |
| r21122 | r21123 | |
| 3405 | 3408 | |
| 3406 | 3409 | void saturn_state::stv_vdp2_draw_basic_bitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 3407 | 3410 | { |
| 3408 | | // if(LOG_VDP2) logerror ("bitmap enable %02x size %08x depth %08x\n", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth); |
| 3409 | | // popmessage ("bitmap enable %02x size %08x depth %08x number %02x", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth,stv2_current_tilemap.bitmap_palette_number); |
| 3410 | | //popmessage("%04x",STV_VDP2_SCRCTL); |
| 3411 | | |
| 3412 | | int xsize = 0, xsizemask = 0; |
| 3413 | | int ysize = 0/*, ysizemask = 0*/; |
| 3414 | | int xlinesize = 0/*, xpixelsize = 0*/; |
| 3415 | | int xcnt,ycnt; |
| 3416 | | UINT8* gfxdata = m_vdp2.gfx_decode; |
| 3417 | | UINT32 *destline; |
| 3418 | | UINT16 pal_color_offset = 0; |
| 3419 | | UINT8* gfxdatalow, *gfxdatahigh; |
| 3420 | | int screen_x,screen_y; |
| 3421 | | |
| 3422 | 3411 | if (!stv2_current_tilemap.enabled) return; |
| 3423 | 3412 | |
| 3424 | 3413 | /* new bitmap code, supposed to rewrite the old one. Not supposed to be clean, but EFFICIENT! */ |
| r21122 | r21123 | |
| 3433 | 3422 | } |
| 3434 | 3423 | |
| 3435 | 3424 | /* intentional fall-through*/ |
| 3436 | | popmessage("%d %s %s %s %s",stv2_current_tilemap.colour_depth, |
| 3425 | popmessage("%d %s %s %s",stv2_current_tilemap.colour_depth, |
| 3437 | 3426 | stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE ? "no trans" : "trans", |
| 3438 | | stv2_current_tilemap.window_control & 6 ? "window" : "no window", |
| 3439 | 3427 | stv2_current_tilemap.colour_calculation_enabled ? "cc" : "no cc", |
| 3440 | 3428 | (stv2_current_tilemap.incx == 0x10000 && stv2_current_tilemap.incy == 0x10000) ? "no zoom" : "zoom"); |
| 3441 | 3429 | } |
| r21122 | r21123 | |
| 3450 | 3438 | } |
| 3451 | 3439 | |
| 3452 | 3440 | /* intentional fall-through*/ |
| 3453 | | popmessage("%d %s %s %s %s",stv2_current_tilemap.colour_depth, |
| 3441 | popmessage("%d %s %s %s",stv2_current_tilemap.colour_depth, |
| 3454 | 3442 | stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE ? "no trans" : "trans", |
| 3455 | | stv2_current_tilemap.window_control & 6 ? "window" : "no window", |
| 3456 | 3443 | stv2_current_tilemap.colour_calculation_enabled ? "cc" : "no cc", |
| 3457 | 3444 | (stv2_current_tilemap.incx == 0x10000 && stv2_current_tilemap.incy == 0x10000) ? "no zoom" : "zoom"); |
| 3458 | 3445 | } |
| 3459 | | |
| 3460 | | /* size for n0 / n1 */ |
| 3461 | | switch (stv2_current_tilemap.bitmap_size) |
| 3462 | | { |
| 3463 | | case 0: xsize=512; ysize=256; break; |
| 3464 | | case 1: xsize=512; ysize=512; break; |
| 3465 | | case 2: xsize=1024; ysize=256; break; |
| 3466 | | case 3: xsize=1024; ysize=512; break; |
| 3467 | | } |
| 3468 | | xsizemask = xsize - 1; |
| 3469 | | /*ysizemask = ysize - 1;*/ |
| 3470 | | |
| 3471 | | switch( stv2_current_tilemap.colour_depth ) |
| 3472 | | { |
| 3473 | | case 0: xlinesize = xsize / 2; /*xpixelsize = 0;*/ break; |
| 3474 | | case 1: xlinesize = xsize; /*xpixelsize = 1;*/ break; |
| 3475 | | case 2: case 3: xlinesize = xsize * 2; /*xpixelsize = 2;*/ break; |
| 3476 | | case 4: xlinesize = xsize * 4; /*xpixelsize = 4;*/ break; |
| 3477 | | } |
| 3478 | | |
| 3479 | | if(stv2_current_tilemap.colour_depth == 0) |
| 3480 | | stv2_current_tilemap.scrollx /= 2; |
| 3481 | | if(stv2_current_tilemap.colour_depth == 2 || stv2_current_tilemap.colour_depth == 3) |
| 3482 | | stv2_current_tilemap.scrollx*=2; |
| 3483 | | if(stv2_current_tilemap.colour_depth == 4) |
| 3484 | | stv2_current_tilemap.scrollx*=4; |
| 3485 | | |
| 3486 | | gfxdatalow = gfxdata + stv2_current_tilemap.bitmap_map * 0x20000; |
| 3487 | | gfxdata+=( |
| 3488 | | (stv2_current_tilemap.scrollx & (xlinesize-1)) + |
| 3489 | | ((stv2_current_tilemap.scrolly & (ysize-1)) * (xlinesize)) + /* TODO: mask ysize, check me! */ |
| 3490 | | (stv2_current_tilemap.bitmap_map * 0x20000) |
| 3491 | | ); |
| 3492 | | gfxdatahigh = gfxdatalow + xlinesize*ysize; |
| 3493 | | |
| 3494 | | // popmessage("%04x %04x",stv2_current_tilemap.scrollx,stv2_current_tilemap.scrolly); |
| 3495 | | |
| 3496 | | /*Enable fading bit*/ |
| 3497 | | if(stv2_current_tilemap.fade_control & 1) |
| 3498 | | { |
| 3499 | | /*Select fading bit*/ |
| 3500 | | pal_color_offset += ((stv2_current_tilemap.fade_control & 2) ? (2*2048) : (2048)); |
| 3501 | | } |
| 3502 | | |
| 3503 | | stv2_current_tilemap.bitmap_palette_number+=stv2_current_tilemap.colour_ram_address_offset; |
| 3504 | | stv2_current_tilemap.bitmap_palette_number&=7;//safety check |
| 3505 | | |
| 3506 | | screen_x = machine().primary_screen->visible_area().max_x; |
| 3507 | | screen_y = machine().primary_screen->visible_area().max_y; |
| 3508 | | |
| 3509 | | switch(stv2_current_tilemap.colour_depth) |
| 3510 | | { |
| 3511 | | /*Palette Format*/ |
| 3512 | | case 0: |
| 3513 | | for (ycnt = 0; ycnt <ysize;ycnt++) |
| 3514 | | { |
| 3515 | | for (xcnt = 0; xcnt <xsize;xcnt+=2) |
| 3516 | | { |
| 3517 | | if (!stv_vdp2_window_process(xcnt+1,ycnt)) |
| 3518 | | { |
| 3519 | | if ((gfxdata[0] & 0x0f) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3520 | | { |
| 3521 | | if (((xcnt + 1) <= screen_x) && (ycnt <= screen_y)) |
| 3522 | | { |
| 3523 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3524 | | bitmap.pix32(ycnt, xcnt+1) = machine().pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]; |
| 3525 | | else |
| 3526 | | bitmap.pix32(ycnt, xcnt+1) = alpha_blend_r32(bitmap.pix32(ycnt, xcnt+1), machine().pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha); |
| 3527 | | } |
| 3528 | | } |
| 3529 | | } |
| 3530 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3531 | | { |
| 3532 | | if ((gfxdata[0] & 0xf0) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3533 | | { |
| 3534 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3535 | | { |
| 3536 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3537 | | bitmap.pix32(ycnt, xcnt) = machine().pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]; |
| 3538 | | else |
| 3539 | | bitmap.pix32(ycnt, xcnt) = alpha_blend_r32(bitmap.pix32(ycnt, xcnt), machine().pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha); |
| 3540 | | } |
| 3541 | | } |
| 3542 | | } |
| 3543 | | gfxdata++; |
| 3544 | | if ( gfxdata >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3545 | | } |
| 3546 | | } |
| 3547 | | break; |
| 3548 | | case 1: |
| 3549 | | if ( stv2_current_tilemap.incx == 0x10000 && stv2_current_tilemap.incy == 0x10000 ) |
| 3550 | | { |
| 3551 | | //int gfx_wraparound = -1; |
| 3552 | | |
| 3553 | | gfxdata += xlinesize*cliprect.min_y; |
| 3554 | | |
| 3555 | | for (ycnt = cliprect.min_y; ycnt <= cliprect.max_y; ycnt++) |
| 3556 | | { |
| 3557 | | for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xcnt++) |
| 3558 | | { |
| 3559 | | int xs = xcnt & xsizemask; |
| 3560 | | |
| 3561 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3562 | | { |
| 3563 | | //60aee2c = $0013 at @605d838 |
| 3564 | | if ((gfxdata[xs] & 0xff) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3565 | | { |
| 3566 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3567 | | { |
| 3568 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3569 | | bitmap.pix32(ycnt, xcnt) = machine().pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]; |
| 3570 | | else |
| 3571 | | bitmap.pix32(ycnt, xcnt) = alpha_blend_r32(bitmap.pix32(ycnt, xcnt), machine().pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha); |
| 3572 | | } |
| 3573 | | } |
| 3574 | | } |
| 3575 | | if ( (gfxdata + xs) >= gfxdatahigh ) |
| 3576 | | { |
| 3577 | | //gfx_wraparound = (ycnt << 16) | xcnt; |
| 3578 | | gfxdata = gfxdatalow - xs; |
| 3579 | | } |
| 3580 | | } |
| 3581 | | if ( (gfxdata + xlinesize) < gfxdatahigh ) |
| 3582 | | { |
| 3583 | | gfxdata += xlinesize; |
| 3584 | | } |
| 3585 | | else |
| 3586 | | { |
| 3587 | | gfxdata = gfxdatalow + ((gfxdata + xlinesize) - gfxdatahigh); |
| 3588 | | } |
| 3589 | | } |
| 3590 | | |
| 3591 | | } |
| 3592 | | else |
| 3593 | | { |
| 3594 | | int xx, xs, yy=0; |
| 3595 | | for (ycnt = cliprect.min_y; ycnt <= cliprect.max_y; yy+=stv2_current_tilemap.incy, ycnt++ ) |
| 3596 | | { |
| 3597 | | gfxdata += xlinesize*(yy>>16); |
| 3598 | | yy &= 0xffff; |
| 3599 | | |
| 3600 | | xx = 0; |
| 3601 | | for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xx+=stv2_current_tilemap.incx, xcnt++) |
| 3602 | | { |
| 3603 | | xs = xx >> 16; |
| 3604 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3605 | | { |
| 3606 | | if ((gfxdata[xs] & 0xff) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3607 | | { |
| 3608 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3609 | | { |
| 3610 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3611 | | bitmap.pix32(ycnt, xcnt) = machine().pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]; |
| 3612 | | else |
| 3613 | | bitmap.pix32(ycnt, xcnt) = alpha_blend_r32(bitmap.pix32(ycnt, xcnt), machine().pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha); |
| 3614 | | } |
| 3615 | | } |
| 3616 | | } |
| 3617 | | |
| 3618 | | if ( (gfxdata + xs) >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3619 | | |
| 3620 | | } |
| 3621 | | } |
| 3622 | | } |
| 3623 | | break; |
| 3624 | | case 2: |
| 3625 | | for (ycnt = 0; ycnt <ysize;ycnt++) |
| 3626 | | { |
| 3627 | | for (xcnt = 0; xcnt <xsize;xcnt++) |
| 3628 | | { |
| 3629 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3630 | | { |
| 3631 | | if (((gfxdata[0] & 0x07) | (gfxdata[1] & 0xff)) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3632 | | { |
| 3633 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3634 | | { |
| 3635 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3636 | | bitmap.pix32(ycnt, xcnt) = machine().pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset]; |
| 3637 | | else |
| 3638 | | bitmap.pix32(ycnt, xcnt) = alpha_blend_r32(bitmap.pix32(ycnt, xcnt), machine().pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset], stv2_current_tilemap.alpha); |
| 3639 | | } |
| 3640 | | } |
| 3641 | | } |
| 3642 | | |
| 3643 | | gfxdata+=2; |
| 3644 | | if ( gfxdata >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3645 | | } |
| 3646 | | } |
| 3647 | | break; |
| 3648 | | /*RGB format*/ |
| 3649 | | /* |
| 3650 | | M L |
| 3651 | | S S |
| 3652 | | B B |
| 3653 | | --------BBBBBGGGGGRRRRR |
| 3654 | | */ |
| 3655 | | case 3: |
| 3656 | | if ( stv2_current_tilemap.incx == 0x10000 && stv2_current_tilemap.incy == 0x10000 ) |
| 3657 | | { |
| 3658 | | /* adjust for cliprect */ |
| 3659 | | gfxdata += xlinesize*cliprect.min_y; |
| 3660 | | |
| 3661 | | for (ycnt = cliprect.min_y; ycnt <= cliprect.max_y; ycnt++) |
| 3662 | | { |
| 3663 | | destline = &bitmap.pix32(ycnt); |
| 3664 | | |
| 3665 | | for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xcnt++) |
| 3666 | | { |
| 3667 | | int r,g,b; |
| 3668 | | int xs = xcnt & xsizemask; |
| 3669 | | |
| 3670 | | if ((gfxdata[2*xs] & 0x80) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3671 | | { |
| 3672 | | b = pal5bit(((gfxdata[2*xs] & 0x7c) >> 2)); |
| 3673 | | g = pal5bit(((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5)); |
| 3674 | | r = pal5bit(gfxdata[2*xs+1] & 0x1f); |
| 3675 | | if(stv2_current_tilemap.fade_control & 1) |
| 3676 | | stv_vdp2_compute_color_offset(&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3677 | | |
| 3678 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3679 | | { |
| 3680 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3681 | | { |
| 3682 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3683 | | destline[xcnt] = MAKE_RGB(r, g, b); |
| 3684 | | else |
| 3685 | | destline[xcnt] = alpha_blend_r32( destline[xcnt], MAKE_RGB(r, g, b), stv2_current_tilemap.alpha ); |
| 3686 | | } |
| 3687 | | } |
| 3688 | | } |
| 3689 | | |
| 3690 | | if ( (gfxdata + 2*xs) >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3691 | | } |
| 3692 | | |
| 3693 | | gfxdata += xlinesize; |
| 3694 | | if ( gfxdata >= gfxdatahigh ) gfxdata = gfxdatalow + (gfxdata - gfxdatahigh); |
| 3695 | | } |
| 3696 | | |
| 3697 | | } |
| 3698 | | else |
| 3699 | | { |
| 3700 | | int xx, xs, yy=0; |
| 3701 | | |
| 3702 | | for (ycnt = cliprect.min_y; ycnt <= cliprect.max_y; yy+=stv2_current_tilemap.incy, ycnt++ ) |
| 3703 | | { |
| 3704 | | gfxdata += xlinesize*(yy>>16); |
| 3705 | | yy &= 0xffff; |
| 3706 | | |
| 3707 | | destline = &bitmap.pix32(ycnt); |
| 3708 | | xx = 0; |
| 3709 | | for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xx+=stv2_current_tilemap.incx, xcnt++) |
| 3710 | | { |
| 3711 | | int r,g,b; |
| 3712 | | |
| 3713 | | xs = xx >> 16; |
| 3714 | | b = pal5bit(((gfxdata[2*xs] & 0x7c) >> 2)); |
| 3715 | | g = pal5bit(((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5)); |
| 3716 | | r = pal5bit(gfxdata[2*xs+1] & 0x1f); |
| 3717 | | if(stv2_current_tilemap.fade_control & 1) |
| 3718 | | stv_vdp2_compute_color_offset( &r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3719 | | |
| 3720 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3721 | | { |
| 3722 | | if ((gfxdata[2*xs] & 0x80) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3723 | | { |
| 3724 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3725 | | { |
| 3726 | | if ( stv2_current_tilemap.colour_calculation_enabled == 1 ) |
| 3727 | | destline[xcnt] = alpha_blend_r32( destline[xcnt], MAKE_RGB(r, g, b), stv2_current_tilemap.alpha ); |
| 3728 | | else |
| 3729 | | destline[xcnt] = MAKE_RGB(r, g, b); |
| 3730 | | } |
| 3731 | | } |
| 3732 | | } |
| 3733 | | |
| 3734 | | if ( (gfxdata + 2*xs) >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3735 | | } |
| 3736 | | /*Guess: myfairlady needs that the vertical resolution is doubled because it's using the double density mode.*/ |
| 3737 | | if(STV_VDP2_LSMD == 3) { gfxdata += xlinesize*(yy>>16); } |
| 3738 | | else { gfxdata += xlinesize; } |
| 3739 | | if ( gfxdata >= gfxdatahigh ) gfxdata = gfxdatalow + (gfxdata - gfxdatahigh); |
| 3740 | | } |
| 3741 | | } |
| 3742 | | break; |
| 3743 | | /* |
| 3744 | | M L |
| 3745 | | S S |
| 3746 | | B B |
| 3747 | | --------BBBBBBBBGGGGGGGGRRRRRRRR |
| 3748 | | */ |
| 3749 | | case 4: |
| 3750 | | /* adjust for cliprect */ |
| 3751 | | gfxdata += xlinesize*(cliprect.min_y); |
| 3752 | | |
| 3753 | | for (ycnt = cliprect.min_y; ycnt <= cliprect.max_y; ycnt++) |
| 3754 | | { |
| 3755 | | destline = &bitmap.pix32(ycnt); |
| 3756 | | |
| 3757 | | for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xcnt++) |
| 3758 | | { |
| 3759 | | int r,g,b; |
| 3760 | | int xs = xcnt & xsizemask; |
| 3761 | | UINT32 dot_data; |
| 3762 | | |
| 3763 | | dot_data = (gfxdata[4*xs+0]<<24)|(gfxdata[4*xs+1]<<16)|(gfxdata[4*xs+2]<<8)|(gfxdata[4*xs+3]<<0); |
| 3764 | | if ((dot_data & 0x80000000) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE)) |
| 3765 | | { |
| 3766 | | b = ((dot_data & 0x00ff0000) >> 16); |
| 3767 | | g = ((dot_data & 0x0000ff00) >> 8); |
| 3768 | | r = ((dot_data & 0x000000ff) >> 0); |
| 3769 | | |
| 3770 | | if(stv2_current_tilemap.fade_control & 1) |
| 3771 | | stv_vdp2_compute_color_offset(&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3772 | | |
| 3773 | | if (!stv_vdp2_window_process(xcnt,ycnt)) |
| 3774 | | { |
| 3775 | | if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y)) |
| 3776 | | { |
| 3777 | | if ( stv2_current_tilemap.colour_calculation_enabled == 0 ) |
| 3778 | | destline[xcnt] = MAKE_RGB(r, g, b); |
| 3779 | | else |
| 3780 | | destline[xcnt] = alpha_blend_r32( destline[xcnt], MAKE_RGB(r, g, b), stv2_current_tilemap.alpha ); |
| 3781 | | } |
| 3782 | | } |
| 3783 | | } |
| 3784 | | |
| 3785 | | if ( (gfxdata + 4*xs) >= gfxdatahigh ) gfxdata = gfxdatalow; |
| 3786 | | } |
| 3787 | | |
| 3788 | | gfxdata += xlinesize; |
| 3789 | | if ( gfxdata >= gfxdatahigh ) gfxdata = gfxdatalow + (gfxdata - gfxdatahigh); |
| 3790 | | } |
| 3791 | | |
| 3792 | | break; |
| 3793 | | } |
| 3794 | 3446 | } |
| 3795 | 3447 | |
| 3796 | 3448 | /*--------------------------------------------------------------------------- |
| r21122 | r21123 | |
| 5245 | 4897 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N0CAOS; |
| 5246 | 4898 | stv2_current_tilemap.fade_control = (STV_VDP2_N0COEN * 1) | (STV_VDP2_N0COSL * 2); |
| 5247 | 4899 | stv_vdp2_check_fade_control_for_layer(); |
| 5248 | | stv2_current_tilemap.window_control = (STV_VDP2_N0LOG << 0) | |
| 5249 | | (STV_VDP2_N0W0E << 1) | |
| 5250 | | (STV_VDP2_N0W1E << 2) | |
| 5251 | | (STV_VDP2_N0SWE << 3) | |
| 5252 | | (STV_VDP2_N0W0A << 4) | |
| 5253 | | (STV_VDP2_N0W1A << 5) | |
| 5254 | | (STV_VDP2_N0SWA << 6); |
| 4900 | stv2_current_tilemap.window_control.logic = STV_VDP2_N0LOG; |
| 4901 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_N0W0E; |
| 4902 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_N0W1E; |
| 4903 | // stv2_current_tilemap.window_control.? = STV_VDP2_N0SWE; |
| 4904 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_N0W0A; |
| 4905 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_N0W1A; |
| 4906 | // stv2_current_tilemap.window_control.? = STV_VDP2_N0SWA; |
| 5255 | 4907 | |
| 5256 | 4908 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N0LCEN; |
| 5257 | 4909 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N0MZE; |
| r21122 | r21123 | |
| 5345 | 4997 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N1CAOS; |
| 5346 | 4998 | stv2_current_tilemap.fade_control = (STV_VDP2_N1COEN * 1) | (STV_VDP2_N1COSL * 2); |
| 5347 | 4999 | stv_vdp2_check_fade_control_for_layer(); |
| 5348 | | stv2_current_tilemap.window_control = (STV_VDP2_N1LOG << 0) | |
| 5349 | | (STV_VDP2_N1W0E << 1) | |
| 5350 | | (STV_VDP2_N1W1E << 2) | |
| 5351 | | (STV_VDP2_N1SWE << 3) | |
| 5352 | | (STV_VDP2_N1W0A << 4) | |
| 5353 | | (STV_VDP2_N1W1A << 5) | |
| 5354 | | (STV_VDP2_N1SWA << 6); |
| 5000 | stv2_current_tilemap.window_control.logic = STV_VDP2_N1LOG; |
| 5001 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_N1W0E; |
| 5002 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_N1W1E; |
| 5003 | // stv2_current_tilemap.window_control.? = STV_VDP2_N1SWE; |
| 5004 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_N1W0A; |
| 5005 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_N1W1A; |
| 5006 | // stv2_current_tilemap.window_control.? = STV_VDP2_N1SWA; |
| 5355 | 5007 | |
| 5356 | 5008 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N1LCEN; |
| 5357 | 5009 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N1MZE; |
| r21122 | r21123 | |
| 5446 | 5098 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N2CAOS; |
| 5447 | 5099 | stv2_current_tilemap.fade_control = (STV_VDP2_N2COEN * 1) | (STV_VDP2_N2COSL * 2); |
| 5448 | 5100 | stv_vdp2_check_fade_control_for_layer(); |
| 5449 | | stv2_current_tilemap.window_control = (STV_VDP2_N2LOG << 0) | |
| 5450 | | (STV_VDP2_N2W0E << 1) | |
| 5451 | | (STV_VDP2_N2W1E << 2) | |
| 5452 | | (STV_VDP2_N2SWE << 3) | |
| 5453 | | (STV_VDP2_N2W0A << 4) | |
| 5454 | | (STV_VDP2_N2W1A << 5) | |
| 5455 | | (STV_VDP2_N2SWA << 6); |
| 5101 | stv2_current_tilemap.window_control.logic = STV_VDP2_N2LOG; |
| 5102 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_N2W0E; |
| 5103 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_N2W1E; |
| 5104 | // stv2_current_tilemap.window_control.? = STV_VDP2_N2SWE; |
| 5105 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_N2W0A; |
| 5106 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_N2W1A; |
| 5107 | // stv2_current_tilemap.window_control.? = STV_VDP2_N2SWA; |
| 5456 | 5108 | |
| 5457 | 5109 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N2LCEN; |
| 5458 | 5110 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N2MZE; |
| r21122 | r21123 | |
| 5549 | 5201 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N3CAOS; |
| 5550 | 5202 | stv2_current_tilemap.fade_control = (STV_VDP2_N3COEN * 1) | (STV_VDP2_N3COSL * 2); |
| 5551 | 5203 | stv_vdp2_check_fade_control_for_layer(); |
| 5552 | | stv2_current_tilemap.window_control = (STV_VDP2_N3LOG << 0) | |
| 5553 | | (STV_VDP2_N3W0E << 1) | |
| 5554 | | (STV_VDP2_N3W1E << 2) | |
| 5555 | | (STV_VDP2_N3SWE << 3) | |
| 5556 | | (STV_VDP2_N3W0A << 4) | |
| 5557 | | (STV_VDP2_N3W1A << 5) | |
| 5558 | | (STV_VDP2_N3SWA << 6); |
| 5204 | stv2_current_tilemap.window_control.logic = STV_VDP2_N3LOG; |
| 5205 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_N3W0E; |
| 5206 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_N3W1E; |
| 5207 | // stv2_current_tilemap.window_control.? = STV_VDP2_N3SWE; |
| 5208 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_N3W0A; |
| 5209 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_N3W1A; |
| 5210 | // stv2_current_tilemap.window_control.? = STV_VDP2_N3SWA; |
| 5559 | 5211 | |
| 5560 | 5212 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N3LCEN; |
| 5561 | 5213 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N3MZE; |
| r21122 | r21123 | |
| 5579 | 5231 | int planesizex = 0, planesizey = 0; |
| 5580 | 5232 | int planerenderedsizex, planerenderedsizey; |
| 5581 | 5233 | UINT8 colour_calculation_enabled; |
| 5582 | | UINT8 window_control; |
| 5583 | 5234 | UINT8 fade_control; |
| 5584 | 5235 | |
| 5585 | 5236 | if ( iRP == 1) |
| r21122 | r21123 | |
| 5705 | 5356 | |
| 5706 | 5357 | colour_calculation_enabled = stv2_current_tilemap.colour_calculation_enabled; |
| 5707 | 5358 | stv2_current_tilemap.colour_calculation_enabled = 0; |
| 5708 | | window_control = stv2_current_tilemap.window_control; |
| 5709 | | stv2_current_tilemap.window_control = 0; |
| 5359 | // window_control = stv2_current_tilemap.window_control; |
| 5360 | // stv2_current_tilemap.window_control = 0; |
| 5710 | 5361 | fade_control = stv2_current_tilemap.fade_control; |
| 5711 | 5362 | stv2_current_tilemap.fade_control = 0; |
| 5712 | 5363 | g_profiler.start(PROFILER_USER1); |
| r21122 | r21123 | |
| 5738 | 5389 | |
| 5739 | 5390 | mycliprect = cliprect; |
| 5740 | 5391 | |
| 5741 | | if ( window_control ) |
| 5392 | /* TODO: remove me. */ |
| 5393 | if ( stv2_current_tilemap.window_control.enabled[0] || stv2_current_tilemap.window_control.enabled[1] ) |
| 5742 | 5394 | { |
| 5743 | 5395 | //popmessage("Window control for RBG"); |
| 5744 | | stv2_current_tilemap.window_control = window_control; |
| 5396 | stv2_current_tilemap.window_control.enabled[0] = 0; |
| 5397 | stv2_current_tilemap.window_control.enabled[1] = 0; |
| 5745 | 5398 | stv_vdp2_apply_window_on_layer(mycliprect); |
| 5746 | 5399 | } |
| 5747 | 5400 | |
| r21122 | r21123 | |
| 5809 | 5462 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_R0CAOS; |
| 5810 | 5463 | stv2_current_tilemap.fade_control = (STV_VDP2_R0COEN * 1) | (STV_VDP2_R0COSL * 2); |
| 5811 | 5464 | stv_vdp2_check_fade_control_for_layer(); |
| 5812 | | stv2_current_tilemap.window_control = (STV_VDP2_R0LOG << 0) | |
| 5813 | | (STV_VDP2_R0W0E << 1) | |
| 5814 | | (STV_VDP2_R0W1E << 2) | |
| 5815 | | (STV_VDP2_R0SWE << 3) | |
| 5816 | | (STV_VDP2_R0W0A << 4) | |
| 5817 | | (STV_VDP2_R0W1A << 5) | |
| 5818 | | (STV_VDP2_R0SWA << 6); |
| 5465 | stv2_current_tilemap.window_control.logic = STV_VDP2_R0LOG; |
| 5466 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_R0W0E; |
| 5467 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_R0W1E; |
| 5468 | // stv2_current_tilemap.window_control.? = STV_VDP2_R0SWE; |
| 5469 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_R0W0A; |
| 5470 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_R0W1A; |
| 5471 | // stv2_current_tilemap.window_control.? = STV_VDP2_R0SWA; |
| 5819 | 5472 | |
| 5820 | 5473 | stv2_current_tilemap.scrollx = 0; |
| 5821 | 5474 | stv2_current_tilemap.scrolly = 0; |
| r21122 | r21123 | |
| 5954 | 5607 | stv_rbg_cache_data.watch_vdp2_vram_writes &= ~STV_VDP2_RBG_ROTATION_PARAMETER_B; |
| 5955 | 5608 | } |
| 5956 | 5609 | } |
| 5957 | | |
| 5958 | 5610 | } |
| 5959 | | |
| 5960 | 5611 | } |
| 5961 | 5612 | |
| 5962 | 5613 | READ16_MEMBER ( saturn_state::saturn_vdp2_regs_r ) |
| r21122 | r21123 | |
| 6591 | 6242 | int res; |
| 6592 | 6243 | |
| 6593 | 6244 | res = 1; |
| 6594 | | if(stv2_current_tilemap.window_control & (2 << win_num)) |
| 6245 | if(stv2_current_tilemap.window_control.enabled[win_num]) |
| 6595 | 6246 | { |
| 6596 | | if(stv2_current_tilemap.window_control & (0x10 << win_num)) |
| 6247 | if(stv2_current_tilemap.window_control.area[win_num]) |
| 6597 | 6248 | res = (y >= s_y && y <= e_y && x >= s_x && x <= e_x); |
| 6598 | 6249 | else |
| 6599 | 6250 | res = (y >= s_y && y <= e_y && x >= s_x && x <= e_x) ^ 1; |
| r21122 | r21123 | |
| 6607 | 6258 | int s_x=0,e_x=0,s_y=0,e_y=0; |
| 6608 | 6259 | int w0_pix, w1_pix; |
| 6609 | 6260 | |
| 6610 | | if ((stv2_current_tilemap.window_control & 6) == 0) |
| 6261 | if (stv2_current_tilemap.window_control.enabled[0] == 0 && |
| 6262 | stv2_current_tilemap.window_control.enabled[1] == 0) |
| 6611 | 6263 | return 1; |
| 6612 | 6264 | |
| 6613 | 6265 | stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y); |
| r21122 | r21123 | |
| 6616 | 6268 | stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y); |
| 6617 | 6269 | w1_pix = get_window_pixel(s_x,e_x,s_y,e_y,x,y,1); |
| 6618 | 6270 | |
| 6619 | | return stv2_current_tilemap.window_control & 1 ? (w0_pix | w1_pix) : (w0_pix & w1_pix); |
| 6271 | return stv2_current_tilemap.window_control.logic & 1 ? (w0_pix | w1_pix) : (w0_pix & w1_pix); |
| 6620 | 6272 | } |
| 6621 | 6273 | |
| 6274 | /* TODO: remove this crap. */ |
| 6622 | 6275 | int saturn_state::stv_vdp2_apply_window_on_layer(rectangle &cliprect) |
| 6623 | 6276 | { |
| 6624 | 6277 | int s_x=0,e_x=0,s_y=0,e_y=0; |
| 6625 | 6278 | |
| 6626 | | if ( stv2_current_tilemap.window_control == 0x12 ) |
| 6279 | if ( stv2_current_tilemap.window_control.enabled[0] && stv2_current_tilemap.window_control.area[0]) |
| 6627 | 6280 | { |
| 6628 | 6281 | /* w0, transparent outside supported */ |
| 6629 | 6282 | stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y); |
| r21122 | r21123 | |
| 6635 | 6288 | |
| 6636 | 6289 | return 1; |
| 6637 | 6290 | } |
| 6638 | | else if ( stv2_current_tilemap.window_control == 0x24 ) |
| 6291 | else if ( stv2_current_tilemap.window_control.enabled[1] && stv2_current_tilemap.window_control.area[1] ) |
| 6639 | 6292 | { |
| 6640 | 6293 | /* w1, transparent outside supported */ |
| 6641 | 6294 | stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y); |
| r21122 | r21123 | |
| 6757 | 6410 | double_x = 0; |
| 6758 | 6411 | |
| 6759 | 6412 | /* window control */ |
| 6760 | | stv2_current_tilemap.window_control = (STV_VDP2_SPLOG * 0x01) | |
| 6761 | | (STV_VDP2_SPW0E * 0x02) | |
| 6762 | | (STV_VDP2_SPW1E * 0x04) | |
| 6763 | | (STV_VDP2_SPSWE * 0x08) | |
| 6764 | | (STV_VDP2_SPW0A * 0x10) | |
| 6765 | | (STV_VDP2_SPW1A * 0x20) | |
| 6766 | | (STV_VDP2_SPSWA * 0x40); |
| 6413 | stv2_current_tilemap.window_control.logic = STV_VDP2_SPLOG; |
| 6414 | stv2_current_tilemap.window_control.enabled[0] = STV_VDP2_SPW0E; |
| 6415 | stv2_current_tilemap.window_control.enabled[1] = STV_VDP2_SPW1E; |
| 6416 | // stv2_current_tilemap.window_control.? = STV_VDP2_SPSWE; |
| 6417 | stv2_current_tilemap.window_control.area[0] = STV_VDP2_SPW0A; |
| 6418 | stv2_current_tilemap.window_control.area[1] = STV_VDP2_SPW1A; |
| 6419 | // stv2_current_tilemap.window_control.? = STV_VDP2_SPSWA; |
| 6767 | 6420 | |
| 6768 | 6421 | // stv_vdp2_apply_window_on_layer(mycliprect); |
| 6769 | 6422 | |