###############################################################################
#
#  File:  turtles.keg
#
#  Description:
#
#      This file contains the definition for Turtles.
#
#  Author:  Kevin Brisley
#
###############################################################################


#
#  The name of the game.
#
Turtles.Name:                           Turtles

# 
#  The desired FPS.
#
Turtles.FramesPerSecond:                60

#
#  The history and anecdote files.
#
Turtles.HistoryFile:                    turtles.his
Turtles.TalesFile:                      turtles.tal

#
#  Address spaces.
#
Turtles.NumSpaces:                       1

#
#  The first address space is used by the Game CPU.  It includes the following:
#  0x00000-0x0FFFF (64K):      Game RAM/ROM.
#
Turtles.Space1.Size:                     0x10000
Turtles.Space1.NumROMs:                  5
Turtles.Space1.ROM1.Description:         turt_vid.2c @ 0x00000
Turtles.Space1.ROM2.Description:         turt_vid.2e @ 0x01000
Turtles.Space1.ROM3.Description:         turt_vid.2f @ 0x02000
Turtles.Space1.ROM4.Description:         turt_vid.2h @ 0x03000
Turtles.Space1.ROM5.Description:         turt_vid.2j @ 0x04000

#
#  CPUs.
#
Turtles.NumCPUs:                         1

#
#  CPU 1 (game).
#
Turtles.CPU1.Description:                Game
Turtles.CPU1.Type:                       Z80
Turtles.CPU1.ClockSpeed:                 3072000
Turtles.CPU1.Space:                      1
Turtles.CPU1.IValue:                     INT_NMI
Turtles.CPU1.IDisable:                   0x0a008


#
#  The number of inputs.
#
Turtles.NumInputs:                       4

Turtles.Input1.Description:              IN0
Turtles.Input1.CPU:                      1
Turtles.Input1.Location:                 0x0b000
Turtles.Input1.Default:                  0xff

Turtles.Input2.Description:              IN1
Turtles.Input2.CPU:                      1
Turtles.Input2.Location:                 0x0b010
Turtles.Input2.Default:                  0xff

Turtles.Input3.Description:              IN2
Turtles.Input3.CPU:                      1
Turtles.Input3.Location:                 0x0b020
Turtles.Input3.Default:                  0xf1

Turtles.Input4.Description:              DSW2
Turtles.Input4.CPU:                      1
Turtles.Input4.Location:                 0x0b820
Turtles.Input4.Default:                  0xff

#
#  The number of outputs.
#
Turtles.NumOutputs:                      0

#
#  The keys used in the game.
#
Turtles.NumKeys:                         10

#  Coin Slot 1
Turtles.Key1.Key:                        KEY_4
Turtles.Key1.Mask:                       0x80
Turtles.Key1.Input:                      1
Turtles.Key1.Default:                    Off/1

#  Coin Slot 2
Turtles.Key2.Key:                        KEY_5
Turtles.Key2.Mask:                       0x40
Turtles.Key2.Input:                      1
Turtles.Key2.Default:                    Off/1

#  Left Player 1
Turtles.Key3.Key:                        KEY_LEFT
Turtles.Key3.Joy:                        JOY_LEFT
Turtles.Key3.Mask:                       0x20
Turtles.Key3.Input:                      1
Turtles.Key3.Default:                    Off/1

#  Right Player 1
Turtles.Key4.Key:                        KEY_RIGHT
Turtles.Key4.Joy:                        JOY_RIGHT
Turtles.Key4.Mask:                       0x10
Turtles.Key4.Input:                      1
Turtles.Key4.Default:                    Off/1

#  Fire Player 1
Turtles.Key5.Key:                        KEY_SPACE
Turtles.Key5.Joy:                        JOY_B1
Turtles.Key5.Mask:                       0x08
Turtles.Key5.Input:                      1
Turtles.Key5.Default:                    Off/1

#  Credit
Turtles.Key6.Key:                        KEY_3
Turtles.Key6.Mask:                       0x04
Turtles.Key6.Input:                      1
Turtles.Key6.Default:                    Off/1

#  Start 1 Player Game
Turtles.Key7.Key:                        KEY_1   
Turtles.Key7.Mask:                       0x80
Turtles.Key7.Input:                      2
Turtles.Key7.Default:                    Off/1

#  Start 2 Player Game
Turtles.Key8.Key:                        KEY_2
Turtles.Key8.Mask:                       0x40
Turtles.Key8.Input:                      2
Turtles.Key8.Default:                    Off/1

#  Down Player 1
Turtles.Key9.Key:                        KEY_DOWN
Turtles.Key9.Joy:                        JOY_DOWN
Turtles.Key9.Mask:                       0x40
Turtles.Key9.Input:                      3
Turtles.Key9.Default:                    Off/1

