Jump to content
IGNORED

Orbit


Vorticon

Recommended Posts

I was testing out some of the features of The Missing Link last night and decided to convert an old listing from the French magazine Science & Vie Micro issue 1 from 1983 where one attempts to rendezvous with a space portal in orbit around a planet. The original program had you input the mass of the planet and the initial location of your rocket, and then ask you for a starting velocity. It would then spew out a list of grid coordinates representing the orbit of your rocket which you were supposed to plot on graph paper.

 

The conversion was fairly simple, and TML allowed me to use pixel plots for the orbit as well as a visualization of the planet and gate. The mass of the planet and your starting location vary with each initial run of the program, and you will be asked to enter the initial rocket velocity components Vx and Vy. Once entered, the resulting orbit will be drawn. The planet is the blue circle and the gate is smaller red one. If at first nothing shows up on screen, it's because parts of the orbit lie outside of the screen boundaries, so just wait for it.

If the orbit is completed and you have not reached the gate location, then your mission will be a failure and you get to enter different velocity elements within the same scenario. Otherwise, you will have succeeded to reach the gate and the game will end after being congratulated.

 

Try different combinations of Vx and Vy as their values can dramatically alter the shape and orientation of the orbit. Also, because the mass of the planet varies, your may need smaller or larger velocity values to achieve a similar orbit. Values beyond 15-20 are probably too large in general.

 

Place the disk in DSK1 with the XB cart in place. TML will autostart. At the prompt, type RUN "DSK1.ORBIT" and off you go.

 

Just a little fun for geeks :)

 

Orbit



// Orbital Rendezvous
// By Walid Maalouli
// March 2015

// Initialization
CALL LINK("CLEAR"):: ..
CALL SCREEN(2):: ..
RANDOMIZE

//Planet location and mass
M=INT(4001*RND)+1000:: ..
XP=120:: ..
YP=96:: ..
CALL LINK("CIRCLE",YP,XP,3,0,6,1)

// Player rocket starting position
StartingX:
X=INT(201*RND)+40:: ..
IF (X>80 AND X<160) THEN ..
	StartingX

StartingY:
Y=INT(153*RND)+20:: ..
IF (Y>76 AND Y<116) THEN ..
	StartingY
	
XS=X:: ..
YS=Y
	
// Temporal gate location
XX=X-XP:: ..
YY=Y-YP:: ..
R0=SQR(XX^2+YY^2)

XG=XP-R0*(0.5-RND):: ..
YG=YP-RO*(0.5-RND)

CALL LINK("CIRCLE",YG,XG,1,0,9,1)

// Input initial velocity parameters
Velocity:
CALL LINK("PRINT",172,1,"Enter initial Vx: "):: ..
CALL LINK("INPUT",172,132,VX)

CALL LINK("PRINT",182,1,"Enter initial Vy: "):: ..
CALL LINK("INPUT",182,132,VY)

// Calculate orbital parameters
J=(X-XP)*VY-(Y-YP)*VX

CS=XX/R0:: ..
SN=YY/R0:: ..
DET=VX*SN-VY*CS

IF DET=0 THEN ..
	GOSUB ResetScreen:: ..
	GOTO Velocity
	
A=-(M*CS/(J^2))-VY/(R0*DET):: ..
B=-(M*SN/(J^2))+VX/(R0*DET)

TH=PI/2

IF XX=0 THEN ..
	CheckYY

TH=ATN(YY/XX)

CheckYY:
IF YY>0 THEN ..
	FinalAngle
	
TH=TH+PI

FinalAngle:
TF=TH+2*PI

// Draw orbit
FOR T=TH TO TF STEP 0.05
	R=1/(A*COS(T)+B*SIN(T)+M/(J^2)):: ..
	X=XP+R*COS(T):: ..
	Y=YP+R*SIN(T)
	
	IF X<1 OR X>240 OR Y<1 OR Y>192 THEN ..
		NextPlotPoint
		
	CALL LINK("PIXEL",Y,X,16,1)
	
	IF ABS(X-XG)+ABS(Y-YG)>3 THEN ..
		NextPlotPoint
		
	CALL LINK("PRINT",10,1,"Objective reached! Bravo!")
	Loop:
	GOTO Loop
	
