Launch sprite change Six interceptors mod - XCOM:EU 2012

From Nexus Mods Wiki
Revision as of 16:34, 25 June 2013 by Bertilsson (talk | contribs) (Hex Change)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

This contains the details about the changes to the "Launch Ship" sprite made in order to expand the number of allowed interceptors from 4 to 6.

Six_interceptors_mod_-_XCOM:EU_2012

Details

The launch window sprite consists of a number of smaller sprites, which are NOT dynamically adjusted.

The screenshot below shows the UI with the mod installed. The six launch sprites can be seen on the right-hand side of the screen.

'Screenshot of Launch Window with Six Interceptors'

The complete "multi-ship" sprite is assembled from smaller sprites, using the command:

<DefineSprite id='226'> (old size -- 0x60 = 96 bytes) (new size -- 0x8C = 140 bytes)
  <PlaceObject2 idref='225' name='ship0' depth='66' matrix='t7041,-1140'/>
  <PlaceObject2 idref='225' name='ship1' depth='53' matrix='t7041,1135'/>
  <PlaceObject2 idref='225' name='ship2' depth='40' matrix='t7041,3410'/>
  <PlaceObject2 idref='225' name='ship3' depth='27' matrix='t7041,5685'/>
  <PlaceObject2 idref='225' name='ship4' depth='14' matrix='t7041,7960'/>
  <PlaceObject2 idref='225' name='ship5' depth='1' matrix='t7041,10235'/>
<ShowFrame/>

Note that I did not have a decompiler that enabled me to automatically decompile this code. The format of the decompiled code above is based upon some decompiled code sent to me by johnnylump, but the decompiling was done by hand.

The original sprite definition had only four PlaceObject2 commands, the matrix translation offset were different, and the depth ordering was reversed. Depth ordered was reversed to minimize the effect of the "sprite enlargement overlap". When the sprite enlarges upon mouse-over, the "LAUNCH" text appears in front of the sprite below.

Freeing space to add new hex

In order to free enough bytes to add the additional sprite calls, other bytes had to be removed. These bytes were removed from two earlier, identical sections (containing essentially unrelated actionscript)

changed:
     <p align="left"><font face="$TitleFont" size="20" color="#ffd138" letterSpacing="0.000000" kerning="0">CLICK TO LAUNCH FIGHTER</font></p>. 
to:
     <p align="left"><font face="$TitleFont" size="20" color="#ffd138" letterSpacing="0.0" kerning="0">LAUNCH</font></p>.

Each change saved 22 bytes, for a total recovery of 44 bytes. (5 bytes from changing "0.000000" to "0.0" and 17 bytes from changing 'CLICK TO LAUNCH FIGHTER' to 'LAUNCH')

Reducing the size of the html string required changing the defined size of the tag that included each string (reducing it by 22 = 0x16 bytes)

The preceding tag definition began with 7F 09 for both of these. This was followed by the byte-size of the tag, A8 00 00 00 in both cases. This was reduced to 92 00 00 00 in both cases.

Other tag definition in between these alterations and the sprite definition were left unchanged.

Changing the sprite

Each PlaceObject2 reference in our DefineSprite tag consists of 22 bytes.

Breakdown of the hex code for PlaceObject2

