This game was written for the Basic 10-Liner Contest 2024 where it took the 1st place in the PUR-80 category. It's written for Commodore 64/128 computers.

Aim of the game

In this game, you control Dan who once used to play in a sandbox. By following his passion he become a great digger.

Help him to find as many diamonds as you can by digging holes down. In order to get out to the surface, you can use a ladder by

pressing fire button. Be careful, as number of ladders is limited. To refill ladders, get out to the surface and exit the level in the top

right side of the screen. Number of diamonds gained on the level will be exchanged for the same number of ladders.

Be careful to not run out of ladders! If Dan cannot get to the surface, he will stay forever underground.

How many diamonds can you find? Can you uncover a single level entirely? Let's dig it!

Controls:

  • Use joystick in port 2.
  • In case Dan will stuck underground, to stop his suffering, press `RUN STOP` to interrupt the game (ESC on PC).
  • Then, to start over again, just type `RUN` followed by Return key.
  • Press fire for ladder


What's on the screen

In the top left part of the screen you see the following, starting from the left:

  • number of ladders
  • number of all diamonds found
  • number of diamonds found on the current level

The rest of the screen contains the current level. The top part with a green horizon is a surface containing exit from a current level to the very right.

The game was tested on a real hardware and with WinVice 2.4 emulator.


Constants and variables

  • A - digger Dan position X
  • A$ - tiles (structure: colour, 2 characters for the first line, 2 characters for the second line), see variable `E` for tiles order
  • B - digger Dan position Y
  • C - tile position X, also used to check if digger wants to move horizontally, if it's possible, this variable will be already used to print the tile in a desired place
  • C$ - beginning of the HUD that sets it in the top left corner of the screen and displays graphical representation of a ladder (`=` sign)
    D - tile position Y, also used to check if digger wants to move vertically, if it's possible, this variable will be already used to print the tile in a desired place
  • D$ - sprite data, only part containing data (zeroes at the end are omitted)
  • E - randomised tile, or tile to be rendered in line 9 (0 = ladder, 1 = diamond, 2 = rock, 3 = earth, 4 = surface)
  • F - PEEK to detect the tile on the screen where digger wants to move (32 = uncovered, 174 = earth, 213 = rock, 235 = ladder)
  • G - number of diamonds found in the current level
  • H - PEEK to detect the tile below character on the screen if it's different than earth (in line 2), then re-used (in line 4) to get tile where the digger stands (see `F` for reference)
  • J - read from joystick port 2
  • K - number of ladders left
  • L - constant for 80
  • M - constant for 16, used for digger sprite coordinates calculation
  • T - total number of diamonds found in all levels
  • V - constant for 53269

Scopes

  • initialisation
  • next level
  • main loop
  • adding ladder
  • tile randomisation
  • draw tile

Code line by line

- Line 0 (initialisation):

   - Initialise global constants and variables with READ in the following order: `V`, `L`, `A$`, `K`, `D$`, `C$` (game starts with 10 ladders stored in `K`)

   - Change colour of the screen and the border to black

   - Set sprite bank 16 for sprite #0 (`POKE 2040,16`)

   - Set sprite #0 colour to yellow

   - Enable sprite #0 (`POKE V,1`)

    - Define function `P` to `PEEK` certain screen memory locations

- Line 1 (next level):

   - Initialise Dan's position (`A` and `B`)

   - Refill number of ladders `K` by number of diamonds `G` found in the previous level (sets `K` to `0` if game just started)

   - Add diamonds found in the current level `G` to total number of diamonds `T`

   - Reset number of diamonds in the current level (`G`)

   - Print hidden `D$` at location 1024 of the screen, it contains sprite data

   - Print hidden zeroes as sprite data contains only bytes that matters

   - Print the surface with `E=4` and call to `GOSUB 9`

   - Set constant for `M`

- Line 2 (main loop):

   - Display HUD

   - Store in `H` if field below the digger is different than earth

   - In case a field below the digger is an earth, increase digger's Y position `B=B-(H=0)` so the digger falls down

   - Set digger's sprite position X and Y

- Line 3:

   - In case there was earth below and digger just fell down, go back to line 2, this way digger cannot be controlled and it will fall to the very bottom of the shaft

   - Read joystick in `J`

   - Calculate if digger wants to move horizontally (`C`) or vertically (`D`)

   - Data for `V`

