# Chapter 8 – Starcharts (Star Graphics)

## Star Graphics

This short demonstration program shows how more complex shapes can be constructed for incorporating into starmaps. These images would represent the brightest stars to be displayed and as such should have geometric forms.

The program
The program is divided into three parts as indicated by the REM statements. The first part to Line 7 copes with the selection of images numbered 1 to 4 via the INKEYS command in Line 3. Line 8 contains two GOSUB commands — the first is conditional on the selection:

GOSUB 100 or 200 or 300 or 400

in the form GOSUB a x 100 where a equals the VALUE of INKEY\$ from Line 4. At the appropriate GOSUB line, the selected star form is PLOTted and DRAWn according to its shape. The program then RETURNS to Line 8 for the second GOSUB (GOSUB 1000).

The third and final section of the program from Line 1000 uses the POINT command to scan the star image just PLOTted and enlarge it for easy viewing. Two FOR/NEXT loops are used (n and f) to cover the tiny area of the screen adjacent to the x and y coordinate positions of the small star image. Lines 1010 and 1020 take the form:

1010 IF POINT (x + n, y + f) = 1 THEN PRINT … “CHR\$143”
1020 IF POINT (x + n, y + f) = 0 THEN PRINT … “CHR\$58”

If POINT equals a value of 1 then PRINT a solid INK square character (ie a pixel is PLOTted at this location). Conversely, if POINT equals a value of 0 then PRINT a colon (ie a pixel is not PLOTted at this location).

Line 1020 is not really necessary to define the star shape but it does help to locate its relative position by marking the unPLOTted points. The program then RETURNS for the next selection.

Further star shapes can be included in the program, starting at Line 600 in steps of one hundred (700, 800, 900, and so on). This is to satisfy the conditional GOSUB in Line 8. The value 4 currently set in Line 3 and Line 5 should be amended for each additional shape included in the program. The final statement in each new PLOT and DRAW section must conclude with RETURN.

It is useful to sketch the new star shapes on squared paper before committing them to the program but it is not essential. You can simply start with a PLOT x,y condition and then add DRAW commands (preferably with quite small values — certainly no greater than a value of 6) and RUN the program to test the new design. If it is unsatisfactory then change it. The aim should be to contain all the new design within the portion of the screen scanned by the POINT command and displayed in enlarged form.

Incorporating results in a starmap program
A subroutine virtually identical to this program could be incorporated in a starmap program to represent some of the brighter stars. Only Lines 100 to 499 (plus any extra lines for your own designs) are required in such a subroutine together with some control lines to make the subroutine work. These would be in the main program area dealing with PLOTting the stars and could take the form:

star PLOTting routine where x and y are star coordinates.
IF n = 1 THEN GOSUB 400 : REM mag 0 star = brightest
IF n = 2 THEN GOSUB 100 : REM mag 1 star
IF n = 3 THEN GOSUB 300 : REM mag 2 star
IF n = 4 THEN GOSUB 200 : REM mag 3 star
If n > 4 THEN PLOT x,y: REM mag 4 are PLOTted as a single pixel and represent the faintest stars.

These conditional sample lines shown above are only one example of what could be used in the program. The permutations are endless. Suppose for example that the first three stars are to be magnitude 0 (the brightest) in each constellation of the starmap and the next two stars of magnitude 1, then the routine would read:

IF n<4 THEN GOSUB 400: NEXT n: REM mag 0 stars 1 to 3
IF n<6 THEN GOSUB 100: NEXT n: REM mag 1 stars 4 and 5
If n=6 THEN GOSUB 300: REM mag 2 star 6

and so on through the sequence as required. Note that the first two conditional lines must include the statement NEXT n so that the program does not proceed beyond that line until the condition is satisfied.

Figure 8.14
Typical shapes to represent brighter stars on computer starmaps. Shown enlarged here for clarity. The POINT command, via two FOR/NEXT loops, is used to scan the actual (tiny) images to the left of each sample which are used in the final starmaps.

2 PRINT “Star Graphics “;
3 PRINT “1 to 4=”;INKEY\$
4 PAUSE 0: LET a=VAL INKEY\$
5 CLS: IF a>4 THEN RUN
6 LET x=99: LET y=80
7 PRINT AT 0,21;a
8 GO SUB a*100: GO SUB 1000
9 PRINT AT 0,0;: GO TO 1
100 PLOT x,y: DRAW 2,2
110 DRAW 2,-2: DRAW -2,-2
120 DRAW -2,2
199 RETURN
200 PLOT x,y: DRAW 0,2
210 PLOT x+1,y+1: DRAW -2,0
299 RETURN
300 PLOT x,y: DRAW 1,1
310 DRAW 1,-1: DRAW -1,-1
399 RETURN
400 PLOT x,y: DRAW 4,0
410 PLOT x+2,y-2: DRAW 0,4
420 PLOT x,y-2: DRAW 4,4
430 PLOT x,y+2: DRAW 4,-4
440 PLOT OVER 1;x+2,y
499 RETURN
1000 FOR n=0 TO 5: FOR f=0 TO 5
1010 IF POINT (x+n-1,y+f-2)=1 THEN PRINT AT 10+f,16+n;CHR\$ 143
1011 IF POINT (x+n-1,y+f-2)=0 THEN PRINT AT 10+f,16+n;CHR\$ 58
1020 NEXT f: NEXT n: RETURN