Changing the ASM Folder Path

From NSMBW Modding Database
Jump to navigation Jump to search

This will guide you through changing the path of NewerSMBW's ASM folder, which by default is /NewerRes.

Requirements

  • A hex editor (required for Hex Editing method only)
  • An XML or text editor
  • NewerSMBW's Loader.bin or NewerSMBW.xml file (the Loader.bin file is for the Hex Editing method only)
  • First Stage Loader (required for the Code Editing method only, you'll need to know how to set up the First Stage Loader)
  • NewerSMBW sources (required for the Code Editing method only, you'll need to know how to compile NewerSMBW's source code)

XML Editing Method

This method is recommended if you aren't planning on implementing the First Stage Loader or aren't making any code edits in your mod.

Step 1

Open the NewerSMBW.xml file with the XML or text editor. Find this line below:
<folder external="NewerRes" disc="/NewerRes" create="true" />

There's no character limit. Change the name in the external attribute to any name you wish, but don't change the name in the disc attribute, because NewerSMBW must know that the new folder name is the /NewerRes folder.

For example, we'll use the name LongerRes. The changes should now look like the text below:
<folder external="LongerRes" disc="/NewerRes" create="true" />

Step 2

Rename the /NewerRes folder (in the NewerSMBW folder) to LongerRes. Afterwards, save the XML file, and launch NewerSMBW up to see if everything works. If it behaves incorrectly or gives any errors, make sure that you put the new folder name in the external attribute and renamed the /NewerRes folder correctly.

Hex Editing Method

This method is not recommended, because you'll have to redo Step 3 every time you recompile NewerSMBW's source code.

Step 1

Open the Loader.bin file with the hex editor and you should see this text below:

Step 2

Hit Ctrl-H on the keyboard to find and replace text in the hex editor. Type NewerRes in the Find box. Use a name that's 8 characters long, not more, nor less, and put it in the Replace box. Then click OK to replace all the occurrences of the text.

For example, we'll use the name Demo-Res. Make sure to have the "As Text" option checked under both of the boxes, otherwise it'll focus on the hex values instead of the text.

Step 3

Save the Loader.bin file. Now rename the /NewerRes folder (in the NewerSMBW folder) to Demo-Res. Go into the folder that you just renamed and open up the DLCode files with the hex editor:
  • DLCodeEU_1.bin
  • DLCodeEU_2.bin
  • DLCodeJP_1.bin
  • DLCodeJP_2.bin
  • DLCodeKR_3.bin
  • DLCodeTW_4.bin
  • DLCodeUS_1.bin
  • DLCodeUS_2.bin

Hit Ctrl-H on the keyboard to find and replace text in the hex editor. Type NewerRes in the Find box, and put Demo-Res in the Replace box. Then click OK to replace all the occurrences of the text. Repeat this for each DLCode file above.

Step 4

Save all the DLCode files. Now open the NewerSMBW.xml file with the XML or text editor. Find this line below:
<folder external="NewerRes" disc="/NewerRes" create="true" />

Change both instances of /NewerRes to /Demo-Res. Afterwards, save the XML file, and launch NewerSMBW up to see if everything works. If it behaves incorrectly or gives any errors, make sure that you're using the correct folder name.

Code Editing Method (First Stage Loader only)

This method is only recommended if you plan on implementing the First Stage Loader into your mod, and you're making edits to NewerSMBW's source code. See Installing the First Stage Loader to set it up for your mod.

Step 1

Open the PranksterLoader.S file with the text editor, and go to line 266. You should see the following text below:
NewerSystem: .string "/NewerRes/Systemxx_x.bin"
NewerDlcode: .string "/NewerRes/DLCodexx_x.bin"
NewerDlrel:  .string "/NewerRes/DLRelocsxx_x.bin"
Replace NewerRes with your own folder name. For example, we'll use the name LongerRes. The changes should now look like the text below:
NewerSystem: .string "/LongerRes/Systemxx_x.bin"
NewerDlcode: .string "/LongerRes/DLCodexx_x.bin"
NewerDlrel:  .string "/LongerRes/DLRelocsxx_x.bin"

Step 2

Go to line 491 (in the PranksterLoader.S file), and you should see the following text below:
InsertRegionIntoFileName: # inserts the region and version into NewerRes/Systemxx_x.bin
    add       r3, r3, r4
    lbz       r5, 0x40(r31)
    stb       r5, 0(r3)
    lbz       r5, 0x41(r31)
    stb       r5, 1(r3)
    stb       r6, 3(r3)
    blr

The stb lines set where the x variables are filled in by the region and version info. Think of it as xx is 0 and 1, the underscore being 2 (which isn't seen in the code as it doesn't get replaced), and the last x is 3.

Count how many characters that you have and don't have, compared to the original NewerRes folder name (which is 8 characters long). In this case, LongerRes is 9 characters, so we need to adjust each number (in the stb lines) by 1. The changes should now look like the text below:
InsertRegionIntoFileName: # inserts the region and version into LongerRes/Systemxx_x.bin
    add       r3, r3, r4
    lbz       r5, 0x40(r31)
    stb       r5, 1(r3) # first X
    lbz       r5, 0x41(r31)
    stb       r5, 2(r3) # second X, 3 would be the underscore
    stb       r6, 4(r3) # third X
    blr

Adding the comments (starting with #) is optional, as well as changing the folder path in the comment at the top. Afterwards, save the PranksterLoader.S file, recompile the loader, then place it in the NewerSMBW folder. While you're inside the NewerSMBW folder, rename the /NewerRes folder to LongerRes.

Step 3

Open the NewerSMBW.xml file with the XML or text editor. Find this line below:
<folder external="NewerRes" disc="/NewerRes" create="true" />

Change both instances of /NewerRes to /LongerRes. Afterwards, save the XML file, and launch NewerSMBW up. You should be able to now get to the "Hold the Wii Remote sideways" screen without any errors, however the game will freeze at the title screen.

Step 4

The reason why it crashes at the title screen is because while NewerSMBW is now loading the custom code from the /LongerRes folder, the code itself is trying to load some of the resource files from the old /NewerRes folder. So we'll need to edit Newer's source code to change the file path strings.

Here are all of the files in the source code where you need to change /NewerRes to /LongerRes:
  • Kamek/src/koopatlas/mapmusic.cpp, line 72
  • Kamek/src/animtiles.cpp, line 23
  • Kamek/src/creditsMgr.cpp, line 161
  • Kamek/src/levelinfo.cpp, line 12
  • Kamek/src/levelnames.cpp, line 38
  • Kamek/src/msgbox.cpp, line 91
  • Kamek/src/randtiles.cpp, line 101

Do your modifications and save your changes afterwards with each file above. Now compile the source code, and launch NewerSMBW up to see if everything works. If it freezes (usually happens when a file is not found) or gives any invalid read errors, make sure that you're using the correct folder name.