-
Notifications
You must be signed in to change notification settings - Fork 0
/
HUNGRY.ELPC
1522 lines (1307 loc) · 38.8 KB
/
HUNGRY.ELPC
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
#output "hungrydinosaurs"
'------------------------
.declares
'--------
#declare k, z, north%, south%, east%, west%, allow%, res%
#declare a$,b$,c$,tok$
#declare current_room%, previous_room%
#declare inventory$(10),inv_count%=0,inv_idx%=0
#declare fed_dino_count% = 0
#declare poll_cnt%=0
#declare t1, delay
' music related vars
' ------------------
#declare music_chunk_index ' old t
#declare bar_index ' old tt
' #declare map_bar_to_chunk(11) ' old m()
#declare v1$(11), v2$(11), v3$(11), v4$(11), v5$(11), v6$(11)
#declare map(14)
map(0)=0:map(1)=1:map(2)=2:map(3)=3
map(4)=2:map(5)=4:map(6)=5:map(7)=7
map(8)=8:map(9)=8:map(10)=5:map(11)=7
map(12)=8:map(13)=8
#declare s%
#struct SONG tmpo%, bars%, cpy%
SONG songs(4) = [ {x5F}
[ 18, 6, 1 ], {x5F}
[ 25, 14, 1 ], {x5F}
[ 35, 10, 0 ], {x5F}
[ 15, 6, 1 ], {x5F}
[ 20, 9, 1 ] {x5F}
]
#declare curx%,cury%, s$, cr, dc, dk, dl, offset%, line$, a, valid%, sk
#declare DEBUG=0
#declare load_state%
#declare ret%, fill_state%
#define COLOUR = 63
#declare vec_data%(12000)
#declare vec_size% = 3
#declare selected_colour% = 1
#declare last_colour% = -1
#define LINE = 0
#define CIRCLE = 1
#define ELLIPSE = 2
#define BOX = 3
#define POLY = 4
#declare m0%, m1%, lx0%, ly0%, mx%, my%, cx0%, cy0%, ex0%, ey0%
#declare radius%, xradius%, yradius%, bx0%, by0%, poly_idx%
#declare poly_x%(250), poly_y%(250), ymin%, ymax%
#declare idx%, rev%, y0%, y1%, tmp%, y%
#declare x0%, x1%, x%, y%, m, c, pidx%, px%(20), i%, swapped%, j%
#declare present$(4), missing% = 0, game_over% = 0
present$(0) = "whistle"
present$(1) = "floppy-disk"
present$(2) = "mega65"
present$(3) = "program-listing"
#declare map_loc_to_objs$(4,2)
#declare map_idx%
#declare onion% = 0, onion$
#define GERMANY=0
#define TURKEY=1
#define THAILAND=2
#define VIETNAM=3
#define AUSTRALIA=4
#define MAX_ROOMS=5
#struct ROOM desc$, exits$, locs$, vart$, offset%
ROOM rooms(MAX_ROOMS) = [ {x5F}
[ "You are trapped in Onion Cake's dirty smelly prison!", {x5F}
"", "", "german.v", 0 ], {x5F}
[ "A Turkish dinosaur is bathing in the thermal waters.", {x5F}
"S", "2", "turk.v", 0 ], {x5F}
[ "A Thai dinosaur is performing a traditional dance.", {x5F}
"NE", "13", "thai.v", -9 ], {x5F}
[ "A Vietnamese dinosaur is tending to the rice terraces.", {x5F}
"WS", "24", "viet.v", 0 ], {x5F}
[ "An inebriated Australian dinosaur rests peacefully.", {x5F}
"N", "3", "aus.v", -16 ] {x5F}
]
s% = THAILAND
#declare has_attic_ram%=0
#declare cached%(MAX_ROOMS),offs
#declare prog$(7), finished_lines%=0
prog$(0)="10 print "+chr$(34)+"i promise to onion cake that i will"+chr$(34)
prog$(1)="20 print "+chr$(34)+"- always write beautiful mega65 programs"+chr$(34)
prog$(2)="30 print "+chr$(34)+"- make use of delicious petscii characters"+chr$(34)
prog$(3)="40 print "+chr$(34)+"- make beautiful sid music with the 'play' command"+chr$(34)
border 0:background 0:print chr$(14);chr$(30);
gosub attic_ram_check
goto main
.attic_ram_check
'---------------
print chr$(147);
poke $8000000, 35
if peek($8000000) <> 35 then begin
has_attic_ram% = 0
print "No attic ram detected (will not cache art)"
sleep 1
print chr$(147);
return
bend
poke $8000000, 36
if peek($8000000) <> 36 then begin
has_attic_ram% = 0
print "No attic ram detected (will not cache art)"
sleep 1
print chr$(147);
return
bend
has_attic_ram%=1
print "Attic ram detected (will cache art)"
sleep 1
return
.remove_from_loc
'---------------
if map_idx%=1 then begin
map_loc_to_objs$(current_room%,1) = ""
bend:else if map_idx%=0 then begin
map_loc_to_objs$(current_room%,0) = ""
if map_loc_to_objs$(current_room%,1) <> "" then begin
map_loc_to_objs$(current_room%,0) = map_loc_to_objs$(current_room%,1)
map_loc_to_objs$(current_room%,1) = ""
bend
bend
return
.take
'----
gosub extract_token
map_idx% = -1
b$=""
for k = 0 to 1
c$ = map_loc_to_objs$(current_room%,k)
if tok$ = left$(c$,3) then b$ = c$:map_idx% = k
next k
if left$(b$,3) = tok$ then begin
allow% = 1
if tok$="egg" then begin
s$="The eggplant stubbornly resists your attempt to take it!"
cr=1:dc=14:gosub draw_text
allow%=0
bend
if b$="rice-plant" then begin
s$="The rice-plant refuses to relent to your will!"
cr=1:dc=14:gosub draw_text
allow%=0
bend
if tok$="car" then begin
s$="The carnivorous-mite gnashes its teeth at you, forcing you to back down!"
cr=1:dc=14:gosub draw_text
allow%=0
bend
if tok$="tig" then begin
s$="The tiger unleashes a ferocious growl, making you shiver in your boots!"
cr=1:dc=14:gosub draw_text
allow%=0
bend
if allow%=1 then begin
inventory$(inv_count%) = b$
inv_count% = inv_count% + 1
gosub remove_from_loc
s$="You take the ":cr=0:dc=14:gosub draw_text
s$=b$:cr=0:dc=3:gosub draw_text
s$="...":cr=1:dc=14:gosub draw_text
bend
bend:else begin
s$="You can't see that here!"
cr=1:dc=14:gosub draw_text
bend
return
.hit
'---
gosub extract_token
map_idx% = -1
b$=""
for k = 0 to 1
c$ = map_loc_to_objs$(current_room%,k)
if tok$ = left$(c$,3) then b$ = c$:map_idx% = k
next k
if left$(b$,3) = tok$ then begin
if tok$="egg" then begin
s$="The impact of your fist causes it to become a "
cr=0:dc=14:gosub draw_text
s$="fainted-eggplant":cr=0:dc=3:gosub draw_text
s$=".":cr=1:gosub draw_text
map_loc_to_objs$(current_room%,map_idx%)="fainted-eggplant"
bend
if tok$="ric" then begin
s$="You flatten the rice with your fist, forming a tasty "
cr=0:dc=14:gosub draw_text
s$="rice-paper-roll":cr=0:dc=3:gosub draw_text
s$=".":cr=1:dc=14:gosub draw_text
map_loc_to_objs$(current_room%,map_idx%)="rice-paper-roll"
bend
if tok$="car" then begin
s$="Your violent actions have made the mite rethink life, it is now a "
cr=0:dc=14:gosub draw_text
s$="vegan-mite":cr=0:dc=3:gosub draw_text
s$=".":cr=1:dc=14:gosub draw_text
map_loc_to_objs$(current_room%,map_idx%)="vegan-mite"
bend
if tok$="tig" then begin
s$="I think you hurt its feelings, it is now a "
cr=0:dc=14:gosub draw_text
s$="crying-tiger":cr=0:dc=3:gosub draw_text
s$="...":cr=1:dc=14:gosub draw_text
map_loc_to_objs$(current_room%,map_idx%)="crying-tiger"
bend
bend:else begin
s$="You can't see that here!"
cr=1:dc=14:gosub draw_text
bend
return
.find_in_inventory
'-----------------
res% = 0 : inv_idx% = -1
if inv_count%=0 then return
for k=0 to inv_count%-1
if left$(inventory$(k),3) = tok$ then res% = 1:inv_idx% = k:b$=inventory$(k)
next k
return
.remove_from_inventory
'---------------------
if inv_idx%=inv_count%-1 then inv_count%=inv_count%-1:return
for k=inv_idx%+1 to inv_count%-1
inventory$(k-1) = inventory$(k)
next k
inv_count% = inv_count% - 1
return
.drop_present
'-----------
if map_loc_to_objs$(current_room%,0) = "" then begin
map_loc_to_objs$(current_room%,0) = present$(fed_dino_count%)
bend:else begin
map_loc_to_objs$(current_room%,1) = present$(fed_dino_count%)
bend
return
.give
'----
gosub extract_token
gosub find_in_inventory
if res%=0 then begin
s$="You are not carrying that!"
cr=1:dc=14:gosub draw_text
return
bend
if left$(b$,3) = tok$ then begin
allow%=0
if tok$="ric" and current_room%=VIETNAM then allow%=1
if tok$="veg" and current_room%=AUSTRALIA then allow%=1
if tok$="cry" and current_room%=THAILAND then allow%=1
if tok$="fai" and current_room%=TURKEY then allow%=1
if current_room%=GERMANY then begin
if tok$="meg" then begin
s$="'Not yet, show me that you know how to use this beautiful machine, or else...'"
cr=1:dc=2:gosub draw_text
bend:else begin
s$="Onion Cake glares at you, "
cr=0:dc=14:gosub draw_text
s$="'Stop wasting time and prove your skills to me!'"
cr=1:dc=2:gosub draw_text
bend
return
bend
if allow% = 0 then begin
s$="The dinosaur appreciates your kind gesture, but that isn't the food it likes"
cr=1:dc=14:gosub draw_text
bend
if allow% = 1 then begin
gosub remove_from_inventory
if current_room% = VIETNAM then begin
s$="The Vietnamese dinosaur devours the tasty rice-paper roll..."
cr=1:dc=14:gosub draw_text
bend
if current_room% = AUSTRALIA then begin
s$="The Australian dinosaur chomps down the scrumptious mite and then"
cr=1:dc=14:gosub draw_text
s$="falls back asleep..."
cr=1:dc=14:gosub draw_text
bend
if current_room% = THAILAND then begin
s$="The Thai dinosaur gracefully dines on the crying-tiger, and "
cr=1:dc=14:gosub draw_text
s$="then raises its clasped paws to its forehead to wai in thanks."
cr=1:dc=14:gosub draw_text
bend
if current_room% = TURKEY then begin
s$="The Turkish dinosaur enthusiastically rips into the tasty fainted-eggplant!"
cr=1:dc=14:gosub draw_text
bend
s$="It drops a present for you to show its gratitude..."
cr=1:dc=14:gosub draw_text
gosub drop_present
fed_dino_count% = fed_dino_count% + 1
bend
bend
return
.check_we_have_all_computer_items
'--------------------------------
s$="Onion cake looks over your inventory..."
cr=1:dc=14:gosub draw_text
delay=1:gosub pause
missing%=0
for z = 0 to 3
tok$ = left$(present$(z), 3)
gosub find_in_inventory
if res%=0 then begin
s$="'Hmm... You seem to be missing a "
cr=0:dc=2:gosub draw_text
s$=present$(z)
cr=0:dc=3:gosub draw_text
s$="...'"
cr=1:dc=2:gosub draw_text
missing%=1
delay=1:gosub pause
bend
next z
if missing%=1 then begin
res%=0
s$="":cr=1:gosub draw_text
s$="'I am afraid this means that I need to shoot you now!'"
cr=1:dc=2:gosub draw_text
delay=1.5:gosub pause
s$="":cr=1:gosub draw_text
s$="BANG!"
cr=1:dc=10:gosub draw_text
delay=1.5:gosub pause
return
bend
s$="'Looks like you've got it all...'"
cr=1:dc=2:gosub draw_text
delay=1:gosub pause
s$="'Now, demonstrate your MEGA65 coding skills to me, otherwise...'"
cr=1:dc=2:gosub draw_text
delay=2:gosub pause
res% = 1
return
.pause
t1=ti
.pauselp
gosub poll_play
if (ti-t1) < delay then goto pauselp
return
.captured_by_onion_cake
'----------------------
s$="Upon hearing your melodious whistling, Onion Cake arrives, holding you"
cr=1:dc=14:gosub draw_text
s$="at gunpoint, and forcefully escorting you to his dungeon in Germany..."
cr=1:dc=14:gosub draw_text
current_room% = GERMANY
gosub init_music
if DEBUG=0 then begin
onion% = 1 : onion$="onion.v" : gosub load
bend:else begin
inventory$(0)="mega65"
inv_count%=1
bend
if DEBUG=0 then begin
delay=2:gosub pause
bend
gosub show_room_graphic
if DEBUG=0 then begin
s$="'I finally caught the thief that stole my MEGA65!'"
cr=0:dc=2:gosub draw_text
s$=", Onion Cake exclaims!"
cr=1:dc=14:gosub draw_text
s$="":cr=1:gosub draw_text
delay=1.5:gosub pause
s$="'If you show me your programming skills I will release you!'"
cr=0:dc=2:gosub draw_text
s$=" he offers."
cr=1:dc=14:gosub draw_text
s$="":cr=1:gosub draw_text
delay=2:gosub pause
s$="'If not, I will shoot you!'"
cr=1:dc=2:gosub draw_text
delay=2:gosub pause
gosub check_we_have_all_computer_items
bend:else begin
return
bend
if res%=0 then game_over%=1:return
return
.type_line
'---------
gosub get_input_to_a$
return
.assess_line
'-----------
if a$=prog$(finished_lines%) then begin
finished_lines% = finished_lines% + 1
if finished_lines%=4 then begin
s$="'Well done, you completed the program!'"
cr=1:dc=2:gosub draw_text
bend:else begin
s$="'Good, now for the next line!'"
cr=1:dc=2:gosub draw_text
bend
bend:else begin
s$="'No no! You made mistakes on this line!'"
cr=0:dc=2:gosub draw_text
s$=", Onion Cake roars"
cr=1:dc=14:gosub draw_text
s$="'Type it again properly, otherwise I will shoot you!'"
cr=1:dc=2:gosub draw_text
bend
return
.start_mega65
'------------
' draw_mega65_listing
onion% = 1 : onion$="mega65.v" : gosub load
do while finished_lines% < 4
s$="Type: "
cr=0:dc=11:gosub draw_text
s$=prog$(finished_lines%)
cr=1:dc=12:gosub draw_text
gosub type_line
gosub assess_line
loop
s$="'Impressive!'"
cr=0:dc=2:gosub draw_text
s$=", Onion Cake says with admiration!"
cr=1:dc=14:gosub draw_text
delay=1:gosub pause
s$="'You have proven yourself worthy to keep alive! I hereby release you!"
cr=1:dc=2:gosub draw_text
delay=2:gosub pause
s$="Remember your promise, otherwise I will find you and shoot you!'"
cr=1:dc=2:gosub draw_text
delay=2:gosub pause
s$="You are free again! Congratulations, you won the game!"
cr=1:dc=7:gosub draw_text
game_over%=1
delay=1.5:gosub pause
return
.use
'---
gosub extract_token
gosub find_in_inventory
if res%=0 then begin
s$="You are not carrying that!"
cr=1:dc=14:gosub draw_text
return
bend
if left$(b$,3) = tok$ then begin
if tok$="whi" then gosub captured_by_onion_cake:return
if tok$="meg" then begin
if current_room%=GERMANY then begin
gosub start_mega65
game_over%=1
return
bend:else begin
s$="How could you think of playing with your MEGA65 when there are hungry"
cr=1:dc=14:gosub draw_text
s$="dinosaurs to feed?!"
cr=1:dc=14:gosub draw_text
return
bend
bend
s$="You cannot use that!"
cr=1:dc=14:gosub draw_text
bend
return
.inventory
'---------
s$="You are carrying:"
cr=1:dc=14:gosub draw_text
if inv_count% = 0 then begin
s$=" - nothing..."
cr=1:dc=12:gosub draw_text
bend:else begin
for k=0 to inv_count%-1
s$=" - "
cr=0:dc=14:gosub draw_text
s$=inventory$(k)
cr=1:dc=3:gosub draw_text
next k
bend
return
.extract_token
'-------------
k = instr(a$," ")
tok$=left$(a$,3)
if k>0 then begin
a$=mid$(a$,k+1)
bend:else begin
a$=""
bend
return
.draw_cursor
'-----------
pen 0,1
dc=1
for dl=0 to 15
line curx%*8,320+cury%*16+dl,curx%*8+7,320+cury%*16+dl
next dl
return
.hide_cursor
'-----------
pen 0,0
for dl=0 to 15
line curx%*8,320+cury%*16+dl,curx%*8+7,320+cury%*16+dl
next dl
return
.safe_cury_inc
'-------------
cury%=cury% + 1
if cury% => 5 then begin
gosub scroll_text_up
sleep .1
bend
return
.get_input_to_a$
'---------------
gosub draw_cursor
line$=""
do
.keyloop
get a$
gosub poll_play
if a$="" then goto keyloop
a=asc(a$)
valid%=1
if (a<32 or a>127) and a<>13 and not (a=20 and len(line$)>0) then valid%=0
if valid% = 1 then begin
if a=13 then begin ' carriage-return?
a$=line$
gosub hide_cursor
curx%=0
gosub safe_cury_inc
return
bend
if a=20 then begin ' inst-del
line$=left$(line$,len(line$)-1)
gosub hide_cursor
curx%=curx%-1
gosub draw_cursor
bend
if a<>13 and a<>20 then begin ' any other key?
line$=line$+a$
gosub hide_cursor
s$=a$:cr=0:gosub draw_text
gosub draw_cursor
bend
bend
loop
return
.user_input
'----------
gosub get_input_to_a$
if a$="n" and north%<>-1 then current_room%=north%:return
if a$="s" and south%<>-1 then current_room%=south%:return
if a$="e" and east%<>-1 then current_room%=east%:return
if a$="w" and west%<>-1 then current_room%=west%:return
if a$="i" then gosub inventory:return
if a$="l" then gosub show_room_text:return
if a$="quit" or a$="exit" then game_over%=1:return
gosub extract_token
if tok$="loo" then gosub show_room_text:return
if tok$="tak" or tok$="get" then gosub take:return
if tok$="inv" then gosub inventory:return
if tok$="hit" then gosub hit:return
if tok$="giv" then gosub give:return
if tok$="use" then gosub use:return
s$="Sorry, I don't understand that command" : cr=1 : dc=14 : gosub draw_text
return
.show_objects
'------------
res%=0
for k=0 to 1
a$ = map_loc_to_objs$(current_room%, k)
b$ = left$(a$,1)
c$ = "aeiou"
if a$<>"" then begin
if res%=0 then begin
s$="You see a" : cr=0 : dc=14 : gosub draw_text
res%=1
bend : else begin
s$=" and a" : cr=0 : dc=14 : gosub draw_text
bend
if instr(c$,b$)<>0 then begin
s$="n" : cr=0 : dc=14 : gosub draw_text
bend
s$ = " " + a$ : cr=0 : dc= 3 : gosub draw_text
bend
next k
if res%<>0 then begin
s$=" here.":cr=1:dc=14:gosub draw_text
bend
return
.scroll_text_up
'--------------
for sk=0 to 7
edma 0, 640*4, $40000+640*21+sk*$4000, $40000+640*20+sk*$4000
next sk
for sk=0 to 7
edma 3, 640, 0, $40000+640*24+sk*$4000
next sk
cury%=cury%-1
return
.draw_text
'---------
pen 0,dc
if len(s$) > 0 then begin
for dk = 0 to len(s$)-1
char curx%, 320+cury%*16,2,1,2,mid$(s$,dk+1,1)
curx% = curx% + 1
if curx% = 80 then begin
curx% = 0
gosub safe_cury_inc
bend
next dk
bend
if cr=1 then begin
curx% = 0
gosub safe_cury_inc
bend
return
.show_room_text
'--------------
s$=rooms_desc$(current_room%):cr=1:dc=14:gosub draw_text
gosub show_objects
north%=-1:south%=-1:east%=-1:west%=-1
s$="Exits: ":cr=0:dc=14:gosub draw_text
a$ = rooms_exits$(current_room%)
if len(a$) > 0 then begin
for k=1 to len(a$)
b$=mid$(a$,k,1)
c$=mid$(rooms_locs$(current_room%),k,1)
s$=b$:cr=0:dc=7:gosub draw_text
if k<>len(a$) then s$= ", ":cr=0:dc=14:gosub draw_text
if b$="N" then north%=val(c$)
if b$="S" then south%=val(c$)
if b$="E" then east%=val(c$)
if b$="W" then west%=val(c$)
next k
bend
if len(a$)=0 then s$="none...":cr=0:dc=12:gosub draw_text
s$="":cr=1:gosub draw_text
return
.show_room_graphic
'-----------------
curx% = 0
cury% = 0
screen clr 0
gosub init_music
'TODO: remove
'return
if has_attic_ram%=1 and cached%(current_room%)=1 then begin
gosub load_from_cache
return
bend
offset% = rooms_offset%(current_room%)
gosub load
return
.main_game
'---------
if DEBUG=1 then begin
gosub captured_by_onion_cake
bend
gosub show_room_graphic
gosub show_room_text
.next_input
gosub user_input
if game_over%=1 then begin
s$="":cr=1:dc=14:gosub draw_text
s$="GAME OVER"
cr=1:dc=5:gosub draw_text
delay=2:gosub pause
screen close
return
bend
if current_room%<>previous_room% then previous_room%=current_room%:goto main_game
goto next_input
return
.init_game
'---------
print chr$(147);
current_room% = VIETNAM
previous_room% = current_room%
inv_count% = 0
fed_dino_count% = 0
missing% = 0
game_over% = 0
finished_lines% = 0
onion%=0
s%=-1
map_loc_to_objs$(TURKEY,0) = "rice-plant"
map_loc_to_objs$(THAILAND,0) = "carnivorous-mite"
map_loc_to_objs$(VIETNAM,0) = "eggplant"
map_loc_to_objs$(AUSTRALIA,0) = "tiger"
map_loc_to_objs$(TURKEY,1) = ""
map_loc_to_objs$(THAILAND,1) = ""
map_loc_to_objs$(VIETNAM,1) = ""
map_loc_to_objs$(AUSTRALIA,1) = ""
screen 0, 640, 400, 4
return
.main
'----
gosub show_title_page
gosub init_game
gosub main_game
goto main
end
.press_a_key
'-----------
print
print "[Press any key to continue]"
get key a$
return
.show_title_page
'---------------
print chr$(147);
play:play "","","","","",""
print "Onion Cake and the Hungry Dinosaurs"
print "==================================="
print " Coding & Music sequencing by Gurce Isikyildiz"
print " Artwork by Ayca Isikyildiz"
print
print " I)nstructions"
print " C)redits"
print
print " Press SPACE BAR to begin"
get a$
get key a$
if a$="i" then gosub instructions:goto show_title_page
if a$="c" then gosub credits:goto show_title_page
if a$<>" " then goto show_title_page
return
.instructions
'------------
print chr$(147);
print "Instructions (page 1 of 2)"
print "============"
print "The dinosaurs are hungry..."
print
print "...go and find them the food that they like!"
print
print "When you give them all the right food, they will reward you with a "
print "new retro computer!"
print
print "...but beware of dirty old Onion Cake..."
print
print "...he is angry due to somebody stealing his favourite retro computer..."
print
print "Maybe you can appease his anger by returning it to him..."
gosub press_a_key
print chr$(147);
print "Instructions (page 2 of 2)"
print "============"
print "This is a simple text adventure game accompanied by vector art drawn "
print "(slowly) via BASIC 65 :)"
print
print "As BASIC 65 didn't come with a routine to draw filled irregular polygons,"
print "I had to write my own (in BASIC!), that made things even slower :)"
print
print "Artwork will be cached after 1st draw attempt completes."
print
print "Type simple VERB NOUN strings to interact with the game."
print " - E.g. TAKE MEGA65"
print
print "You can abbreviate any word to the first 3 letters."
print " - E.g. TAK MEG"
print
print "NOTE: Current MEGA65 core has problems in 640x400 16 colour mode"
print "- Performs better in Xemu right now"
gosub press_a_key
print chr$(147);
print "Game Vocabulary"
print "---------------"
print "- N, S, E, W (to go North, South, East, West)"
print "- L/LOOK"
print "- I/INVENTORY"
print "- GET/TAKE <object>"
print "- USE <object>"
print "- GIVE <object>"
print "- HIT <object>"
print "- QUIT/EXIT"
gosub press_a_key
return
.credits
'-------
print chr$(147);
print "Credits"
print "======="
print "Coding and Music sequencing by Gurce Isikyildiz"
print "Artwork by Ayca Isikyildiz"
print "- You're welcome to donate to the artist to encourage her to contribute more"
print " of her artwork to future MEGA65 games!"
print " - https://tinyurl.com/ayca-donate"
print
print "Song credits"
print "------------"
print "Australia - ";chr$(34);"Cocky the Cloned Cockatoo";chr$(34);" - Gurce"
print "Germany - ";chr$(34);"The Angel's Angled Ankle";chr$(34);" - Gurce"
print "Thailand - ";chr$(34);"Khleun Grathop Fang";chr$(34)
print " (Waves crash to the shore) - King Prajadhipok"
print "Turkey - ";chr$(34);"Hatcam Cikmis Gul Dalina";chr$(34)
print " (My Hatche came out on the Rose Branch) - Unknown"
print "Vietnam - ";chr$(34);"Con Thuong Rau Dang Moc Sau He";chr$(34)
print " (Still Love the Bitter Herb that Grows after Summer) - Bac Son"
gosub press_a_key
print chr$(147);
print "Thanks to MrZaadii"
print "------------------"
print "Finally, a word of thanks to MrZaadii for his awesome youtube videos:"
print "- https://tinyurl.com/mrzaadii-playlist"
print
print "The inspiration for this game came from his 'Escape from Onion Cake' game:"
print "- https://youtu.be/TvFXC_quuDo"
print
print "His last-released version of the game no longer works with latest MEGA65 ROM:"
print "- https://tinyurl.com/efoc-orig"
print
print "I've made some repairs/enhancements so that it runs on latest MEGA65 ROM here:"
print "- https://tinyurl.com/efoc-new"
gosub press_a_key
return
.load_error
'----------
border 2
load_state% = -4
print "error loading file..."
stop
return
.find_ymin_ymax
'--------------
ymin% = poly_y%(0)
ymax% = poly_y%(0)
for idx% = 0 to poly_idx%-1
if poly_y%(idx%) < ymin% then ymin% = poly_y%(idx%)
if poly_y%(idx%) > ymax% then ymax% = poly_y%(idx%)
next idx%
return
.is_y_in_line_yrange
'-------------------
ret% = 0: rev% = 0
y0% = poly_y%(idx%-1)
y1% = poly_y%(idx%)
if y0% > y1% then tmp%=y0%:y0% = y1%:y1% = tmp%:rev%=1
if y0% <= y% and y% < y1% then ret% = 1
return
.check_line_intersect
'--------------------
gosub is_y_in_line_yrange
if ret% = 0 then return
x0% = poly_x%(idx%-1)
x1% = poly_x%(idx%)
if rev%=1 then tmp%=x0%:x0% = x1%:x1% = tmp%
if x0% = x1% then x% =x0%:ret% = 1:return
m = (y1%-y0%) / (x1% - x0%)
c = y0% - m * x0%
x% = (y% - c) / m
ret% = 1
return
.find_intersects
'---------------
pidx% = 0
' check last-point to first
poly_x%(poly_idx%) = poly_x%(0)
poly_y%(poly_idx%) = poly_y%(0)
for idx% = 1 to poly_idx%
gosub check_line_intersect
if ret% = 1 then px%(pidx%)=x% : pidx% = pidx% + 1
next idx%
return
.sort_intersects
'---------------
' bubble sort algorithm from: geeksforgeeks.org/bubble-sort
#ifdef DEBUG_SORT
gosub clear_menu
char 0,0,1,1,2,str$(pidx%-1)
for i%=0 to pidx%-1
char 4+i%*4,0,1,1,2,str$(px%(i%))
next i%
#endif
for i% = 0 to pidx%-2
swapped% = 0
for j% = 0 to pidx%-i%-2