Site logo

Triceraprog
La programmation depuis le Crétacé

VG5000µ, Video Memory Layout ()

This post is in English following request for assistance on System.cfg forum for details on how to access the Video system on the VG5000µ. As most of the reference is in French, here's an explanation of the video memory layout when running the BASIC System. A French version of this article will follow shortly.

For starters, the video processor on the VG5000µ is EF9345. There's a possibility to access it directly to leverage all its power, but the simplest way, when under the BASIC System, is the work with the RAM.

The Blank Start signal of the video processor is connected to the interrupt pin of the Z80, thus triggering an IRQ which, under the interrupt mode the BASIC initializes the Z80, calls address 0x0038 as an interrupt.

The IRQ routine uses flags to decide is the RAM content should be sent to the EF9345 considering 0x47FA (counter down to 0), 0x47FB (force refresh if not 0), 0x47FC (reference value for 0x47FA). In BASIC, this corresponds to the DISPLAY command.

If the refresh is triggered, then the Video Memory is decoded and transferred to the EF9345. To check how it's done, on a version 1.1 BASIC, this really starts at 0x0056, jumping to 0x00bc and ending in 0x018b. Register ix is always 0x47fa when running the BASIC, this is to know to understand where the display variables are fetch from (don't temper with ix if you want to let the BASIC system handle video, or do it with interruption disabled).

Video RAM is standard RAM not wired in any particular way, if you want to take control of the display and put it anywhere and in any format you want. The layout used by the BASIC ROM starts at 0x4000. The line/column layout is as follow:

Offset (decimal) Column 0 Column 1 Column 2 ... Column 38 Column 39
Ligne 0 +0/+1 +2/+3 +4/+5 ... +76/+77 +78/+79
Ligne 1 +80/+81 +82/+83 +84/+85 ... +156/+157 +158/+159
Ligne 2 +160/+161 +162/+163 +164/+165 ... +236/+237 +238/+239
...
Ligne 24 +1840/+1841 +1842/+1843 +1844/+1845 ... +1916/+1917 +1918/+1919
Ligne 25 +1920/+1921 +1922/+1923 +1924/+1925 ... +1996/+1997 +1998/+1999

Every displayable unit is encoded into a pair of bytes. The first byte is mainly the character code, the second byte contains mainly the attributes. Character set is selected by a bit in each byte.

First byte of the pair has this layout:

Bit 7 6 / 5 / 4 / 3 / 2 / 1 / 0
Content N (0)/E (1) character number

The second byte of the pair has this layout:

Bit 7 6 5 4 3 2 / 1 / 0
Content TX (0) Reverse Width x2 Height x2 Blink Color
Content GR (1) Background ... ... ... color Blink Foreground Color

With N/E (Normal/Extended) and TX/GR, the selection of the character set is made. This corresponds to the various graphic selections in BASIC. Normal TX is TX, Extended TX is ET, Normal GR is GR, Extended GR is EG. Extended mode allows character redefinition. Normal text is ASCII, normal graphics is the Semi-Graphic character set.

As you can see, there's no way to specify a background color attribute in text mode. The background color is the latest background color as fixed by the previous graphic character attribute on the same line. That's why, when using the BASIC INIT command to clear the screen, every character in column 0 is set to an invisible graphic character with the clear color. And that's why the BASIC monitor doesn't use the first column.

Last note: EF9345 has much more capabilities than the layout implied by the BASIC Monitor. You can find on Internet resources that handles 80 column mode, or mode that the 7 colors. That needs a bit more work, as it needs to communicates completely with the EF9345 through 0x8F and 0xCF I/O ports.