#  Up Player 1
Turtles.Key10.Key:                       KEY_UP
Turtles.Key10.Joy:                       JOY_UP
Turtles.Key10.Mask:                      0x10
Turtles.Key10.Input:                     3
Turtles.Key10.Default:                   Off/1


#
#  The dip switches used in the game.
#
Turtles.NumDips:                         3

#  Type of machine
Turtles.Dip1.Description:                Cocktail or Upright
Turtles.Dip1.Mask:                       0x08
Turtles.Dip1.Input:                      3
Turtles.Dip1.Default:                    On/0  

#  Coins Per Play (1 of 2)
Turtles.Dip2.Description:                Coins Per Play (1 of 2)
Turtles.Dip2.Mask:                       0x04
Turtles.Dip2.Input:                      3
Turtles.Dip2.Default:                    On/0

#  Coins Per Play (2 of 2)
Turtles.Dip3.Description:                Coins Per Play (2 of 2)
Turtles.Dip3.Mask:                       0x02
Turtles.Dip3.Input:                      4
Turtles.Dip3.Default:                    Off/1



#
#  Screen Resolution.
#
Turtles.ScreenWidth:                     256
Turtles.ScreenHeight:                    256


#
#  Graphics Sets.
#
Turtles.NumGfxSets:                      2

#
#  The first set contains the characters.
#
Turtles.GfxSet1.Width:                   8
Turtles.GfxSet1.Height:                  8
Turtles.GfxSet1.Number:                  256
Turtles.GfxSet1.BPP:                     2
Turtles.GfxSet1.BPs:                     0 16384
Turtles.GfxSet1.XBits:                    56  48  40  32  24  16   8   0
Turtles.GfxSet1.YBits:                     0   1   2   3   4   5   6   7
Turtles.GfxSet1.Increment:               64
Turtles.GfxSet1.NumROMs:                 2
Turtles.GfxSet1.ROM1.Description:        turt_vid.5f
Turtles.GfxSet1.ROM2.Description:        turt_vid.5h

#
#  The second set contains the sprites.
#
Turtles.GfxSet2.Width:                   16
Turtles.GfxSet2.Height:                  16
Turtles.GfxSet2.Number:                  64
Turtles.GfxSet2.BPP:                     2
Turtles.GfxSet2.BPs:                     0 16384
Turtles.GfxSet2.XBits:                   184 176 168 160 152 144 136 128 \
                                          56  48  40  32  24  16   8   0
Turtles.GfxSet2.YBits:                     0   1   2   3   4   5   6   7 \
                                          64  65  66  67  68  69  70  71
Turtles.GfxSet2.Increment:               256
Turtles.GfxSet2.NumROMs:                 2
Turtles.GfxSet2.ROM1.Description:        turt_vid.5f
Turtles.GfxSet2.ROM2.Description:        turt_vid.5h


#
#  Graphic Layers
#
Turtles.NumGfxLayers:                    2

###############################################################################
#  The first layer renders the characters.
#
#  The video RAM starts at 0x09000 and is mapped as follows:
#
#      0x93e0 0x93c0 0x93a0   ...   0x9020 0x9000
#      0x93e1 0x93c1 0x93a1   ...   0x9021 0x9001
#      ...    ...    ...            ...    ...
#      0x93ff 0x93df 0x93bf   ...   0x903f 0x901f
#
#  The colour RAM starts at 0x9800 and is mapped as follows:
#
#      0x9801 0x9801 0x9801   ...   0x9801 0x9801
#      0x9803 0x9803 0x9803   ...   0x9803 0x9803
#      ...    ...    ...            ...    ...
#      0x983f 0x983f 0x983f   ...   0x983f 0x983f
###############################################################################
Turtles.GfxLayer1.Lightweight:                  Yes
Turtles.GfxLayer1.Space:                        1
Turtles.GfxLayer1.GfxSet:                       1
Turtles.GfxLayer1.Palette:                      1
Turtles.GfxLayer1.ColourTable:                  1
Turtles.GfxLayer1.Transparency:                 Off
Turtles.GfxLayer1.BlankChar:                    16
Turtles.GfxLayer1.NumChars:                     1024

Turtles.GfxLayer1.NumDirty:                     2
Turtles.GfxLayer1.Dirty1.Start:                 0x09000
Turtles.GfxLayer1.Dirty1.End:                   0x093ff
Turtles.GfxLayer1.Dirty1.CharsPerLoc:           1
Turtles.GfxLayer1.Dirty1.Assign:                #
Turtles.GfxLayer1.Dirty2.Start:                 0x09800
Turtles.GfxLayer1.Dirty2.End:                   0x0983f
Turtles.GfxLayer1.Dirty2.CharsPerLoc:           32
Turtles.GfxLayer1.Dirty2.Assign:                # / 2 + 32 * $

