Jump to content

Dune II editor with 1.07 support


Nyerguds

Recommended Posts

On a slightly related note, I noticed that the Saboteur, when you just put him on Guard, attacks nearby enemy stuff by shooting at it, just like the normal soldier ;D

I first learned that from this FAQ: http://db.gamefaqs.com/console/genesis/file/dune_ii_battle_for_arakis.txt

Although it's for the Sega version, it's got plenty of interesting stuff that applies to the PC version as well :) The other Dune 2 FAQs at GameFAQs are also useful.

Link to comment
Share on other sites

Do we have the addresses of those exceptions for The WOR for Harkonnen and Light Factory for Harkonnen (pls. including comments about the stack variables / register values or is the whole disassembly somewhere availabe)?

Just want to play with those for my custom Sardaukar, Mercenary, Fremen tech trees, in the SuperDune Classic (btw. the offsets are -0x50 in the super.exe executable, was it reflected into *.asm code file?).

Link to comment
Share on other sites

Here you go:

is the heavy factory techlevel2 skipping Ordos only?

essentially...

if(ordos && heavy factory && techlevel == 2)

  techlevel = 3;

seg007:02B1 26 80 7F 08 02                    cmp    es:[bx+_buildingGame.houseID], 2

seg007:02B6 75 1F                            jnz    short loc_17A87

seg007:02B8 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:02BC 26 80 7F 02 04                    cmp    es:[bx+_buildingGame.TypeIndex], 4  ; Heavy factory

seg007:02C1 75 14                            jnz    short loc_17A87

seg007:02C3 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:02C7 26 80 7F 4E 02                    cmp    es:[bx+_buildingGame.techLevel], 2

seg007:02CC 75 09                            jnz    short loc_17A87

seg007:02CE C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:02D2 26 C6 47 4E 03                    mov    es:[bx+_buildingGame.techLevel], 3

theres a bunch more too, except they're located in a different function (called right after the code above)

Hark / Hi-tech

seg010:2618 26 80 7F 08 00                    cmp    es:[bx+_buildingGame.houseID], 0

seg010:261D 75 0F                            jnz    short loc_1CA5E

seg010:261F C4 5E 06                          les    bx, [bp+buildingGamePtr]

seg010:2622 26 80 7F 02 05                    cmp    es:[bx+_buildingGame.TypeIndex], 5  ; Hi-Tech Fact

seg010:2627 75 05                            jnz    short loc_1CA5E

theres a WOR factory check just below this too, if you like give me a list of specifics i should be looking for and ill try track the code down for you

Harkonnen Light Factory is managed here (in the structureCreate function itself)

seg010:00F1 83 7E 0A 00                      cmp    [bp+houseID], 0                    ; Compare Two Operands

seg010:00F5 75 0D                            jnz    short loc_1A534                    ; Jump if Not Zero (ZF=0)

seg010:00F7 83 FE 03                          cmp    si, 3                              ; Compare Two Operands

seg010:00FA 75 08                            jnz    short loc_1A534                    ; Jump if Not Zero (ZF=0)

seg010:00FC C4 5E FC                          les    bx, [bp+gameObjectPtr]              ; Load Full Pointer to ES:xx

seg010:00FF 26 C6 47 4E 01                    mov    es:[bx+_buildingGame.techLevel], 1

Link to comment
Share on other sites

Nyerguds, got a few more fields for you

Structures:

Unknown 35 - 36 (anim0)

Unknown 37 - 38 (anim1)

Unknown 39 - 40 (anim2)

These are offsets (dwords), which point to the animation frame data for each "frame mode" of a structure.

quick example,

the exe im looking at: const yard anim0 comes to 0x3A900

below data appears as 'ZYYY'

Z is the function to execute

Y is the data

Z indexs:

( field is shifted right 12 bits before use )

0: Remove structure from map, clear the anim cell data struct

1: clear the anim cell data struct

2: not sure

3: set a wait + random time

4: reset to step 0

5: play a sound effect

6: set the frame number (based in the icon data)

7: decrease step by "

8: change the gfx id (this id would be set initially to the construction yard id (17) in this case)

