# Chip's Challenge File Layout Information

## (Copyright 1997 Greg Heier)

NOTE: This document was contributed by a visitor who wishes to remain anonymous, and replaces the information I had on this site before (it is far more complete). There may be an inaccuracy here and there, and needs some editing, but other than that it should prove to be very useful to those who might hack CHIPS.DAT a bit.

Amended and HTML cleaned up by John Elliott

Below you will find a description of the layout of the file CHIPS.DAT.

Each level of Chips Challenge is made up on a 32x32 tile grid. In addition, each Chip's Challenge level is made up of two layers: upper and lower. This allows chips to be placed under dirt blocks and monsters on top of cloning machines.

## File Header

Offset | Description
--- | ---
$00-$03 | Unsigned Long | This is a 'magic number'. CHIPS.EXE uses this to check for a valid CHIPS.DAT file. The value must be $0002AAAC. Tile World also accepts $0102AAAC and uses it to select Atari Lynx rules.
$04-$05 | Unsigned Word | Number of levels in the file

## Format of a level:

### General information

The first 8 bytes of a level have fixed meanings:

Unsigned Word | Number of bytes in this level (not including this word)
Unsigned Word | Level number
Unsigned Word | Time (in seconds). A value of ZERO indicates no time limit.
Unsigned Word | Number of chips to pick up

### Map details

Unsigned Word | 0 or 1: Map detail
Unsigned Word | Number of bytes in first layer
... | Map detail, first layer
Unsigned Word | Number of bytes in second layer
... | Map detail, second layer

- The first word must always be 0 or 1, though 0 is not used in the existing CHIPS.DAT. Possibly it was intended to indicate whether the level data are uncompressed or compressed.
- Map detail is created using a series of object codes (outlined later)
- Valid object codes range from $0-$6F
- Object codes $70-$9F are used internally as "OR'd" copies of codes $3F-$6F
- Object codes $9F-$CF are used internally as "XOR'd" copies of codes $70-$9F
- An object code of $FF is an indicator of RLE (run-length-encoding)
- RLE takes the form: $FF, #copies.byte, object-code.byte
- Therefore an rle code of "$FF,$08,$02" would create a row of 8 chips

(If the second layer is not used, it appears as, "FF FF 00 FF FF 00 FF FF 00 FF FF 00 FF 04 00", which indicates that there are 255+255+255+255+4 = 1024 = 32x32 spaces under the objects.)

### "Optional" fields

The "Optional" fields are preceded by a word describing how many bytes there are. If there are more than 1152 bytes, "Chip's Challenge" will crash when loading the level.

Unsigned Word | Number of bytes of optional fields
... | One or more optional fields

All "Optional" fields start with two bytes:

Unsigned Byte | Field type
Unsigned Byte | Number of additional bytes in field

Since all field types include the number of additional bytes, CHIPS.EXE can skip over fields which it does not recognise.

Field types are:

- Field 1 is the level time (not used)
- Field 2 is the number of chips on the level (not used)
- Field 3 is the map title.
- Field 4 is used to map brown buttons to traps.
- Field 5 is used to map red buttons to cloning machines.
- Field 6 is used to indicate password.
- Field 7 is used to indicate hint text
- Field 8 is also used to indicate the password (not used)
- Field 9 is not used.
- Field 10 is used to indicate where moving objects (monsters) occur
- All other field types are treated like Field 9.

The standard levels file contains extra fields in the order 3,7,6,4,5,10; but this is not required.

Each level will always include fields 3 and 6.

#### Field 1 - Level time

Unsigned Byte | $01 = Field type
Unsigned Byte | $02 = Field length
Unsigned Word | Time in seconds, 0 for none

This field is not found in CHIPS.DAT because it is completely unnecessary.

#### Field 2 - Chip count

Unsigned Byte | $02 = Field type
Unsigned Byte | $02 = Field length
Unsigned Word | Number of chips on the level

This field is not found in CHIPS.DAT because it is completely unnecessary.

#### Field 3 - Map Title

Unsigned Byte | $03 = Field type
Unsigned Byte | Length of string including the terminating 0
ASCII | Map title. Can be up to 63 bytes.
Byte | 0 (end of string)

#### Field 4 - Trap Controls

