I've come back to this issue tonight to dig for some more information, but I can't wrap my head around it.
I added extra log outputs to dosbox-0.74 so that it would print out the palette when it's changed:
Code: Select all
--- dosbox-0.74/src/gui/render.cpp.old 2017-11-05 23:23:45.508654441 +0100
+++ dosbox-0.74/src/gui/render.cpp 2017-11-05 23:24:34.987851237 +0100
@@ -68,11 +68,16 @@
break;
case scalerMode32:
default:
+ if (render.pal.first == 0) {
+ LOG_MSG("const uint32_t g_palette[256] = {\n");
+ }
+
for (i=render.pal.first;i<=render.pal.last;i++) {
Bit8u r=render.pal.rgb[i].red;
Bit8u g=render.pal.rgb[i].green;
Bit8u b=render.pal.rgb[i].blue;
Bit32u newPal = GFX_GetRGB(r,g,b);
+ LOG_MSG("\t0x%08X,\n", newPal);
if (newPal != render.pal.lut.b32[i]) {
render.pal.changed = true;
render.pal.modified[i] = 1;
I also added extra printouts for other system calls like file open, read, and close. Here's an example of the log output from a run of the game:
Code: Select all
8281289: FILES:file open command 0 file DGATE010.FNT
SPEL\DGATE\DGATE010.FNT: reading 4096 bytes @ 0x00000000
8303866: FILES:file close command: SPEL\DGATE\DGATE010.FNT
8367343: FILES:file close command: SPEL\DGATE\DGATE000.PIC
8372084: FILES:file open command 0 file C:\SPEL\DGATE\DGATE001.PIC
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x00001000
SPEL\DGATE\DGATE001.PIC: reading 5120 bytes @ 0x00002000
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x00003400
8593830: FILES:file close command: SPEL\DGATE\DGATE001.PIC
8598443: FILES:file open command 0 file C:\SPEL\DGATE\DGATE000.PIC
SPEL\DGATE\DGATE000.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE000.PIC: reading 4096 bytes @ 0x0000196D
8702771: FILES:file close command: SPEL\DGATE\DGATE000.PIC
8706810: FILES:file open command 0 file C:\SPEL\DGATE\DGATE001.PIC
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x0001311A
SPEL\DGATE\DGATE001.PIC: reading 4096 bytes @ 0x000062AC
8779698: FILES:file open command 0 file C:\SPEL\DGATE\DGATE019.RGN
SPEL\DGATE\DGATE019.RGN: reading 4096 bytes @ 0x00000000
8836227: FILES:file close command: SPEL\DGATE\DGATE001.PIC
8840350: FILES:file open command 0 file C:\SPEL\DGATE\DGATE019.PIC
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x0001EA98
SPEL\DGATE\DGATE019.PIC: reading 4608 bytes @ 0x0001FA98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00020C98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00021C98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00022C98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00023C98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00024C98
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00025C98
8894818: FILES:file close command: SPEL\DGATE\DGATE019.PIC
8899704: FILES:file open command 0 file C:\SPEL\DGATE\DGATE057.PIC
SPEL\DGATE\DGATE057.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE057.PIC: reading 4096 bytes @ 0x0006FDE4
8928523: FILES:file close command: SPEL\DGATE\DGATE057.PIC
8933374: FILES:file open command 0 file C:\SPEL\DGATE\DGATE019.PIC
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00000000
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00028891
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x00026B68
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x0002865C
SPEL\DGATE\DGATE019.PIC: reading 4096 bytes @ 0x0002788A
const uint32_t g_palette[256] = {
0x00000000,
0x00101010,
...
0x00414141,
0x00FFFFFF,
There is much more in the log but I thought it best to keep it short. There is also a fading effect going on after the intro. This seems to be done with palette cycling; a lot of new palettes are getting applied while after the intro is done and the first scene fades in.
I've setup dosbox to automatically run the game and I hit the ESC button to skip any intro, which takes me directly to the first interactive screen. This is how that screen looks like:
By inspecting the log, and using my tool to open the resource files, I can see that the game extracts a few different images and layer them on top of each other. For example, DGATE019.PIC contains this image at offset 0x0001EA98
Notice how the right lamp post, Xar, and the Nexus seal piece above his head are missing. These are all also located in the DGATE019.PIC resource file, at the offsets indicated by the log file. However, and this is what really bothers me, if I take the exact palette that dosbox dumped in the log for me and apply it to those overlayed images, it shows the completely wrong colors (the "big" picture is fine). For example, here's what I believe is the lamp post and the nexus seal piece:
![Image](https://image.ibb.co/e3kJHb/lamp_post.png)
I feel like I'm missing something crucial in understanding either how palettes work or how death gate is handling these overlayed images. Maybe there is some kind of index translation going on?
There might be some clues in the DGATE019.RGN file that is opened just before DGATE019.PIC.
Test code is, as usual, available on
GitHub
EDIT:
I feel that figuring out how the scene display code works is the major blocker for allowing me (and others) to work on an actual game engine for Death Gate. I'm running out of ideas and that's when the progress slows down. If only I could figure this out, it would be so much easier to start hacking away at getting an actual game running. It would definitely feel like it's progressing faster once you can actually interact with the game.