9: calls 0

flapping of the flag on the const yard:

seg123:0000 02 60                   dw 6002h                                    

seg123:0002 1E 30                   dw 301Eh

seg123:0004 03 60                   dw 6003h

seg123:0006 1E 30                   dw 301Eh

seg123:0008 00 40                   dw 4000h

0: set frame to 2

1: wait 0x1e + (seed & 3)

2: set frame to 3

3: wait 0x1e + (seed & 3)

4: set step to 0            (infinite loop)

Link to comment
Share on other sites

theres also a few fields which are not used (editing them is pointless, as the game overwrites during runtime)

Structures:

Unknown 24: Used inbetween the game and the Choam screen, is set to 1 if the structure can be built, -1 if an upgrade is needed, and 0 if dont show

Units:

Unknown 21: Same as Structures Unknown 24

22-23 i believe are used similar

Link to comment
Share on other sites

the exe im looking at: const yard anim0 comes to 0x3A900

Huh, how does that translate? The actual data in the exe is "00 00 2A 90". It also seems that the final actual offset is 2F500

You know, with this data, I'm tempted to put a script editor for this in my editor.. thought that'd be tons of work. Might have to add a "level 5" in the internals (for scrolling and selecting items - 1=types list, 2=items list, 3=options list, 4=editing mode list) :P

Link to comment
Share on other sites

0: Remove structure from map, clear the anim cell data struct

1: clear the anim cell data struct

2: not sure

3: set a wait + random time

4: reset to step 0

5: play a sound effect

6: set the frame number (based in the icon data)

7: decrease step by "

8: change the gfx id (this id would be set initially to the construction yard id (17) in this case)

9: calls 0

flapping of the flag on the const yard:

seg123:0000 02 60                   dw 6002h                                    

seg123:0002 1E 30                   dw 301Eh

seg123:0004 03 60                   dw 6003h

seg123:0006 1E 30                   dw 301Eh

seg123:0008 00 40                   dw 4000h

0: set frame to 2

1: wait 0x1e + (seed & 3)

2: set frame to 3

3: wait 0x1e + (seed & 3)

4: set step to 0            (infinite loop)

Hm, this reminded me of the stuff at the beginning of BUILD.EMC. Actually, I think it might very well be the same thing :)

Link to comment
Share on other sites

Huh, how does that translate? The actual data in the exe is "00 00 2A 90". It also seems that the final actual offset is 2F500

not sure exactly, but i use it like this

word *cResourceExe::animPtrGet( size_t pAddress ) {

byte *test = _bufferExe + (pAddress >> 12) + 0x4C00;

return (word*) test;

}

0x4C00 is start of segment 0 in this particular exe

Hm, this reminded me of the stuff at the beginning of BUILD.EMC. Actually, I think it might very well be the same thing :)

your close ;)  (the var name 'frame' in the building stuff is misleading, however it was named in the emcpack tools years ago... so ive left it as is)

but at the start of build.emc is a script which is executed by all buildings when placed on field.

it flickers between the construction frame script, which is number -1 (255)

which only displays 1 frame, the construction frame

and the buildings "anim0" frame script

start of the script,

Push                255

Execute            SetFrame

AddSP              1

Push                15

Execute            Delay

AddSP              1

Push                0

Execute            SetFrame

Link to comment
Share on other sites

So is there a way to determine what Unknown 006 bit 6 is about? I keep wondering why it's off for all units in v1.0 and on for everything except projectiles in 1.07. Could it be that this has something to do with units getting stuck at map borders? In v1.0, Carryalls sometimes get stuck at the border of the map when bringing in reinforcements, and I suspect this happens to Frigates as well.

Link to comment
Share on other sites

0: Remove structure from map, clear the anim cell data struct

1: clear the anim cell data struct

2: not sure

3: set a wait + random time

4: reset to step 0

5: play a sound effect

6: set the frame number (based in the icon data)

7: decrease step by "

8: change the gfx id (this id would be set initially to the construction yard id (17) in this case)

9: calls 0

What exactly do you mean with #1 and #7, and what's the difference between 4 and 9?

