Jump to content

Rewriting Cryo's Dune 1 : it seems possible !!!


Monsieur OUXX
 Share

Recommended Posts

take a phone book and look for Dune's programmer, it is easy... ;)

Err.. I don't think this is SO easy... It took me one month to find him back.

To use a phone book you have to know where he lives, and he relocated since the Dune times.

And now he is an older man who doesn't work anymore, so I'm not sure he'd parreciate that tens of fans ask him tons of questions... He'd probably prefer the questions to be clear and centralized.

Link to comment
Share on other sites

Hi guys! I have been keeping my eye on this thread for several months already, and first I would like to say that you're doing an awesome job! :)

However, I'm actually posting to ask for help with the unhsq thingie... I didn't manage to compile the unhsq assembly code myself using different versions of tasm under dosbox (I don't have an access to a "real" DOS machine).

If there exists a binary, could you please make it available to the public? The site at dev.java.net seems like a good place for this, right? See, I'm only interested in Dune music (I'm a big fan of Stephane Picq's works) and I'd like to play with the uncompressed agd/sdb files, maybe try to reverse engineer them. I also think the unhsq util may also be useful for the KGB tracks as well...

That's why I'm asking for it :)

Link to comment
Share on other sites

If there exists a binary of UnHSQ, could you please make it available to the public?

This binary IS AVAILABLE as an attached file to one of the previous posts, made by Roman or Borg

I'm not writing in red beacause I'm angry, but because several persons asked me that question :-)

Link to comment
Share on other sites

  • 1 month later...

Music:

ARRAKIS.HSQ - default/standard background music in many Dune scenes

BAGDAD.HSQ

KURSK.HSQ

MORNING.HSQ

SEKENCE.HSQ

SIETCHM.HSQ

WARSONG.HSQ - TAKE AN ORNITHOPTER

WATER.HSQ - Scene: The Water of life cave inside a Sietch

WORMSUIT.HSQ - DUNE intro (with text/introduction/history)

WORMINTR.HSQ - DUNE intro (without text/introduction/history)

The mentioned HSQ files will be played if you chosed: "Adlib music card" or "Sound Blaster (music + sounds)" in in DUNE's Installation (hardware configuration/GAME CONFIGURATION).

After this, the dune.bat file calls/starts the DUNE ("DUNEPRG.exe") executable with on of the following switches:

+ ADL

+ SDB2207

(depending on the music/sound device which was set before.)

*.AGD - DUNE music with Adlib Gold instrumentation and for Adlib Gold compatible devices

If you chose "Adlib Gold music card" in DUNE's Installation(hardware configuration/GAME CONFIGURATION), then the dune.bat file starts the DUNE executable with the parameter "AGD388".

Then DUNE loads "DUNEAGD.hsq" at the beginning and before playing any kind of music.

The unpacked "DUNEAGD.hsq" seems to be a kind of DUNE music format file reader and player for the *.AGD files.

...should be continued. :)

I noticed a file in the "MEGARACE.DAT" called, "DFSDB.HSQ", that might be MegaRace's format file reader and player for MegaRace's currently unplayable *.SDB files.  I have included a zip containing both the compressed "DFSDB.HSQ" and the uncompressed "DFSDB.___" generated by "UNHSQ".  Maybe these files can help us out with the SDB file format.  :)

dfsdb-MegaRace.zip

Link to comment
Share on other sites

Hi everyone,

quite a few years ago I created a DUNE 1 music

player by disassembling the original duneprg.exe.

I have also separated the code for uncompressing

HSQ files. In case anyone's interested, please

e-mail me, because I don't read the forum regularly.

Good luck.

Link to comment
Share on other sites

  • 1 month later...

Do you have any "real" material to show us? Or is the project still only

non-visual code?

