Author Topic: ECL hacking  (Read 44 times)

Offline jhirvonen

  • Jr. Member
  • **
  • Posts: 87
ECL hacking
« on: August 13, 2017, 09:02:54 PM »
Possible spoilers ahead if you haven't played Pools of Darkness...


This is lengthy and code heavy so it might be tedious...



Most of you who have played Pools of Darkness are familiar with this scenario:





Travelling through the Limbo destroys most magical items as you can see from the AC values. All items which have plusses in the item properties are destroyed.

A new tool which can browse the ECL files, edit the parameters and then rebuild the file:



If we open the ECL which handles the Limbo stuff and search the text:

Code: [Select]
$0767     $8765   12   PRINTCLEAR          "'REMEMBER, THY ITEMS MAY BE DESTROYED! ITEMS FROM THE PRIME MATERIAL PLANE CAN BE LEFT SAFELY IN STORAGE HERE."
$07BD     $87BB   09   SAVE                0  <$0039> 
$07C3     $87C1   1D   ???                 
$07C4     $87C2   12   PRINTCLEAR          "DO YOU CONTINUE TO " 
$07D6     $87D4   11   PRINT               {$030D} 
$07DA     $87D8   11   PRINT               "?" 
$07DE     $87DC   22   ???                 
$07DF     $87DD   17   IF <>               
$07E0     $87DE   01   GOTO                <$8471> 
$07E4     $87E2   0E   PICTURE             139 
$07E7     $87E5   12   PRINTCLEAR          "ELMINSTER LEADS YOU TO THE GATE. " 
$0803     $8801   09   SAVE                14  <$0039> 
$0809     $8807   11   PRINT               "'FAREWELL...'" 
$0816     $8814   09   SAVE                0  <$0039> 
$081C     $881A   1D   ???                 
$081D     $881B   12   PRINTCLEAR          "" 
$0820     $881E   02   GOSUB               <$96D6> 

The values are: offset in file, address, command code, command name, parameters

At address $881E there's a GOSUB-command to $96d6 which is:

Code: [Select]
$16D8     $96D6   09   SAVE                0  <$00BF> 
$16DE     $96DC   11   PRINT               "THE WINDS OF LIMBO TEAR AT YOU! " 
$16F9     $96F7   2F   AND                 16  <$00EB>  <$00C0> 
$1702     $9700   17   IF <>               
$1703     $9701   01   GOTO                <$9758> 
$1707     $9705   30   OR                  16  <$00EB>  <$00EB> 
$1710     $970E   3A   DELAY               
$1711     $970F   3A   DELAY               
$1712     $9710   33   PRINT RETURN       
$1713     $9711   11   PRINT               "EACH STEP YOU TAKE MAY BE A MILE OR AN INCH. THE VOYAGE MAY HAVE TAKEN A MOMENT OR A YEAR."
$175A     $9758   1D   ???                 
$175B     $9759   03   COMPARE             1  <$00A2> 
$1761     $975F   16   IF =               
$1762     $9760   13   RETURN             
$1763     $9761   09   SAVE                0  <$009E> 
$1769     $9767   01   GOTO                <$9798> 

If $00A2 is 1, the subroutine returns to the caller. Otherwise, $009e is set to 0 and the GOTO $9798 jumps to following code block:

Code: [Select]
$179A     $9798   03   COMPARE             <$00BF>  73 
$17A0     $979E   16   IF =               
$17A1     $979F   09   SAVE                1  <$009E> 
$17A7     $97A5   03   COMPARE             <$00BF>  65 
$17AD     $97AB   16   IF =               
$17AE     $97AC   09   SAVE                1  <$009E> 
$17B4     $97B2   03   COMPARE             83  <$009B> 
$17BA     $97B8   17   IF <>               
$17BB     $97B9   01   GOTO                <$976B> 
$17BF     $97BD   03   COMPARE             <$00BF>  60 
$17C5     $97C3   16   IF =               
$17C6     $97C4   09   SAVE                1  <$009E> 
$17CC     $97CA   03   COMPARE             <$00BF>  62 
$17D2     $97D0   16   IF =               
$17D3     $97D1   09   SAVE                1  <$009E> 
$17D9     $97D7   03   COMPARE             <$00BF>  63 
$17DF     $97DD   16   IF =               
$17E0     $97DE   09   SAVE                1  <$009E> 
$17E6     $97E4   01   GOTO                <$976B> 

From what I understand the code block starting at $9798 checks for item types which may survive and sets $009e to 1 if such is found.

(item type 73 = vorpal sword, 65 = ring of wizardry, these are checked because they actually have plusses in the item properties)

Then there's a check for $009b which I guess check if the party is going to the Web dimension where the drow items (item types 62 and 63) will survive.

And then back to $976b.

Code: [Select]
$176D     $976B   03   COMPARE             1  <$009E> 
$1773     $9771   16   IF =               
$1774     $9772   01   GOTO                <$9783> 
$1778     $9776   30   OR                  128  <$00BF>  <$00C3> 
$1781     $977F   40   DESTROY ITEMS       <$00C3> 
$1785     $9783   03   COMPARE             <$00BF>  75 
$178B     $9789   1B   IF >=               
$178C     $978A   13   RETURN             
$178D     $978B   04   ADD                 1  <$00BF>  <$00BF> 
$1796     $9794   01   GOTO                <$9759> 

If $009e is 1, the routine jumps over the DESTROY ITEMS command.  This is probably some kind of routine which loops through the items and destroys them if $009e is not set.

At $9759 there was the COMPARE for $00a2. If it's 0, we go through the destroying routine, if 1 then we RETURN. How about if we return from the subroutine in both cases without going through
the destroying part at all?

Here's the code again:

Code: [Select]
$175B     $9759   03   COMPARE             1  <$00A2> 
$1761     $975F   16   IF =               
$1762     $9760   13   RETURN             
$1763     $9761   09   SAVE                0  <$009E> 
$1769     $9767   01   GOTO                <$9798> 

If we change the GOTO at $9767 to jump to $9760 instead of $9798 we will jump to a RETURN command which ends the subroutine call. Or, we could change the COMPARE so that both parameters are the same (for example 1 and 1) so that the IF= at $975f would always be true.



Let's also change the Elminster's "YE, OF COURSE, REALIZE THAT ANY ITEMS FROM THE OUTER DIMENSION WILL BE DESTROYED..." speech.

After saving the ECL and loading the same save game...





... the items survived.


If interested, I've included the ECL-Tool in the latest Gold Box Companion release. Read ECL-Tool.txt for more instructions.
http://personal.inet.fi/koti/jhirvonen/gbc


Offline jhirvonen

  • Jr. Member
  • **
  • Posts: 87
Re: ECL hacking
« Reply #1 on: August 16, 2017, 04:17:36 PM »
I added support for the Buck Rogers - games and The Dark Queen of Krynn. Monster and item names (in treasure) are now shown. You can now edit commands too (previously only the parameters of the commands).

Surprisingly, the Dark Queen uses the similar ECL-commands and not anything like FRUA events. The command set is almost/is same as in say, Pools of Darkness. The ECL.GLB-file had no run-length encoding either.

ECL-Tool is included in Gold Box Companion:
http://personal.inet.fi/koti/jhirvonen/gbc/gbc.zip

Offline Ishad Nha

  • Hero Member
  • *****
  • Posts: 941
Re: ECL hacking
« Reply #2 on: August 16, 2017, 09:07:59 PM »
DQK is halfway between previous Gold Box games and FRUA. SSI may have been in a hurry, they may have needed to get something out the door pronto.
Retaining the previous Ecl format may also have been an attempt to save space on the floppy disks.