Author: Jonathan Harston Category: Christmas Challenge System: Any system that can run BBC BASIC with POS and VPOS implemented Language: BBC BASIC Source length: 160 bytes Executable length: 160 bytes Instructions: On any system that can run BBC BASIC where POS and VPOS is implemented, load into BASIC and run. Demonstrated with BBC BASIC on Apple IIe, BBC Micro, Windows, Commodore 64, Amstrad CPC128, PC-DOS, PDP11 Copro, UKNC/Electronica, ZX Spectrum. Description: If the code is expanded out as: 10 REM > XMAS2022a 20 PRINT CHR$8;:W=POS/2-8 30 REPEAT:H=VPOS:PRINT:UNTIL H=VPOS 40 CLS:PRINT STRING$(H/2-9,CHR$10) 50 A$="453627180944434241" 60 FOR L=-16 TO 16 STEP 2 70 A=VALMID$(A$,ABSL+1,1) 80 B=VALMID$(A$,ABSL+2,1) 90 PRINT SPC(W+A);STRING$(B,"*");SPC(2*(9-A-B)-1+B/5);STRING$(B-INT(B/5),"*") 100 NEXT Printing CHR$8 backs off the left side of the screen and onto the right side on the next line up. Reading POS tells us that column, and dividing by two gives the centre of the screen. Subtracting 8 is half the width of the 17x17 star and gives the indent to centre it. We then enter a loop, reading the vertical position with VPOS and then doing a blank print to move to then next line. We loop until VPOS remains the same because we've got to the bottom line. We clear the screen and print enough blank lines to align with the first line we want to display the star, again baring in mind that the star is an odd number of characters in size. The star is symetrical in four directions, two of which can be usefully used. The right side is a reflection of the left side, and the bottom is a reflection of the top. A slight complication arises in that the star is an odd number of characters in size, so the one-character centre lines needs dealing with. A$ is set to a string of nine pairs of single-digit values. These values are the number of spaces and stars to make each line on the top-left corner. The value pairs are in reverse order so we can scan through twice by counting from a negative offset to a positive offset, and taking the absolute value. We loop through the string in A$ and read out the values from it. This is an example of "data without DATA", being able to use some fixed data in a program without having to read it into variables. Another example is: MID$("SunMonTueWedThuFriSat",day%*3-2,3) The first value is the number of spaces to output, we add that to the indent to centre the line. Next is the number of stars. A bit of arithmetic works out the number of spaces between the stars on the left and the stars on the right, then the stars are repeated, each time adjusted to reduce by one to get an odd total number. The loop passes through the data twice, backwards then forwards, which gives the bottom half as a reflection of the top half.