Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ineluki Key Patch #1181

Closed
Ghabry opened this issue May 24, 2017 · 9 comments · Fixed by #2397
Closed

Ineluki Key Patch #1181

Ghabry opened this issue May 24, 2017 · 9 comments · Fixed by #2397

Comments

@Ghabry
Copy link
Member

Ghabry commented May 24, 2017

DL: http://cherrytree.at/cms/download/?did=3

"This famous tool (which isn’t really a patch but a DLL replacement) allows full keyboard and mouse input as well es executing external programs from an RPG Maker event. It also provides MP3 support, which is very complicated and buggy, however."

Basicly a harmony.dll replacement with "scripts" written as INI files in Music folder...

Files are of format ".script.wav". Player already detects them and reports "Nope!"

@carstene1ns carstene1ns changed the title Patch Support: Ineluki Key Patch Ineluki Key Patch Jul 25, 2017
@Ghabry Ghabry self-assigned this Jan 19, 2018
@Ghabry
Copy link
Member Author

Ghabry commented Jan 19, 2018

Because I'm currently working on this:
https://my.mixtape.moe/mnjlnm.webm

Mouse and Keyboard reading is so useful that it would be a waste to only support it via Ineluki.

I would like to discuss 2 new event commands to make this more accessible (at least we have a working (script) editor thanks to @20kdc). Problem: Not really for Android ^^'.

0xEA511: Get Mouse Position (relative to the window, 0-319; 0-239)

  • Arg 1: Variable X out
  • Arg 2: Variable Y out
    When the cursor is outside the window it returns the last position inside the window.

0xEA512: Key Input Proc Extended

  • Arg 1: Variable that receives the Scancode
  • Arg 2: When 1: Wait for input
  • Arg 3: Measure time until input? 1: Yes
  • Arg 4: Variable that receives time measurement
  • Arg 5: Type of reading (bitfield).

Arg 5 values:

  • 1: Read any keyboard key
  • 2: Read mouse button
  • 4: Read specific key/button. Which keys to read follows as additional arguments (scancode list)

There should be a way to alias specific keyboard keys to joystick buttons but can't be really discussed without any input editor.

Related #491

@20kdc
Copy link
Contributor

20kdc commented Jan 19, 2018

Since I was mentioned:

https://easyrpg.org/irc/log/2018-01-19.html#msg-14:19:24

<t20kdc> Ghabry: Just read your key commands proposal. I'm able to implement this in R48 whenever, though I'd prefer not to put it in the UI if it doesn't exist yet in an implementation.
(one message omitted)
<Ghabry> t20kdc: Sure, and I wait for the others to give some feedback.

@Ghabry
Copy link
Member Author

Ghabry commented Apr 28, 2020

Because we have now this awesome game database @rygos I can make statistics about how terrible this is.

There are 76 RPG2k and 11 RPG2k3 games using this.

The difficult to implement commands are execprogram (worst), mcicommand (needs some parsing and BGM play), registerkeydownevent/registerkeyupevent (needs input polling and a huge mapping table).
getmouseposition is not problematic, this is even exposed through our Ui Api.

Obviously to get a proper statistic would need to parse all ldb and lmu files but this is overkill, so lets only do a basic search:

Nobody uses mcicommand 🎊

ExecProgram by popularity:

ag -A1 "execprogram" | grep -a Command= | cut -d= -f2 |
  sort | uniq -ic | sort -nr

     10 SFX.exe 2
      7 SaveCount.dat
      5 ExitGame.exe
      5 SFX.exe
      3 LS.dat 4645524
      2 PPCOMP.EXE SAVE 1
      2 PPCOMP.EXE Quit
      2 PPCOMP.EXE LOAD 1
      2 LS.dat 4649324
      1 taskkill /IM RPG_RT.exe
      1 re.exe score.png /Y
      1 PPCOMP.EXE UNLOCKPICTURES 1
      1 PPCOMP.EXE SAVE [15]
      1 PPCOMP.EXE Restart
      1 PPCOMP.EXE DELETESAVE <15>
      1 PPCOMP.EXE CHECKSAVE 1 99
      1 PPCOMP.EXE CHECKSAVE 1 22
      1 PPCOMP.DAT SIMULATEKEYPRESS 40 UP
      1 PPCOMP.DAT SIMULATEKEYPRESS 40 DOWN
      1 PPCOMP.DAT SIMULATEKEYPRESS 27 50
      1 PPCOMP.DAT SIMULATEKEYPRESS 13 50
      1 LS.dat 4786428
      1 Load.exe Q

