This is a simple little program demonstrating how the phases of the Moon develop depending upon the positions of the Moon and the Sun in the sky.
The view is for an observer in the northern hemisphere looking south - you Southern-hemispherical people would see things upside-down (but then we're not sure what is preventing you from falling off the Earth anyway! - cue for Pete to give his "gravity of the situation" pun).
The dark green foreshortened half-circle at the bottom represents the viewer's horizon: the Sun and Moon rise in the East (left-hand side) and sink in the West.
Of course, the sizes of the Sun and Moon are way, way larger than in the actual sky, but it is the phase of the moon that is the only important factor.  Apart from the phase, all other factors are quite unrealistic.
The program will start with your current time and date and will then proceed minute-by-minute.  The position of the Sun will be correct, but the Moon starts arbitrarily opposite the Sun (full Moon).  The Sun will gradually catch up the Moon, and there will be a total eclipse every complete Moon cycle (27.3 days in this model).
I could have made the program more complex with more realistic factors, but have left it in this state.  It is rather a simple piece of code and I therefore feel slightly embarrassed to foist it upon you.  You will need the moon image.
'Moon Phases by QWERKEY 02/03/19
 
CONST Radius% 
= 98, HalfScreenX% 
= 550, HalfScreenY% 
= 300, Pi! 
= 4 * ATN(1) CONST G! 
= 0.75, H! 
= 0.7, Twelve% 
= 720, MinsStep%% 
= 2, Delta! 
= 0.15, Eclipse! 
= 0.004  
TempImg& 
= _NEWIMAGE(2 * Radius% 
+ 1, 2 * Radius% 
+ 1, 32)_PUTIMAGE (0, 0)-(2 * Radius%
, 2 * Radius%
), Moon1&
 Moon& = MakeHardware&(TempImg&)
TempImg& 
= _NEWIMAGE(2 * Radius% 
+ 1, 2 * Radius% 
+ 1, 32)Sun& = MakeHardware&(TempImg&)
TempImg& 
= _NEWIMAGE(2 * HalfScreenX% 
+ 1, 2 * HalfScreenX% 
+ 1, 32)CIRCLE (HalfScreenX%
, HalfScreenX%
), HalfScreenX%
, _RGB32(0, 50, 0) Ground& = MakeHardware&(TempImg&)
 
DIM Months$
(12, 1), Days%
(1) DATA Jan
,31,Feb
,28,Mar
,31,Apr
,30,May
,31,Jun
,30,Jul
,31,Aug
,31,Sep
,30,Oct
,31,Nov
,30,Dec
,31 IF Days%
(0) = 2 AND Days%
(1) = 29 THEN Days%
(1) = 28 Beta1! = (Twelve% - NoMins%) * Pi! / Twelve%
Beta2! = Beta1! - Pi!
 
 
 
 
    Theta! = Beta1! - Beta2! - 3 * Pi! / 2
        Theta! = Theta! + 2 * Pi!
        Theta! = Theta! - 2 * Pi!
 
    IF Beta1! 
> -Pi! 
/ 2 AND Beta1! 
< Pi! 
/ 2 THEN         IF (Theta! 
< -3 * Pi! 
/ 2 + Eclipse! 
AND Theta! 
> -3 * Pi! 
/ 2) OR (Theta! 
< Pi! 
/ 2 AND Theta! 
> Pi! 
/ 2 - Eclipse!
) THEN     IF Beta1! 
> -Pi! 
/ 2 - Delta! 
AND Beta1! 
< Pi! 
/ 2 + Delta! 
THEN         X1% 
= CINT(HalfScreenX% 
* SIN(-Beta1!
))        Y1% 
= CINT(2 * HalfScreenY% 
* G! 
* COS(-Beta1!
))        _PUTIMAGE (HalfScreenX% 
+ X1% 
- Radius%
, 2 * HalfScreenY% 
+ 1 - Y1% 
- Radius%
), Sun&
     IF Beta2! 
> -Pi! 
/ 2 - Delta! 
AND Beta2! 
< Pi! 
/ 2 + Delta! 
THEN         TempImg& 
= _NEWIMAGE(2 * Radius% 
+ 1, 2 * Radius% 
+ 1, 32)                Phi! = N% * Pi! / 500
                Phi! = N% * Pi! / 500
                Phi! = N% * Pi! / 500
            Theta2! = Theta! + Pi!
                Phi! = N% * Pi! / 500
        Shadow& = MakeHardware&(TempImg&)
        X2% 
= CINT(HalfScreenX% 
* SIN(-Beta2!
))        Y2% 
= CINT(2 * HalfScreenY% 
* G! 
* COS(-Beta2!
))        _PUTIMAGE (HalfScreenX% 
+ X2% 
- Radius%
, 2 * HalfScreenY% 
+ 1 - Y2% 
- Radius%
), Moon&
         _PUTIMAGE (HalfScreenX% 
+ X2% 
- Radius%
, 2 * HalfScreenY% 
+ 1 - Y2% 
- Radius%
), Shadow&
     _PUTIMAGE (0, (2 * HalfScreenY% 
+ 1) * H!
)-(2 * HalfScreenX% 
+ 1, 2 * HalfScreenY% 
+ 1), Ground&
, , (0, 0)-(2 * HalfScreenX% 
+ 1, HalfScreenX%
)     LOCATE 1, 130: 
PRINT Months$
(Days%
(0), 0) + " "; Days%
(1);
  
 
    NoMins% = NoMins% + MinsStep%%
        NoMins% = NoMins% - 1440
        Days%(1) = Days%(1) + 1
            Days%(1) = 1
            Days%(0) = Days%(0) + 1
            IF Days%
(0) > 12 THEN Days%
(0) = 1     Beta1! = (Twelve% - NoMins%) * Pi! / Twelve% ' Sun
    IF Beta1! 
< -Pi! 
THEN Beta1! 
= Beta1! 
+ 2 * Pi!
     Beta2! = Beta2! - (MinsStep%% * Pi! / Twelve%) + (2 * 0.0001593) 'Moon 27.39days - factor of 2???
    IF Beta2! 
< -Pi! 
THEN Beta2! 
= Beta2! 
+ 2 * Pi!