Sunday, September 13, 2020

FMod - v2.11.3

I received a report from a PCKF user that Abiathar was unable to open a certain mod's levels because one level was wider than 255 tiles. Indeed, Abiathar's level size restrictions structure uses one byte to store each dimension, so it couldn't handle larger levels. Such levels have weird behavior in-game past coordinate 255, but they can be played. 

So I increased the default limits to 65,535 (the maximum that can be stored in the standard level format). It wasn't as simple as just increasing some constants, though, because some parts need to pack two coordinates into one 16-bit number, mostly having to do with links. I added some checks to reject link destinations with coordinates larger than 255. Then I found that saving really huge levels crashed because their compressed plane data sizes couldn't be fit into two bytes. I introduced a "maximum area" field to the level size restrictions and added checks for this to the level properties dialog and row/column manipulators.

Since inability to open valid levels is a major problem, I released these changes (and the IMF-related ones waiting in beta) immediately as v2.11.3.

Tuesday, September 8, 2020

Finding out what a "Host Process for Windows Tasks" is doing

Today I noticed a "Host Process for Windows Tasks" process (taskhostw.exe) with heavy disk usage. That name isn't very specific, and indeed the program seems to be just a holder for various tasks' modules. To look at it more closely I fired up Process Explorer as administrator and opened the instance of taskhostw.exe with the most activity. I switched to the Threads tab and looked at the thread with CPU activity. Its Start Address was in SetupCleanupTask.dll, which is located in C:\Windows\System32\oobe.

That was at least more specific, but it didn't tell me exactly what that module does. I went back to the main Process Explorer screen and set View | Lower Pane View to Handles to see what the process had open. Selecting the process and looking through the lower pane, I found that it had some log files open in C:\Windows\Logs\SetupCleanupTask. Skimming those logs suggested that this module checks to see if it's been long enough (10 days) since the last Windows feature update was installed, then deletes the C:\Windows.old folder, reclaiming disk space.

Sunday, September 6, 2020

Tiny Blogger glitch: extra space

Since Google revamped the Blogger management UI to be more modern and bubbly, there's been a tiny glitch with the post editor. When starting a new post, the editor box initially contains one space, so clicking in the box and just starting to type makes the first line start shifted to the right slightly. Deleting the initial space is easy, it's just a strange UI thing.

Friday, September 4, 2020

Selecting a Python virtualenv in Visual Studio Code

I'm using Visual Studio Code to do some Python development over SSH. The project is in a virtualenv, so many packages are not available system-wide, so for autocomplete to fully work VSCode needs to recognize the virtual environment. For some reason I thought this would be more complicated than it is: when selecting the Python interpreter, pick the python symlink inside the virtualenv's bin folder. I also enabled the "Activate Env In Current Terminal" so the shell in the Terminal tab would be immediately ready to go. VSCode doesn't consistently display the environment as a virtualenv in the status bar, at least over SSH, but autocomplete picked up the libraries.

Saturday, August 15, 2020

When VMs won't keep an IPv4 address

Today while troubleshooting Internet slowness on my laptop I noticed that a virtual machine I had running lacked an IPv4 address. It had an IPv6 address and could connect to some sites including the host machine. After some stumbling around I found this Ask Ubuntu answer which mentioned clock skew. Sure enough, my modem/router's time was an hour off, possibly due to automatic Daylight Savings Time adjustment being disabled? I fixed that and made the VM reattempt DHCP configuration. It got an IP address, but with a very short lease. A little while later I found that its IP became the same as the host's, which was concerning. I only got it to hold onto a unique IP by adding a DHCP reservation in the router settings.

Sunday, August 9, 2020

Measuring mouse sensitivity

While writing the Super User answer mentioned in yesterday's post, I needed to measure the ratio of physical mouse movement to pointer movement, making sure my 1:1 acceleration curve was actually equivalent to the desired unaccelerated setting. One of the posts I linked supplies a ZIP file which contains a MouseMovementRecorder ZIP file which contains a program that prints every mouse movement. I launched that program, made a very sudden horizontal or vertical mouse movement, and identified an output line with large distances. Dividing the large component of the "pointer movement" column by its counterpart in "mouse movement" produced the desired ratio, 2.5 by default on my system, though it probably varies by DPI. After setting an acceleration curve with a different slope, I measured again to make sure the ratio was scaled by the desired factor.

Saturday, August 8, 2020

Setting an arbitrarily precise mouse sensitivity

The Mouse Properties dialog has a slider with discrete tick marks for setting the mouse sensitivity. The MouseSensitivity value in HKCU\Control Panel\Mouse has twice the resolution but is still an integer, with a range from 1 to 20. The mapping of that number to sensitivity multiplier is tabulated here.

It is possible to set an arbitrarily precise sensitivity scale by taking advantage of the SmoothMouseXCurve and SmoothMouseYCurve values, which are consulted when "enhance pointer precision" is on. These are explained in great depth in this article, but in summary they are a set of points that describe a piecewise linear function of physical mouse speed to pointer speed. If the curve is changed to a straight line, the fancy pointer-precision-enhancing effect is disabled: a mouse movement's distance alone, not speed, determines the pointer movement distance. Since the curve points are 16.16 fixed-point values, there are far more than 20 options for the slope. Starting from a curve equivalent to the default sixth tick (provided by this site)...

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Mouse]
"SmoothMouseXCurve"=hex:\
    00,00,00,00,00,00,00,00,\
    C0,CC,0C,00,00,00,00,00,\
    80,99,19,00,00,00,00,00,\
    40,66,26,00,00,00,00,00,\
    00,33,33,00,00,00,00,00
"SmoothMouseYCurve"=hex:\
    00,00,00,00,00,00,00,00,\
    00,00,38,00,00,00,00,00,\
    00,00,70,00,00,00,00,00,\
    00,00,A8,00,00,00,00,00,\
    00,00,E0,00,00,00,00,00

...all Y values can be multiplied or all X values can be divided by the sensitivity multiplier of choice. Only the first 4 bytes of each line matter, and they're in little-endian. A logoff/logon cycle may be necessary for the change to take effect.

Based on my Super User answer.