Turtles.GfxLayer1.NumCharNums:                  1
Turtles.GfxLayer1.CharNum1.Value:               @(0x09000 + #)

Turtles.GfxLayer1.NumColours:                   1
Turtles.GfxLayer1.Colour1.Value:                @(0x09800 + # % 32 * 2 + 1)

Turtles.GfxLayer1.NumXPoss:                     1
Turtles.GfxLayer1.XPos1.Value:                  (31 - # / 32) * 8

Turtles.GfxLayer1.NumYPoss:                     1
Turtles.GfxLayer1.YPos1.Value:                  (# % 32) * 8


###############################################################################
#  The second layer renders the sprites.
#
#  The sprite RAM starts at 0x09840.  There are 4 sequential bytes per
#  sprite and 8 sprites.  The following describes the 4 bytes:
#
#      0 : X Position.
#      1 : bits 0-5 indicate the sprite number
#          bit  6   indicates vertical flip
#          bit  7   indicates horizontal flip
#      2 : Colour
#      3 : Y Position.
###############################################################################
Turtles.GfxLayer2.Space:                  1
Turtles.GfxLayer2.GfxSet:                 2
Turtles.GfxLayer2.Palette:                1
Turtles.GfxLayer2.ColourTable:            1
Turtles.GfxLayer2.Clipping:               16,239,0,255
Turtles.GfxLayer2.Transparency:           On
Turtles.GfxLayer2.NumChars:               8

Turtles.GfxLayer2.NumDirty:               1
Turtles.GfxLayer2.Dirty1.Start:           0x09840
Turtles.GfxLayer2.Dirty1.End:             0x0985f
Turtles.GfxLayer2.Dirty1.CharsPerLoc:     1
Turtles.GfxLayer2.Dirty1.Assign:          # / 4

Turtles.GfxLayer2.NumCharNums:            1
Turtles.GfxLayer2.CharNum1.Value:         @(0x09841 + 4 * #) & 0x3f

Turtles.GfxLayer2.NumColours:             1
Turtles.GfxLayer2.Colour1.Value:          @(0x09842 + 4 * #)

Turtles.GfxLayer2.NumXPoss:               1
Turtles.GfxLayer2.XPos1.Value:            @(0x09840 + 4 * #)

Turtles.GfxLayer2.NumYPoss:               1
Turtles.GfxLayer2.YPos1.Value:            @(0x09843 + 4 * #)

Turtles.GfxLayer2.NumEnables:             1
Turtles.GfxLayer2.Enable1.Value:          1

Turtles.GfxLayer2.NumHFlips:              1
Turtles.GfxLayer2.HFlip1.Value:           @(0x09841 + 4 * #) & 0x80

Turtles.GfxLayer2.NumVFlips:              1
Turtles.GfxLayer2.VFlip1.Value:           @(0x09841 + 4 * #) & 0x40


#
#  Colour Palettes
#
Turtles.NumPalettes:                     1

Turtles.Palette1.NumColours:             16
Turtles.Palette1.MaxValue:               255
Turtles.Palette1.Colour1.RGB:            0x00/0x00/0x00
Turtles.Palette1.Colour2.RGB:            0x94/0x00/0xd8
Turtles.Palette1.Colour3.RGB:            0xd8/0x00/0x00
Turtles.Palette1.Colour4.RGB:            0xf8/0x64/0xd8
Turtles.Palette1.Colour5.RGB:            0x00/0xd8/0x00
Turtles.Palette1.Colour6.RGB:            0x00/0xf8/0xd8
Turtles.Palette1.Colour7.RGB:            0xd8/0xd8/0x94
Turtles.Palette1.Colour8.RGB:            0xd8/0xf8/0xd8
Turtles.Palette1.Colour9.RGB:            0xf8/0x94/0x44
Turtles.Palette1.Colour10.RGB:           0x00/0x00/0xd8
Turtles.Palette1.Colour11.RGB:           0xf8/0x00/0x00
Turtles.Palette1.Colour12.RGB:           0xff/0x00/0xff
Turtles.Palette1.Colour13.RGB:           0x00/0xf8/0x00
Turtles.Palette1.Colour14.RGB:           0x00/0xff/0xff
Turtles.Palette1.Colour15.RGB:           0xf8/0xf8/0x00
Turtles.Palette1.Colour16.RGB:           0xff/0xff/0xff

#
#  The colour lookup table.
#
Turtles.NumColourTables:           1

Turtles.ColourTable1.NumEntries:   32
Turtles.ColourTable1.List:                                                     \
                                  0x00,0x02,0x09,0x06,0x00,0x0c,0x01,0x08,    \
                                  0x00,0x04,0x02,0x0e,0x00,0x02,0x04,0x0e,    \
                                  0x00,0x0e,0x04,0x0a,0x00,0x0c,0x08,0x0e,    \
                                  0x00,0x07,0x0a,0x03,0x00,0x05,0x0a,0x07