Keys by popularity:

ag -A1 "registerkeydownevent" | grep -a "Key=" |
  iconv -f windows-1252 -t utf-8 | cut -d= -f2 |
  sed -re 's/^\s+//' | sed -re 's/\s+$//' |
  sed -e 's/\(.*\)/\L\1/' | sort | uniq -c | sort -nr

     54 a
     52 s
     47 1
     37 d
     37 4
     37 3
     37 2
     35 7
     35 6
     35 5
     33 8
     31 w
     31 9
     31 0
     30 (tab)
     29 q
     24 f
     22 e
     18 y
     17 t
     16 r
     15 o
     15 g
     14 z
     14 p
     14 m
     14 i
     13 n
     13 c
     13 b
     12 x
     12 v
     12 u
     12 l
     11 k
     11 j
     11 h
     10 (entf)
     10 (ende)
     10 (bildrunter)
     10 (bildhoch)
      9 (pos1)
      9 (einfg)
      8 (strg)
      8 (space)
      8 (runter)
      8 num(-)
      8 num(+)
      8 num(*)
      8 (esc)
      8 (enter)
      7 (rechts)
      7 (links)
      7 (hoch)
      7 (backspace)
      6 ü
      6 ß
      6 ö
      6 (alt)
      6 ä
      6 ^
      6 .
      6 ,
      5 (f1)
      5 ´
      5 <
      5 -
      5 +
      5 #
      4 (scrolllock)
      4 (numlock)
      4 num(5)
      4 num(0)
      4 num(/)
      4 (f9)
      4 (f8)
      4 (f7)
      4 (f6)
      4 (f5)
      4 (f4)
      4 (f3)
      4 (f2)
      4 (f12)
      4 (f11)
      4 (f10)
      4 (capslock)
      1 (rshift hoch)
      1 (lshift runter)
      1 (lshift hoch)

@Ghabry
Copy link
Member Author

Ghabry commented Apr 28, 2020

Based on hash there are 3 versions of ppcomp. Others have only one version. Load.exe is nowhere to be found:

ExitGame.exe
ppcomp3.exe,ppcomp2.exe,ppcomp.exe
SaveCount.dat
LS.dat
re.exe
SFX.exe

ExitGame

Finds the RPG_RT.exe window and sends WM_CLOSE to it.

SaveCount.dat

Creates a Saves.script.wav with this content:

[execute]
Action = MidiTickFunction
Command = output
next=Saves

[Saves]
Action = AddOutPut
Value = 4   <- Amount of lsd files
next=

;by Stephan Fischer

LS.dat

See #1367 (does WriteProcessMemory to the passed address)

SFX.exe

Is some kind of screenshot program (needs testing)

re.exe

Also some kind of screenshot tool

PPComp

