20.02.2013 Views

ZX Computings - OpenLibra

ZX Computings - OpenLibra

ZX Computings - OpenLibra

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Orbit<br />

S M King from Bristol takes<br />

you and your <strong>ZX</strong>81 far out<br />

into space, where you can<br />

obsereve the four<br />

innermost planets of the<br />

solar system — Mercury,<br />

Venus, good old Earth and<br />

Mars — happily circling the<br />

sun.<br />

S M King from Bristol takes<br />

you and your <strong>ZX</strong>81 far out<br />

into space, where you can<br />

observe the four innermost<br />

planets of the solar system<br />

— Mercury, Venus, good old<br />

Earth and Mars — happily<br />

circling the sun.<br />

Orbit is a program which<br />

was originally intended to<br />

produce an animated simulation<br />

of the movement of<br />

the four inner planets in<br />

our solar system around the<br />

sun. However, it soon<br />

became apparent that producing<br />

accurate elliptical<br />

orbits was going to be<br />

rather difficult, especially<br />

with the limited 64x44<br />

resolution available. The<br />

result is that the program<br />

uses circular orbits to<br />

display the relative motion<br />

of the planets at the expense<br />

of accuracy. Whilst it<br />

Lines 30-76:<br />

Lines 80 & 85:<br />

Line 90:<br />

Lines 100-115:<br />

Lines 120Ef 125:<br />

Lines 130 & 135:<br />

Lines 140Ef 145:<br />

Lines 1 50 & 155:<br />

Lines 165-180:<br />

Lines 200-220:<br />

may still find use in an instructive<br />

role it would be<br />

much better placed in, say,<br />

a "Star Trek" type of program<br />

as a "long-range scanner<br />

report".<br />

The Program<br />

The program was written<br />

on a Sinclair <strong>ZX</strong>81 with 8K<br />

Floating-point BASIC and<br />

16K of RAM, although it by<br />

no means uses this much.<br />

With the omission of REM<br />

statements and with the<br />

use of other space-saving<br />

tips (which will be discussed<br />

later) the program should<br />

fit easily within 7K — with<br />

four planets.<br />

Documentation is given<br />

to aid conversion to other<br />

micros and the program<br />

should RUN unaltered on a<br />

<strong>ZX</strong>80 with the 8K BASIC.<br />

PRINT the introduction. Line 35, for<br />

example, PRINTs one blank line,<br />

cause the introduction to be displayed<br />

for 4000/50 (80) seconds. The POKE<br />

instruction simply resets the system<br />

variable. These lines could be replaced<br />

by a FOR/NEXT loop.<br />

CLS is the "Clear Screen" instruction,<br />

assign variables to the number of<br />

radians each planet moves per day. The<br />

numbers are expressed in scientific<br />

notation: ie, 57 • 1 E-03 - 0 • 0571.<br />

pixel co-ordinates for the start position<br />

of Mercury (Hermes),<br />

pixel co-ordinates for the start position<br />

of Venus.<br />

pixel co-ordinates for the start position<br />

of Earth.<br />

pixel co-ordinates for the start position<br />

of Mars.<br />

assign variables to the "orbital radii" of<br />

each planet. The numbers are the<br />

number of pixels,<br />

display the first "question". The<br />

animated display will show successive<br />

earth days, months or years.<br />

<strong>ZX</strong>81 Programs<br />

Line 225:<br />

Line 230:<br />

Lines 250-260:<br />

Line 265:<br />

Lines 300-305:<br />

Line 315:<br />

Line 335:<br />

Lines 41 5-443:<br />

Lines 445-520:<br />

Lines 525-540:<br />

Line 545:<br />

Line 550:<br />

Lines 560-575:<br />

Line 587:<br />

Lines 590-605:<br />

Line 610:<br />

Line 620:<br />

causes the program to wait until a<br />

number (the choice) is entered,<br />

checks to see if the number entered is a<br />

1, 2 or 3. If it is then the program<br />

continues at line 245. If not, then a<br />

reminder is PRtNTed (line 235) and the<br />

program returns to the INPUT<br />

statement at 225.<br />

choose the period incrementing factor<br />

(in days),<br />

sets the period counter to one.<br />

display the second "question". How<br />

many days, months or years are to be<br />

displayed?<br />

makes the number entered at line 310<br />

an integer if it was a decimal. It has no<br />

effect if the number was already an<br />

integer. Note that the number must be<br />

greater than one for the program to<br />

continue.<br />

displays the third "question". What realtime<br />

time delay is required between<br />

successive "frames" of the animation?<br />

Line 345 prevents the delay from being<br />

zero seconds. Line 350 converts the<br />

figure entered into a number used by<br />

the PAUSE instruction.<br />

DIMension 8 arrays (2 per planet) to hold<br />

the pixel co-ordinates for PLOTting and<br />

UNPLOTting. The first array in each case<br />

holds X-coords, the second Y-coords.<br />

calculate the positions that each of the<br />

four planets will be at during the<br />

simulation. Lines 450, 470, 490 and 510<br />

calculate X pixel co-ordinates, whilst<br />

Lines 455, 475, 495 and 515 calculate Y<br />

pixel co-ordinates.<br />

"black-in" the starting positions of the<br />

planets.<br />

sets the main loop counter to one.<br />

increments the period counter,<br />

display the positions of the planets<br />

during the simulation,<br />

checks to see if the required number of<br />

days/months/years have been<br />

displayed. If they have then the<br />

program jumps to line 700.<br />

"black-in" the positions of the planets<br />

during the simulation,<br />

increments the loop counter,<br />

returns the loop.<br />

PROGRAM BETWEEN LINES 700 AND 999 ONLY WORKS<br />

WHEN THE MAIN SIMULATION HAS FINISHED.<br />

18 <strong>ZX</strong> COMPUTING SUMMER 1982 i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!