A downloadable game

DOKOBAN

Dokoban is a sokoban game for the Amstrad CPC. The main character is the doctor or adminis the french gamopat forum.

Keyboard arrows are used to move the character and pushing the blocks.

ENTER/RETURN key is used to restart level.

The game includes 13 levels (size 20x12)


TECHNICAL PART

The game works on all Amstrad CPC (using only BASIC 1.0)

1) Control Characters

The game use a lot of Control characters to replace MODE, PAPER, BORDER, INK, SYMBOL in only one PRINT in the first line :

MODE is CHR$(4)+"1" FOR MODE 1

PAPER is CHR$(14)+"0" FOR PAPER 0

BORDER is CHR$(29)+CHR$(64+0)+CHR$(64+0) for BORDER 0,0

INK is CHR$(18)+CHR$(64+v)+CHR$(64+v) for INK v,v

SYMBOL is CHR$(25)+CHR$(i)+CHR$(a)+CHR$(b)+CHR$(c)+CHR$(d)+CHR$(e)+CHR$(f)+CHR$(g)+CHR$(h) for SYMBOL i,a,b,c,d,e,f,g,h

PEN and transparent mode are also used in the tiles's strings :

PEN is CHR$(15)+CHR$(p) FOR PEN p

Transparent mode is enabled by CHR$(22)+CHR$(1) and disabled by CHR$(22)+CHR$(0)

2) CALL &BD1C

The BASIC use MODE 1 but a CALL &BD1C is doing a MODE 0 without clearing the screen. With this trick you can have 8x16x4 colors tiles with a simple PRINT.

For example for the brick :

I use PAPER 0 and PEN 1 for it so I have the colors :

0 (00b) is PEN 0 (Black)

1 (01b) is PEN 4 (Red),

2 (10b) is PEN 1 (Bright Red)

3 (11b) is PEN 5 (Yellow)

The brick look like : (See Brick.png)

3220

2210

2110

0000

2032

1022

1021

0000


I need to translate it for SYMBOL :

+-+------------------Pixel 1
| |
|+-+-----------------Pixel 2
||||
||||+-+--------------Pixel 3
||||| |
|||||+-+-------------Pixel 4
||||||||
11101000 = 232
11000010 = 194
10010010 = 146
00000000 = 0 
10001110 = 142
00101100 = 44
00101001 = 41
00000000 = 0

The character 240 is printed 4 times for a brick with :

CHR$(240)+CHR$(240)+CHR$(8)+CHR$(8)+CHR$(10)+CHR$(240)+CHR$(240) (CHR$(8) move cursor to the left and CHR$(10) move it down and i also store the PEN / PAPER to do all in one PRINT)

3) Levels encoding

All Levels are 20 by 12

There is 3 byte per row to define walls and free part of the level :

Here is an example for the first level :

            11111111
 x012345678901234567x
y     ###            |0000011 1000000 0000000
0    ## ##           |0000110 1100000 0000000
1    #   #           |0000100 0100000 0000000
2    #$  #           |0000100 0100000 0000000
3  ###  $##          |0011100 0110000 0000000
4  #  $ $ #          |0010000 0010000 0000000
5### # ## ########## |1110101 1011111 1111100
6#   # ## ## ##  ..# |1000101 1011011 0000100
7# $  $          ..# |1000000 0000000 0000100
8##### ### #@##  ..# |1111101 1101011 0000100
9    #     ######### |0000100 0001111 1111100
y    #######         |0000111 1111000 0000000

Then you need a byte for the initial position of the character and for each blocks and goal.

Each position (x,y) is stored in one byte with y * 18 + x with x between 0 and 17 and y between 0 and 9 because first/last row/column are not usable and then max is 9 * 18 + 17 = 179

So you need 37 + <block count> * 2 bytes for a level

All tiles and levels are stored in strings using all the range 0-255. Storing character 0 need to use CHR$(0) because you can't store it directly. CHR$(34) (") can't be stored but i don't have it (for levels I use range 36- to avoid it)

Cheating :

If you want to go to the next level you can do ESC ESC then GOTO 9

StatusReleased
Rating
Rated 5.0 out of 5 stars
(2 total ratings)
AuthorBASIC 10Liner
GenrePuzzle
Tags8-Bit, amstradcpc, basic, basic10liner, schneider

Download

Download
dokoban.dsk 190 kB
Download
dokoban.txt 3 kB
Download
dokoban_full.bas 7 kB
Download
Listing 255.png 47 kB

Install instructions

HOW TO RUN IN THE WINAPE 2.0 BETA 2 EMULATOR

1) With the dsk

File / Drive A: / Insert Disk Image... or CTRL+F1

Choose the dokoban.dsk file

then just type :

RUN"DOKOBAN

2) With the dokoban_full.bas file :

Select all the text in an editor and Copy in the clipboard with CTRL+C

In the WinAPE emulator use File / Paste or CTRL+F11

You can also use Settings / High Speed (1000%) or Shift+F4 to speed up copy (restore normal speed with Settings / Normal Speed (100%) or Shift+F3)

After the Paste :

RUN 100

then

RUN

Comments

Log in with itch.io to leave a comment.

Oh! First game I see using my graphics technique! Great work!!

Hope, we will see more this year. New contest starting soon.

Awesome game and use of code!!!

Sorcery!

Seriously, this is simply amazing. Brilliant work!

Seriously? All this gameplay in ten lines?!?

Check out the docs :)

I did, still can't believe it😄

Nice game !!