2439
2437
UINT32 rb = (a & 0xff00ff) + (b & 0xff00ff);
2440
2438
UINT32 g = (a & 0x00ff00) + (b & 0x00ff00);
2441
if (rb & 0x1000000) rb |= 0xff0000;
2442
if (g & 0x10000) g = 0xff00;
2443
if (rb & 0x100) rb |= 0xff;
2444
return (rb & 0xff00ff) | g;
2439
return MAKE_RGB((rb & 0x1000000) ? 0xff : RGB_RED(rb),
2440
(g & 0x0010000) ? 0xff : RGB_GREEN(g),
2441
(rb & 0x0000100) ? 0xff : RGB_BLUE(rb)
2447
2445
static void stv_vdp2_drawgfxzoom(
2774
2771
data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1];
2775
t_pen = (data & 0x8000) || ( transparency == STV_TRANSPARENCY_NONE );
2772
if ((data & 0x8000) || (transparency == STV_TRANSPARENCY_NONE))
2778
b = (data & 0x7c00) >> 7;
2779
g = (data & 0x03e0) >> 2;
2780
r = (data & 0x001f) << 3;
2774
b = pal5bit((data & 0x7c00) >> 10);
2775
g = pal5bit((data & 0x03e0) >> 5);
2776
r = pal5bit( data & 0x001f);
2781
2777
if(stv2_current_tilemap.fade_control & 1)
2782
2778
stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
2887
2882
data = (source[(x_index>>16)*4+0] << 24) | (source[(x_index>>16)*4+1] << 16) | (source[(x_index>>16)*4+2] << 8) | (source[(x_index>>16)*4+3] << 0);
2888
t_pen = (data & 0x80000000) || ( transparency == STV_TRANSPARENCY_NONE );
2883
if ((data & 0x80000000) || (transparency == STV_TRANSPARENCY_NONE))
2891
2885
b = (data & 0xff0000) >> 16;
2892
2886
g = (data & 0x00ff00) >> 8;
2925
2919
int xlinesize = 0/*, xpixelsize = 0*/;
2927
2921
UINT8* gfxdata = state->m_vdp2.gfx_decode;
2928
static UINT32 *destline;
2929
2923
UINT16 pal_color_offset = 0;
2930
2924
UINT8* gfxdatalow, *gfxdatahigh;
2931
/*Window effect 1=no draw*/
2933
/*Transparency code 1=opaque,0=transparent*/
2935
2925
int screen_x,screen_y;
2937
2927
if (!stv2_current_tilemap.enabled) return;
2994
2984
for (xcnt = 0; xcnt <xsize;xcnt+=2)
2996
tw = stv_vdp2_window_process(machine,xcnt+1,ycnt);
2986
if (!stv_vdp2_window_process(machine,xcnt+1,ycnt))
2999
t_pen = (((gfxdata[0] & 0x0f) >> 0) != 0) ? (1) : (0);
3000
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
2988
if ((gfxdata[0] & 0x0f) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3003
2990
if (((xcnt + 1) <= screen_x) && (ycnt <= screen_y))
3005
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3006
bitmap.pix32(ycnt, xcnt+1) = machine.pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3008
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);
2992
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
2993
bitmap.pix32(ycnt, xcnt+1) = machine.pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
2995
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);
3012
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
2999
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3015
t_pen = (((gfxdata[0] & 0xf0) >> 4) != 0) ? (1) : (0);
3016
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3001
if ((gfxdata[0] & 0xf0) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3019
3003
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3021
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3022
bitmap.pix32(ycnt, xcnt) = machine.pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3024
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);
3005
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3006
bitmap.pix32(ycnt, xcnt) = machine.pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3008
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);
3044
3028
int xs = xcnt & xsizemask;
3046
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3030
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3049
3032
//60aee2c = $0013 at @605d838
3050
t_pen = ((gfxdata[xs] & 0xff) != 0) ? (1) : (0);
3051
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3033
if ((gfxdata[xs] & 0xff) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3054
3035
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3056
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3057
bitmap.pix32(ycnt, xcnt) = machine.pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3059
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);
3037
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3038
bitmap.pix32(ycnt, xcnt) = machine.pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3040
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);
3085
3066
gfxdata += xlinesize*(yy>>16);
3088
destline = &bitmap.pix32(ycnt);
3090
3070
for (xcnt = cliprect.min_x; xcnt <= cliprect.max_x; xx+=stv2_current_tilemap.incx, xcnt++)
3093
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3073
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3096
t_pen = ((gfxdata[xs] & 0xff) != 0) ? 1 : 0;
3097
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3075
if ((gfxdata[xs] & 0xff) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3100
3077
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3102
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3103
bitmap.pix32(ycnt, xcnt) = machine.pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3105
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);
3079
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3080
bitmap.pix32(ycnt, xcnt) = machine.pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
3082
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);
3119
3096
for (xcnt = 0; xcnt <xsize;xcnt++)
3121
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3098
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3124
t_pen = ((((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff)) != 0) ? (1) : (0);
3125
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3100
if (((gfxdata[0] & 0x07) | (gfxdata[1] & 0xff)) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3128
3102
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3130
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3131
bitmap.pix32(ycnt, xcnt) = machine.pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset];
3133
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);
3104
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3105
bitmap.pix32(ycnt, xcnt) = machine.pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset];
3107
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);
3163
3137
int xs = xcnt & xsizemask;
3165
t_pen = ((gfxdata[2*xs] & 0x80) >> 7) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE);
3139
if ((gfxdata[2*xs] & 0x80) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3169
b = ((gfxdata[2*xs] & 0x7c) << 1);
3170
g = ((gfxdata[2*xs] & 0x03) << 6) | ((gfxdata[2*xs+1] & 0xe0) >> 2);
3171
r = ((gfxdata[2*xs+1] & 0x1f) << 3);
3141
b = pal5bit(((gfxdata[2*xs] & 0x7c) >> 2));
3142
g = pal5bit(((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5));
3143
r = pal5bit(gfxdata[2*xs+1] & 0x1f);
3172
3144
if(stv2_current_tilemap.fade_control & 1)
3173
3145
stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
3174
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3147
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3177
3149
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3179
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3180
destline[xcnt] = MAKE_RGB(r, g, b);
3182
destline[xcnt] = alpha_blend_r32( destline[xcnt], MAKE_RGB(r, g, b), stv2_current_tilemap.alpha );
3151
if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
3152
destline[xcnt] = MAKE_RGB(r, g, b);
3154
destline[xcnt] = alpha_blend_r32( destline[xcnt], MAKE_RGB(r, g, b), stv2_current_tilemap.alpha );
3211
t_pen = ((gfxdata[2*xs] & 0x80) >> 7);
3212
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3213
b = ((gfxdata[2*xs] & 0x7c) << 1);
3214
g = ((gfxdata[2*xs] & 0x03) << 6) | ((gfxdata[2*xs+1] & 0xe0) >> 2);
3215
r = ((gfxdata[2*xs+1] & 0x1f) << 3);
3183
b = pal5bit(((gfxdata[2*xs] & 0x7c) >> 2));
3184
g = pal5bit(((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5));
3185
r = pal5bit(gfxdata[2*xs+1] & 0x1f);
3216
3186
if(stv2_current_tilemap.fade_control & 1)
3217
3187
stv_vdp2_compute_color_offset(machine, &r,&g,&b,stv2_current_tilemap.fade_control & 2);
3218
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3189
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3191
if ((gfxdata[2*xs] & 0x80) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3223
3193
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
3260
3230
UINT32 dot_data;
3262
3232
dot_data = (gfxdata[4*xs+0]<<24)|(gfxdata[4*xs+1]<<16)|(gfxdata[4*xs+2]<<8)|(gfxdata[4*xs+3]<<0);
3264
t_pen = (dot_data & 0x80000000) >> 31;
3265
if(stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE) t_pen = 1;
3233
if ((dot_data & 0x80000000) || (stv2_current_tilemap.transparency == STV_TRANSPARENCY_NONE))
3269
3235
b = ((dot_data & 0x00ff0000) >> 16);
3270
3236
g = ((dot_data & 0x0000ff00) >> 8);
3273
3239
if(stv2_current_tilemap.fade_control & 1)
3274
3240
stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2);
3275
tw = stv_vdp2_window_process(machine,xcnt,ycnt);
3242
if (!stv_vdp2_window_process(machine,xcnt,ycnt))
3278
3244
if (((xcnt + 0) <= screen_x) && (ycnt <= screen_y))
5382
5348
dot = (gfxdata[base_offs+0]<<8)|gfxdata[base_offs+1];
5383
b = (dot & 0x7c00) >> 7;
5384
g = (dot & 0x03e0) >> 2;
5385
r = (dot & 0x001f) << 3;
5349
b = pal5bit((dot & 0x7c00) >> 10);
5350
g = pal5bit((dot & 0x03e0) >> 5);
5351
r = pal5bit( dot & 0x001f);
5386
5352
if(STV_VDP2_BKCOEN)
5387
5353
stv_vdp2_compute_color_offset( machine, &r, &g, &b, STV_VDP2_BKCOSL );
5584
5550
palette_set_color_rgb(space->machine(),(offset*2)+1,pal5bit(r),pal5bit(g),pal5bit(b));
5586
5552
palette_set_color_rgb(space->machine(),((offset*2)+1)^0x400,pal5bit(r),pal5bit(g),pal5bit(b));
5587
5554
b = ((state->m_vdp2_cram[offset] & 0x7c000000) >> 26);
5588
5555
g = ((state->m_vdp2_cram[offset] & 0x03e00000) >> 21);
5589
5556
r = ((state->m_vdp2_cram[offset] & 0x001f0000) >> 16);
6321
6287
if(STV_VDP2_SPWINEN && pix == 0x8000) /* Pukunpa */
6324
b = (pix & 0x7c00) >> 7;
6325
g = (pix & 0x03e0) >> 2;
6326
r = (pix & 0x1f) << 3;
6290
b = pal5bit((pix & 0x7c00) >> 10);
6291
g = pal5bit((pix & 0x03e0) >> 5);
6292
r = pal5bit( pix & 0x001f);
6328
6293
if ( color_offset_pal )
6330
6295
stv_vdp2_compute_color_offset( machine, &r, &g, &b, STV_VDP2_SPCOSL );
6357
6323
/*shadow - in reality, we should check from what layer pixel beneath comes...*/
6358
6324
if ( STV_VDP2_SDCTL & 0x3f )
6360
bitmap_line[x] = (bitmap_line[x] & ~0x010101) >> 1;
6326
UINT32 p = bitmap_line[x];
6327
bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6362
6329
/* note that when shadows are disabled, "shadow" palette entries are not drawn */
6399
b = (pix & 0x7c00) >> 7;
6400
g = (pix & 0x03e0) >> 2;
6401
r = (pix & 0x1f) << 3;
6366
b = pal5bit((pix & 0x7c00) >> 10);
6367
g = pal5bit((pix & 0x03e0) >> 5);
6368
r = pal5bit( pix & 0x001f);
6402
6369
if ( color_offset_pal )
6404
6371
stv_vdp2_compute_color_offset( machine, &r, &g, &b, STV_VDP2_SPCOSL );
6447
6415
/*shadow - in reality, we should check from what layer pixel beneath comes...*/
6448
6416
if ( STV_VDP2_SDCTL & 0x3f )
6450
bitmap_line[x] = (bitmap_line[x] & ~0x010101) >> 1;
6418
UINT32 p = bitmap_line[x];
6419
bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6452
6421
/* note that when shadows are disabled, "shadow" palette entries are not drawn */
6453
6422
} else if ( pix )
6505
6474
stv_sprite_priorities_in_fb_line[y][sprite_priorities[0]] = 1;
6508
b = (pix & 0x7c00) >> 7;
6509
g = (pix & 0x03e0) >> 2;
6510
r = (pix & 0x1f) << 3;
6478
b = pal5bit((pix & 0x7c00) >> 10);
6479
g = pal5bit((pix & 0x03e0) >> 5);
6480
r = pal5bit( pix & 0x001f);
6511
6481
if ( color_offset_pal )
6513
6483
stv_vdp2_compute_color_offset( machine, &r, &g, &b, STV_VDP2_SPCOSL );
6599
6570
/*shadow - in reality, we should check from what layer pixel beneath comes...*/
6600
6571
if ( STV_VDP2_SDCTL & 0x3f )
6602
bitmap_line[x] = (bitmap_line[x] & ~0x010101) >> 1;
6573
UINT32 p = bitmap_line[x];
6574
bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1);
6604
6576
/* note that when shadows are disabled, "shadow" palette entries are not drawn */
6605
6577
} else if ( pix )
6866
6839
fp=fopen("68k.dmp", "w+b");
6869
fwrite(machine.region(REGION_CPU3)->base(), 0x100000, 1, fp);
6842
fwrite(machine.root_device().memregion(REGION_CPU3)->base(), 0x100000, 1, fp);