Chapter 9 – Further Programs (The Messier List)

The Messier List, check out the fake comets
Telescope, the facts about telescopes, binoculars, cameras and astronomy
Star Tester, a quiz
Ellipses, various ellipses
Spectrum World Map, a map of the world in CHR$ CODE.

The following programs do not fit conveniently into previous chapters and have been gathered here. Although they are all diverse, I hope that you will find them interesting.

The Messier List

There is great kudos in having one’s name permanently applied to a heavenly body, but chance discoveries are exceptionally rare and an intimate knowledge of the night sky is really required if you are to have any hope of success.

Curiously, the French astronomer Charles Messier is renowned no longer for the many comets he discovered, but for his ‘Catalogue of 104 Non-stellar Objects’ (published in 1784) which forewarned the unwary against false claims: each object on the ‘Messier List’ is a remote deep-sky nebula or galaxy which appears comet-like in a small telescope or binoculars.

The program
The following program, designed around the ‘Messier List’, indicates how DATA can be stored economically in CODE form in string arrays. The program has two options:

  1. To list all 104 obj ects in numerical sequence with host constellation and type of object.
  2. To quiz the user as to where a random selection of these objects are to be located.

Good use is made of Spectrum colour to enliven the displays and to mark your score in the quiz mode. In the latter your initial title of ‘ASTRONOMER’ is slowly cut down in size for each incorrect answer!

Data store
The DATA is stored in the following manner:
a$ = 104 characters in the range 0 to 9 & A to Y (total = 35) for the 35 constellations hosting the 104 objects.
c$ = 35 constellation names to correct IAU abbreviations.
k$ = 104 numeric CODEs in the range 0 to 5 (total = 6 CODEs) for the class of object.

Unlike the non-standard ZX-81 CHR$ set (on which this program was originally designed), CHR$ 0 to 9 and A to Y are not consecutive in the Spectrum ASCII set (used for this book). Thus the a$ is handled in two ways to extract the DATA used in the variable z as follows:

270 IF CODE a$(n) < 58 THEN LET z = 1 + VAL a$(n): GOTO 290 280 LET z = CODE a$(n) – 54

Lines 410 and 420 work in a similar way. Consult your Spectrum Manual to see the values returned by various CODEs. The k$ is used to return a VALue used in the conditional GOSUB eg:

320 GOSUB 100 + VAL k$(n)* 10 ie GOSUB 100, 110, 120 etc.

and then PRINT the object type (eg ‘an open cluster’) and RETURN. Line 480 works in a similar way.

Figure 9.1
First page of the Messier List.
Messier_List

Figure 9.2
The screen display in quiz mode.
Messier_Quiz

RUNning the program
Once the program has been keyed in and RUNs satisfactorily as checked against the sample screen displays in Figures 9.1 and 9.2, it is worth remembering to set the CAPS LOCK. In the quiz mode lower case answers are unacceptable. If you need a little help and have aZX printer, the ‘Messier List’ can be COPYed a ‘page’ at a time with:

BREAK COPY ENTER

When the COPY is complete, press CONTINUE ENTER for the next page.

10 REM Messier List & Quiz
20 DIM b$(20): INK 9
30 LET y$=”ASTRONOMER”
40 LET a$=”S14PRPPOIIQIDIKROOIOOOOOOQWOA600TL
B222AU5JJ35MMCVH479OOGGVVVVP49EE3COON11XOLBJF
PUUCV9VV9VVYDM4EEU999UY7V”
50 LET c$=”AND AQR AUR CNC CVN CMA CAP CAS CET COM CYG GEM HYA HER LEO LEP LYR MON OPH ORI PEG PER PUP SGE SGR SCO SCT SER TAU TRI UMA VIR VUL PSC ??? ”
60 LET K$=”4222211422122221412412111132125551
111110144111115151222235555255551222221523542
2555555555502155535555015″
70 GO TO 200
100 PRINT “a Messier mistake!”
105 RETURN
110 PRINT “an open cluster ”
115 RETURN
120 PRINT “a globular cluster”
125 RETURN
130 PRINT “a planetary nebula”
135 RETURN
140 PRINT “a diffuse nebula ”
145 RETURN
150 PRINT “an external galaxy”
155 RETURN
200 INPUT “Messier List or Quiz (l or q)?”, LINE l$: CLS : PAUSE 1
210 IF l$”l” AND l$”L” THEN GO TO 360
230 PRINT TAB 10;”Messier List”
240 PRINT TAB 10;”************”: GO SUB 600
250 PRINT “No Con Code Type”
260 PRINT : FOR n=1 TO 104
270 IF CODE a$(n)<58 THEN LET z=1+VAL a$(n): GO TO 290
280 LET z=CODE a$(n)-54
290 LET j=VAL k$(n)
300 BEEP .01,j*10: PAPER j
310 LET x$=c$(z*4-3 TO z*4)
320 PRINT “M”;n;TAB 5;x$+a$(n)+””+k$(n);” “;
330 GO SUB 100+VAL k$(n)*10
340 IF n/5=INT (n/5) THEN PRINT
350 NEXT n: PAPER 7: GO TO 590
365 POKE 23658,8
370 LET c=0: LET w=0
380 FOR n=1 TO 10: CLS
390 LET r=1+INT (RND*103)
400 IF r=40 OR r=91 OR r=102 THEN GO TO 390
410 LET k=VAL k$(r): BORDER k: LET d=w
420 IF CODE a$(r)<58 THEN LET z=1+VAL a$(r): GO TO 440
430 LET z=CODE a$(r)-54
440 LET x$=c$(z*4-3 TO z*4)
450 PRINT TAB 10;”Messier Quiz”
460 PRINT TAB 10;”************”
470 PRINT PAPER k’c$+b$”” In what constellation is M”;r;”?”+(” ” AND r<100)+(” ” AND r<10)
480 PRINT ‘” This is “;
490 GO SUB 100+VAL k$(r)*10
500 INPUT t$: LET t$=t$+” ”
510 IF t$=x$ THEN LET c=c+1: GO SUB 600
520 IF t$x$ THEN LET w=w+1
530 PRINT ”c;” correct”,w;” wrong”
540 PRINT FLASH 1;AT 15,(d-w)*15;”——–> “;10-n;” left”
550 IF t$x$ THEN BEEP .2,-16: BEEP .5,-30: PRINT ‘” The answer is “; FLASH 1;x$;AT 3+INT (z/9),0;TAB (z-1)*4;x$
560 PRINT PAPER n-1;AT 19,0;” Call yourself an ?”
570 PAUSE 300: NEXT n
580 PRINT PAPER 1; PAPER 4′” Time is up “+y$+b$( TO 8)
585 POKE 23658,0
590 GO SUB 600: PRINT #0;” Press any key to continue.”: PAUSE 0: GO TO 200
600 FOR a=-30 TO 30 STEP 5: BEEP .1,a: NEXT a: RETURN

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s