Friday 29 January 2016

Trek complete

Yes, it's finished and working, coming in at 3,227 bytes.

This is the (probably) final listing. The next (and probably last) thing I will do is rig the emulator up so this is loaded by default.

I didn't actually write this ; it's pretty incomprehensible. The commented version with full variable names, which is about 5 times as long is on github.

A peculiarity of the original MINOL is you have to write it like this (except you can have comments) - most of the time the interpreter does not allow spaces so you can't write "PR C" it has to be "PRC". I removed the spaces in the preprocessor primarily to save space.

Though I have just noticed it has the superfluous 'A' command which invites the Klingons to attack you (which was for debugging). Still, maybe a Ferengi will play the game, it might be useful ?

The main thing that is missing that I might add, but probably won't as it's nearly time out and the weekend, is the phaser damage does not take distance into account.

But overall I'm quite pleased with it. It does have most of the proper features of Star Trek BASIC, which the other tiny versions (<4k) I have seen don't.

It may be technically wrong. The original MINOL claims a line length of 70 odd characters max but this is more to do with the keyboard buffer than internal structure. With 700 bytes left, I could stretch it out so no line is more than 70 characters long, but I won't :)

   2 (14,254)=12:(14,255)=0:PR$(14,254),"STAR TREK V1.0":PR"(C) PSR 2016":PR:(14,240)=0:(14,241)=7:(14,242)=8
   3 (14,243)=9:(14,244)=255:(14,245)=0:(14,246)=1:(14,247)=0-9:(14,248)=0-8:(14,249)=0-7
   4 PR"SKILL 1-9 ?";:IND:IFD=0;D=5:K=0:I=0
   5 N=0:IF!<2*D+35;N=N+!/80+1:K=K+N:IF!<16;N=N+100:(14,I)=!/50+1*10+N:I=I+1:IFI<64;GOTO5
   6 E=250:T=4:Q=!/4:(14,Q)=163:PRK,"KLINGONS"
  10 I=64:PR"IN QUADRANT ";:N=Q/8*8:(14,254)=Q-N+48:PR$(14,254),",";:(14,254)=Q/8+48:PR$(14,254)
  11 (14,I)=0:I=I+1:IFI#128;GOTO11:N=(14,Q):J=1:O=0:(14,J+151)=255:(14,J+152)=255:(14,J+153)=255:(14,J+154)=255
  12 IFN/10*10=N;GOTO14
  13 I=!/4+64:IF(14,I)#0;GOTO13:(14,I)=J:N=N-1:IF9<J;GOTO12:(14,J+150)=I-64:(14,J+160)=!/10+12:J=J+1:O=O+1:GOTO12
  14 N=N/10:J=J+1:IFJ<9;J=10:IFN#0;GOTO12
  15 S=!/4:IF(14,S+64)#0;GOTO15:(14,S+64)=12
  20 IFK=0;GOTO245:I=(12,128):PR" ",E;:(12,128)=I:PR"E:";:(12,128)=I+5:(14,254)=T+'0';:PR" T:",$(14,254),">";:INI
  21 IFI='A';GOTO200
  22 IFI<33;GOTO30:IFI='S';GOTO30:IFI='L';GOTO40:IFI='W';GOTO50:IFI='M';GOTO60:IFI='Q';GOTO70:IFI='T';GOTO80:IFI='P';GOTO90
  23 PR"CMD: SLWMPTQ":GOTO20
  30 (14,254)=12:PR$(14,254):I=0
  31 N=(14,I+64):IFN=0;GOTO34:IFN<9;N=9:N=N-9*2+224:(0,I*2)=N:(0,I*2+1)=N+1
  34 I=I+1:IFI#64;GOTO31:CALL(0,5):PR$(14,254);:GOTO20
  40 I=7
  41 J=0:PR"  ";
  42 N=I+J:N=(14,240+N):N=N+Q
  43 IFN<64;GOTO44:N=N-64:GOTO43
  44 N=(14,N):M=N/100*100:N=N-M:PRN;:(12,128)=(12,128)-4
  45 (14,254)=M/100+'0':PR$(14,254);:(12,128)=(12,128)+2:IFJ#2;PR"!";:J=J+1:IFJ#3;GOTO42
  46 I=I-3:PR:IFI<7;PR"  ---+---+---":IFI<7;GOTO41:GOTO20
  50 IFE-1<8;GOTO53:PR"DIR:";:INI:IF9<I;GOTO20:Q=Q+(14,240+I):E=E-8
  51 IFQ<64;GOTO52:Q=Q-64:GOTO51
  52 GOTO10
  53 PR"ENERGY!":GOTO20
  60 PR"DIR : ";:INI:IF9<I;GOTO20:I=(14,240+I):IFI=0;GOTO20:PR"WARP: ";:INJ:IF8<J;GOTO20:(14,S+64)=0
  61 IFJ=0;GOTO65:IFE-1<2;GOTO65:J=J-1:E=E-2:S=S+I
  62 IFS<64;GOTO63:S=S-64:GOTO62
  63 N=(14,S+64):IFN=0;GOTO61:IFN<10;GOTO240:IFN=10;GOTO241:PR"STARBASE DOCK":E=250:T=4:(14,Q)=(14,Q)-100
  65 (14,S+64)=12:GOTO200
  70 PR"SURE ?";:INI:IFI='Y';GOTO242:GOTO20
  80 IFT=0;GOTO20:PR"DIR : ";:INI:IF9<I;GOTO20:I=(14,240+I):IFI=0;GOTO20:J=7:N=S:T=T-1
  81 IFJ=0;GOTO200:J=J-1:N=N+I
  82 IFN<64;GOTO83:N=N-64:GOTO82
  83 M=(14,64+N):IFM=0;GOTO81:IFM=10;GOTO200:IFM=11;GOTO243:IFM=12;END:I=M:GOTO120
  90 IFO=0;GOTO20:PR"LVL : ";:INI:IFI=0;GOTO20:IFE-1<I;GOTO20:E=E-I:N=I/O+3:N=N-D+5:IF200<N;N=0:I=1
  91 IF(14,150+I)=255;GOTO94:J=(14,160+I)-N:(14,160+I)=J:IF200<J;GOTO120
  94 I=I+1:IFI#5;GOTO91:GOTO200
 120 PR"KLINGON DOWN !":J=(14,I+150):IFJ=255;END:N=(14,J+64):IFN#I;END:K=K-1:PRK,"LEFT"
 121 O=O-1:(14,J+64)=0:(14,I+150)=255:(14,Q)=(14,Q)-1:IFK=0;GOTO245:GOTO200
 200 IFO=0;GOTO20:I=0:PR"KLINGONS ATTACK"
 201 I=I+1:IFI=5;GOTO20:IF(14,I+150)=255;GOTO201:GOTO220
 210 N=!/32+1:IFN=6;N=9:N=(14,N+240):J=(14,I+150)+N:IF(14,(14,I+150)+64)#I;END
 211 IFJ<64;GOTO212:J=J-64:GOTO211
 212 IF(14,J+64)#0;GOTO201:(14,(14,I+150)+64)=0:(14,I+150)=J:(14,J+64)=I:GOTO201
 220 N=(14,I+160):N=N+D-5:M=!/64+1:N=N*M/4:IFN=0;GOTO201:IFE<N;N=E
 221 E=E-N:PRN,"DAMAGE":IFE=0;GOTO244
 222 M=(14,I+160):N=N/3:IFM-1<N;N=M-1:(14,I+160)=M-N:GOTO201
 240 PR"YOU HAVE COLLIDED WITH A KLINGON.":END
 241 PR"YOU HAVE BURNED UP IN A STAR.":END
 242 PR"YOU HAVE RESIGNED FROM STARFLEET.":END
 243 PR"YOU HAVE DESTROYED A STARBASE AND BEEN ARRESTED.":END
 244 PR"A KLINGON SHIP DESTROYED YOU":END
 245 PR"CONGRATS - YOU WON !":END

.

No comments:

Post a Comment