Link to comment
Share on other sites

an array using the following structure,

00000000 struc_13        struc ; (sizeof=0x11)

00000000 timer          dd ?

00000004 foundationSize  dw ?

00000006 houseID        db ?

00000007 tileFrameCount  db ?

00000008 structGfxID    db ?

00000009 tileAnimData    dd ?

0000000D posX            dw ?

0000000F posY            dw ?

00000011 struc_13        ends

is used at runtime for every "map cell animation" thats running (atleast one for each structure)

#1, clears the structure in the array (stops the animation)

#7, the current 'step'/'tileAnimData' ptr is reduced by X (X is supplied as the data)

(these are what i meant by steps)

seg123:0000 02 60                  dw 6002h                                   

seg123:0002 1E 30                  dw 301Eh

seg123:0004 03 60                  dw 6003h

seg123:0006 1E 30                  dw 301Eh

9 does the same as 0, removes the structure animation from the screen and wipes the data struct

4 goes back to the start of the animation

Link to comment
Share on other sites

I have a question. I'm trying to turn the IX into an AI-controlled Starport (as inspired by Dune2EX, the Ordos & Mercs have access to a starport instead of a factory). The way I want to do this is to turn the IX into a factory that LOOKS like the starport but acts as a heavy factory (and is obviously only controllable by the AI). The graphic switch succeeded, but I can't get the AI to use it to produce units. I set "has a build screen" to YES, but it still doesn't work.

When I give myself one of these buildings, it has the build unit icon of a carryall (which does nothing), and I can't enter the building's construction screen. Did I miss something? Do I have to change something in build.emc?

Link to comment
Share on other sites

The fact that the build screen is activated is just a graphic/interface tweak. It does not actually ALLOW the building to "build stuff" or even access a build menu for the building. This menu is hardcoded somewhere else "probably in BUILD.EMC".

-Daelin

Link to comment
Share on other sites

The fact that the build screen is activated is just a graphic/interface tweak. It does not actually ALLOW the building to "build stuff" or even access a build menu for the building. This menu is hardcoded somewhere else "probably in BUILD.EMC".

Hardcoded, yes, but not in BUILD.EMC - it's in the EXE. We discussed it with segra a while ago:

I think this is worth mentioning. I've been playing around with structure editing and, among other things, tried converting the House of IX into a factory-type structure. I copied all the data from WOR and later Hi-Tech Factory using Nyerguds' editor, and although the IX structure got a clickable icon and an option to build a Carryall (no matter what actual units I specified in the build list), I couldn't either open the actual build menu by clicking on the icon, or produce anything: the production of a Carryall could be started by clicking on the "Build It" icon, and it would reach 100% and say "Complete", yet the Carryall would not come out of the structure at all. I thought the data defining if a structure can produce units or not is defined via BUILD.EMC, but found that the part of the script referring to the IX structure is identical to that of WOR - reveal terrain, play animation, nothing else.

Does it mean there are other places in the EXE where data concerning such things as described above is stored?

Kinda doesn't surprise me, all throughout the game code exists segments such as this

seg007:05B6 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:05BA 26 80 7F 02 0A                    cmp    es:[bx+_buildingGame.TypeIndex], 0Ah ; Barracks

seg007:05BF 74 72                            jz      short BarracksWOR

seg007:05C1 C4 1E C0 84                      les    bx, buildingGamePtrCurrent

seg007:05C5 26 80 7F 02 07                    cmp    es:[bx+_buildingGame.TypeIndex], 7 ; WOR

seg007:05CA 74 67                            jz      short BarracksWOR

seg007:05CC

The "TypeIndex" field is actually the index into the data table (this code jumps to a location if its in the WOR/BARRACKS data position)... alot of code is like this

Link to comment
Share on other sites

build menu is generated when you click the choam button, it uses the various hardcoded datafields, as well as some runtime ones

the code is similar to this,

map< word, sData* > buildList;

dword structs = houseGet()->structuresHaveGet();

dword structsNeeded;

word ax;

