PR - the vpalace.dat extracting bug

Post Reply
htamas
Efendi
Efendi
Posts: 10
Joined: February 22nd, 2009, 7:49 pm

PR - the vpalace.dat extracting bug

Post by htamas »

This topic was originally available at http://popuw.com/forum/viewtopic.php?t=557. I tried to salvage posts from my locally saved files and the Internet Archive's Wayback Machine. If you have some additional material, please share it. Thanks.
hanswurst @ popuw.com (Thu Aug 03, 2006 5:08 pm) wrote: I've a question about the Prince Resources. When I extract the vpalace.dat, some of the wall tiles won't extract (and they aren't even in any non-bmp files, such as f.e. the main stack center wall tile in the vdungeon.dat). Please can you help me, how to edit the vpalace walls? Or it's unevoidable bug taht makes the palace walls editting impossible?
htamas @ popuw.com (Thu Aug 10, 2006 7:26 am) wrote: Information about the palace background tiles is in resources 363-377. The main problem here is not with pr but with the handling of palace tiles in prince. That is, you cannot control how the tiles look, since they are put together from one-coloured rectangles using some hard-coded palette entries. The only thing these resources can control are the greyish-brown dots that are usually between the bricks. By modifying them, you can create patterns like this:
Image
(similarly patterned blocks are from the same resource). Unfortunately, you can't change much more. You may either
(i) choose your palette entries such that the wall generated matches your mod's style, and perhaps fine-tune it using these resources (pr gives you the correct bitmaps, but the palettes are wrong - you'll have to experiment; also export the missing ones)
(ii) change all levels to dungeon - yes, it'll be more daunting, but if you use 1.3 or 1.4, you may add different palettes to compensate this
(iii) hack prince.exe to use the dungeon wall-drawing algorithm with tiles from vpalace.dat too, though this seems quite tough to me
programmer @ popuw.com (Thu Aug 10, 2006 1:53 pm) wrote:
change all levels to dungeon - yes, it'll be more daunting, but if you use 1.3 or 1.4, you may add different palettes to compensate this
htamas, can you write which offsets should be edited to change it? I knew that but I've forgotten :/ I have already asked for it here, http://popuw.com/forum/viewtopic.php?t=573
htamas @ popuw.com (Thu Aug 10, 2006 5:41 pm) wrote:
programmer wrote:
change all levels to dungeon - yes, it'll be more daunting, but if you use 1.3 or 1.4, you may add different palettes to compensate this
htamas, can you write which offsets should be edited to change it? I knew that but I've forgotten :/ I have already asked for it here, http://popuw.com/forum/viewtopic.php?t=573
For prince 1.0, you need to modify the bytes at 0x1acea to 0x1acf8. A byte of 0x00 means dungeon, whereas one of 0x01 means palace. You can find the offsets in any version by searching for 00000000010101000000010100000100 (hex).
programmer @ popuw.com (Fri Aug 11, 2006 6:59 pm) wrote: Thanks, I'll look at this.
hanswurst @ popuw.com (Sun Aug 13, 2006 6:38 pm) wrote: Please can you somebody tell me, where could I find a site with informations about what each byte of each file means? I've once discovered anything (it wasn't sourceforge, but something quite simillar), but now I can't find it...
hanswurst @ popuw.com (Sun Aug 13, 2006 6:45 pm) wrote: Ouch, sorry, I've just found it:
http://cvs.lug.fi.uba.ar/cgi-bin/cvsweb ... ce#dirlist
htamas @ popuw.com (Mon Aug 14, 2006 12:30 am) wrote:
htamas wrote: (iii) hack prince.exe to use the dungeon wall-drawing algorithm with tiles from vpalace.dat too, though this seems quite tough to me
I've managed to do this
Image

You are probably interested ;), so I'll explain the steps I took to make palace levels use the dungeon WDA. As I see, you are not using a unix-like OS, so your mileage may vary.

I was using pr v1.2 with resources.xml v1.0.0 (2005-Jun-04). Using the same versions may help to avoid some errors.