I could show you an early version of the UML scheme of the "game" part of the project (not the "viewer" part"), but it's of little interest.

I've already thought of a global architecture, using Ogre3D for the display and LUA for the script, but these are only preliminary ideas

Link to comment
Share on other sites

I thought I'd drop by and see how things are going. When you get to the artwork part contact me if you need help.

About the coding part, well, if you need help just post the part that is not working, and if anyone knows how to help will write the modifications.

Link to comment
Share on other sites

What C are you using? If you use C++ 3.1 then it will work. At least I think it will. I never used ASM in C simply because I don't know assembler. I had C++ 3.1 under Win XP and it worked fine, though it used 100% of my P4 2400 Mhz (!!!).

Link to comment
Share on other sites

100 cpu usage? You simply need to find a way to cut some slack on the cpu in the OS you run it in? I use a 3rd party library, where i can yield_timeslice and use 'rest()' in order to give the cpu an x amount of time to do other stuff (and thus not take a 100% time/load on my program). In fact , if you want to have it real neat (check out the d2tm source if you want to know how), you simply let your program take more rest when it can give up more, and take more cpu when it really needs it...

Link to comment
Share on other sites

I never got that far in optimising. Does anyone have the Borland C++ 3.1? I've lost mine quite a while ago.

I didn't do any programming in 3 years (!!!), man, time flies. There was a moment when I thought I'll go to Polytechnics - Automatics ( meaning computers/programming) but I went to Architecture.

So, every time I see a code line I remember high-school.

ok, ok sorry for the softness back there  ;D

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

hello, can anyone please repost the unhsq tool. It seems that the original attachement was deleted.

Good news! A new contributor, Rafał Przywarski, wrote a C uncompressor, using the link to the wiki just above. He told me he'd probably post on the wiki the minor modifications he made to HNM to make it HSQ-reverse-compatible.

Anyway, here is the source code : it should be very easy to compile.

The code contains two identical functions :

- unpack (assembly)

- unpack2 ©

You only need one of them.

Compile this code and you'll get a brand new UNHSQ


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

typedef unsigned char byte;
typedef unsigned short word;

byte *loadfile(const char *filename)
{
      FILE *f = fopen(filename, "rb");


      if (f == NULL) {

              printf("ERROR:Can't open file %s!n", filename);

              exit(0);
      }
      else
              printf("Reading file %s...n", filename);

      int size = 0;

      fseek(f, 3, SEEK_SET);

      fread(&size, 2, 1, f);

      byte *data = new byte[size];

      fseek(f, 0, SEEK_SET);
      fread(data, size, 1, f);

      fclose(f);

      return data;
}

int getbit(int& q, byte *& src)
{
      if (q == 1) {

              q = 0x10000 | *(word *) src;
              src += 2;
      }

      if (q & 1) {

              q >>= 1;

              return 1;
      }
      else {

              q >>= 1;

              return 0;
      }
}

bool unpack2(byte *src, byte *dst)
{
      if (((src[0] + src[1] + src[2] + src[3] + src[4] + src[5]) & 0xff) != 171)
              return false;

      int q = 1;

      src += 6;

      while (1) {

              if (getbit(q, src)) *dst++ = *src++;
              else {

                      int count;
                      int offset;

                      if (getbit(q, src)) {

                              count = *src & 7;
                              offset = 0xffffe000 | ((*(word *) src) >> 3);

                              src += 2;

                              if (!count) {

                                      count = *src++;
                              }

                              if (!count)    return true;
                      }
                      else {

                              count = getbit(q, src) << 1;
                              count |= getbit(q, src);

                              offset = 0xffffff00 | *src++;
                      }

                      count += 2;

                      byte *dm = dst + offset;

                      while (count--) *dst++ = *dm++;
              }
      }
}

void unpack(byte *src)
{
      static byte *s = src;

      asm {
                              mov        edi,src

                              push  ecx
                              push  edi
                              push  ds
                              push  es
                              pop    ds
                              mov    edx, edi
                              add    edx, ecx
                              mov    ecx, 6
                              mov    esi, edi
                              xor    eax, eax
@@1:            lodsb
                              add    ah, al
                              loop  @@1
                              cmp    ah, 0abh
                              jne    @@2
                              mov    esi, edi
                              xor        eax,eax
                              lodsw
                              mov    edi, eax
                              lodsb
                              or    al, al
                              je    @@3
@@2:            stc
                              pop    ds
                              pop    edi
                              pop    ecx
                              ret

                              push  ecx
                              push  di
                              push  ds
                              add    esi, 6
                              xor    ebp, ebp
                              jmp    @@4

@@3:
                              xor        eax,eax
                              lodsw
                              mov    ecx, eax
                              sub    esi, 5
                              mov    ebp, esi
                              add    edi, esi
                              add    edi, 20h
                              add    esi, ecx
                              dec    esi
                              dec    edi
                              sub    ecx, 6
                              std
                              shr    ecx, 1
                              jnb    @@5
                              movsb
@@5:            dec    esi
                              dec    edi
                              rep movsw
                              cld
                              mov    esi, edi
                              add    esi, 2
                              mov    edi, ebp
                              xor    ebp, ebp
@@4:            shr    bp, 1
                              je    @@6
                              jnb    @@7
@@8:            movsb
                              jmp    @@4
@@6:
                              xor        eax,eax
                              lodsw
                              mov    ebp, eax
                              stc
                              rcr    bp, 1
                              jb    @@8
@@7:            xor    ecx, ecx
                              shr    bp, 1
                              jne    @@9
                              xor        eax,eax
                              lodsw
                              mov    ebp, eax
                              stc
                              rcr    bp, 1
@@9:            jb    @@12
                              shr    bp, 1
                              jne    @@10
                              xor        eax,eax
                              lodsw
                              mov    ebp, eax
                              stc
                              rcr    bp, 1
@@10:          rcl    ecx, 1
                              shr    bp, 1
                              jne    @@11
                              xor        eax,eax
                              lodsw
                              mov    ebp, eax
                              stc
                              rcr    bp, 1
@@11:          rcl    ecx, 1
                              mov        eax,-1
                              lodsb
@@13:          add    eax, edi
                              xchg  esi, eax
                              mov    ebx, ds
                              mov    edx, es
                              mov    ds, edx
                              inc    ecx
                              inc    ecx
                              rep movsb
                              mov    ds, ebx
                              mov    esi, eax
                              jmp    @@4

@@12:
                              xor        eax,eax
                              lodsw
                              mov    cl, al
                              shr    eax, 1
                              shr    eax, 1
                              shr    eax, 1
                              or        eax, 0ffffe000h
//                              or    ah, 0e0h
                              and    cl, 7
                              jne    @@13
                              mov    ebx, eax
                              lodsb
                              mov    cl, al
                              mov    eax, ebx
                              or    cl, cl
                              jne    @@13
                              pop    ds
                              pop    edi
                              pop    ecx
                              mov    edi, esi
                              sub    edi, 20h

      }
}

void writefile(const char *filename, byte *data, int size)
{
      FILE *f = fopen(filename, "wb");

      if (f == NULL) {

              printf("ERROR:Can't create file %s!n", filename);

              exit(0);
      }
      else
              printf("Writing file %s...n", filename);

      fwrite(data, size, 1, f);

      fclose(f);
}

int main(int argc, char* argv[])
{
      printf("UnHSQ Copyright (C) Roman Dolejsinn");

      if (argc != 3) {

              printf("usage: unhsq <input file.hsq> <output file>n");

              return 1;
      }

      byte *src = loadfile(argv[1]);
      int size = *((int *) src) & 0xffff;
      byte *dst = new byte[size];

      printf("Unpacking...n");

      if (unpack2(src, dst)) {

              writefile(argv[2], dst, size);
              printf("donen");
      }
      else printf("failedn");

      delete[] src;
      delete[] dst;

      return 0;
}
//---------------------------------------------------------------------------

Link to comment
Share on other sites

Is it possible for anyone to make a simple HNM player/viewer

It's possible.

At this moment I'm focused on HSQ format, and the second step of compression (RLE) still has to be solved, but the hardest has been done.

But be warned : it'll be much more difficult to code a player that also plays the sounds of the videos!

Link to comment
Share on other sites

Hi everyone, ;)

