The following article contains code and data addresses, both of which will only be correct for the uncompressed civ.exe version 1, as described here.

**The Special Resources Pattern**

As many players will have noticed, the special resources patterns on different maps look similar and often are the same. The pattern is determined by a special number, the so-called

**resource seed**. Depending on the seed, there are 16 different possible patterns.

The resource seed of a running game can be found inside the RAM at position 0x40FB0.

But there's more ingredients. Each square has a horizontal index, the

**x coordinate**, and a vertical index, the

**y coordinate**. Both are used to determine if a square will contain a special resource or not.

And finally, there's a complex formula which reads the seed and the coordinates and tells the game whether a given square is a special resource square or not. Since it's not easy to rewrite the whole formula, I'll propose a relatively easy way to do limited changes by changing two constants inside the formula. This only requires a hex editor.

The first constant is 13 by default (0x0D in hex code) and can be found at position 0x1F016. The second constant, 11 by default (0x0B) is found at position 0x1F024. Changing the constants will change the look of the special resources pattern. The change may be more or less distinct, depending on which values you choose.

Of course, you can also go ahead and rewrite the whole formula, but be aware that some basic knowledge of the x86 assembler language is required.

Here's the relevant code chunk:

Code:

```
seg012:1828 push bp
seg012:1829 mov bp, sp
seg012:182B sub sp, 2
seg012:182E cmp [bp+arg_4], 1 // check if y coordinate is smaller than 2
seg012:1832 jle short loc_2C88A
seg012:1834 cmp [bp+arg_4], 30h // check if y coordinate is greater than 47
seg012:1838 jl short loc_2C88E
seg012:183A sub ax, ax
seg012:183C jmp short loc_2C8D2
seg012:183E mov ax, [bp+arg_2] // load x coordinate
seg012:1841 sar ax, 1 // divide by 2
seg012:1843 sar ax, 1 // divide by 2
seg012:1845 mov cx, 0Dh
seg012:1848 imul cx // multiply by 13
seg012:184A mov cx, ax
seg012:184C mov ax, [bp+arg_4] // load y coordinate
seg012:184F sar ax, 1 // divide by 2
seg012:1851 sar ax, 1 // divide by 2
seg012:1853 mov bx, 0Bh
seg012:1856 imul bx // multiply by 11
seg012:1858 add cx, ax // add both results
seg012:185A add cx, word_40FB0 // add resource seed
seg012:185E mov [bp+var_2], cx // save result (first value)
seg012:1861 mov ax, [bp+arg_2] // load x coordinate
seg012:1864 and ax, 3 // reduce it modulo 4
seg012:1867 shl ax, 1 // multiply by 2
seg012:1869 shl ax, 1 // multiply by 2
seg012:186B mov cx, [bp+arg_4] // load y coordinate
seg012:186E and cx, 3 // reduce it modulo 4
seg012:1871 add ax, cx // add both results (second value)
seg012:1873 mov cl, byte ptr [bp+var_2] // load first value
seg012:1876 sub ch, ch
seg012:1878 and cx, 0Fh // reduce it modulo 16
seg012:187B cmp ax, cx // compare the result to the second value
seg012:187D jnz short loc_2C88A // if both are the same, the square is a special resource square
seg012:187F mov ax, 1
seg012:1882 mov sp, bp
seg012:1884 pop bp
seg012:1885 retf
```

**The Huts Pattern**

The huts pattern is very similar to the special resources pattern.

Again, there are two constants which allow for limited changes (it's even the same constants), the first one (13=0x0D by default) at position 0x1F08B, and the second one (11=0x0B by default) at position 0x1F099.

Also, the same resource seed is used.

And finally, here's the relevant code chunk for hut locations:

Code:

```
seg012:1886 push bp
seg012:1887 mov bp, sp
seg012:1889 sub sp, 2
seg012:188C push si
seg012:188D cmp [bp+arg_0], 0Ah
seg012:1891 jz short loc_2C8FF
seg012:1893 mov ax, 32h
seg012:1896 imul [bp+arg_2]
seg012:1899 mov si, ax
seg012:189B mov bx, [bp+arg_4] // load y coordinate
seg012:189E test byte ptr [bx+si+7FF8h], 1
seg012:18A3 jnz short loc_2C8FF
seg012:18A5 cmp bx, 1 // check if it's smaller than 2
seg012:18A8 jle short loc_2C8FF
seg012:18AA cmp bx, 30h // check if it's greater than 47
seg012:18AD jl short loc_2C903
seg012:18AF sub ax, ax
seg012:18B1 jmp short loc_2C95B
seg012:18B3 mov ax, [bp+arg_2] // load x coordinate
seg012:18B6 sar ax, 1 // divide by 2
seg012:18B8 sar ax, 1 // divide by 2
seg012:18BA mov cx, 0Dh
seg012:18BD imul cx // multiply by 13
seg012:18BF mov cx, ax
seg012:18C1 mov ax, [bp+arg_4] // load y coordinate
seg012:18C4 sar ax, 1 // divide by 2
seg012:18C6 sar ax, 1 // divide by 2
seg012:18C8 mov bx, 0Bh
seg012:18CB imul bx // multiply by 11
seg012:18CD add cx, ax // add both results
seg012:18CF add cx, word_40FB0 // add resource seed
seg012:18D3 add cx, 8 // add 8
seg012:18D6 mov [bp+var_2], cx // save result
seg012:18D9 mov ax, [bp+arg_2] // load x coordinate
seg012:18DC and ax, 3 // reduce it modulo 4
seg012:18DF shl ax, 1 // multiply by 2
seg012:18E1 shl ax, 1 // multiply by 2
seg012:18E3 mov cx, [bp+arg_4] // load y coordinate
seg012:18E6 and cx, 3 // reduce it modulo 4
seg012:18E9 add ax, cx // add both results
seg012:18EB mov cl, byte ptr [bp+var_2] // load first value
seg012:18EE sub ch, ch
seg012:18F0 and cx, 1Fh // reduce it modulo 32
seg012:18F3 cmp ax, cx // compare the result to the second value
seg012:18F5 jnz short loc_2C8FF // if both are the same, a hut is placed on the square
seg012:18F7 push [bp+arg_4]
seg012:18FA push [bp+arg_2]
seg012:18FD push cs
seg012:18FE call near ptr sub_2C5C7
seg012:1901 add sp, 4
seg012:1904 test al, 1
seg012:1906 jnz short loc_2C8FF
seg012:1908 mov ax, 1
seg012:190B pop si
seg012:190C mov sp, bp
seg012:190E pop bp
seg012:190F ret
```

Note that not much has changed in Civilization II, see here:

http://apolyton.net/forums/showthread.php?t=68481