============================================ NEXT-A-SKETCH for Spectrum Next (and CSpect) By Jim Waterman, 16-19 January 2023 ============================================ As part of my learning process of Next BASIC, it's a good job that there's a real Next owner (well, N-Go owner, actually, but it works the same way) running this year's CSSCGC so that I have somewhere to send my initial efforts. I have warned Jamie Bradbury I was going to do this, and here's the first instalment of that saga. I ran my 2021 competition on the grounds that I was the editor of Sinclair Programs (or any similar listings section, such as Open Forum in Popular Computing Weekly) and judged each entry on whether or not it would make it into the pages of my hallowed magazine. And it is on that basis that I justify this absolutely-not-a-*game* for entry into the CSSCGC. There were a couple of listings for Etch-a-sketch programs in these magazines - it's hardly a difficult job, just controlling a PLOT point on screen (unless you're trying to do it on a ZX80, then it's a whole barrel of headaches...). The first was Utility Draw, written by Peter Safranek and sent to the January-February 1983 issue of Sinclair Programs: https://archive.org/details/sinclair-programs-05/page/n31/mode/1up?view=theater A. Brahmbhatt and K. Brahmbatt looked at Utility Draw, and they saw that it was good... but not good enough, so they wrote their own improved version, Super Draw, and sent it to the July 1983 issue: https://archive.org/details/sinclair-programs-09/page/n32/mode/1up?view=theater If anyone wants any further justification, there's already been a similar entry: Peter Murray's Etch-a-Sketch Simulator, sent to Jim Langmead's 2004 competition. https://www.yoursinclair.co.uk/csscgc/csscgc.cgi?search=EtchASketchSimulator.tap&year=2004 I wonder if anyone looked at these programs, and thought "I wish there was an even more enhanced Etch-a-Sketch program, on a more advanced machine - such as the SAM Coupé, that doesn't have any colour clash, and has even more colours to play with! And while we're at it, let's have loads more ridiculous features such as drawing a hexagon, and an arc that has its maximum start and end point calculated accurately so that it fits anywhere on the screen even where a whole circle wouldn't! And it's on a machine that runs at eight times the speed of a Spectrum! And it won't take all day to save the screen!" Someone must have rubbed the lamp and the genie shot out and granted... the first of those three wishes, at least. I am your genie and I bring you... NEXT-A-SKETCH! It is packed with features. Utility Draw was a mere 1,314 bytes. Super Draw was 3,036 bytes. Etch-a-Sketch Simulator was a mere 824 bytes. Next-a-Sketch is... 24,991 bytes* of sophisticated, mostly-procedural Next BASIC (with quite a lot of errant GOTOs that QL programmers snarl at... but this isn't a QL). I don't do things by halves. All that remains is to tell you how to use it. The program runs on the 256-colour, clash-free LAYER 2. To start, define your initial paper and ink colour. These are shown on screen along with the HTML code of each colour. The palette entry can be worked out from its RGB value thus: Red and green have eight intensity levels: 0 = #00, 1 = #24, 2 = #49, 3 = #6D, 4 = #92, 5 = #B6, 6 = #DB, 7 = #FF. Blue has four intensity levels, as the human eye is less sensitive to blue: 0 = #00, 1 = #6D, 2 = #B6, 3 = #FF (levels 0, 3, 5 and 7 of the red and green). And the equation is: Palette entry = 32*red + 4*green + blue. There's also the transparency, which is initially set to palette entry 173, a disgusting salmon pink that nobody in their right mind would ever want to draw with. Note that on the starting screen it is NOT transparent, so that you can see how awful it is, and it is NOT the Next's default transparency (palette entry 227, "bright magenta", #FF00FF - a native Spectrum colour). You only get one chance to redefine the transparency colour, so get it right. This is because I tried to add a feature to change the transparency on the fly, but there was no way of making it work (at least, not without machine code which I haven't yet attempted on the Next). LAYER 2 starts out as a blank canvas filled with the transparency colour, with LAYER 1,1 underneath set to show the chosen paper colour. This way, the paper can be changed, and it'll change on the whole screen, instantly. Once you've done with your initial setup, you can get drawing. Directional controls -------------------- Use the eight keys around S (Q,W,E,A,D,Z,X,C) to draw in the eight compass directions. The cursor keys will also draw in the four straight directions. The cursors won't draw diagonally in combination with each other - this is deliberate, so that mistakes aren't so easily made. Colour controls --------------- I = input a new INK as a direct value, i.e. its palette entry. J = input a new INK by its RGB levels (0-7 for red and green, 0-3 for blue). P = input a new PAPER as a direct value. L = input a new PAPER by its RGB levels. O or 0 = switch ink eradicator on or off (i.e. INK switches between itself and the transparency colour). Position controls ----------------- S = view the current coordinates (at the centre of the diagonal-movement block). M = move the current coordinates to a specified point. K = move to the centre of the screen (128,96). F = store the current coordinates. R = recall the stored coordinates (initially set as the centre of the screen). Geometric shapes ---------------- H = draw a circle; input the centre and radius. Y = draw a square; input the top left corner and side length. U = draw a rectangle; input the top left corner, width and height. T = draw an equilateral triangle; input the highest point and side length. B = draw a five-pointed star; input the highest point and side length. N = draw a cross (+ sign style); input the leftmost corner of the top edge, and side length. G = draw a regular hexagon; input highest point and side length. Anything else ------------- 2 = draw a line from one pair of coordinates to another. 3 = draw an arc; input the centre of the circle of which it is a part, and the initial and final angle in degrees, clockwise from due north. BEWARE: though the angle range is shown on screen, using a value at either extreme might still cause the end of the arc to be drawn off screen, and the DRAW command will go haywire. This feature accepts fractional input, so give it half a degree's leeway at least. You have been warned! V = clear the screen... after a prompt to make sure. 1 = view the instructions on screen, in a condensed form that fits onto a LAYER 1,2 screen. 9 = save the screen to an .SL2 file. WARNING: IT TAKES FIVE MINUTES TO DO THIS! See, I told you the genie didn't grant the wish of a short save time. This is because the background layer (1,1) needs to be manually merged into the drawn-on layer (2). There is bound to be a better way to do this (probably with machine code), but that's for another time. Have fun, or don't. Party like it's 1983 and you're a kid again and you've just drawn on the TV screen with wax crayons. * Some extra procedures have been left in the code. They're for features that were removed because I couldn't get them to work, mainly the ability (or not) to alter the transparency while using the program, and if there's ever a version 1.1 of this program, I might have learned enough techniques to be able to put them back in. Don't hold your breath, though, or you'll die, and I will not be held responsible for that. - JRW 20/1/2023