MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / displayHudMessage

Function displayHudMessage

TheForceEngine/TFE_DarkForces/hud.cpp:1248–1317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1246 }
1247
1248 void displayHudMessage(Font* font, DrawRect* rect, s32 x, s32 y, u8* msg, u8* framebuffer)
1249 {
1250 if (!font || !rect || !framebuffer) { return; }
1251 u32 dispWidth, dispHeight;
1252 vfb_getResolution(&dispWidth, &dispHeight);
1253
1254 if (dispHeight == 200)
1255 {
1256 s32 xi = x;
1257 s32 x0 = x;
1258 for (u8 c = *msg; c != 0;)
1259 {
1260 if (c == '\n')
1261 {
1262 xi = x0;
1263 y += font->height + font->vertSpacing;
1264 }
1265 else if (c == ' ')
1266 {
1267 xi += font->width;
1268 }
1269 else if (c >= font->minChar && c <= font->maxChar)
1270 {
1271 s32 charIndex = c - font->minChar;
1272 TextureData* glyph = &font->glyphs[charIndex];
1273 blitTextureToScreen(glyph, rect, xi, y, framebuffer);
1274
1275 xi += font->horzSpacing + glyph->width;
1276 }
1277 msg++;
1278 c = *msg;
1279 }
1280 }
1281 else
1282 {
1283 s32 fntScale = s_hudScaleFactors[HudScale_HudFnt];
1284 fixed16_16 xScale = vfb_getXScale();
1285 fixed16_16 yScale = vfb_getYScale();
1286
1287 xScale /= fntScale;
1288 yScale /= fntScale;
1289
1290 fixed16_16 xf = mul16(intToFixed16(x), xScale);
1291 fixed16_16 yf = mul16(intToFixed16(y), yScale);
1292 fixed16_16 x0 = xf;
1293
1294 fixed16_16 fWidth = mul16(intToFixed16(font->width), xScale);
1295 for (u8 c = *msg; c != 0;)
1296 {
1297 if (c == '\n')
1298 {
1299 xf = x0;
1300 yf += mul16(intToFixed16(font->height + font->vertSpacing), yScale);
1301 }
1302 else if (c == ' ')
1303 {
1304 xf += fWidth;
1305 }

Callers 1

hud_drawMessageFunction · 0.85

Calls 8

vfb_getResolutionFunction · 0.85
vfb_getXScaleFunction · 0.85
vfb_getYScaleFunction · 0.85
mul16Function · 0.85
intToFixed16Function · 0.85
floor16Function · 0.85
blitTextureToScreenFunction · 0.50

Tested by

no test coverage detected