0

Background:

  1. Because HoMM3 was made in dark ages of 800x600 resolution VCMI requires minimum of 800x600
  2. VCMI performs check, via SDL, and crashes itself if pixel resolutions is too small (so no, xrandr --scale 1x1.25 is not a solution, application crashes itself anyway)
  3. Device is RaspberryPi 4B with "original" 800x480 touchscreen, running Ubuntu 20.10
  4. Everything works on big screens, device is fully capable of running VCMI out of a bix. Problem is only in running it in 480p
  5. Windowed mode is playable just by throwing xrandr --mode 800x600 --scale 1.5x1.5, but it breaks touchscreen-to-mouse.

I got it more or less working by stockpiling so many hacks and workarounds that I had to kill error reporting services to not melt my Pi...

  1. Creating custom 800x600@60 resolution with cvt 800 600 60 and xrandr --newmode ... as per How do I set a custom resolution? VCMI now launches in windowed, true fullscreen, and not-true fullscreen (borderless maximized?). Obviously not very playable because bottom 120px of window is out of screen bounds.
  2. Then I scaled down image down to native resolution, 600px * 0.8 = 480px, and discovered that "true fullscreen" ignores scale and "not-true fullscreen" has interesting bug/feature where it scales down to 480px properly but draws centered so image is not aligned with (physical) screen. So ssh'ed from PC and brutally moved it few pixels up until it looked fine and ended up with this abomination: xrandr --output DSI-1 --mode forced600 --transform 1.0,0,0,0,1.25,+80,0,0,1

It "works", but I have problems with mouse and touchpanel due to severe abuse of xrandr --transform. Once I apply my hacks device works in 800x600 resolution with fancy scalling and transforms which results in:

  • mouse being able to go down offscreen, irritating but not "gamebreaking" issue
  • touchscreen accuracy is messed up by non-native resolution, scale, and offset, which makes it hard to accurately touch buttons

How can I fix those two pointer issues? Is there a better way to force VCMI to run in 480p?

PTwr
  • 101

1 Answers1

0

Well, turns out that resolution check is only at startup. Once VCMI is up and running I can just revert to native resolution. VCMI takes care of scaling all on its own, by drawing to fill while keeping aspect ratio. This gets rid of all problems with mouse and touchscreen.

# disable external screen
xrandr --output HDMI-1 --off 
# force 800x600 resolution
xrandr --output DSI-1 --mode forced600
# after 10 seconds reset to standard resolution
( sleep 10; xrandr --output DSI-1 --mode FIXED_MODE --scale 1.0x1.0 ) &
# run game
vcmiclient

However it sadly results in game being letterboxed. TODO: get that touchscreen working with display scaling... TODO: figure out how to right click on touchscreen...

PTwr
  • 101