Before you run this program or even look over the code, let me explain why it’s written and runs the way it does. I originally wrote this 32 years ago on my Apple II that had 32K of memory. HiRes graphics had a screen resolution of 320x192 which took up 16K of that 32K of memory. The original program and article appeared in the August 1980, issue 27, page 33 of Micro (The 6502 Journal) magazine. I thought I would convert it to run on my iPad with as little change as possible. If you want to see the original program and article go here http://www.6502.org/documents/publications/micro/ . Even if you don’t care about the program or article, you might find it interesting to look over the archived issues of Micro that show information about the Apple II, the Pet, the Kim-1, etc. Since I didn’t change much of the program, it’s still set up for the year 1980. If you want to see planet positions for 2012, then use 11,688 plus the days from Jan 1st when it asks for a specific date. 11,688 is the number of days from Jan 1, 1980 to Jan 1, 2012. Compared to the programs today, this looks and runs pretty primitive, but back then the Apple II with it’s graphics was top of the line. I won’t go into the details of the program here, but you can read the article if interested. Also, if interested, I had a part 2 Solar System program that was in the October 1981, issue 41, of Micro.
supportedOrientation(PORTRAIT)
function setup()
displayMode(FULLSCREEN)
textMode(CORNER)
backingMode(RETAINED)
showKeyboard()
init()
end
function init()
ptab={}
tab={}
str=""
count=0
z1=0
buf=""
ans=""
size=0
clr=true
ret=false
disp=0
waiting=false
delay=false
for x=1,6 do
ptab[x]=vec2(0,0)
end
fill(255)
pstate=f1000
end
function draw()
if clr then
background(40, 40, 50)
end
if isKeyboardShowing() == false then
fill(40,40,50)
rect(10,850,50,30)
fill(255)
text(z1,10,850)
end
if delay then
for l1=0,q2,1/36*q2 do
x=x1+math.cos(l1)*350
y=y1-math.sin(l1)*350
ellipse(x,y,2,2)
end
for ww=1,#ptab do
ellipse(math.floor(ptab[ww].x),math.floor(ptab[ww].y),2,2)
end
ellipse(WIDTH/2,HEIGHT/2,8,8)
count = count + 1
if count<20 then
return
end
count=0
if single==1 then
return
end
if single==0 and pause then
return
end
end
pstate()
end
function keyboard(k)
if size=="yn" then
if k=="y" or k=="n" then
ans=k
return
end
end
if size=="01" then
if k=="0" or k=="1" then
ans=k
return
end
end
if size=="09" then
ret=false
buf=buf..k
if k==BACKSPACE then
buf=string.sub(buf,1,#buf-1)
end
if k==RETURN then
ans=tonumber(buf)
buf=""
ret=true
end
end
end
function touched(t)
if t.state==BEGAN then
if waiting then
init()
end
end
end
function wait()
text("tap screen to continue",10,900)
clr=false
waiting=true
pstate=idle
end
function idle()
end
function f200()
d=z - math.floor(z/srd)* srd
b=q-(d/srd*q2)
rv=a-(p/(1+e*math.cos(b)))
v=pe/rv-ez
if v>=1 then
v=vl
end
if v<=-1 then
v= -vl
end
v1=-math.atan(v/math.sqrt(-v*v+1))+t
if d>srd/2 then
v1=q2-v1
end
v1=v1+j
x=math.cos(v1)*rv
y=math.sin(v1)*rv
x=x*tt+x1
y=y*tt+y1
end
function f1000()
t=1.5708
q=3.14159265
q2=6.2831853
vl=.99999999
x1=WIDTH/2
y1=HEIGHT/2
showKeyboard()
text(str,10,820)
text("do you want to display ",10,800)
text("the same planets as your last run",10,780)
text("y or n",10,760)
size="yn"
if ans== "y" then
if me==nil and ve==nil and ea==nil and ma==nil and ju==nil and sa==nil then
str="you haven't picked any planets yet"
return
end
pstate=f4000
ans=""
disp=0
end
if ans == "n" then
pstate=f2000
me=nil
ve=nil
ea=nil
ma=nil
ju=nil
sa=nil
ans=""
disp=0
end
str=""
end
function f2000()
text("choose the planets you want to display",10,800)
text("enter y for yes, n for no",10,780)
size="yn"
if me==nil then
text("display mercury",10,760)
if ans == "y" or ans=="n" then
me=ans
ans=""
end
ans=""
s1=87.969
e1=.2056
a1=43.403+28.597
p1=a1*(1-e1*e1)/2
k1=1/e1
u1=p1/e1
j1=77.1*q/180
w1=37.58
if me=="y" then
tt=6.9
end
return
end
if ve==nil then
text("display venus",10,760)
if ans=="y" or ans=="n" then
ve=ans
ans=""
end
ans=""
s2=224.701
e2=.0068
a2=67.726+66.813
p2=a2*(1-e2*e2)/2
k2=1/e2
u2=p2/e2
j2=131.3*q/180
w2=140.5
if ve=="y" then
tt=4.5
end
return
end
if ea==nil then
text("display earth",10,760)
if ans=="y" or ans=="n" then
ea=ans
ans=""
end
ans=""
s3=365.256
e3=.0167
a3=94.555+91.445
p3=a3*(1-e3*e3)/2
k3=1/e3
u3=p3/e3
j3=102.6*q/180
w3=-3
if ea=="y" then
tt=3.15
end
return
end
if ma==nil then
text("display mars",10,760)
if ans=="y" or ans=="n" then
ma=ans
ans=""
end
ans=""
s4=686.98
e4=.0934
a4=154.936+128.471
p4=a4*(1-e4*e4)/2
k4=1/e4
u4=p4/e4
j4=335.7*q/180
w4=289
if ma=="y" then
tt=1.8
end
return
end
if ju==nil then
text("display jupiter",10,760)
if ans=="y" or ans=="n" then
ju=ans
ans=""
end
ans=""
s5=4332.125
e5=.0478
a5=507.046+460.595
p5=a5*(1-e5*e5)/2
k5=1/e5
u5=p5/e5
j5=13.6*q/180
w5=1604
if ju=="y" then
tt=.6
end
return
end
if sa==nil then
text("display saturn",10,760)
if ans=="y" or ans=="n" then
sa=ans
ans=""
pstate=f4000
end
ans=""
s6=10825.863
e6=.0555
a6=937.541+838.425
p6=a6*(1-e6*e6)/2
k6=1/e6
u6=p6/e6
j6=95.5*q/180
w6=2115
if sa=="y" then
tt=.36
end
return
end
end
function f4000()
fill(255)
if disp==0 then
text("do you want point (0)",10,800)
text("or continuous (1) plots",10,780)
text(ans,10,760)
size="01"
if ans=="0" or ans == "1" then
ty=tonumber(ans)
ans=""
disp=1
end
end
if disp==1 then
text("do you want to start at a specific date (0)",10,800)
text("or the beginning of the year 1980 (1)",10,780)
if ans=="0" or ans=="1" then
dt=tonumber(ans)
if dt==0 then
disp=2
else
disp=3
de=0
z1=0
end
ans=""
ret=false
end
end
if disp==2 then
text("enter # of days since jan 0 1980",10,800)
text(buf,10,780)
size="09"
if ret then
de=tonumber(ans)
ans=""
z1=de
ret=false
disp=3
end
end
if disp==3 then
size="09"
text("enter # of days to plot",10,800)
text(buf,10,780)
if ret then
dn=tonumber(ans)
ans=""
ret=false
disp=4
end
end
if disp==4 then
text("enter # of days between plots",10,800)
text(buf,10,780)
if ret then
da=tonumber(ans)
if da==0 then
da=1
end
ans=""
ret=false
disp=0
pstate=f4800
end
end
end
function f4800()
hideKeyboard()
if ty==0 then
clr=true
else
clr=false
end
delay=true
if me=="y" then
a=a1
p=p1
e=e1
pe=u1
ez=k1
srd=s1
j=j1
w=w1
z=z1+w
f200()
ptab[1]=vec2(x,y)
end
if ve=="y" then
a=a2
p=p2
e=e2
pe=u2
ez=k2
srd=s2
j=j2
w=w2
z=z1+w
f200()
ptab[2]=vec2(x,y)
end
if ea=="y" then
a=a3
p=p3
e=e3
pe=u3
ez=k3
srd=s3
j=j3
w=w3
z=z1+w
f200()
ptab[3]=vec2(x,y)
end
if ma=="y" then
a=a4
p=p4
e=e4
pe=u4
ez=k4
srd=s4
j=j4
w=w4
z=z1+w
f200()
ptab[4]=vec2(x,y)
end
if ju=="y" then
a=a5
p=p5
e=e5
pe=u5
ez=k5
srd=s5
j=j5
w=w5
z=z1+w
f200()
ptab[5]=vec2(x,y)
end
if sa=="y" then
a=a6
p=p6
e=e6
pe=u6
ez=k6
srd=s6
j=j6
w=w6
z=z1+w
f200()
ptab[6]=vec2(x,y)
end
z1=z1+da
if z1>=de+dn then
pstate=wait
end
end
Perhaps I shouldn’t have put all of the files in main but when I run this all I get is a blank screen with the keyboard constantly showing.
BTW, the 80’s were not so bad from what I can remember.
.@Keebo, it is a text based console which plots a display of the planets (Which is awesome @Dave1707 ;-)) My suggestion is press “nyyyyyy0” “1” “710” “2”
I guess I am doing it all wrong as your suggestion does not bring anything up. Thank you for trying though.
Try turning the ipad the right way.
I’m sorry, I forgot to put in code for portrait mode. I’m so used to holding the iPad in portrait that I forget that others use landscape. @Jordan, you’re correct about the console based input. The Apple II had 2 memory areas, one for text and the other for graphics. You could switch from one to the other without either being affected. So it was easy to do text input and then switch to graphics mode and switch back to text again. Like I said earlier, this is a primitive program and my main reason for doing this was my finding the archived files of Micro magazine. I thought others might be interested to see what the early Apple computers had to offer and the prices that everything was selling for and how different they were from the iPads today.
Oh, I see now. This is pretty cool especially considering it’s history. Nice original work on such an early Apple and even nicer to be able to port it to an iPad.
Looking through the first edition of Micro, I see where you could get a 4K memory board socketed, assembled, and tested for a mere $129.00 .
And if you wanted 8 gig of memory (8 gig flash card for $6 now) it would only have cost you $270 million. Did I do that right. (8 x 1024x1024x1024) / (4x1024) x $129.