One final splash of colour

[Inspired by this article on Bob’s 8-bit blog]

This was going to be a short post: the ZX81 does not allow for the screen border to be colored.

But I decided that this would be a good opportunity to put all the things we’ve learned so far together, and draw a frame around our display zone.

        LD A, (FRCOL)
        LD C, A
        LD B, 32
        LD HL, (D_FILE)
L0:     INC HL
        LD (HL), C
        DJNZ L0
        INC HL
        LD DE, 31
        LD B, 22
L1:     INC HL
        LD (HL), C
        ADD HL, DE
        LD (HL),C
        INC HL
        DJNZ L1
        INC HL
        LD B,32
L2:     LD (HL),C
        INC HL
        DJNZ L2
        ret
FRCOL  defb 0x80

We reserve one byte to put the color of the frame we want to draw (0x80 is for a black square):

FRCOL defb 0x80

The program starts by reading the content of this byte and load A with it:

LD A, (FRCOL)

The program is pretty straightforward. We draw the top line of the frame, then for 22 line, we draw the first char, skip 31 char, and draw the last char of the line. We finish by drawing the bottom line of the frame.
Changing the frame color is only a matter of changing the value of FRCOL. Try it out!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s