Chapter 3 – The Moon (UDG Moon’s Phases)

The Moon’s Phases, the phases of the moon over a monthly cycle
Phases of the Moon, plots the Earth and Moon in orbit around each other with a full description of each phase
UDG Moon’s Phases, using the UDG character set.

UDG Moon’s Phases

When the changing phases of a moon are needed for display in rapid succession and a single character square is large enough, it can be useful to use the UDG character set. Obviously, not every conceivable phase can be indicated but a sufficient selection can be, at least, to make the effect convincing.

The following program, which may be incorporated into a longer program as a subroutine (see the Moons of Mars in Chapter 6), is designed for this purpose. It defines sixteen UDG characters from CHR$ 144 to CHR$ 159 inclusive. The successive phases are from ‘new moon’ (CHR$ 144) to ‘full moon’ (CHR$ 152) and back again to a narrow crescent (CHR$ 159) immediately before ‘new moon’ again. Figure 3.4 details each pixel position of the complete set.

Figure 3.4
UDG_Moons_Phases

To redefine all sixteen characters requires POKEing 128 items of DATA (16×8 lines). In this program the DATA contains only 48 values — sufficient for the first three lines of each character. As the lower section of each character is a ‘mirror image’ of the upper portion, the program does the necessary duplication of DATA as shown in Figure 3.5.

Figure 3.5
Final Crescent phase – CHR$ 159
UDG_Moons_Phases_Final_Cres

Program RUN
Enter the complete program and RUN it to see the results of your efforts. Lines 110 to 220 define the new UDG character and, from Line 1000, there is a demonstration PRINTing to show the daily changes in the moon’s phases (see Figure 3.6).

Note that the increasing phase is PRINTed further to the left — away from the Sun — for each day represented, until the final crescent phase immediately to the right of the Sun. Full moon is PRINTed at maximum distance from the Sun in the centre of the display. This correctly mimics the appearance and movement of all the major moons in the solar system in a direct or anticlockwise direction as seen from above (to the north) of the moon’s orbit.

Figure 3.6
UDG_Moons_Phases_Spectrum_S

New graphics
A simple procedure to redesign any characters of this type is as follows:
1) Sketch out the new design on squared paper.
2) Enter as a direct command in the Spectrum the BIN values, eg
PRINT BIN 00000110 ENTER (decimal value 6-lineO)
PRINT BIN 00000111 ENTER (decimal value 7 – line 1)
PRINT BIN 00001111 ENTER (decimal value 15-line 2)
3) Substitute the new values into the DATA, remembering the first three values are for CHR$ 144 and the last three values are for CHR$ 159.

99 REM ***********************
100 REM UDG moons phases
101 REM ***********************
110 DATA 0,0,0,12,2,1,12,6,3,12,6,7,12,14,15,12,30,31,28,62,63
120 DATA 60,126,127,60,126,255,60,126,254,56,124,252,48,120,248
130 DATA 48,112,240,48,96,224,48,96,192,48,64,128
139 REM ***********************
140 REM poke UDG moons
141 REM ***********************
150 FOR n=0 TO 15: FOR f=0 TO 1
160 READ p
170 POKE USR CHR$ (144+n)+f,p
180 POKE USR CHR$ (144+n)+7-f,p
190 NEXT f
200 READ c: FOR x=2 TO 5
210 POKE USR CHR$ (144+n)+x,c
220 NEXT x: NEXT n
999 REM ***********************
1000 REM test printing
1001 REM ***********************
1010 BORDER 1: PAPER 1: INK 6
1020 CLS
1030 PRINT “UDG Moon’s Phases”
1040 PRINT AT 20,6;”sun”;TAB 23;”sun”;AT 2,6; INK 5;”new Lqt ful 1qt new moon “; INK 6;”day”
1050 FOR n=0 TO 15: LET z=n+4
1060 PRINT AT 3,23-n;”<.”
1070 PRINT AT z,3;n+1;AT z,7;”*”
1080 PRINT AT z,24;”*”
1090 PRINT AT z,23-n; PAPER 0; INK 5;CHR$ (144+n): PAUSE 50: NEXT n
1100 INK 0: PAPER 7
9900 REM ***********************
9990 SAVE “udgmoon”



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 )

Connecting to %s