CBM BASIC gets very cryptic very quickly.
gr$()
: Graphics data in the form of a 4x1 tile.lv$()
: Level data strings. See below.ml
: max levelsw
: level width in tilesh
: level height in tilesmx
: number of tiles per level, should not exceed 255mu
: max undo tiles
fnpp(x)
: Function that returns the rule for foreground tile at positionx
.ru%(0..31)
: Property rules for each object. Two bytes per.- where
n
contains a byte of tile data,r=ru%(nand31)orru%(n/32)
setsr
to the rule bits of both the foreground and background tile, so that any interaction works the same regardless of which object is in front.
- where
tr%(0..7)
: Transformation rules for each object.dr
: Rule bit of an object being destroyed in a two-rule interaction
l%
: current level number- `pf%(0..mx): Playfield tiles. Even though the compiled version only
1 byte per tile, it can allow multiple objects to overlap so that they
can be tested for interaction.
n=pf%(x) and 31
: set n to foreground tile at positionx
- 0 - 7
(nand24=0)
: Objects - 8 - 15
(nand24=8)
: Noun tiles - 16 - 31
(nand24>15)
: Property or verb tiles
- 0 - 7
int(pf%(x)/32)
: Background tile at positionx
- It can only be 0 through 7, because the rules cannot be modified such that text tiles can overlap.
- `ud%(0..mu,0..2): Undo stack, 3 bytes per tile changed
ud%(dl,0)
: location of changed tileud%(dl,1)
: old value of tileud%(dl,2)
: turn number when tile changed
dl
: next index to store a tile change inud%()
ud
: TODO: something to do with the undo stack, kind of like dl?u%(0..mx)
: list of tiles with "YOU" property
Objects 0 through 7 are inert by default. Objects 1 through 7 may be granted the
following properties through the following bits in the ru%()
array:
- YOU (
1
): "YOU" tiles will move according to player input. If no on-screen tiles have the "YOU" property, then the player may not influence the level, and generally must undo or reset.- There are not yet any autonomous movement properties that would allow a level to be solved by temporarily relinquishing control.
- WIN (
2
): The player wins the level if the "YOU" tile overlaps a "WIN" tile. - STOP (
4
): Objects cannot move onto a "STOP" tile. Any movement operation that encounters a "STOP" tile will be aborted. - PUSH (
8
): If an object attempts to move into a tile with a "PUSH" object, the "PUSH" object will attempt to move in the same direction to get out of the way. - SHUT (
16
): Behaves the same as a "STOP" tile, except that if an "OPEN" object moves onto it, both objects are destroyed.- we need to test that this works with a chain of PUSH blocks
- OPEN (
32
): see above - SINK (
64
): If any object moves onto it, both objects are destroyed. - LOSE (
128
): If any "YOU" object moves onto it, both objects are destroyed. - HOT (
256
): Inert except to "MELT" objects - MELT (
512
): Destroyed if it moves onto a "HOT" tile. - there are several undefined properties
All text tiles are treated as "PUSH" objects with no other properties.
TODO
Press "E" to enter the level editor. This will allow you to edit the playfield in place. You can return to the game at any time by pressing "F7".
A cursor will appear that looks like >@@<
. When you move the
cursor over a tile, it will display the contents of that tile as a
two-letter code. The left character is the background and the right
character is the foreground. For example. >@@<
is an empty tile,
>EA<
is Baba standing on a water tile.
Editor controls are as follows:
- CRSR keys: move the cursor
F1
: Show a legend of supported tiles.@
,A
-Z
,[
,£
,]
,uparrow
,leftarrow
: put that object in the foreground.SHIFT-A
throughSHIFT-G
: put that object in the background.DEL
: remove foreground object. promote background to foreground.F5
: Save current screen to memory.F3
: Restore screen saved from memory.F7
: Return to the game.
To add a level to the actual game, you'll have to use this workflow:
- Use
E
to enter the editor and start making changes. - When you are ready to playtest, press
F5
to save the screen, and thenF7
to return to the game. - To restart the level, press
E
to re-enter the editor,F3
to restore the screen, and thenF7
to return to the game. - When you're finished playtesting, press
F7
to return to the game and pressD
to generateDATA
statements.
The program will print two lines: a DATA
statement containing the
compressed level data, and replacement for line 15
redefining
the maximum number of levels. It will exit to BASIC so that you can
move the cursor up and add both of these lines to the program.
Then you can SAVE
the new program with the new level at the end.
The DATA
statements starting around line 9200
contain level data in a compressed
format. When the player enters a new level, the data string is decompressed as
follows:
119
: entire playfield is filled with0
(empty space)120-135
: variables are initializedlv$
contains the current levelx
contains the index being read fromlv$
starting at1
i
contains the index being written infopf%()
starting at0
140-150
: each PETSCII value fromlv$
is read intot
and parsed.- character
191
(CBM-B) seems to indicate that the level data continues into anotherDATA
statement, so read the next array element intolv$
and continue.
(I doubt it'll work becausel2
gets reset at line120
which is where theGOTO
statement leads) - character
252
(PI) is treated as character34
(double quotes), to accommodate the limitations of BASIC. - character
64
to95
(unshifted letters): store the low 5 bits (0-31
) to the playfield - character
192
to223
(shifted letters): store the low 5 bits (0-31
) to the playfield, and store the "IS" type to the next tile. - character
33
to47
(punctuation): the nextt-32
tiles are zero. (off by one?) - character
49
to63
(punctuation): repeat the previous tilet-48
times.
- character
TODO document the DATA
statement generator