From a236cb9fb3d288cc63221d92ddc58147fd7ba999 Mon Sep 17 00:00:00 2001 From: Stephen West Date: Sun, 8 Oct 2023 06:39:30 -0600 Subject: [PATCH 1/8] fit mac textures by halving the hud scale when drawing those textures --- TheForceEngine/TFE_DarkForces/hud.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/hud.cpp b/TheForceEngine/TFE_DarkForces/hud.cpp index 1e1da8455..5a2b07a50 100644 --- a/TheForceEngine/TFE_DarkForces/hud.cpp +++ b/TheForceEngine/TFE_DarkForces/hud.cpp @@ -471,6 +471,10 @@ namespace TFE_DarkForces hudScaleY = floatToFixed16(fixed16ToFloat(yScale) * hudSettings->scale); } + u16 hud_width = s_hudStatusL->width; // should be 76 or 76*2 = 152 + u16 hud_height = s_hudStatusL->height; // should be 40 or 80 + u16 hudDoubled = hud_width == 76 ? 0 : 1; + fixed16_16 x0, x1; if (hudSettings->hudPos == TFE_HUDPOS_4_3) { @@ -479,7 +483,7 @@ namespace TFE_DarkForces } else { - x0 = intToFixed16(dispWidth) - mul16(intToFixed16(s_cachedHudRight->width - 1), hudScaleX); + x0 = intToFixed16(dispWidth) - (mul16(intToFixed16(s_cachedHudRight->width - 1), hudScaleX) >> hudDoubled); x1 = 0; } x0 -= intToFixed16(hudSettings->pixelOffset[0]); @@ -490,13 +494,13 @@ namespace TFE_DarkForces y0 += intToFixed16(hudSettings->pixelOffset[2]); y1 += intToFixed16(hudSettings->pixelOffset[2]); - screenGPU_blitTextureScaled(s_hudStatusR, nullptr, x0, y0, hudScaleX, hudScaleY, 255); - screenGPU_blitTextureScaled(s_hudStatusL, nullptr, x1, y1, hudScaleX, hudScaleY, 255); + screenGPU_blitTextureScaled(s_hudStatusR, nullptr, x0, y0, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, 255); + screenGPU_blitTextureScaled(s_hudStatusL, nullptr, x1, y1, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, 255); if ((hudSettings->hudPos == TFE_HUDPOS_4_3 || hudSettings->pixelOffset[0] > 0 || hudSettings->pixelOffset[1] > 0) && s_hudCapLeft && s_hudCapRight) { screenGPU_blitTextureScaled(s_hudCapLeft, nullptr, x1 - mul16(intToFixed16(s_hudCapLeft->width - 1), hudScaleX), y1, hudScaleX, hudScaleY, 31); - screenGPU_blitTextureScaled(s_hudCapRight, nullptr, x0 + mul16(intToFixed16(s_hudStatusR->width), hudScaleX), y1, hudScaleX, hudScaleY, 31); + screenGPU_blitTextureScaled(s_hudCapRight, nullptr, x0 + mul16(intToFixed16(s_hudStatusR->width >> hudDoubled), hudScaleX), y1, hudScaleX, hudScaleY, 31); } // Energy @@ -525,7 +529,6 @@ namespace TFE_DarkForces { char lifeCountStr[8]; sprintf(lifeCountStr, "%1d", lifeCount); - fixed16_16 xPos = mul16(intToFixed16(52), hudScaleX) + x1; fixed16_16 yPos = mul16(intToFixed16(26), hudScaleY) + y1; hud_drawStringGpu(s_hudHealthFont, xPos, yPos, hudScaleX, hudScaleY, lifeCountStr); @@ -538,11 +541,11 @@ namespace TFE_DarkForces fixed16_16 yPos = y0; if (s_headlampActive) { - screenGPU_blitTextureScaled(s_hudLightOn, nullptr, xPos, yPos, hudScaleX, hudScaleY, 31); + screenGPU_blitTextureScaled(s_hudLightOn, nullptr, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, 31); } else { - screenGPU_blitTextureScaled(s_hudLightOff, nullptr, xPos, yPos, hudScaleX, hudScaleY, 31); + screenGPU_blitTextureScaled(s_hudLightOff, nullptr, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, 31); } s_rightHudShow = 4; } From 562f776b34f006c6660e4296603e1ae73076fa11 Mon Sep 17 00:00:00 2001 From: Stephen West Date: Tue, 10 Oct 2023 21:49:39 -0600 Subject: [PATCH 2/8] assign langkeys even if agentmenu.lfd isn't found this doesn't prevent crashing, it simply delays it, but it doesn't give a false crash accessing langKeys which are loaded fine, but not assigned, instead crashes in menu load, which actually didn't load --- TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp b/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp index 82808c720..da27120d4 100644 --- a/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp +++ b/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp @@ -449,8 +449,13 @@ namespace TFE_DarkForces void agentMenu_load(LangHotkeys* langKeys) { + s_langKeys = langKeys; + FilePath filePath; - if (!TFE_Paths::getFilePath("AGENTMNU.LFD", &filePath)) { return; } + if (!TFE_Paths::getFilePath("AGENTMNU.LFD", &filePath)) { + TFE_System::logWrite(LOG_ERROR, "AgentMenu", "agentMenu_load: AGENTMNU.LFD NOT FOUND."); + return; + } Archive* archive = Archive::getArchive(ARCHIVE_LFD, "AGENTMNU", filePath.path); TFE_Paths::addLocalArchive(archive); @@ -459,8 +464,6 @@ namespace TFE_DarkForces s_agentDlgCount = getFramesFromAnim("agentdlg.anim", &s_agentDlgFrames); getFrameFromDelt("cursor.delt", &s_cursor); TFE_Paths::removeLastArchive(); - - s_langKeys = langKeys; } void agentMenu_startup() From 83604863b2a4b9e77ae9e88a8624d1ca975b7964 Mon Sep 17 00:00:00 2001 From: Stephen West Date: Tue, 10 Oct 2023 21:50:21 -0600 Subject: [PATCH 3/8] add mac specific folders/gobs --- TheForceEngine/TFE_DarkForces/darkForcesMain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp b/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp index ca634e3e0..d35671a15 100644 --- a/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp +++ b/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp @@ -71,6 +71,7 @@ namespace TFE_DarkForces "SOUNDS.GOB", "TEXTURES.GOB", "SPRITES.GOB", + "WEAPONS.GOB", // Mac data has weapons in here }; enum GameConstants @@ -1077,6 +1078,8 @@ namespace TFE_DarkForces TFE_Paths::addLocalSearchPath(""); TFE_Paths::addLocalSearchPath("LFD/"); // Dark Forces also adds C:/ and C:/LFD but TFE won't be doing that for obvious reasons... + TFE_Paths::addLocalSearchPath("Cutscenes/"); + // mac data has LFDs in Cutscenes folder // Add some extra directories, if they exist. // Obviously these were not in the original code. From 7b9bfbc4b08fb13167469eeb3014cd4a3cf812ab Mon Sep 17 00:00:00 2001 From: Stephen West Date: Tue, 10 Oct 2023 22:14:57 -0600 Subject: [PATCH 4/8] finish gpu hud scaling --- TheForceEngine/TFE_DarkForces/hud.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/hud.cpp b/TheForceEngine/TFE_DarkForces/hud.cpp index 5a2b07a50..bfe98a2dd 100644 --- a/TheForceEngine/TFE_DarkForces/hud.cpp +++ b/TheForceEngine/TFE_DarkForces/hud.cpp @@ -529,9 +529,10 @@ namespace TFE_DarkForces { char lifeCountStr[8]; sprintf(lifeCountStr, "%1d", lifeCount); + // box starts at x=104, y=52 fixed16_16 xPos = mul16(intToFixed16(52), hudScaleX) + x1; fixed16_16 yPos = mul16(intToFixed16(26), hudScaleY) + y1; - hud_drawStringGpu(s_hudHealthFont, xPos, yPos, hudScaleX, hudScaleY, lifeCountStr); + hud_drawStringGpu(s_hudHealthFont, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, lifeCountStr); s_rightHudShow = 4; } @@ -593,7 +594,7 @@ namespace TFE_DarkForces fixed16_16 xPos = mul16(intToFixed16(15), hudScaleX) + x1; fixed16_16 yPos = mul16(intToFixed16(26), hudScaleY) + y1; - hud_drawStringGpu(s_hudShieldFont, xPos, yPos, hudScaleX, hudScaleY, shieldStr); + hud_drawStringGpu(s_hudShieldFont, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, shieldStr); } // Health { @@ -606,7 +607,7 @@ namespace TFE_DarkForces sprintf(healthStr, "%03d", s_playerInfo.health); fixed16_16 xPos = mul16(intToFixed16(33), hudScaleX) + x1; fixed16_16 yPos = mul16(intToFixed16(26), hudScaleY) + y1; - hud_drawStringGpu(s_hudHealthFont, xPos, yPos, hudScaleX, hudScaleY, healthStr); + hud_drawStringGpu(s_hudHealthFont, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, healthStr); s_leftHudShow = 4; } @@ -651,13 +652,13 @@ namespace TFE_DarkForces } fixed16_16 xPos = mul16(intToFixed16(12), hudScaleX) + x0; fixed16_16 yPos = mul16(intToFixed16(21), hudScaleY) + y0; - hud_drawStringGpu(s_superChargeHud ? s_hudSuperAmmoFont : s_hudMainAmmoFont, xPos, yPos, hudScaleX, hudScaleY, str); + hud_drawStringGpu(s_superChargeHud ? s_hudSuperAmmoFont : s_hudMainAmmoFont, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, str); // Draw a colored quad to hide single-pixel "leaking" from beneath. xPos = mul16(intToFixed16(25), hudScaleX) + x0; yPos = mul16(intToFixed16(12), hudScaleY) + y0; - fixed16_16 quadWidth = mul16(intToFixed16(11), hudScaleX); - fixed16_16 quadHeight = mul16(intToFixed16(7), hudScaleY); + fixed16_16 quadWidth = mul16(intToFixed16(11), hudScaleX >> hudDoubled); + fixed16_16 quadHeight = mul16(intToFixed16(7), hudScaleY >> hudDoubled); screenGPU_drawColoredQuad(xPos, yPos, xPos + quadWidth, yPos + quadHeight, 0); @@ -669,7 +670,7 @@ namespace TFE_DarkForces { sprintf(str, "%02d", ammo1); } - hud_drawStringGpu(s_hudShieldFont, xPos, yPos, hudScaleX, hudScaleY, str); + hud_drawStringGpu(s_hudShieldFont, xPos, yPos, hudScaleX >> hudDoubled, hudScaleY >> hudDoubled, str); s_rightHudShow = 4; } From d9223cca4b9db3c43f582863d3aaa7de9eb1dc11 Mon Sep 17 00:00:00 2001 From: Stephen West Date: Wed, 11 Oct 2023 07:20:02 -0600 Subject: [PATCH 5/8] fix for wait.bm --- TheForceEngine/TFE_DarkForces/mission.cpp | 2 +- TheForceEngine/TFE_Jedi/Renderer/virtualFramebuffer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/mission.cpp b/TheForceEngine/TFE_DarkForces/mission.cpp index 2c2a663fb..cc2d13286 100644 --- a/TheForceEngine/TFE_DarkForces/mission.cpp +++ b/TheForceEngine/TFE_DarkForces/mission.cpp @@ -201,7 +201,7 @@ namespace TFE_DarkForces void mission_createDisplay() { - vfb_setResolution(320, 200); + vfb_setResolution(s_loadScreen->width, s_loadScreen->height); s_framebuffer = vfb_getCpuBuffer(); } diff --git a/TheForceEngine/TFE_Jedi/Renderer/virtualFramebuffer.cpp b/TheForceEngine/TFE_Jedi/Renderer/virtualFramebuffer.cpp index 0e2ba6a7b..4ffbfad80 100644 --- a/TheForceEngine/TFE_Jedi/Renderer/virtualFramebuffer.cpp +++ b/TheForceEngine/TFE_Jedi/Renderer/virtualFramebuffer.cpp @@ -251,7 +251,7 @@ namespace TFE_Jedi { vdispFlags |= VDISP_GPU_COLOR_CONVERT; } - if (graphics->widescreen && (width != 320 || height != 200)) + if (graphics->widescreen && (width != 320 || height != 200) && (width != 640 || height != 480)) { vdispFlags |= VDISP_WIDESCREEN; } From 0fdf5021925548deef205b41848dc6583f3963cd Mon Sep 17 00:00:00 2001 From: Stephen West Date: Wed, 11 Oct 2023 22:08:05 -0600 Subject: [PATCH 6/8] change gob load error to warning for mac weapons.gob --- TheForceEngine/TFE_DarkForces/darkForcesMain.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp b/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp index d35671a15..9d5236728 100644 --- a/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp +++ b/TheForceEngine/TFE_DarkForces/darkForcesMain.cpp @@ -71,7 +71,7 @@ namespace TFE_DarkForces "SOUNDS.GOB", "TEXTURES.GOB", "SPRITES.GOB", - "WEAPONS.GOB", // Mac data has weapons in here + "WEAPONS.GOB", // Mac data has weapons in here instead of textures }; enum GameConstants @@ -1122,7 +1122,12 @@ namespace TFE_DarkForces } else { - TFE_System::logWrite(LOG_ERROR, "Dark Forces Main", "Cannot find required game data - '%s'.", c_gobFileNames[i]); + if (strcmp(c_gobFileNames[i],"WEAPONS.GOB") == 0) { + TFE_System::logWrite(LOG_WARNING, "Dark Forces Main", "Cannot find required mac game data - '%s'.", c_gobFileNames[i]); + } + else { + TFE_System::logWrite(LOG_ERROR, "Dark Forces Main", "Cannot find required game data - '%s'.", c_gobFileNames[i]); + } } } } From 9d51711d6d6ed6c73e4dca98b093310d2639b77c Mon Sep 17 00:00:00 2001 From: Stephen West Date: Thu, 12 Oct 2023 09:05:44 -0600 Subject: [PATCH 7/8] apply hudDoubled to software renderer --- TheForceEngine/TFE_DarkForces/hud.cpp | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/TheForceEngine/TFE_DarkForces/hud.cpp b/TheForceEngine/TFE_DarkForces/hud.cpp index bfe98a2dd..9b48c07ca 100644 --- a/TheForceEngine/TFE_DarkForces/hud.cpp +++ b/TheForceEngine/TFE_DarkForces/hud.cpp @@ -373,7 +373,9 @@ namespace TFE_DarkForces { hud_setupToggleAnim1(JTRUE); } - offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOff, 19, 0); + u16 hudWidth = s_hudStatusL->width; // should be 76(dos) or 76*2 = 152(mac) + u16 hudDoubled = hudWidth == 76 ? 0 : 1; + offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOff, 19 << hudDoubled, 0); } void hud_drawMessage(u8* framebuffer) @@ -471,9 +473,8 @@ namespace TFE_DarkForces hudScaleY = floatToFixed16(fixed16ToFloat(yScale) * hudSettings->scale); } - u16 hud_width = s_hudStatusL->width; // should be 76 or 76*2 = 152 - u16 hud_height = s_hudStatusL->height; // should be 40 or 80 - u16 hudDoubled = hud_width == 76 ? 0 : 1; + u16 hudWidth = s_hudStatusL->width; // should be 76(dos) or 76*2 = 152(mac) + u16 hudDoubled = hudWidth == 76 ? 0 : 1; fixed16_16 x0, x1; if (hudSettings->hudPos == TFE_HUDPOS_4_3) @@ -755,6 +756,9 @@ namespace TFE_DarkForces // Go ahead and just update the HUD every frame, there are already checks to see if each item changed. //if (s_leftHudShow || s_rightHudShow) { + u16 hudWidth = s_hudStatusL->width; // should be 76(dos) or 76*2 = 152(mac) + u16 hudDoubled = hudWidth == 76 ? 0 : 1; + fixed16_16 batteryPower = TFE_Jedi::abs(s_batteryPower * 100); s32 percent = round16(batteryPower >> 1); if (s_prevBatteryPower != percent) // True when energy ticks down. @@ -785,7 +789,7 @@ namespace TFE_DarkForces char lifeCountStr[8]; sprintf(lifeCountStr, "%1d", lifeCount); - hud_drawString(s_cachedHudLeft, s_hudHealthFont, 52, 26, lifeCountStr); + hud_drawString(s_cachedHudLeft, s_hudHealthFont, 52 << hudDoubled, 26 << hudDoubled, lifeCountStr); s_rightHudShow = 4; } @@ -794,11 +798,11 @@ namespace TFE_DarkForces s_prevHeadlampActive = s_headlampActive; if (s_headlampActive) { - offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOn, 19, 0); + offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOn, 19 << hudDoubled, 0); } else { - offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOff, 19, 0); + offscreenBuffer_drawTexture(s_cachedHudRight, s_hudLightOff, 19 << hudDoubled, 0); } s_rightHudShow = 4; } @@ -845,7 +849,7 @@ namespace TFE_DarkForces sprintf(shieldStr, "%03d", s_playerInfo.shields); } s_prevShields = s_playerInfo.shields; - hud_drawString(s_cachedHudLeft, s_hudShieldFont, 15, 26, shieldStr); + hud_drawString(s_cachedHudLeft, s_hudShieldFont, 15 << hudDoubled, 26 << hudDoubled, shieldStr); } if (s_playerInfo.health != s_prevHealth) { @@ -857,7 +861,7 @@ namespace TFE_DarkForces char healthStr[32]; sprintf(healthStr, "%03d", s_playerInfo.health); - hud_drawString(s_cachedHudLeft, s_hudHealthFont, 33, 26, healthStr); + hud_drawString(s_cachedHudLeft, s_hudHealthFont, 33 << hudDoubled, 26 << hudDoubled, healthStr); s_leftHudShow = 4; } @@ -900,7 +904,7 @@ namespace TFE_DarkForces { sprintf(str, "%03d", ammo0); } - hud_drawString(s_cachedHudRight, s_superChargeHud ? s_hudSuperAmmoFont : s_hudMainAmmoFont, 12, 21, str); + hud_drawString(s_cachedHudRight, s_superChargeHud ? s_hudSuperAmmoFont : s_hudMainAmmoFont, 12 << hudDoubled, 21 << hudDoubled, str); if (ammo1 < 0) { @@ -910,7 +914,7 @@ namespace TFE_DarkForces { sprintf(str, "%02d", ammo1); } - hud_drawString(s_cachedHudRight, s_hudShieldFont, 25, 12, str); + hud_drawString(s_cachedHudRight, s_hudShieldFont, 25 << hudDoubled, 12 << hudDoubled, str); s_rightHudShow = 4; s_prevPrimaryAmmo = ammo0; @@ -957,9 +961,11 @@ namespace TFE_DarkForces vfb_getResolution(&dispWidth, &dispHeight); if (dispWidth == 320 && dispHeight == 200) { + u16 hudHeight = s_hudStatusL->height; // should be 40(dos) or 80(mac) + u16 hudOffset = hudHeight - 40; // The original 320x200 code. - hud_drawElementToScreen(s_cachedHudRight, screenRect, 260, c_hudVertAnimTable[s_rightHudVertAnim], framebuffer); - hud_drawElementToScreen(s_cachedHudLeft, screenRect, 0, c_hudVertAnimTable[s_leftHudVertAnim], framebuffer); + hud_drawElementToScreen(s_cachedHudRight, screenRect, 320-s_cachedHudRight->width, c_hudVertAnimTable[s_rightHudVertAnim] - hudOffset, framebuffer); + hud_drawElementToScreen(s_cachedHudLeft, screenRect, 0, c_hudVertAnimTable[s_leftHudVertAnim] - hudOffset, framebuffer); } else { From c53ac85552b8433b5039a2e5e5ef04931a75d143 Mon Sep 17 00:00:00 2001 From: Stephen West Date: Fri, 13 Oct 2023 06:24:49 -0600 Subject: [PATCH 8/8] Support langkeys for agent menu quit --- TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp b/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp index da27120d4..dcae81f58 100644 --- a/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp +++ b/TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp @@ -245,7 +245,7 @@ namespace TFE_DarkForces s_buttonPressed = AGENT_REMOVE; s_buttonHover = JTRUE; } - else if (TFE_Input::keyPressed(KEY_D)) // DOS + else if (TFE_Input::keyPressed(s_langKeys->k_quit)) // DOS { s_buttonPressed = AGENT_EXIT; s_buttonHover = JTRUE;