NextPlotPoint:
NEXT T

CALL LINK("PRINT",10,1,"Objective failed... Sorry.")

WaitForKey:
CALL KEY(0,K,S):: ..
IF S=0 THEN ..
	WaitForKey
	
GOSUB ResetScreen:: ..

X=XS:: ..
Y=YS:: ..
GOTO Velocity

ResetScreen:
CALL LINK("CLEAR"):: ..
CALL LINK("CIRCLE",YP,XP,3,0,6,1):: ..
CALL LINK("CIRCLE",YG,XG,1,0,9,1):: ..
RETURN

	

 

 

ORBIT.dsk

  • Like 5
Link to comment
Share on other sites

Yeah, SVM was might favorite computer magazine back in the day :) You can find all the issues and many other French computing magazines here :http://www.abandonware-magazines.org/affiche_mag.php?mag=48 . There is also an upgraded version of the program in the same issue where you try to rendezvous with an orbiting satellite which is not fixed in space like the gate in the first program, and you also have a limited amount of fuel and air. I'm going to work on converting that one as well.

Link to comment
Share on other sites

How hard is it to use the SAMS with TML?

 

I attempted this with RXB and could never get it to work.

 

I would use RXB commands:

 

CALL AMSINIT ! Sets up SAMS for use by setting up banks 0 to 239 4K pages. (First number is lower bank, second number is upper banks of 4K pages)

CALL AMSBANK(100,101) ! Sets banks 100 in lower 8K >2000 to >2FFF, 101 sets bank >3000 to >3FFF

RUN "DSK1.TML" ! LOAD The Missing Link

CALL ISROFF(ISR) ! Turns off the ISR hook at >83C4 and puts value into Variable ISR

CALL PEEK(13568,X,Y) ! Just peek a address to see what is there

CALL AMSBANK(24,25) ! Switch Lower 8K banks

CALL PEEK(13568,A,B) ! Just peek a address to show it changed pages

CALL AMSBANK(100,101) ! Put the TML lower 8K bank back in lower 8K

CALL ISRON(ISR) ! Turn on the ISR hook at >83C4 from Variable ISR

 

* SYNTAX ERROR * This error is completely wrong for the problem that resulted.

Edited by RXB
Link to comment
Share on other sites

Yea the way the Missing Link works seems to just totally hose the SAMS. Every trick in the book I have tried fails.

 

I can load many other Assembly programs that even have a ISR Hook and switch and use them using the SAMS.

 

But TML seems to be one that seems impossibly incompatible with the SAMS.

 

Not sure exactly why?

Link to comment
Share on other sites

  • 3 weeks later...

This is the full game of Orbital Rendezvous. You are attempting to rendezvous with the space station in orbit around a planet or moon before your oxygen and fuel supplies run out. You start at a random location around the planetary body, and you enter your initial velocity parameters. Your orbit will then be traced in red and the station's orbit will be in magenta. You have to get to within 10 kilometers of the station in order to achieve your objective.
Press and hold any key at any time to enter adjustments to your velocity components which will alter your orbit. The orbits are redrawn with each adjustment made.
It will take some time to get a feel of the magnitude of the adjustments needed as well as the timing (apogee, perigee, etc...) in order to achieve a desired orbit. Also, which planetary body you choose and where you start around it will affect your initial orbit, so every play around will be different.
Good luck!

 

https://youtu.be/9_fZ0DAFC70

 

 

 


