-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.wsa
1385 lines (1243 loc) · 17.8 KB
/
game.wsa
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; It's all so empty... ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Heap layout: ;;
;; 1-256 are used for variables. ;;
;; 1 is quarks. ;;
;; 2 is heat. ;;
;; 3 is neutrons. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 257-512 are for internals. ;;
;; 257 is used for stdin. ;;
;; 258 is the seed of the RNG. ;;
;; 259 is a temp variable. ;;
;; 260 is number of quarks/heat ;;
;; on quark creation. ;;
;; 261 is chance to avoid quark ;;
;; annihilation * 10. ;;
;; 262 is universal expansion ;;
;; * 100. ;;
;; 263 is quarks/second. ;;
;; 264 is total q-generator Is. ;;
;; 265 is q-gen I multiplier ;;
;; * 100. ;;
;; 266 is total q-generator IIs. ;;
;; 267 is q-gen II multiplier ;;
;; * 100. ;;
;; 268 is total q-generator III. ;;
;; 269 is q-gen III multiplier ;;
;; * 100. ;;
;; 270 is q-gen IV multiplier ;;
;; * 100. ;;
;; 271 is q-gen I cost ;;
;; 272 is q-gen II cost ;;
;; 273 is q-gen III cost ;;
;; 274 is q-gen IV cost ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 513-768 are for flags. ;;
;; 513 is the upgrade flag. ;;
;; (unlock at 10 heat) ;;
;; 514 is the beginner flag. ;;
;; (hides heat for first ;;
;; five quarks) ;;
;; 515 is hide bought flag. ;;
;; (hides bought upgrades) ;;
;; 516 is the move on flag. ;;
;; (says we're ready to go!) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 769-1024 are for upgrades ;;
;; and generators. ;;
;; 769 is double gain. ;;
;; (Double quark/heat gain.) ;;
;; 770 is chance increase. ;;
;; (Increase non-annihilation ;;
;; chance to 5%.) ;;
;; 771 is expansion increase. ;;
;; (Increase universal ;;
;; expansion to 0.9.) ;;
;; 772 is chance increase II. ;;
;; (Increase non-annihilation ;;
;; chance to 20%.) ;;
;; 773 is expansion increase II. ;;
;; (Increase universal ;;
;; expansion to 0.5.) ;;
;; 774 is chance increase III. ;;
;; (Increase non-annihilation ;;
;; chance to 50%.) ;;
;; 775 is bought quark ;;
;; generator I. ;;
;; 776 is bought quark ;;
;; generator II. ;;
;; 777 is bought quark ;;
;; generator III. ;;
;; 778 is bought quark ;;
;; generator IV. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Setup
push 1 ;; quarks
push 0
store
push 2 ;; heat
push 0
store
;; RNG is seeded by player input.
;; See the end of the intro.
push 260 ;; amount on creation
push 1
store
push 261 ;; avoid annihilation chance
push 0
store
push 262 ;; universal expansion
push 99
store
push 265 ;; gen I mult
push 100
store
push 267 ;; gen II mult
push 100
store
push 269 ;; gen III mult
push 100
store
push 270 ;; gen IV mult
push 100
store
push 271 ;; gen I cost
push 1
store
push 272 ;; gen II cost
push 100
store
push 273 ;; gen III cost
push 100000
store
push 274 ;; gen IV cost
push 1000000000
store
push 513 ;; upgrade flag
push 1
store
push 514 ;; beginner flag
push -5
store
push 516 ;; move on flag
push 1
store
push 769 ;; gain upgrade
push 1
store
push 770 ;; chance upgrade
push 1
store
push 771 ;; expansion upgrade
push 1
store
push 772 ;; chance upgrade II
push 1
store
push 773 ;; expansion upgrade II
push 1
store
push 774 ;; chance upgrade III
push 1
store
;; Intro
push "You are nothing.\n"
call print
push "But you could be something.\n"
call print
push "Exist. (Type something!)\n"
call print
push 0 ;; accumulator
loop:
readc 257
retrieve 257
dup
push '\n'
sub ;; check if \n
jz .done
;; not done.
add ;; accum + current value
jmp loop
.done:
drop ;; drop \n
push 134456
mod ;; make sure it's in our bounds
push 258
swap
store ;; RNG seeded.
push "And so, you are.\n\n\n"
call print
quarks:
retrieve 2
jz .noheat
retrieve 514
jn .noheat
push "You have "
call print
retrieve 1
printi
push " quarks and "
call print
retrieve 2
push 10
div
printi
push " heat.\n"
call print
push "Universal expansion is causing your heat\n"
call print
push "to be multiplied by 0."
call print
retrieve 262
printi
push " when you create a quark.\n"
call print
jmp .merge
.noheat:
push "You have "
call print
retrieve 1
printi
push " quarks.\n"
call print
.merge:
retrieve 513
jz .upgr
push "Create a (q)uark.\n"
call print
jmp .input
.upgr:
push "Create a (q)uark, or check the (u)pgrades.\n"
call print
retrieve 770
jz .notemoveon
jmp .input
.notemoveon:
push 29
retrieve 1
sub ;; 29 - quarks
jn .enoughquarks
push "***Move on: Have 30 quarks and no heat.***\n"
call print
jmp .input
.enoughquarks:
push 10
retrieve 2
sub ;; 10 - energy
jn .notenoughcool
push 516
push 0
store
push "(M)ove on.\n"
call print
jmp .input
.notenoughcool:
push "***Move on: Have 30 quarks and no heat.***\n"
call print
jmp .input
.input:
call safereadc
dup
push 'q'
sub
jz createquark
dup
push 'Q'
sub
jz createquark
retrieve 513
jz .hasupgrades
jmp .noupgrades
.hasupgrades:
dup
push 'u'
sub
jz .toupgrades
dup
push 'U'
sub
jz .toupgrades
.noupgrades:
retrieve 516
jz .canmoveon
jmp quarks
.canmoveon:
dup
push 'm'
sub
jz .moveon
dup
push 'M'
sub
jz .moveon
jmp quarks
.moveon:
push "It seems the universe is cool.\n"
call print
push "Perhaps you can make something greater with\n"
call print
push "what you have collected.\n"
call print
jmp baryons
end
.toupgrades:
drop
jmp upgrades
upgrades:
push "You have "
call print
retrieve 1
printi
push " quarks and "
call print
retrieve 2
push 10
div
printi
push " heat.\n"
call print
push "Current upgrades:\n"
call print
push 259
push 1 ;; upgrades
store
retrieve 769
jz .b769
push -769
call .nextup
push "Double Up: You get double the quarks/heat on quark creation.\n"
call print
push " 15 heat.\n"
call print
.b769:
retrieve 770
jz .b770
push -770
call .nextup
push "Baryon Asymmetry: Your quarks have a chance to avoid annihilation. (10%)\n"
call print
push " 25 heat.\n"
call print
jmp .findisplay
.b770:
retrieve 771
jz .b771
push -771
call .nextup
push "Cool Down: Universal Expansion is 0.9.\n"
call print
push " 1 quark.\n"
call print
.b771:
retrieve 772
jz .b772
;; I'd put a req for 770 here,
;; but you can only see this upgrade
;; if you bought 770!
push -772
call .nextup
push "Tip the Scales: Baryon Asymmetry is 20%.\n"
call print
push " 3 quarks, 15 heat.\n"
call print
.b772:
retrieve 774
jz .b774
retrieve 772
jz .774r
jmp .b774
.774r:
push -774
call .nextup
push "Anti-antimatter: Baryon Asymmetry is 100%.\n"
call print
push " 7 quarks.\n"
call print
.b774:
;; my beautiful ordering is ruined!
;; but that's what happens when you don't plan.
retrieve 773
jz .findisplay
retrieve 771
jz .773r
jmp .findisplay
.773r:
push -773
call .nextup
push "Inflationary Epoch: Universal Expansion is 0.5.\n"
call print
push " 20 quarks.\n"
call print
.findisplay:
push "(0) Go back.\n"
call print
readi 257
retrieve 257
dup
jz .return
retrieve 259
.loop:
push 1
sub ;; d259 - 1
dup
jz .done
copy 1 ;; copy input
copy 1 ;; copy d259 - 1
sub ;; input - (d259 - 1)
jz .yes
jmp .loop
.yes:
drop ;; don't need two copies
push -769
.loop2:
dup
retrieve
copy 2 ;; copy user input
sub ;; in - 0d(-7XX)
jz .same
push -1
add ;; -7XX - 1
jmp .loop2
.same:
dup
push -769
sub
jz .buy769
dup
push -770
sub
jz .buy770
dup
push -771
sub
jz .buy771
dup
push -772
sub
jz .buy772
dup
push -773
sub
jz .buy773
dup
push -774
sub
jz .buy774
push "Error: Invalid upgrade number.\n"
call print
end
.buy769:
call .clearup
drop
drop
retrieve 2
push 150
sub ;; heat - 150
dup
jn .notenough
push 2
swap
store
push 769
push 0
store
push 260
retrieve 260
push 2
mul
store
push "Upgrade bought.\n"
call print
jmp upgrades
.buy770:
call .clearup
drop
drop
retrieve 2
push 250
sub ;; heat - 250
dup
jn .notenough
push 2
swap
store
push 770
push 0
store
push 261
push 100
store
push "Upgrade bought.\n"
call print
jmp upgrades
.buy771:
call .clearup
drop
drop
retrieve 1
push 1
sub ;; quarks - 1
dup
jn .notenough
push 1
swap
store
push 771
push 0
store
push 262
push 90
store
push "Upgrade bought.\n"
call print
jmp upgrades
.buy772:
call .clearup
drop
drop
retrieve 2
push 150
sub ;; heat - 150
dup
jn .notenough
retrieve 1
push 3
sub ;; quarks - 3
dup
jn .notenough
push 1
swap
store
push 2
swap
store
push 772
push 0
store
push 261
push 200
store
push "Upgrade bought.\n"
call print
jmp upgrades
.buy773:
call .clearup
drop
drop
retrieve 1
push 20
sub ;; quarks - 20
dup
jn .notenough
push 1
swap
store
push 773
push 0
store
push 262
push 50
store
push "Upgrade bought.\n"
call print
jmp upgrades
.buy774:
call .clearup
drop
drop
retrieve 1
push 7
sub ;; quarks - 7
dup
jn .notenough
push 1
swap
store
push 774
push 0
store
push 261
push 1000
store
push "Upgrade bought.\n"
call print
jmp upgrades
.notenough:
drop
push "Can't afford upgrade.\n"
call print
jmp upgrades
.done:
;; not valid.
drop
jmp upgrades
.return:
drop
jmp quarks
.clearup:
push -769
.clearup.loop:
dup
push 0
store
push 1
sub
dup
push -775
sub
jz .clearup.done
jmp .clearup.loop
.clearup.done:
drop
ret
.nextup:
;; prints "(1) " on first call,
;; "(2) " on second call,
;; "(3) " on third call,
;; etc.
;; also sets -(upgrade num) to be
;; the printed number.
;; push the number on the stack
;; before calling.
retrieve 259
store
push '('
printc
push 259
retrieve 259
dup
printi
push 1
add
store
push ')'
printc
push ' '
printc
ret
createquark:
retrieve 2
retrieve 262
mul
push 100
div
push 2
swap
store
drop
retrieve 514
jn .begfail ;; beginner
call random
retrieve 258
push 1000
mod
retrieve 261 ;; non-annihilation chance
swap
sub ;; 50 - RNG
push 1
sub ;; -1 to avoid RNG = 0 shenanigans
jn .fail
push "You obtained "
call print
retrieve 260
dup
printi
push " quark(s).\n"
call print
retrieve 1
add
push 1
swap
store
jmp quarks
.begfail:
push 514
retrieve 514
push 1
add
store ;; add 1 to beginner flag
push "You created a quark, but\n"
call print
push "an anti-quark was also created,\n"
call print
push "which annihilated your quark.\n"
call print
push "The universe feels warmer...\n"
call print
retrieve 2
push 10
add
push 2
swap
store
jmp quarks
.fail:
retrieve 513
jz .exp
push "You created a quark, but\n"
call print
push "an anti-quark was also created,\n"
call print
push "which annihilated your quark.\n"
call print
.exp:
push "You obtained "
call print
retrieve 260
dup
printi
push 10
mul
push " heat.\n"
call print
retrieve 2
dup
push 90
sub ;; heat - 90
jn .noupgr
push 513
push 0
store ;; set upgrade flag
.noupgr:
add
push 2
swap
store
jmp quarks
baryons:
retrieve 3
jz .noneutrons
push "You have "
call print
retrieve 1
printi
push " quarks and "
call print
retrieve 3
printi
push " neutrons.\n"
call print
push "Obtain 4 neutrons to win the game.\n"
call print
.noneutrons:
push "You have "
call print
retrieve 1
printi
push " quarks.\n"
call print
.merge:
retrieve 1
push 100000000000
sub
jn .skipneutrons
push "Fuse all of your quarks and quark generators (except a single gen 1) into 1 (n)eutron.\n"
call print
.skipneutrons:
push "Check the (g)enerators tab.\n"
call print
push "Or (w)ait for your generators.\n"
call print
.input:
call safereadc
retrieve 775
jz .inskipneutrons
dup
push 'n'
sub
jz createneutron
dup
push 'N'
sub
jz createneutron
.inskipneutrons:
dup
push 'g'
sub
jz generators
dup
push 'G'
sub
jz generators
dup
push 'w'
sub
jz .wait
dup
push 'W'
sub
jz .wait
jmp .input
.wait:
call tick
jmp baryons
createneutron:
retrieve 3
push 1
add
dup
push 4
sub
jz beatgame
push 3
swap
store
push 1
push 0
store
push 264
push 1
store
push 266
push 0
store
push 268
push 0
store
push 265
push 100
store
push 267
push 100
store
push 269
push 100
store
push 271
push 100
store
push 272
push 100
store
push 273
push 100000
store
push 274
push 1000000000
store
push 775
push 1
store
push 776
push 0
store
push 777
push 0
store
push 778
push 0
store
jmp baryons
beatgame:
push "As you watch your four neutrons, suddenly\n"
call print
push "two of them undergo beta decay, forming a proton and electron each.\n"
call print
push "Delightfully, the two remaining neutrons combine with the decay results\n"
call print
push "to form a Helium atom. From here, a new universe will take shape...\n"
call print
push "And it's all thanks to your hard work. Good job!\n"
call print
push "Thanks for playing!!!\n"
call print
push "I will likely continue working on this project after the deadline passes...\n"
call print
push "But right now I'm sleep-deprived and making way too many little errors to function.\n"
call print
push "So this is where it ends!\n"
call print
push "Once again, thanks for playing!\n"
call print
end
tick:
retrieve 778
retrieve 270
mul
push 100
div
retrieve 268
add
push 268
swap
store
retrieve 268
retrieve 269
mul
push 100
div
retrieve 266
add
push 266
swap
store
retrieve 266
retrieve 267
mul
push 100
div
retrieve 264
add
push 264
swap
store
retrieve 264
retrieve 265
mul
push 100
div
push 263