Unsigned Byte | $04 = Field type
Unsigned Byte | Length of field, a multiple of $0A bytes
Trap records | Unsigned Word | Button X position
Unsigned Word | Button Y position
Unsigned Word | Trap X position
Unsigned Word | Trap Y position
Unsigned Word | Always zero (used in the game for open/closed?)

- Traps are assigned to appropriate brown buttons on the map detail.
- An X-Y coordinate system is used. Since the map is a 32x32 tile grid, valid X-Y values are $00-$1F

#### Field 5 - Cloning Machine Controls

Unsigned Byte | $05 = Field type
Unsigned Byte | Length of field, a multiple of $08 bytes
Cloning machine records | Unsigned Word | Button X position
Unsigned Word | Button Y position
Unsigned Word | Trap X position
Unsigned Word | Trap Y position

- Cloning Machines are assigned to appropriate Red buttons on the map detail.
- An X-Y coordinate system is used, as in Field 4 above.
- Each coordinate pair is NOT terminated with a 0 word, therefore Cloning Machine data is always a multiple of $08 bytes. (Don't ask me why the inconsistencies, I didn't have anything to do with the programming J )

#### Field 6 - Map Password

Unsigned Byte | $06 = Field type
Unsigned Byte | Length of string including the terminating 0
ASCII | Encoded password.
Byte | 0 (end of string)

Standard passwords are always 4 bytes long, but the game engine allows passwords to be up to 9 bytes.

The password is encoded by XORing each byte in it with $99. This gives character encodings:

A | D8 | N | D7
B | DB | O | D6
C | DA | P | C9
D | DD | Q | C8
E | DC | R | CB
F | DF | S | CA
G | DE | T | CD
H | D1 | U | CC
I | D0 | V | CF
J | D3 | W | CE
K | D2 | X | C1
L | D5 | Y | C0
M | D4 | Z | C3

#### Field 7 - Map Hint

Unsigned Byte | $07 = Field type
Unsigned Byte | Length of string including the terminating 0
ASCII | Hint text. Can be up to 127 bytes.
Byte | 0 (end of string)

#### Field 8 - Map Password

Unsigned Byte | $08 = Field type
Unsigned Byte | Length of string including the terminating 0
ASCII | Password (not encoded).
Byte | 0 (end of string)

- This is the same as field 6, but the password is stored in plain ASCII rather than encoded.
- This field type does not appear in CHIPS.DAT.

#### Field 9 - Unknown

Unsigned Byte | $09 = Field type
Unsigned Byte | Length of field data
... | Field data.

This field is ignored by CHIPS.EXE.

#### Field 10 - Movement

Unsigned Byte | $0A = Field type
Unsigned Byte | Length of field, a multiple of $02 bytes
Monster movement records | Unsigned Byte | Monster X position
Unsigned Byte | Monster Y position

- Each Monster placed on the map must be listed in this field in order for movement to occur. If not listed, it will simply remain in its starting position.
- An X-Y coordinate system is used. Since the map is a 32x32 tile grid, valid X-Y values are $00-$1F.
- There can be at most 128 moving monsters.

### Example dump of CHIPS.DAT

Offset | Description
--- | ---
$00-$03 | Unsigned Long | $0002AAAC - magic number
$04-$05 | Unsigned Word | $95 -> 149, number of levels
The information below applies to the first record. The levels that follow are in the same format.
$06-$07 | Unsigned Word | Offset to next record. Level 1 = $135 bytes in level. $08+$135=$13D=begin next level.
$08-$09 | Unsigned Word | Level number
$0A-$0B | Unsigned Word | Time (in seconds). A value of ZERO indicates no time limit
$0C-$0D | Unsigned Word | Number of chips to pick up
$0E-$0F | Unsigned Word | Always = 1 = field 1 = Map detail Upper layer
$10-$11 | Unsigned Word | Number of bytes in Map detail, first layer. Level 1 = $C1. $12+$C1=$D3=begin lower layer
$12-$D2 | N/A | Level 1 map detail Upper layer
$D3-$D4 | Unsigned Word | Number of bytes in Map detail, second layer. Level 1 = $0F. $D5+$0F=$E4=end map detail
$D5-$E3 | N/A | Level 1 map detail (second layer)
$E4-$E5 | Unsigned Word | Number of bytes to end of level. Level 1 = $57. $E6+$57=$13D
$E6 | Unsigned Byte | Always = 3. Field 3 = Level Title
$E7 | Unsigned Byte | Number of bytes in Title. Level 1 = 9
$E8-$F0 | N/A | Level Title. Level 1 = "Lesson 1",0
$F1 | Unsigned Byte | Always 7 = Field 7 = Hint text
$F2 | Unsigned Byte | Number of bytes in Hint text. Level 1 = $43. $F3+$43=$136=end Hint Text
$F3-$135 | N/A | ASCII - Hint text. Level 1 = "Collect chips to get past the chip socket. Use keys to open doors.",00
$136 | Unsigned Byte | Always 6. Field 6 = Password
$137 | Unsigned Byte | Always 5. Password length
$138-$13C | N/A | Level Password (encrypted). Level 1 = $DB,$DD,$D1,$C9,$00 = BDHP

