Format of the team file (team.* in \data directory):

Size of the team structure used in files is 684 bytes. Maximum size of team
file is 64000 bytes, as that is the size of the fixed buffer SWOS uses,
anything above that will cause immediate SWOS termination. Inside the team
files teams seem to be sorted alphabetically.

First we have a word, big endian - number of teams in the file
then there is team header, 76 bytes
header is followed by 16 structures that represent players
size is 38 bytes each

team header:
------------
offset:  size:  description:
-------  -----  ------------
   0       1    country number - number of team file (team.nnn), used as an
                index into some kind of translation table, 2nd byte is added to
                the result
                Files 80 to 85 contain national teams by continents:
                80 - Europe
                81 - Africa
                82 - South America
                83 - North America
                84 - Asia
                85 - Australia and Oceania
                (for the rest see map of team.* files near the bottom)
   1       1    team ordinal in the file
   2       2    global team number: formed by converting country number via a
                translation table and adding team ordinal to the result (it has
                to be unique in entire SWOS)
   4       1    team status (who's controlling it):
                  0 - team isn't selected
                  1 - computer
                  2 - player-coach
                  3 - coach
                this field is irrelevant in the file
   5      17    team name, null-terminated
  22       1    I'm guessing null terminator :P
  23       1    AND this with 0xFE
  24       1    tactics:
                  0  - 4-4-2
                  1  - 5-4-1
                  2  - 4-5-1
                  3  - 5-3-2
                  4  - 3-5-2
                  5  - 4-3-3
                  6  - 4-2-4
                  7  - 4-3-3
                  8  - SWEEP
                  9  - 5-2-3
                  10 - ATACK
                  11 - DEFEND
                  12 - USER A
                  13 - USER B
                  14 - USER C
                  15 - USER D
                  16 - USER E
                  17 - USER F
  25       1    league:
                  0 - premier
                  1 - first
                  2 - second
                  3 - third
                  4 - non-league
                primary set:
  26       1    shirt type:
                  0 - plain
                  1 - colored sleeves
                  2 - vertical stripes
                  3 - horizontal stripes
  27       1    shirt color (first color)
                  0 - gray
                  1 - white
                  2 - black
                  3 - orange
                  4 - red
                  5 - blue
                  6 - brown
                  7 - light blue
                  8 - green
                  9 - yellow
  28        1   stripe color (second color)
  29        1   shorts color
  30        1   socks color
                secondary set:
  31        1   shirt type
  32        1   shirt color (first color)
  33        1   stripe color (second color)
  34        1   shorts color
  35        1   socks color
  36       23   coach name, null-terminated
  59        1   some sort of flag (unimportant for file), maybe 0 - left team,
                1 - right team
                edit tactics menu writes here during initialization
  60       16   player indices -- this array tells us where the player is
                inside the team file
                also players are listed before the match according to these
                numbers; they also decide who gets to play (1..11), and who
                goes to bench (12..16); this order is used to assign positions
                (with tactic influencing it of course)

  Size 76 bytes.

Basic team colors conflict table:
       gray white black orange red blue brown l.blue green yellow
gray     x                           x           x     x
white         x
black               x                x    x            x
orange                    x     x                             x
red                       x     x         x
blue     x          x                x           x
brown               x           x         x
l.blue   x                           x           x
green    x          x                                  x
yellow                    x                                   x

Stripes vs shorts conflict table:
       gray white black orange red blue brown l.blue green yellow
gray     x    x                      x           x     x
white    x    x                                  x            x
black               x                x    x            x
orange                    x     x                             x
red                       x     x         x
blue     x          x                x    x      x
brown               x           x    x    x
l.blue   x    x                      x           x
green    x          x                                  x
yellow        x            x                                  x

Player structure:
----
offset:  size:  description:
-------  -----  ------------
   0       1    nationality:

    0  - ALB        51  - CRC        102 - ANG
    1  - AUT        52  - SAL        103 - TOG
    2  - BEL        53  - GUA        104 - ZIM
    3  - BUL        54  - HON        105 - EGY
    4  - CRO        55  - BHM        106 - TAN
    5  - CYP        56  - MEX        107 - NIG
    6  - TCH        57  - PAN        108 - ETH
    7  - DEN        58  - USA        109 - GAB
    8  - ENG        59  - BAH        110 - SIE
    9  - EST        60  - NIC        111 - BEN
    10 - FAR        61  - BER        112 - CON
    11 - FIN        62  - JAM        113 - GUI
    12 - FRA        63  - TRI        114 - SRL
    13 - GER        64  - CAN        115 - MAR
    14 - GRE        65  - BAR        116 - GAM
    15 - HUN        66  - ELS        117 - MLW
    16 - ISL        67  - SVC        118 - JAP
    17 - ISR        68  - ARG        119 - TAI
    18 - ITA        69  - BOL        120 - IND
    19 - LAT        70  - BRA        121 - BAN
    20 - LIT        71  - CHL        122 - BRU
    21 - LUX        72  - COL        123 - IRA
    22 - MLT        73  - ECU        124 - JOR
    23 - HOL        74  - PAR        125 - SRI
    24 - NIR        75  - SUR        126 - SYR
    25 - NOR        76  - URU        127 - KOR
    26 - POL        77  - VEN        128 - IRN
    27 - POR        78  - GUY        129 - VIE
    28 - ROM        79  - PER        130 - MLY
    29 - RUS        80  - ALG        131 - SAU
    30 - SMR        81  - SAF        132 - YEM
    31 - SCO        82  - BOT        133 - KUW
    32 - SLO        83  - BFS        134 - LAO
    33 - SWE        84  - BUR        135 - NKR
    34 - TUR        85  - LES        136 - OMA
    35 - UKR        86  - ZAI        137 - PAK
    36 - WAL        87  - ZAM        138 - PHI
    37 - YUG        88  - GHA        139 - CHN
    38 - BLS        89  - SEN        140 - SGP
    39 - SVK        90  - CIV        141 - MAU
    40 - ESP        91  - TUN        142 - MYA
    41 - ARM        92  - MLI        143 - PAP
    42 - BOS        93  - MDG        144 - TAD
    43 - AZB        94  - CMR        145 - UZB
    44 - GEO        95  - CHD        146 - QAT
    45 - SWI        96  - UGA        147 - UAE
    46 - IRL        97  - LIB        148 - AUS
    47 - MAC        98  - MOZ        149 - NZL
    48 - TRK        99  - KEN        150 - FIJ
    49 - LIE        100 - SUD        151 - SOL
    50 - MOL        101 - SWA        152 - CUS

   1       1    ??? (looks like a boolean)
   2       1    player's shirt number
   3      23    player name (null terminated)
  26       1    bit-packed player position (in the field) and face/hair color
                                 position:
                face:    G    RB   LB   D    RW   LW   M    A
                black   0x10 0x30 0x50 0x70 0x90 0xB0 0xD0 0xF0
                white   0x00 0x20 0x40 0x60 0x80 0xA0 0xC0 0xE0
                ginger  0x08 0x28 0x48 0x68 0x88 0xA8 0xC8 0xE8

                bits 5,6,7 - position, 0 = goalkeeper
                bits 3,4 - face (00 = white, 10 = black, 01 = ginger)
  27       1    ??? bit-field (initialized to zero)
                bits 2,3,4 - cards: bit 2 - yellow card, bit 3 - red card
                     (doesn't matter if direct or after two yellow)
                bits 0,1 - could be cards state if D3 param to PlayGame is true
                           if D3 param is true:
                            bits 0,1 are:
                             zero: cards <- 0
                             non-zero: cards <- 2 (red card)
                           I think it's cards from previous game(s)
                bits 5,6,7 - injuries
                    bit 5 marks very bad injury (player can't play next game)
                value of this field is not read from file, before the game bits
                5,6,7 are set to random values
  28       1    (h.o. nibble) ???
                (l.o.  -||- ) passing (values 0..15)
  29       1    (h.o.  -||- ) shooting
                (l.o.  -||- ) heading
  30       1    (h.o.  -||- ) tackling
                (l.o.  -||- ) ball control
  31       1    (h.o.  -||- ) speed
                (l.o.  -||- ) finishing
  32       1    player price:
                  0  - 25K-      25 - 800K
                  1  - 25K       26 - 850K
                  2  - 30K       27 - 950K
                  3  - 40K       28 - 1M
                  4  - 50K       29 - 1.1M
                  5  - 65K       30 - 1.3M
                  6  - 75K       31 - 1.5M
                  7  - 85K       32 - 1.6M
                  8  - 100K      33 - 1.8M
                  9  - 110K      34 - 1.9M
                  10 - 130K      35 - 2M
                  11 - 150K      36 - 2.25M
                  12 - 160K      37 - 2.75M
                  13 - 180K      38 - 3M
                  14 - 200K      39 - 3.5M
                  15 - 250K      40 - 4.5M
                  16 - 300K      41 - 5M
                  17 - 350K      42 - 6M
                  18 - 450K      43 - 7M
                  19 - 500K      44 - 8M
                  20 - 550K      45 - 9M
                  21 - 600K      46 - 10M
                  22 - 650K      47 - 12M
                  23 - 700K      48 - 15M
                  24 - 750K      49 - 15M+
  33       1      ? (init to zero)
  34       1      ? (init to zero)
  35       1      ? (init to zero)
  36       1      ? (init to zero)
  37       1      some kind of flag, 154 = trial player, 155 = reserve

Size 38 bytes.


===============================================================================
There is another team structure, which is used during the game, and its size is
1704 bytes. We'll refer to it as in-game team.

offset:  size:  desc.
-------  -----  -----
                (converted colors)
                 primary set:
   0       2    shirt type
   2       2    shirt background color
   4       2    shirt stripes color
   6       2    shorts color
   8       2    socks color
                 secondary set:
  10       2    shirt type
  12       2    shirt background color
  14       2    shirt stripes color
  16       2    shorts color
  18       2    socks color
  20       2    marked player index (-1 if nobody was marked)
  22      17    team name, null terminated
  39       1    ?
  40       1    number of own goals
  41       1    ? - these 3 fields are always zero in hil files

Header size - 42 bytes.

  Ofs22 is tested in FixupAndColorPitchFile(), and if lower bit is set,
  team places are swapped

16 player structures follow the header:

offset:  size:  desc.
-------  -----  -----
   0       1    ? - always zero in hil files, but if it's not zero the player
                is skipped (arrow can't select it), probably isInjured flag
   1       1    player index in team file structure
   2       1    number of goals scored
   3       1    shirt number
   4       1    player position index, or -1 he was substituted
   5       1    player face index
   6       1    is player injured? [0,1]
   7       1    ?
   8       1    not sure what it is exactly, but if it's true player will spend
                only 25 frames on tackling instead of 55, although it's reset
                to -1 later in each case (wtf)
   9       1    this influences red card criteria, seems to be more strict if
                it's true
                might be true if player already has a yellow card?
                cards (offset 10) are copied here right before the game
  10       1    yellow/red card bit-flags:
                bit 0 - yellow card
                bit 1 - red card (direct, or via double yellow)
                range seems to be 0..4
  11       1    not sure what it is, but if it's negative the player can not be
                substituted -- that is only in the case bench state is 3, which
                never happens, so this might be unused
  12      14    player number + name (or first letter of name + surname) (string)
  26       1    probably zero terminator for field above
  27       1    passing (values 0..7)
  28       1    shooting
  29       1    heading
  30       1    tackling
  31       1    ball control
  32       1    speed
  33       1    finishing
  34       1    0..7, related to goalkeeper, index into a table of pointers
                which ends up written to TeamGeneralInfo ofs24
  35       1    OR with PlayerFile ofs103 & 0xff1f, bits 7,6 and 5 mean
                something - seems to be red cross blinking speed when a player
                is injured; if this is zero player is not injured; if whole
                field is not zero, and bit 5 isn't set, seems to be permanent
                injury
                5th bit marks serious injury (0x20)
                bits 5, 6 and 7 represent degree of injury, and based on their
                value player speed value gets handicapped via the table:
                0, -96, -128, -160, -192, -224, -256, -288
  36       1    seems to be the number of the half the player was in the game, values can be [0, 1, 2]:
                0 = didn't play or was substituted/not in starting team
                1 = started first or second half
                2 = started second half (or later)
                - these values change by the following algorithm:
                  initialized before the game starts: 0
                  at minute 1 and 46: if (value != 2) value = 1
                  at minute 45 and 90: if (value == 1) value = 2
                - they are only changed if player has less than 2 cards.
                - fresh played entering the game starts from value 0.
                - this interpretation makes sense only for players from the starting 11
  37       1    player face index, used when drawing player icon in stadium menu before the game; it gets
                initialized differently from face field at offset 5, player index is gotten via
                GetPlayerGameBreakPosition() instead of GetPlayerAtIndex()
  38      23    full name of the player, it's actually wrong during the game, since it's initialized the same
                way as previous field (luckily it's never used)

61 is the size of player structure. Players seems to be sorted by numbers
inside the file structure.

686 unknown bytes follow, which are always zero in hil files.

Seems there is some mess in the code regarding the last two fields: when drawing player sprites in the stadium
menu right before the game, players are traversed linearly from topTeamIngame and bottomTeamIngame. Face field
from offset 37 and full name from offset 38 are used. But in the game face field from offset 5 is used, and
players are iterated in a different manner: by GetPlayerAtIndex() which returns players in the order of
tactics team uses. Ingame teams end up initialized with wrong data in fields at offset 37 and 38, but it
doesn't manifest itself as they aren't used during the game.


===============================================================================
Structure containing general informations about teams:

offset:  size:  desc.
-------  -----  -----
   0       4    pointer to opponent team (this same structure)
   4       2    player controls:
                0 - CPU
                1 - player 1 (whatever was selected  in setup)
                2 - player 2              -//-
                this controls whether Player1StatusProc or 2 is called, and
                from there the controls get copied into this structure
   6       2    number of the player coaching this team (0 - nobody is
                coaching, team is directly controled by player or CPU)
   8       2    is any player coach of this team? (255 = yes)
  10       4    pointer to in-game team structure
  14       4    pointer to statistics data
  18       2    team number (1 or 2)
  20       4    pointer to a table of pointers to sprites of team players
                (in-game Sprites), there are exactly 11 of them
  24       4    based on a direction which the goalkeeper is facing (0..7) a
                pointer to some table is written here
                for the player it's always one fixed table
                that table:
                word 6   - sprite speed
                word 8   - also some speed (goalkeeper when diving)
                word 10  - table, 16 words, indices into coordinate table used
                           when deciding if goalkeeper should dive (I think)
                           values up to 8, indexes into another table for the goalkeeper, picks goalkeeper speed per
                           frame to save this shots
                word 48  - gets compared with high 4 bits of stoppageTimer
                           after that the keeper claimed comment is played
                word 52  - strong goalkeeper deflect chance, must be greater than a random number 0..15
                word 54  - medium goalkeeper deflect chance, must be greater than a random number 0..15;
                           first offset 52 is tested, then this, if both fail weak deflect ball speed is used
                word 58  - gets compared to random value based on bits 4-7 of
                           stoppageTimer
  28       2    team tactics
  30       2    holds a player index possibly, gets bumped every frame, starts from 0, ends at 10 (wraps around)
                compared to a number of players left to process, so if it's a player index it indexes from the back
                goalkeepers are exception, they are updated each frame
  32       4    pointer to sprite structure of controlled player
                (ofs12 of that sprite has to be zero)
  36       4    seems to be a pointer to the player that's receiving a pass
  40       2    is our player controlling the ball?
  42       2    something about turn flags (some bit number)
                camera direction gets written here
  44       2    current allowed direction, or -1 if nothing is pressed
                it doesn't change if direction isn't allowed (say opposite
                direction when taking throw-in)
  46       2    current direction, or -1 if nothing is pressed
                changes with each frame
  48       1    rapid fire; very quick firing (-1 = true)
  49       1    short fire flag; short button press, but if consecutive ofs48
                gets set (-1 = true)
                slightly longer press than rapid fire, it's set to -1 for only
                a single frame
  50       1    fire, = -1 as long as it's pressed, 0 when released
  51       1    short fire, set to 1 very shortly (for one frame), when starting firing
                set from pl1ShortFire, joystick fire but only in this cycle
  52       2    ??? (UpdatePlayers sets it) (zero during the game)
                if non-zero, reset pl1ShortFireCounter to zero (for CPU team)
                I think it might be true if player is heading
  54       2    fire counter; increases while fire is held, resets when not;
                no limitations it seems
  56       2    direction of the player controlling the ball:
                        0
                    7   |   1
                      \ | /
                   6 ---+--- 2
                      / | \
                    5   |   3
                        4
                (only updates while the player really controls the ball)
  58       2    gets set when the ball is kicked, and reset only when the fire
                button is depressed
  60       1    ???
                this gets incremented by product of results from ofs56 table
                and results from ofs118 table
  61       1    true if the controlled player is very near the ball (d <= 32u)
  62       1    true if the controlled player is near the ball (32u < d <= 72u)
  63       1    true if the controlled player isn't too far away from the ball
                (72u < d <= 2450u)
  64       1    true if ball z <= 4
  65       1    true if 4 < ball <= 8
  66       1    true if 8 < ball <= 12
  67       1    true if 12 < ball z  <= 17
  68       1    true if ball z > 17
  69       1    copy ofs61 here
  70       2    ??? something when goalkeeper dives
  72       2    ??? 4 bytes pointer to a player
                I'd say pointer to a last player hitting the ball with the head
                player that's tackling is written here (tackle at distance 64 or less from the ball)
  74       2    distance from the ball
  76       2    ??? 5, -5 (timer)
                if positive decrease, if negative increase
                if negative put -1 to ofs118
                has something to do with the goalkeeper saved comment...
  78       2    ???
  80       2    true - goalkeeper diving right
  82       2    true - goalkeeper diving left
  84       2    255 if the ball is out of play (or at the goalkeeper); zero otherwise
  86       2    255 if the ball is out of play (or at the goalkeeper)
                1 if goalkeeper is controlling the ball (with feet)
                0 otherwise
  88       2    1 if a pass has started; remains one until the ball touches
                a team mate (and probably the one to who the pass is for)
  90       2    true only when the precise pass is in progress, ie. when the
                player being passed to is temporarily controlled by the CPU
  92       2    timer, initialized to 25; starts ticking when a player that
                wasn't controlled becomes controlled; when reaches 0 stays that
                way
  94       2    1 while the ball is in play, zero during breaks
  96       2    seems to be 1 when the player controls camera during breaks
                (e.g. taking throw-in)
  98       2    ball x coordinate
 100       2    ball y coordinate
 102       2    counter, initially 25, ticks down once the player gets rid of the ball by kicking, passing,
                tackling or heading (but not otherwise), else zero
                decremented until zero
                AI compares it to 13
 104       4    pointer to some sprite (which one I don't know yet)
                changes during passes and kicks
 108       2    ???
 110       2    true when the ball can be controlled, when it is "at rest";
                false during kicks and passes (sticky)
 112       2    direction of the player controlling the ball; changes only
                while he actually controls it; sticky, initialized to -1
 114       2    ???
 116       2    ???
 118       2    spin timer; activated only when the player releases the ball
                through a kick or pass; while active, spin can be applied to
                the kick/pass (if the player presses left/right); after it
                expires, spin can no longer be applied
                initialized to -1 (= spin not in progress), range 0..9
                if zero, clear both left and right spin (fields 120 and 122)
                (possible start of applying spin)
                used as an index into the table:
                dw 5, 4, 3, 2, 2, 2, 2, 1, 1, 1
                if not 4, increment it; if it reaches 10, set it to -1, where
                it remains
                this timer ensures a short delay after the kick/pass before
                spin can be applied; pressing left/right during that period
                adds spin
 120       2    left spin, boolean, relative to player direction
 122       2    right spin,               - || -
 124       2    long-pass flag: pass, then quickly release fire and press
                left/right/nothing; the pass can travel as far as half the
                pitch (sticky; a normal pass resets it)
                reduce the passing player's speed to 12.5%
                once activated, do not alter player speed further
 126       2    long curved pass: press backward and apply sideways spin; it
                extends a normal pass (not a long pass!)
                also reduce player speed to 12.5%, then leave it unchanged
                the difference from the previous field is unclear
 128       2    passing flag; set whether or not passing into empty space;
                reset behavior is not implemented very well
                if nonzero, subtract one
                after touch is applied as pass/kick based on this
 130       2    AI timer; incremented every frame if the computer controls the
                team; never reset
 132       2    AI timer; initialized to 4; set randomly
 134       2    AI; strength of ball after-touch to apply to the ball after
                kick/pass; possible values are 0, 1, 2 and it will be used as
                an index into a 3-element table which will decide the
                direction; value fetched from the table gets added to the
                current controls direction
 136       2    AI; ball after-touch direction & long kick; decides which table
                will be indexed by the offset 134 value:
                < 0:  -1, -2, -3                    ; left spin
                != 0:  1, 2, 3                      ; right spin
                == 0 && offset 134 != 1: 0, -999, 4 ; normal, standard or
                                                    ; strong kick
 138       2    possibly timer, while active ball can't be won over from the player that controls it
                gets set to 12 when a player in the opposing team tackles the ball
 140       2    true if goalkeeper controls the ball like a regular player;
                from what I have seen, zero during a match
 142       2    if != 0, skip AI; do not update the ball if true
 144       1    joy1SecondaryFire: -1 while the second button is held, 0 while
                released

Size: 145 bytes.


===============================================================================
Structure that contains informations about team statistics:

offset:  size:  desc.
-------  -----  -----
   0       2     possession time (in seconds or some other units)
   2       2     number of corners taken
   4       2     number of fouls
   6       2     number of yellow cards
   8       2     number of red cards
  10       2     shots on goal (total)
  12       2     shots on target

Size: 14 bytes.


===============================================================================
Map of team files:

file:                country:
------------        ----------
team.000             Albania
team.001             Austria
team.002             Belgium
team.003             Bulgaria
team.004             Croatia
team.005             Cyprus
team.006             Czech Republic
team.007             Denmark
team.008             England
team.010             Estonia
team.011             Faroe Icelands
team.012             Finland
team.013             France
team.014             Germany
team.015             Greece
team.016             Hungary
team.017             Iceland
team.018             Republic of Ireland
team.019             Izrael
team.020             Italy
team.021             Latvia
team.022             Lithuania
team.023             Luxembourg
team.024             Malta
team.025             Netherlands
team.026             Northern Ireland
team.027             Norway
team.028             Poland
team.029             Portugal
team.030             Romania
team.031             Russia
team.032             San Marino
team.033             Scotland
team.034             Slovenija
team.035             Spain
team.036             Sweden
team.037             Switzerland
team.038             Turkey
team.039             Ukraine
team.040             Wales
team.041             Yugoslavia
team.042             Algeria
team.043             Argentina
team.044             Australia
team.045             Bolivia
team.046             Brazil
team.047             Costa Rica
team.048             Chile
team.049             Colombia
team.050             Ecuador
team.051             El Salvador
team.055             Japan
team.057             South Korea
team.059             Malaysia
team.060             Mexico
team.062             New Zealand
team.064             Paraguay
team.065             Peru
team.066             Surinam
team.067             Taiwan
team.068             Apparently some Asian cup
team.069             South Africa
team.070             Tanzania
team.071             Uruguay
team.072             customs, presumably
team.073             USA
team.074             World Cup
team.075             India
team.076             Belarus
team.077             Venezuela
team.078             Slovakia
team.079             Ghana
team.080             Europe        - national teams
team.081             Afrika        -     - || -
team.082             South America -     - || -
team.083             North America -     - || -
team.084             Asia          -     - || -
team.085             Oceania       -     - || -
team.172             old teams (including Red Star 90-91)
..\customs.edt       edited custom teams

Internal table used to translate country numbers into strings.
countriesTable:
                  0   - Albania
                  1   - Austria
                  2   - Belgium
                  3   - Bulgaria
                  4   - Croatia
                  5   - Cyprus
                  6   - Czech Republic
                  7   - Denmark
                  8   - England
                  9   - England (second occurrence, but unused)
                  10  - Estonia
                  11  - Faroe Islands
                  12  - Finland
                  13  - France
                  14  - Germany
                  15  - Greece
                  16  - Hungary
                  17  - Iceland
                  18  - Republic of Ireland
                  19  - Izrael
                  20  - Italy
                  21  - Latvia
                  22  - Lithuania
                  23  - Luxembourg
                  24  - Malta
                  25  - Netherlands
                  26  - Northern Ireland
                  27  - Norway
                  28  - Poland
                  29  - Portugal
                  30  - Romania
                  31  - Russia
                  32  - San Marino
                  33  - Scotland
                  34  - Slovenija
                  35  - Spain
                  36  - Sweden
                  37  - Switzerland
                  38  - Turkey
                  39  - Ukraine
                  40  - Wales
                  41  - Yugoslavia
                  42  - Algeria
                  43  - Argentina
                  44  - Australia
                  45  - Bolivia
                  46  - Brazil
                  47  - /
                  48  - Chile
                  49  - Colombia
                  50  - Ecuador
                  51  - El Salvador
                  52  - /
                  53  - /
                  54  - /
                  55  - Japan
                  56  - /
                  57  - /
                  58  - /
                  59  - /
                  60  - Mexico
                  61  - /
                  62  - New Zealand
                  63  - /
                  64  - Paraguay
                  65  - Peru
                  66  - Surinam
                  67  - Taiwan
                  68  - /
                  69  - Juzna Afrika
                  70  - /
                  71  - Uruguay
                  72  - custom
                  73  - USA
                  74  - /
                  75  - India
                  76  - Belarus
                  77  - Venezuela
                  78  - Slovakia
                  79  - Ghana
                  80  - Europe
                  81  - Afrika
                  82  - South America
                  83  - North America
                  84  - Asia
                  85  - Oceania
                  86..99 - /
                  100 - edited customs
                  101..251 - /
                  252 - World Cup qualifiers
                  253 - European Championship
                  254 - world
                  255 - null country

===============================================================================
A sequence of twelve eight-byte structures represents the match list in the
contest menu; these structures are actually two pointers.

What the first pointer points to:

offset:  size:  description
-------  -----  -----------
   0       1    ???
   5       1    ???

What the second pointer points to:

offset:  size:  description
-------  -----  -----------
  11       1    some flags
                if the fifth bit is set and the seventh bit is clear, print
                "1ST LEG %0-%1"
                if both the fifth and eighth bits are clear, print nothing
                otherwise, if the second and third bits are clear and the
                sixth bit is set, print "(REPLAY)", and so on...

  12       2    first team number
  14       2    second team number
  16       2    ???
  18       2    ???
  20       2    ???

===============================================================================
Team organization

There are several tables, but competitionsTable is the central one. It is a
table of pointers to variable structures. The first member is a dword; it may
be a normal pointer, -1, -2, or a number below 256 representing a country
number. The index value (which country it is) is also examined separately and
receives different treatment.

First comes a pointer to the country's league, followed by -2 and pointers to
cups and additional competitions. These are not displayed when selecting the
team to manage in a career. The end is marked by -1.

For a continent (indices 80-85) or wordTable, the end of the table (-1 dword)
is followed by bytes containing the numbers of countries on that continent.
The byte sequence ends with byte -1 (0xff).

Competition format:

offset:  size:  description
-------  -----  -----------
   0       1    competition number
   1       1    competition type: 0 = division, 1 = cup, 2 = league
   2       1    country number, i.e. the .dat file teams are read from; 255 =
                custom
   3       1    competition start month (times 8)
   4       1    competition end month     -||-
   5       1    custom name, if nonzero: this + competition pointer + 5 yields
                a pointer to a dword which, when added to aChairmanScenes
                (offset 0x16f8), yields a pointer to the competition name
   6       3    ???
   9       1    number of leagues


1) 14BDC6 (-1 terminated)
2) 14BE62 (     -||-    ) - continental competitions table
3) 14BE7E (     -||-    )
4) 14BF36 (     -||-    )
5) 14BFD2 probably cups


POOLPLYR.DAT
============

It is comprised of 900 records, sized 58 bytes each. This makes the file size
fixed to 52,200 bytes. Structure of records is:

offset:  size:  description
-------  -----  -----------
   0       2    some id word, maybe team id
   2       1    also used for comparing and locating records
   3      17    team name
  20      38    Player (file) record


GetPlayerPrice
==============

Determines the price of the specified player.

Terminology:
- quadrant - the pitch is divided into 35 quadrants in which the ball may be
- each player has a destination quadrant to run to for each of the 35 possible
  ball quadrants

Algorithm:
- take the player's skills and pack them into one dword in this nibble order:
  ???, passing, shooting, heading, tackling, ball control, speed, finishing
- skills normally occupy half a byte (0..15), but only the lower three bits
  (value % 8) are considered when calculating the price
- for each ball quadrant:
    - unless it is in the top or bottom two rows, or is the lower central
      quadrant in front of the penalty area, determine how many players go
      there (compare where all 10 players run for the current ball quadrant)
    - use one for the excluded quadrants
    - for a CPU team, value every quadrant as 1
    - store the value in numPlayersAtQuadrant
  - use the player's destination quadrant to fetch a mask from the table; it
    packs skill weights with values from 0 to 5 into a dword

    priceSkillPonders: (the index is the quadrant number)
    dd 00005020h, 00024010h, 00034000h, 00024010h, 00005020h, 01003030h, 01013020h
    dd 00024010h, 01013020h, 01003030h, 02002030h, 02013010h, 01013000h, 02013010h
    dd 02002030h, 02010130h, 02013000h, 03011000h, 02013000h, 02010130h, 02001230h
    dd 03000220h, 04100200h, 03000220h, 02001230h, 03000240h, 02210220h, 03230312h
    dd 02210220h, 03000240h, 03000330h, 02200221h, 01220124h, 02200221h, 03000330h

  - the point is to weight tackling more highly for defensive positions, for
    example, and shooting/finishing more highly for attacking positions
  - the maximum sum of skill weights is 14 and the minimum is 5
  - maximum distinct skills per position: 6; minimum: 2

- shift the skill value into range 1..8, then obtain its multiplier from the
  following table:

  skillValuePonders:
  db 0, 1, 3, 6, 10, 15, 21, 28
  the index is the skill value extracted from priceSkillPonders

- put the weighted skill value into the accumulator

  weight | val |
         |     | skill: 1   2   3   4   5   6   7   8
  =======+=====+=====================================
    0    |  0  |        0   0   0   0   0   0   0   0
    1    |  1  |        1   2   3   4   5   6   7   8
    2    |  3  |        3   6   9  12  15  18  21  24
    3    |  6  |        6  12  18  24  30  36  42  48
    4    |  10 |       10  20  30  40  50  60  70  80
    5    |  15 |       15  30  45  60  75  90 105 120
    /    |  21 |
    /    |  28 |

- based on the table, the final accumulator minimum is 8 and maximum is 200
- this accumulator is a measure of player skills for the given quadrant

- halve the total skill value [4..100]
- then multiply it by a coefficient from the table below:
  skillsPerQuadrant:
  db 4, 4, 4, 3, 3, 4, 4, 4, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 1, 1, 2, 3, 1, 1, 1, 2
  db 3, 3, 4, 4, 4, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 2, 2, 2, 3, 3, 2, 1, 1, 2, 3, 2, 1, 1, 1, 3
  db 3, 4, 4, 4, 3, 3, 4, 4, 4, 3, 2, 4, 4, 4, 2, 1, 3, 4, 3, 1, 1, 2, 3, 2, 1, 1, 1, 3, 1, 1, 1, 1, 4, 1, 1
  db 3, 3, 1, 2, 2, 3, 3, 2, 2, 2, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3
  db 2, 2, 1, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 3, 4, 4
  db 1, 1, 2, 1, 1, 2, 3, 4, 3, 2, 3, 4, 4, 4, 3, 3, 4, 4, 4, 3, 3, 4, 4, 4, 3, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1
  db 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 4, 4, 3, 3, 4, 4, 4, 3, 3, 4, 4, 4, 3

  The row is selected from player position: G, RB, LB, D, RW, LW, M, A (the goalkeeper is not counted).
  The index within the row is the quadrant. Its value says how highly that quadrant is valued for the player based
  on his position. Thus defenders value quadrants nearer our goal more highly, and the emphasis shifts toward the
  other end as positions become more attacking.

- the value is now [4..400]

- table arranged in submatrices (first expand each submatrix into a row for linear representation):
quadrantDistanceFactor:
32,  24,  16,   8,   2,     24,  32,  24,  16,   8,     16,  24,  32,  24,  16,      8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,      8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
16,  16,  16,   8,   2,     16,  16,  16,  16,   8,     16,  16,  16,  16,  16,      8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
 8,   8,   8,   8,   2,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
 2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,
 1,   1,   1,   1,   1,      1,   1,   1,   1,   1,      1,   1,   1,   1,   1,      1,   1,   1,   1,   1,      1,   1,   1,   1,   1,
 0,   0,   0,   0,   0       0,   0,   0,   0,   0       0,   0,   0,   0,   0       0,   0,   0,   0,   0       0,   0,   0,   0,   0

24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,      8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
32,  24,  16,   8,   2,     24,  32,  24,  16,   8,     16,  24,  32,  24,  16,      8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,      8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
16,  16,  16,   8,   2,     16,  16,  16,  16,   8,     16,  16,  16,  16,  16,      8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
 8,   8,   8,   8,   2,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
 2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,
 1,   1,   1,   1,   1       1,   1,   1,   1,   1       1,   1,   1,   1,   1       1,   1,   1,   1,   1       1,   1,   1,   1,   1

16,  16,  16,   8,   2,     16,  16,  16,  16,   8,     16,  16,  16,  16,  16,      8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,      8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
32,  24,  16,   8,   2,     24,  32,  24,  16,   8,     16,  24,  32,  24,  16,      8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,      8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
16,  16,  16,   8,   2,     16,  16,  16,  16,   8,     16,  16,  16,  16,  16,      8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
8,    8,   8,   8,   2,     8,    8,   8,   8,   8,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
2,    2,   2,   2,   2      2,    2,   2,   2,   2       2,   2,   2,   2,   2       2,   2,   2,   2,   2       2,   2,   2,   2,   2

 8,   8,   8,   8,   2,      8,   8,   8,   8,   8,       8,   8,   8,   8,   8,     8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
16,  16,  16,   8,   2,     16,  16,  16,  16,   8,      16,  16,  16,  16,  16,     8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,      16,  24,  24,  24,  16,     8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
32,  24,  16,   8,   2,     24,  32,  24,  16,   8,      16,  24,  32,  24,  16,     8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
24,  24,  16,   8,   2,     24,  24,  24,  16,   8,      16,  24,  24,  24,  16,     8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
16,  16,  16,   8,   2,     16,  16,  16,  16,   8,      16,  16,  16,  16,  16,     8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
 8,   8,   8,   8,   2       8,   8,   8,   8,   8        8,   8,   8,   8,   8      8,   8,   8,   8,   8       2,   8,   8,   8,   8

  2,   2,   2,   2,   2,      2,   2,   2,   2,   2,      2,   2,   2,   2,   2,     2,   2,   2,   2,   2,      2,   2,   2,   2,   2,
  8,   8,   8,   8,   2,      8,   8,   8,   8,   8,      8,   8,   8,   8,   8,     8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
 16,  16,  16,   8,   2,     16,  16,  16,  16,   8,     16,  16,  16,  16,  16,     8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
 24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,     8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
 32,  24,  16,   8,   2,     24,  32,  24,  16,   8,     16,  24,  32,  24,  16,     8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
 24,  24,  16,   8,   2,     24,  24,  24,  16,   8,     16,  24,  24,  24,  16,     8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
 16,  16,  16,   8,   2      16,  16,  16,  16,   8      16,  16,  16,  16,  16      8,  16,  16,  16,  16       2,   8,  16,  16,  16

 1,   1,   1,   1,   1,       1,   1,   1,   1,   1,      1,   1,   1,   1,   1,     1,   1,   1,   1,   1,      1,   1,   1,   1,   1,
 2,   2,   2,   2,   2,       2,   2,   2,   2,   2,      2,   2,   2,   2,   2,     2,   2,   2,   2,   2,      2,   2,   2,   2,   2,
 8,   8,   8,   8,   2,       8,   8,   8,   8,   8,      8,   8,   8,   8,   8,     8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
16,  16,  16,   8,   2,       16,  16,  16,  16,   8,     16,  16,  16,  16,  16,    8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
24,  24,  16,   8,   2,       24,  24,  24,  16,   8,     16,  24,  24,  24,  16,    8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
32,  24,  16,   8,   2,       24,  32,  24,  16,   8,     16,  24,  32,  24,  16,    8,  16,  24,  32,  24,      2,   8,  16,  24,  32,
24,  24,  16,   8,   2        24,  24,  24,  16,   8      16,  24,  24,  24,  16     8,  16,  24,  24,  24       2,   8,  16,  24,  24

 0,   0,   0,   0,   0,       0,   0,   0,   0,   0,       0,   0,   0,   0,   0,    0,   0,   0,   0,   0,      0,   0,   0,   0,   0,
 1,   1,   1,   1,   1,       1,   1,   1,   1,   1,       1,   1,   1,   1,   1,    1,   1,   1,   1,   1,      1,   1,   1,   1,   1,
 2,   2,   2,   2,   2,       2,   2,   2,   2,   2,       2,   2,   2,   2,   2,    2,   2,   2,   2,   2,      2,   2,   2,   2,   2,
 8,   8,   8,   8,   2,       8,   8,   8,   8,   8,       8,   8,   8,   8,   8,    8,   8,   8,   8,   8,      2,   8,   8,   8,   8,
16,  16,  16,   8,   2,      16,  16,  16,  16,   8,      16,  16,  16,  16,  16,    8,  16,  16,  16,  16,      2,   8,  16,  16,  16,
24,  24,  16,   8,   2,      24,  24,  24,  16,   8,      16,  24,  24,  24,  16,    8,  16,  24,  24,  24,      2,   8,  16,  24,  24,
32,  24,  16,   8,   2       24,  32,  24,  16,   8       16,  24,  32,  24,  16     8,  16,  24,  32,  24       2,   8,  16,  24,  32

- select the row by ball quadrant; the column is the player's destination quadrant for that ball quadrant
- this appears to be a coefficient for the effect of quadrant proximity: the farther the destination quadrant, the
  less its skill coefficient contributes to the total
- after multiplication divide by 8; coefficients are really 0..4 but multiplied by 8 for more precise arithmetic
- the value is now [0..1600]
- if more than two players go to that quadrant, divide by the number going there minus one
  [0..1600] / 1..9
- do not divide for a CPU team
- then multiply by the "proximity factor" (also skipped for a CPU team)
  - count "nearby" quadrants for the current quadrant using the table above; only distances of at least 8 count
  - inspect each nearby quadrant's destination and compare it to the current destination quadrant
  - count destination quadrants no farther than 4 away (effectively the same as above)
  - multiply the price factor by nearby-quadrant count and divide by nearby-destination count (quotient at most 1)
- do this per quadrant, then sum all 35 quadrants [0..56000]
- divide by 350 [0..160]
- subtract 8 [-8..152]
- clamp to [0..49]: below 0 => 0; above 49 => 49
- subtract the player's file price from the result
- if our calculated price is lower, return it
- if higher, index plPricesIncreaseTable by the difference, add the result to the file price, and return it
plPricesIncreaseTable:
db 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
db 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
- since both numbers are in [0..49], the difference must be in [1..49]
- table values are tuned so the result is always in [0..49]
- table values must be <= their indices for the result to remain in [0..49]

Player swapping
===============
Players in starting lineup (1-11) will keep their shirt number when swapped.
Bench players are explicitly assigned numbers 12-16, and if at least one bench
player is involved in the swap both players will swap their shirt numbers with
each other. Bench player(s) will still end up as 12-16 as SWOS will assign
those numbers to all bench players after the swap has been made.