First, here is the patch for prince 1.0. It's a bash script you'll need to run in the same directory as prince.exe. You'll also need a little utility called binpatch (also by me), for which you'll find the sources after the script. You may also follow the script and make the required changes using a hex editor.

contents of 'patch.sh':

Code: Select all

#!/bin/bash
# make a group of modifications to prince.exe
# by htamas, 2006 (gnu gpl v2+)
#
# note: the offsets are only valid for prince 1.0

POS_A=default
POS_B=default
POS_C=default
POS_D=dungeon
POS_E=dungeon
POS_F=dungeon
POS_G=default
POS_H=default
POS_I=default
POS_J=default

if [ "$POS_A" = "default" ]; then
binpatch prince.exe <<end
b f49 8a
b f4a 9f
b f4b b2
b f4c 02
end
elif [ "$POS_A" = "dungeon" ]; then
binpatch prince.exe <<end
b f49 b3
b f4a 00
b f4b 90
b f4c 90
end
elif [ "$POS_A" = "palace" ]; then
binpatch prince.exe <<end
b f49 b3
b f4a 01
b f4b 90
b f4c 90
end
else
echo POS_A is invalid >&2
fi

if [ "$POS_B" = "default" ]; then
binpatch prince.exe <<end
b fb0 74
b fb1 05
end
elif [ "$POS_B" = "dungeon" ]; then
binpatch prince.exe <<end
b fb0 eb
b fb1 05
end
elif [ "$POS_B" = "palace" ]; then
binpatch prince.exe <<end
b fb0 90
b fb1 90
end
else
echo POS_B is invalid >&2
fi

if [ "$POS_C" = "default" ]; then
binpatch prince.exe <<end
b 4d2b 74
b 4d2c 05
end
elif [ "$POS_C" = "dungeon" ]; then
binpatch prince.exe <<end
b 4d2b eb
b 4d2c 05
end
elif [ "$POS_C" = "palace" ]; then
binpatch prince.exe <<end
b 4d2b 90
b 4d2c 90
end
else
echo POS_C is invalid >&2
fi

if [ "$POS_D" = "default" ]; then
binpatch prince.exe <<end
b a7bb 74
b a7bc 07
end
elif [ "$POS_D" = "dungeon" ]; then
binpatch prince.exe <<end
b a7bb eb
b a7bc 07
end
elif [ "$POS_D" = "palace" ]; then
binpatch prince.exe <<end
b a7bb 90
b a7bc 90
end
else
echo POS_D is invalid >&2
fi

if [ "$POS_E" = "default" ]; then
binpatch prince.exe <<end
b c51c 1b
b c51d c0
b c51e f7
b c51f d8
end
elif [ "$POS_E" = "dungeon" ]; then
binpatch prince.exe <<end
b c51c b8
b c51d 01
b c51e 00
b c51f 90
end
elif [ "$POS_E" = "palace" ]; then
binpatch prince.exe <<end
b c51c b8
b c51d 00
b c51e 00
b c51f 90
end
else
echo POS_E is invalid >&2
fi

if [ "$POS_F" = "default" ]; then
binpatch prince.exe <<end
b ac9b 74
b ac9c 07
end
elif [ "$POS_F" = "dungeon" ]; then
binpatch prince.exe <<end
b ac9b eb
b ac9c 07
end
elif [ "$POS_F" = "palace" ]; then
binpatch prince.exe <<end
b ac9b 90
b ac9c 90
end
else
echo POS_F is invalid >&2
fi

if [ "$POS_G" = "default" ]; then
binpatch prince.exe <<end
b a5f3 74
b a5f4 28
end
elif [ "$POS_G" = "dungeon" ]; then
binpatch prince.exe <<end
b a5f3 eb
b a5f4 28
end
elif [ "$POS_G" = "palace" ]; then
binpatch prince.exe <<end
b a5f3 90
b a5f4 90
end
else
echo POS_G is invalid >&2
fi

if [ "$POS_H" = "default" ]; then
binpatch prince.exe <<end
b a661 74
b a662 2c
end
elif [ "$POS_H" = "dungeon" ]; then
binpatch prince.exe <<end
b a661 eb
b a662 2c
end
elif [ "$POS_H" = "palace" ]; then
binpatch prince.exe <<end
b a661 90
b a662 90
end
else
echo POS_H is invalid >&2
fi

