forked from gweg/rainpanic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
2629 lines (2364 loc) · 68.6 KB
/
main.c
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
// RAIN PANIC alpha version
// GOYO 2019 (C)
//
// HIMEM on peut descendre à #600 (basic à #400)
// HI user ram #9800
// reste à implémenter:
// -------------------
//
// -les différents niveaux -> toutes les vagues de pluie . actuellement que la 1ere vague
//
// -gestion de l'actication du son et de la musique
//
// - jambes qui marchent durant le déplacement continue
//
// - collision avec ice : faire tomber Aldo
//
// BUGS :
// ------
//
// chat shape
//
// legs traces
//
/* chars coding screen
25C=7,64 WAVE 1,zzzzzzzzzzzzzzzANDz
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
m ~zzlzzzzzzzzzzzzzzzzzzzzzzzzzzz~mm
m ~ ~mm
mm~ l ~mm
mm~ k ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ ~mm
mm~ [\] ~mm
mm~ ^_` ~mm
mm~ abc ~mm
mm~ ghi ~mm
~~~ ~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~o~o~o~~~~~~~~~~~~~~~~~~SCORE 0 ~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Oric Std Charset
=32 !=33 "=34 #=35 $=36 %=37 &=38 '=3
9 (=40 )=41 *=42 +=43 ,=44 -=45 .=46 /
=47 0=48 1=49 2=50 3=51 4=52 5=53 6=54
7=55 8=56 9=57 :=58 ;=59 <=60 ==61 >=
62 ?=63 @=64 A=65 B=66 C=67 D=68 E=69
F=70 G=71 H=72 I=73 J=74 K=75 L=76 M=7
7 N=78 O=79 P=80 Q=81 R=82 S=83 T=84 U
=85 V=86 W=87 X=88 Y=89 Z=90 [=91 \=92
]=93 ^=94 _=95 `=96 a=97 b=98 c=99 d=
100 e=101 f=102 g=103 h=104 i=105 j=10
6 k=107 l=108 m=109 n=110 o=111 p=112
q=113 r=114 s=115 t=116 u=117 v=118 w=
119 x=120 y=121 z=122 {=123 |=124 }=12
5 ~=126 =127
*/
#include <lib.h>
#define RAINDROPMAX 20 // max drop sprite in the screen
#define jump_max_time 8 // time to keep in jump state
#define benddown_max_time 8 // time to Aldo benddown
#define music_tempo_delay 6 // delay to temporize the music
#define SCRADDR 0xBB80 // address of the text screen
#define CARADDR 0xB400 // address of std chars to redefine them
#define def_ceiling_pos 6 // default ceiling position =6
// arrays to manage rain drops, for : x y timer state alstate
#define floor_y 25
#undef DEBUG // to switch to debug mode !!! : define/undef
unsigned char raindropx[RAINDROPMAX];
unsigned char raindropy[RAINDROPMAX];
//unsigned char raindroptimer[RAINDROPMAX]="";
unsigned char raindropstate[RAINDROPMAX]="";
int index_raindrop; // index to read from the rain[] array
unsigned char codedrop; // to read drop x position value in Rain[] array.
int raindroptime; // to read time drop => time between two drops
unsigned int timer1,timer2;
char drop_catch_time; // paper 6 during this time to indicate catch is successfull
char shoot_cat_time; // paper cyan during this time to indicate shoot with the cat
char shoot_tile_time; //
char shoot_fireball_time;
char drop_floor_time; //
char endgame; // loose game = 1 winned =2
unsigned int scroll_text;
unsigned char scroll_text_time;
char px,py; // ALDO position x & y
unsigned char armsdown; // arms set down
unsigned char legsup; // legs set up
char waterlevel; // level of water
int score; // game score
int music_index; // music in for music array indexing
int music_tempo; // music temporisation
unsigned int wait,wait2; // global variable to manage wait time
char active_sound; // activated sound state
char active_music; // activated music state
char volume; // game sound volume
char walking; // manage walking
char walking_alt; // alternate legs chars to walking
unsigned char jump_time=0; // gestion du saut du héro
unsigned char benddown=0; // time to avoid the fireball
unsigned char standuptime; // time to standup : to avoid to jump just after stand up
char unsigned catx; // x cat position
char unsigned caty; // y cat position
char unsigned cat; // pour savoir si le cat est prensent ou pas
char dircat; // direction du cat
char unsigned catwait; // delai du cat qui reste sur place avant de partir
char seecat; // if cat is visible
char colcat; // enable collision with the cat
unsigned char colcattime; // duration of collision of Aldo with the cat enabled
char unsigned fireballx; // x fireball position
char unsigned firebally; // y fireball position
char unsigned fireball; // pour savoir si le fireball est prensent ou pas
char unsigned dirfireball; // direction du fireball
char unsigned fireballwait; // delai du fireball qui reste sur place avant de partir
char unsigned seefireball;
char unsigned colfireballtime; // duration of collision of Aldo with fireball enabled
char unsigned player_wait; // close eyes afeter no activity
unsigned char k,lastk; // to read the key pressed : k=key();
char unsigned wave_nbr;
char ceiling_y; // hauteur du plafond = 8 fixe
unsigned int game_timer; // compteur de temps général durant le jeu
char life; // player lifes
char unsigned tile_fall; // if tile fall
char unsigned lightning; // if lightning actived
int unsigned lightning_time; // duration of lightning
char unsigned tile_x; // position x of the beam
char unsigned tile_y; // position y of the beam
unsigned char rdindex;
char altchar; // to alternate char for the falling rain drop
unsigned char drop_sliding; // y step of vertically scrolling for the rain drop
int adr; // use for assembly inline
unsigned int i,j; // usefull in many time in this program
unsigned display_wave_level_timer; // used to display the wave level
unsigned char lx; // used to display lightning
unsigned char ly; // used to display lightning
unsigned char being_falling;
// other falling object
unsigned char obj_kernel;
unsigned char obj_ice;
unsigned char obj_x;
unsigned char obj_y;
// ma,que son pour le JUMP, la retombé du jump, l'eau tombe à terre
unsigned char bong_sound[]={104,177,184,44,254,29,166,58,27,83,35,74,2,83};
unsigned char cat_collision_sound[]={102,144,100,122,168,7,252,9,215,92,153,10,10,1};
unsigned char cat_at_door_sound[]={28,188,255,21,247,92,136,18,176,229,253,145,1,9};
unsigned char rain_menu_sound[]={105,243,91,101,202,108,209,215,73,142,13,178,71,11};
unsigned char silence_sound[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned char player_fallout_sound[]={68,64,207,83,241,143,141,119,218,145,164,167,2,211};
unsigned char player_jump_sound[]={238,2,0,0,0,0,77,14,16,0,0,0,4,4};
unsigned char scroll_y;
unsigned char scroll_y_nbr;
unsigned char scroll_timer;
unsigned char read; //to read string from keyboard;
void AdvancedPrint(char x_pos,char y_pos,const char *ptr_message);
char credits_text[]=" RAIN PANIC "
" INSTRUCTIONS : DURING A STRONG THUNDERSTORM HELP MR ALDO TO CATCH ALL THE DROPS OF WATER FALLING FROM HIS HOUSE CEILING "
" BE CARREFULL OF ROOF TILE FALLING "
" USE LEFT AND RIGHT ARROWS TO MOVE ALDO (OR O,P)"
" USE SPACE TO JUMP ESC TO EXIT "
" "
" CODING BY GOYO IN C LANGUAGE WITH ORIC OSDK AND FEW INLINE ASSAMBLY CODE ORIGINAL MUSIC : LADYWASKY "
" THANKS TO THE HELP OF MANY MEMBERS OF COE FORUM : DBUG RETORIC"
" LADYWASKY DRPSY KENNETH ISS AND OTHERS ORICIANS .. "
" HAVE FUN ..... ";
// Music : Rainy Day , by LADYWASKY
char game_music[] = {
1,7,12,4,0,0,0,0, 1,7,12,4,0,0,0,0, 1,7,11,4,0,0,0,0, 1,7,11,4,0,0,0,0, 1,7,9,4,0,0,0,0, 3,3,9,4,8,2,0,0,
//Intro,A2,,,,,,,
6,7,0,0,8,3,4,4, 3,3,9,4,8,2,0,0, 7,7,11,4,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,11,4,7,3,2,4, 2,3,0,0,7,2,0,0,
7,7,11,4,7,3,2,4, 2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,3,3,12,4,5,2,0,0,
7,7,11,4,5,3,12,4,3,3,11,4,5,2,0,0,7,7,9,4,5,3,12,4, 3,3,9,4,8,2,0,0, 6,7,0,0,8,3,4,4, 3,3,12,4,8,2,0,0,
7,7,2,5,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,12,4,7,3,2,4, 3,3,11,4,7,2,0,0,7,7,9,4,7,3,2,4, 2,3,0,0,5,2,0,0,
6,7,0,0,5,3,12,4, 2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,1,7,12,4,0,0,0,0,3,3,12,4,5,2,0,0, 7,7,11,4,5,3,12,4,
3,3,11,4,5,2,0,0, 6,7,9,4,5,3,12,4,2,3,9,4,8,2,0,0, 6,7,0,0,8,3,4,4, 3,3,12,4,8,2,0,0, 6,7,0,0,8,3,4,4,
3,3,7,4,7,2,0,0, 6,7,0,0,7,3,2,4, 2,3,0,0,7,2,0,0, 7,7,12,4,7,3,2,4, 3,3,11,4,5,2,0,0, 7,7,9,4,5,3,12,4,
3,3,11,4,5,2,0,0,7,7,12,4,5,3,12,4,2,3,0,0,5,2,0,0, 6,7,0,0,5,3,12,4, 2,3,0,0,5,2,0,0, 6,7,0,0,5,3,12,4,
3,3,12,4,8,2,0,0,
//Boucle,A3,,,,,,,
6,7,0,0,8,3,4,4, 3,3,7,4,8,2,0,0, 7,7,7,4,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,4,4,7,3,2,4, 3,3,7,4,7,2,0,0,
7,7,7,4,7,3,2,4, 2,3,0,0,5,2,0,0, 6,7,0,0,5,3,12,4, 2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,3,3,12,4,5,2,0,0,
7,7,11,4,5,3,12,4,3,3,11,4,5,2,0,0,7,7,9,4,5,3,12,4, 3,3,9,4,8,2,0,0,
//Boucle,A2,,,,,,,
6,7,0,0,8,3,4,4, 3,3,9,4,8,2,0,0, 7,7,11,4,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,11,4,7,3,2,4, 2,3,0,0,7,2,0,0,
7,7,11,4,7,3,2,4, 2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,3,3,12,4,5,2,0,0,
7,7,11,4,5,3,12,4,3,3,11,4,5,2,0,0,7,7,9,4,5,3,12,4, 3,3,9,4,8,2,0,0, 6,7,0,0,8,3,4,4, 3,3,12,4,8,2,0,0,
7,7,2,5,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,12,4,7,3,2,4, 3,3,11,4,7,2,0,0,7,7,9,4,7,3,2,4, 2,3,0,0,5,2,0,0,
6,7,0,0,5,3,12,4, 2,3,0,0,5,2,0,0, 7,7,12,4,5,3,12,4,1,7,12,4,0,0,0,0,3,3,12,4,5,2,0,0, 7,7,11,4,5,3,12,4,
3,3,11,4,5,2,0,0, 6,7,9,4,5,3,12,4,2,3,9,4,8,2,0,0, 6,7,0,0,8,3,4,4, 3,3,12,4,8,2,0,0, 6,7,0,0,8,3,4,4,
3,3,7,4,7,2,0,0, 6,7,0,0,7,3,2,4, 2,3,0,0,7,2,0,0, 7,7,12,4,7,3,2,4,3,3,11,4,5,2,0,0, 7,7,9,4,5,3,12,4,
3,3,11,4,5,2,0,0, 7,7,12,4,5,3,12,4,2,3,0,0,5,2,0,0, 6,7,0,0,5,3,12,4,2,3,0,0,5,2,0,0, 6,7,0,0,5,3,12,4,
//Fin,A4,,,,,,,
3,3,2,5,8,2,0,0, 6,7,0,0,8,3,4,4, 3,3,7,4,8,2,0,0, 7,7,7,4,8,3,4,4, 2,3,0,0,7,2,0,0, 7,7,4,4,7,3,2,4,
3,3,7,4,7,2,0,0, 7,7,7,4,7,3,2,4, 3,3,5,4,5,2,0,0, 6,7,0,0,5,3,12,4,3,3,4,5,5,2,0,0, 6,7,0,0,5,3,12,4,
3,3,2,5,5,2,0,0, 1,7,9,4,0,0,0,0, 2,7,0,0,5,2,0,0, 2,7,0,0,5,2,0,0, 2,7,0,0,5,2,0,0};
//
// WAVES OF RAINDROP DATA
//
// RAIN[] -> raindrop array [XPOS(drop), DELAY(between 2 drop),,,,]
// rain drop must be bewteen 6 and 32 x position (7 left---19 center -- right 31) with step of 2 )
// 255 = next wave
// 250 = cat appear on the left (cardir)
// 251 = cat appear on the right
// 252 = fireball appear on the left
// 253 = fireball appear on the right
// 200-226 = lightning appear and use this code to define x position of lighting (Xpox = code-200 + 7)
// 180-196 = Life fall
// 150-176 = ice fall
// 0x08 or 0x09 must be in hexa don't know why. Its look lika a bug ?!
unsigned char rain[] = { //----------------------------------------------|new wave|
// wave 1 time=3/2 x position (7 left---19 center -- right 31)
253,3, 250,0, 19,2, 252,0, 32,2, 7,2, 253,0,
32,3, 19,3, 07,3, 32,3, 251,0 ,7,3, 16,3, 18,3, 20,3,
07,3 ,9,3 ,250,0 ,26,3 ,28,3, 251,0, 32,3, 7,3, 250,0, 32,3,
15,3 ,17,3, 251,0 ,19,3 ,21,3, 250,0, 23,3,
07,3 ,9,3 ,11,3 ,251,0 ,28,3 ,32,3, 250,0, 07,3, 251,0 ,32,3, 22,3,
251,0, 21,3, 252,0, 7,3, 250,0, 32,2, 251,0, 21,6, // 39eme
255,0, // wave 2 time =2
7,3, 32,2, 32,2, 250,0, 7,2,
13,3 ,30,2, 251,0, 07,3, 215,0, 32,3, 250,0 ,18,3, 250,0, 07,3, 32,2, 217,0, //
07,2, 251,0, 32,3, 250,0, 07,3, 251,0, 32,3, 250,0, 07,3, 207,0,
31,2, 17,3, 217,0, 32,2, 224,0, 7,1, 19,6,
255,0, // wave 3
14,2, 251,0 ,25,2, 215,0, 250,0, 32,2, 07,2, 251,0, 32,2, // 73eme
14,2,250,0, 16,2, 251,0, 18,2, 250,0, 20,2,217,0,14,2,218,0,32,2,
07,2, 32,2, 251,0, 9,3, 220,0, 168,3, // ice here reprendre ici
32,3, 07,3, 215,0, 31,3, 215,0, 07,3, 216,0, 30,3,
255,0, // wave 4
250,0, 0x08,3,212,0, 13,2,
29,3, 251,0, 0x09,3, 230,0, 28,3, 251,0, 10,3, 251,0, 13,4, 230,0, 30,4, 16,4, 208,0,
07,4, 250,0, 32,4, 18,4, 07,4, 10,4, 251,0, 15,4, 11,4, 24,4,
255,0, // wave 5
19,3,
9,1, 11,1, 251,0, 13,1, 15,1, 250,0, 17,1,19,1,
251,0, 21,1, 23,1, 250,0, 25,1,27,4,
250,0, 15,0, 251,0, 17,0 ,19,0, 250,0, 21,0,23,0, 25,3,
7,0, 250,0, 9,0, 11,0, 250,0, 13,0 ,15,0, 17,3,251,0,
21,0, 23,0, 251,0, 25,0, 27,0, 29,0, 31,3,
7,0, 250,0, 9,0, 11,0, 251,0, 13,0 ,15,3,
21,0, 23,0, 25,0, 27,0, 29,0, 31,3,
7,0,9,0,11,1, 14,0,16,0,18,1, 21,0,23,0,25,1, 27,0,29,0,31,1,
19,2, 19,5,
// one line
// [x,y] y =0 -> force to align drops in same line
};
// redefined 35 characters for graphics and sprites game
unsigned char redefchar[]={
01,01,01,01,02,03,06,06, // 91
63,63,63,63,63,30,00,30, // 92
32,32,32,32,16,48,24,24, // 93
06,06,06,06,07,03,01,00, // 94
63,45,63,51,30,45,63,63, // 95
24,24,24,24,56,48,32,00, // 96
30,63,45,63,51,45,63,30, // 97 // ungry head - ancien blanc coté gauche du ventre, peut etre recyclé
63,63,63,00,63,63,63,51, // 98
00,30,47,63,63,63,30,00, // 99 - ice boulder
00,00,00,00,00,00,01,01, // 100
51,51,51,00,30,30,63,63, // 101
00,00,00,00,00,00,32,32, // 102
01,01,01,00,01,01,07,07, // 103
51,51,51,00,33,33,33,33, // 104
32,32,32,00,32,32,56,56, // 105
63,63,63,51,30,45,63,63, // 106
0x08,0x08,28,28,62,62,46,28, // 107 goutte à rattraper 1/2 - bug with 8 value ? must be hex 0x08
00,00,00,00,00,00,00,00, // 108 goutte à rattraper 2/2
00,00,04,04,14,14,10,04, // 109
00,00,00,00,00,00,00,00, // 110
30,63,45,63,63,45,51,30, // 111 head of life number
04,28,31,15,03,03,02,06, // 112 right cat // bug a cette position dans la memoire verifier si addresse utilsiée ailleurs
01,01,62,60,60,12,38,42, // 113 right cat
16,16,15,07,07,06,12,10, // 114 left cat
04,07,63,62,56,24,40,44, // 115 left cat
00,00,00,00,06,06,07,07, // 116
00,00,00,00,00,03,47,47, // 117
00,00,00,00,00,48,61,61, // 118
00,00,00,00,24,24,56,56, // 119
04,35,0x9,07,07,0x9,35,04, // 120 fire boulder left 04,34,0x09,07,07,0x09,34,04
0x08,17,36,56,56,36,17,0x08, // 121 fire boulder right
62,62,62,62,62,62,62,28, // 122 tile
03,06,12,31,00,00,00,01, // 123 lightning left
00,00,00,60,12,24,48,32, // 124 lightning right
03,02,04,0x08,16,32,00,00// 125 lightning head character redefine
// 126, 127 allready used in them native graphics
};
unsigned char catfish[]={
00,48,11,05,31,39,11,16, // 112 left catfish
16,49,59,63,62,63,59,33, // 113 left catfish (queue)
02,35,55,63,31,63,55,33, // 114 right fish
00,03,52,40,62,57,52,02 // 115 right fish
};
unsigned char catcat[]={
04,28,31,15,03,03,02,06, // 112 right cat
01,01,62,60,60,12,38,42, // 113 right cat
16,16,15,07,07,06,12,10, // 114 left cat
04,07,63,62,56,24,40,44 // 115 left cat}
};
unsigned char redefcharExt[]={
// happy aldo: player les bras en bas
00,00,00,00,00,00,00,30, // 34 à haut de la tête
00,00,00,00,00,00,00,01, // 35 à gauche de la tête
00,00,00,00,00,00,00,32, // 36 à droite de la tête
03,03,06,06,06,00,06,06, // 37 à gauche du corps
48,48,24,24,24,00,24,24, // 38 à droite du corps
22,61,63,63,30,30,12,00 // 39 kernel
};
// redefine characters
void redefine_char()
{
// 0xB400 - 46080 beginning of charset
// 46808 = char no 86
char startchar;
j=0;
for (i=46808;i<46808+sizeof(redefchar)-1;i++)
*(unsigned char*)i=redefchar[j++];
}
// happy ALDO
void redefine_charExt()
{
// 0xB400 - 46080 beginning of charset
// 46352 = char no 34
char startchar;
j=0;
for (i=46352;i<46352+sizeof(redefcharExt)-1;i++)
*(unsigned char*)i=redefcharExt[j++];
}
// game win animation
void wingame()
{
int pos_scr;
int i,j,x,y;
unsigned char kk;
// ici bruit de pluie qui s'arrete ?
j=0;
//scanner tout l'écran afin de faire disparaitre les gouttes
for (pos_scr=0xBB80;pos_scr<0xBB80+1000;pos_scr++)
{
if (j++==39)
{
for (wait=0;wait<1000;wait++);
j=0;
}
drop_sliding_outside();
// clear the rain
if ((peek(pos_scr)==109)||
(peek(pos_scr)==108)||
(peek(pos_scr)==107)||
(peek(pos_scr)==22))
poke(pos_scr,32);
}
*(unsigned char*)(0Xbb80+(20*40)+4)=32;
*(unsigned char*)(0Xbb80+(21*40)+4)=32;
*(unsigned char*)(0Xbb80+(22*40)+4)=32;
*(unsigned char*)(0Xbb80+(23*40)+4)=32;
// Aldo exit the house
for (j=0;j<31;j++)
{
for (wait=0;wait<1000;wait++);
scroll_right(1,23);
if (walking==0)
walking=1;
else
walking=0;
disp_aldo(px,py);
}
paper(3); //yellow
// the cat come to Aldo
for (j=3;j<px-3;j++)
{
for (wait=0;wait<1500;wait++);
*(unsigned char*)(0Xbb80+(caty*40)+j-2)=32;
*(unsigned char*)(0Xbb80+(caty*40)+j-1)=0;
*(unsigned char*)(0Xbb80+(caty*40)+j)=114;
*(unsigned char*)(0Xbb80+(caty*40)+j+1)=115;
}
*(unsigned char*)(0XBBAA+(40*(caty-2))+j-3)=1; // color of kernel
// clear the hires box
for (i=40;i<4480+40;i++)
poke(0xA01B+i,64); // 64 = correct
// set the text mode in hires
for (i=40;i<4480+40;i+=40)
poke(0xA01B+i,27);
// set the hires mode in text
for (i=2;i<14;i++)
poke(0xBB80+(i*40)+2,31);
// set the colors of inside box
for (i=2;i<14;i++)
{
poke(0xBB80+(i*40)+1,7); // white before hires blox
poke(0xBB80+(i*40)+28,4); // blue before house
}
poke(0x24E,10);
// set graphicals primitives avaible in text mode
poke(0x213,255);
// draw the sun
for(j=1;j<32;j++)
{
curset(90,64,1);circle(j,1);
}
poke(0xBB80+608,12); // blink before text
poke(0xBB80+633,8); // no blink
poke(0xBB80+80+608,12); // blink before text
poke(0xBB80+80+633,8); // no blink
AdvancedPrint(10,15,"CONGRATULATION ALDO !");
AdvancedPrint(5,17,"YOU R SURVIVOR OF THIS STORM !");
// here play a victory music ??
j=0;
for (wait=0;wait<200;wait++)
{
// make sun shining
if (j==10)
{
*(unsigned char*)(0XBBAA+(40*(caty-2))+px-5)=39;
curset(90,64,1);circle(34,1);
curset(90,64,1);circle(38,1);
curset(90,64,1);circle(48,1);
}
if (j++==20)
{
*(unsigned char*)(0XBBAA+(40*(caty-2))+px-5)=32;
curset(90,64,1);circle(48,0);
curset(90,64,1);circle(38,0);
curset(90,64,1);circle(34,0);
j=0;
}
kk=key();
if (kk==27)
break;
}
}
void play_music()
{
unsigned char p1,p2,n1,o1,n2,o2,n3,o3;
p1=game_music[music_index];
p2=game_music[music_index+1];
n1=game_music[music_index+2];
o1=game_music[music_index+3];
n2=game_music[music_index+4];
o2=game_music[music_index+5];
n3=game_music[music_index+6];
o3=game_music[music_index+7];
//rv=game_music[music_index+8];
play(p2,0,0,0);
//printf("p1=%d p2=%d o1=%dn1=%d o2=%d n2=%d o3=%d\n",p1,p2,o1,n2,o2,n3,o3);
if (n1>0)
music(1,o1,n1,volume);
if (n2>0)
music(2,o2,n2,volume);
if (n3>0)
music(3,o3,n3,volume);
music_index+=8;
if (music_index>=(sizeof(game_music)-9))
music_index=0;
//music(1,game_music[music_index],game_music[music_index+1],0);
//play(1,0,8,(1110*game_music[music_index+2]));
//music_index+=3;
//if (music_index>=sizeof(game_music))
// music_index=0;
}
// drop sliding animation for outside rain
void drop_sliding_outside() //
{
asm("ldy #7;"
"lda $B400+856+16,y;"
"tax;"
"suite_ge;"
"dey;"
"lda $B400+856+16,y;"
"iny;"
"sta $B400+856+16,y;"
"dey;"
"bne suite_ge;"
"txa;"
"sta $B400+856+16;"
);
asm("ldy #7;"
"lda $B400+856+16,y;"
"tax;"
"suite_ge2;"
"dey;"
"lda $B400+856+16,y;"
"iny;"
"sta $B400+856+16,y;"
"dey;"
"bne suite_ge2;"
"txa;"
"sta $B400+856+16;"
);
}
// to redefine rain drop char ( 2 char to make drop scrolling over 2 char
void redefine_raindrop()
{
*(unsigned char*)(CARADDR+864)=8;// == poke (CARADDR+864,8);
*(unsigned char*)(CARADDR+865)=8;
*(unsigned char*)(CARADDR+866)=28;
*(unsigned char*)(CARADDR+867)=28;
*(unsigned char*)(CARADDR+868)=62;
*(unsigned char*)(CARADDR+869)=62;
*(unsigned char*)(CARADDR+870)=46;
*(unsigned char*)(CARADDR+871)=28;//poke (CARADDR+871,28);
// 108 blanc reservé pour drop_sliding goutte sur 2eme car
*(unsigned char*)(CARADDR+856)=0;
*(unsigned char*)(CARADDR+857)=0;
*(unsigned char*)(CARADDR+858)=0;
*(unsigned char*)(CARADDR+859)=0;
*(unsigned char*)(CARADDR+860)=0;
*(unsigned char*)(CARADDR+861)=0;
*(unsigned char*)(CARADDR+862)=0;
*(unsigned char*)(CARADDR+863)=0;
}
// player falling by collission with cat or tile
void player_falling()
{
int time;
//colcat=0; // disable cat collision
//colfireball=0; // disable fireball collision
if (active_sound==1)
{
shoot();
music_tempo=3;
}
for (i=0;i<5;i++)
{
//manage_cat();
disp_aldo(px,py+i);
//plot(px,py-1+i,32);
//plot(px+1,py-1+i,32);
//plot(px-1,py-1+i,32);
for (time=0;time<2000;time++);
// must manage bottom screen repaint
}
display_floor(); // bug dans cette methode voir si pbl de clc ou registre a sauver sur pile ?
}
// others object falling : ice or kernel
void manage_falling_obj()
{
if ((obj_kernel!=0)||(obj_ice!=0))
{
if (obj_y<floor_y-3)
{
obj_y++;
if (obj_y>ceiling_y+1)
{
*(unsigned char*)(0XBBAA+(40*(obj_y-1))+obj_x)=32;
if (obj_kernel==1)
{
*(unsigned char*)(0XBBAA+(40*obj_y)+obj_x)=39;
*(unsigned char*)(0XBBAA+(40*obj_y)+obj_x-1)=1;
}
if (obj_ice==1)
{
*(unsigned char*)(0XBBAA+(40*obj_y)+obj_x)=99;
*(unsigned char*)(0XBBAA+(40*obj_y)+obj_x-1)=6;
}
*(unsigned char*)(0XBBAA+(40*obj_y)+obj_x+1)=0;
}
}
else
{
poke(0XBBAA+(40*obj_y)+obj_x,32);
if (obj_kernel==1)
obj_kernel=0;
if (obj_ice==1)
obj_ice=0;
}
// fall on Aldo body
if ((px-2==obj_x )&&((obj_y>=py-1)&&(obj_y<=py+3)))
{
if (obj_kernel==1)
{
if (active_sound==1)
{
ping();
music_tempo=12;
}
obj_kernel=0;
life++;
}
if (obj_ice==1)
{
if (active_sound==1)
{
explode();
music_tempo=12;
}
obj_ice=0;
being_falling=1;
player_falling();
being_falling=0;
life--;
}
}
}
}
// manage lightning
// tile_x = lightning x
//
void manage_lightning()
{
if (tile_fall==0)
{
if (lightning==1)
{
// afficher foudre
tile_fall=1;
tile_y=ceiling_y-3;
lightning_time=12; // temps de durée de l'éclair
paper(0);
if (active_sound==1)
{
explode();
music_tempo=12;
}
}
}
if (lightning_time>0)
{
lightning_time--;
for (ly=0;ly<ceiling_y-1;ly++)
{
// display the lightning
//poke(0XBBAA+(40*ly)+tile_x-1,3);
*(unsigned char*)(0XBBAA+(40*ly)+tile_x-1)=123|128;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x)=124|128;
//poke(0XBBAA+(40*ly)+tile_x+2,4);
}
// pointe de l'éclair
//poke(0XBBAA+(40*(ly))+tile_x-1,3);
*(unsigned char*)(0XBBAA-1+(40*(ly))+tile_x)=125|128;
//poke(0XBBAA+(40*(ly))+tile_x+1,4);
if (lightning_time==1)
{
// clear ligthning
for (ly=0;ly<ceiling_y-1;ly++)
{
// efface éclair avec gouttes
if (ly<def_ceiling_pos)
{
*(unsigned char*)(0XBBAA+(40*ly)+tile_x-1)=109;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x)=109;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x+1)=109;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x+2)=109;
}
else
{
*(unsigned char*)(0XBBAA+(40*ly)+tile_x-1)=32;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x)=32;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x+1)=32;
*(unsigned char*)(0XBBAA+(40*ly)+tile_x+2)=32;
}
}
if (ly<def_ceiling_pos)
*(unsigned char*)(0XBBAA+((40*ly+2))+tile_x-3)=109;
else
*(unsigned char*)(0XBBAA+((40*ly+2))+tile_x-3)=32;
//*(unsigned char*)(0XBBAA+(40*ly)+tile_x-1)=109;
//*(unsigned char*)(0XBBAA+(40*ly)+tile_x)=109;
//*(unsigned char*)(0XBBAA+(40*ly)+tile_x+1)=109;
lightning_time=0;
paper(7);
}
}
if (tile_fall==1)
{
// roof tile fall on the player
if ((px-2==tile_x )&&((tile_y>=py-1)&&(tile_y<=py+3)))
{
poke(0XBBAA+(40*tile_y)+tile_x,32);
tile_fall=0; //
shoot_tile_time=3; // 4 main program cycles for show color indacte correct catching
lightning=0;
lightning_time=0;
paper(3);
if (active_sound==1)
{
shoot();
music_tempo=7;
}
benddown=1;
legsup=1;
// clear head zone
gotoxy(px-1,py);printf(" ");
life--;
}
if (tile_y<floor_y-3)
{
tile_y++;
if (tile_y>ceiling_y+1)
{
*(unsigned char*)(0XBBAA+(40*(tile_y-1))+tile_x)=32;
*(unsigned char*)(0XBBAA+(40*tile_y)+tile_x)=122;
*(unsigned char*)(0XBBAA+(40*tile_y)+tile_x+1)=0;
*(unsigned char*)(0XBBAA+(40*tile_y)+tile_x-1)=1;
}
}
else
{
lightning=0;
// display falling tile
tile_fall=0;
poke(0XBBAA+(40*tile_y)+tile_x,32);
}
}
}
// scroll right
// min y pos =1
void scroll_right(char y,char nbr)
{
scroll_y_nbr=nbr;
scroll_y=y;
asm("lda #$AA;"
"sta write_sr+1;"
"sta read_sr+1;"
"lda #$BB;"
"sta write_sr+2;"
"sta read_sr+2;"
// calculate y start position
"ldy %scroll_y;"
//"bne saut_sr_y;"
"suite_scry:"
"clc;"
"lda read_sr+1;"
"adc #40;"
"bcc saut_sr;"
"inc write_sr+2;"
"inc read_sr+2;"
"saut_sr:"
"sta write_sr+1;"
"sta read_sr+1;"
"dey;"
"bne suite_scry;"
//"saut_sr_y:"
// here calculate the y start position
"ldy %scroll_y_nbr;"
"suite1_sr:"
"clc;"
"ldx #37;"
"suite2_sr:"
"dex;"
"read_sr:"
"lda $1234,x;"
"inx;"
"write_sr:"
"sta $1234,x;"
"dex;"
"bne suite2_sr;"
"lda write_sr+1;"
"adc #40;"
"bcc saut_retenue_sr;"
"inc write_sr+2;"
"inc read_sr+2;"
"saut_retenue_sr:"
"sta write_sr+1;"
"sta read_sr+1;"
"dey;"
"bne suite1_sr;");
}
void scroll_left(char y,char nbr)
{
scroll_y_nbr=nbr;
scroll_y=y;
asm("lda #$AA;" // #$AA
"sta write1_sl+1;"
"sta read1_sl+1;"
"lda #$BB;"
"sta write1_sl+2;"
"sta read1_sl+2;"
// calculate y start position
"ldy %scroll_y;" // 1 = minimum value
//"bne saut_sl_y;"
"suite_scly:"
"clc;"
"lda read1_sl+1;"
"adc #40;"
"bcc saut_sl;"
"inc write1_sl+2;"
"inc read1_sl+2;"
"saut_sl:"
"sta write1_sl+1;"
"sta read1_sl+1;"
"dey;"
"bne suite_scly;"
//"saut_sl_y:"
// left scrolling
"ldy %scroll_y_nbr;"
"suite11_sl:"
"ldx #0;"
"suite21_sl:"
"inx;"
"read1_sl:"
"lda $1234,x;"
"dex;"
"write1_sl:"
"sta $1234,x;"
"inx;"
"cpx #37;" // instead 38 for bug on title page
"bne suite21_sl;"
"clc;"
"lda read1_sl+1;"
"adc #40;"
"bcc saut_retenue1_sl;"
"inc write1_sl+2;"
"inc read1_sl+2;"
"saut_retenue1_sl:"
"sta write1_sl+1;"
"sta read1_sl+1;"
"dey;"
"bne suite11_sl;");
}
// house shaking bc ceiling go down
void house_shaking()
{
int j;
for (j=0;j<4;j++)
{
scroll_right(1,23);
for (wait=0;wait<500;wait++);
scroll_left(1,23);
for (wait=0;wait<500;wait++);
} // scroll_left()
}
void manage_cat()
{
#ifdef DEBUG
gotoxy(30,0);printf("WA LVL=%d",waterlevel);
#endif
if (cat==0)
{
j=0;
if (waterlevel>0)
{ // redefine chars for catfish apparence
for (i=46976;i<46976+32;i++)
*(unsigned char*)i=catfish[j++];
}
else
{ // redefine chars for cat apparence
for (i=46976;i<46976+32;i++)
*(unsigned char*)i=catcat[j++];
}
if (seecat==1) //appear on left
{
catx=3;
cat=1;
dircat=0;
catwait=10;
if (active_sound)
{
SoundEffect(cat_at_door_sound);
music_tempo=2;
}
}
if (seecat==2)// appear on right
{
catx=34;
cat=1;
dircat=1;
catwait=10;
if (active_sound)
{
SoundEffect(cat_at_door_sound);
music_tempo=2;
}
}
}
else // cat ==1 , gérer la présence du cat et son déplacement
{
// affichage du cat
// forme du cat de gauche à droite
if (dircat==0)
{
*(unsigned char*)(0Xbb80+(caty*40)+catx-2)=32;
*(unsigned char*)(0Xbb80+(caty*40)+catx-1)=0;
*(unsigned char*)(0Xbb80+(caty*40)+catx)=114;
*(unsigned char*)(0Xbb80+(caty*40)+catx+1)=115;
}
else // forme du cat de droite à gauche
{
*(unsigned char*) (0Xbb80+(caty*40)+catx)=112;
*(unsigned char*) (0Xbb80+(caty*40)+catx+1)=113;
*(unsigned char*) (0Xbb80+(caty*40)+catx-1)=0;
*(unsigned char*)(0Xbb80+(caty*40)+catx+2)=32;
}
if (catwait>0)
{
catwait--;
}
if (dircat==0) // de gauche à droite
{
if (catwait==0)
{
catx++;
}
if (catx==7) // restore left zone