switch( typeGet() ) {

case _StructureType_LightFactory:

case _StructureType_HeavyFactory:

case _StructureType_HiTech:

case _StructureType_WOR:

case _StructureType_Barracks:

for( word si = 0; si < 8; ++si ) {

ax = dataGet()->constructOpt[si];

if(ax == 0xFFFF)

continue;

if(ax == 0x0D && scriptDataGet()->stack[0x0F] == 2)

ax = 0x0E;

sUnitData *unitData = engineGet()->resourcesGet()->unitGet( ax );

short int di = (short int) unitData->UpgradesNeeded;

if( ax == 0x0A && scriptDataGet()->stack[0x0F] == 2)

--di;

structsNeeded = (structs & unitData->PreReqs);

if( structsNeeded != unitData->PreReqs)

continue;

word dx = (1 << scriptDataGet()->stack[0x0F]);

if( !(unitData->Owner & dx ))

continue;

if( _techLevel >= di ) {

buildList.insert( make_pair( 1, unitData ) );

continue;

}

if( _techUpgradeProgress == 0 )

continue;

ax = _techLevel + 1;

if( ax < di )

continue;

buildList.insert( make_pair( 0xFF, unitData ) );

}

return buildList;

case _StructureType_IX:

case _StructureType_Windtrap:

return buildList;

case _StructureType_ConstYard:

for( word si = 0; si < 0x13; ++si ) {

sStructureData *structData = engineGet()->resourcesGet()->structureGet( si );

word di = structData->Techlevel;

structsNeeded = structData->PreReqs;

if( si == _StructureType_WOR ) {

if( _house->houseIDGet() == eHouse_Harkonnen )

if( engineGet()->missionNumberPreviousGet()  >= 1 ) {

structsNeeded &= 0xFFFFFBFF; // fixme?

di = 2;

}

}

structsNeeded = (structs & structData->PreReqs);

if(structsNeeded != structData->PreReqs) {

if( houseGet() == engineGet()->houseHumanGet() )

continue;

}

if( houseGet()->houseIDGet() != eHouse_Harkonnen && si == _StructureType_LightFactory )

di = 2;

ax = di;

--ax;

if( ax > engineGet()->missionNumberPreviousGet() )

continue;

ax = structData->Owner;

word dx = (1 << houseGet()->houseIDGet());

if( !(dx & ax ))

continue;

ax = structData->CYUpgradesNeeded;

if( ax <= _techLevel || _house != engineGet()->houseHumanGet() ) {

buildList.insert( make_pair( 1, structData ) );

continue;

}

if( !_techUpgradeProgress )

continue;

ax = structData->CYUpgradesNeeded;

if( ax > (_techLevel + 1) )

continue;

buildList.insert( make_pair( 0xFF, structData ) );

}

return buildList;

case _StructureType_Starport:

buildList.insert( make_pair( 0xFF, (sData*) 0x0 ) );

return buildList;

default:

return buildList;

}

Link to comment
Share on other sites

Man, why on earth didn't they put a building construction type in the building stats and make the case check on that? -_-

Hmm... you know, with the leftover blank bytes we got from some 2-byte bit flags that use less than 8 bits, we could theoretically squeeze that in there :)

That byte just before the infantry spawn chance isn't actually used anywhere, right? Just included in the 2-byte value for the bit flags before it ;D

Link to comment
Share on other sites

On a vaguely related note, segra, is it possible to fix the flashing item selection box on build lists for the new sides? Normally, the selection box that indicates the currently selected item flashes and has the current House's color; with the new sides in Super Dune II, the selection box is always white:

heraldnormalhr2.png

heraldplaceholderpl2.png

EDIT: File type 6 seems to mark PAK files that are absolutely necessary for the game to run, and without which the game will refuse to load at all.

Also, it makes the game freeze while reading a Mentat database entry if a MENTAT?.ENG file edited with SSTEditor is inside ENGLISH.PAK :)

Link to comment
Share on other sites

Nice info on the PAK types.

As for the blinking colours, not sure if that can be fixed. My experience from C&C and RA1 tells me that every blinking colour is an actual palette entry that does that. So I kinda doubt these extra sides will have such a colour on the palette.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.