void CFont::Create (void) { // Check if all the objects to communicate with are set ASSERT (m_pDisplay != NULL); // Set default text/shadow color m_TextColorOffset = GetColorOffset (FONTCOLOR_WHITE); m_ShadowColorOffset = GetColorOffset (FONTCOLOR_BLACK); // Draw the characters in sprite layer 0 by default m_SpriteLayer = 0; // By default don't draw any text shadow m_DrawShadow = false; // Set default shadow direction SetShadowDirection (SHADOWDIRECTION_UP); }
void SetColor(u16 x, u16 y, u8 *color) { u32 offset = GetColorOffset(x, y); if (bpmem.blendmode.colorupdate) { if (bpmem.blendmode.alphaupdate) SetPixelAlphaColor(offset, color); else SetPixelColorOnly(offset, color); } else if (bpmem.blendmode.alphaupdate) SetPixelAlphaOnly(offset, color[ALP_C]); }
void BlendTev(u16 x, u16 y, u8 *color) { u32 dstClr; u32 offset = GetColorOffset(x, y); u8 *dstClrPtr = (u8*)&dstClr; GetPixelColor(offset, dstClrPtr); if (bpmem.blendmode.blendenable) { if (bpmem.blendmode.subtract) SubtractBlend(color, dstClrPtr); else BlendColor(color, dstClrPtr); } else if (bpmem.blendmode.logicopenable) { LogicBlend(*((u32*)color), dstClr, bpmem.blendmode.logicmode); } else { dstClrPtr = color; } if (bpmem.dstalpha.enable) dstClrPtr[ALP_C] = bpmem.dstalpha.alpha; if (bpmem.blendmode.colorupdate) { if (bpmem.blendmode.alphaupdate) SetPixelAlphaColor(offset, dstClrPtr); else SetPixelColorOnly(offset, dstClrPtr); } else if (bpmem.blendmode.alphaupdate) { SetPixelAlphaOnly(offset, dstClrPtr[ALP_C]); } // branchless bounding box update PixelEngine::bbox[0] = std::min(x, PixelEngine::bbox[0]); PixelEngine::bbox[1] = std::max(x, PixelEngine::bbox[1]); PixelEngine::bbox[2] = std::min(y, PixelEngine::bbox[2]); PixelEngine::bbox[3] = std::max(y, PixelEngine::bbox[3]); }
void BlendTev(u16 x, u16 y, u8 *color) { u32 dstClr; u32 offset = GetColorOffset(x, y); u8 *dstClrPtr = (u8*)&dstClr; GetPixelColor(offset, dstClrPtr); if (bpmem.blendmode.blendenable) { if (bpmem.blendmode.subtract) SubtractBlend(color, dstClrPtr); else BlendColor(color, dstClrPtr); } else if (bpmem.blendmode.logicopenable) { LogicBlend(*((u32*)color), dstClr, bpmem.blendmode.logicmode); } else { dstClrPtr = color; } if (bpmem.dstalpha.enable) dstClrPtr[ALP_C] = bpmem.dstalpha.alpha; if (bpmem.blendmode.colorupdate) { if (bpmem.blendmode.alphaupdate) SetPixelAlphaColor(offset, dstClrPtr); else SetPixelColorOnly(offset, dstClrPtr); } else if (bpmem.blendmode.alphaupdate) { SetPixelAlphaOnly(offset, dstClrPtr[ALP_C]); } // branchless bounding box update SWPixelEngine::pereg.boxLeft = SWPixelEngine::pereg.boxLeft>x?x:SWPixelEngine::pereg.boxLeft; SWPixelEngine::pereg.boxRight = SWPixelEngine::pereg.boxRight<x?x:SWPixelEngine::pereg.boxRight; SWPixelEngine::pereg.boxTop = SWPixelEngine::pereg.boxTop>y?y:SWPixelEngine::pereg.boxTop; SWPixelEngine::pereg.boxBottom = SWPixelEngine::pereg.boxBottom<y?y:SWPixelEngine::pereg.boxBottom; }
u8 *GetPixelPointer(u16 x, u16 y, bool depth) { if (depth) return &efb[GetDepthOffset(x, y)]; return &efb[GetColorOffset(x, y)]; }
void GetColor(u16 x, u16 y, u8 *color) { u32 offset = GetColorOffset(x, y); GetPixelColor(offset, color); }