Decided I need to start getting some real code laid down, rather than just experimenting with things.
So I have started with the code to draw the game screen, so I am now learning about BORDER, PAPER, INK, and BRIGHT, etc. Also the Spectrum screen is split into two sections. The top part is 22 Lines and the bottom part is 2 Lines. I want to use the last two lines but PRINT AT doesn’t reach down there.
Lesson: Don’t go poking around with the System Variables when you have unsaved code!
I have changed the variable ‘return’ to just ‘ret’ to avoid issues with BASiN and potentially the Spectrum interpreter itself.
I vaguely recall reading somewhere that the bottom of the screen is accessed via channel 1.
And this printed the ‘*’ at the bottom, however it was right at the bottom, ie. the 24th line and not the 23rd line that I wanted. Reading through the character set (Appendix A) I found that CHR$(22) was ‘AT control’ so I tried the following which luckily does what I wanted:
PRINT #1;CHR$ (22);CHR$ (0);CHR$ (0);"*";
By changing the values in the two CHR$(n) sections I can effectively PRINT AT on the bottom part of the screen.
To simplify things I have created a Function using DEF FN to generate the 3 CHR$:
DEF FN p$(x,y)=CHR$ (22)+CHR$ (y)+CHR$ (x)
It seems that FN definitions can only be single letters (making them fairly limited) and you need to remember if it is returning a string that it needs the $ at the end.
Another thing I have discovered is that though I am using the BRIGHT 1 statement, the items I am printing in the bottom portion are not, and in fact apart from the PAPER the rest of the Attributes are wrong.
The solution is to again use special control codes printed to channel 1, however you cannot pre-setup the attributes and need to output the control characters at the beginning of each print to channel 1.