Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: LiTTleDRAgo on November 23, 2018, 03:56:58 am

Title: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: LiTTleDRAgo on November 23, 2018, 03:56:58 am
Is there any way to change smooth mode & reduce screen flickering with a script?

Spoiler: ShowHide
(https://i.imgur.com/zy0Dd4s.jpg)

https://i.imgur.com/zy0Dd4s.jpg
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: Blizzard on November 23, 2018, 12:15:26 pm
I'm not 100% sure, but I think those settings are put into the registry. If you could track down where they are, you could easily use a registry modifier script to change that.
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: LiTTleDRAgo on November 23, 2018, 01:48:34 pm
Oh, you're right!
Thanks Blizz.

Spoiler: ShowHide
(https://i.imgur.com/mf0zIZy.jpg)

https://i.imgur.com/mf0zIZy.jpg

HKEY_CURRENT_USER/Software/Enterbrain/RGSS/SmoothMode
HKEY_CURRENT_USER/Software/Enterbrain/RGSS/WaitForVsync
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: KK20 on November 23, 2018, 02:35:02 pm
I've been tinkering with this for the past couple of hours and don't think it's possible.

OpenKey = Win32API.new('advapi32', 'RegOpenKeyEx', 'lpllp', 'l')
SetKey = Win32API.new('advapi32', 'RegSetValueEx', 'lpllpl', 'l')
CloseKey = Win32API.new('advapi32', 'RegCloseKey', 'l', 'l')


handle = [0].pack('L')
key = [0x80000001, # HKEY_CURRENT_USER , ref: https://www.rubydoc.info/stdlib/dl/2.0.0/Win32/Registry/Constants
       'Software\\Enterbrain\\RGSS',
       0,
       2, #KEY_SET_VALUE
       handle]
p OpenKey.call(*key) # successful = 0
hkey = handle.unpack('L').first


val = [0].pack('L')
reg = [hkey,
      'PlaySound',#'SmoothMode',
      0, # reserved, keep it 0
      0x10, #REG_DWORD
      val, # value to be set
      4] # size of value, in bytes
p SetKey.call(*reg) # successful = 0

p CloseKey.call(hkey)

I had regedit open while running the game and can observe that the registry key did change. But when I press F1 to access the window, the change is not reflected. And after closing the game, the registry key reverts back. If I were to call this on a different key (say RGSS3), then the change is permanent. Opening a RMVXA Game.exe and pressing F1 reflected the updated value.

So my guess is that Game.exe reads the registry keys and values, uses them to initialize the values in the F1 window, then runs the game. When the EXE closes, it checks the values in the F1 window and applies them directly to the registry keys/values. So any registry key modifications done in-game are ultimately ignored.
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: Blizzard on November 23, 2018, 03:01:57 pm
That's a shame. :/ Well, that's XP for you.
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: KK20 on November 23, 2018, 03:20:28 pm
Well there is ONE way, but would require a bit more work.
If you open up another Game.exe *before* closing the first one, you can carry over the change to the new Game.exe.
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: LiTTleDRAgo on November 23, 2018, 03:32:10 pm
I guess it can be do it like this:

Detect if registry key SmoothMode is 0
- Change registry key SmoothMode to 1.
- Open new game instances.
- Exit old game instances.
else
- Nothing happens
end
Title: Re: Regarding [Smooth mode] & [Reduce screen flickering]
Post by: Blizzard on December 03, 2018, 04:42:50 pm
You might wanna try call RegFlushKey before RegCloseKey. https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regclosekey

Quote
The RegCloseKey function does not necessarily write information to the registry before returning; it can take as much as several seconds for the cache to be flushed to the hard disk. If an application must explicitly write registry information to the hard disk, it can use the RegFlushKey function. RegFlushKey, however, uses many system resources and should be called only when necessary.