Difference between revisions of "User:Morgan525"

From UFOpaedia
Jump to navigation Jump to search
Line 12: Line 12:
  
 
==Other information==
 
==Other information==
 
+
.text:00432160                mov    cx, [esp+missiontype]
  text:00432160                mov    cx, [esp+missiontype]
 
 
  .text:00432165                push    ebx
 
  .text:00432165                push    ebx
 
  .text:00432166                mov    ebx, [esp+4+zonenum]
 
  .text:00432166                mov    ebx, [esp+4+zonenum]
  .text:0043216A                push    ebp
+
  .text:0043216A                push     
  .text:0043216B                movsx  eax, bx
+
  .text:0043216B                movsx   
  .text:0043216E                push    edi
+
  .text:0043216E                push     
  .text:0043216F                lea    edi, ds:0[eax*8]
+
  .text:0043216F                lea     
  .text:00432176                movsx  edx, cx
+
  .text:00432176                movsx   
  .text:00432179                sub    edi, eax
+
  .text:00432179                sub     
 
  .text:0043217B                mov    eax, dwpMISSIONSDAT_49B220
 
  .text:0043217B                mov    eax, dwpMISSIONSDAT_49B220
  .text:00432180                add    edx, edi
+
  .text:00432180                add     
  .text:00432182                cmp    cx, 3             ;*
+
  .text:00432182                cmp    cx, 3
  .text:00432186                mov     bp, [eax+edx*8+6] 
+
  .text:00432186                mov      
  .text:0043218B                jnz    loc_4326E1        ;*if missiontype is not 3 goto loc_4326E1
+
  .text:0043218B                jnz    loc_4326E1        ;if missiontype is not 3 goto 4326E1
  --------------
+
  ------------------------------------------------------------------------------------------------
  .text:00432191                xor    edx, edx        
+
<MISSION TYPE 3 - infiltration
.text:00432193                push    esi
+
 +
  .text:00432191                xor    edx, edx                   ;edx & dx = 0           
 
  .text:00432194                cmp    bx, dx       
 
  .text:00432194                cmp    bx, dx       
  .text:00432197                jnz    loc_432230                ;if zonenum!=0 goto loc_432230
+
  .text:00432197                jnz    loc_432230                ;if zonenum!=0 goto 432230*
 +
-------------------------------
 +
<ZONE 0 - North America>
 
  .text:0043219D                cmp    wDIP_USA_b2_4728FA, dx
 
  .text:0043219D                cmp    wDIP_USA_b2_4728FA, dx
  .text:004321A4                jz      short loc_4321EA          ;if DIP.USA.b2=0 goto loc_4321EA
+
  .text:004321A4                jz      short loc_4321EA          ;if DIP.USA.b2 = 0 goto 4321EA
 
  --------------
 
  --------------
  .text:004321A6                mov    wDIP_USA_b1E_472916, 1    ;set DIP.USA.byte 1E=1
+
<USA>
  .text:004321AF                mov    word ptr [eax+18h], dx     ;resets UFO counter to 0
+
  .text:004321A6                mov    wDIP_USA_b1E_472916, 1
.text:004321B3                movsx  eax, wCurrentMonth_49B1B8
+
  .text:004321AF                mov    [eax+18h], dx
.text:004321BA                mov    ecx, eax
 
.text:004321BC                shl    ecx, 5
 
.text:004321BF                sub    ecx, eax
 
.text:004321C1                mov    eax, 96h
 
.text:004321C6                shl    ecx, 2
 
.text:004321C9                mov    esi, dword_49B280[ecx]
 
.text:004321CF                add    esi, eax
 
.text:004321D1                mov    dword_49B280[ecx], esi
 
.text:004321D7                mov    esi, dword_49B240[ecx]
 
.text:004321DD                add    esi, eax
 
.text:004321DF                mov    dword_49B240[ecx], esi
 
 
  .text:004321E5                jmp    loc_432695
 
  .text:004321E5                jmp    loc_432695
  -----------------------------------------------------------------
+
  --------------
 +
<CANADA>
 
  .text:004321EA                mov    wDIP_CAN_b1E_472B32, 1      ;set DIP.CAN.byte 1E=1
 
  .text:004321EA                mov    wDIP_CAN_b1E_472B32, 1      ;set DIP.CAN.byte 1E=1
 
  .text:004321F3                mov    word ptr [eax+18h], 0FFFFh  ;disables infiltration in MISSION.DAT
 
  .text:004321F3                mov    word ptr [eax+18h], 0FFFFh  ;disables infiltration in MISSION.DAT
  .text:004321F9                 movsx  eax, wCurrentMonth_49B1B8
+
  .text:0043222B                 jmp    loc_432695
  .text:00432200                 mov     ecx, eax
+
----------------------------------
  .text:00432202                 shl     ecx, 5
+
  .text:00432205                 sub     ecx, eax
+
  .text:00432230                 cmp     bx, 3                ;if zonenum!=3 goto 43227F
  .text:00432207                 mov     eax, 96h