if [ "$POS_I" = "default" ]; then
binpatch prince.exe <<end
b acf0 74
b acf1 0e
end
elif [ "$POS_I" = "dungeon" ]; then
binpatch prince.exe <<end
b acf0 eb
b acf1 0e
end
elif [ "$POS_I" = "palace" ]; then
binpatch prince.exe <<end
b acf0 90
b acf1 90
end
else
echo POS_I is invalid >&2
fi

if [ "$POS_J" = "default" ]; then
binpatch prince.exe <<end
b a57f 74
b a580 09
end
elif [ "$POS_J" = "dungeon" ]; then
binpatch prince.exe <<end
b a57f eb
b a580 09
end
elif [ "$POS_J" = "palace" ]; then
binpatch prince.exe <<end
b a57f 90
b a580 90
end
else
echo POS_J is invalid >&2
fi
contents of 'binpatch.c':

Code: Select all

/*
  Applies some patches to a binary file. The name of the binary file is
  given as an argument, while the list of offset/newvalue pairs are read
  from the standard input.
  (c) Hubai Tamas, 2006. Licensed under the GNU General Public License v2+
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
  FILE *f; char t; char b; short w; int d; int ofs;
  if(argc<2) {
    fprintf(stderr, "Usage: %s filename\nSee the source for more details.\n",
      argv[0]); exit(1);
  }
  f=fopen(argv[1],"r+b");
  if(!f) {
    fprintf(stderr, "Unable to open %s\n", argv[1]); exit(1);
  }
  while(!feof(stdin)) {
    t=getchar();
    switch(t) {
      case 'b':
        scanf("%x %hhx\n", &ofs, &b);
   fseek(f, ofs, SEEK_SET);
   fwrite(&b, 1, 1, f);
        break;
      case 'w':
        scanf("%x %hx\n", &ofs, &w);
   fseek(f, ofs, SEEK_SET);
   fwrite(&w, 2, 1, f);
        break;
      case 'd':
        scanf("%x %x\n", &ofs, &d);
   fseek(f, ofs, SEEK_SET);
   fwrite(&d, 4, 1, f);
        break;
      default:
        while(t!='\n') t=getchar();
    } 
  }
  fclose(f);
  return 0;
}
So you've run ./patch.sh. Suppose pr and resources.xml are in the same directory. Get the following unified diff. It's mime-encoded because this forum seems not to preserve the trailing spaces, so when I tested the instructions before posting, I got 'hunk failed' errors. This way, it works correctly, sorry for the extra complication.

contents of 'resources.diff', mime-encoded (use 'mimencode -u' to convert back):

Code: Select all

LS0tIHJlc291cmNlcy54bWwJMjAwNi0wNy0xOCAyMjozODoxOS4wMDAwMDAwMDAgKzAyMDAK
KysrIHJlc291cmNlcy54bWwJMjAwNi0wOC0xMyAyMjo0NDozOS4wMDAwMDAwMDAgKzAyMDAK
QEAgLTM5LDYgKzM5LDExIEBACiAgIFZlcnNpb246IDAuOC4xICgyMDA0LU1hci0xMSkKICAg
VmVyc2lvbjogMC44LjIgKDIwMDUtTWFyLTI2KQogICBWZXJzaW9uOiAxLjAuMCAoMjAwNS1K
dW4tMDQpCisgIAorICBNb2RpZmllZCBieTogSHViYWkgVGFtYXMgKGh0YW1hczJAZ21haWwu
Y29tKQorICBOb3RlIHRoYXQgdGhpcyBtb2RpZmllZCB2ZXJzaW9uIGlzIE5PVCB2YWxpZCBm
b3IgdGhlIG9yaWdpbmFsCisgIHByaW5jZS5leGUsIG9ubHkgZm9yIGEgc3BlY2lmaWMgcGF0
Y2hlZCB2ZXJzaW9uLgorICBTZWUgaHR0cDovL3BvcHV3LmNvbS9mb3J1bS92aWV3dG9waWMu
cGhwP3Q9NTU3IGZvciBtb3JlIGRldGFpbHMuCiAKICBOb3RlOgogICBETyBOT1QgcmVtb3Zl
IHRoaXMgY29weXJpZ2h0IG5vdGljZQpAQCAtMTg5LDggKzE5NCw4IEBACiAgIDxmb2xkZXIg
bmFtZT0id2FsbHMiIHBhdGg9IndhbGxzIj4KICAgIDxpdG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lPSIzNjciIHBhdGg9InJlczM2Ny5iaW4iPlVua25vd24gUmVz
b3VyY2UgbnVtYmVyIDM2NzwvaXRlbT4KLSAgIDxpdGVtIHZhbHVlPSIzNjgiIHBhdGg9InJl
czM2OC5iaW4iPlVua25vd24gUmVzb3VyY2UgbnVtYmVyIDM2ODwvaXRlbT4KLSAgIDxpdGVt
IHZhbHVlPSIzNjkiIHBhdGg9InJlczM2OS5iaW4iPlVua25vd24gUmVzb3VyY2UgbnVtYmVy
IDM2OTwvaXRlbT4KLSAgIDxpdGVtIHZhbHVlPSIzNzAiIHBhdGg9InJlczM3MC5iaW4iPlVu
a25vd24gUmVzb3VyY2UgbnVtYmVyIDM3MDwvaXRlbT4KLSAgIDxpdGVtIHZhbHVlPSIzNzEi
IHBhdGg9InJlczM3MS5iaW4iPlVua25vd24gUmVzb3VyY2UgbnVtYmVyIDM3MTwvaXRlbT4K
LSAgIDxpdGVtIHZhbHVlPSIzNzIiIHBhdGg9InJlczM3Mi5iaW4iPlVua25vd24gUmVzb3Vy
Y2UgbnVtYmVyIDM3MjwvaXRlbT4KLSAgIDxpdGVtIHZhbHVlPSIzNzMiIHBhdGg9InJlczM3
My5iaW4iPlVua25vd24gUmVzb3VyY2UgbnVtYmVyIDM3MzwvaXRlbT4KLSAgIDxpdGVtIHZh
bHVlPSIzNzQiIHBhdGg9InJlczM3NC5iaW4iPlVua25vd24gUmVzb3VyY2UgbnVtYmVyIDM3
NDwvaXRlbT4KICAgPC9mb2xkZXI+CiAgPC9mb2xkZXI+CiAK
and run "patch -p0 < resources.diff".

Note: The first patch in the file corrects the missing extensions for two tiles, so they are meaningful for the original prince.exe as well. The other resources, however, have different interpretation in the dungeon and the palace WDA, so this resources.xml should be kept separately from the generic one.

Now you have a changed prince.exe and resources.xml, but your vpalace.dat does not reflect the modifications. So you'll need to extract both vdungeon.dat and vpalace.dat and copy some files, then import back the changes.

Code: Select all

./pr -xtemp vdungeon.dat
./pr -xtemp vpalace.dat
cp temp/vdungeon/walls/* temp/vpalace/walls/
cp temp/vdungeon/palette/dungeon.pal temp/vpalace/palettes/wall.pal
cp temp/vdungeon/palette/dungeon.pal.more temp/vpalace/palettes/wall.pal.more
./pr -itemp vpalace.dat
rm -rf temp/
Launch prince.exe in dosbox and check out the changes. Hopefully you should see the same as on the screenshot above. If everything goes fine, you can start editing the tiles in vpalace/walls. Don't forget that the palette for these files are in vpalace/palettes/wall.pal, not in either the regular dungeon or palace palette. If it doesn't work for you, or just need help, ask :). It might be easier to supply the patched files, however, I'm unsure whether it is legal.

Happy modding ;)
hanswurst @ popuw.com (Mon Aug 14, 2006 4:36 am) wrote: Hmm, thank you, it looks very interresting... I only hope I could catch, how to use it, cause programming isn't my "strong point" (I've stuck in Borland Pascal, about the modern programming I know almost nothing), so it will be for me much harder to catch the procedure than the whole layout editting... :roll:
htamas @ popuw.com (Mon Aug 14, 2006 6:40 pm) wrote:
hanswurst wrote: Hmm, thank you, it looks very interresting... I only hope I could catch, how to use it, cause programming isn't my "strong point" (I've stuck in Borland Pascal, about the modern programming I know almost nothing), so it will be for me much harder to catch the procedure than the whole layout editting... :roll:
Ok, I've tried to make it a bit easier. Here is a version that is less customisable but only uses c code so that you don't need bash.

contents of pdpatch.c:

Code: Select all

/*
  Patches PoP1 to use the dungeon WDA for palace levels.
  You'll need to modify vpalace.dat as well for this mod to be usable.
  by htamas, 2006 (gnu gpl v2+)
  note: you'll have to specify prince.exe as the argument,
  with the correct capitalization
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
  FILE *f;
  char ma[4]={'\xb8','\x01','\x00','\x90'};
  char mb[2]={'\xeb','\x07'};
  if(argc<2) {
    fprintf(stderr, "Usage: %s filename\nSee the source for more details.\n",
      argv[0]); exit(1);
  }
  f=fopen(argv[1],"r+b");
  if(!f) {
    fprintf(stderr, "Unable to open %s\n", argv[1]); exit(1);
  }
  fseek(f, 0xc51c, SEEK_SET);
  fwrite(ma, 4, 1, f);
  fseek(f, 0xa7bb, SEEK_SET);
  fwrite(mb, 2, 1, f);
  fseek(f, 0xac9b, SEEK_SET);
  fwrite(mb, 2, 1, f);
  fclose(f);
  return 0;
}
I've tried to cross-compile it with mingw to create a windows .exe file. I couldn't test it, since I don't have windows, but it should work fine. I have uploaded both this .exe and the patched resources.xml in a zip-file to a free file upload service, you can download it from here.

Extract this file to your prince 1.0 folder (make a copy of it first), open a command line, go to that directory and run "pdpatch prince.exe". Now, your prince.exe should be patched, and if you run it, you should see that the wall on palace levels is mainly black, with some brown junk where the edges of bricks would normally be.

Since you've made some graphics mods, I assume that you can use pr. Extract vdungeon.dat and vpalace.dat using the resources.xml found in the zip file. Since the wall tiles in vpalace.dat use the palace WDA format, you'll have to overwrite them with the wall tiles from vdungeon.dat (simply copy the contents of the wall folder from vdungeon to vpalace). Also, copy the dungeon palette found in vdungeon.dat over the wall palette found in vpalace.dat (not the palace palette). Then, import back vpalace.dat from the extracted modified files.

If you start prince.exe now, you'll see the dungeon walls in the palace levels, as on the screenshot. You can modify the files you've just copied from the dungeon environment to customize the palace walls and its palette.

I hope this is now comprehensible ;). Good luck.
hanswurst @ popuw.com (Tue Aug 15, 2006 5:06 pm) wrote: Yeyyy jigga jigga it works!! 8-) Thank you very much, after hacking the Prince.exe I even didn't need the whole new resources.xml file. With all versions of PR works, if you copy only the "palace wall tiles" (one directory) from your resources.xml and overwrite with them the same directory in the original resources.xml...

P.S.: I think the trick with the vpalace wall tiles hacking should be sticken od the top of the "PoP1 mods" topic in this forum, because many layout editors could have the same problem as me... 8-)
htamas @ popuw.com (Wed Aug 16, 2006 12:42 am) wrote:
hanswurst wrote: after hacking the Prince.exe I even didn't need the whole new resources.xml file. With all versions of PR works, if you copy only the "palace wall tiles" (one directory) from your resources.xml and overwrite with them the same directory in the original resources.xml...
Perhaps you are using different versions of resources.xml than me. For me, some of the palace tiles are marked as unknown (they go to the binary folder in raw mode, not in bitmap mode) and for the others the palette is incorrect. If you only use the import function of pr, you won't get any errors and the game will work correctly until you would like to modify one of the tiles that are marked as unknown. So I'll suggest to use the extracted version of resources.xml, just in case (since it isn't more difficult).

By the way, I'm looking forward to see the first palace mod ;). I liked your dungeon ones.
hanswurst wrote: I think the trick with the vpalace wall tiles hacking should be sticken od the top of the "PoP1 mods" topic in this forum
Maybe. But it might be better to collect the prince.exe hacks in a thread and make that one sticky. There are quite a number of interesting ones, such as:
- starting level, hit points (lives) and time
- maximal number of hit points
- dungeon or palace switch for levels
- base guard hit points in each level
- minimal and maximal level where you can save
and perhaps (I don't know where to find these)
- palette indexes for dungeon and palace levels in 1.3 or 1.4
- type of guards in each level (default, skeleton, fat, shadow, jaffar)
- which levels the special objects/effects appear in (no sword, skeleton, mid-level save, mirror, drinking shadow, stepping shadow, finish by fallout, mouse, merging shadow, appearing blocks, finish by leaving left, auto-falling blocks, guard opens gate, intro dialog, potions with letters)
- room and tile numbers used for special effects
(and some of the hard-coded limits such as the number of levels, rooms per level, etc., but these are tough ones since they affect multiple places in the file and need to change some of the resources' format.)
These ones are/would be quite useful for modders. Among these, we could include the vpalace patch, too.
hanswurst @ popuw.com (Wed Aug 16, 2006 10:44 am) wrote: I've copied only the wall tiles from the extracted vdungeon to the extracted vpalace. The both background and forground palettes I've let in the palette directory (default for the vpalace) and it works, so the extracted files from vdungeon and from vpalace are now almost the same, except for the background palette (for vdungeon it's in the binary folder, for vpalace in the palette folder) and the special tiles for each type of level layout (skeleton vs. laticce, balcony, mirror and carpet...)
programmer @ popuw.com (Wed Aug 16, 2006 2:48 pm) wrote: htamas, I see you have managed to change many aspects of game by editing the executable. Can you write more details for any of those?
htamas @ popuw.com (Thu Aug 17, 2006 1:46 am) wrote:
programmer wrote: htamas, I see you have managed to change many aspects of game by editing the executable. Can you write more details for any of those?
Yes, but I don't have them ready, so I'll need to do some debugging for them. I'll post the results when I've found them.
htamas @ popuw.com (Thu Aug 17, 2006 8:20 pm) wrote:
htamas wrote:
programmer wrote: htamas, I see you have managed to change many aspects of game by editing the executable. Can you write more details for any of those?
Yes, but I don't have them ready, so I'll need to do some debugging for them. I'll post the results when I've found them.
I've posted it to a new thread.
ecco @ popuw.com (Sun Aug 20, 2006 12:48 am) wrote: Hi htamas,

I've been reading this thread as I would like to develop a vpalace graphic set. I downloaded the patch and ran it as instructed (in the prince directory), including copying the wall directory and palette and us etc also as instructed, and replacing the resources xml with your modified one, but I don’t think it’s working..

What's al that text in the text file after the intro about? Do I need to do something with that? What does ' note: you'll have to specify prince.exe as the argument,
with the correct capitalization' mean?

I've been trying to work this out for a couple of hours now.. sigh
I don't have a clue when it comes to code :)


I'm very grateful and happy you've been making this possible- to edit vpalace walls. I might just continue with my vpalce with this..

Thanks


Image


EDIT: Here is where I had got to before- a long time ago.

Image
htamas @ popuw.com (Sun Aug 20, 2006 4:21 am) wrote:
ecco wrote: Hi htamas,

I've been reading this thread as I would like to develop a vpalace graphic set. I downloaded the patch and ran it as instructed (in the prince directory), including copying the wall directory and palette and us etc also as instructed, and replacing the resources xml with your modified one, but I don’t think it’s working..
Perhaps you are using a different version of prince.exe. The patch I uploaded only works for the packed 1.0 version that can be downloaded from this site. It was mentioned in a previous post but not in the one with the steps needed. You either need to use that version, or if it is necessary to use another, you can patch it manually using the information I posted in the hex editing thread.
ecco wrote: What's al that text in the text file after the intro about? Do I need to do something with that? What does ' note: you'll have to specify prince.exe as the argument, with the correct capitalization' mean?
I think it's not much related to your problem, but here it is anyway. I'm using Gnu/Linux, which has case-sensitive file-systems, that is, I can have a file named prince.exe or Prince.exe, and they are not the same. (I could also have them simultaneously.) When I use dosbox, it scans the directories I mount and indexes them with uppercase only, so when I type "prince" into dosbox, it will start regardless of the capitalization. But when I wrote the patch, I didn't want to check for all possibilities and didn't want to hardcode a specific capitalization. Therefore, I've left it as an argument. The comment is simply there to tell you that the additional complexity of having to give an argument (i.e. it isn't enough to double-click pdpatch.exe) is in fact a feature. :)
ecco wrote: I've been trying to work this out for a couple of hours now.. sigh
I don't have a clue when it comes to code :)
Ok, let's try to find where the problem is. I've repeated the steps of my instructions, and it works for me, so I'll write the md5 checksum of each changed file after each step here, so that you can check in which step the difference occurs. If you didn't know yet, md5 is a short hexadecimal string that can be computed from a file. Same files of course give the same string, while if the files are different, the checksums practically always differ. It is a comfortable way of finding out whether two files are identical if they aren't on the same computer. If you prefer utilities with a windowed interface, you can download md5 from digestIT, while if you prefer using the command-line, you can use md5sum for win32.

First download prince.zip and pdpatch.zip. Check them:

Code: Select all

fca8d4883eafe57879dd7c2af7b56d94  prince.zip
539136e52779095b6d6c0f49df1270aa  pdpatch.zip
Extract prince.zip

Code: Select all

673cff6493fa4ca6ca7a33c9156019c7  cdungeon.dat
e8f26a422c6f4098b7525459d3f2408f  cheats.bat
90b8e144a0640da0dc5b790d75fbba21  chklist.ms
10054079c32dc7bb227f178be6903e47  cpalace.dat
44476198612c4524cbbe80c06989f9fb  digisnd1.dat
7354cc5134a9801b9ed12b52264ba681  digisnd2.dat
5fb53b949d5a93d0f5d9a3487f1c664a  digisnd3.dat
5bcf2e961557f8a03a8c8603b3327dbf  edungeon.dat
c3388992315aa340934febb783bcd3dc  epalace.dat
c7145b333d1b82840afe273199127641  fat.dat
c9c4289cc0782bedbac1e6ee3af2db72  guard1.dat
ec0681974515a399eacafadd565c79cc  guard2.dat
27a45a2b2cc5ff2cc6589137572e3d33  guard.dat
08b61289714383532198cfbdaa3fab61  ibm_snd1.dat
3f26ac4ccf927a2dc33d426fe8cd9f55  ibm_snd2.dat
11bce4d594761f72019651e454f2a729  install.exe
c8306d955c016839d31d366fb75a7e9e  install.pdm
b6f0e8591dc0e317d9ef6427b04e19ad  kid.dat
be363625e64533fda1b0ef3263b26ac5  levels.dat
9307f2ac94e182c1e1fd9758b19429b1  midisnd1.dat
260e59171fabbb2f2b743abb04d6e110  midisnd2.dat
2b35b5d317c7464d534105156fbe5e46  poptrain.exe
4511be5b57aabb97f341cf18e18d4945  prince.dat
4ac7c522469baa084f1687c1c93f38c3  prince.exe
ad6eee596a6816eebab1702b879d9210  pv.dat
75cd22a5fc5e2638052c0097210ccdaf  readme.txt
0163c73287f822882a7b2b2d37f334e0  shadow.dat
a816258ce3089ad6dce9d17340ac355d  skel.dat
f8719b84b748e326d513d73ee6119329  title.dat
c2e164644dbcb194014140d057c00dee  vdungeon.dat
33a910991b0afb800868b631efaca1f3  vizier.dat
and pdpatch.zip

Code: Select all

1470d551ff63c7640302f383d1b7333c  pdpatch.c
1e3874c4dc6b182e28ea46d068e001a4  pdpatch.exe
fcb37b18ced7cf4220bc46622bcbd5af  resources.xml
Run "pdpatch prince.exe" from the command line.

Code: Select all

b75f8ed573f71c22f57038ee7795df58  prince.exe
Extract vdungeon.dat and vpalace.dat using pr. You can use the following commands:
pr -xvdungeon vdungeon.dat
pr -xvpalace vpalace.dat
There are quite some files there, so I won't write all the checksums here.
Copy all files from vdungeon\vdungeon\walls to vpalace\vpalace\walls, overwriting the files there. The files should be:

Code: Select all

5c652b04896044123d9e3f9bf927c66f  centre stack base.bmp
506d59df2884a86e2e6e01f8eacf2952  centre stack main.bmp
ec39d44ee3deacc22c999c746d4c4374  divider01.bmp
852e69de653abdc5812a1b9dc0e75238  divider02.bmp
e90c062c3d81f5660b9a6fa350271dc3  face stack main.bmp
caf0d0d54a1adaf7aaaac550005edd94  face stack top.bmp
96b37433cab81cf028a084dc7318630c  left stack base.bmp
24fffa143be4a8a3966ccb1c9f36f1e6  left stack main.bmp
915fc2b16271dfdf250ece5b42cce6e6  mark01.bmp
51b051996947b18481f2201f14a26ea4  mark02.bmp
95dbfad39cb417eaf3507ca838428133  mark03.bmp
acc8859946fbd625c4df8710bcc15224  mark04.bmp
5a3a966d2b9f2614bbbd2549d11c043b  random block.bmp
fc32e884ccfdb7bf54cdbe1f1060f3bd  right stack base.bmp
d7a4917b397d33eba226ad4c42e0d625  right stack main.bmp
ce64671a16f9d2afdede211a255b9067  single stack base.bmp
a59c9a63bcc4c4eb641812a0a1145dd3  single stack main.bmp
Copy vdungeon\vdungeon\palette\dungeon.pal to vpalace\vpalace\palette\wall.pal and vdungeon\vdungeon\dungeon.pal.more to vpalace\vpalace\palette\wall.pal.more. The vpalace\vpalace\palette folder should now contain:

Code: Select all

815bb6e3f496ea4d070d9710e9f5af4e  palace.pal
ac29ba1187e76f0666f5f6a2d18e426a  palace.pal.more
68ac0e933a04034ad65495f9809aba75  wall.pal
fa47cad5cb135dff19fa20744c8afbbf  wall.pal.more
Now that you have modified the palace tiles, you'll have to reimport them into vpalace.dat. You can use
pr -ivpalace vpalace.dat
to do this. After that, your vpalace.dat should be like this:

Code: Select all

738def40f506745e625d59e02ff7ae0f  vpalace.dat
If everything is identical so far, then you should get the correct results. If you identify the step where a difference occurs, it is more likely that we can find out the cause as well.

It should work. If it doesn't, ask me again.
ecco @ popuw.com (Sun Aug 20, 2006 2:10 pm) wrote: :D It's worked!! :D Thankyou so much- you're amazing.

I just went through the steps one by one again. I think maybe originally I didn't patch it correctly, and also something to do with the resources xml.

Also, I remember when attempting this yesterday that I read you had mentioned it had to be a specific version of prince.exe, but I couldn't find the post again.

I downloaded the checksum things which I couldn't even get them to work, but no worries now as it's fixed.

Thanks so much again. Here you go.. you now have your name etched in stone: :) (although the last 's' has mostly corroded away- sorry)

Image
poirot @ popuw.com (Sun Aug 20, 2006 6:31 pm) wrote: wow, I'm really impressed with all this new stuff!
  • further messages written after Aug 29, 2006 may have been lost
OrSpeeder
Sheikh
Sheikh
Posts: 49
Joined: July 24th, 2005, 8:05 pm
Location: Valinhos

Re: PR - the vpalace.dat extracting bug

Post by OrSpeeder »

I wish that I understood how to hack WDA into my 1.4 exec (that I already hacked some manually, by reading the .xml file and guessing what to do), because CusPOP is borked :(
Post Reply