-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1612 lines (1531 loc) · 54.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Star Trek Classic">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Star Trek Classic : BASIC</title>
<link rel="stylesheet" type="text/css" href="https://www.emogic.com/games/StarTrek_Classic/lcars.css">
<style>
body
{
color: white;
background-color : black;
}
#game_area
{
border-style: solid;
border-width: 1px;
white-space: pre;
font-family: 'courier';
overflow: auto;
height: 400px;
}
.w100
{
width:100%;
}
.sizable_font
{
font-size:calc(8px + .8vw);
}
.my_border
{
border-style: solid;
border-width: 1px;
border-color: black;
}
#zoom_container
{
width: 100%;
height: 120px;
position: relative;
overflow: hidden;
display: none;
}
#zoom_space
{
position: absolute;
}
</style>
<script>
</script>
</head>
<body>
<!--
https://en.wikipedia.org/wiki/Star_Trek_(1971_video_game)</br>
-->
<table cellpadding='0' cellspacing='0' border=0 width='100%'>
<tr>
<td valign='top'>
<div class="lcars-elbow left-bottom" ><a></a></div>
<div class="lcars-text-box lcars-golden-tanoi-bg" > </div>
</td>
<td valign='top' width='100%'>
<div class='lcars-bar horizontal'><b><i>Star Trek Classic : Basic</i></b></div>
<div class="lcars-row sizable_font">
<div class="lcars-element rounded lcars-dodger-blue-bg lcars-text-box w100 my_border" onclick="GOSUB5820(); PRINT('COMMAND: ')">Manual</div>
<div class="lcars-element rounded lcars-dodger-blue-bg lcars-text-box w100 my_border" onclick="playAudio('Space');">Space</div>
</div>
<div class="lcars-row sizable_font">
<div class="lcars-element rounded lcars-dodger-blue-bg lcars-text-box w100 my_border" onclick="copyGame(game_area)">Record</div>
<div class="lcars-element rounded lcars-dodger-blue-bg lcars-text-box w100 my_border" onclick="game_area.innerHTML='';">Clear</div>
</div>
</td>
<td valign='top'>
<div class='lcars-bar horizontal right-end '></div>
</td>
</tr>
</table>
<audio id='myAudio'>
<source src="https://www.emogic.com/mine/TypingTutor/space.mp3" type="audio/wav">
Your browser does not support the audio element.
</audio>
<div id='zoom_container'>
<pre id='zoom_space'>
,------*------,
,-------------, '--- ------'
'-------- --' / /
,---' '-------/ /--,
'-----------------'
THE USS ENTERPRISE --- NCC-1701
</pre>
</div>
<div id='game_area' class='lcars-text-box w100'></div>
<form action='javascript:void(0);'>
Commands: <input id="command_box" type="text" autocomplete="off">
</form>
<!--
http://joernweissenborn.github.io/lcars/
https://github.com/joernweissenborn/lcars
-->
<div class="lcars-column lcars-u-2 w100">
<div class="lcars-bracket top hollow"></div>
<div class="lcars-row">
<div class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">.</div>
<div title='COMMAND 1 = SHORT RANGE SENSOR SCAN
PRINTS THE QUADRANT YOU ARE CURRENTLY IN, INCLUDING
STARS, KLINGONS, STARBASES, AND THE ENTERPRISE; ALONG
WITH OTHER PERTINATE INFORMATION.' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">1</div>
<div title='COMMAND 2 = LONG RANGE SENSOR SCAN
SHOWS CONDITIONS IN SPACE FOR ONE QUADRANT ON EACH SIDE
OF THE ENTERPRISE IN THE MIDDLE OF THE SCAN. THE SCAN
IS CODED IN THE FORM XXX, WHERE THE UNITS DIGIT IS THE
NUMBER OF STARS, THE TENS DIGIT IS THE NUMBER OF STAR-
BASES, THE HUNDREDS DIGIT IS THE NUMBER OF KLINGONS.' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">2</div>
<div title='COMMAND 3 = PHASER CONTROL ALLOWS YOU TO DESTROY THE KLINGONS BY HITTING HIM WITH SUITABLY LARGE NUMBERS OF ENERGY UNITS TO DEPLETE HIS SHIELD POWER. KEEP IN MIND THAT WHEN YOU SHOOT AT HIM, HE GONNA DO IT TO YOU TOO.' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">3</div>
<div title='COMMAND 4 = PHOTON TORPEDO CONTROL
COURSE IS THE SAME AS USED IN WARP ENGINE CONTROL
IF YOU HIT THE KLINGON, HE IS DESTROYED AND CANNOT FIRE
BACK AT YOU. IF YOU MISS, HE WILL SHOOT HIS PHASERS AT
YOU.
NOTE: THE LIBRARY COMPUTER (COMMAND 7) HAS AN OPTION
TO COMPUTE TORPEDO TRAJECTORY FOR YOU (OPTION 2).' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">4</div>
<div title='COMMAND 5 = SHIELD CONTROL
DEFINES NUMBER OF ENERGY UNITS TO BE ASSIGNED TO SHIELDS
ENERGY IS TAKEN FROM TOTAL SHIPS ENERGY.' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">5</div>
<div title='COMMAND 6 = DAMAGE CONTROL REPORT
GIVES STATE OF REPAIRS OF ALL DEVICES. A STATE OF REPAIR
LESS THAN ZERO SHOWS THAT THAT DEVICE IS TEMPORARALY
DAMAGED.' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">6</div>
<div title='COMMAND 7 = LIBRARY COMPUTER
THE LIBRARY COMPUTER CONTAINS THREE OPTIONS:
OPTION 0 = CUMULATIVE GALACTIC RECORD
SHOWS COMPUTER MEMORY OF THE RESULTS OF ALL PREVIOUS
LONG RANGE SENSOR SCANS
OPTION 1 = STATUS REPORT
SHOWS NUMBER OF KLINGONS, STARDATES AND STARBASES
LEFT.
OPTION 2 = PHOTON TORPEDO DATA
GIVES TRAJECTORY AND DISTANCE BETWEEN THE ENTERPRISE
AND ALL KLINGONS IN YOUR QUADRANT' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">7</div>
<div class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">8</div>
<div class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">9</div>
<div title='COMMAND 0 = WARP ENGINE CONTROL
"COURSE" IS IN A CIRCULAR NUMERICAL 4 3 2
VECTOR ARRANGEMENT AS SHOWN. \ ^ /
INTERGER AND REAL VALUES MAY BE \^/
USED. THEREFORE COURSE 1.5 IS 5 ----- 1
HALF WAY BETWEEN 1 AND 2. /^\
/ ^ \
A VECTOR OF 9 IS UNDEFINED, BUT 6 7 8
VALUES MAY APPROACH 9.
COURSE
ONE "WARP FACTOR" IS THE SIZE OF
ONE QUADRANT. THEREFORE TO GET
FROM QUADRANT 6,5 TO 5,5 YOU WOULD
USE COURSE 3, WARP FACTOR 1' class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="buttonCommands(this.innerHTML)">0</div>
<div class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick="storeCommand();">Enter</div>
<div class="lcars-element lcars-dodger-blue-bg lcars-text-box w100" onclick=" command_box.value ='';">Clear</div>
</div>
<div class="lcars-bracket bottom hollow"></div>
</div>
<p class='tocenter'><a href='https://github.com/vpelss/StarTrek-Classic' target='_blank'>Github</a></p>
<p class='tocenter'><a href='https://www.emogic.com/' target='_blank'>by Emogic</a></p>
<script>
var zoom_space = document.getElementById('zoom_space'); //set a DOM element for the zoom_space
var zoom_container = document.getElementById('zoom_container'); //set a DOM element for the zoom_container
var game_area = document.getElementById('game_area'); //set a DOM element for the game area
var command_box = document.getElementById('command_box'); //set a DOM element for the commands area
command_box.focus();
var x = document.getElementById("myAudio");
function playAudio() {
x.play();
}
function buttonCommands(button)
{
command_box.blur();
command_box.value = command_box.value + button;
command_box.blur();
//command_box.focus();
}
function copyGame(elm)
{
//var elm = document.getElementById("divClipboard");
// for Internet Explorer
if(document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(elm);
range.select();
document.execCommand("Copy");
alert("Copied the game to clipboard");
}
else if(window.getSelection) {
// other browsers
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(elm);
selection.removeAllRanges();
selection.addRange(range);
document.execCommand("Copy");
alert("Copied the game to clipboard");
}
}
function PRINT (thestring) //set a PRINT function
{
if (thestring === undefined) {thestring='\r';}
game_area.innerHTML = game_area.innerHTML + '\n' + thestring;
var objDiv = document.getElementById("game_area");
objDiv.scrollTop = objDiv.scrollHeight;
}
function PRINTLETTER (thestring) //set a PRINT function
{
if (thestring === undefined) {thestring='';}
game_area.innerHTML = game_area.innerHTML + thestring;
var objDiv = document.getElementById("game_area");
objDiv.scrollTop = objDiv.scrollHeight;
}
function FillArray(theArray , theValue)
{
var arrayLength = theArray.length;
for(var I = 0 ; I < arrayLength; I++)
{
if ( !(theArray[I] instanceof Array) )
{//at the end on this array of array, so set the value and return
theArray[I] = theValue;
}
else
{//recurse through array of arrays
FillArray(theArray[I] , theValue);
}
}
}
//like the BASIC DIM :) use: var multiDimensionalArray = DIM([7,8,9])
function DIM( arrayOfDimensions , theValue)
{
let localArrayOfDimensions = arrayOfDimensions.slice(); //must copy array as scope is global for arrayofdimensions
let returnArray = [];
if (localArrayOfDimensions.length === 0) //no more dimensions
{
return theValue; //for variables , string or number value only
//return JSON.parse(JSON.stringify(theValue)); //copy the value, not the pointer if an array or object
//if(typeof theValue === undefined)
// {return undefined;}
//else
//{return theValue;}
}
let arraySize = localArrayOfDimensions.shift(); // size of current dimension
for (let arrayPointer = 0 ; arrayPointer < arraySize ; arrayPointer++)
{//for each array pointer in this array dimension, recusivly call DIM, and return and assign the value
returnArray[arrayPointer] = DIM( localArrayOfDimensions , theValue);
}
return returnArray; //return here if there are still more array dimensions
}
function StringReplace(fullString , replaceLocation , replaceString)
{
//string.substr(start, length)
//string.substring(start, end)\
var replacementStringLength = replaceString.length;
var newString = fullString.substring(0 , replaceLocation) + replaceString + fullString.substring(replaceLocation + replacementStringLength);
return newString ;
}
//modified changed D to I, and two calls use I now
function FND(I) //360 DEF FND(D)=SQR((K[I,1]-S1)^2+(K[I,2]-S2)^2)
{
return Math.sqrt( Math.pow( K[I][1] - S1 , 2 ) + Math.pow( K[I][2] - S2 , 2 ) );
}
function FNR(R)
{
return Math.floor( Math.random() * R * 7.98 + 1.01 );
}
//allows us to take BASIC INPUT (which waits) and allow the command_box to call an event and resume program logic
var globalComandStorage = ''; //value from command_box
var nextLine = 200; //where we will resume code after command_box event. Line200 in this starting case
document.getElementById("command_box").addEventListener('change', storeCommand); //store command
document.getElementById("command_box").focus();
function storeCommand()
{
globalComandStorage = document.getElementById("command_box").value;
document.getElementById("command_box").value = '';
PRINTLETTER(' ' + globalComandStorage);
switch_board(nextLine); //resume program
};
function switch_board(lineNumber)
{
var fnName = "Line" + lineNumber;
window[fnName]();
}
/*
https://en.wikipedia.org/wiki/HP_Time-Shared_BASIC
REM Extracted from HP tape image 16-Nov-2003 by Pete Turnbull
1 REM **** HP BASIC PROGRAM LIBRARY ******************************
2 REM
3 REM STTR1: STAR TREK
4 REM
5 REM 36243 REV B -- 10/73
6 REM
7 REM **** CONTRIBUTED PROGRAM ***********************************
100 REM *****************************************************************
110 REM *** ***
120 REM *** STAR TREK: BY MIKE MAYFIELD, CENTERLINE ENGINEERING ***
130 REM *** ***
140 REM *** TOTAL INTERACTION GAME - ORIG. 20 OCT 1972
150 REM *** ***
160 REM *****************************************************************
*/
//global variables. need to be created outside functions
var G = DIM([8+1,8+1]); //260 DIM G[8,8],C[9,2],K[3,3],N[3],Z[8,8]
var C = DIM([9+1,2+1]);
var K = DIM([3+1,3+1]);
var NN = DIM([3+1]);
var Z = DIM([8+1,8+1]);
var C$ = ''; //270 DIM C$[6],D$[72],E$[24],A$[3],Q$[72],R$[72],S$[48]
var D$ = '';
var E$ = '';
var A$ = '';
var Q$ = ''; //Note: later Q$[][] is used. second [] is acting like substring location
var R$ = '';
var S$ = '';
var Z$ = ' '; //73 spaces //280 DIM Z$[72]
var T0 = T = Math.floor(Math.random() * 20 + 20) * 100; //290 T0=T=INT(RND(1)*20+20)*100
var T9 = 30; //300 T9=30
var D0 = 0; //310 D0=0
var E0 = E = 3000; //320 E0=E=3000
var P0 = P = 10; //330 P0=P=10
var S9 = 200; //340 S9=200
var S = H8 = 0; //350 S=H8=0
var Q1 = Math.floor(Math.random()*8+1); //370 Q1=INT(RND(1)*8+1)
var Q2 = Math.floor(Math.random()*8+1); //380 Q2=INT(RND(1)*8+1)
var S1 = Math.floor(Math.random()*8+1); //390 S1=INT(RND(1)*8+1)
var S2 = Math.floor(Math.random()*8+1); //400 S2=INT(RND(1)*8+1)
var dt = new Date(); //410 T7=TIM(0)+60*TIM(1)
var T7 = dt.getTime();
var S3,K3,K9,B3,B9,X,W1,C1,R1,R2,Z1,Z2; //var that need init
var D = DIM([8+1]);
//170 GOSUB 5460
//GOSUB5460(); //print 11 lines
//PRINT(" STAR TREK ");//180 PRINT " STAR TREK "
//PRINT ("DO YOU WANT INSTRUCTIONS (y/n) (THEY ARE LONG!)");//190 PRINT "DO YOU WANT INSTRUCTIONS (THEY'RE LONG!)";
nextLine=230;
Line230();
// added a Intructions button. Ignore
function Line200()
{
game_area.innerHTML = '';
A$ = globalComandStorage;//200 INPUT A$
if(A$ == 'y') //210 IF A$ <> "YES" THEN 230
{//220 GOSUB 5820
GOSUB5820();
}
Line230();
return;
}
function Line230()
{
PRINT("Internet Explorer is not supported. Please use a grown up browser.");
//230 REM ***** PROGRAM STARTS HERE *****
//did at var Z$ //240 Z$=" "
//250 GOSUB 5460
//GOSUB5460(); //11 blank lines
T0 = T = Math.floor(Math.random() * 20 + 20) * 100; //290 T0=T=INT(RND(1)*20+20)*100
T9 = 30; //300 T9=30
D0 = 0; //310 D0=0
E0 = E = 3000; //320 E0=E=3000
P0 = P = 10; //330 P0=P=10
S9 = 200; //340 S9=200
S = H8 = 0; //350 S=H8=0
Q1 = Math.floor(Math.random()*8+1); //370 Q1=INT(RND(1)*8+1)
Q2 = Math.floor(Math.random()*8+1); //380 Q2=INT(RND(1)*8+1)
S1 = Math.floor(Math.random()*8+1); //390 S1=INT(RND(1)*8+1)
S2 = Math.floor(Math.random()*8+1); //400 S2=INT(RND(1)*8+1)
//Q1=1;Q2=1;S1=4;S2=4;
dt = new Date(); //410 T7=TIM(0)+60*TIM(1)
T7 = dt.getTime();
//420 C[2,1]=C[3,1]=C[4,1]=C[4,2]=C[5,2]=C[6,2]=-1
C[2][1]=C[3][1]=C[4][1]=C[4][2]=C[5][2]=C[6][2] = -1;
//430 C[1,1]=C[3,2]=C[5,1]=C[7,2]=C[9,1]=0
C[1][1]=C[3][2]=C[5][1]=C[7][2]=C[9][1] = 0;
//440 C[1,2]=C[2,2]=C[6,1]=C[7,1]=C[8,1]=C[8,2]=C[9,2]=1
C[1][2]=C[2][2]=C[6][1]=C[7][1]=C[8][1]=C[8][2]=C[9][2] = 1;
FillArray(D , 0); //450 MAT D=ZER
//460 D$="WARP ENGINESS.R. SENSORSL.R. SENSORSPHASER CNTRL"
D$ = " WARP ENGINESS.R. SENSORSL.R. SENSORSPHASER CNTRLPHOTON TUBESDAMAGE CNTRL";
//470 D$[49]="PHOTON TUBESDAMAGE CNTRL"
E$=" SHIELD CNTRLCOMPUTER"; //480 E$="SHIELD CNTRLCOMPUTER"
do{
B9 = K9 = 0; //490 B9=K9=0
for(var I=1 ; I <= 8 ; I++) //500 FOR I=1 TO 8
{
for(var J=1 ; J <= 8 ; J++) //510 FOR J=1 TO 8
{
R1 = Math.random(); //520 R1=RND(1)
if(R1 > 0.98) //530 IF R1>.98 THEN 580
{//580 K3=3 //590 K9=K9+3 //600 GOTO 660
K3 = 3;
K9 = K9 + 3;
}
else if(R1 > 0.95) //540 IF R1>.95 THEN 610
{//610 K3=2 //620 K9=K9+2 //630 GOTO 660
K3=2;
K9= K9+2;
}
else if(R1 > 0.8) //550 IF R1>.8 THEN 640
{//640 K3=1 //650 K9=K9+1
K3 = 1;
K9 = K9 + 1;
}
else //560 K3=0
{//570 GOTO 660
K3 = 0;
}
R1 = Math.random(); //660 R1=RND(1)
if(R1 > 0.96) //670 IF R1>.96 THEN 700
{ //700 B3=1 //710 B9=B9+1
B3 = 1;
B9 = B9 + 1;
}
else
{//680 B3=0 //690 GOTO 720
B3 = 0;
}
S3 = Math.round(Math.random()*8+1);//720 S3=INT(RND(1)*8+1)
G[I][J]=K3*100+B3*10+S3; //730 G[I,J]=K3*100+B3*10+S3
Z[I][J]=0;//740 Z[I,J]=0
}//750 NEXT J
}//760 NEXT I
K7 = K9; //770 K7=K9
}while((B9 <= 0) || (K9 <= 0)); //775 IF B9 <= 0 OR K9 <= 0 THEN 490
PRINT();
PRINT("YOU MUST DESTROY "+K9+" KLINGONS IN "+T9+" STARDATES WITH "+B9+" STARBASES");//780 PRINT "YOU MUST DESTROY"K9;" KLINGONS IN"T9;" STARDATES WITH"B9;" STARBASES"
GOTO810();return;
};
function GOTO810()
{//entering new quadrant, build it
K3=B3=S3=0;//810 K3=B3=S3=0
if( !(Q1<1 || Q1>8 || Q2<1 || Q2>8) )//820 IF Q1<1 OR Q1>8 OR Q2<1 OR Q2>8 THEN 920
{
X=G[Q1][Q2]*0.01; //830 X=G[Q1,Q2]*.01
K3=Math.floor(X);//840 K3=INT(X)
B3=Math.floor((X-K3)*10);//850 B3=INT((X-K3)*10)
S3=G[Q1][Q2]-Math.floor(G[Q1][Q2]*0.1)*10; //860 S3=G[Q1,Q2]-INT(G[Q1,Q2]*.1)*10
if(K3!==0)//870 IF K3=0 THEN 910
{
if(S<=200)//880 IF S>200 THEN 910
{
PRINT("COMBAT AREA CONDITION RED");//890 PRINT "COMBAT AREA CONDITION RED"
PRINT(" SHIELDS DANGEROUSLY LOW");//900 PRINT " SHIELDS DANGEROUSLY LOW"
}
}
FillArray(K, 0); //910 MAT K=ZER
}
//duplicate 910?
for(var I=1 ; I<=3 ; I++)//920 FOR I=1 TO 3
{
K[I][3]=0;//930 K[I,3]=0
}//940 NEXT I
Q$=Z$; // fill array with blank lines //950 Q$=Z$
R$=Z$; //960 R$=Z$
S$=Z$; //970 S$=Z$[1,48]
//place enterprise
A$="<*>"; //980 A$="<*>"
Z1=S1; //990 Z1=S1
Z2=S2; //1000 Z2=S2
GOSUB5510(); //1010 GOSUB 5510
//place klingons
for(var I=1 ; I<=K3 ; I++)//1020 FOR I=1 TO K3
{
GOSUB5380(); //1030 GOSUB 5380
A$="+++"; //1040 A$="+++"
Z1=R1;//1050 Z1=R1
Z2=R2;//1060 Z2=R2
GOSUB5510(); //1070 GOSUB 5510
K[I][1]=R1;//1080 K[I,1]=R1
K[I][2]=R2;//1090 K[I,2]=R2
K[I][3]=S9;//1100 K[I,3]=S9
//K[3][1]=1; K[3][2]=7; K[3][3]=100; //remove
}//1110 NEXT I
//place base(s)
for(var I=1 ; I<=B3 ; I++) //1120 FOR I=1 TO B3
{
GOSUB5380(); //1130 GOSUB 5380
A$=">!<";//1140 A$=">!<"
Z1=R1;//1150 Z1=R1
Z2=R2;//1160 Z2=R2
GOSUB5510();//1170 GOSUB 5510
} //1180 NEXT I
//place stars
for(var I=1 ; I<=S3 ; I++) //1190 FOR I=1 TO S3
{
GOSUB5380(); //1200 GOSUB 5380
A$=" * ";//1210 A$=" * "
Z1=R1; //1220 Z1=R1
Z2=R2; //1230 Z2=R2
GOSUB5510();//1240 GOSUB 5510
} //1250 NEXT I
GOSUB4120();//1260 GOSUB 4120
PRINT("COMMAND:"); //1270 PRINT "COMMAND:";
nextLine = 1270;
}
function Line1270()
{
//PRINT("COMMAND:"); //1270 PRINT "COMMAND:";
A = parseInt(globalComandStorage); //1280 INPUT A
switch(A)//1290 GOTO A+1 OF 1410,1260,2330,2530,2800,3460,3560,4630
{
case 0: //move
PRINT("COURSE (1-9):"); //1410 PRINT "COURSE (1-9):";
nextLine = 1410;
return;
case 1: //short range scan
GOSUB4120();//1260 GOSUB 4120 ;
PRINT("COMMAND:");
return;
case 2: //long range sensors
Line2330();
return;
case 3: //phasers
Line2530();
return;
case 4: //photons
Line2800();
return;
case 5: //shields
Line3460();
return;
case 6: //shields
Line3560();
return;
case 7: //shields
Line4630();
return;
default:
{
//PRINT(); //1300 PRINT
PRINT(" 0 = SET COURSE");//1310 PRINT " 0 = SET COURSE"
PRINT(" 1 = SHORT RANGE SENSOR SCAN");//1320 PRINT " 1 = SHORT RANGE SENSOR SCAN"
PRINT(" 2 = LONG RANGE SENSOR SCAN");//1330 PRINT " 2 = LONG RANGE SENSOR SCAN"
PRINT(" 3 = FIRE PHASERS");//1340 PRINT " 3 = FIRE PHASERS"
PRINT(" 4 = FIRE PHOTON TORPEDOES"); //1350 PRINT " 4 = FIRE PHOTON TORPEDOES"
PRINT(" 5 = SHIELD CONTROL"); //1360 PRINT " 5 = SHIELD CONTROL"
PRINT(" 6 = DAMAGE CONTROL REPORT"); //1370 PRINT " 6 = DAMAGE CONTROL REPORT"
PRINT(" 7 = CALL ON LIBRARY COMPUTER"); //1380 PRINT " 7 = CALL ON LIBRARY COMPUTER"
//PRINT(); //1390 PRINT
PRINT("COMMAND:"); //1270 PRINT "COMMAND:";
nextLine = 1270; //1400 GOTO 1270
}
}
}
function Line1410()
{
C1 = parseInt( globalComandStorage );//1420 INPUT C1
if(C1==0)//1430 IF C1=0 THEN 1270
{
PRINT("COURSE CANCELLED");
PRINT("COMMAND:"); //1270 PRINT "COMMAND:";
nextLine = 1270;
return;
}
if(C1<1 || C1>=9)//1440 IF C1<1 OR C1 >= 9 THEN 1410
{
PRINT("COURSE (1-9):"); //1410 PRINT "COURSE (1-9):";
nextLine=1410;
return;
}
PRINT("WARP FACTOR (0-8):");//1450 PRINT "WARP FACTOR (0-8):";
nextLine=1460;
}
function Line1460()
{
W1 = parseFloat( globalComandStorage );//1460 INPUT W1
if(W1<0 || W1>8)//1470 IF W1<0 OR W1>8 THEN 1410
{
PRINT("COURSE (1-9):"); //1410 PRINT "COURSE (1-9):";
nextLine=1410;
return;
}
if (!(D[1] >= 0 || W1 <= .2))//1480 IF D[1] >= 0 OR W1 <= .2 THEN 1510
{
PRINT("WARP ENGINES ARE DAMAGED, MAXIMUM SPEED = WARP .2");//1490 PRINT "WARP ENGINES ARE DAMAGED, MAXIMUM SPEED = WARP .2"
PRINT("COURSE (1-9):"); //1410 PRINT "COURSE (1-9):";
nextLine=1410;
return;//1500 GOTO 1410
}
//1510 IF K3 <= 0 THEN 1560 : NOT REQIRED : GOSUB3790() has this check at start
GOSUB3790();//1520 GOSUB 3790 klingons attack
if(K3<0)//1530 IF K3 <= 0 THEN 1560
{
if(E>0)//1560 IF E>0 THEN 1610
{
Line1610(); return; //like a GOTO
}
if(S<1)//1570 IF S<1 THEN 3920
{
GOTO3920(); return; //we lose :(
}
PRINT("YOU HAVE" + E + " UNITS OF ENERGY");//1580 PRINT "YOU HAVE"E" UNITS OF ENERGY"
PRINT("SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE " + S + " UNITS LEFT");//1590 PRINT "SUGGEST YOU GET SOME FROM YOUR SHIELDS WHICH HAVE"S" UNITS LEFT"
nextLine=1270; //1600 GOTO 1270
return;
}
if(S<0)//1540 IF S<0 THEN 4000 //dead
{
GOTO3920(); return; //we lose :(
}
Line1610(); return; //1550 GOTO 1610
}
function Line1610()
{
//????
for(var I=1 ; I<=8 ; I++)//1610 FOR I=1 TO 8
{
if(D[I] >= 0) {continue} //1620 IF D[I] >= 0 THEN 1640
D[I]=D[I]+1; //1630 D[I]=D[I]+1
}//1640 NEXT I
//80% chance drives work
if(Math.floor(Math.random()) > 0.2 )//1650 IF RND(1)>.2 THEN 1810
{
GOTO1810(); return;
}
//20% chance we will be here
//50% chance of random repair OR damage
R1=Math.floor(Math.random()*8+1)//1660 R1=INT(RND(1)*8+1)
if(Math.random() >= 0.5)//1670 IF RND(1) >= .5 THEN 1750\
{
GOTO1750();
return;
}
D[R1]=D[R1]-(Math.random()*5+1);//1680 D[R1]=D[R1]-(RND(1)*5+1)
PRINT();//1690 PRINT
PRINT("DAMAGE CONTROL REPORT:"); //1700 PRINT "DAMAGE CONTROL REPORT:";
GOSUB5610(); //1710 GOSUB 5610
PRINT(" DAMAGED"); //1720 PRINT " DAMAGED"
PRINT(); //1730 PRINT
GOTO1810(); return;//1740 GOTO 1810
}
function GOTO1750()
{
D[R1]=D[R1]+(Math.random()*5+1); //1750 D[R1]=D[R1]+(RND(1)*5+1)
PRINT();//1760 PRINT
PRINT("DAMAGE CONTROL REPORT:");//1770 PRINT "DAMAGE CONTROL REPORT:";
GOSUB5610(); //1780 GOSUB 5610
PRINT(" STATE OF REPAIR IMPROVED"); //1790 PRINT " STATE OF REPAIR IMPROVED"
PRINT(); //1800 PRINT
GOTO1810(); return;
}
function GOTO1810()
{
N=Math.floor(W1*8); //1810 N=INT(W1*8)
A$=" "; //1820 A$=" "
Z1=S1; //1830 Z1=S1
Z2=S2; //1840 Z2=S2
GOSUB5510(); //1850 GOSUB 5510 insert string
X=S1; //1870 X=S1
Y=S2; //1880 Y=S2
C2=Math.floor(C1); //1885 C2=INT(C1)
// first part is interger direction, and last part does fraction up to next interger direction
X1=C[C2][1]+(C[C2+1][1]-C[C2][1])*(C1-C2); //1890 X1=C[C2,1]+(C[C2+1,1]-C[C2,1])*(C1-C2)
X2=C[C2][2]+(C[C2+1][2]-C[C2][2])*(C1-C2); //1900 X2=C[C2,2]+(C[C2+1,2]-C[C2,2])*(C1-C2)
for(var I=1 ; I<=N ; I++) //1910 FOR I=1 TO N
{
S1=S1+X1; //1920 S1=S1+X1
S2=S2+X2; //1930 S2=S2+X2
if(S1<.5 || S1 >= 8.5 || S2<.5 || S2 >= 8.5) //1940 IF S1<.5 OR S1 >= 8.5 OR S2<.5 OR S2 >= 8.5 THEN 2170
{
GOTO2170(); return;
}
A$=" "; //1950 A$=" "
Z1=S1; //1960 Z1=S1
Z2=S2; //1970 Z2=S2
GOSUB5680(); //1980 GOSUB 5680
//move until we run into something
if(Z3 != 0) {continue;} //1990 IF Z3 <> 0 THEN 2070
PRINT("WARP ENGINES SHUTDOWN AT SECTOR " + S1 + ',' + S2 + " DUE TO BAD NAVIGATION"); //2030 PRINT USING 5370;S1,S2 //5370 IMAGE " WARP ENGINES SHUTDOWN AT SECTOR ",D,",",D," DUE TO BAD NAVIGATION"
S1=S1-X1; //2040 S1=S1-X1
S2=S2-X2; //2050 S2=S2-X2
GOTO2080(); //2060 GOTO 2080
return;
}//2070 NEXT I
GOTO2080(); return;
}
function GOTO2080()
{//same sector
A$="<*>"; //2080 A$="<*>"
S1=Math.floor(S1+.5); //2083 S1=INT(S1+.5)
S2=Math.floor(S2+.5); //2086 S2=INT(S2+.5)
Z1=S1; //2090 Z1=S1
Z2=S2; //2100 Z2=S2
GOSUB5510(); //2110 GOSUB 5510
E=E-N+5; //2120 E=E-N+5
if(W1>=1)//2130 IF W1<1 THEN 2150
{
T=T+1; //2140 T=T+1
}
if(T>T0+T9) //2150 IF T>T0+T9 THEN 3970
{
GOTO3920();
return;
}
GOSUB4120(); //sr sensors
PRINT("COMMAND:"); nextLine = 1270; return; //2160 GOTO 1260
}
function GOTO2170()
{//new sector
X=Q1*8+X+X1*N; //2170 X=Q1*8+X+X1*N
Y=Q2*8+Y+X2*N; //2180 Y=Q2*8+Y+X2*N
Q1=Math.floor(X/8); //2190 Q1=INT(X/8)
Q2=Math.floor(Y/8); //2200 Q2=INT(Y/8)
S1=Math.floor(X-Q1*8+.5); //2210 S1=INT(X-Q1*8+.5)
S2=Math.floor(Y-Q2*8+.5); //2220 S2=INT(Y-Q2*8+.5)
if(S1 == 0)//2230 IF S1 <> 0 THEN 2260
{
Q1=Q1-1; //2240 Q1=Q1-1
S1=8; //2250 S1=8
}
if(S2 == 0) //2260 IF S2 <> 0 THEN 2290
{
Q2=Q2-1; //2270 Q2=Q2-1
S2=8; //2280 S2=8
}
//vinman : create a closed universe
if(Q1<=0)
{
Q1=8+Q1;
}
if(Q2<=0)
{
Q2=8+Q2;
}
if(Q1>=9)
{
Q1=Q1-8;
}
if(Q2>=9)
{
Q2=Q2-8;
}
T=T+1; //2290 T=T+1
E=E-N+5; //2300 E=E-N+5
if(T>T0+T9) //2310 IF T>T0+T9 THEN 3970
{
GOTO3920();
return;
}
GOTO810();return;//2320 GOTO 810
}
function Line2330()
{//long range sensors
if(D[3] < 0)//2330 IF D[3] >= 0 THEN 2370
{
PRINT("LONG RANGE SENSORS ARE INOPERABLE"); //2340 PRINT "LONG RANGE SENSORS ARE INOPERABLE"
PRINT("COMMAND:"); nextLine = 1270; return; //2360 GOTO 1270
}
PRINT( "LONG RANGE SENSOR SCAN FOR QUADRANT " + Q1 + "," + Q2 ); //2370 PRINT USING 2350;Q1,Q2 //2350 IMAGE "LONG RANGE SENSOR SCAN FOR QUADRANT",D,",",D
PRINT("-----------------"); //2380 PRINT USING 2520 //2520 IMAGE "-----------------"
for(var I=Q1-1 ; I <= Q1+1 ; I++)//2390 FOR I=Q1-1 TO Q1+1
{
FillArray(NN , 0);//2400 MAT N=ZER
for(var J=Q2-1 ; J <= Q2+1 ; J++)//2410 FOR J=Q2-1 TO Q2+1
{
if(I<1 || I>8 || J<1 || J>8){continue;}//2420 IF I<1 OR I>8 OR J<1 OR J>8 THEN 2460
NN[J-Q2+2]=G[I][J]; //2430 N[J-Q2+2]=G[I,J]
if(D[7]<0){continue;}//2440 IF D[7]<0 THEN 2460
Z[I][J]=G[I][J]; //2450 Z[I,J]=G[I,J]
}//2460 NEXT J
var pad = ':';
var strN = NN[1].toString().padStart(3, '0') + pad + NN[2].toString().padStart(3, '0') + pad + NN[3].toString().padStart(3, '0');
//str1.padStart(3, '0')
PRINT(pad + strN + pad); //2470 PRINT USING 2510;N[1],N[2],N[3] //2510 IMAGE ": ",3(3D," :")
PRINT("-----------------"); //2480 PRINT USING 2520 //2520 IMAGE "-----------------"
}//2490 NEXT I
PRINT("COMMAND:"); nextLine = 1270; return; //2500 GOTO 1270
}
function Line2530()
{//phasers I
if(K3<=0) //2530 IF K3 <= 0 THEN 3670 //3670 PRINT "SHORT RANGE SENSORS REPORT NO KLINGONS IN THIS QUADRANT" //3680 GOTO 1270
{
PRINT("SHORT RANGE SENSORS REPORT NO KLINGONS IN THIS QUADRANT");
PRINT("COMMAND:"); nextLine = 1270; return;
}
Line2570();
return;
}
function Line2570()
{
if(D[4] < 0) //2540 IF D[4] >= 0 THEN 2570
{
PRINT("PHASER CONTROL IS DISABLED"); //2550 PRINT "PHASER CONTROL IS DISABLED"
PRINT("COMMAND:"); nextLine = 1270; return; //2560 GOTO 1270
}
if(D[7]<0) //2570 IF D[7] >= 0 THEN 2590
{
PRINT("COMPUTER FAILURE HAMPERS ACCURACY"); //2580 PRINT " COMPUTER FAILURE HAMPERS ACCURACY"
}
PRINT("PHASERS LOCKED ON TARGET. ENERGY AVAILABLE=" + E); //2590 PRINT "PHASERS LOCKED ON TARGET. ENERGY AVAILABLE="E
PRINT("NUMBER OF UNITS TO FIRE:"); //2600 PRINT "NUMBER OF UNITS TO FIRE:";
nextLine=2610; //2610 INPUT X
}
function Line2610()
{
var X = parseInt( globalComandStorage ); //2610 INPUT X
if(X<=0) //2620 IF X <= 0 THEN 1270
{
PRINT("COMMAND:"); nextLine = 1270; return; //2560 GOTO 1270
}
if(E-X<0)//2630 IF E-X<0 THEN 2570
{
Line2570();return;
}
E=E-X; //2640 E=E-X
GOSUB3790(); //klingons fire first? //2650 GOSUB 3790
if(D[7]<0)//2660 IF D[7] >= 0 THEN 2680
{
X=X*Math.random(); //2670 X=X*RND(1)
}
for(var I=1 ; I<=3 ; I++) //2680 FOR I=1 TO 3
{
if(K[I][3]<=0){continue;} //2690 IF K[I,3] <= 0 THEN 2770
H=(X/K3/FND(I))*(2*Math.random()); //2700 H=(X/K3/FND(I))*(2*RND(1))
K[I][3]=K[I][3]-H; //2710 K[I,3]=K[I,3]-H
PRINT(H + " UNIT HIT ON KLINGON AT SECTOR " + K[I][1] +','+ K[I][2] +': '+ K[I][3] + ' LEFT'); //2720 PRINT USING 2730;H,K[I,1],K[I,2],K[I,3]
//2730 IMAGE 4D," UNIT HIT ON KLINGON AT SECTOR ",D,",",D," (",3D," LEFT)"
if(K[I][3]>0){continue;} //2740 IF K[I,3]>0 THEN 2770
GOSUB3690(I); //2750 GOSUB 3690
if(K9 <= 0) //2760 IF K9 <= 0 THEN 4040
{//all klingons destroyed
GOTO4040();
//nextLine=200;
return;
}
}//2770 NEXT I
if(E<0) //2780 IF E<0 THEN 4000
{//Enterprise destroyed
GOTO3920();
//nextLine=200;
return;
}
PRINT("COMMAND:"); nextLine = 1270; return; //2790 GOTO 1270
}
function Line2800()
{ //Photons I
if(D[5]<0) //2800 IF D[5] >= 0 THEN 2830
{
PRINT("PHOTON TUBES ARE NOT OPERATIONAL"); //2810 PRINT "PHOTON TUBES ARE NOT OPERATIONAL"
PRINT("COMMAND:"); nextLine = 1270; return; //2820 GOTO 1270
}
if(P<=0) //2830 IF P>0 THEN 2860
{
PRINT("ALL PHOTON TORPEDOES EXPENDED"); //2840 PRINT "ALL PHOTON TORPEDOES EXPENDED"
PRINT("COMMAND:"); nextLine = 1270; return; //2850 GOTO 1270
}
Line2860();
return;
}
function Line2860()
{
PRINT("TORPEDO COURSE (1-8):"); //2860 PRINT "TORPEDO COURSE (1-9):";
nextLine=2870;
return;
}
function Line2870()
{
C1 = parseFloat( globalComandStorage ); //2870 INPUT C1
if(C1==0) //2880 IF C1=0 THEN 1270
{
PRINT("COMMAND:"); nextLine=1270; return;
}
if(C1<1 || C1 >= 9) //2890 IF C1<1 OR C1 >= 9 THEN 2860
{
Line2860();
return;
}
C2=Math.floor(C1); //2895 C2=INT(C1)
X1=C[C2][1]+(C[C2+1][1]-C[C2][1])*(C1-C2); //2900 X1=C[C2,1]+(C[C2+1,1]-C[C2,1])*(C1-C2)
X2=C[C2][2]+(C[C2+1][2]-C[C2][2])*(C1-C2); //2910 X2=C[C2,2]+(C[C2+1,2]-C[C2,2])*(C1-C2)
X=S1; //2920 X=S1
Y=S2 ; //2930 Y=S2
P=P-1; //2940 P=P-1
PRINT("TORPEDO TRACK:"); //2950 PRINT "TORPEDO TRACK:"
GOTO2960();
return;
}
function GOTO2960()
{
do //move torpedo until we hit something or miss
{
X=X+X1; //2960 X=X+X1
Y=Y+X2; //2970 Y=Y+X2
//has torpedo missed?
if(X<.5 || X >= 8.5 || Y<.5 || Y >= 8.5) //2980 IF X<.5 OR X >= 8.5 OR Y<.5 OR Y >= 8.5 THEN 3420
{
PRINT("TORPEDO MISSED"); //3420 PRINT "TORPEDO MISSED"
GOTO3430();
return;
}
PRINT(X + ',' + Y + ','); //2990 PRINT USING 3000;X,Y
//3000 IMAGE 15X,D,",",D
//is there a target?
A$=" "; //3010 A$=" "
Z1=X; //3020 Z1=X
Z2=Y; //3030 Z2=Y
GOSUB5680(); //3040 GOSUB 5680
}while(Z3!=0) //3050 IF Z3=0 THEN 3070 //3060 GOTO 2960
//check for klingon
A$="+++"; //3070 A$="+++"
Z1=X; //3080 Z1=X
Z2=Y; //3090 Z2=Y
GOSUB5680(); //3100 GOSUB 5680
if(Z3==0) //3110 IF Z3=0 THEN 3220
{
GOTO3220();
return;
}
PRINT("*** KLINGON DESTROYED ***"); //3120 PRINT "*** KLINGON DESTROYED ***"
K3=K3-1; //3130 K3=K3-1
K9=K9-1; //3140 K9=K9-1
if(K9<=0) //3150 IF K9 <= 0 THEN 4040
{GOTO4040(); return;}
for(var I=1 ; I<=3 ; I++) //3160 FOR I=1 TO 3
{
if(Math.floor(X+.5) != K[I][1]) //3170 IF INT(X+.5) <> K[I,1] THEN 3190
{continue;}
if(Math.floor(Y+.5)==K[I][2]) //3180 IF INT(Y+.5)=K[I,2] THEN 3200
{break;}
} //3190 NEXT I
K[I][3]=0; //3200 K[I,3]=0
GOTO3360(); //3210 GOTO 3360
return;
}
function GOTO3220()
{
//check for star
A$=" * "; //3220 A$=" * "
Z1=X; //3230 Z1=X
Z2=Y; //3240 Z2=Y
GOSUB5680(); //3250 GOSUB 5680
if(Z3==0) //3260 IF Z3=0 THEN 3290
{
GOTO3290();
return;
}
PRINT("YOU CAN'T DESTROY STARS SILLY"); //3270 PRINT "YOU CAN'T DESTROY STARS SILLY"
PRINT("TORPEDO MISSED"); //3420 PRINT "TORPEDO MISSED" //3280 GOTO 3420
GOTO3430();
return;
}
function GOTO3290()