Debug Mode - trigger-segfault/TriggersTools.CatSystem2 GitHub Wiki
Enabling debug mode in CatSystem2 games is relatively easy to do programmatically. Although it's possible to do with a hex editor, you'd need a search functionality to find the parts to modify.
Big thanks to marcussacana/CatSceneEditor as their program was essential during the process of learning more about the CatSystem2 engine. The patch outlined in their program is relatively unchanged. Although it seems that you do not need to change the V_CODEs associated with the Cs2 executable, and commenting out the <v_code>
tag in startup.xml
is also possibly unnecessary (but is still finicky).
There are two blocks of bytes in the CatSystem2 executable that can be changed to forcefully enable debug mode. The first appearance of each block must have the first byte replaced with 0xEB
, while the remaining bytes should stay the same. The replacement of these bytes was determined by marcussacana, who designed the debug patch in marcussacana/CatSceneEditor.
These blocks are both assembly conditional jump instructions. These jumps are performed when a key file is found to be valid. Changing the first byte to EB
changes the instruction to an unconditional jump (always jump without comparison). If the program does not jump at these instructions, you may encounter a message box saying the game installation is invalid (depending on translation).
Pattern | Replace with |
---|---|
75 75 8D 4C |
EB 75 8D 4C |
74 2D 6A 00 68 |
EB 2D 6A 00 68 |
CatSystem2 also requires a file in the installation directory which acts as (you guessed it) a key for enabling debug mode features. The file: cs2_debug_key.dat
, is 64 bytes long. It is the same file that comes with the Cs2 Toolset .
See Key Files for more information on what cs2_debug_key.dat
is, and how you can generate one yourself. The key file provided here is publicly available and will only work with this patch, or a CatSystem2 Toolset executable.
The debug key is as follows: Download (Download location may change in the future)
Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000: E2 2A A8 65 C5 CE 04 55 DA E4 CD 9A 96 F2 15 1E
00000010: 1B 0E 13 D0 AB 8F F8 3D 3F EA 46 73 37 FA 8D 90
00000020: 48 4B 83 FF 39 21 D0 50 2D 12 36 B3 F0 C3 D5 8C
00000030: D7 B3 DD F5 F1 8A 77 E2 BD 3F D2 4F C9 66 0E FA
Although optional, the the Window Menu contains a few additional debug features that do not have an access hotkey. As shown below, the /document/APP/wndmenu
element in %INSTALLDIR%/config/startup.xml
must be present and have its value changed from 0
to 1
in order to show up in-game. When saving changes to startup.xml
always make sure you save with the Shift JIS (codepage 932) encoding.
<APP>
<brand>brandname</brand>
<title>cs2-open-V4</title>
<mutex>CS2O_MUTEXOBJ</mutex>
<mutex_cfg>CS2O_MUTEXOBJ_CONFIG</mutex_cfg>
<cdid>cs2_open.id</cdid>
<icon>icon.ico</icon>
<iconno>0</iconno>
<banner>banner.bmp</banner>
<imgcache>32</imgcache>
<direct>1</direct>
<wndmenu>1</wndmenu> <!-- THIS VALUE -->
</APP>
When in Debug Mode, CatSystem2 allows loading of local files from subfolders in the install directory instead of the file entries in the KIF Archive files. The names of these subfolders are usually the names of the .int
files, however some files may use different directory structures. To check where the game expects your files to be located, goto the /document/int/int##/dir
element in %INSTALLDIR%/config/startup.xml
for the .int
file of your choosing. The <dir>
element will contain the location of the local files relative to the installation directory.
This states that all HG‐3 Image resources are located in the %INSTALLDIR%/image
subfolder
<INT>
<!-- ... -->
<int00>
<name>image</name>
<int>image.lst</int>
<ext>hg3</ext>
<dir>image</dir>
</int00>
<!-- ... -->
</INT>
For most games, all sounds will be in an extra subfolder %INSTALLDIR%/sound/%SOUNDTYPE%
. For example: below is some of the sound directories for Grisaia no Rakuen.
<INT>
<!-- ... -->
<int19>
<name>bgm</name>
<int>bgm.int</int>
<ext>ogg</ext>
<dir>sound\bgm</dir>
</int19>
<int20>
<name>se</name>
<int>se.int</int>
<ext>ogg</ext>
<dir>sound\se</dir>
</int20>
<int21>
<name>hse</name>
<int>hse.int</int>
<ext>ogg</ext>
<dir>sound\hse</dir>
</int21>
<int22 voice="pcm_a">
<name>pcm_a</name>
<int>pcm_a.int</int>
<ext>ogg</ext>
<dir>sound\yum</dir>
</int22>
<!-- ... -->
</INT>
The only .int
files that do not support local files are the kcs.int
and possible motion.int
files. This is likely because the contained binary files cannot be modified or added to. But that's just a guess.
Debug mode comes with a nice collection of features for modifying the game.
Note: All image previews below are from Cs2 executables with an English translation and Windows Visual Style patch made using this Library. If these patches are not applied, and the program is not run in the Japanese Locale, then most text will just be some variation of ?????
as this text is not translatable using languages.txt
like other text in the UI.
By far one of the most useful features, this window allows you to jump to any scene file in the game, as long as the file is available locally in the scene.int
file's associated local subfolder. (The image of the window has been shortened for the sake of vertical space. The Scene List can be opened with the S key while in a scene, or the Scene List menu item in the Debug dropdown in the Window Menu.
-
File List is the only supported List Type (which presumably shows local files while Scene List would show files within the
scene.int
archive). - Filter is used to filter the scene list by name using the textbox below.
- Update List will refresh the Filter and changes to the local files in the folder.
-
Compile All Scene Scripts will run whatever command is entered into
startup.xml
as shown below.
<SCENELIST>
<convert>
<current>scene</current>
<!--
<command>mc.exe</command>
<param>*.*</param>
-->
<command>convert_all.bat</command>
<param></param>
</convert>
</SCENELIST>
Also a very useful tool, the Message List allows you to filter through and jump to any message in the current scene, whether forwards or backwards. The Message List can be opened with the Scene List menu item in the Debug dropdown in the Window Menu. Messages in the list are prefixed with the name of the speaker. @
stands for monologue or no speaker.
- Double Clicking on a message will jump to that message in the current scene.
- Name dropdown will allow you to filter messages by who the speaker is.
- Sentence textbox will allow you to filter the messages in the list to help search for a specific message in the scene. This filter searches the message text and speaker name.
The Debug Log displays commands executed by CatSystem2 in real-time. This includes CST Scene script commands/messages/names/input, FES Screen script commands, and CatSystem2 internal commands such as logging the loading of a file.
- It is unknown what the COPY and FILE and buttons do as they are always disabled. I plan to forcefully enable them via Windows resource modification to see if they do anything.
- CLEAR is a button to simply clear the log. Pretty self-explanatory.