It's been a while since I've discovered this nice thread and following with enthusiasm the Dune Revival Project. I'd like to ask some things about the structure of the game:

1) I have decompressed all the .hsq files (thanks to Monsieur OUXX who has sent me the unhsq already compiled :) ) and noticed that the files phrase11.unp, phrase12.unp, phrase21.unp, phrase22.unp, phrase31.unp and phrase32.unp contain all the dialogues used in the game in english, french and german. But actually in the game I can't change the language of subtitles, there is only english! ??? Is my version of the game corrupted or is this a normal thing? If so, why put also the french and german dialogues if they can't be used?

2) I have also the CD version of the game (with a lot more features, Dune movie footage, digitalized speeches, etc.), and, since there is the Italian version of the dialogues, I would like to extract it just like those I have unpacked now with unhsq. But in this version of the game there aren't any hsq files, just a huge dune.dat of 380 MB! I suppose it should be a kind of archive containing all the hsq files of the floppy version plus other things. Do you know if there is a mean to unpack this type of archive?

Thanks :)

Rymoah

Link to comment
Share on other sites

I think there might be two problems with that.  As you know, Dune's HSQ files are packed in the *.EXE, but in MegaRace, they're in a *.DAT file known as "MEGARACE.DAT".  Fortunately, there is a program known as "Game Extractor" that unpacks the HSQ files from the DAT file.  We just need to tell <b>UNHSQ.BAT</b> it doesn't need to look through the DAT file, it can just go to the HSQ files directly.