- Line 4 (adding ladder):

   - Re-use `H` variable to get tile where the digger stands

   - If no fire button has been pressed, go to line 5

   - Otherwise, go to line 3 if ladders `K` are not available or a ladder is present in the current location (`H=235`)

   - Otherwise, decrement number of ladders by 1

   - Prepare variables to draw a ladder (`E=0`) in digger's current location by calling `GOSUB 9`

   - Go to line 2

- Line 5:

   - Go to line 2 if digger wants to move beyond level boundaries

   - Otherwise, update digger's desired positions to move (`C` and `D`)

   - Data for `L`, `A$`

- Line 6 (tile randomisation):

   - Store value of PEEK in `F` to detect the tile on the screen where digger wants to move

   - Go to line 8 if the desired position of the digger is the surface (`D=2`)

   - Otherwise, go to line 7 if the desired position is not an uncovered tile (`F<>32`)

   - Otherwise, randomise next tile followed by call to `GOSUB 9` in order to printing it on the screen immediately

   - Go to line 2 if randomised tile is a diamond (`E=1`) or a rock (`E=2`)

- Line 7:

   - Go to line 3 if rock has been uncovered, digger won't move in this direction

   - Otherwise, also go to line 3 if no ladder found in digger's current position (`H<>235`) and digger wants to move up

   - Otherwise, go to line 8 if earth (`F=174`) or ladder (`F=235`) found in the desired direction

   - Otherwise, the last option available is that diamond was found there, so increment number of diamonds found in the level (`G`)

   - Call `GOSUB 9` to draw earth tile as diamond is being taken

- Line 8:

   - Update digger's position (`A` and `B`), this place is unreachable if digger cannot move to a desired field

   - Go to line 1 if the top-right corner of surface has been reached, resulting in drawing a new level

   - Otherwise, go to line 2

   - Data for `K`, `D$`

- Line 9 (draw tile):

   - Set cursor position X and Y where tile is going to be drawn followed by call to `SYS 58640` routine

   - Print first and the second line of a tile

   - Return

   - Data for `C$`

Tricks and notes

  1. Order of tiles is not accidental. Line 6 uses an elegant `ON E GOTO 2,2,8` solution depends on a tile given which is a great way to squeeze conditions in a small amount of space.
  2. Separate program has been used to generate data in form of characters for sprite data.
  3. By design, digger should not be able to move left-up or right-up diagonals when the targeted position is still uncovered and ladder is not present on the actual position. I didn't find space to check if the desired position is above digger's current position in line 7. In such case, it should result in going to line 2. Instead, in case of earth (`E=3`) it goes straight to line 8 that updates digger's position. Anyways, it's not a big deal. Thanks to Dan's pick, he's able to get one level above when digging a new hole. It's really a good pick! I tell you!
  4. This is the second iteration of this game written fully on the real hardware. I lost the first draft version as for some reason the Vice emulator I used on Mac didn't overwrite the file on d64 image. But thanks to that, this implementation works much better. In the version I've lost, digger moved immediately to a field where diamond was located. It was hard to notice that a diamond was found there, so I knew I will need to fix it. In this version, digger won't move to a field if diamond is found there. So, this issue has resolved by itself, it wasn't my design decision. Anyways, rewriting the whole thing straight from my head (it's just 10 lines of code, right?) took me 1,5 hours only, so I will always recommend to design something at least twice.
  5. Basic Abbreviator (still in alpha version) assisted in writing of this game.

StatusReleased
PlatformsHTML5
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
AuthorCommocore
GenrePlatformer
Tags10liner, basic, Commodore 64

Download

Download NowName your own price

Click download now to get access to the following files:

dan-the-digger-10.prg 752 bytes

Comments

Log in with itch.io to leave a comment.

(+1)

That thing about writing a part or a lot again has happened to me several times and apart from the regrettable loss, one does it much better and faster with better results, it is incredible.

Totally! I wonder how our projects could look in the end only if there would be a natural order etc. that the first design is always lost. Without forcing it, it's hard to imagine re-writing something when the first design just works.

(+1)

Nice game!

Thanks, Saberman! Really appreciate your comment! That you're still on the post for all game releases (actually not only for C64!) is simply unbelievable! Gorące pozdrowienia! C64 wiecznie żywe!!!

(+1)

Simply amazing for PUR-80! Looks so cool.

Thanks a lot, Roman! This simple idea came to my mind one day, and I knew I have to try it out. It was fun making it, even though I lost the first version of it (see: Tricks and notes, point 4).