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

Function weapon_draw

TheForceEngine/TFE_DarkForces/weapon.cpp:989–1119  ·  view source on GitHub ↗

In DOS, this was part of drawWorld() - for TFE I split it out to limit the amount of game code in the renderer.

Source from the content-addressed store, hash-verified

987 // In DOS, this was part of drawWorld() -
988 // for TFE I split it out to limit the amount of game code in the renderer.
989 void weapon_draw(u8* display, DrawRect* rect)
990 {
991 // TFE - don't draw weapon in external camera mode
992 if (s_externalCameraMode)
993 {
994 return;
995 }
996
997 const fixed16_16 weaponLightingZDist = FIXED(6);
998 const fixed16_16 gasmaskLightingZDist = FIXED(2);
999
1000 PlayerWeapon* weapon = s_curPlayerWeapon;
1001 if (weapon && !s_weaponOffAnim)
1002 {
1003 s32 x = weapon->xPos[weapon->frame];
1004 s32 y = weapon->yPos[weapon->frame];
1005 if (weapon->flags & 1)
1006 {
1007 x += weapon->rollOffset;
1008 y += weapon->pchOffset;
1009 }
1010 if (weapon->flags & 2)
1011 {
1012 x += weapon->xWaveOffset;
1013 y += weapon->yWaveOffset;
1014 }
1015 if (weapon->flags & 4)
1016 {
1017 x += weapon->xOffset;
1018 y += weapon->yOffset;
1019 }
1020
1021 const u8* atten = RClassic_Fixed::computeLighting(weaponLightingZDist, 0);
1022 TextureData* tex = weapon->frames[weapon->frame];
1023 if (weapon->ammo && *weapon->ammo == 0 && (weapon->ammo == &s_playerInfo.ammoDetonator || weapon->ammo == &s_playerInfo.ammoMine))
1024 {
1025 tex = s_playerWeaponList[WPN_FIST].frames[0];
1026 }
1027
1028 u32 dispWidth, dispHeight;
1029 vfb_getResolution(&dispWidth, &dispHeight);
1030
1031 if (dispWidth == 320 && dispHeight == 200 && TFE_Jedi::getSubRenderer() != TSR_CLASSIC_GPU)
1032 {
1033 if (atten && !s_weaponLight)
1034 {
1035 blitTextureToScreenLit(tex, rect, x, y, atten, display, JTRUE);
1036 }
1037 else
1038 {
1039 blitTextureToScreen(tex, rect, x, y, display, JTRUE);
1040 }
1041 }
1042 else
1043 {
1044 // HUD scaling.
1045 fixed16_16 xScale = vfb_getXScale();
1046 fixed16_16 yScale = vfb_getYScale();

Callers 2

mission_renderFunction · 0.85
mission_mainTaskFuncFunction · 0.85

Calls 13

vfb_getResolutionFunction · 0.85
getSubRendererFunction · 0.85
vfb_getXScaleFunction · 0.85
vfb_getYScaleFunction · 0.85
floor16Function · 0.85
mul16Function · 0.85
intToFixed16Function · 0.85
vfb_getWidescreenOffsetFunction · 0.85
computeLightingFunction · 0.50
blitTextureToScreenLitFunction · 0.50

Tested by

no test coverage detected