add new .dat file with guard

Discussions about all other tools (CusPop, SAV/HOF editors) and hex editing.

Moderator: English Moderator Team

User avatar
jjur
Efendi
Efendi
Posts: 13
Joined: February 7th, 2015, 10:56 pm
Location: Slovakia
Contact:

add new .dat file with guard

Postby jjur » March 13th, 2015, 8:58 pm

Is possible add new guard .dat file?
I need all existing (vizer.dat, guard.dat, skel.dat, fat.dat shadow.dat) and i need to add 6th guard resource. How i can add it? Which file i have to modify?

David
The Prince of Persia
The Prince of Persia
Posts: 1336
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: add new .dat file with guard

Postby David » March 15th, 2015, 12:56 pm

You need to hex-edit prince.exe...
...but first I have to figure out what to modify. :)

First, I assume you are using version 1.0 of PoP.
In the EXE, there is a table with the names of guard DAT files.
It is immediately followed by other string tables, and finally the "guard type per level" table:

Code: Select all

data:03BA 4F 03 59 03 61 03 tbl_guard_dat   dw offset guard_dat, offset fat_dat, offset skel_dat
          6A 03 75 03                       dw offset vizier_dat, offset shadow_dat
data:03C4 80 03 81 03 83 03 tbl_envir_gr    dw offset env_none, offset env_cga1, offset env_cga2
          85 03 87 03 89 03                 dw offset env_ega1, offset env_ega2, offset env_vga
data:03D0 8B 03 93 03       tbl_envir_ki    dw offset dungeon, offset palace
data:03D4 00 00 00 00 00 00 tbl_guard_type  dw 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 4, 3, 0FFFFh, 0FFFFh
          02 00 00 00 00 00
          01 00 00 00 00 00
          ...

Guard types 0..4 are the existing types, 5..12 could be the new types.
The easiest option is to use as filenames the strings that are already there:

Code: Select all

5="" (useless)
6 or 7="C"
8 or 9="E"
10="V"
11="DUNGEON"
12="PALACE"
This means you can use files named "C", "E", "V", "DUNGEON" or "PALACE" as a guard DAT.
(Yes, these names look odd, but it's easier to use what is already there.)
Note that there is no .DAT after the names.

To use the new types, you need to hex-edit the "guard type per level" table (in PRINCE.EXE).
(CusPop has this feature, but it allows only the "normal" types.)
It looks like this: (Search for the second row with the hex editor.)

Code: Select all

0     1     2     3     4     5     6     7     8     9     10    11    12    13    14    15 <- levels
00 00 00 00 00 00 02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 00 03 00 FF FF FF FF

Choose the level where you want the new guard type: from the first 00, go right levelnumber*2 bytes.
Then write the number of the new guard type.
For example, if you want level 2 to use a file called "C", then from the first 00, go right 2*2=4 bytes, and change that byte to 06 (or 07).

To make a new DAT file with these new names, you can make it with PR using the filename of an existing type, and then rename the file.


Return to “Other Tools & Hex Editing”

Who is online

Users browsing this forum: No registered users and 1 guest