ksp: update launch files

This commit is contained in:
Vince Weaver 2016-05-24 16:04:32 -04:00
parent 0b18406b57
commit 956766ecc7
4 changed files with 88 additions and 6 deletions

View File

@ -9,6 +9,9 @@ basic: VAB.BAS THEME.BAS
ACMPLX.BAS: acmplx.bas ACMPLX.BAS: acmplx.bas
$(TXT2BAS) < acmplx.bas > ACMPLX.BAS $(TXT2BAS) < acmplx.bas > ACMPLX.BAS
LAUNCH.BAS: launch.bas
$(TXT2BAS) < launch.bas > LAUNCH.BAS
LOADING.BAS: loading.bas LOADING.BAS: loading.bas
$(TXT2BAS) < loading.bas > LOADING.BAS $(TXT2BAS) < loading.bas > LOADING.BAS
@ -18,6 +21,7 @@ VAB.BAS: vab.bas
ksp.dsk: ACMPLX.BAS \ ksp.dsk: ACMPLX.BAS \
LAUNCH.BAS \
LOADING.BAS LOADING.HGR SQUAD.HGR TITLE.HGR \ LOADING.BAS LOADING.HGR SQUAD.HGR TITLE.HGR \
VAB.BAS VAB.HGR VAB.BAS VAB.HGR
$(DOS33) -y ksp.dsk SAVE B LOADING.HGR $(DOS33) -y ksp.dsk SAVE B LOADING.HGR
@ -27,6 +31,7 @@ ksp.dsk: ACMPLX.BAS \
$(DOS33) -y ksp.dsk SAVE B VAB.HGR $(DOS33) -y ksp.dsk SAVE B VAB.HGR
$(DOS33) -y ksp.dsk SAVE A LOADING.BAS $(DOS33) -y ksp.dsk SAVE A LOADING.BAS
$(DOS33) -y ksp.dsk SAVE A ACMPLX.BAS $(DOS33) -y ksp.dsk SAVE A ACMPLX.BAS
$(DOS33) -y ksp.dsk SAVE A LAUNCH.BAS
LOADING.HGR: loading.pcx LOADING.HGR: loading.pcx

View File

@ -6,10 +6,21 @@
/* Also, high school physics (thanks Mr. Brennen) */ /* Also, high school physics (thanks Mr. Brennen) */
void home(void) {
printf("%c[2J%c[1;1H",27,27);
}
void htabvtab(int x,int y) {
printf("%c[%d;%dH",27,y,x);
}
/* TODO: want 2d-vectors at least */ /* TODO: want 2d-vectors at least */
int main(int argc, char **argv) { int main(int argc, char **argv) {
double angle=0;
double capsule_mass=1.0; double capsule_mass=1.0;
double engine_isp=270.0; /* s */ double engine_isp=270.0; /* s */
@ -19,6 +30,7 @@ int main(int argc, char **argv) {
double tank_mass=0.5; /* tons */ double tank_mass=0.5; /* tons */
double fuel_mass=4.0; /* tons */ double fuel_mass=4.0; /* tons */
double total_fuel=fuel_mass;
double gravity=9.8; /* m/s^2 */ double gravity=9.8; /* m/s^2 */
@ -31,6 +43,10 @@ int main(int argc, char **argv) {
double time=0.0; /* s */ double time=0.0; /* s */
int stage=1;
char input;
total_mass=engine_mass+tank_mass+fuel_mass+capsule_mass; total_mass=engine_mass+tank_mass+fuel_mass+capsule_mass;
empty_mass=total_mass-fuel_mass; empty_mass=total_mass-fuel_mass;
@ -45,9 +61,7 @@ int main(int argc, char **argv) {
printf("Fuel flow rate=%lf, time=%lfs\n", printf("Fuel flow rate=%lf, time=%lfs\n",
fuel_flow_rate,fuel_mass/fuel_flow_rate); fuel_flow_rate,fuel_mass/fuel_flow_rate);
for(time=0.0;time<500.0;time++) { while(1) {
printf("Time: %lf\n",time);
printf("\tFuel left: %lf\n",fuel_mass);
if (fuel_mass<0.1) { if (fuel_mass<0.1) {
fuel_mass=0.0; fuel_mass=0.0;
rocket_acceleration=-gravity; rocket_acceleration=-gravity;
@ -69,9 +83,32 @@ int main(int argc, char **argv) {
fuel_mass=fuel_mass-fuel_flow_rate; fuel_mass=fuel_mass-fuel_flow_rate;
total_mass=engine_mass+tank_mass+fuel_mass+capsule_mass; total_mass=engine_mass+tank_mass+fuel_mass+capsule_mass;
} }
printf("\tRocket acceleration: %lf g\n",rocket_acceleration/gravity);
printf("\tRocket velocity: %lf m/s\n",rocket_velocity); home();
printf("\tRocket altitude: %lf m\n",rocket_altitude);
htabvtab(1,21);
printf("Time: %lf\n",time);
printf("ALT: %lf m\n",rocket_altitude);
printf("VEL: %lf m/s\tStage: %d\n",rocket_velocity,stage);
printf("ACCEL: %lf g\tFuel: %lf%%\n",
rocket_acceleration/gravity,
fuel_mass*100.0/total_fuel);
htabvtab(30,21);
printf("ZURGTROYD");
htabvtab(30,20);
if ((angle>90) && (angle<270)) printf("SCREAM");
else if (rocket_velocity>100) printf("SMILE");
else if (rocket_acceleration<0) printf("FROWN");
else printf("NEUTRAL");
scanf("%c",&input);
time+=1.0;
} }
return 0; return 0;

40
ksp/launch.bas Normal file
View File

@ -0,0 +1,40 @@
2000 REM *** LAUNCH ***
2010 HIMEM: 8135
2020 POKE 232,199: POKE 233,31
2030 FOR L = 8135 TO 8175: READ B: POKE L,B: NEXT L
2035 HGR : ROT= 0: SCALE= 2
2040 GOTO 2150
2090 END
2100 DATA 3,0,8,0,18,0,33,0,53,53
2101 DATA 53,63,63,63,44,44,44,0,0,40
2102 DATA 45,54,54,54,63,63,63,36,36,36
2103 DATA 45,5,0,40,53,55,63,60,44,5
2104 DATA 0
2150 REM
2151 S=3
2152 ST(1)=3:FT(1)=2:EN(1)=3
2153 ST(2)=3:FT(2)=2:EN(2)=3
2154 ST(3)=3:FT(3)=2:EN(3)=3
2155 R=0
2160 GOSUB 2200
2165 GET A$
2170 GOSUB 2200
2180 R=R+1
2190 GOTO 2160
2200 REM *** DRAW SHIP ***
2205 ROT=R
2210 X=132:Y=28
2215 XDRAW 1 AT X,Y+2
2230 FOR I = 1 TO S
2268 FOR J = 1 TO FT(I)
2270 XDRAW 2 AT X, Y+13*J
2272 IF ST(I) >1 THEN XDRAW 2 AT X-14, Y+13*J
2274 IF ST(I) >2 THEN XDRAW 2 AT X+14, Y+13*J
2278 NEXT J
2279 Y=Y+13*FT(I)
2290 XDRAW 1 AT X, Y+8
2292 IF EN(I) >1 THEN XDRAW 1 AT X-14, Y+8
2294 IF EN(I) >2 THEN XDRAW 1 AT X+14, Y+8
2297 Y=Y+6
2300 NEXT I
2310 RETURN

Binary file not shown.