Code:
//Bitmap Quad()
void do_bmpdrawquadr(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
{
//sdci[1] = layer
int x1 = sdci[2]/10000; //vectorset x1[]
int y1 = sdci[3]/10000; //y1[]
int x2 = sdci[4]/10000; //x2[]
int y2 = sdci[5]/10000; //y2[]
int x3 = sdci[6]/10000; //x3[]
int y3 = sdci[7]/10000; //y3[]
int x4 = sdci[8]/10000; //x4[]
int y4 = sdci[9]/10000; //y4[]
int w = sdci[10]/10000; //w arg, used in vectorsey
int h = sdci[11]/10000; // ... h ; otherwise hardcoded to 256
int color = sdci[12]/10000; //not used
int flip=(sdci[13]/10000)&3; //not used
int bitmapIndex = sdci[14]/10000; //the user bitmap ID.
int polytype = sdci[15]/10000; //render mode
//sdci 16 and 17 reserved and set in globalsymbols as TYPE_FLOAT
//Grab the user bitmap from sdci[14]
BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
//if that bitmap is invalid, exit
if(!sourceBitmap)
{
Z_message("Warning: Screen->DrawBitmapQuad(%d) contains invalid data or is not initialized.\n", bitmapIndex);
Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
return;
}
//make a bitmap pointer and try to get a subbitmap
BITMAP* subBmp = script_drawing_commands.AquireSubBitmap(256, 256);
//Safety net
bool mustDestroyBmp = false;
//if we couldn't grab an available sub bitmap, make one, and clear it.
if(!subBmp)
{
mustDestroyBmp = true;
subBmp = create_bitmap_ex(8, 256, 256);
clear_bitmap(subBmp);
}
//blit the user bitmap to the sub bitmap
masked_stretch_blit(sourceBitmap, subBmp, 0, 0, 256, 256, 0, 0, 256, 256);
//populate the vectors
V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, 0 };
V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), 0 };
V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h),0 };
V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, 0 };
//log the event
Z_message("BitmapQuad() : Trying to draw Bitmap ID", bitmapIndex);
// Draw the quad using the sub bitmap as the render source, to the screen 'bmp'
quad3d_f(bmp, polytype, subBmp, &V1, &V2, &V3, &V4);
//if we created a new bitmap, purge it
if ( mustDestroyBmp )
destroy_bitmap(subBmp);
} //end