Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiling a new challenge.chl file
#1
Hello everyone.

I know this has been asked before but I would like to make some very small changes to the challenge.chl file. I saw some programs such as "CHLEX" and "CHASM", which can decompile and recompile the challenge.chl file.
I had success decompiling the challenge.chl file using "CHLEX" but could not recompile the challenge.chl file using "CHASM". I was able to compile one of the example scripts however.

I want to do this for Black & White, not CI. I was linked https://filehorst.de/download.php?file=bbfHEGqg from my previous post here before, but I'm fairly sure this is only for the CI scripting tool.

One thing I'd like to do is simply remove the script that is called to spawn the throwable villager in Land 3. By the looks of it, the script associated with this is called "ThrowBlokeMain" and removing this should be as simple as removing the line that calls this script.
Could someone provide me a small tutorial on the basic compiling of the challenge.chl file either with the mentioned programs above ("CHASM" and "CHLEX") or another way that would be better? Unless it's just not possible for Black & White at all?

Thank you!
Reply
#2
Put challenge.chl into CHLEX's directory.
Create a directory named "example" in the same directory.
Create a .bat file in the same directory, and put this into it:
Code:
chlex challenge.chl /s example/challenge.prj
chlex challenge.chl /ac example
Use the .bat file.
Move the directory named "example" into CHASM's directory.
Create a .bat file in the same directory, and put this into it:
Code:
chasm example/challenge.prj challenge.chl

" strt ThrowBlokeMain" is in the LandControl3.txt.
I didn't test removing it.

" strt TheLostFlock" is in the LandControl1.txt.
I did test removing it. Success.
Reply
#3
Thank you very much.

It decompiles and compiles fine but there's something wrong. The challenge.chl is not working correctly. I did not add or remove anything from the scripts. I simply wanted to test if I could compile a new file first, before I apply any changes that I want to make.

I've attached the two directories of my CHLEX and CHASM. One thing I noticed was that the recompiled challenge.chl is 11kb smaller than the original. If the attachment isn't working correctly, I've also uploaded it here: https://1drv.ms/u/s!AuCZqIgG7CKcihq7vQ1Mj3J1_PXW
Reply
#4
How exactly is it not working correctly?
I tried your .chl, restarted the Player, saw the scrolls.
The difference in size is because of a part at the end of the file, which is not in the recompiled file.
Reply
#5
Me too, but actually click on one of the scrolls. For example, go to Land 2, it will completely bug out. The landscape doesn't load at all.
Reply
#6
You're right about Land 2. I didn't notice any other problems, though.
That last part of the challenge.chl file is, actually, important.
The original LandControlAll.txt has this:
Code:
    load map "scripts/land2.txt"
In CHLEX's version the same part is this:
Code:
    pshi    0x29A0
    sys    0x98
0x29A0 is the offset from the beginning of that last part to the string "scripts/land2.txt".
"scripts/land2.txt" isn't in the disassembled files at all.
So, CHLEX isn't perfect, it doesn't recognize the difference between a simple integer and an offset into that last part.
I doubt that CHASM supports such strings in the code.
It, probably, isn't perfect, either.
Disassembling and assembling the file doesn't damage those offsets, though, so simply duplicating the original file's last part into the new file would restore the lost data.
I made a simple program to do that.
You should be able to add your own strings at the end of that last part by using a HEX editor and correcting the size of that last part, which is 10855 (67 2A 00 00) by default, to use them in your own code by specifying offsets to them.


Attached Files
.zip   bawsiteCHLLastPartCopier.zip (Size: 8.88 KB / Downloads: 4)
Reply
#7
The problem is that it seems all of the quests are actually broken and interacting with them crashes the game, despite me never editing them. Try out a few of the scrolls yourself and you'll encounter problems with many of them. For example, the "rock throwing" tutorial crashes the game.

It should be noted that I did not edit any of the scripts but rather, only decompiled and recompiled the challenge.chl file. I don't want to make it load my own custom code but rather just load slightly modified existing code. So, I'm failing to understand why the offsets for unedited scripts need to be specified, could you elaborate a bit more on the HEX editing step you mentioned? Do I have to specify the offset for every single quest that is broken?

Using your program, I made the original challenge.chl the "source" and my compiled one the "destination". It restored the file size back to the original but it still crashes (probably because I'm stuck at the HEX editing step).

Also, thank you for your time!
Reply
#8
The HEX editing step is just for cases when a custom string would be needed, for example if you would want to add an additional map between Land 1 and Land 2.
There should be no need for it otherwise.

I checked, there really is a problem with throwingstones.txt.
Line 249:
Code:
    until End>0
It made an instruction that was disassembled by CHLEX as this:
Code:
lbl1482:
    jmp    lbl1482
Which is an obvious endless loop, which is what seems to actually happen instead of a crash.
It is assembled by CHASM as something different from what there originally was, so it was supposed to be something else.
The instruction begins at the address 1331888.
The difference is at the address 1331892. In the original version there is "0", in CHASM's version there is "1".
Overwriting that "1" with "0" seems to fix the problem with this specific quest.
But this quest has this problem at more than one location.
Line 379:
Code:
        until End>0
It made an instruction that was disassembled by CHLEX as this:
Code:
lbl149D:
    jmp    lbl149D
The instruction begins at the address 1343328.
The difference is at the address 1343332.
Overwriting both of the "1" with "0" seems to fully fix this specific quest.

The same problem is at 11 other instructions.
List of addresses with the difference:
Code:
434472
436092
437712
439332
440952
442572
1005812
1331892
1343332
1584812
1587292
1680432
1917472

There are 51 other bytes that are different, but they are not of the instructions, so, hopefully, they aren't causing any problems.
If those 51 other bytes aren't causing any problems, then there should be only 13 locations with problems.
So, at most, only 12 quests have the problem. I doubt that there are only 12 quests. Some should be fine.

I made a simple program that can automatically find these endless loops and fix them.


Attached Files
.zip   bawsiteCHLEndlessLoopFixer.zip (Size: 8.74 KB / Downloads: 3)
Reply
#9
Success! I made a small change with Khazar's script at the beginning of Land 2, just to test if it works, and it does.
Check it out!
https://youtu.be/heU4zG9hi2k
Reply
#10
Made some bigger changes here, such changing the music and changing what text is called through creating some custom branches.
Check it out: https://www.youtube.com/watch?v=fAt1pLouNOo&
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)