## Chip's Challenge Object Codes

This is a listing of the object codes used in the Map Detail. This will be helpful to those who wish to change their maps. Please read File Layout Information for more information.

$00 | Empty Tile (Space) | $26 | Switch Block, Open | $4C | Tank (N)
$01 | Wall | $27 | Brown Button - Traps | $4D | Tank (W)
$02 | Computer Chip | $28 | Blue Button - Tanks | $4E | Tank (S)
$03 | Water | $29 | Teleport | $4F | Tank (E)
$04 | Fire | $2A | Bomb | $50 | Ghost (N)
$05 | Invisible Wall (won't appear) | $2B | Trap | $51 | Ghost (W)
$06 | Blocked North | $2C | Invisible Wall (Will appear) | $52 | Ghost (S)
$07 | Blocked West | $2D | Gravel | $53 | Ghost (E)
$08 | Blocked South | $2E | Pass Once | $54 | Frog (N)
$09 | Blocked East | $2F | Hint | $55 | Frog (W)
$0A | Movable Dirt Block | $30 | Blocked South - East | $56 | Frog (S)
$0B | Dirt | $31 | Cloning Machine | $57 | Frog (E)
$0C | Ice | $32 | Force All Direction | $58 | Dumbbell (N)
$0D | Force South (S) | $33 | Drowning Chip | $59 | Dumbbell (W)
$0E | Cloning Block North (N) | $34 | Burned Chip | $5A | Dumbbell (S)
$0F | Cloning Block West (W) | $35 | Burned Chip(2) | $5B | Dumbbell (E)
$10 | Cloning Block South (S) | $36 | NOT used | $5C | Blob (N)
$11 | Cloning Block East (E) | $37 | NOT used | $5D | Blob (W)
$12 | Force North (N) | $38 | NOT used | $5E | Blob (S)
$13 | Force East (E) | $39 | Chip in Exit - end game | $5F | Blob (E)
$14 | Force West (W) | $3A | Exit - end game | $60 | Centipede (N)
$15 | Exit | $3B | Exit - end game | $61 | Centipede (W)
$16 | Blue Door | $3C | Chip Swimming (N) | $62 | Centipede (S)
$17 | Red Door | $3D | Chip Swimming (W) | $63 | Centipede (E)
$18 | Green Door | $3E | Chip Swimming (S) | $64 | Blue Key
$19 | Yellow Door | $3F | Chip Swimming (E) | $65 | Red Key
$1A | South« East Ice Slide | $40 | Bug (N) | $66 | Green Key
$1B | South« West Ice Slide | $41 | Bug (W) | $67 | Yellow Key
$1C | North« West Ice Slide | $42 | Bug (S) | $68 | Flippers
$1D | North« East Ice Slide | $43 | Bug (E) | $69 | Fire Boots
$1E | Blue Block, becomes Tile | $44 | Fire Bug (N) | $6A | Ice Skates
$1F | Blue Block, becomes Wall | $45 | Fire Bug (W) | $6B | Suction Boots
$20 | NOT used | $46 | Fire Bug (S) | $6C | Chip (N)
$21 | Thief | $47 | Fire Bug (E) | $6D | Chip (W)
$22 | Socket | $48 | Pink Ball (N) | $6E | Chip (S) (Always used)
$23 | Green Button - doors | $49 | Pink Ball (W) | $6F | Chip (E)
$24 | Red Button - cloning | $4A | Pink Ball (S)
$25 | Switch Block, Closed | $4B | Pink Ball (E)

Codes $20,$36,$37,$38 work apparently in the same fashion as code $05. However they are not used in the original game.

Codes $39-$3F are only used internally by the game.

Back to Chip's Challenge for Windows Main Page