don't click here

Nights Journey of Dreams Debug/misc research

Discussion in 'Technical Discussion' started by evilhamwizard, Feb 2, 2011.

  1. evilhamwizard

    evilhamwizard

    Researcher
    1,392
    455
    63
    *PLEASE NOTE: some of this might be incorrect, as this is still ongoing.*

    I love it when developers put the right amount of files in games so that all it requires to activate debug stuff is to turn on a few variables in config/lua files. Like Shadow the Hedgehog, you can configure the game using the game's configuration files. Unlike Shadow the Hedgehog where it seems that nothing works, it appears that it is possible to get the debug crap to appear in this game.

    Since this game was programmed/developed by the same people who brought you Shadow the Hedgehog and some of the Wii Sonic games (namely the storybook games), it appears that these games share similar configuration files. You can configure the ROM version (alpha/beta/tgs/e3/development/etc), choose who the user that's debugging the game is, activate the debugging flags, etc. You name it, you can probably modify it.

    But let's talk about Nights JoD for a moment. This game appears to use multiple files for configuration, whereas in Shadow the Hedgehog everything was in that one or two .ini files. The game appears to take note of 3 configuration files:

    According to Config.txt (this file describes what each configuration setting does, yay!):
    Config.lua ????????????? (used for the retail version of the game, the final version uses this lua file for it's settings)
    ConfigDebug.lua ?????????????(D,DO?) (used for developer copies? I think there's a way to make the game iso/image itself appear to be a developers copy but I forget how. doing so will probably activate this config file by default instead)
    _ConfigUser.lua ?????????????? ConfigUser.lua??????(used to override settings depending on which user is debugging the game, not sure if this particular file is used since there's a ConfigUser.lua file without the underscore - I need to look into this more)

    What I've currently checked out so far is Config.lua. The Config.lua file takes two functions into consideration, PjnConfigBeforeInstance() and PjnConfigAfterInstance(). For the retail release, the BeforeInstance has nothing under the function. This means that there aren't any settings being activated before the game itself loads (I think this means even before the Sega logo appears). Normally, according to ConfigDebug, this is where you would activate the user/debug/trace flags. Since this is the config file for the release build, it makes sense that there wouldn't be any here. For the AfterInstance function, this is where settings are activated AFTER the game loads up. This is where you'll be able to configure the Romversion, the BootModule (does the game boot up at the logo? the "viewer"? the "unittest"? these are .rso module files located in the rso directory), and either or not the game uses the resource files located at the root of the data partition of the disk.

    When I dive into this a little bit more, I'll see what everything does specifically later. But for now, let's look at what the Romversion can do.

    Here are all the Romversions the game will recognize.

    Code (Text):
    1. -- Romversion ---------------------------- 
    2. --    SetRomVersion("DEVELOPMENT")
    3. --    SetRomVersion("FIRST")
    4. --    SetRomVersion("SECOND")
    5. --    SetRomVersion("THIRD")
    6. --    SetRomVersion("ALPHA")
    7. --    SetRomVersion("E3")
    8. --    SetRomVersion("BETA")
    9. --    SetRomVersion("TGS")
    10. ------------------------------------------
    This is what it looks like in Config.lua by default. As you can see, everything is commented out by the — This means that it will run at the default retail setting. But what happens when you remove the -- from one of the SetRomVersions? Let's take a look at what happens with each one.

    DEVELOPMENT - After the Sonic Team logo, the screen is black. It seems that you can still scroll about some menu, which might be the menu that loads up after you press start at the title screen - but it's hard to tell what the heck it is because everything is invisible. You can get the game to load up by fidgeting around a bit - but by default, it appears that you can't get into any of the stages and you can restart/quit the game from pressing the + button or whatever. Also, since there aren't any debug/trace flags enabled by default, it appears that nothing shows up. Might need to look into this a bit more.

    FIRST - Crashes after Sonic Team logo, boo.

    SECOND - Loads up to NiGHTs after the Sonic Team logo. You can only move in place. Trying to exit the game will bring you back to the same place. None of the game's counters are enabled.

    THIRD - Same as Second.

    ALPHA - It appears to load up the game as if it were the retail game. I wouldn't suspect any differences anyway, boo.

    E3 - Success!

    [​IMG]

    Pressing + will load up Aqua Garden automatically. No stage select like a demo would.

    BETA - Same as ALPHA.

    TGS - Success!

    [​IMG]

    There's even a stage select as well!

    [​IMG]

    However, it doesn't appear that all stages work. Aqua Garden works, Lost Park seems to crash the game, "Liver Rescue" (rofl) seems to go back to the Title Screen. There might be more stages that work/don't work, I have to check.

    That's all I have for now. It's pretty difficult for me to check each setting, because I have to use WiiScrubber 1.21 (newer version seem to corrupt the ISO when replacing files) on the ISO every time to replace the config file. It's not that big of a deal, but where the real problem comes in is when you want to replace the config file with a slightly larger file. In order to replace the file with WiiScrubber, you need to have the file either be smaller or at the same size as the file on the ISO. I know I can make the ISO larger so I can replace it with files that are larger, but I don't think I can with 1.21. Oh well. In order for me to mess around with the configuration files, I'd have to either get rid of the comments and anything that's commented out - or use Riivolution. But since Riivolution is anti-backup, I can't use it. Bummer.

    For the sake of showing off the config files in their entirety, I uploaded the lua/luaObject folders so you can check them out. Just note, some of them are modified because of me, but I kept the original configuration files as separate files.

    But I really wish that someone else can help me with this, since this could get very interesting. I'm sure we can get the debug crap back up and running with this retail copy of the game.

    Any recommendations, tips, advice, etc would be most helpful.
     
  2. evilhamwizard

    evilhamwizard

    Researcher
    1,392
    455
    63
    Okay, I'm getting a little closer, I can feel it. At least, I'm starting to get a sense of what's actually happening.

    Thanks to Dolphin's Logging features, I was able to see what files NiGHTs JoD was loading from the moment I launched the ISO to when I get to the blank screen (which I'm very very very sure now is a debug menu with no graphics loaded, see below for more info).

    Here's the log of what occurs up until the point I get the blank screen:

    Code (Text):
    1. 10:00:532 .\Src\Boot\Boot.cpp:164 N[BOOT]: Booting D:\jod\jod.iso
    2. 10:00:748 .\Src\Hle\HLE_OS.cpp:52 N[OSREPORT]: 812003d8->81300000|
    3. Apploader Initialized.
    4. 10:00:748 .\Src\Hle\HLE_OS.cpp:52 N[OSREPORT]: 812003f4->81300000| This Apploader built Mar  1 2007 02:16:30 for RVL
    5. 10:01:125 .\Src\PowerPC\Interpreter\Interpreter_SystemRegisters.cpp:353 N[PowerPC]: Flush Instruction Cache! ICE=0
    6. 10:01:143 .\Src\PowerPC\Interpreter\Interpreter_SystemRegisters.cpp:344 N[PowerPC]: Instruction Cache Enable (HID0.ICE) = 1
    7. 10:01:144 c:\dokumente und einstellungen\saber\desktop\cruisecontrol\repository\dolphin\source\core\core\src\ipc_hle\WII_IPC_HLE_Device.h:233 W[WII_IPC_HLE]: /dev/usb/hid faking Close()
    8. 10:01:144 c:\dokumente und einstellungen\saber\desktop\cruisecontrol\repository\dolphin\source\core\core\src\ipc_hle\WII_IPC_HLE_Device.h:77 W[WII_IPC_HLE]: _Unimplemented_Device_ does not support Close()
    9. 10:01:218 .\Src\FileUtil.cpp:98 W[COMMON]: IsDirectory: stat failed on : The system cannot find the path specified.
    10.  
    11. 10:02:076 .\Src\FileMonitor.cpp:108 W[FileMon]:       6 kB lua/Config.lua
    12. 10:02:090 .\Src\IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp:125 W[WII_IPC_FILEIO]: FileIO: Open failed - File doesn't exist ./User/Wii/title/00010002/4841464a/data/wc24dl.vff
    13. 10:02:092 .\Src\IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp:125 W[WII_IPC_FILEIO]: FileIO: Open failed - File doesn't exist ./User/Wii/title/00010002/48414645/data/wc24dl.vff
    14. 10:02:093 .\Src\IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp:125 W[WII_IPC_FILEIO]: FileIO: Open failed - File doesn't exist ./User/Wii/title/00010002/48414650/data/wc24dl.vff
    15. 10:02:114 .\Src\FileMonitor.cpp:108 W[FileMon]:       6 kB hbm/HomeButton2/homeBtnIcon.tpl
    16. 10:02:173 .\Src\FileMonitor.cpp:108 W[FileMon]:       3 kB lua/LaderTable.lua
    17. 10:02:176 .\Src\FileMonitor.cpp:108 W[FileMon]:   9,795 kB hugeData/PJN_voices.afs
    18. 10:02:179 .\Src\FileMonitor.cpp:108 W[FileMon]:       9 kB lua/ResultTable.lua
    19. 10:02:183 .\Src\FileMonitor.cpp:108 W[FileMon]:       3 kB lua/StageTable.lua
    20. 10:02:185 .\Src\FileMonitor.cpp:108 W[FileMon]:      27 kB banner/bannerUs.tpl
    21. 10:02:187 .\Src\FileMonitor.cpp:108 W[FileMon]:       4 kB banner/icon.tpl
    22. 10:02:241 .\Src\FileMonitor.cpp:108 W[FileMon]:     585 kB csd/textures/straprminderen.tls
    23. 10:02:249 .\Src\FileMonitor.cpp:108 W[FileMon]:       2 kB csd/advertise/pjn_strap_reminder.one
    24. 10:02:304 .\Src\IPC_HLE\WII_IPC_HLE_Device_fs.cpp:140 W[WII_IPC_FILEIO]:     Not a directory - return FS_INVALID_ARGUMENT
    25. 10:02:314 .\Src\IPC_HLE\WII_IPC_HLE_Device_fs.cpp:140 W[WII_IPC_FILEIO]:     Not a directory - return FS_INVALID_ARGUMENT
    26. 10:02:466 .\Src\IPC_HLE\WII_IPC_HLE_Device_fs.cpp:140 W[WII_IPC_FILEIO]:     Not a directory - return FS_INVALID_ARGUMENT
    27. 10:02:501 .\Src\IPC_HLE\WII_IPC_HLE_Device_fs.cpp:140 W[WII_IPC_FILEIO]:     Not a directory - return FS_INVALID_ARGUMENT
    28. 10:12:582 .\Src\FileMonitor.cpp:108 W[FileMon]:     131 kB csd/textures/logo_1stromus.tls
    29. 10:12:584 .\Src\FileMonitor.cpp:108 W[FileMon]:       1 kB csd/advertise/Logo_1stROM.one
    30. 10:12:749 .\Src\FileMonitor.cpp:108 W[FileMon]:      65 kB csd/textures/pjn_btnwindowus.tls
    31. 10:12:751 .\Src\FileMonitor.cpp:108 W[FileMon]:      22 kB csd/textures/pjn_infoiconsus.tls
    32. 10:12:753 .\Src\FileMonitor.cpp:108 W[FileMon]:      92 kB csd/textures/pjn_message_btnus.tls
    33. 10:12:755 .\Src\FileMonitor.cpp:108 W[FileMon]:     432 kB hbm/HomeButton2/homeBtn_ENG.arc
    34. 10:12:761 .\Src\FileMonitor.cpp:108 W[FileMon]:      59 kB hbm/HomeButton2/SpeakerSe.arc
    35. 10:12:763 .\Src\FileMonitor.cpp:108 W[FileMon]:       2 kB hbm/HomeButton2/home_nosave.csv
    36. 10:12:765 .\Src\FileMonitor.cpp:108 W[FileMon]:       0 kB hbm/HomeButton2/config.txt
    37. 10:12:767 .\Src\FileMonitor.cpp:108 W[FileMon]:     134 kB rso/NightsWii.sel
    38. 10:12:770 .\Src\FileMonitor.cpp:108 W[FileMon]:       5 kB csd/advertise/pjn_hud_btnwindow.one
    39. 10:12:772 .\Src\FileMonitor.cpp:108 W[FileMon]:       4 kB csd/advertise/pjn_hud_infoicons.one
    40. 10:12:773 .\Src\FileMonitor.cpp:108 W[FileMon]:       6 kB csd/advertise/pjn_hud_message_btn.one
    41. 10:12:787 .\Src\FileMonitor.cpp:108 W[FileMon]:   2,464 kB rso/global.rso
    42. 10:12:859 .\Src\FileMonitor.cpp:108 W[FileMon]:   2,145 kB fontJapan.inf
    43. 10:12:883 .\Src\FileMonitor.cpp:108 W[FileMon]:   2,145 kB fontJapan_16.inf
    44. 10:13:012 .\Src\FileMonitor.cpp:108 W[FileMon]:     313 kB fontJapan.bin
    45. 10:13:115 .\Src\FileMonitor.cpp:108 W[FileMon]:     137 kB fontJapan_16.bin
    46. 10:13:151 .\Src\FileMonitor.cpp:108 W[FileMon]:   1,673 kB hugeData/audio/SE_B0.csb
    47. 10:13:169 .\Src\FileMonitor.cpp:108 W[FileMon]:     329 kB hugeData/audio/SE_homemenu.csb
    48. 10:13:173 .\Src\FileMonitor.cpp:108 W[FileMon]:     131 kB csd/textures/pjn_help.tls
    49. 10:13:175 .\Src\FileMonitor.cpp:108 W[FileMon]:     114 kB csd/textures/mindsite_test.tls
    50. 10:13:177 .\Src\FileMonitor.cpp:108 W[FileMon]:       6 kB csd/controller.one
    51. 10:13:179 .\Src\FileMonitor.cpp:108 W[FileMon]:      45 kB csd/indication.one
    52. 10:13:181 .\Src\FileMonitor.cpp:108 W[FileMon]:       2 kB csd/advertise/pjn_hud_nowsaving.one
    53. 10:13:183 .\Src\FileMonitor.cpp:108 W[FileMon]:   1,825 kB ModuleResourceStationary.one
    54. 10:13:235 .\Src\FileMonitor.cpp:108 W[FileMon]:     409 kB rso/title.rso
    55. 10:13:282 .\Src\FileMonitor.cpp:108 W[FileMon]:      10 kB message/ResidentEN.one
    56. 10:13:295 .\Src\FileMonitor.cpp:108 W[FileMon]:       0 kB ModuleResourceTitle.td
    57. 10:13:317 .\Src\FileMonitor.cpp:108 W[FileMon]:       3 kB character/etc/title/TwoPBack_Kumo01.brmdl
    58. 10:13:330 .\Src\FileMonitor.cpp:108 W[FileMon]:       4 kB character/etc/title/TwoPBack_Kumo02.brmdl
    59. 10:13:331 .\Src\FileMonitor.cpp:108 W[FileMon]:       0 kB character/etc/title/TwoPBack_Kumo01.brtsa
    60. 10:13:333 .\Src\FileMonitor.cpp:108 W[FileMon]:       0 kB character/etc/title/TwoPBack_Kumo02.brtsa
    61. 10:13:334 .\Src\FileMonitor.cpp:108 W[FileMon]:       4 kB character/etc/title/EVT_k_ind03.brtex
    62. 10:13:336 .\Src\FileMonitor.cpp:108 W[FileMon]:       8 kB character/etc/title/EVT_k_kumo04.brtex
    63. 10:16:116 .\Src\FileMonitor.cpp:108 W[FileMon]:     168 kB hugeData/adx/stlogo.adx
    As you can see, the VERY first thing Dolphin loads from the game is the Config.lua file. It doesn't recognize the User lua file, or the debug file. This means that this game was built to automatically run with retail settings, no surprise there. However, I think there might be a way to trick the game into thinking it's a developer copy by editing some part of the header of the game dvd image itself, this however - I haven't figured out. The key to getting everything to work naturally, without doing ugly tricks, is to get the game to load ConfigDebug.lua first, not Config.lua.

    But I know what you're thinking, why not just rename the files then repackage the ISO? I did indeed try it, and I got a working ISO with all the modified files in it. But alas, this doesn't change the fact that it's loading everything on the basis that it's a retail copy. So while it will load whatever is described in Config.lua, it's not truly a developers build - because the condition for the actual ConfigDebug.lua file to load isn't satisfied.

    For the sake of record keeping, this is how I was able to switch files around (guide taken from here):

    1.) Get WiiScrubber 1.4 and 1.21 (1.4 for replacing the partition, 1.21 for replacing individual files later)
    2.) Get PartitionBuilder 1.2
    3.) Take the NiGHTS JoD ISO and load it up in WiiScrubber 1.4
    4.) Right Click on the DATA Partition. Choose "Unencrypted Partition" -> "Extract" (KEEP THIS IN ITS OWN FOLDER, THIS IS NEEDED FOR PARTITIONBUILDER)
    5.) Expand the partition by clicking the "+" symbol next to it. Find these files and extract them (Right Click -> "Extract"): 'partition.bin' 'apploader.img' 'boot.bin' 'bi2.bin' and 'main.dol'.
    6.) Rename, replace, edit, etc the files you want (in this case, this is where I renamed ConfigDebug.lua to Config.lua and the same thing for the equivalent luaObject file .luao, though the .luao file might be unnecessar)
    7.) Open up PartitionBuilder 1.2 and select the partition.bin, apploader.img, etc files here, and point the directory of the extracted DATA directory (the very last thing to click browse for)
    8.) Leave Data Alignment at 4, and begin to create your new partition1.img file that contains the modified files.
    9.) Go back to WiiScrubber 1.4 again, load up the NiGHTS JoD ISO, and right click the DATA partition itself and go to "Unencrypted Partition" -> "Load".
    10.) Load up the partition1.img file that you just created and wait for it to replace the original partition.
    11.) Load the game itself up in Dolphin/Wii and hope for the best!

    While renaming the lua files themselves didn't really help with much however, I have a plan that uses this renaming method for other important files. Take a look at what happens when I fidget about the blank screen for a way to load into the game:

    http://pastebin.com/W9Acs8pC

    Yeah, this is what happens from the moment I got something to load to it actually appearing. What has actually happened here is

    that I somehow was able to get Helen to load up into the 9999th day of the Dream World (the entrance stage where you can access

    the other worlds). Note that after the stlogo.adx before all this stuff happens (this is when the Sonic Team logo comes and fades

    into the black screen), this is all that loads up. Everything that happened in the 15 seconds of this log indicates that the

    black screen problem is the result of something either not loading at all or the wrong file being loaded during this time.

    But more importantly, check out what's loaded first when entering a stage:

    Code (Text):
    1. 10:25:094 .\Src\FileMonitor.cpp:108 W[FileMon]:     178 kB rso/play.rso
    2. 10:25:173 .\Src\FileMonitor.cpp:108 W[FileMon]:       9 kB ModuleResourceWillMotion.td
    3. 10:25:178 .\Src\FileMonitor.cpp:108 W[FileMon]:       1 kB ModuleResourceWillModel.td
    4. 10:25:179 .\Src\FileMonitor.cpp:108 W[FileMon]:     668 kB csd/textures/pjn_screen_allus.tls
    5. 10:25:187 .\Src\FileMonitor.cpp:108 W[FileMon]:      15 kB archive.arc
    6. 10:25:189 .\Src\FileMonitor.cpp:108 W[FileMon]:     176 kB csd/hud.one
    Take note of play.rso. This is a module file, where you'll normally have the data that represents the coding of the game. Notice how in the first log the very first module the game loads is global.rso. This is the MAIN module, the brain of all the other modules.

    Now with evidence of all this unused/debug/dev data around, you think they might leave some kind of debugging modules in the game? Guess what, we're in luck!

    [​IMG]

    Look at all those modules! Look at the modules that comes with multiple "D" versions (D for either Development or Debug, who knows what DO is - probably related to the TGS/demo builds).

    This is the main part of the problem. The game in it's current setting is loading the normal retail modules instead of loading up the potentially cool developer ones! This is probably the reason why I can't see anything after the Sonic Team logo, and even more importantly - why I can't see any cool debug crap loaded up anywhere while in game. Because even in the stages they're loading retail modules, and Sonic Team left the developer modules right in here!

    While I'm not sure if this is going to work as planned, this should help cause SOMETHING to happen. Who knows, maybe even just renaming the first few files that are loaded under the rso directory will cause a chain effect to load the other modules as well without renaming them. Now the method has changed. Instead of messing with the lua files, I'm now looking into the modules themselves. I'm going to be renaming one module or file, repacking the ISO, and then experimenting at a time. This is the only way to make sure I don't royally screw up (helps to retrace my steps in case I do).

    So, wish me luck. This could be it!

    PS: For the record, all the different regions of NiGHTS JoD are exactly identical in file structure, etc. Nothing was really added or removed. So if this method works for the USA version, it'll work for the other versions as well.

    EDIT: forum doesnt like big posts, sorry bout that.
     
  3. Yuzu

    Yuzu

    Member
    2,548
    51
    28
    Any luck with progress on getting the Developer files working in-game? I'd love to help out, but sadly I sold my Wii back in Winter. D:
     
  4. Jarun

    Jarun

    Member
    7
    0
    0
    I think this is a highly under rated game full of interesting undocumented things. I'm hoping to inspire more hacking/ research into it. Personally I would love more My Dream research and a moon jump code for the kids (there is a freeze the clock cheat for Gecko OS that allows you to walk around as a kid unhindered, but you actually can't see/find much because there are invisible walls that prevent you from going very far).
     
  5. evilhamwizard

    evilhamwizard

    Researcher
    1,392
    455
    63
    I totally forgot about this topic, lol.

    I tried to switch the files around, but alas, no dice. It just crashes. But I noticed that there are other Sonic Team games that have a similar set up with the files and such. I noticed for Sonic & Mario @ the Olympic Winter Games that they had the same kind of thing going on there, but the configuration files are never loaded or looked at (the module files don't even have developers build equivalents like NiGHTS does). However, NiGHTS takes the configuration files into consideration, but only depending what the game build is. Like I said, since the game is a release build, it won't load up the ConfigDebug.lua file by default. Switching around files just doesn't seem to cut it, unfortunately.

    If there's some kind of flag someone in the apploader or something that can distinguish a developers copy, maybe the game uses that as a flag for loading up those debug files. But I'm not sure where to begin. If we did manage to turn the game into a "developers" build, it probably more than likely wouldn't work with a retail Wii. And since I don't recall a single Wii prototype ever dumped, I don't know what to expect from an actual developers build of any Wii game.
     
  6. Jarun

    Jarun

    Member
    7
    0
    0
    It would be my guess that Demo Version does not function properly because it was not finished. I can't recall every seeing a demo version or hearing about one. Nights is something I have researched quite abit too. But, I could be wrong.

    Have you asked around on other hacking forums? I can point you to a few.