#!/bin/sh
# RE2HD SourceNext 1.1.0 / Classic REbirth 1.0.9.1, 1080p display.
# 1440x1080 full:0 is the native borderless 4:3 mode, verified at 1920x1080.
# Apply synchronously before Wine starts; preserve all other game settings.
[ "$1" = "gameStart" ] || exit 0
[ "$2" = "windows" ] || exit 0
[ "$5" = "/userdata/roms/windows/RE2HD.pc" ] || exit 0
python - <<'PYCONFIG'
from pathlib import Path
import re, datetime
p = Path('/userdata/roms/windows/RE2HD.pc/config.ini')
raw = p.read_bytes()
new, count = re.subn(rb'(?m)^DisplayMode[ \t]*=[^\r\n]*', b'DisplayMode = 1440x1080 0bpp full:0', raw)
if count != 1:
    raise SystemExit('RE2HD: expected exactly one DisplayMode; no changes made')
if new != raw:
    p.write_bytes(new)
with open('/userdata/system/logs/re2hd-fullscreen.log', 'a') as log:
    log.write(str(datetime.datetime.now()) + ' mode=1440x1080 0bpp full:0 changed=' + str(new != raw) + '\n')
PYCONFIG
