-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
1905 lines (1719 loc) · 38.2 KB
/
Copy pathplayer.cpp
File metadata and controls
1905 lines (1719 loc) · 38.2 KB
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
#include "globals.h"
#include "player.h"
static int e_mode;
void player_compre2();
void player_proc();
void player_main();
void player_control();
void player_control_sub();
void player_control_main();
void player_jump_init();
void player_shock_proc();
void player_djump_air_proc();
void player_jump_proc();
void player_jump_sub();
void player_jump_sub2();
void player_zin_proc();
void player_form();
void player_walk_form();
void player_walk_form_sub(int tblno);
void player_death_form();
void player_inwater_form();
void player_jump_form();
void player_zstage_form();
void player_zbossstage_form();
void set_player_dir();
void check_in_air_water();
int player_xoff_solid(int off);
int check_scroll();
void player_ysa0023_refresh_y();
void player_refresh_y();
void player_y_regulate();
void calc_zin_xyspeed();
short calc_valdiv80(short val, int comp_f);
void p_bullet_init();
void p_bullet_proc();
void player_sub0();
void player_sub1();
void player_sub2();
void player_sub3();
SUB player_subs[]={
player_sub0, player_sub1, player_sub2, player_sub3
};
void player_compre(){
player_compre2();
if (mag_screen==2)
mag_screen=0;
if (boss_ascroll | demon_ascroll)
scroll_to_do=1;
p_bullet_proc();
show_p_bullets();
}
void player_compre2(){
static unsigned char diffs[]={0,2,1,3,2};
//$D3B4
scroll_to_do=0;
player_normal=0;
diff_extra=0;
//$D460
player_proc();
if (player.inv_cnt)
player.inv_cnt--;
else if (player.state==1)
player_normal=1;
if (player.invul_cnt){
if (!(framecount&7))
player.invul_cnt--;
}
if (player.fire_cnt)
player.fire_cnt--;
player.carspeed=0;
diff_extra =diffs[player.gun_type[player.crt_gun]];
}
void player_proc(){
static int e_modes[]={0,1,2,1,0,0,0,0};
e_mode=e_modes[stage];
if (zstage_f&0x80)
e_mode=3;
player_subs[player.state]();
}
void player_sub0(){
static int xy_init[]={0x20,0x60,0x50,0x60, 0x30,0x70,0x30, 0x70};
clear_pvars();
chr_ys[0] =xy_init[e_mode];
chr_xs[0] =xy_init[4+e_mode];
player.jump_f=1;
if (!zstage_f && !check_landingok()){
chr_xs[0]=0x10;
while(!check_landingok()){
chr_xs[0]+=0x10;
if (chr_xs[0]>=0xe0){
chr_xs[0]=0x30;
break;
}
}
}
player.form_idx=2;
player.yspeed=0;
player.inv_cnt=0x80;
player.state++;
}
void player_sub1(){
player_main();
player_form();
show_player();
player.dir_last =player.dir;
if (!player.outof_bound){
if (chr_ys[0]>=0xe8)
player_death_init();
}
}
void player_sub2(){
static unsigned char dforms[]={4,4,6};
static short dxspeed[]={-1,0,0};
int idx=(zstage_f)?(zstage_f&0x80?1:2):0;
if (boss_ascroll | demon_ascroll){
if (vstage_f)
chr_ys[0]++;
else if (chr_xs[0]>=0x1a)
chr_xs[0]--;
}
player.anim=dforms[idx];
if (player.counter){
if (--player.counter){
player_form();
show_player();
}else{
player.gun_type[player.crt_gun]=0;
clear_pvars();
player.state=0;
if (!player.lives)
player.go_flag=1;
else
player.lives--;
}
return;
}else{
player.xspeed =dxspeed[idx];
if (player.dir>=5){
player.dir_of_death |=2;
player.xspeed =-player.xspeed;
}
if (player.yspeed>=0x0200){
if (player.outof_bound)
player.counter=0x40;
else{
if (!check_in_air())
if (bg_val!=2){
player_y_regulate();
player.counter=0x40;
}
}
}
player_ysa0023_refresh_y();
player_form();
show_player();
}
}
void player_sub3(){
return;
}
void player_main(){
set_player_dir();
check_in_air_water();
p_bullet_init();
player_control();
if (boss_ascroll | demon_ascroll){
if (vstage_f)
chr_ys[0]++;
else if (chr_xs[0]>=0x1a)
chr_xs[0]--;
}
}
void player_control(){
if (!player.zin_f)
player.xspeed =0;
player_control_main();
player_control_sub();
}
void player_control_sub(){
static int xlimit[]={0xe6,0xe0,0xd0,0x1a,0x20,0x30};
static int xlimit2[]={0x90,0xff,0xff,0xff,0xa0,0xd0,0xb0,0xb0};
int idx=(zstage_f)?(zstage_f&0x80?1:2):0;
player.xspeed +=player.carspeed;
if (player.inwater_f & 0x80)
return;
if (player.xspeed==0)
return;
if (player.xspeed>0){
if (!(stage_clear&0x80)){
if(player_xoff_solid(8))
return;
if (chr_xs[0]>=xlimit[idx])
return;
if (boss_ascroll_done && chr_xs[0]>=xlimit2[stage])
return;
}
check_scroll();
player.x_acum &=0xff;
player.x_acum +=player.xspeed;
chr_xs[0] +=player.x_acum>>8;
}else{
if(player_xoff_solid(-8))
return;
if (!(stage_clear&0x80)){
if (chr_xs[0]<xlimit[idx+3])
return;
}
player.x_acum &=0xff;
player.x_acum +=player.xspeed;
chr_xs[0] +=player.x_acum>>8;
}
}
void player_control_main(){
int tmp;
player.anim=3;
if (player.auto_jump_f){
player.auto_jump_f=0;
player.zin_f=0;
chr_xs[0]=player.x_to_restore;
chr_ys[0]=player.y_to_restore;
player_jump_init();
return;
}
if (player.shock_cnt){
player_shock_proc();
return;
}
if (player.djump_air_f){
player_djump_air_proc();
return;
}
if (player.jump_f){
player_jump_proc();
return;
}
if (player.zin_f){
player_zin_proc();
return;
}
if (!player.inwater_f && (player.triggers &0x80)){
if ((player.keys&7)==4){
player.anim=2;
if (screens_of_stage==0xff || !vstage_f){
if (solid_solidunderplat_abyss(chr_ys[0]+0x10))
return;
}
player.djump_air_f=0x81;
player.free_dist =chr_ys[0]+0x14;
if (player.free_dist>0xff)
player.free_dist=0xff;
}else{
player_jump_init();
}
return;
}
if (tmp=(player.keys & 3)){
if (!player.inwater_f || !(player.keys&4))
player.xspeed=(tmp==1)?0x0100:0xff00;
return;
}
if(player.keys &4){
player.anim=2;
}else if (player.keys &8){
if (!(zstage_f&1))
player.anim=1;
else{
if(room_clear){
player.anim=5;
if (!player.zin_f){
mag_screen=1;
player.zin_f=1;
player.form_idx=0;
player.counter=0;
calc_zin_xyspeed();
}
}else{
player.anim=1;
player.shock_cnt=0x30;
PLAYSOUND1(P_SHOCK);
}
}
}else
player.anim=0;
}
void player_jump_init(){
if (player.dir>=5)
player.jump_f=0x91;
else
player.jump_f=0x11;
player.counter=0;
player.form_idx=0;
if (zstage_f)
player.yspeed =(short)0xfc90;
else
player.yspeed =(short)0xfbf0;
}
void player_shock_proc(){
player.anim=1;
player.shock_cnt--;
if (room_clear)
player.shock_cnt=0;
}
void player_djump_air_proc(){
int val;
//if (chr_ys[0]>=player.free_dist && !check_in_air()){
if (chr_ys[0]>=player.free_dist){
if (!check_in_air()){
player_y_regulate();
player_landing();
return;
}
}
player_ysa0023_refresh_y();
if (chr_ys[0]>=player.free_dist){
val=(player.keys & 2)?0x40:(player.keys & 1)?0x20:0;
if (val)
player.djump_air_f =(player.djump_air_f &0x9f) | val;
}
if (player.djump_air_f &0x40)
player.xspeed=(short)0xff00;
else if (player.djump_air_f &0x20)
player.xspeed=(short)0x0100;
}
void player_jump_proc(){
if (player.yspeed>=0){
if (zstage_f || player.yspeed>=0x400 ||
(player.yspeed>=0x100 && ((chr_ys[0]+vscroll)&0xf)<8) ){
if (!check_in_air()){
player_y_regulate();
player_jump_sub2();
player_landing();
return;
}
}
}else{
if (!(stage_clear&0x80)){
check_bg(chr_xs[0], chr_ys[0]-0xa, 0);
if (bg_solid_f)
player.yspeed=0;
}
}
player_jump_sub();
}
void player_jump_sub(){
player.yspeed +=0x0023;
if (!vstage_f || !check_scroll())
player_refresh_y();
player_jump_sub2();
}
void player_jump_sub2(){
int val;
val=(player.keys & 2)?0x40:(player.keys & 1)?0x20:0;
if (val)
player.jump_f =(player.jump_f &0x9f) | val;
if (player.jump_f &0x40)
player.xspeed=(short)0xff00;
else if (player.jump_f &0x20)
player.xspeed=(short)0x0100;
}
void player_zin_proc(){
player.anim=5;
player.y_acum &=0xff;
player.y_acum +=player.yspeed_zin;
chr_ys[0] +=player.y_acum>>8;
if (mag_screen>=2){
player.zin_f=0;
chr_xs[0]=player.x_to_restore;
chr_ys[0]=player.y_to_restore;
}
}
void player_form(){
static unsigned char oform[]={0x0f, 0x16,0x17};
if (player.inwater_f){
player_inwater_form();
return;
}
if (player.djump_air_f){
player.form=5;
player.attr &=0x3f;
if (player.dir>=5)
player.attr |=0x40;
return;
}
if (player.jump_f){
player_jump_form();
return;
}
if (zstage_f){
if (zstage_f&0x80)
player_zbossstage_form();
else
player_zstage_form();
return;
}
if (player.anim<3)
player.form =oform[player.anim];
else if(player.anim==3){
player_walk_form();
}else{
player_death_form();
}
}
void player_walk_form(){
static unsigned char tblno[]={0,2,0,3,0,0,3,0,2,0};
if (tblno[player.dir])
player_walk_form_sub(tblno[player.dir]);
else
if (player.fire_cnt)
player_walk_form_sub(1);
else
player_walk_form_sub(0);
}
void player_walk_form_sub(int tblno){
static unsigned char wforms[]={
0x02,0x03,0x04,0x05,0x03,0x06,
0x0d,0x0e,0x0f,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x10,0x11,0x12,
0x13,0x14,0x15,0x13,0x14,0x15,
0x51,0x52,0x53,0x51,0x52,0x53,
};
unsigned char *pforms;
pforms =&wforms[tblno*6];
player.form =pforms[player.form_idx];
if (! ((++player.counter) & 7)){
player.form_idx++;
if (player.form_idx>=6)
player.form_idx=0;
}
player.attr &=0x3f;
if (player.dir>=5)
player.attr |=0x40;
}
void player_death_form(){
static unsigned char dforms[]={
0x0a,0x00,0x0b,0x00,0x0a,0xc0,0x0b,0xc0,0x0c,0x00
};
unsigned char *pforms;
if (! ((++player.counter2) & 7)){
player.form_idx++;
if (player.form_idx>4)
player.form_idx=4;
}
pforms =&dforms[player.form_idx<<1];
player.form=*pforms++;
player.attr=*pforms;
if (player.dir_of_death)
player.attr ^=0x40;
}
void player_inwater_form(){
static unsigned char wforms[]={
0x19,0x00,0x19,0x00,0x19,0x00,0x18,0x00,0x18,0x00,0x18,0x40,0x18,0x40,0x19,0x40,
0x19,0x40,0x19,0x40
};
static unsigned char wforms_f[]={
0x1b,0x00,0x1c,0x00,0x1d,0x00,0x18,0x00,0x18,0x00,0x18,0x40,0x18,0x40,0x1d,0x40,
0x1c,0x40,0x1b,0x40
};
unsigned char* pforms;
if (!(player.inwater_f & 0x4)){//未完成入水形态动画
if (!(player.inwater_f & 0x10)){//已完成入水初始设置
player.form_idx=0;
player.form=5;
chr_ys[0] +=0x10;
if (player.dir>=5)
player.inwater_f |=2;
player.wio_form_delay=0x10;
player.inwater_f |=0x90;
}
player.xspeed=0;
if (player.wio_form_delay){
if (player.wio_form_delay<0xc){
player.form=(player.wio_form_delay>=8)?0x73:0x18;
}
player.wio_form_delay--;
if (player.inwater_f & 2)
player.attr |=0x40;
}else{
player.inwater_f |=4;
player.inwater_f &=0x7f;
}
return;
}else{
if (player.inwater_f & 8){//出水中?
if (player.wio_form_delay){
if (player.wio_form_delay<0x5)
player.form=5;
player.wio_form_delay--;
if (player.inwater_f & 2)
player.attr |=0x40;
}else{
player.inwater_f=0;
player.form_idx=0;
chr_ys[0] -=0x10;
}
return;
}else{
if (player.fire_cnt)
pforms=wforms_f;
else
pforms=wforms;
player.form =pforms[(player.dir<<1)];
player.attr =(player.attr&0xf) |pforms[(player.dir<<1)+1];
if (!(framecount&0xf))
player.form_idx++;
if (player.form_idx&1)
player.attr &=0xf7;
else
player.attr |=8;
if (check_bg(chr_xs[0],chr_ys[0],0)!=2){
player.inwater_f |=0x88;
player.wio_form_delay=0xc;
player.form =0x1a;
player.inwater_f &=0xfd;
if (player.dir>=5)
player.inwater_f |=2;
}
}//else of 出水中
}//else of 未完成入水形态动画
}
void player_jump_form(){
static unsigned char jfoms[]={8,9,8,9};
unsigned char tmp =(player.jump_f&0x80)?0x40:0;
unsigned char tmp2 =(player.form_idx>=2)?0xc0:0;
player.attr =((player.attr&0x3f) | tmp2) ^tmp;
player.form =jfoms[player.form_idx];
if (++player.counter2>=5){
player.counter2 =0;
player.form_idx++;
if (player.form_idx>=4)
player.form_idx=0;
}
}
void player_zstage_form(){
switch (player.anim){
case 0:
player.form =0x50;
break;
case 1:
player.form =0x55;
break;
case 2:
player.form =0x54;
break;
case 3:
case 4:
if (player.fire_cnt)
player_walk_form_sub(4);
else
player_walk_form_sub(0);
break;
case 5:
if (--player.counter>=0x80){
PLAYSOUND1(P_LANDING);
player.counter=0xa;
player.form_idx++;
player.form =0x57+(player.form_idx &1);
}
break;
case 6:
if (player.counter2<0x1b){
player.counter2++;
player.form =0x55;
}else
player.form =0x56;
player.attr=0;
}
}
void player_zbossstage_form(){
switch (player.anim){
case 0:
case 1:
case 2:
player.attr &=0x3f;
player.form=0x50;
break;
case 3:
player_walk_form();
break;
case 4:
if (player.counter2<0x1b){
player.counter2++;
player.form =0x55;
}else
player.form =0x56;
player.attr=0;
}
}
void clear_pvars(){
disp_forms[0]=0;
player.x_acum=player.y_acum=0;
player.xspeed=0;
player.yspeed_zin=0;
player.counter=0;
player.jump_f=0;
player.djump_air_f=0;
player.form_idx=0;
player.y_to_restore=0;
player.mgun_var=0;
player.inv_cnt=0;
player.invul_cnt=0;
player.inwater_f=0;
player.on_car=0;
player.free_dist=0;
player.outof_bound=0;
player.x_to_restore=0;
player.dir_last=0;
player.dir=0;
player.yspeed=0;
player.shock_cnt=0;
player.auto_jump_f=0;
player.wio_form_delay=0;
player.fire_cnt=0;
player.form=0;
player.attr=0;
player.prio=0;
}
int check_landingok(){
check_in_air();
if (bg_val & 0x80)
return 0;
if (solid_solidunderplat_abyss(chr_ys[0]+0x20))
return 0;
return 1;
}
int check_in_air(){
int ey;
if (zstage_f){
ey =zstage_f&0x80 ?0xc8:0xa0;
if (chr_ys[0]>=ey)
return 0;
else
return 1;
}else{
check_bg(chr_xs[0],chr_ys[0]+0x10, 0);
return bg_empty_f;
}
}
int solid_solidunderplat_abyss(int y){
int ty =y>>4;
unsigned char bgt;
unsigned char toff;
if (solid_or_solidunderplat(chr_xs[0], y))
return 1;
bgt =bg_toff &0x40;
toff =bg_toff & 0x3f;
while(++ty<0xe){
toff +=4;
if (vstage_f){
if (toff>=0x40 || toff>=0x80){
bgt^=0x40;
toff &=0x3f;
}
bg_toff =bgt+toff;
}else{
bg_toff =bgt+(toff &0x3f);
}
read_bg(0, bg_toff);
if (!bg_empty_f)
return 0;
}
return 1;
}
void set_player_dir(){
static unsigned char tbl1[]={2,2,7,2,4,3,6,2,0,1,8,2,7,2,7,2};
static unsigned char tbl2[]={7,2,7,2,5,3,6,2,9,1,8,2,7,2,7,2};
static unsigned char tbl3[]={0,2,7,0,0,2,7,2,0,1,8,2,7,2,7,2};
static unsigned char tbl4[]={0,2,7,0,0xA,3,6,2,0,1,8,2,7,2,7,2};
unsigned char *ptbl;
if (zstage_f&0x80){
if (player.jump_f)
ptbl=tbl4;
else
ptbl=tbl3;
}else{
if (player.dir_last<5)
ptbl=tbl1;
else
ptbl=tbl2;
}
player.dir=ptbl[player.keys & 0xf];
}
void check_in_air_water(){
if (player.on_car){
player.djump_air_f=0;
return;
}
if (player.inwater_f | player.jump_f | player.djump_air_f | player.zin_f)
return;
if(check_in_air()){
if (player.dir<5)
player.djump_air_f=0x21;
else
player.djump_air_f=0x41;
player.free_dist =chr_ys[0]+0x14;
if (player.free_dist>0xff)
player.free_dist=0xff;
}else if (bg_val==2){
player.inwater_f =1;
}else{
player.djump_air_f=0;
}
}
int player_xoff_solid(int off){
int tx=chr_xs[0]+off;
int yoff_head =(player.form==0x17)?0:0xb;
int y_head, yoff_end;
int second_yoff;
unsigned char bgt;
unsigned char toff;
if (player.outof_bound)
y_head=0xa;
else{
y_head =chr_ys[0]-yoff_head;
if (y_head<0x10)
y_head=0xa;
}
if (check_in_air() && player.jump_f)
yoff_end =0x1b;
else
yoff_end =yoff_head+0xa;
second_yoff =0x10-((y_head+vscroll)&0xf);
if (solid_or_solidunderplat(tx, y_head))
return 1;
bgt =bg_toff &0x40;
toff =bg_toff & 0x3f;
while(second_yoff<yoff_end){
second_yoff +=0x10;
toff +=4;
if (vstage_f){
if (toff>=0x40 || toff>=0x80){
bgt^=0x40;
toff &=0x3f;
}
bg_toff =bgt+toff;
}else{
bg_toff =bgt+(toff &0x3f);
}
if (solid_or_solidunderplat_cont())
return 1;
}
return 0;
}
int check_scroll(){
int tmpy;
if (zstage_f | boss_ascroll | demon_ascroll)
return 0;
if (player.state!=1)
return 0;
if (!vstage_f){
if (screens_of_stage==0xff)
return 0;
if (chr_xs[0]<0x80)
return 0;
if (!can_scroll())
return 0;
player.x_acum &=0xff;
player.x_acum +=player.xspeed;
scroll_to_do +=player.x_acum>>8;
player.xspeed=0;
return 1;
}else{
if (chr_ys[0]>=0x50)
return 0;
if (player.yspeed>=0)
return 0;
if (!can_scroll())
return 0;
player.y_acum &=0xff;
player.y_acum +=player.yspeed;
tmpy =chr_ys[0]+(player.y_acum>>8);
scroll_to_do =chr_ys[0] -tmpy;
return 1;
}
}
void player_ysa0023_refresh_y(){
player.yspeed +=0x0023;
player_refresh_y();
}
void player_refresh_y(){
player.y_acum &=0xff;
player.y_acum +=player.yspeed;
chr_ys[0] +=player.y_acum>>8;
if (!(stage_clear&0x80)){
if (chr_ys[0]<0 || chr_ys[0]>0x100)
player.outof_bound=1;
else
player.outof_bound=0;
}
}
void player_y_regulate(){
static rys[]={0,0xc9,0xa8};
int idx=(zstage_f)?(zstage_f&0x80?1:2):0;
short tmp;
if (rys[idx])
chr_ys[0]=rys[idx];
else{
tmp= (vscroll&0x0f)-0x10;
chr_ys[0] = ((chr_ys[0]+tmp) & 0xfffffff0) -tmp+4;
}
}
void player_landing(){
if (player.djump_air_f | player.jump_f){
player.form_idx=0;
player.counter=0;
player.free_dist=0;
PLAYSOUND1(P_LANDING);
}
player.attr &=0x3f;
if (player.dir>=5)
player.attr |=0x40;
player.djump_air_f =player.jump_f=0;
player.anim=0;
player.yspeed=0;
player.yspeed_zin=0;
}
void calc_zin_xyspeed(){
short xdelta,comp_f;
player.yspeed_zin =calc_valdiv80(0x58, 0);
player.x_to_restore=chr_xs[0];
player.y_to_restore=chr_ys[0];
comp_f =xdelta=chr_xs[0]-0x80;
if (xdelta<0)
xdelta =-xdelta;
player.xspeed =calc_valdiv80(xdelta, comp_f);
}
short calc_valdiv80(short val, int comp_f){
short res=val<<1;
if (comp_f>=0)
res =-res;
return res;
}
void player_death_init(){
PLAYSOUND1(P_DEATH);
player.djump_air_f =player.jump_f=0;
player.anim=0;
player.yspeed=0;
player.yspeed_zin=0;
player.inwater_f=0;
player.shock_cnt=0;
player.counter=player.counter2=0;
player.form_idx=0;
player.yspeed=(short)0xfd80;
player.state++;
}
void player_addscore(unsigned short score_to_add){
unsigned int tmp=player.score+score_to_add;
unsigned short bscore_inc;
if (tmp<65536)
player.score=tmp;
else
player.score=65535;
if (score_to_add>=0x0100)
bscore_inc=5000;
else{
if (player.score >=player.bonus_score){
bscore_inc=300;
}else
bscore_inc=0;
}
if (bscore_inc){
tmp =player.bonus_score + bscore_inc;
if (tmp<65536)
player.bonus_score=tmp;
else
player.bonus_score=65535;
player.lives++;
if (player.lives>99)
player.lives=99;
if (bscore_inc==300)
PLAYSOUND0(P_1UP);
}
if (hi_score<player.score)
hi_score=player.score;
}
int find_free_bno_init(int limit);
void init_bno(int no);
void clear_bvars(int no);
void init_bulletxy();
void init_bulletspd();
int mgun_auto();
void init_fb_spec();
void init_sb(int sb_no);
void init_sbspd(int sb_no);
void init_zbulletxy(int no);
void init_zbulletspd(int no);
void init_zb_counter();
void init_lb_spec(int no, int lb_no);
void p_bullet_init0();
void p_bullet_init1();
void p_bullet_init2();
void p_bullet_init3();
void p_bullet_init4();
void p_bullet_init5();
void p_bullet_init6();
void p_bullet_init7();
SUB p_bullet_inits[]={
p_bullet_init0, p_bullet_init1, p_bullet_init2, p_bullet_init3,
p_bullet_init4, p_bullet_init5, p_bullet_init6, p_bullet_init7,
p_bullet_init3, p_bullet_init4
};
static int tg_type, t_rapid, t_jump_f, tg_dir;
static int tpx, tpy;
static int tb_no;
void p_bullet_init(){
unsigned char tkey, val;
if (player.outof_bound | player.shock_cnt)
return;
if (player.inwater_f && (player.dir>=3 && player.dir<7))
return;
tg_type =player.gun_type[player.crt_gun] & 0xf;
if (tg_type==1 || tg_type==4)
tkey=player.keys;
else
tkey=player.triggers;
if (tkey&0x40){
t_rapid =(player.gun_type[player.crt_gun]>>4) & 1;
t_jump_f=player.jump_f;
if (t_jump_f && (player.dir==4 || player.dir==5))