Skip to content

Modifying files in the pack / patch RtMI's .dinky script file - #14

Closed
JanFrederick00 wants to merge 12 commits into
bgbennyboy:masterfrom
JanFrederick00:RtMI-Support
Closed

Modifying files in the pack / patch RtMI's .dinky script file#14
JanFrederick00 wants to merge 12 commits into
bgbennyboy:masterfrom
JanFrederick00:RtMI-Support

Conversation

@JanFrederick00

Copy link
Copy Markdown
Collaborator

I'm not sure if this is useful to many others, but I think it would be a nice addition.

What I did:

  • I refactored the BundleReader_ggpack.
    • It does no longer keep the bundle file open
    • it has functions for adding Files to the bundle
    • This means that the bundle's contents can be modified and saved.
  • Files can now be added to the pack by dragging them into the explorer window.
    • If a file with this name already exists, it will be overwritten.
  • The DinkDisassembler can now save the file again. When not modified, the file's contents are identical to the source file.
  • The DinkDisassembler can apply patches from a JSON-formatted patch file.
    • Add constants
    • modify constant's values
    • replace instructions
    • add instructions between other instructions
    • -> when a file with the extension ".dinkypatch" is draggen into the explorer window, the patch will be applied.

As an example, I have written a "simple" patch file to bypass the main-method's checks for the debug mode and thus enable all of the command line options (--testertron, --soaktron, --jumptron, --checkreachable)

{
	"title": "Enable debug command line options",
	"author": "JanFrederick",
	"description": "Re-activates the debug command-line options --testertron=roomname, --jumptron and --soaktron. Also adds a Log message on startup stating that the game's files have been modified.",
	"function_patches": [
		{
			"script": "Boot.dinky",
			"function": "main",
			"patches": [	
				{
					"type": "add_local",
					"index": 150,
					"value": 1,
					"valuetype": "int",
				},
				{
					"type": "replace_instruction",
					"index": 216,
					"value": "POP",
					"old_value": "JUMP_TOPTRUE 7",
				},	
				{
					"type": "replace_instruction",
					"index": 217,
					"value": "JUMP 105"
				},	
				{
					"type": "replace_instruction",
					"index": 323,
					"value": "PUSH_CONST 150",
					"old_value": "PUSH_GLOBAL 83"
				},
				{ 
					"type": "add_local",
					"value": "This game's scripts have been modified.",
					"index": 151
				},	
				{
					"type": "insert_instructions",
					"index": 0,
					"value": "PUSH_CONST 15 \nPUSH_CONST 151\n PUSH_VAR 17\n CALL 2"
				}
			]
		}
	]	
}

This patch also writes a message into the "Log.txt" file on startup.

Future improvements:

  • At the moment, Thimbleweed Park's pack files cannot be modified because I have not written an encryption routine for TWP's encryption mechanism. This could easily be added.
  • There really should be a GUI / editor for the patch files. Writing this one was pretty tedious.

It would be nice if someone other than me could review this request as I changed quite a few files.

@JanFrederick00

Copy link
Copy Markdown
Collaborator Author

I have added a GUI to create/edit patch files. This PR is obsolete.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant