Description
Game scroll speeds do not scale with view port size and aspect ratio. This is bad, because it means that scrolling LEFT or RIGHT (horizontal) can have different speed than TOP or BOTTOM (vertical). Overall, player has to adjust his scrolling habits to the inconsistency the game supplies.
GenTool fixes this by calculating new values for scroll speed that make its speed consistent under various conditions.
game.dat
GameData.ini contains multiple settings for scrolling, 2 of which are these:
HorizontalScrollSpeedFactor = 1.6; ; Factor applied to the maximum RMB scroll speed. Larger allows faster scrolling.
VerticalScrollSpeedFactor = 2.0; ; Split to account for aspect ratio induced speed limits. Room to mouse drag.
As you can see, instead of having just one scroll speed, we have 2 different ones, so it can be tweaked for one Aspect Ratio only. By default it is set for a 5:4 aspect ratio.
To tweak scroll values we need a few different things:
- memory addresses of horizontal and vertical scroll speed values
- memory address of viewport height (F9 button changes viewport height)
- memory address of camera pitch
- screen width and height
float pointed to by static address 0xA2A2A4
and offset 0x16C
"GameData.ini" CameraPitch
float pointed to by static address 0xA2A2A4
and offset 0x7D8
"GameData.ini" HorizontalScrollSpeedFactor
float pointed to by static address 0xA2A2A4
and offset 0x7DC
"GameData.ini" VerticalScrollSpeedFactor
integer pointed to by static address 0xA2B684
and offset 0x18
"TacticalView" ViewportWidth
integer pointed to by static address 0xA2B684
and offset 0x1C
"TacticalView" ViewportHeight
With these values we can get started. What we want to achieve is combing scroll speed into 1 value, so that if we tweak horizontal scroll speed, the vertical scroll speed is adjusted automatically for any given view port and aspect ratio
We have a function
bool SetScrollSpeed(float hSpeed)
In this function we first make some checks.
if (hSpeed < FLT_EPSILON)
return false;
uint32 viewportHeight;
if (!Hack_GetViewportHeight(viewportHeight))
return false;
Then we do first step to calculate vSpeed
by considering camera pitch. m_cameraPitch
refers to the current camera pitch. Likely 37.5.
// Adjust vertical scroll speed to camera pitch.
float vSpeed = hSpeed / sin(m_cameraPitch * PI / 180.f);
Then we do second step to make further modification to vSpeed
by considering viewport. Note there is some very weird behavior when Aspect ratio doubles vertical scroll speed as soon as aspect ratio crosses multiples of 1.6. With this hack we need to counter act this. In Thyme this weirdness could be tackled differently to avoid countering this strange behavior. Here is the full second step:
// Adjust vertical scroll speed to viewport aspect ratio.
const RECT screenSize = utils::GetScreenSize();
const uint32 screenWidth = screenSize.right;
const uint32 screenHeight = screenSize.bottom;
const float screenAspect = (float)screenWidth / (float)screenHeight;
// Screen aspect ratio of 1.6 and higher will double vertical scroll speed in REGULAR viewport.
// Screen aspect ratio of 3.2 and higher will triple vertical scroll speed in FULL viewport.
// Screen aspect ratio of 3.2 and higher will quadruple vertical scroll speed in REGULAR viewport.
// Compensate by scaling vertical scroll speed accordingly.
vSpeed /= std::max<int>(1, int(screenAspect / 1.6f) * 2 - (viewportHeight / screenHeight));
Looks strange? Yes. Does it work? Yes absolutely. Finally we set the hScroll
and vScroll
values with the addresses provided further up this page.
Hack_SetHorizontalScrollSpeedFactor(hSpeed);
Hack_SetVerticalScrollSpeedFactor(vSpeed);
return true;
Scroll speeds must be refreshed when
- Changing camera pitch
- Changing viewport size (pressing F9 or clicking Control Bar Toggle button)
- Changing resolution