Lunar Lander - by David Nowotnik ZX Computing, October/November 1985, p.88 ZX851011_021088LunarLander.mdv ========================================================= Program & information typed by Jim Waterman, October 2020 ========================================================= File on microdrive: land_bas ========================================================= BUGS: For some reason that is far beyond my knowledge of how the QL works - despite the explanation in this article - on QLAY 0.90, the UDGs do not show up, but they *do* show up when using QemuLator 3.3.1. I have tested it with the JM and JS ROMs on both emulators. (excerpt from the main body of the text:) Having created one or more UDGs, then these new characters have to be transferred to the application program requiring them. An example of this appears in the program in listing 2. This is a lunar landing program, in which the UDGs provide the shape of the landing vehicle. Full game instructions appear with the program, and it's quite fun, as well as being a good example of UDGs! The UDGs are set up in their own procedure (Line 1000 onwards), in which space is reserved (Line 1040), and the bit pattern start address is defined (Line 1050). Channel 4's 'extra' character set vector is changed to the new start address (1060), and the table contents POKEd into position (1070-1100). It's worth making some comment about the layout of the character bit pattern table. The first byte of the table contains the character code of the first character in the table *minus 1*. In the 'Lander' program it is 127, as the first character is 128. The second byte contains the number of characters whose bit pattern is defined in the table; fifteen in this example. The next nine bytes make up the bit pattern of the 'default' character - that is, the character which is printed on the screen if you try to print an 'illegal' character. Finally, we get round to the bit pattern of the UDGs, which follow the default character in blocks of nine, in ascending numerical order. The first block of nine defines character 128, the next nine, 129, and so on. The numbers that are POKEd in, in each block of nine, are those which appear in the UDG designer program, and they are POKEd into the bit pattern table in the same order as they appear on the screen in the designer program. So, you should now have all the information necessary to design and use UDGs in your own programs. Before I close, there are a couple of additional features of 'Lander' (nothing to do with UDGs) which programmers might find of value. The simple statement in line 3270 sets the internal clock to zero, to make the start of the game. The duration, in minutes and seconds, then gets printed onto the screen using a substring (DATE$). For the calculations involving time, it was necessary to have at least a tenth of a second accuracy; the internal clock was inadequate for this, as it has one second as its smallest unit. The program makes use of the QL's frame counter, which increments every 1/50th of a second. The frame counter is at address 163886, and is a 'word' (two bytes) in length. Having set the frame counter to zero (line 3280), it is then possible to PEEK_W the frame counter to determine the number of 50ths of a second which have elapsed.