Individual cell paper and pen in MODE 2 and MODE 4 via BASIC
Hello all,
I'm usually a Spectrum user, but with more time on my hands I have been looked at the SAM Coupe, and looking at the four screen modes and was was wondering how you set the individual cell paper and pen in MODE 2 and MODE 4 via BASIC?
The screenshot of the manual page and my very simple example code is on my Spectrum Computing Forum.
https://spectrumcomputing.co.uk/forums/viewtopic.php?f=31&t=4091
Thank you.
Hi
For character printing just setting the PEN and PAPER before printing a character will do it in any mode but only for the character, MODE4 is has no attribute cells as it is bitmapped with a nibble per pixel (2 pixels per byte) [EDIT: same for MODE3 but with 2 bits per pixel, 4 pixels per byte)] and MODE2 behaves as it does on the speccy so you the cells will inherit the attribute of the last plotted pixel or you can POKE them directly.
From the Technical Manual:
You can see how the POKEing the screen memory works in different modes with something like this, this one pokes the upper nibble with 16 so in MODE4 you get alternate bright white and black pixels - or for somthing more fun POKE it with RND*255 which will affect more pixels depending on the mode and get nice and trippy when you hit the attribute area in MODE1 and 2 :)
Thanks
Thanks Dan,
Most useful. I read with Mode 2 the ATTR command just looks at the top row of the equivalent 8x8 cell, but you can peek the screen memory to find the attribute at any 8x1 section in mode 2. Where does that screen memory start?
Please see text here (sorry, can't see how to include images in post. Tried the <img> html tag.
https://i.ibb.co/G0y7jP2/Mode2.png
Screen address
The variable SCAD in Dan's example stands for 'SCreen ADdress', it reads the value of the video memory page register (port 252), discards the upper non-page bits with band (= Binary AND) 31 (= binary %00011111) leaving only the page part. Subsequently 1 is added (since BASIC maps addresses 0-16383 to ROM0) and this is multiplied by 16384 to get the address that BASIC uses.
To get to the attributes you then need to add 8192 (as per the manual) to get to the attributes section.
Thanks
Thanks Stefan.