Computer / Programmazione / Z80 · 15 June 2019 0

LM80C: VPOKE & VPEEK

In the last days I’ve worked to expand the commands and functions of NASCOM BASIC by adding VPOKE & VPEEK.

VPOKE is a command that, as you can understand looking at the name, lets you write a value into a specific VRAM cell. VPEEK is a function that, obviously, reads a byte from a VRAM cell. These two are necessary because the LM80C firmware manages the cursor through an interrupt raised by a timer of the Z80 CTC: due to this way of working, at regular intervals the main code flow is interrupted and the cursor management code is executed. Since the VDP has a data buffer for reading and writing from/to the VRAM and since it also has an auto increment counter that, after the first read/write, automatically increments the address pointer, if you use OUTs and INs to write/read to the VRAM, you will experience glitches and graphical artifacts because the read/write operation you are making could be interrupted in the middle of its run by the cursor manager: this will lead to collisions between the two codes that make a VRAM access through the VDP and unpredictable side effects, like random chars that could appear on the screen or wrong data written into memory.

VPOKE & VPEEK avoid this, since they disable interrupts before accessing the VRAM and re-enable them after they did their work. In the video below you can see the new statements in action:

The new firmware is marked R1.8 and is available for download from my Github repo.