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

Inaccurate JSON to binary conversion? #4

Open
rchyla opened this issue Feb 25, 2024 · 0 comments
Open

Inaccurate JSON to binary conversion? #4

rchyla opened this issue Feb 25, 2024 · 0 comments

Comments

@rchyla
Copy link

rchyla commented Feb 25, 2024

I played a small bit with your these tools, but i found out that editing it is quite a chore as everything is inflated out of proportions (although aesthetic). When i tried to look at the binary and the sources of GS tools, although i didn't understand much i noticed that OPcodes may be be same as in NDS script files and to my surprise, when i used an original script from NDS's Phoenix Wright, it ran properly (text was a mess cause of different encoding, but commands were executed properly). Years ago i tried to make my own decoder/encoder for NDS script files, PWSE was quite a chore to use and alpha state to begin with. I made such a tool after some "ordeal" as i'm an amateur and i noticed that original file translated to text with my tool and a file generated by gsmdttool.exe from unmodified JSON is a bit different than source file, the contents may be proper, but something with jump table is not correct.

This is original sc0_text_u.mdt.dec file converted to text:

[0]<noop><6B:1,0,31><bganim:98,626><6B:0,0,0><bganim:98,625>........

---- commands and text here ----

.....<wait:120><nextpage_nobutton>
<speed:255><hidetextbox:1><wait:40><bgcolor:516,1,31><wait:25>
<soundtoggle:1><bganim:0,4096><endjmp>



[1]<noop><person:0,0,0><bg:4095><bgcolor:257,1,31><wait:7>
<name:0><hidetextbox:0><74><p><noop>.....

As you can see, opcode ends the first script, but when i used my tool on a binary file converted from JSON, it looks like this:

[0]<b><noop><hideperson><bganim:98,626><6B:0,0,0>
<bganim:98,625><wait:1><6B:4,1,31><bganim:98,627><bganim:0,8192>...


---- commands and text here ----

<nextpage_nobutton><speed:255><hidetextbox:1><wait:40><bgcolor:516,1,31>
<wait:25><soundtoggle:1><bganim:0,4096><endjmp><noop>
<person:0,0,0>

[1]<noop><noop><bg:4095><bgcolor:257,1,31><wait:7>
<name:0><hidetextbox:0><74><p><noop>
<fademusic:23,0><26:1><wait:30><speed:10><30:2>

First script ends with <person,0,0,0> now. I checked it in the hex editor, original .mdt.dec file from game have 116 entries and generated one have 115 entries, original file points to second script at 0x54c, new file points to 0x54a.

At 0x54a we have 0x0000 0x0000 0x001b. When script is executed in sequence, nothing out of ordinary should happen, but glitches may appear during jump to a previous script. for e.g.

In the original file there are two entries at the end of pointer table that are pointing outside of the script, it seems that one of those is missing, hence two words shift in the file contents. I don't know if those are used in PC version (they are there), but in NDS i had black screen at the end of the case and for a long time i didn't know why.

Edit:

Actually the game crashes (stuck on judge animation, but text doesn't appear) at the first case when judge is about to ask about who defendant is, i imported a script from original PW game form NDS and although a text is garbage, it doesn't crash.

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

No branches or pull requests

1 participant