Unofficial Simfarm File Format Documentaion     06/27/2001 Jeff Connelly
Last updated 09/08/2001

This file describes what is known about the saved-game format used with
Maxis SimFarm for Windows. All the information here was obtained through
experimentation and not from Maxis.

32-Byte Records
===============
.SFM files are of fixed length (139,072 bytes), which means they're not
compressed in any way. It seems as if most of the file is divided into
32-byte records, record #0 being from 0*32=0 to byte 2*32-1=31, record #1 from
byte 1*32=32 to 2*32-2=63, and so on. However, some areas of the file do not
have 32 byte records, this will be noted in the descriptions below.

Individual offsets in records are labelled 0x00-0x1F - relative
to the beginning of the record, in hex. If you have an offset with a record
number and want to convert it to an absolute position in the file, use 
REC_LEN*RECORD_NO+OFFSET. Likewise, if you have an absolute position
and want to convert it to a record number and offset, use the formula
RECORD_NO=integer(POSITION/RECLEN), and OFFSET=POSITION mod RECLEN.

For example, if you determine that 216E4 is where your funds are stored as
a dword, then RECORD_NO=0x216E4/0x20=0x1B7. OFFSET=0x216E4 mod 0x20=4. MS-DOS
Edit can edit these files nicely if used with the /32 switch (to get rec number
from line number, subtract one; to get offset from column, subtract one)

What follows is what I know about all the fields in the SFM file format.
All numbers are in hexadecimal. First field is offset, second is description.

Livestock limit         = 255 =  FF
Food & water limit      = 511 = 1FF

32-Byte Record 0 (0x00-0x20) - Header
-------------------------------------
Offsets     Description
00          SIGNATURE=0x18. Used to verify that the file is a Simfarm game.
01          cow: 00->22. No effect noticed when changed manually on plain.sfm.
            cow: 00->01.
01-1F       usually 00's. No effect noticed when all changed to 7F.

32-Byte Records 1-FF (0x21-1FE0) - Livestock
--------------------------------------------
Maximum livestock: 0xFF=255. This has been verified; you cannot place more
than 255 animals on any one farm.

00-02       ???. Usually zeros. Nothing noticed when changed to 7F.
03          X coordinate(*)
04          Y coordinate(*)
            * There is more to location than these bytes. If you only
              change these, your livestock's image will stay in one place
              but the livestock's ghost will move around, sometimes
              invisibily, other times not. The info tool will tell you the
              frozen animal image is an animal, but will not give a price
              nor the picture. However the info tool will display correct
              results where the animal really is.
05          image, offspring bit
            H G F E - D C B A
                \            \ 
                 \            0=without offspring
                  \           1=with offspring
                   \    
                    \   
                     0=farmer image
                     1=cows image
            00-1F farmer
            02 dead?
            20 normal
            21 with offspring
            22 normal
            23 with offspring
            24 normal
            25 with offspring
            26 normal
            etc.
06          ??? usually 00
07          07, 06, unknown
            02 when dead?
08          01, unknown
            02 when dead?
09          animal type
            A0 horse
            A1 cow
            A2 pig
            A3 sheep
            A4 horse image in Info, sheep description
            A5 corn  -- WARNING: May crash program when unpaused
            A6 wheat -- (see above also) may be unsellable

            Note: When changing the animal type via this byte, there appears
            to be no problems. The icon initially is that of the previous
            animal but changes to the appropriate icon when unpaused. The info
            tool also works correctly.
0A          ??? Affects animal description, icon, behavior, etc.
            Normally 00. Pointer into an animal info structure somewhere?
            Once was 0E.
0B          Grade - animal value multiplication
            FF-C0 A - High (Bad*8) (High/1)
            BF-80 B - Fair (Bad*4) (High/2)
            7F-40 C - Poor (Bad*2) (High/4)
            3F-00 X - Bad  (Bad*1) (High/8)
0C          ??? Seems to not affect livestock, normally 00
0D-0E       Age, higher increases value but livestock have finite lifespans.
            Initially zero and increases as time goes on.
            For BAD : PREMIUM = age*1          
            For POOR: PREMIUM = age*1
            For FAIR: PREMIUM = age*1.25
            For HIGH: PREMIUM = age*1.25
            Age increases as animal grows more valuable. Signed. May be
            inconsistant between Zoom tool and Sell window.

            Base prices: (in BAD condition, HIGH is base*8)
            ------------
            Sheep   $22.5
            Pig     $47.5
            Cow     $60
            Horse   $110

            Actual price = (BASE + PREMIUM) * GRADE      ??? - incorrect

            Age 5 when animal is dead?

0E          ??? usually 00
0F          ??? usually 01, even when dead
10-11       08 or 90 when animal dies 
11          24 ($) after animal dies
12-1C       ???
1D          28, unknown (cow)
            30 (horse)
1E-1F       ???

32-Byte Record 14F (0x29E1-0x2A00)
----------------------------------
11          tractor: 00->01

32-Byte Record 151 (0x2A21-0x2A40)
----------------------------------
0D          tractor: 00->A0

32-Byte Record 152 (0x2A41-0x2A60)
----------------------------------
09          tractor: 33->44
0A          tractor: 00->19
1C          tractor: 00->01

32-Byte Record 153 (0x2A61-0x2A80)
----------------------------------
00          tractor: 00->01
01          tractor: 00->01

Food/Water? - 12-Byte records AE2-CE0 (0xC3E6-0xE7C0)
-----------------------------
Maximum food+water units: 1FF=511. No more than 511 food and water units
can be placed on a single farm.

Does not apppear to be usual 32-byte records, rather 36-byte, or actually
12-byte. Info below is for 12-byte records.

00          location? small integers, sometimes 00.
01          0x20
02          null. Nothing noticed when changing.
03          type?
            0x2B - water trough
            0x2C - food
04          0x01. No noticable effect when changing.
05          null
06          type?
            0x01 - water trough
            0x02 - food
07-0A       nulls
0B          location? small integers, sometimes 00.




32-Byte Records A96-C68 (0x152C1-0x18D01)
-----------------------------------------
04          food:    1B->17
05          tractor: 00->08
            food:    00->08
            cow:     00->08
06          tractor: 00->50
            cow:     00->C2
            food:    00->FC
07          tractor: 00->0B
            cow:     00->0B
            food:    08->0B

32-Byte Record 104C (0x20981-0x209A0)
-------------------------------------
18          was 00 before bought tractor, 01 after

32-Byte Record 1066 (0x20CC1-0x20CE0)
-------------------------------------
14          cow:     00->01

32-Byte Record 10B3 (0x21661-0x21680)
-------------------------------------
1C          tractor: 00->90
1D          tractor: 00->01

32-Byte Record 10B4 (0x21681-0x216A0)
-------------------------------------
08          cow:     00->E0
09          cow:     00->01

32-Byte Record 10B5 (0x216A1-0x216C1)
-------------------------------------
08          tractor: 00->90
09          tractor: 00->01
18-19       Livestock Expeditures

32-Byte Record 10B7 (0x216E1-0x21700)
-------------------------------------
04-08       Funds, unsigned.
0D          food:    03->04
17-18       tractor: D018->6D19, D018->0F1A
            cow    : 153F->7043
            food   : 153F->9060
            Some sort of checksum?
19-1A       tractor: D018->6D19, D018->0F1A
            cow    : 153F->7043
            food   : 153F->9060
            Some sort of checksum?
