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

Function hud_drawAndUpdate

TheForceEngine/TFE_DarkForces/hud.cpp:889–1203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887 }
888
889 void hud_drawAndUpdate(u8* framebuffer)
890 {
891 // Handle the case where the HUD has not been loaded.
892 if (!s_hudStatusL || !s_hudStatusR) { return; }
893
894 // Fix-up textures/fonts on change.
895 const bool enableHdHud = TFE_Settings::getEnhancementsSettings()->enableHdHud && TFE_Settings::getGraphicsSettings()->colorMode == COLORMODE_TRUE_COLOR &&
896 TFE_Settings::getGraphicsSettings()->rendererIndex == RENDERER_HARDWARE;
897 if ((s_hudStatusL == s_texIndex[HudTex_StatusL_Hd] && TFE_Settings::getGraphicsSettings()->rendererIndex != RENDERER_HARDWARE) ||
898 (enableHdHud && s_hudStatusL == s_texIndex[HudTex_StatusL] && s_texIndex[HudTex_StatusL_Hd]))
899 {
900 hud_reloadTextures();
901 }
902
903 ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_UI);
904
905 // TFE Note: drawing the HUD when GPU rendering is enabled is a bit different, since we can just draw all of the items scaled.
906 if (TFE_Jedi::getSubRenderer() == TSR_CLASSIC_GPU)
907 {
908 hud_drawGpu();
909 return;
910 }
911
912 // Clear the 3D view while the HUD positions are being animated.
913 if (s_rightHudMove || s_leftHudMove)
914 {
915 if (s_rightHudMove)
916 {
917 s_rightHudMove--;
918 }
919 if (s_leftHudMove)
920 {
921 s_leftHudMove--;
922 }
923 clear3DView(framebuffer);
924 }
925
926 // Go ahead and just update the HUD every frame, there are already checks to see if each item changed.
927 //if (s_leftHudShow || s_rightHudShow)
928 {
929 fixed16_16 batteryPower = TFE_Jedi::abs(s_batteryPower * 100);
930 s32 percent = round16(batteryPower >> 1);
931 if (s_prevBatteryPower != percent) // True when energy ticks down.
932 {
933 s_prevBatteryPower = percent;
934 const s32 offset = 3 * 3 + 1; // offset 3 color indices + 1 because we are only changing the green color.
935 // I think this should be < 5, since there are 5 pips.
936 // This actually overwrites memory in DOS, but here I just made the array larger.
937 for (s32 clrIndex = 0; clrIndex <= 5; clrIndex++)
938 {
939 if (percent > 20)
940 {
941 s_hudWorkPalette[3 * clrIndex + offset] = 58;
942 percent -= 20;
943 }
944 else
945 {
946 // Color value between [8, 58], where 8 @ 0% and 58 @ 20%

Callers 2

mission_renderFunction · 0.85
mission_mainTaskFuncFunction · 0.85

Calls 15

getEnhancementsSettingsFunction · 0.85
getGraphicsSettingsFunction · 0.85
hud_reloadTexturesFunction · 0.85
vfb_getScreenRectFunction · 0.85
getSubRendererFunction · 0.85
hud_drawGpuFunction · 0.85
absFunction · 0.85
round16Function · 0.85
player_getLifeCountFunction · 0.85
hud_drawStringFunction · 0.85
minFunction · 0.85

Tested by

no test coverage detected