Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The border.s file is an example of transitioning for assembly

  • The gen.py file is an example of transitioning in BASIC

Safe BASIC access to screen+colour memory (T@& and C@&)

As an alternative to directly peek’ing and poke’ing hardcoded addresses for screen memory and colour memory in your BASIC programs, a safer alternative is to use the T@& and C@& arrays.

Writing examples:

  • T@&(5,0) = 1 (place the letter 'A' at column 5, row 0)

  • C@&(5,0) = 2 (set the color to red for character at column 5, row 0)

Reading examples:

  • PRINT T@&(0,0) (print the screen-code value of the character at column 0, row 0)

  • PRINT C@&(0,0) (print the colour-value of the character at column 0, row 0)

Obtaining base address of screen and colour memory:

Code Block
10 TR=WPEEK($D060) + WPEEK($D062) *65536  : REM SCREEN MEMORY BASE
20 CR=$FF80000 + WPEEK($D064) : REM COLOUR MEMORY BASE

Bit Shifter’s example

How to PEEK or POKE screen text RAM and attribute (colour) RAM.

This example program shows, how the base address of text and attribute can be obtained to be used in PEEK and POKE.

This method works on old and new ROMs regardless of the current setting of colour RAM base address.

The first lines show the access with the special arrays T@& and C@&, that avoid the usage of PEEK and POKE.

...