+
  .text:00432234                 jnz     short loc_43227F
  .text:0043220C                 shl     ecx, 2
+
  .text:0043220F                 mov    esi, dword_49B280[ecx]
+
----------------------------------
  .text:00432215                 add     esi, eax
+
  .text:00432217                 mov    dword_49B280[ecx], esi
+
  .text:0043227F                 cmp     bx, 4                ;if zonenum != 4 goto 432412
  .text:0043221D                 mov     esi, dword_49B27C[ecx]
+
  .text:00432283                 jnz     loc_432412
  .text:00432223                 add    esi, eax
+
  .text:00432225                 mov     dword_49B27C[ecx], esi
+
--------------
  .text:0043222B                 jmp    loc_432695
+
<ZONE 4 - EUROPE>
 +
  .text:00432289                 cmp     wDIP.UK.b2_472942, dx
 +
  .text:00432290                 jz      short loc_4322D9
 +
 +
  .text:004322D9                 cmp     wDIP.FRA.b2_472966, dx
 +
  .text:004322E0                 jz      short loc_432329
 +
 +
  .text:00432329                 cmp     wDIP.GER.b2_47298A, dx
 +
  .text:00432330                 jz      short loc_432379
 +
 +
  .text:00432329                 cmp     wDIP.ITA.b2_47298A, dx
 +
  .text:00432330                 jz      short loc_432379
 
   
 
   
 +
-----------------------------------------------------------
 
  -----------------------------------------------------------
 
  -----------------------------------------------------------
 
  .text:00432695                mov    eax, dwpMISSIONSDAT_49B220
 
  .text:00432695                mov    eax, dwpMISSIONSDAT_49B220
Line 73: Line 77:
 
  -------------
 
  -------------
 
  .text:004326A1                mov    si, word_470F36        ;time for first infiltration counter
 
  .text:004326A1                mov    si, word_470F36        ;time for first infiltration counter
.text:004326A8                and    esi, 0FFFFh
+
  .text:004326AD                movsx  ecx, si
  .text:004326AD                mov    ecx, esi
 
 
  .text:004326B1                push    ecx
 
  .text:004326B1                push    ecx
 
  .text:004326B2                call    sGetRandomNum_43D850
 
  .text:004326B2                call    sGetRandomNum_43D850
  .text:004326B7                mov    cx, ax
+
  <more calculation>
.text:004326BA                add    esp, 4
 
.text:004326BD                movsx  eax, si
 
.text:004326C0                cdq
 
.text:004326C1                sub    eax, edx
 
.text:004326C3                mov    edx, dwpMISSIONSDAT_49B220
 
.text:004326C9                sar    eax, 1
 
.text:004326CB                add    ecx, eax
 
 
  .text:004326CD                mov    [edx+edi*8+1Ch], cx    :byte 1C = rand(time)+(time/2)
 
  .text:004326CD                mov    [edx+edi*8+1Ch], cx    :byte 1C = rand(time)+(time/2)
 
  -------------
 
  -------------
Line 90: Line 86:
 
  .text:004326D3                push    ebx
 
  .text:004326D3                push    ebx
 
  .text:004326D4                call    sCreateAlienBase_432700
 
  .text:004326D4                call    sCreateAlienBase_432700
.text:004326D9                add    esp, 8
 
.text:004326DC                pop    esi
 
.text:004326DD                pop    edi
 
.text:004326DE                pop    ebp
 
.text:004326DF                pop    ebx
 
 
  .text:004326E0                retn
 
  .text:004326E0                retn
 +
 +
This routine is called when infiltration or Alien Base missions are complete. The first section checks to see what the mission is.  If the mission is not infiltration, the routine skips to the code to spawn a base and exits.  For infiltration, the next check is what zone the mission is in. 
 +
:If the zone is 0, it checks byte 4728FA (which is byte 2 of the USA entry in the DIPLOMAT.DAT array).
 +
:If this is not 0, it sets byte 1E (to indicate that the USA will sign a pact at the end of the month), gives points to the aliens in North America and USA, and resets the UFO Counter entry in MISSION.DAT to 0.
 +
:If the USA byte 2 is 0, CANADA is set to leave at the end of the month and scores for the aliens are given but the entry in MISSION.DAT is set to 0xFFFF to disable the mission. (no countries left in America to infiltrate.)
 +
Once either of these has been done, the routine jumps to the end where it checks the UFO counter in MISSIONS.DAT for the current zone.  If it is 0, it randomly determines a time and sets the timer.  Then the routine calls the "spawn alien base" routine and exits.

Revision as of 01:31, 6 December 2014

I'm also known as "Tycho" on StrategyCore forums. I've been studying disassembly and C++ coding since December of 2011. This all started because I wanted to mod the tank/cannon of '94 Enemy Unknown into a tank/chaingun for my own games. I started playing the DOS version but eventually switched to the CE version. At first, I focused on the sound problems which is when I started to experiment with Seb76's UFOloader.

UFO Extender

