Making a mod¶
A mod's folder¶
A mod is one folder. Inside, the game's folders it changes, laid out as on the disc below PS3_GAME\USRDIR:
My Mod/
param/gameparam/gameparamna.parambnd.dcx
parts/lg_m_1000.partsbnd.dcx
msg/na_english/item.msgbnd.dcx
Put only the files you change. A file the game never opens changes nothing, so a backup copy of a game file left in the mod does no harm, but it does make the download bigger.
Ship plain files, not files locked again for the PS3 (NPD .sdat or .edat): the game can't read those. Scripts
(.luabnd.dcx.sdat and the talk scripts) work as plain files under their usual names. One exception: a locked file
that is an unchanged copy of one of the game's, at its own place or under a new name in the same folder, is fine. The
game reads the game's own file in its place.
Look or gameplay¶
The game decides from your files whether your mod changes how the game plays, which keeps players offline (see Using mods). A mod that only changes textures, models, text, sound, movies, effects, lighting or fog keeps online play. If yours is a look mod, keep gameplay files out of it.
Mods that change the same file¶
Many mods ship a whole archive for a few changes: the param archive for a few weapons, the item text for a few names. The game merges these when two mods that are on have them, so both mods' changes are kept:
- Params: each mod's file is compared with the disc's, row by row and value by value. The merged file has every value a mod changes, every row a mod adds, and not the rows a mod removes.
- Text: merged by text ID.
- Equipment pieces: each part (the model, the textures) from the mod that changes it, so one mod's model and another's textures can go together. When a mod adds or removes parts, or two change the same part, the higher mod gives the whole piece.
- When two change the same value or text, the higher mod's is used. The log names each one.
Scripts and maps aren't merged: the higher mod gives the whole file.
What the Mods screen checks¶
Two things in a mod that the game can't take are named on its card (in the list, and in full below it when it's selected) and in the log. The mod can still be turned on.
- An old
NpcParam.param. A param archive (param/gameparam/*.parambndor*.parambnd.dcx) whoseNpcParam.paramis version 2 or less: the 16 bits at offset 0x08 of the param. The disc's is version 3. On a PS3 the game stops when it loads an older one. Here it goes on, but it reads the NPCs' values with a layout they weren't written for. Save the archive with a tool that keeps the disc's version. - A load list line that is too long. Each line of an
.arealoadlistnames a file the game loads with the area, for examplemap:/MapStudio/m02_00_00_00.msb. The game builds each one in a buffer of 64 wide characters, so a line can be 63 characters at most. The disc's longest is 36. Characters are counted, not bytes. A load list is the one place a mod names a file the game builds a path for: its other files have the disc's names.
Map layouts (.msb) have no such limit. See Memory and limits.
New worlds and new blocks¶
The game names a place by its map number, mWW_BB: WW is the world (the map files' number: m01 is the Nexus, m02
is Boletarian Palace) and BB is the block. A mod can add both. Scripts take the player there (WarpNextStage).
- A new block of a world (1 to 7). The game loads all of a world's blocks at once, from the world's load list
(
map/mWW_00_00_00/mWW_00_00_00.arealoadlist; block 1 for world 3). A mod adds its block's map layout and navmesh lines to that list. Nothing else is needed. A block needs its own entity IDs: a copy of a block's layout with the same IDs makes the game fail. - A new world, numbered 9 to 97. The game loads its map, layout, navmesh, collision, textures, drawparam, music,
scripts and sound effects by its number. Three files it loads only for the disc's worlds, so this version lets the
game load them for a new world when a mod has them: its effects bank (
sfx/ds_sfxbnd_mWW.ffxbnd.dcx), its collision archive (map/mWW_BB_00_00/mWW_BB_00_00.hkxfilebnd.dcx) and its NPC talk scripts (script/talk/mWW.talkesdbnd.dcx.sdat). Each block of a new world has its own load list (map/mWW_BB_00_00/mWW_BB_00_00.arealoadlist). - Numbers that don't work. 1 to 8 are the disc's. 98 and 99 are special cases in the game's script loader. A world past 99 doesn't fit the file names' two digits.
- Names in menus. The area's name in the menus and on screen comes from the message files, which a mod changes as for any area.
Another world's banks: areas.toml¶
A new world can use the banks of a world it is made from, instead of copies under its own number. The mod names them
in soulbrandt/areas.toml, in the same folder as its chr, map and sfx folders. In a mod laid out as the disc,
that is PS3_GAME/USRDIR/soulbrandt/areas.toml, not beside PS3_GAME.
# World 9 uses the Nexus's effects, sound effects and music.
[[area]]
world = 9 # the new world: 9 to 97
effects = 1 # sfx/ds_sfxbnd_m01.ffxbnd.dcx
sounds = 1 # sound/ds_se_m01 (.mowb, .moib, .mosb)
music = 1 # sound/ds_bgm_m01 (.mowb, .moib, .mosb)
- One
[[area]]per new world. A key left out means the world's own file, by its own number. Each number is 1 to 97. - What it changes: only the world number in those three banks' names, when the game loads and releases them. The world's map, scripts, talk scripts and other files keep its own number.
- Several mods: each mod's file is read. When two give the same world, the higher mod's is used, as with files.
- A bank that isn't there (no file by that number on the disc or in a mod, such as
effects = 7) is not used: the world loads its own, and the log says so. A number always means that world's own file, even when that world is a new one with its own[[area]]. - A file the game can't use (a misspelt key, a number out of range, a world given twice) is not used at all, and
the log says why, for example
areas.toml of Some Mod not used: area 1: "effect" is not a key of an area. - The log has one line per world it reads:
areas.toml: world 9's effects bank m01, sound effects m01, music m01.
Program patches¶
A mod can carry patches for the game's program in RPCS3's format: a patch.yml, or a file whose name ends in
_patch.yml, at the top of the mod's folder or beside its game folders. A mod can be only a patch file.
- Every patch for the running disc applies at start. Patches in the same
Group:are alternatives: only the first applies. - Patches that change the program's data (numbers, text, tables) apply at once.
- Patches that change its code need the game built again with them, which the next start does (see below).
- Patches for the programs the game runs on the PS3's other processors (the SPUs), which sit among the program's data, don't apply.
- Patches the port already does are not applied. A patch that writes where the port has its own code, or where it changes the program, is one. RPCS3's aspect ratio patch is another: Settings > Display > Aspect ratio does the same.
- A mod with a patch file counts as a gameplay mod. The log has a
[patch]line for each patch: applied, or not, and why.
Patches that change the program's code¶
This version's program was translated from the game's code once, at setup. So a patch that changes the code (a
be32, be16 or bef32 write into the executable's .text section) needs that translation done again. When such a
mod is on, the start finds it, and setup builds the game again with the mod's code patches, the way it built the game
the first time, only the main processor's part.
- Once for each set of patches. The game built with them is kept in the setup folder, under
program_mods. The next start with the same mods on uses it at once. Turning the mods off starts the game as before; turning them on again uses the kept build. A change to any of the patches, or a new version of the PC port, builds again. - How long: about as long as the main processor's part of the first setup, a few minutes on a fast PC. The setup window shows the estimate for this PC.
- Old builds. Each build is about 1 GB, and nothing removes one on its own. When
program_modsholds builds other than the one this start uses, the Mods window shows Delete old builds with how many there are and how much room they take, such as "3 old builds, 2.9 GB". It removes only those builds, never the one in use. A build it removes is made again if the mods that need it are turned on later. - The Mods window calls such a mod "Changes the program", once a start has found its code patches. Online play is
off while it's on. Seamless co-op works, but every player in the party needs the same code patches: the co-op mods
warning lists them as
program changes <id>, and players with the same patches see the same id, whatever their PC. - If the build fails, setup's window says why and offers Play without them: the game starts with its own build and the mods' code patches left out. Their data patches and files still apply.
To write one, key the patch as for RPCS3: by the PPU- hash RPCS3 shows for the program, with Games: naming the
disc. Rules for code patches:
- Only the program's own code, changed in place. A patch that needs new code somewhere else (a code cave) is left
out, with the reason in the log and in setup's window. That covers the types
alloc,calloc,jump,jumplandjumpf, and a written branch (b,bl,bc...) to anywhere but the start of a function or a place in the same function. - Not where the port has its own code. The port hooks the program in some places and replaces some functions whole (its own camera, frame rate and menu fixes). A patch that writes there is left out, and the log names the address and what the port does there. A setting often does what such a patch does already.
- A patch is all or nothing, as with data patches: one write left out leaves the whole patch out.
The European, Japanese and Asian discs' programs have their own PPU- hashes.
Changed programs, xdelta and bsdiff files¶
Some PS3 mods change the game's program itself. They ship a patched EBOOT.BIN, or a difference file that makes one
from the disc's: an xdelta or a bsdiff file. This version runs its own program, so it can't run a changed one. It can
make the same changes, the way it makes a patch file's.
- What setup looks for:
EBOOT.BIN,EBOOT.ELForEBOOT.SELF, or a file ending in.xdelta,.xdelta3,.vcdiff,.bsdiff,.bsdiff4,.bsdiff40or.bsdiff43, at the top of the mod's folder or one folder down. One per mod. - How: the card shows Fix it. Press it. The card says "Reading the mod's program..." for a few seconds, and the
window stays usable. Setup makes the mod's program, compares it with the game's program from your own copy of the
game, and writes each changed 4-byte word as a row of
soulbrandt_eboot_patch.ymlat the top of the mod's folder. From then on the mod is a mod with a patch file (see above): its card says "Has patches for the game's program", and the rows apply at start. - Which rows apply: rows in the program's data apply. Rows in its code are kept in a patch of their own, which is built in as above.
- Rows the port already does: rows that only change how big one of the game's memory heaps is are left out, with a comment line in the file. With mods on, this version gives those heaps more room than such a mod asks for (see Memory and limits). A patch file left with no rows doesn't make the mod a gameplay mod.
- If the mod's program is encrypted, setup has RPCS3 unlock it, as it does the game's files. Without RPCS3, the card says so.
- What setup refuses, by name: a difference made from another version of the game or from an already changed
program, a program laid out differently (segments moved or grown), a damaged file, and more than 256 KB of changes.
The reason goes in
soulbrandt_eboot_problem.txtbeside the file, and the card shows it with Fix it still there. - When the mod changes: a new version of the mod's file makes the card show Fix it again. A patch file whose program is gone or changed is not applied.
Testing your mod¶
- The log (in the data folder's
logs) has a[mods]line for each mod, and lines for each file merged, each patch, each music track and voice line, and each texture that needed attention. - Memory in this area on the Mods screen shows how close your mod brings each area to the game's limits. Walk through the areas your mod changes and watch it. See Memory and limits.