Is the PowerPatch Compact (http://cherrytree.at/cms/download/?did=8) by @CherryDT :D

Based on the stats most commands were never used (or the games were lost).

      2 SAVE 1
      2 Quit
      2 LOAD 1
      1 UNLOCKPICTURES 1
      1 SAVE [15]
      1 Restart
      1 DELETESAVE <15>
      1 CHECKSAVE 1 99
      1 CHECKSAVE 1 22
      1 SIMULATEKEYPRESS 40 UP    <- Down Arrow
      1 SIMULATEKEYPRESS 40 DOWN  <- Down Arrow
      1 SIMULATEKEYPRESS 27 50    <- ESC for 50ms
      1 SIMULATEKEYPRESS 13 50    <- ENTER for 50ms

I'm curious if your parser really supported [15] and <15>.
Typical case of users having no idea how to read the docs: >.>

PPCOMP.EXE SAVE [Slot]
PPCOMP.EXE CHECKSAVE <Slot>

@CherryDT
Copy link

CherryDT commented Apr 28, 2020

[15] and such: Haha no that would have loaded and saved game 0 instead. (Which may actually work.)

SFX.exe: It's this one (ignore the SSL error): https://dl1.rpg-atelier.net/ressourcen2/programme/Effect.exe

Load.exe: Ah, this together with more things (save.exe, savecounter.exe, exitsaveload.exe, ls.dat, sfx.exe...) was used in SaveLoad-Script by Vampire of Eternal Chaos. I reuploaded it here now: http://share.cherrytree.at/showfile-33208/saveload_script.zip

PPCOMP Versions: Oh... well.
image
Beyond those, there are also additional "special editions" I made for some people, usually also in different versions, and I have no idea what was special about each of them. :| I also find a "special version of R.D." and "special version R.D. (old)" in my files, and ppcomp_maki is probably the special edition for Makenshi.

For the special ones I have the source though so I could diff it to see what is special, if needed. For the ppcomp2+ppcomp3 I have no idea really

@Ghabry
Copy link
Member Author

Ghabry commented Apr 28, 2020

@CherryDT
Thanks, can confirm that

ExitGame.exe
LS.dat
SFX.exe

are in your linked download and have the same hash.

In case you want to check the powerpatch versions. Here are the md5 hashes:

188874fbf1b721ecaa24cfb737eecca4  ppcomp.exe
b7d4fc28ddfbe40bf88d9d5c78d9dffa  ppcomp2.exe
a3ae915223cff6537f855808a0d6baad  ppcomp3.exe

The naming was by me btw, they were all called ppcomp.exe or ppcomp.dat.

@CherryDT
Copy link

CherryDT commented Apr 28, 2020

Oh. Because I had ppcomp2/ppcomp3 as well and I was already wondering how they got out because I thought this was an internal thing, my own copies of some sort.

OK so 188874FBF1B721ECAA24CFB737EECCA4 is the latest regular one.

My ppcomp_maki/ppcomp2/ppcomp3 are FB3649334A3B72A4CD9981F77E69AEAE, AA8B087F1DA82DB1FFA32628767B8B9A and FE82D6F53B60CFB1A1DA4BA500218C37 respectively. But I have another version also for Makenshi Lachsen apparently which is 8BD992C01F4BA37A64AFDC9CDFA3F1F4 (and next to it is a file powerp_maki_notlachsen.bas where I have no idea what I meant by that but it seems I have another version which says "Makenshi" instead, I guess that's the one I have as ppcomp_maki before). What was special about it is that it had the debug window/watches feature which was not released at that time. I think by now the official version has it too.

B7D4FC28DDFBE40BF88D9D5C78D9DFFA (your "ppcomp2") is what I know as "PPC R.D. Special".

What seems to be special is:

  • sss(...) as Lua-interpreted command (similar to setvar), which calls sss_send.exe with the given string as parameter
  • gamepath exists as string available in Lua commands (sss and setvar)
  • There is a bunch of new magic commands: R.D.-SPECIAL, R.D.-SPECIAL-FINDWINDOW, R.D.-SPECIAL-TESTPLAY, R.D.-SPECIAL-WALLPAPER, R.D.-SPECIAL-WINDOWED, R.D.-SPECIAL-LOADVARS, R.D.-SPECIAL-SAVEVARS.
		Case "R.D.-SPECIAL"
			Do
				WaitUntilActive()
				For i As Integer = 0 To 7
					Var k = Game.Input_FunctionKeys(&h0C + 5 * &h20 + i)
					If (k AndAlso GetAsyncKeyState(k)) Or Game.Switches(CmdEval(Command(3))) Then
						Game.WindowProperty(RM2kDev.WINDOW_MESSAGE Or RM2kDev.WPR_ROLLON1) = 0
						Game.WindowProperty(RM2kDev.WINDOW_MESSAGE Or RM2kDev.WPR_ROLLON2) = 1
						Game.Switches(CmdEval(Command(2))) = TRUE
						Exit Do
					EndIf
				Next
			Loop Until Finished()
		Case "R.D.-SPECIAL-FINDWINDOW"
			Dim tmp As XString
			tmp = Command(3)
			tmp.Replace("$", " ")
			Dim arg As String = tmp
			Game.Switches(CmdEval(Command(2))) = IIf(FindWindow(arg, NULL), TRUE, FALSE)
		Case "R.D.-SPECIAL-TESTPLAY"
			Game.Switches(CmdEval(Command(2))) = GameData.TestPlay
		Case "R.D.-SPECIAL-WALLPAPER"
			Var buf = ExePath & "\Picture\" & Command(2) & ".bmp"
			SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, StrPtr(buf), SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE)
		Case "R.D.-SPECIAL-WINDOWED"
			Game.Switches(CmdEval(Command(2))) = IIf(GetSystemMetrics(SM_CXSCREEN) > 640, TRUE, FALSE)
		Case "R.D.-SPECIAL-SAVEVARS"
			Kill(ExePath & "\Sound\misc" & Command(2) & ".wav")
			Open ExePath & "\Sound\misc" & Command(2) & ".wav" For Binary As #20
			For i As Integer = CmdEval(Command(3)) To CmdEval(Command(3)) + CmdEval(Command(4)) - 1
				Var v = Game.Variables(i)
				Put #20, , v
			Next
			Close #20
		Case "R.D.-SPECIAL-LOADVARS"
			Open ExePath & "\Sound\misc" & Command(2) & ".wav" For Binary As #20
			For i As Integer = CmdEval(Command(3)) To CmdEval(Command(3)) + CmdEval(Command(4)) - 1
				Dim v As Integer
				Get #20, , v
				Game.Variables(i) = v
			Next
			Close #20

The first command I believe does some sort of message-skip mechanism.

For the rest, I think the game used some fourth-wall breaking stuff, that's why it allowed looking for other open windows, changing your wallpaper, checking if you are in fullscreen mode and "stealthily" saving and loading some variabled across savestates by hiding them in a fake sound file.

  • CHANGEFUNCTIONKEY has a weird change where I get the feeling it's actually unintentional because I think it breaks the command... it writes into a wrong memory location for any index other than 0 because it accesses x+index*3 instead of x+index*4 in memory...

Then I have F9B00E137F296C0D3FCD3C8B53DE3226, the "old R.D. special" version which seems to be based off an older version of PPCOMP and has less features.

For a3ae915223cff6537f855808a0d6baad I don't know. Maybe it's an older version of the regular one without watches feature in the debug window.

Btw, I found a game (Mr. Hat II by R.D.) which uses other commands of PPCOMP, in the R.D. Special version. And it also uses the re.exe. Reuploaded: http://share.cherrytree.at/showfile-33210/___mr_hat_ii___.rar

EDIT: The load.exe should also be in the download I linked before!

@Ghabry
Copy link
Member Author

Ghabry commented Aug 20, 2020

The patch is now mostly supported in this branch: https://github.com/EasyRPG/Player/compare/master...Ghabry:ineluki?expand=1

"Execute Program" is not fully working (obviously) and there are some conflicts because we map WSAD to movement and Left/Right click to Confirm/Cancel but otherwise it works quite well. :)

Will open a PR later, need to do more game testing first.

@Ghabry Ghabry added this to the 0.6.3 milestone Oct 12, 2020
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Oct 12, 2020
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Oct 12, 2020
@BossRpg
Copy link

BossRpg commented Feb 11, 2023

It would be very interesting if you could extract this information in a separate file:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants