Hello Screen2: VDP programming for MSX1

Gilbert Francois Duivesteijn

< Back to main page

The goal of this page is to show how to create graphics in screen mode 2. The examples in this page are the very minimum to create a tile, an 8x8 pixel sized block and copy the tile 2 times more using the pattern name table.

For more in-depth information about the code itself, read Hello Screen2: VDP programming for MSX1. This page is more focussed on how to develop it on a real MSX with Champ. There are download links for the source code (in Champ format) and binary at the bottom of the page.

But first....

First read this and avoid problems later! Since Champ is running on the MSX, the same machine as your test code is running, you have to take care of the following facts:

Let me give an example with comments:

 

In Champ, it will look something like in the screenshot below, where the 3 NOP instructions are a placeholder for your program.

champ

Implementation of Method 1

Here, the code example of Hello Screen2: VDP programming for MSX1 using method one is shown, how to enter the code and run it using Champ.

Type in the listing. Note that there are slight differences between this code and the one from the other "Hello Screen2" tutorial. First, Champ cannot have binary numbers. The data for the pattern PAT0 is in HEX. Second, when having arithmetics in the code, like in line containing LD HL, $1800 + $41, only one + or - sign is allowed. Third, at the end, a ENDPROG label is added. This will help later when saving the binary to cassette. When you don't want to type the code in yourself, you can download the source code on the bottom of this page.
In <assemble> mode, press S and give a filename to save the source to cassette.
In <assemble> mode, press A,2. Note that the label ENDPRG shows the address we need later.
Let's test and run the program. Press G C000 where C000 is the start address of the program.
When all goes well, you will see the 3 tiles drawn in screen 2. Press any key to finish the program and to return to Champ.
It all seems to work well. Let's save the binary by dumping the block of memory to cassette. For that, we need to know the start and end addresses of the program. Since we made it easy for ourselves by adding a ENDPRG label at the end of the program, we can simply ask for the address by pressing H ENDPROG.
Make sure you have a cassette with free space on it and type: W C000 C04D HS2BIN. The file will be saved to cassette.
Reset the computer, rewind the tape and test the program if it runs. Type bload"cas:",r and wait what happens...
Success! Your program is ready to be shipped :)

In the next tutorial, we will look deeper into Champ on how to use the debugger and monitor.

Resources