This is the original program created by Seb76 for use with Enemy Unknown. Check out the UFO Extender's Information Page. You can download the latest version and patches here: UFOextender.

If you're interested in the source code, it is available. Be warned you'll need to decompile the executable and be familiar with disassembly terminology to understand a lot of what the Extender does, since it inserts new lines into preexisting code. The source files for the Extender are here: File:UFOExtender-src.zip.

TFTD Extender

It adds a lot of functionality and fixes to the Collector's Edition (MS Windows version) of Terror from the Deep. Click on the title to get to the information page.

For those interested, here is the source code for the Extender.

Other information

.text:00432160                 mov     cx, [esp+missiontype]
.text:00432165                 push    ebx
.text:00432166                 mov     ebx, [esp+4+zonenum]
.text:0043216A                 push    
.text:0043216B                 movsx   
.text:0043216E                 push    
.text:0043216F                 lea     
.text:00432176                 movsx   
.text:00432179                 sub     
.text:0043217B                 mov     eax, dwpMISSIONSDAT_49B220
.text:00432180                 add     
.text:00432182                 cmp     cx, 3
.text:00432186                 mov       
.text:0043218B                 jnz     loc_4326E1        ;if missiontype is not 3 goto 4326E1
------------------------------------------------------------------------------------------------
<MISSION TYPE 3 - infiltration 

.text:00432191                 xor     edx, edx                   ;edx & dx = 0             
.text:00432194                 cmp     bx, dx       
.text:00432197                 jnz     loc_432230                 ;if zonenum!=0 goto 432230*
-------------------------------
<ZONE 0 - North America>
.text:0043219D                 cmp     wDIP_USA_b2_4728FA, dx
.text:004321A4                 jz      short loc_4321EA           ;if DIP.USA.b2 = 0 goto 4321EA
--------------
<USA>
.text:004321A6                 mov     wDIP_USA_b1E_472916, 1
.text:004321AF                 mov     [eax+18h], dx
.text:004321E5                 jmp     loc_432695
--------------
<CANADA>
.text:004321EA                 mov     wDIP_CAN_b1E_472B32, 1       ;set DIP.CAN.byte 1E=1
.text:004321F3                 mov     word ptr [eax+18h], 0FFFFh   ;disables infiltration in MISSION.DAT
.text:0043222B                 jmp     loc_432695
----------------------------------

.text:00432230                 cmp     bx, 3                 ;if zonenum!=3 goto 43227F
.text:00432234                 jnz     short loc_43227F 

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

.text:0043227F                 cmp     bx, 4                ;if zonenum != 4 goto 432412
.text:00432283                 jnz     loc_432412

--------------
<ZONE 4 - EUROPE>
.text:00432289                 cmp     wDIP.UK.b2_472942, dx
.text:00432290                 jz      short loc_4322D9 

.text:004322D9                 cmp     wDIP.FRA.b2_472966, dx
.text:004322E0                 jz      short loc_432329 

.text:00432329                 cmp     wDIP.GER.b2_47298A, dx
.text:00432330                 jz      short loc_432379

.text:00432329                 cmp     wDIP.ITA.b2_47298A, dx
.text:00432330                 jz      short loc_432379

-----------------------------------------------------------
-----------------------------------------------------------
.text:00432695                 mov     eax, dwpMISSIONSDAT_49B220
.text:0043269A                 cmp     [eax+edi*8+18h], dx
.text:0043269F                 jnz     short loc_4326D2        ;if UFO counter !=0 goto loc_4326D2
-------------
.text:004326A1                 mov     si, word_470F36        ;time for first infiltration counter
.text:004326AD                 movsx   ecx, si
.text:004326B1                 push    ecx
.text:004326B2                 call    sGetRandomNum_43D850
<more calculation>
.text:004326CD                 mov     [edx+edi*8+1Ch], cx    :byte 1C = rand(time)+(time/2)
-------------
.text:004326D2                 push    ebp
.text:004326D3                 push    ebx
.text:004326D4                 call    sCreateAlienBase_432700
.text:004326E0                 retn

This routine is called when infiltration or Alien Base missions are complete. The first section checks to see what the mission is. If the mission is not infiltration, the routine skips to the code to spawn a base and exits. For infiltration, the next check is what zone the mission is in.

If the zone is 0, it checks byte 4728FA (which is byte 2 of the USA entry in the DIPLOMAT.DAT array).
If this is not 0, it sets byte 1E (to indicate that the USA will sign a pact at the end of the month), gives points to the aliens in North America and USA, and resets the UFO Counter entry in MISSION.DAT to 0.
If the USA byte 2 is 0, CANADA is set to leave at the end of the month and scores for the aliens are given but the entry in MISSION.DAT is set to 0xFFFF to disable the mission. (no countries left in America to infiltrate.)

Once either of these has been done, the routine jumps to the end where it checks the UFO counter in MISSIONS.DAT for the current zone. If it is 0, it randomly determines a time and sets the timer. Then the routine calls the "spawn alien base" routine and exits.