I've been rather busy with work lately, so I've not had much chance to work on BBC BASIC. That said, I've added some features.
The COLOUR statement can be used to change the colour of text. If the most significant bit is set it changes the background colour, if reset it changes the foreground colour (that is, 0..127 set the foreground colour and 128..255 set the background colour). Currently any non-zero colour is taken as black, but I'm going to recommend 127/255 are used as black for future compatibility (eg a future greyscale mode might have 0..31 as white, 32..63 as light grey, 64..95 as dark grey and 96..255 as black).
Americans, have no fear, as this version of BBC BASIC also supports the COLOR statement. (However, it doesn't have XOR, sticking to the British EOR).
The above screenshot also demonstrates the useful LIST IF statement, which can be used to search for keywords or strings in program lines when LISTing.
This screenshot shows a feature borrowed from the BBC Micro: copy key editing. By pressing a cursor key when entering a line of code, the cursor splits into two - a read cursor and a write cursor. The write cursor remains on the end of the line you were editing (a solid block), but the read cursor can be moved to any location on the screen. Pressing the COPY key (in this case, I've commandeered the XTθn key for this purpose) reads the character that is under the read cursor and copies it to the write cursor, then increments both.
I've also implemented ADVAL, which lets you poll a mouse connected to your calculator. Most of the work I've done recently has been compiling the documentation together, though, so here's a snippet:
ADVAL positive argument
If the argument is positive, ADVAL returns a value related to the distance that the mouse has been moved.
- ADVAL(1) returns the distance travelled in the X-direction.
- ADVAL(2) returns the distance travelled in the Y-direction.
- ADVAL(3) returns the amount that the scroll-wheel has been rotated.
The value returned corresponds to the total distance travelled in a particular axis since the last time that axis was checked using ADVAL.
Code: Select all
mouseX%= 0
mouseY%= 0
REPEAT
mouseX%= mouseX% + ADVAL(1)
mouseY%= mouseY% + ADVAL(2)
UNTIL FALSE
ADVAL zero argument
ADVAL(0) returns a value in the range 0 to 7 corresponding to the state of the three mouse buttons. You can check the state of individual buttons using the AND operator.
Code: Select all
buttons%= ADVAL(0)
leftPressed%= buttons% AND 1
rightPressed%= buttons% AND 2
middlePressed%= buttons% AND 4
Another addition is *REFRESH; a useful one copied from BBC BASIC for Windows. Normally, drawing commands output directly to the LCD; by stating *REFRESH OFF only the graph buffer is updated. You can then copy the data to the screen by calling *REFRESH, or *REFRESH ON to restore the original behaviour.
Fortunately, BBC BASIC calls an entry point in the host interface prior to displaying errors, so we can make sure that *REFRESH is back ON, the text isn't the same background and foreground colour and the screen is on (and so on and so forth) before displaying error messages.
![Smile :)](./images/smilies/grayscale_smile.gif)