-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMKINIT.C
More file actions
1290 lines (1025 loc) · 29.7 KB
/
MKINIT.C
File metadata and controls
1290 lines (1025 loc) · 29.7 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
/******************************************************************************
File: mkinit.c
Date: August 1994
(C) Williams Entertainment
Mortal Kombat III Initialization and Main Loop Routines
******************************************************************************/
#define CHECKSUM 0
/* INCLUDES */
#include "system.h"
#ifdef SONY_PSX
#include "mksony.h"
//#include <libgs.h>
#endif /* SONY_PSX */
#include "mkbkgd.h"
#include "mkobj.h"
#include "mkos.h"
#include "mkfile.h"
#include "mkgame.h"
#include "mkinit.h"
#include "mkmain.h"
#include "mkutil.h"
#include "mkguys.h"
#include "mkani.h"
#include "mkjoy.h"
#include "mkdiag.h"
#include "mkamode.h"
#include "moves.h"
#include "mkreact.h"
#include "mkscore.h"
#include "mkbug.h"
#include "valloc.h"
#include "mktext.h"
#include "mkdiag.h"
#include "psxsnd.h"
#include "wessapi.h"
#include "mksound.h"
#include "mkpal.h"
#include "stdio.h"
extern WORD f_white;
WORD loading_pal;
extern WORD LOADING_P[];
extern FNTSETUP pf_15point_soff[];
typedef struct
{
WORD pid; /* process id */
JUMPTBL proc_func; /* function to excute */
} SWTAB;
static SWTAB swtab[64] =
{
{0,NULL}, /* open 0 */
{0,NULL}, /* open 1 */
{PID_SWITCH1,p1_button5_open}, /* open 2, PLAYER 1 RUN */
{PID_SWITCH1,p1_button2_open}, /* open 3, PLAYER 1 BLOCK */
{PID_SWITCH1,p1_button0_open}, /* open 4, PLAYER 1 HI PUNCH */
{PID_SWITCH1,p1_button3_open}, /* open 5, PLAYER 1 HI KICK */
{PID_SWITCH1,p1_button4_open}, /* open 6, PLAYER 1 LOW KICK */
{PID_SWITCH1,p1_button1_open}, /* open 7, PLAYER 1 LOW PUNCH */
{0,NULL}, /* open 8 */
{0,NULL}, /* open 9 */
{0,NULL}, /* open a */
{PID_SWITCH1,p1_start_open}, /* open b, clear pause thaw state */
{0,NULL}, /* open c */
{0,NULL}, /* open d */
{0,NULL}, /* open e */
{0,NULL}, /* open f */
{0,NULL}, /* open 10 */
{0,NULL}, /* open 11 */
{PID_SWITCH2,p2_button5_open}, /* open 12, PLAYER 2 RUN */
{PID_SWITCH2,p2_button2_open}, /* open 13, PLAYER 2 BLOCK */
{PID_SWITCH2,p2_button0_open}, /* open 14, PLAYER 2 HI PUNCH */
{PID_SWITCH2,p2_button3_open}, /* open 15, PLAYER 2 HI KICK */
{PID_SWITCH2,p2_button4_open}, /* open 16, PLAYER 2 LOW KICK */
{PID_SWITCH2,p2_button1_open}, /* open 17, PLAYER 2 LOW PUNCH */
{0,NULL}, /* open 18 */
{0,NULL}, /* open 19 */
{0,NULL}, /* open 1a */
{PID_SWITCH2,p2_start_open}, /* open 1b, clear pause thaw state */
{0,NULL}, /* open 1c */
{0,NULL}, /* open 1d */
{0,NULL}, /* open 1e */
{0,NULL}, /* open 1f */
{PID_SWITCH1,p_profile}, /* close 20/0, poor mans profile */
{PID_SWITCH1,p_grid}, /* close 21/1, grid */
{PID_SWITCH1,p1_button5}, /* close 22/2, PLAYER 1 RUN */
{PID_SWITCH1,p1_button2}, /* close 23/3, PLAYER 1 BLOCK */
{PID_SWITCH1,p1_button0}, /* close 24/4, PLAYER 1 HI PUNCH */
{PID_SWITCH1,p1_button3}, /* close 25/5, PLAYER 1 HI KICK */
{PID_SWITCH1,p1_button4}, /* close 26/6, PLAYER 1 LOW KICK */
{PID_SWITCH1,p1_button1}, /* close 27/7, PLAYER 1 LOW PUNCH */
{PID_SWITCH1,p_colbox}, /* close 28/8, collision box */
{PID_SWITCH1,p_profile}, /* close 29/9, poor mans profile */
{PID_SWITCH1,p_grid}, /* close 2a/a, grid */
{PID_SWITCH1,p1_start_button}, /* close 2b/b, PLAYER 1 START */
{PID_SWITCH1,p1_joy_up}, /* close 2c/c, PLAYER 1 JOYSTICK UP */
{PID_SWITCH1,p1_joy_right}, /* close 2d/d, PLAYER 1 JOYSTICK RIGHT */
{PID_SWITCH1,p1_joy_down}, /* close 2e/e, PLAYER 1 JOYSTICK DOWN */
{PID_SWITCH1,p1_joy_left}, /* close 2f/f, PLAYER 1 JOYSTICK LEFT */
{PID_SWITCH2,p_profile}, /* close 30/10, poor mans profile */
{PID_SWITCH2,p_grid}, /* close 31/11, grid */
{PID_SWITCH2,p2_button5}, /* close 32/12, PLAYER 2 RUN */
{PID_SWITCH2,p2_button2}, /* close 33/13, PLAYER 2 BLOCK */
{PID_SWITCH2,p2_button0}, /* close 34/14, PLAYER 2 HI PUNCH */
{PID_SWITCH2,p2_button3}, /* close 35/15, PLAYER 2 HI KICK */
{PID_SWITCH2,p2_button4}, /* close 36/16, PLAYER 2 LOW KICK */
{PID_SWITCH2,p2_button1}, /* close 37/17, PLAYER 2 LOW PUNCH */
{PID_SWITCH2,p_colbox}, /* close 38/18, collision box */
{PID_SWITCH2,p_profile}, /* close 39/19, poor mans profile */
{PID_SWITCH2,p_grid}, /* close 3a/1a, grid */
{PID_SWITCH2,p2_start_button}, /* close 3b/1b, PLAYER 2 START */
{PID_SWITCH2,p2_joy_up}, /* close 3c/1c, PLAYER 2 JOYSTICK UP */
{PID_SWITCH2,p2_joy_right}, /* close 3d/1d, PLAYER 2 JOYSTICK RIGHT */
{PID_SWITCH2,p2_joy_down}, /* close 3e/1e, PLAYER 2 JOYSTICK DOWN */
{PID_SWITCH2,p2_joy_left} /* close 3f/1f, PLAYER 2 JOYSTICK LEFT */
};
extern ADDRESS *check_start;
extern ADDRESS *check_end;
LONG checkinit;
LONG checkcur;
ADDRESS checksum(void)
{
ADDRESS value=0;
ADDRESS *ptr;
ptr=check_start;
while ( ptr<check_end )
{
value+=*ptr++;
}
return(value);
}
extern void floor_code_setup(void);
WORD primmax=0;
extern WORD watchdog;
/******************************************************************************
Function: void main(void)
By: David Schwartz
Date: Aug 8, 1994
Parameters: None
Returns: None
Description: This is were the game starts.
******************************************************************************/
void main(void)
{
WORD swindex;
WORD swpid;
FUNC swproc_func;
FUNC disp_func;
ADDRESS *display_list;
LONG *prnt;
#if PROFILE
int vstart,vend;
#endif
POWERUP:
WARMBOOT:
system_marker=0;
df_fastrun=1;
f_no_clock=1;
CPRT("MORTAL KOMBAT III LIVES!");
#if MK_EJBBUG
pmax=0;
#endif
#if COLLISION_BOX
f_colbox=0;
#endif
//***************************************************************
//REMOVE SONY DEBUG PRINTF STATEMENTS FROM LIBRARIES, PRETTY LAME BUT WILL
//HOPEFULLY FIX THE CRASH BUG!!!!!
prnt=(LONG *)printf; // get start of printf function
*prnt=0x03e00008; // patch code jr ra
*(prnt+1)=0x00000000; // patch code nop
//***************************************************************
ResetCallback();
PadInit(0); /* reset pad */
//ResetGraph(0);
//SetGraphDebug(0);
/* Setup file system */
module_io_init();
psxcd_init();
/* WMS Sound System Init */
PsxSoundInit((char *)p1_heap);
wess_master_sfx_vol_set(96);
/* load sound stuff */
sound_module_load(SMOD_SELECT); // prime the pump
VSync(0); // init vscync stuff
/* Initialize Game System and Stacks Switches */
main_init();
/* -DHS- determine what to do, activate hidden characters */
f_mileena=1;
f_ermac=1;
f_oldsz=1;
MAIN_GO:
system_marker=SYSTEM_INIT_MARKER;
coinflag=0; /* not on coinpage, yet */
/* create attact mode process */
CREATE(PID_AMODE,amode);
#if CHECKSUM
checkinit=checksum();
#endif
/* MAIN GAME LOOP (EXEC) */
while (TRUE)
{
/****************************************************************************
START VBLANK CODE STUFF (mkdisp.asm)
****************************************************************************/
POLLING;
#if CHECKSUM
if ( checkinit!=(checkcur=checksum()) )
{
LOCKUP;
}
#endif
#if DEBUG
if (cdb->primcnt>primmax)
primmax=cdb->primcnt;
#endif
/* perform page flipping if needed */
cdb = (cdb==db)? db+1: db; /* swap double buffer ID */
cdb->curr_prim=cdb->obj_prim; /* setup prim ptr */
cdb->primcnt=0;
cdb->box_ptr=cdb->box_prim; /* setup prim ptr for boxes */
cdb->ot_ptr=cdb->ot+1; /* set ot ptr */
ClearOTag(cdb->ot+1, OTSIZE-1); /* clear ordering table, leave clear primitive */
/* setup image compression base, based on gstate */
idcomp_ptr=idcomp_base;
/* prof start */
#if PROFILE
prof_start=GetRCnt(RCntCNT1);
vstart=tick;
#endif
/****************************************************************************
START MAIN LOOP CODE STUFF (mkinit.asm)
****************************************************************************/
/* unstack switch processes */
current_proc=(PROCESS *)&active_head;
while (swstack != swstmn)
{
if (free_head==NULL) break; /* if no free processes save for next loop */
swstack--; /* pop stack */
swindex=*swstack; /* retrieve index */
swproc_func=swtab[swindex].proc_func; /* create process if not NULL */
if (swproc_func != NULL && f_pause<PAUSE_OFF)
{
swpid=swtab[swindex].pid;
CREATE(swpid,swproc_func);
}
}
process_dispatch();
#ifdef MK_EJBBUG
if (current_proc->plink != NULL)
while (TRUE);
#endif /* MK_EJBBUG */
/* do sound update */
/* player bar stuff */
update_bar(&p1_bar,&p1_bar_view); /* update player 1 strength bar */
raise_turbo_bar(&p1_turbo,&p1_turbo_view,&p1_dont_raise);
update_bar(&p2_bar,&p2_bar_view); /* update player 2 strength bar */
raise_turbo_bar(&p2_turbo,&p2_turbo_view,&p2_dont_raise);
position_p2_bar();
/* joystick switch process */
current_proc=(PROCESS *)&active_head;
/****************************************************************************
END MAIN LOOP CODE STUFF (mkinit.asm)
****************************************************************************/
/* palette transfers */
transfer_palettes();
/* routine to run every vblank */
if (call_every_tick!=NULL)
call_every_tick();
if (f_pause<PAUSE_OFF || f_pause==PAUSE_P1_INIT || f_pause==PAUSE_P2_INIT)
{
/* gravity & keep in bounds */
if (p1_obj !=NULL)
gravity_n_bounds(p1_obj,left_edge+LEFT_PADDING,right_edge+(SCRRGT-RIGHT_PADDING));
if (p2_obj !=NULL)
gravity_n_bounds(p2_obj,left_edge+LEFT_PADDING,right_edge+(SCRRGT-RIGHT_PADDING));
/* update scrolling */
worldtlx8.pos+=scrollx8.pos;
worldtlx7.pos+=scrollx7.pos;
worldtlx6.pos+=scrollx6.pos;
worldtlx5.pos+=scrollx5.pos;
worldtlx4.pos+=scrollx4.pos;
worldtlx3.pos+=scrollx3.pos;
worldtlx2.pos+=scrollx2.pos;
worldtlx1.pos+=scrollx1.pos;
worldtlx.pos+=scrollx.pos;
worldtly.pos+=scrolly.pos;
/* setup floor buffers */
floor_code_setup();
}
#if CD_DEBUG
f_cdbug=1;
dallobj(OID_CD);
lm_setup(pf_15point_soff);
fnt_state.fnt_posy=96;
fnt_state.fnt_posx=32;
printf_p1("%d ",cdl_intr);
fnt_state.fnt_posy=120;
fnt_state.fnt_posx=32;
printf_p1("%d ",cdl_stat);
fnt_state.fnt_posy=144;
fnt_state.fnt_posx=32;
printf_p1("%d ",cdl_com);
fnt_state.fnt_posy=96;
fnt_state.fnt_posx=232;
printf_p1("%d ",cdl_errcount);
fnt_state.fnt_posy=120;
fnt_state.fnt_posx=232;
printf_p1("%d ",cdl_errintr);
fnt_state.fnt_posy=144;
fnt_state.fnt_posx=232;
printf_p1("%d ",cdl_errstat);
fnt_state.fnt_posy=168;
fnt_state.fnt_posx=232;
printf_p1("%d ",cdl_errcom);
fnt_state.fnt_posy=192;
fnt_state.fnt_posx=32;
printf_p1("%d ",g_place);
fnt_state.fnt_posy=192+24;
fnt_state.fnt_posx=32;
printf_p1("%d ",g_marker);
f_cdbug=0;
#endif
/* transfer display lists to primitives */
if (dlists != NULL)
{
dlists_ptr=dlists;
disp_world.u.ypos=worldtly.u.intpos;
while ((display_list=(*((ADDRESS **)dlists_ptr)++)) != 0)
{
if ((long)display_list==-1)
{
disp_func=(FUNC)GET_LONG(dlists_ptr)++; // get func to execute
disp_func();
}
else
{
disp_world.u.xpos=*((WORD *)(GET_LONG(dlists_ptr)++));
display_object_lists(&disp_world,(OBJECT *)display_list);
}
}
}
if (f_doscore!=0)
update_control_panel();
//******************************************************************
/* display bogus NOW LOADING Message */
if ( f_load )
{
switch ( f_load )
{
case 1: //VS
setXYWH(cdb->curr_prim,114,50,92,14);
SetUVWH(cdb->curr_prim,92,LOADING_BASE_Y+30,92,14);
break;
case 4: //LADDER
setXYWH(cdb->curr_prim,114,79,92,14);
SetUVWH(cdb->curr_prim,92,LOADING_BASE_Y+30,92,14);
break;
case 2: // SELECT
setXYWH(cdb->curr_prim,114,SCY(0xec)+12,92,14);
SetUVWH(cdb->curr_prim,92,LOADING_BASE_Y+30,92,14);
break;
case 3: // MAIN
setXYWH(cdb->curr_prim,83,108,153,23);
SetUVWH(cdb->curr_prim,92,LOADING_BASE_Y,153,23);
break;
}
cdb->curr_prim->clut=get_fore_pal(LOADING_P); //loading_pal;
cdb->curr_prim->tpage=load_tpage;
SetSemiTrans(cdb->curr_prim,0);
cdb->primcnt++;
AddPrim(cdb->ot_ptr,cdb->curr_prim);
cdb->curr_prim++; /* next prim */
}
//******************************************************************
#if DEBUG_GRID
/* Debug Grid */
if (f_gridon!=0)
debug_grid();
#endif
#if PROFILE
prof_draw_start=prof_end=GetRCnt(RCntCNT1);
#endif
DrawSync(0); // wait for everything to finish
#if PROFILE
prof_draw_end=GetRCnt(RCntCNT1);
vend=tick-vstart;
prof_draw_end+=(vend*240);
profiler();
#endif
/* Object Sort Routine, synced to irq_timer needed here */
do
{
yzsort();
}
while (irq_timer==0);
if (noflip==0)
{
PutDrawEnv(&cdb->draw); /* update drawing environment */
PutDispEnv(&cdb->disp); /* update display environment */
}
// setRGB0(&cdb->draw, GET_RED(irqskye)*8, GET_GREEN(irqskye)*8, GET_BLUE(irqskye)*8); /* set background color */
setRGB0(&cdb->clear, GET_RED(irqskye)*8, GET_GREEN(irqskye)*8, GET_BLUE(irqskye)*8); /* set background color */
if ( f_white==1 )
{
/* generate a white screen */
DrawPrim((LONG *)&cdb->clear);
}
else
{
// cdb->draw.isbg=f_auto_erase;
if (f_auto_erase)
DrawOTag(cdb->ot); /* draw */
else DrawOTag(cdb->ot+1); /* draw w/no clear */
}
}
return;
}
/******************************************************************************
Function: void update_bar(WORD *bar,WORD *bar_view,WORD *bram,WORD type)
By: David Schwartz
Date: Aug 8, 1994
Parameters: *bar - ptr to player bar real strength variable
*bar_view - ptr to player bar strength view variable
*bram = ptr to player dont raise turbo flag
type = 1=raise_turbo bar 0=update_bar
Returns: None
Description: update player's strength bar
******************************************************************************/
void update_bar_common(WORD *bar,WORD *bar_view,WORD *bram,WORD type)
{
if ( f_pause>=PAUSE_OFF )
return;
/* raise_turbo_bar */
if (type)
{
if (*bram)
{
(*bram)--;
}
else
{
(*bar)++;
if (*bar>FULL_TURBO)
*bar=FULL_TURBO;
}
}
/* update bar */
if (*bar & 0x8000) return; /* neg means effect going on, don't touch */
if (*bar != 0)
{
/* upsb1, real power > 0 */
if (*bar_view != *bar)
{
/* upsb4 */
if (*bar_view<*bar)
(*bar_view)++; // viewable is smaller --> add
else (*bar_view)--; // viewable is biggger --> sub
}
/* upsb3 */
if (*bar_view<3)
*bar_view=3;
}
else
{
/* real power = 0 */
if (*bar_view==0) // viewable = 0 ---> stuff
return;
if ((--(*bar_view))<3) // drop bar towards 0
*bar_view=0; // view<3 then zero it
return;
}
}
/******************************************************************************
Function: void main_init(void)
By: David Schwartz
Date: Aug 8, 1994
Parameters: None
Returns: None
Description: Main system initialize routine.
******************************************************************************/
void main_init(void)
{
BLK_FILL clr;
#ifdef SONY_PSX
init_sony_system(); /* init game platform */
#endif
idcomp_base=image_dcomp_buffer; /* init decompression buffer base */
swstack=swstmn; /* initialize switch stack */
curback=0; /* set current background to 0 */
text_draw=0;
/* clear overlay stuff */
load_bkgd=0xffff; // set to nada loaded
load_level=LVL_NONE; // no data loaded at level_loadaddr
/* clear screen */
SetBlockFill(&clr);
setRGB0(&clr,0,0,0);
setXY0(&clr,BUF0_X_COORD,BUF0_Y_COORD);
setWH(&clr,BUFFER_WIDTH,BUFFER_HEIGHT);
DrawPrim((u_long *)&clr);
SetBlockFill(&clr);
setRGB0(&clr,0,0,0);
setXY0(&clr,BUF1_X_COORD,BUF1_Y_COORD);
setWH(&clr,BUFFER_WIDTH,BUFFER_HEIGHT);
DrawPrim((u_long *)&clr);
randomize(GetRCnt(RCntCNT1),GetRCnt(RCntCNT1));
#if CD_DEBUG
g_marker=0;
g_place=0;
#endif
POLLING;
dipinit(); /* init dipswitch settings */
process_initialize(); /* init process list */
object_initialize(); /* init object list */
/* load permanent art into VRAM */
load_perm_art();
f_load=0;
p1_heap_char=p2_heap_char=0xffff;
f_shang_morph=MORPH_QUASI;
#ifdef SONY_PSX
// EnterCriticalSection();
// EnableEvent(vbEvent);
// ExitCriticalSection();
DISPLAY_ON;
#endif
return;
}
/******************************************************************************
Function: void dipinit(void)
By: David Schwartz
Date: Aug 8, 1994
Parameters: None
Returns: None
Description: Routine to initialize system according to dip switches (SECRET CODE SETTINGS)
******************************************************************************/
void dipinit(void)
{
f_no_violence=0;
f_no_blood=0;
diff=4;
cmos_diff=2;
f_freeplay=0; // no free play
f_no_clock=0;
f_smoke=0;
f_cheat_menu=0;
df_nopower=0;
f_unlim_fatal=0;
f_level_select=0;
f_one_win=0;
f_shang_morph=MORPH_QUASI;
credits=GAME_CREDITS;
f_no_sfx=0;
f_music=2;
#if JAP_VERSION
f_voice=1; // voice effects on
#endif
f_no_pan=0; // pan normal (OFF)
f_stereo=1; // stero on
f_no_vs=0;
f_blast=0;
/* configure sound driver */
sound_driver_config();
return;
}
/******************************************************************************
Function: void wipeout(void)
By: David Schwartz
Date: Mar 1995
Parameters: None
Returns: None
Description: wipes the system clear of all other processes, objects *
and coordinates. *
it returns with the display system and auto-erase on, *
color ram cleared, and the bit map wiped clean. *
this is nice to use when switching between stuff. *
******************************************************************************/
void wipeout(void)
{
WORD pa0;
coinflag=on_hstd=0;
process_kill_class(0,0x8000); // kill all procs except coin
object_initialize(); // reinit object lists
pa0=tick;
while (tick==pa0); // wait for new vblank
clr_scrn();
process_sleep(1);
clr_scrn();
process_sleep(1);
irqskye=0;
DISPLAY_ON;
return;
}
/******************************************************************************
Function: void p[1|2]_button[0..4][_open]
By: David Schwartz
Date: Aug 8, 1994
Parameters: None
Returns: None
Description: Various player switch processes. These functions are expected to
commit suicide at the end. They will never return from the queue
and jump routine!!!!!
******************************************************************************/
void p1_button0_open(void)
{
queue_and_jump(SW_HI_PUNCH,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p1_button1_open(void)
{
queue_and_jump(SW_LO_PUNCH,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p1_button2_open(void)
{
queue_and_jump(SW_BLOCK,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p1_button3_open(void)
{
queue_and_jump(SW_HI_KICK,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p1_button4_open(void)
{
queue_and_jump(SW_LO_KICK,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p1_button5_open(void)
{
queue_and_jump(SW_RUN,p1_boq,PLAYER1_TYPE,SW_OPEN);
process_suicide();
}
void p2_button0_open(void)
{
queue_and_jump(SW_HI_PUNCH,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p2_button1_open(void)
{
queue_and_jump(SW_LO_PUNCH,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p2_button2_open(void)
{
queue_and_jump(SW_BLOCK,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p2_button3_open(void)
{
queue_and_jump(SW_HI_KICK,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p2_button4_open(void)
{
queue_and_jump(SW_LO_KICK,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p2_button5_open(void)
{
queue_and_jump(SW_RUN,p2_boq,PLAYER2_TYPE,SW_OPEN);
process_suicide();
}
void p1_button0(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_HI_PUNCH,p1_bcq);
queue_and_jump(SW_HI_PUNCH,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p1_button1(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LO_PUNCH,p1_bcq);
queue_and_jump(SW_LO_PUNCH,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p1_button2(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_BLOCK,p1_bcq);
queue_and_jump(SW_BLOCK,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p1_button3(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_HI_KICK,p1_bcq);
queue_and_jump(SW_HI_KICK,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p1_button4(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LO_KICK,p1_bcq);
queue_and_jump(SW_LO_KICK,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p1_button5(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_RUN,p1_bcq);
queue_and_jump(SW_RUN,p1_bcq,PLAYER1_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button0(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_HI_PUNCH,p2_bcq);
queue_and_jump(SW_HI_PUNCH,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button1(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LO_PUNCH,p2_bcq);
queue_and_jump(SW_LO_PUNCH,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button2(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_BLOCK,p2_bcq);
queue_and_jump(SW_BLOCK,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button3(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_HI_KICK,p2_bcq);
queue_and_jump(SW_HI_KICK,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button4(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LO_KICK,p2_bcq);
queue_and_jump(SW_LO_KICK,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p2_button5(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_RUN,p2_bcq);
queue_and_jump(SW_RUN,p2_bcq,PLAYER2_TYPE,SW_CLOSE);
process_suicide();
}
void p1_start_button(void)
{
start_entry(&p1_state,0);
}
void p1_joy_up(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_UP,p1_jcq);
queue_and_jump(SW_UP,p1_jcq,PLAYER1_TYPE,SW_CLOSE);
}
void p1_joy_right(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_RIGHT,p1_jcq);
queue_and_jump(SW_RIGHT,p1_jcq,PLAYER1_TYPE,SW_CLOSE);
}
void p1_joy_down(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_DOWN,p1_jcq);
queue_and_jump(SW_DOWN,p1_jcq,PLAYER1_TYPE,SW_CLOSE);
}
void p1_joy_left(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LEFT,p1_jcq);
queue_and_jump(SW_LEFT,p1_jcq,PLAYER1_TYPE,SW_CLOSE);
}
void p2_start_button(void)
{
start_entry(&p2_state,1);
}
void p2_joy_up(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_UP,p2_jcq);
queue_and_jump(SW_UP,p2_jcq,PLAYER2_TYPE,SW_CLOSE);
}
void p2_joy_right(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_RIGHT,p2_jcq);
queue_and_jump(SW_RIGHT,p2_jcq,PLAYER2_TYPE,SW_CLOSE);
}
void p2_joy_down(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_DOWN,p2_jcq);
queue_and_jump(SW_DOWN,p2_jcq,PLAYER2_TYPE,SW_CLOSE);
}
void p2_joy_left(void)
{
if (gstate==GS_AMODE)
home_code_que(SW_LEFT,p2_jcq);
queue_and_jump(SW_LEFT,p2_jcq,PLAYER2_TYPE,SW_CLOSE);
}
void p1_start_open(void)