The other problem is that when I typed in the DOS prompt, it said,

"File not found" and I got this in the text file:<b>

Volume in drive D is MEGARACE

Volume Serial Number is 0794-E722

Directory of D:

                        0 bytes free</b>

Did something go wrong?  Nevertheless, I'll still send the text file and HSQ files to you via email.

Sure thing, Borg Number One! ;)

Sorry, I've noticed only now this post by Lance Boyle. I've seen the Game Extractor compatibility list, and Dune is included, but the extension associated isn't the same (.dun). Assuming that MegaRace format is the same (.dat), and being both games developed by Cryo, do you think this Game Extractor should work also for Dune?

Thanks

Rymoah

Link to comment
Share on other sites

Here is what I discovered recently concerning the Graphics files, thanks to the source codes of Rafał Przywarski and Roman Dolejsi.

I managed to understand how the palette works :

GENERAL EXPLANATIONS

At the beginning of the file, there are several "palettes pieces", or "sub-palettes", i.e. local definitions of different parts of the global palette.

For each sub-palette, the file contains :

1/ The place where the sub-palette will be inserted in the in-game palette, that means if you read "07h" and then you read 4 colors, these colors will replace the four colors of the in-game palette, starting from color 07.

2/ the number of colors the sub-palette defines (you have to multiply by 3 to find the number of bytes to read),

3/ the RGB values of the colors

(in balcon.hsq unpacked) :

You can see what happens if you change these values by going to the "balcon screen" on the right just at the beginning if the game.

Note : this has also effects on the "palace entrance" screen.

HEADER ?

00h = the offset of the end of the "palette data"?

[01h, 06h] = ???

SUB-PALETTE #1 : brown parts of the orni

07h = offset where sub-palette #1 has to be inserted in the global palette

08h = nb of colors of sub-palette #1

[09h,23h] = sub-palette #1

SUB-PALETTE #2 : green cockpit of the orni

24h = offset where sub-palette #2 has to be inserted in the global palette

25h = nb of colors of sub-palette #2

[26h,2Bh] = sub-palette #2

SUB-PALETTE #3 : violet walls of the palace

2Ch = offset of sub-palette #3

2Dh = nb of colors

[2Eh,5Dh] = sub-palette #3

ESCAPE CODE?

5E and 5F = escape code (FF FF) to indicate the end of the header ?

After this data, the sprites definitions begin..

---------------

PS :

(thanks to Monsieur OUXX who has sent me the unhsq already compiled Smiley )

You should thank Roman Dolejsi who is the author of this program and compiled it for our purpose.

Link to comment
Share on other sites

PS :

You should thank Roman Dolejsi who is the author of this program and compiled it for our purpose.

Sorry, obviously I didn't want to forget the great job that has done RDOS coding this depacker. ;)

Thanks Roman! :)

And thanks again to you, Monsieur OUXX, for your efforts to bring back to life this fantastic game!

(PS: finally I've managed with Multi Ex Commander to unpack the .dat file of the CD version. It's full of .hsq files, .hnm files and .voc files, the ones that contains speeches. Do you think it will be possible, Monsieur OUXX, after having programmed the virtual machine for the floppy version, to adapt it also to the CD version?)

Rymoah

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...