pitchx.dat
pitchx.blk, 1<=x<=6

Pitchx.dat files contain pointers into corresponding pitchx.blk files. Pointers
point to 16 x 16 patterns that comprise the entire pitch.

55 chunks 176 bytes long are transferred from pitchx.dat files to
g_pitchDatBuffer (55 x 168 = 9240, entire file), but only first 168 bytes are
read from the file (those unread 8 bytes are zeros, since g_pitchDatBuffer is
initialized to zero). After reading pitchx.dat the pointer fixup is performed,
pointers get incremented by the address of corresponding pitch.blk file's
contents.

For pitchx.blk file SWOS sets aside 75776 bytes, which is enough for 296 unique
patterns. All above that will cause overwrite of the patterns near the end by
saved sprites, which will make a big mess on the field.

At the start of the pitchx.dat file there are 2 x 21 pointers. Those are
pointers to patterns that need to be converted - ie. colored to colors of teams
that are playing (fans). First 21 pointers are for the left team, and second 21
are for the right one. At the end of the file there are 42 more pointers to
patterns that need color conversion.

Patterns with indices 1..24 are used to animate the crowd.
0 - empty tile (mostly, not always)
1..12  - upper spectator area \
                              |- animated crowd
13..24 - lower spectator area /
Odd indices are static images, even are moving (jumping, waving with scarf,
etc.)

Colors are converted using a lookup table. Each color byte from the pattern is
used as an index into the table (multiplied by two - word index). Resulting
byte replaces original pixel. Size of the table seems to be 96 byte, but only
even bytes are used. Before the actual conversion takes place, conversion table
is edited, a word is written to offset 20: shirt background color, if shirts
aren't plain, and if they are shorts color, and to offset 22: shirt stripes
color (primary color). Colors that are converted are 10 and 11 (20 / 2 and
22 / 2). Those are bright red and bright blue.

Real patterns that comprise the field start from 42. One screen fits 20
patterns horizontally (20x16=320). Dimensions of the virtual field are 42 x 53
patterns, that is 672 x 848 pixels. After 42 + 42 x 53 patterns, another 42
patterns used for fan coloring follow. Since initial patterns start at 42, 16
needs to be subtracted from y coordinates used in SWOS in order to get the
first pixel of the field.


    single row:

    20 visible patterns   |    22 invisible patterns
    +--+--+--+   +--+--+--+--+--+--+--+--+   +--+--+
    |  |  |  |...|  |  |  |  |  |  |  |  |...|  |  |
    +--+--+--+   +--+--+--+--+--+--+--+--+   +--+--+
                          |


    Entire virtual field:

              1               42              1
            +---+-----------     -----------+---+
          1 |   |            ...            |   | 1
            +---+-----------     -----------+---+
          1 |   |                           |   | 1
            +---+-----------     -----------+---+
            |   |                           |   |
            |   |                           |   |
            |   |                           |   |
            |   |                           |   |
                              .
         53                   .
                              .
            |   |                           |   |
            |   |                           |   |
            |   |                           |   |
            +---+-----------     -----------+---+
          1 |   |                           |   | 1
            +---+-----------     -----------+---+
          1 |   |                           |   | 1
            +---+-----------     -----------+---+
              1               42              1

Additional rows and columns around the field are used for scrolling: when
camera moves, for each pixel of movement 1 pattern is drawn into this slack
area.

Tables for the movement:
patternTableVert db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
    db -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, -1, 22, -1, 23, -1
patternTableHorz db 0, 1, 2, 3, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10,
    db -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1

For each of 16 pixels that are scrolled (a whole pattern), one or two patterns
are copied in the spots around the virtual screen. So when the 16-pixel pattern
limit is crossed, next row or column of patterns is already in its spot and
scrolling can continue (18 or 24 patterns). It is probably done like this in
order to divide job more equally for each frame and avoid delaying update if
scroll routine has too much to do.
Copy patterns function is called twice per pixel scrolled, odd indices are used
for first call, even for second. -1 means don't copy anything.
24 x 16 = 384 (24 patterns for virtual screen length)
18 x 16 = 288 (18 patterns for virtual screen length)

Each pitch file contains corresponding type of stripes on the field:
pitch1 - vertical stripes
pitch2 - horizontal stripes
pitch3 - rhombus
pitch4 - squares
pitch5 - diagonal stripes
pitch6 - training pitch

Pitch types:
0 - frozen
1 - muddy
2 - wet
3 - soft
4 - normal
5 - dry
6 - hard

are achieved by palette editing. For each type of pitch there is a 27 bytes
(colors) table, and it's used to copy the colors are to the specific place in
working palette: (0, 1, 2, 21, 22, 23, 27, 28, 29, 234, 235, 236, 237, 238,
239, 240, 241, 242, 243, 244, 245, 318, 319, 320, 321, 322, 323). Those are the
colors: 0, 7, 9, 78, 79, 80, 81, 106, 107.
