Labirint

I considered some kind of labyrinth a must for this series. The problem was not to implement game rules or even to generate a random maze, but to do it reasonably fast so player won't fall asleep while program draws maze. I decided that regualr spatial maze should be combined with a time measurement, since just passing through maze where all passes can be clearly seen seems trivial. As a consequence, program was supposed to be restarted many times, so it was very important to fill the screen quickly.

Rules


Run from upper left corner to bottom right as fast as you can.

Labyrinth will be the same every time, so you have chance to try different ways.

Code and comments


Download the original LABIRINT.NSG code or version for international character set.

Major trick here is to use machine code subroutine to fill screen with random noise. Subroutine is placed in string variable T$ and DEFUSR statement initialises user function to whatever this variable's descriptor points to. Subroutine is written in a way that would allow it to execute at any address (the picture on the right shows it placed at address 0x100).

It scans ROM starting at predefined (0x187) address and prints a code for filled block (0x9b for MSX in question, should be 0xDB for "international" codepage), for every byte that is less than threshold (0x79) or space otherwise. I had to play with starting address and threshold to find decent looking screen. It can be different for different MSX, but I guess, BIOS area is always the same.

I cannot quite remember what BIOS call to 0x7F4 does. Probably it is “set start VRAM addres for writing” or something like that.

Other minor tricks include


[ MSX BASIC | << Previous | Next >> | Feedback ]