From 956766ecc75e0dc11003af2f6df2a1c62e1d0782 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 24 May 2016 16:04:32 -0400 Subject: [PATCH] ksp: update launch files --- ksp/Makefile | 5 +++++ ksp/c/ksp_launch.c | 49 +++++++++++++++++++++++++++++++++++++++------ ksp/launch.bas | 40 ++++++++++++++++++++++++++++++++++++ ksp/title.pcx | Bin 5619 -> 5516 bytes 4 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 ksp/launch.bas diff --git a/ksp/Makefile b/ksp/Makefile index d86d9064..629aa010 100644 --- a/ksp/Makefile +++ b/ksp/Makefile @@ -9,6 +9,9 @@ basic: VAB.BAS THEME.BAS ACMPLX.BAS: acmplx.bas $(TXT2BAS) < acmplx.bas > ACMPLX.BAS +LAUNCH.BAS: launch.bas + $(TXT2BAS) < launch.bas > LAUNCH.BAS + LOADING.BAS: loading.bas $(TXT2BAS) < loading.bas > LOADING.BAS @@ -18,6 +21,7 @@ VAB.BAS: vab.bas ksp.dsk: ACMPLX.BAS \ + LAUNCH.BAS \ LOADING.BAS LOADING.HGR SQUAD.HGR TITLE.HGR \ VAB.BAS VAB.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 A LOADING.BAS $(DOS33) -y ksp.dsk SAVE A ACMPLX.BAS + $(DOS33) -y ksp.dsk SAVE A LAUNCH.BAS LOADING.HGR: loading.pcx diff --git a/ksp/c/ksp_launch.c b/ksp/c/ksp_launch.c index a328c573..e40007e0 100644 --- a/ksp/c/ksp_launch.c +++ b/ksp/c/ksp_launch.c @@ -6,10 +6,21 @@ /* 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 */ int main(int argc, char **argv) { + double angle=0; + double capsule_mass=1.0; double engine_isp=270.0; /* s */ @@ -19,6 +30,7 @@ int main(int argc, char **argv) { double tank_mass=0.5; /* tons */ double fuel_mass=4.0; /* tons */ + double total_fuel=fuel_mass; double gravity=9.8; /* m/s^2 */ @@ -31,6 +43,10 @@ int main(int argc, char **argv) { double time=0.0; /* s */ + int stage=1; + + char input; + total_mass=engine_mass+tank_mass+fuel_mass+capsule_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", fuel_flow_rate,fuel_mass/fuel_flow_rate); - for(time=0.0;time<500.0;time++) { - printf("Time: %lf\n",time); - printf("\tFuel left: %lf\n",fuel_mass); + while(1) { if (fuel_mass<0.1) { fuel_mass=0.0; rocket_acceleration=-gravity; @@ -69,9 +83,32 @@ int main(int argc, char **argv) { fuel_mass=fuel_mass-fuel_flow_rate; 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); - printf("\tRocket altitude: %lf m\n",rocket_altitude); + + home(); + + 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; diff --git a/ksp/launch.bas b/ksp/launch.bas new file mode 100644 index 00000000..f3cbdae2 --- /dev/null +++ b/ksp/launch.bas @@ -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 diff --git a/ksp/title.pcx b/ksp/title.pcx index 4943f40c86a851fa7109774265f1864134e7a0e0..9160cf8f9d7db92fa4a02783e3a34d36d423cb39 100644 GIT binary patch delta 510 zcmYLGJxYT?6r9<-6c#3eD2kPJt{@hk!*kf?0(LopHxRtR?tVY{LHtS7G**IWA*cu@ zA~^3;u-IjH=FPk}yYIc@-s#b5KN8QwMAW*+7oJ%XsTl&zSNpx;WCq%Np|g$+;DlXA)^3{H2^*XEBJfUl zq4nDcwGiYmq0N?fvMJGFq_4U=G$IXPPI{P+D@%XAkWd_yAF# zU`UWE*?`^6m864L#KCTNz3->ryL2Hk2VTJ*Js?7C$V`b_1p`|Pxi#6`#Cz#sUSaiL z|Hz?*A>Uw?8~Brtj8=2m6v(nLeF9bU1iR4l9{9&tM)pJ%KVXGWh4Y|Z_X3+ptWkoH UAgtmu>|BBH?QlNZSi5ik0IqP$`vCzxY?!iWY*3kVFJ$ zzbJ%9-t6rB>^mBM4o?ny`$iaA&QP*I!6|r&Zv<$dxtL&4ueBP8A`;@d0eLJ4*qh za_m#C%#QmTqtsVRR!Wu1R2skFCFWrm2TWxO@ik0_orQ)fD}B?QgsNZs)#?@eSx#{W zI+V_9c9ezxODd6C%1+0BAHmzdWYURbF0lze;7#bnmx@kt6*+m!WunJ96DBzLFYt@_ ve2E_Sk&2^