REM Orbital Rendezvous
REM By Walid Maalouli
REM April 2015
REM Original concept by Frédéric Neuville as published in Science & Vie Micro #1, Dec. 83
// Initialization
CALL LINK("CLEAR"):: ..
CALL SCREEN(2):: ..
RANDOMIZE
OPTION BASE 1:: ..
DIM A(2),B(2),J(2)
CALL LINK("CHAR",127,"3C7EFFFFFFFF7E3C")
CALL LINK("CHAR",1,"01060E1CB8706090C5A2554834324D87")
CALL LINK("FORMAT",2,4,3)
Start:
DT=0.8:: ..
AIR=200:: ..
FUEL=20:: ..
FFLAG=0:: ..
SFLAG=1
// Splash screen
CALL LINK("LOADP","DSK1.ORBIT")
CALL LINK("PENHUE",16,1):: ..
CALL LINK("CHSIZE",8,12):: ..
CALL LINK("PRINT",144,48,"ORBITAL"):: ..
CALL LINK("PRINT",158,48,"RENDEZVOUS")
CALL LINK("CHSIZE",8,8):: ..
CALL LINK("PRINT",172,24,"By Walid Maalouli"):: ..
CALL LINK("PRINT",182,48,"April 2015")
GOSUB WaitForKey
// Planet selection
CALL LINK("LOADP","DSK1.STARS")
CALL LINK("PENHUE",3,1):: ..
CALL LINK("PRINT",20,1,"Please select the planet/moon:")
CALL LINK("PENHUE",15,1):: ..
CALL LINK("PRINT",36,15,"1- Mercury")
CALL LINK("PENHUE",10,1):: ..
CALL LINK("PRINT",46,15,"2- Mars")
CALL LINK("PENHUE",7,1):: ..
CALL LINK("PRINT",56,15,"3- Io")
CALL LINK("PENHUE",16,1):: ..
CALL LINK("PRINT",66,15,"4- Europa")
CALL LINK("PENHUE",12,1):: ..
CALL LINK("PRINT",76,15,"5- Titan")
ChoosePlanet:
GOSUB WaitForKey
IF KY<49 OR KY>53 THEN ..
ChoosePlanet
ON KY-48 GOTO Mercury,Mars,Io,Europa,Titan
Mercury:
Y=36:: ..
C=15:: ..
P$="1- Mercury":: ..
K=5578:: ..
GOTO ShowPlanetSelection
Mars:
Y=46:: ..
C=10:: ..
P$="2- Mars":: ..
K=8000:: ..
GOTO ShowPlanetSelection
Io:
Y=56:: ..
C=7:: ..
P$="3- Io":: ..
K=3700:: ..
GOTO ShowPlanetSelection
Europa:
Y=66:: ..
C=16:: ..
P$="4- Europa":: ..
K=3375:: ..
GOTO ShowPlanetSelection
Titan:
Y=76:: ..
C=12:: ..
K=4055:: ..
P$="5- Titan"
ShowPlanetSelection:
FOR I=1 TO 3
CALL LINK("PENHUE",C,1):: ..
CALL SOUND(35,1000,0):: ..
CALL LINK("PRINT",Y,15,P$)
CALL LINK("PENHUE",C,4):: ..
CALL LINK("PRINT",Y,15,P$)
GOSUB Delay
NEXT I
// Planet coordinates
XC=120:: ..
YC=96
// Player rocket starting position
StartingX:
X=INT(201*RND)+40:: ..
IF (X>80 AND X<160) THEN ..
StartingX
StartingY:
Y=INT(153*RND)+20:: ..
IF (Y>76 AND Y<116) THEN ..
StartingY
// Initial rocket velocity vectors
CALL LINK("PENHUE",3,1):: ..
CALL LINK("PRINT",140,46,"Rocket velocity vectors:")
CALL LINK("PENHUE",14,1):: ..
CALL LINK("PRINT",152,70,"Vx:"):: ..
CALL LINK("PRINT",164,70,"Vy:")
VelocityVectors:
CALL LINK("INPUT",152,100,VX,5):: ..
CALL LINK("INPUT",164,100,VY,5)
IF VX<0 OR VY<0 THEN ..
VelocityVectors
// Calculate rocket orbital elements
X0=(X-XC):: ..
Y0=(Y-YC):: ..
R0=SQR(X0^2+Y0^2):: ..
J(1)=(X-XC)*VY-(Y-YC)*VX
CO=X0/R0:: ..
SI=Y0/R0
DET=VX*SI-VY*CO:: ..
IF DET=0 THEN ..
VelocityVectors
A(1)=-(K*CO/J(1)^2)-VY/(R0*DET):: ..
B(1)=-(K*SI/J(1)^2)+VX/(R0*DET)
// Calculate space station orbital elements
J(2)=300+RND*100:: ..
TS=6.29*RND
A(2)=-0.01+(RND*0.02):: ..
B(2)=-0.01+(RND*0.02)
// Draw orbits
GOSUB UpdateScreen
CALL LINK("PENHUE",9,1):: ..
N=1:: ..
GOSUB DrawOrbit
CALL LINK("PENHUE",14,1):: ..
N=2:: ..
GOSUB DrawOrbit
// Display rocket position
T=1.5708
IF X<>XC THEN ..
T=ATN((Y-YC)/(X-XC))
IF Y<YC THEN ..
T=T+PI
UpdatePositions:
TH=T:: ..
R=1/(A(1)*COS(TH)+B(1)*SIN(TH)+K/J(1)^2):: ..
PL=0
IF SFLAG=1 THEN ..
SFLAG=0:: ..
GOTO SkipRocketDisplay
IF X>=0 AND X<240 THEN ..
IF Y>=0 AND Y<192 THEN ..
PL=1:: ..
CALL LINK("SPRITE",1,1,8,Y,X,0,0)
SkipRocketDisplay:
T=T+DT*J(1)/R^2:: ..
TH=T:: ..
R=1/(A(1)*COS(TH)+B(1)*SIN(TH)+K/J(1)^2)
X1=X:: ..
Y1=Y:: ..
X=XC+R*COS(TH):: ..
Y=YC+R*SIN(TH)
// Display space station position
TH=TS:: ..
R=1/(A(2)*COS(TH)+B(2)*SIN(TH)+K/J(2)^2):: ..
PS=0
IF XS>=0 AND XS<240 THEN ..
IF YS>=0 AND YS<192 THEN ..
PS=1:: ..
CALL LINK("SPRITE",2,2,6,YS,XS,0,0)
TS=TS+DT*J(2)/R^2:: ..
TH=TS:: ..
R=1/(A(2)*COS(TH)+B(2)*SIN(TH)+K/J(2)^2)
XS1=XS:: ..
YS1=YS:: ..
XS=XC+R*COS(TH):: ..
YS=YC+R*SIN(TH)
// Adjust consumables quantities
AIR=AIR-DT:: ..
CALL LINK("PENHUE",3,1):: ..
GOSUB UpdateConsumables
IF AIR<=30 AND FFLAG= 0 THEN ..
CALL LINK("PENHUE",16,9):: ..
CALL LINK("PRINT",180,16,"WARNING! OXYGEN LEVEL LOW!"):: ..
FFLAG=1
IF AIR<=0 THEN ..
CALL LINK("PENHUE",16,9):: ..
CALL LINK("PRINT",32,16,"YOU HAVE DIED OF ASPHYXIA..."):: ..
GOTO PlayAgain
// Display velocity components
VX=-(B(1)*J(1)+(K/J(1))*SIN(T)):: ..
VY=A(1)*J(1)+(K/J(1))*COS(T):: ..
CALL LINK("PENHUE",3,1):: ..
GOSUB UpdateVelocity
// Update rocket and space station positions
IF PS=1 THEN ..
CALL LINK("SPRITE",2,2,6,YS1,XS1,0,0)
IF PL=1 THEN ..
CALL LINK("SPRITE",1,1,8,Y1,X1,0,0)
DS=(X-XS)^2+(Y-YS)^2
GOSUB UpdateDistance
// Determine if rendezvous achieved
IF DS<10 THEN ..
CALL LINK("PENHUE",8,1):: ..
CALL LINK("PRINT",80,9,"RENDEZVOUS ACHIEVED! BRAVO!"):: ..
GOTO PlayAgain
// Check for user input
CALL KEY(0,KY,S):: ..
IF S=0 THEN ..
NoKeyPressed
CALL LINK("PENHUE",3,1)
EnterDeltaVelocity:
CALL SOUND(35,1000,0)
CALL LINK("PRINT",180,1,"Delta Vx: "):: ..
CALL LINK("INPUT",180,80,V1)
CALL SOUND(35,1000,0):: ..
CALL LINK("PRINT",180,1,"Delta Vy: "):: ..
CALL LINK("INPUT",180,80,V2)
IF ABS(V1)+ABS(V2)<=FUEL THEN ..
AdjustVelocity
CALL SOUND(35,110,0):: ..
CALL LINK("PRINT",180,1,"INSUFFICIENT FUEL!"):: ..
FOR I=1 TO 100:: ..
NEXT I:: ..
GOTO EnterDeltaVelocity
// Adjust rocket velocity
AdjustVelocity:
FUEL=FUEL-(ABS(V1)+ABS(V2)):: ..
VX=VX+V1:: ..
VY=VY+V2
// Update the rocket's orbit
GOSUB UpdateScreen
CALL LINK("PENHUE",14,1):: ..
N=2:: ..
GOSUB DrawOrbit
X0=(X-XC):: ..
Y0=(Y-YC):: ..
R0=SQR(X0^2+Y0^2):: ..
J(1)=(X-XC)*VY-(Y-YC)*VX
CALL LINK("PENHUE",9,1):: ..
N=1:: ..
GOSUB DrawOrbit
FFLAG=0:: ..
GOTO UpdatePositions
NoKeyPressed:
GOTO UpdatePositions
PlayAgain:
CALL LINK("PENHUE",3,1):: ..
CALL LINK("PRINT",140,80,"Play Again?"):: ..
GOSUB WaitForKey
IF KY<>89 AND KY<>121 THEN ..
STOP
GOTO Start
WaitForKey:
CALL KEY(0,KY,S):: ..
IF S=0 THEN ..
WaitForKey
RETURN
Delay:
FOR D=1 TO 25:: ..
NEXT D:: ..
RETURN
DrawOrbit:
FOR TH=0 TO 6.28 STEP 0.16
R=1/(A(N)*COS(TH)+B(N)*SIN(TH)+K/J(N)^2)
XP=XC+R*COS(TH):: ..
YP=YC+R*SIN(TH)
IF XP<0 OR XP>240 OR YP<0 OR YP>191 THEN ..
NextStep
CALL LINK("PIXEL",YP,XP)
NextStep:
NEXT TH
RETURN
UpdateScreen:
CALL LINK("CLEAR"):: ..
CALL LINK("COLOR",2,2):: ..
CALL LINK("PENHUE",C,1):: ..
CALL LINK("PRINT",YC,(XC),CHR$(127))
CALL LINK("PENHUE",3,1):: ..
CALL LINK("PRINT",1,116,"Oxygen:"):: ..
CALL LINK("PRINT",10,116,"Fuel:")
CALL LINK("PRINT",1,1,"Vx:"):: ..
CALL LINK("PRINT",10,1,"Vy:")
CALL LINK("PRINT",170,1,"Distance:")
GOSUB UpdateConsumables:: ..
GOSUB UpdateVelocity:: ..
GOSUB UpdateDistance
RETURN
UpdateConsumables:
CALL LINK("PRINT",1,176,AIR):: ..
CALL LINK("PRINT",10,176,FUEL):: ..
RETURN
UpdateVelocity:
CALL LINK("PRINT",1,22,VX):: ..
CALL LINK("PRINT",10,22,VY):: ..
RETURN
UpdateDistance:
CALL LINK("FORMAT",8,3,1):: ..
CALL LINK("PRINT",170,70,DS):: ..
CALL LINK("FORMAT",2,4,3)
RETURN

 

 

 

** EDIT: This is the latest version which corrects a few minor bugs and speeds up a little bit the orbits display (5/18/15)

ORBIT.dsk

  • Like 4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...