Videopac G7000 BIOS
Last changed: 2003-07-22

Other useful routines not yet explained

In this section I will explain several useful routines which I have not used in any of the demo programs.

Routines for characters

The first routine is very simple, it is called clearchar and clears all characters. This means all characters on the screen disappear. The grid, sprites and quads are not affected.

If you look at the description for the character registers you will see that byte 2 and 3 are not easy to calculate, but fortunately there are several routines for that in the BIOS. At first there is calcchar23, you feed it with the Y position in R4, the character to display in R5 and the color in R6. It tells you what to put into byte 2/3 in R5/R6. A very similar routine is putchar23, it is a front-end to calcchar23 and puts the register data into the registers, so it needs a pointer to a character register byte 2 as additional parameter in R0. Another front-end for calcchar23 is tablechar23, it puts the register data into a table, the order of the bytes is reversed.

Routines for tables

There are some more routines which deal with tables in the BIOS, the simplest one puts a 2 into the table at R0. It is called tableput2. Then there is tablebcdnibble. It puts the lower nibble of A as a BCD number into the table for use as a character. The length and start register have to be put into the table manually before calling tablebcdnibble. There is a front-end to tablebcdnibble called tablebcdbyte. It initialises the table, processes the parameters, ends the table and activates it. The BCD number to display has to be put into A, a pointer to the first character into R1. As usual the screen position is in R3/R4 and the color in R6.

Routines for mathematics

There is one routine for multiplication and one for division in the BIOS. They are called multiply and divide. Both use repeated addition/subtraction, so they are not very fast. The results are limited to 8 bit, there are no checks for overflow, so be careful with the results.

Routine for initialisation

There is one routine which initialises nearly everything called init. It can be used if you don't want to display the "SELECT GAME" message. Just make sure to switch to RB1 before using it if you want to use the standard IRQ routines or other routines which switch register banks, there are several. If you use the keyboard routines put 0FFh into R7 at RB0 first.

Routines for random number generation

There are two routines which can be used to generate random numbers. They use the T register for this purpose, so you have to start the timer with STRT T once at the beginning. This implies you can't use the line interrupt, the random numbers would depend on the screen position where you get them. The routine called random generates two random nibbles in R2 and R3=A. Before you call this routine you have to set R2 and R7 to the 1's complement of the biggest number you want to get. The number returned in R2 is less or equal to the 1's complement set in R7, the number returned in R3 is less or equal to the 1's complement set in R2. Note that the number in R2 does not depend on what you put in there before the call, thats R7.

There is a helper routine called nibblemixer which takes a nibble in R5 and mixes it until it is less or equal to the 1's complement of R7. For this purpose it uses a ROM table starting at 02B3h. This routine does not depend on T, the result is always the same.

This routines are not very useful, you should better implement your own random number generator eg. using primitive polynomials (also known as LFSR).

This routines are not available on the Videopac+ G7400 which is just another argument against them. This incompatibility is the reason why Videopac 5 (Blackjack) hangs when shuffling the cards.