(see [1] for more details)

  <PlaceObject2 idref='225' name='ship0' depth='66' matrix='t7041,-1140'/>
		BF 06 10 00 00 00 26 42 00 E1 00 1C DC 0F 71 80 73 68 69 70 30 00 

  • BF 06
    bit-packed tag code and 'size' (in practice the AS compiler uses 0x3F in the size field for most tags)
    • Actionscript sprite commands are bit-packed. The command consists of 10 bits, followed by the size consisting of 6 bits.
      • BF 06 --> 0x6BF = 0000 0110 1011 1111 --> 0000011010 111111 --> 0x1A 0x3F
        • Hex code 1A corresponds to the PlaceObject2 command
        • Since the size is 0x3F, that indicates that the actual size will follow the tag code in a 4-byte integer
  • 10 00 00 00
    Size of tag in bytes
    • Size is counted in number of bytes AFTER the tag and size integer
      Defined size is 0x10 = 16 bytes + 2 bytes for tag code + 4 bytes for size = 22 bytes
  • 26
    bit-packed flags defining what fields are present in this PlaceObject2 tag
    • 0x26 = 0010 0110
      • These flags indicate that the tag has a name, a matrix, and a character
  • 42 00
    the depth of the placed object
    • 42 00 --> 0x0042 = 66
  • E1 00
    The character (IDref) of the placed object
    • E1 00 --> 0x00E1 = 225
  • 1C DC 0F 71 80
    the transform matrix for the placed object
    • Transform matrices are bit-packed (see [2] for more information)
    • 1C = 0001 1100, which indicates that the matrix does not define scale or rotate, and that the translate values are defined with 14 bits
      the final 0 bit in 1C is the leading bit of the first matrix translate value
    • 1C DC 0F 71 80 --> 00011100 11011100 00001111 01110001 10000000 --> 0001110 01101110000001 11101110001100 00000 --> XX 0x1B81 0x3B8C 0
      • 0x1B81 = 7041 -- this is measured in 'twips'
      • 0x3B8C = -1041 -- because the leading bit is 1, this is a negative number (represented in 2's complement)
      • the final 5 bits are unused filler, required because the next field must be byte-aligned
  • 73 68 69 70 30 00
    ASCII for 'ship0' with null termination character

All six PlaceObject2 commands were assembled using this method.

The DefineSprite command had hex code:

<DefineSprite id='226'> (old size -- 0x60 = 96 bytes) (new size -- 0x8C = 140 bytes)
    FF 09 8C 00 00 00 E2 00 01 00 

  • FF 09
    the DefineSprite tag code
    • FF 09 --> 0x9FF --> 00001001 11111111 --> 0000100111 111111 --> 0x27 0x3F
      • Hex code 0x27 corresponds to the DefineSprite command
      • size 0x3F indicates that the actual size will follow in a four byte integer
  • 8C 00 00 00
    size of DefineSprite command
    • original size was 60 00 00 00

Hex Change

Command1.upk
original:
(Offset !45254606)
FF 14 29 00 00 00 DA 00 75 62 FE 8A 14 42 51 D8 75 64 9E 83 94 5C 51 70 01 00 01 14 00 A0 02 00 03 FF D1 38 FF 01 25 D5 92 14 5D F0 47 8C 00 7F 09 A8 00 00 00 DB 00 77 FB 0C C2 FF B0 23 F0 ED 33 1F 00 90 01 FF D1 38 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 54 69 74 6C 65 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 66 66 64 31 33 38 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 30 30 30 30 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 43 4C 49 43 4B 20 54 4F 20 4C 41 55 4E 43 48 20 46 49 47 48 54 45 52 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 DB 00 48 00 00 00 00 00 00 00 00 00 FF 14 27 00 00 00 DC 00 75 62 5E 87 0B 94 2E 60 75 62 7E 86 8B 96 2E 58 01 00 01 02 00 00 00 80 80 80 FF 01 25 D5 89 8B 97 F0 47 E8 00 7F 09 2E 00 00 00 DD 00 77 FB 0B F0 FF B0 15 50 ED 31 1F 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 49 4E 54 45 52 43 45 50 54 4F 52 20 30 33 35 00 BF 12 0C 00 00 00 DD 00 48 00 00 00 00 00 00 00 00 00 7F 09 2A 00 00 00 DE 00 77 FB 0B ED 7F B0 12 28 ED 31 4B 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 57 65 61 70 6F 6E 20 4E 61 6D 65 00 BF 12 0C 00 00 00 DE 00 48 00 00 00 00 00 00 00 00 00 7F 09 9D 00 00 00 DF 00 77 FB 0B ED 7F B0 12 28 ED 33 4B 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 4E 6F 72 6D 61 6C 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 38 30 38 30 38 30 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 30 30 30 30 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 53 68 69 70 20 53 74 61 74 75 73 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 DF 00 48 00 00 00 00 00 00 00 00 00 7F 09 A8 00 00 00 E0 00 77 FB 0C C2 FF B0 23 F0 ED 33 1F 00 90 01 FF D1 38 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 54 69 74 6C 65 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 66 66 64 31 33 38 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 30 30 30 30 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 43 4C 49 43 4B 20 54 4F 20 4C 41 55 4E 43 48 20 46 49 47 48 54 45 52 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 E0 00 48 00 00 00 00 00 00 00 00 00 FF 09 E3 02 00 00 E1 00 35 00 FF 0A 07 00 00 00 6E 6F 72 6D 61 6C 00 86 06 06 03 00 C6 00 00 86 06 06 04 00 C7 00 00 BF 06 0F 00 00 00 26 05 00 C8 00 1D 57 D8 67 80 6E 61 6D 65 00 BF 06 11 00 00 00 26 06 00 C9 00 1D 57 B8 C9 00 77 65 61 70 6F 6E 00 BF 06 11 00 00 00 26 07 00 CA 00 1D 57 B9 03 00 73 74 61 74 75 73 00 BF 06 18 00 00 00 26 08 00 CD 00 C5 5A 3E AD 1F 3A 53 10 E6 40 73 68 69 70 49 63 6F 6E 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 FF 0A 09 00 00 00 64 69 73 61 62 6C 65 64 00 85 06 03 04 00 CE 00 BF 06 11 00 00 00 36 05 00 CF 00 1D 57 D8 67 80 0E 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 D0 00 1D 57 B8 C9 00 0E 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 D1 00 1D 57 B9 03 00 0E 00 73 74 61 74 75 73 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 02 07 08 00 FF 0A 09 00 00 00 73 65 6C 65 63 74 65 64 00 85 06 03 03 00 D2 00 85 06 03 04 00 D3 00 BF 06 11 00 00 00 36 05 00 D4 00 1D 57 D8 67 80 1A 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 D5 00 1D 57 B8 C9 00 1A 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 D6 00 1D 57 B9 03 00 1A 00 73 74 61 74 75 73 00 BF 06 1A 00 00 00 36 08 00 D9 00 C5 5A 3E AD 1F 3A 53 10 E6 40 1A 00 73 68 69 70 49 63 6F 6E 00 86 06 06 0A 00 DA 00 00 BF 06 13 00 00 00 36 0B 00 DB 00 1D 68 59 4F C0 1A 00 6C 61 75 6E 63 68 00 BF 06 18 00 00 00 36 0C 00 3C 00 1D 5F 89 6B 80 1A 00 62 74 6E 48 65 6C 70 49 63 6F 6E 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 02 07 0A 00 02 07 0B 00 FF 0A 12 00 00 00 73 65 6C 65 63 74 65 64 5F 64 69 73 61 62 6C 65 64 00 85 06 03 04 00 DC 00 BF 06 11 00 00 00 36 05 00 DD 00 1D 57 D8 67 80 26 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 DE 00 1D 57 B8 C9 00 26 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 DF 00 1D 57 B9 03 00 26 00 73 74 61 74 75 73 00 BF 06 13 00 00 00 36 0A 00 E0 00 1D 68 59 4F C0 26 00 6C 61 75 6E 63 68 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 00 00 FF 09 60 00 00 00 E2 00 01 00 BF 06 10 00 00 00 26 01 00 E1 00 1C DC 0F B8 00 73 68 69 70 30 00 BF 06 10 00 00 00 26 0E 00 E1 00 1C DC 09 12 E0 73 68 69 70 31 00 BF 06 10 00 00 00 26 1B 00 E1 00 1C DC 0A 6D C0 73 68 69 70 32 00 BF 06 10 00 00 00 26 28 00 E1 00 1C DC 0B C8 A0 73 68 69 70 33 00 40 00 00 00
new: FF 14 29 00 00 00 DA 00 75 62 FE 8A 14 42 51 D8 75 64 9E 83 94 5C 51 70 01 00 01 14 00 A0 02 00 03 FF D1 38 FF 01 25 D5 92 14 5D F0 47 8C 00 7F 09 92 00 00 00 DB 00 77 FB 0C C2 FF B0 23 F0 ED 33 1F 00 90 01 FF D1 38 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 54 69 74 6C 65 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 66 66 64 31 33 38 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 4C 41 55 4E 43 48 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 DB 00 48 00 00 00 00 00 00 00 00 00 FF 14 27 00 00 00 DC 00 75 62 5E 87 0B 94 2E 60 75 62 7E 86 8B 96 2E 58 01 00 01 02 00 00 00 80 80 80 FF 01 25 D5 89 8B 97 F0 47 E8 00 7F 09 2E 00 00 00 DD 00 77 FB 0B F0 FF B0 15 50 ED 31 1F 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 49 4E 54 45 52 43 45 50 54 4F 52 20 30 33 35 00 BF 12 0C 00 00 00 DD 00 48 00 00 00 00 00 00 00 00 00 7F 09 2A 00 00 00 DE 00 77 FB 0B ED 7F B0 12 28 ED 31 4B 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 57 65 61 70 6F 6E 20 4E 61 6D 65 00 BF 12 0C 00 00 00 DE 00 48 00 00 00 00 00 00 00 00 00 7F 09 9D 00 00 00 DF 00 77 FB 0B ED 7F B0 12 28 ED 33 4B 00 90 01 80 80 80 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 4E 6F 72 6D 61 6C 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 38 30 38 30 38 30 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 30 30 30 30 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 53 68 69 70 20 53 74 61 74 75 73 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 DF 00 48 00 00 00 00 00 00 00 00 00 7F 09 92 00 00 00 E0 00 77 FB 0C C2 FF B0 23 F0 ED 33 1F 00 90 01 FF D1 38 FF 00 00 00 00 00 00 00 28 00 00 3C 70 20 61 6C 69 67 6E 3D 22 6C 65 66 74 22 3E 3C 66 6F 6E 74 20 66 61 63 65 3D 22 24 54 69 74 6C 65 46 6F 6E 74 22 20 73 69 7A 65 3D 22 32 30 22 20 63 6F 6C 6F 72 3D 22 23 66 66 64 31 33 38 22 20 6C 65 74 74 65 72 53 70 61 63 69 6E 67 3D 22 30 2E 30 22 20 6B 65 72 6E 69 6E 67 3D 22 30 22 3E 4C 41 55 4E 43 48 3C 2F 66 6F 6E 74 3E 3C 2F 70 3E 00 BF 12 0C 00 00 00 E0 00 48 00 00 00 00 00 00 00 00 00 FF 09 E3 02 00 00 E1 00 35 00 FF 0A 07 00 00 00 6E 6F 72 6D 61 6C 00 86 06 06 03 00 C6 00 00 86 06 06 04 00 C7 00 00 BF 06 0F 00 00 00 26 05 00 C8 00 1D 57 D8 67 80 6E 61 6D 65 00 BF 06 11 00 00 00 26 06 00 C9 00 1D 57 B8 C9 00 77 65 61 70 6F 6E 00 BF 06 11 00 00 00 26 07 00 CA 00 1D 57 B9 03 00 73 74 61 74 75 73 00 BF 06 18 00 00 00 26 08 00 CD 00 C5 5A 3E AD 1F 3A 53 10 E6 40 73 68 69 70 49 63 6F 6E 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 FF 0A 09 00 00 00 64 69 73 61 62 6C 65 64 00 85 06 03 04 00 CE 00 BF 06 11 00 00 00 36 05 00 CF 00 1D 57 D8 67 80 0E 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 D0 00 1D 57 B8 C9 00 0E 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 D1 00 1D 57 B9 03 00 0E 00 73 74 61 74 75 73 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 02 07 08 00 FF 0A 09 00 00 00 73 65 6C 65 63 74 65 64 00 85 06 03 03 00 D2 00 85 06 03 04 00 D3 00 BF 06 11 00 00 00 36 05 00 D4 00 1D 57 D8 67 80 1A 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 D5 00 1D 57 B8 C9 00 1A 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 D6 00 1D 57 B9 03 00 1A 00 73 74 61 74 75 73 00 BF 06 1A 00 00 00 36 08 00 D9 00 C5 5A 3E AD 1F 3A 53 10 E6 40 1A 00 73 68 69 70 49 63 6F 6E 00 86 06 06 0A 00 DA 00 00 BF 06 13 00 00 00 36 0B 00 DB 00 1D 68 59 4F C0 1A 00 6C 61 75 6E 63 68 00 BF 06 18 00 00 00 36 0C 00 3C 00 1D 5F 89 6B 80 1A 00 62 74 6E 48 65 6C 70 49 63 6F 6E 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 02 07 05 00 02 07 06 00 02 07 07 00 02 07 0A 00 02 07 0B 00 FF 0A 12 00 00 00 73 65 6C 65 63 74 65 64 5F 64 69 73 61 62 6C 65 64 00 85 06 03 04 00 DC 00 BF 06 11 00 00 00 36 05 00 DD 00 1D 57 D8 67 80 26 00 6E 61 6D 65 00 BF 06 13 00 00 00 36 06 00 DE 00 1D 57 B8 C9 00 26 00 77 65 61 70 6F 6E 00 BF 06 13 00 00 00 36 07 00 DF 00 1D 57 B9 03 00 26 00 73 74 61 74 75 73 00 BF 06 13 00 00 00 36 0A 00 E0 00 1D 68 59 4F C0 26 00 6C 61 75 6E 63 68 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00 00 00 FF 09 8C 00 00 00 E2 00 01 00 BF 06 10 00 00 00 26 42 00 E1 00 1C DC 0F 71 80 73 68 69 70 30 00 BF 06 10 00 00 00 26 35 00 E1 00 1C DC 08 8D E0 73 68 69 70 31 00 BF 06 10 00 00 00 26 28 00 E1 00 1C DC 09 AA 40 73 68 69 70 32 00 BF 06 10 00 00 00 26 1B 00 E1 00 1C DC 0A C6 A0 73 68 69 70 33 00 BF 06 10 00 00 00 26 0E 00 E1 00 1C DC 0B E3 00 73 68 69 70 34 00 BF 06 10 00 00 00 26 01 00 E1 00 1E 6E 05 3F D8 73 68 69 70 35 00 40 00 00 00

Decompiled Code

Not available. Limiting decompilation was performed by hand, as described in the Details section above.

Development Notes

The development notes are quite long, and so are embedded within a separate file.

UI Development Notes

References

Referred to by this article:

That refer to this article: