-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
th03_mainl.asm
3076 lines (2751 loc) · 63.5 KB
/
th03_mainl.asm
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
;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2009 by Hex-Rays, <[email protected]> |
; +-------------------------------------------------------------------------+
;
; Input MD5 : CE44AA7A114237C6B3CD67EEA9C0225A
; File Name : th03/MAINL.EXE
; Format : MS-DOS executable (EXE)
; Base Address: 0h Range: 0h-10CF0h Loaded length: F72Ch
; Entry Point : 0:0
; OS type : MS DOS
; Application type: Executable 16bit
.386
.model use16 large _TEXT
include ReC98.inc
include th03/th03.inc
include th01/hardware/grppsafx.inc
include th03/sprites/regi.inc
include th03/formats/scoredat.inc
extern SCOPY@:proc
extern __ctype:byte
extern _execl:proc
group_01 group CFG_LRES_TEXT, MAINL_SC_TEXT, CUTSCENE_TEXT, SCOREDAT_TEXT, REGIST_TEXT, mainl_03_TEXT
; ===========================================================================
; Segment type: Pure code
_TEXT segment word public 'CODE' use16
assume cs:_TEXT
assume es:nothing, ds:_DATA, fs:nothing, gs:nothing
include libs/master.lib/bfnt_entry_pat.asm
include libs/master.lib/bfnt_extend_header_skip.asm
include libs/master.lib/bfnt_header_read.asm
include libs/master.lib/bfnt_header_analysis.asm
include libs/master.lib/bcloser.asm
include libs/master.lib/bfill.asm
include libs/master.lib/bfnt_palette_set.asm
include libs/master.lib/bgetc.asm
include libs/master.lib/palette_black_in.asm
include libs/master.lib/palette_black_out.asm
include libs/master.lib/bopenr.asm
include libs/master.lib/bread.asm
include libs/master.lib/bseek.asm
include libs/master.lib/bseek_.asm
include libs/master.lib/dos_axdx.asm
include libs/master.lib/dos_filesize.asm
include libs/master.lib/dos_keyclear.asm
include libs/master.lib/dos_setvect.asm
include libs/master.lib/egc.asm
include libs/master.lib/file_append.asm
include libs/master.lib/file_close.asm
include libs/master.lib/file_create.asm
include libs/master.lib/file_exist.asm
include libs/master.lib/file_read.asm
include libs/master.lib/file_ropen.asm
include libs/master.lib/file_seek.asm
include libs/master.lib/file_size.asm
include libs/master.lib/file_write.asm
include libs/master.lib/dos_close.asm
include libs/master.lib/dos_ropen.asm
include libs/master.lib/grcg_boxfill.asm
include libs/master.lib/grcg_byteboxfill_x.asm
include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/gdc_outpw.asm
db 0
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_read.asm
include libs/master.lib/gaiji_write.asm
include libs/master.lib/graph_400line.asm
include libs/master.lib/graph_clear.asm
include libs/master.lib/graph_copy_page.asm
include libs/master.lib/graph_extmode.asm
include libs/master.lib/graph_gaiji_putc.asm
include libs/master.lib/graph_pi_free.asm
include libs/master.lib/graph_pi_load_pack.asm
include libs/master.lib/graph_pack_put_8.asm
include libs/master.lib/graph_scrollup.asm
include libs/master.lib/graph_show.asm
include libs/master.lib/iatan2.asm
include libs/master.lib/js_end.asm
include libs/master.lib/palette_show.asm
include libs/master.lib/pfclose.asm
include libs/master.lib/pfgetc.asm
include libs/master.lib/pfread.asm
include libs/master.lib/pfrewind.asm
include libs/master.lib/pfseek.asm
include libs/master.lib/random.asm
include libs/master.lib/palette_entry_rgb.asm
include libs/master.lib/rottbl.asm
include libs/master.lib/smem_release.asm
include libs/master.lib/smem_wget.asm
include libs/master.lib/soundio.asm
include libs/master.lib/text_clear.asm
include libs/master.lib/text_fillca.asm
include libs/master.lib/vsync.asm
include libs/master.lib/vsync_wait.asm
include libs/master.lib/palette_white_in.asm
include libs/master.lib/palette_white_out.asm
include libs/master.lib/hmem_lallocate.asm
include libs/master.lib/mem_assign_dos.asm
include libs/master.lib/mem_assign.asm
include libs/master.lib/memheap.asm
include libs/master.lib/mem_unassign.asm
include libs/master.lib/super_free.asm
include libs/master.lib/super_entry_pat.asm
include libs/master.lib/super_entry_at.asm
include libs/master.lib/super_entry_bfnt.asm
include libs/master.lib/super_cancel_pat.asm
include libs/master.lib/super_put.asm
include libs/master.lib/respal_exist.asm
include libs/master.lib/respal_set_palettes.asm
include libs/master.lib/pfint21.asm
db 0
include libs/master.lib/js_start.asm
include libs/master.lib/js_sense.asm
db 0
include th03/formats/pfopen.asm
include libs/master.lib/pf_str_ieq.asm
include libs/master.lib/graph_pack_put_8_noclip.asm
_TEXT ends
; ===========================================================================
CFG_LRES_TEXT segment byte public 'CODE' use16
@cfg_load_resident_ptr$qv procdesc near
CFG_LRES_TEXT ends
MAINL_SC_TEXT segment byte public 'CODE' use16
@win_load$qv procdesc pascal near
@win_text_put$qv procdesc pascal near
MAINL_SC_TEXT ends
; Segment type: Pure code
CUTSCENE_TEXT segment byte public 'CODE' use16
assume cs:group_01
;org 3
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
include th03/formats/cdg_free_all.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_978D proc near
push bp
mov bp, sp
push si
graph_accesspage 1
call graph_clear
graph_accesspage 0
call graph_clear
graph_showpage 0
mov PaletteTone, 0
call far ptr palette_show
call graph_show
call cdg_put_noalpha_8 pascal, large (352 shl 16) or 300, 0
kajacall KAJA_SONG_PLAY
push 2
call palette_black_in
call snd_delay_until_measure pascal, (6 shl 16) or 16
mov si, 1
jmp short loc_97FC
; ---------------------------------------------------------------------------
loc_97E8:
call cdg_put_noalpha_8 pascal, large (352 shl 16) or 300, si
call @frame_delay$qi pascal, 6
inc si
loc_97FC:
cmp si, 5
jl short loc_97E8
call snd_delay_until_measure pascal, (10 shl 16) or 64
mov PaletteTone, 200
call far ptr palette_show
call cdg_put_noalpha_8 pascal, large (224 shl 16) or 64, 6
call cdg_put_noalpha_8 pascal, large (352 shl 16) or 300, 5
push ds
push offset aLogo1_rgb ; "logo1.rgb"
call palette_entry_rgb
call far ptr palette_show
call cdg_free_all
call snd_delay_until_measure pascal, (11 shl 16) or 4
push 1
call palette_white_in
call @frame_delay$qi pascal, 8
call @win_text_put$qv
call sub_9887
or ax, ax
jnz short loc_9868
call sub_990C
loc_9868:
call @input_mode_interface$qv
cmp _input_sp, INPUT_NONE
jnz short loc_987D
call @frame_delay$qi pascal, 1
jmp short loc_9868
; ---------------------------------------------------------------------------
loc_987D:
push 1
call palette_black_out
pop si
pop bp
retn
sub_978D endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_9887 proc near
var_2 = word ptr -2
enter 2, 0
les bx, _resident
cmp es:[bx+resident_t.game_mode], GM_STORY
jnz short loc_98A1
les bx, _resident
cmp es:[bx+resident_t.pid_winner], 0
jz short loc_98A6
loc_98A1:
mov ax, 1
leave
retn
; ---------------------------------------------------------------------------
loc_98A6:
les bx, _resident
mov al, es:[bx+resident_t.story_stage]
mov ah, 0
add bx, ax
mov al, es:[bx+resident_t.story_opponents]
mov bx, word ptr _resident
mov es:[bx+resident_t.RESIDENT_playchar_paletted][1], al
cmp es:[bx+resident_t.story_stage], 7
jnz short loc_98CA
mov ax, 3
leave
retn
; ---------------------------------------------------------------------------
loc_98CA:
les bx, _resident
cmp es:[bx+resident_t.story_stage], 8
jnz short loc_98DA
mov ax, 4
leave
retn
; ---------------------------------------------------------------------------
loc_98DA:
les bx, _resident
cmp es:[bx+resident_t.story_stage], 9
jnz short loc_98EA
mov ax, 5
leave
retn
; ---------------------------------------------------------------------------
loc_98EA:
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
mov ah, 0
dec ax
cwd
sub ax, dx
sar ax, 1
mov [bp+var_2], ax
cmp [bp+var_2], 7
jl short loc_9908
mov es:[bx+resident_t.RESIDENT_playchar_paletted][1], (1 + (PLAYCHAR_REIMU * 2))
loc_9908:
xor ax, ax
leave
retn
sub_9887 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_990C proc near
var_1 = byte ptr -1
enter 2, 0
graph_showpage 0
graph_accesspage 1
mov al, _playchar[0]
mov [bp+var_1], al
push 0
push ds
mov ah, 0
cwd
sub ax, dx
mov bx, ax
sar bx, 1
add bx, bx
push _PIC_FN[bx]
mov al, [bp+var_1]
mov ah, 0
and ax, 1
push ax
call cdg_load_single
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
add al, -1
mov [bp+var_1], al
push 1
push ds
mov ah, 0
cwd
sub ax, dx
mov bx, ax
sar bx, 1
add bx, bx
push _PIC_FN[bx]
mov al, [bp+var_1]
mov ah, 0
and ax, 1
push ax
call cdg_load_single
mov al, [bp+var_1]
mov ah, 0
cwd
sub ax, dx
sar ax, 1
mov [bp+var_1], al
mov _do_not_show_stage_number, 1
les bx, _resident
cmp es:[bx+resident_t.game_mode], GM_STORY
jz short loc_9997
mov bx, word_E504
mov al, [bx+4]
add al, 4
jmp short loc_99CB
; ---------------------------------------------------------------------------
loc_9997:
cmp [bp+var_1], 7
jnz short loc_99A8
mov bx, word_E504
mov al, [bx+4]
add al, 2
jmp short loc_99CB
; ---------------------------------------------------------------------------
loc_99A8:
cmp [bp+var_1], 8
jnz short loc_99B7
mov bx, word_E504
inc byte ptr [bx+4]
jmp short loc_99F1
; ---------------------------------------------------------------------------
loc_99B7:
les bx, _resident
cmp es:[bx+resident_t.story_stage], 6
jnz short loc_99D4
mov bx, word_E504
mov al, [bx+4]
add al, 3
loc_99CB:
mov bx, word_E504
mov [bx+4], al
jmp short loc_99F1
; ---------------------------------------------------------------------------
loc_99D4:
push 2
push ds
push word_E502
les bx, _resident
mov al, es:[bx+resident_t.story_stage]
mov ah, 0
inc ax
push ax
call cdg_load_single
mov _do_not_show_stage_number, 0
loc_99F1:
call @pi_load$qinxc pascal, 0, ds, offset aStnx0_pi
call @pi_put_8$qiii pascal, large 0, 0
freePISlotLarge 0
call @pi_load$qinxc pascal, 0, ds, word_E504
call @pi_put_8$qiii pascal, large 0, 0
leave
retn
sub_990C endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_9A2C proc near
var_4 = word ptr -4
var_2 = word ptr -2
enter 4, 0
push si
mov si, 3A3h
mov [bp+var_2], 3AAh
mov PaletteTone, 0
call far ptr palette_show
call @pi_palette_apply$qi pascal, 0
call graph_copy_page pascal, 0
freePISlotLarge 0
call cdg_put_8 pascal, large (96 shl 16) or 96, 0
call cdg_put_hflip_8 pascal, large (352 shl 16) or 96, 1
cmp _do_not_show_stage_number, 0
jnz short loc_9A8E
call cdg_put_8 pascal, large (384 shl 16) or 46, 2
loc_9A8E:
call cdg_free pascal, 0
call cdg_free pascal, 1
call cdg_free pascal, 2
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][0]
mov ah, 0
dec ax
cwd
sub ax, dx
sar ax, 1
add ax, ax
mov [bp+var_4], ax
push (80 shl 16) or 292
push (V_WHITE or FX_WEIGHT_BOLD)
mov bx, [bp+var_4]
shl bx, 2
pushd CHAR_TITLE[bx]
call graph_putsa_fx
push (128 shl 16) or 308
push (V_WHITE or FX_WEIGHT_BOLD)
mov bx, [bp+var_4]
shl bx, 2
pushd CHAR_NAME[bx]
call graph_putsa_fx
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
mov ah, 0
dec ax
cwd
sub ax, dx
sar ax, 1
add ax, ax
mov [bp+var_4], ax
push (336 shl 16) or 292
push (V_WHITE or FX_WEIGHT_BOLD)
mov bx, [bp+var_4]
shl bx, 2
pushd CHAR_TITLE[bx]
call graph_putsa_fx
push (384 shl 16) or 308
push (V_WHITE or FX_WEIGHT_BOLD)
mov bx, [bp+var_4]
shl bx, 2
pushd CHAR_NAME[bx]
call graph_putsa_fx
push 1
call palette_black_in
mov vsync_Count1, 0
graph_accesspage 1
call graph_clear
push 0
call sub_9D20
push 1
call sub_9D20
call @pi_load$qinxc pascal, 0, ds, offset aEn2_pi
call @pi_put_interlace_8$qiii pascal, large 280, 0
freePISlotLarge 0
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
mov ah, 0
dec ax
cwd
sub ax, dx
sar ax, 1
mov [bp+var_4], ax
mov bx, [bp+var_4]
cmp bx, 8
ja short loc_9BC2
add bx, bx
jmp cs:off_9C9F[bx]
loc_9B97:
push 0
push ds
push offset aEnemy00_pi ; "ENEMY00.pi"
jmp short loc_9BBD
; ---------------------------------------------------------------------------
loc_9B9F:
push 0
push ds
push offset aEnemy01_pi ; "ENEMY01.pi"
jmp short loc_9BBD
; ---------------------------------------------------------------------------
loc_9BA7:
push 0
push ds
push offset aEnemy02_pi ; "ENEMY02.pi"
jmp short loc_9BBD
; ---------------------------------------------------------------------------
loc_9BAF:
push 0
push ds
push offset aEnemy03_pi ; "ENEMY03.pi"
jmp short loc_9BBD
; ---------------------------------------------------------------------------
loc_9BB7:
push 0
push ds
push offset aEnemy04_pi ; "ENEMY04.pi"
loc_9BBD:
call @pi_load$qinxc
loc_9BC2:
call @pi_put_interlace_8$qiii pascal, large 304, 0
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
mov ah, 0
dec ax
cwd
sub ax, dx
sar ax, 1
mov [bp+var_4], ax
cmp [bp+var_4], 0Ah
jl short loc_9BFB
mov bx, 10
cwd
idiv bx
add al, [si]
mov [si], al
mov ax, [bp+var_4]
cwd
idiv bx
mov [bp+var_4], dx
loc_9BFB:
mov al, [si+1]
add al, byte ptr [bp+var_4]
mov [si+1], al
kajacall KAJA_SONG_STOP
les bx, _resident
cmp es:[bx+resident_t.story_stage], 6
jz short loc_9C1E
push SND_LOAD_SONG
push ds
push si
jmp short loc_9C25
; ---------------------------------------------------------------------------
loc_9C1E:
push SND_LOAD_SONG
push ds
push [bp+var_2]
loc_9C25:
call _snd_load
add sp, 6
call _snd_load c, offset aYume_efc, ds, SND_LOAD_SE
mov _input_sp, INPUT_NONE
loc_9C42:
cmp vsync_Count1, 20h ; ' '
jbe short loc_9C42
jmp short loc_9C50
; ---------------------------------------------------------------------------
loc_9C4B:
call @input_mode_interface$qv
loc_9C50:
cmp vsync_Count1, 60h
ja short loc_9C5E
cmp _input_sp, INPUT_NONE
jz short loc_9C4B
loc_9C5E:
push 1
call palette_white_out
graph_accesspage 0
call graph_clear
push 1
call palette_white_in
call text_fillca pascal, (' ' shl 16) + TX_BLACK + TX_REVERSE
call @pi_palette_apply$qi pascal, 0
freePISlotLarge 0
call respal_set_palettes
pop si
leave
retn
sub_9A2C endp
; ---------------------------------------------------------------------------
off_9C9F dw offset loc_9B97
dw offset loc_9B97
dw offset loc_9B9F
dw offset loc_9BA7
dw offset loc_9B9F
dw offset loc_9BA7
dw offset loc_9B97
dw offset loc_9BAF
dw offset loc_9BB7
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_9CB1 proc near
arg_0 = dword ptr 4
arg_4 = word ptr 8
push bp
mov bp, sp
push si
mov si, [bp+arg_4]
call @pi_load$qinxc pascal, 0, large [bp+arg_0]
mov ax, si
imul ax, 320
call @pi_put_interlace_8$qiii pascal, ax, (200 shl 16)
freePISlotLarge 0
les bx, [bp+arg_0]
mov byte ptr es:[bx+2], 'e'
mov byte ptr es:[bx+3], 'x'
call @pi_load$qinxc pascal, 0, word ptr [bp+arg_0+2], bx
mov ax, si
imul ax, 320
call @pi_put_interlace_8$qiii pascal, ax, (208 shl 16)
freePISlotLarge 0
pop si
pop bp
retn 6
sub_9CB1 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_9D20 proc near
var_E = byte ptr -0Eh
var_D = byte ptr -0Dh
var_2 = word ptr -2
arg_0 = word ptr 4
enter 0Eh, 0
push si
push di
mov di, [bp+arg_0]
xor si, si
jmp short loc_9D35
; ---------------------------------------------------------------------------
loc_9D2D:
mov al, [si+116h]
mov [bp+si+var_E], al
inc si
loc_9D35:
cmp si, 0Ch
jl short loc_9D2D
les bx, _resident
add bx, di
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted]
mov ah, 0
dec ax
mov [bp+var_2], ax
cmp [bp+var_2], 10
jl short loc_9D65
mov bx, 10
cwd
idiv bx
add al, [bp+var_E]
mov [bp+var_E], al
mov ax, [bp+var_2]
cwd
idiv bx
mov [bp+var_2], dx
loc_9D65:
mov al, [bp+var_D]
add al, byte ptr [bp+var_2]
mov [bp+var_D], al
push di
push ss
lea ax, [bp+var_E]
push ax
call sub_9CB1
pop di
pop si
leave
retn 2
sub_9D20 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
; int __cdecl main(int argc, const char **argv, const char **envp)
public _main
_main proc far
var_2 = byte ptr -2
var_1 = byte ptr -1
_argc = word ptr 6
_argv = dword ptr 8
_envp = dword ptr 0Ch
enter 2, 0
call @cfg_load_resident_ptr$qv
or ax, ax
jz @@ret
call @game_init_main$qnxuc pascal, ds, offset aCOul
call respal_exist
mov _snd_midi_active, 0
les bx, _resident
cmp es:[bx+resident_t.bgm_mode], SND_BGM_OFF
jz short loc_9DAD
call _snd_determine_mode
loc_9DAD:
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
call _snd_load c, offset aYume_efc, ds, SND_LOAD_SE
call _snd_se_reset
call _hflip_lut_generate
les bx, _resident
cmp es:[bx+resident_t.show_score_menu], 0
jz short loc_9E04
call sub_B7D2
call text_clear
call gaiji_restore
call @game_exit$qv
pushd 0
push ds
push offset path ; "op"
push ds
push offset path ; "op"
call _execl
add sp, 0Ch
loc_9E04:
les bx, _resident
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][0]
add al, -1
mov _playchar[0], al
mov al, es:[bx+resident_t.RESIDENT_playchar_paletted][1]
add al, -1
mov _playchar[1], al
cmp es:[bx+resident_t.story_stage], 0
jz loc_9F85
cmp es:[bx+resident_t.game_mode], GM_STORY
jnz short loc_9E3F
call sub_9887
mov [bp+var_1], al
cmp [bp+var_1], 4
jz short loc_9E89
cmp [bp+var_1], 5
jnz short loc_9E3F
call sub_B972
loc_9E3F:
call _snd_load c, offset aWin_m, ds, SND_LOAD_SONG
call @win_load$qv
call sub_978D
kajacall KAJA_SONG_STOP
les bx, _resident
cmp es:[bx+resident_t.game_mode], GM_STORY
jnz loc_9F58
call sub_9887
mov [bp+var_1], al
cmp [bp+var_1], 0
jnz short loc_9E7B
loc_9E75:
call sub_9A2C
jmp loc_9F1E
; ---------------------------------------------------------------------------
loc_9E7B:
cmp [bp+var_1], 3
jz short loc_9E89
cmp [bp+var_1], 4
jnz loc_9F38
loc_9E89:
call cdg_free_all
freePISlotLarge 0
mov al, _playchar[0]
mov ah, 0
cwd
sub ax, dx
sar ax, 1
mov [bp+var_2], al
cmp [bp+var_2], 10
jb short loc_9EDC
les bx, off_E4B6
mov al, es:[bx+1]
mov dl, [bp+var_2]
mov dh, 0
mov bx, 10
push ax
mov ax, dx
cwd
idiv bx
pop dx
add dl, al
mov bx, word ptr off_E4B6
mov es:[bx+1], dl
mov al, [bp+var_2]
mov ah, 0
mov bx, 10
cwd
idiv bx
mov [bp+var_2], dl
loc_9EDC:
les bx, off_E4B6
mov al, [bp+var_2]
add es:[bx+2], al
cmp [bp+var_1], 4
jnz short loc_9EF1
inc byte ptr es:[bx+5]
loc_9EF1:
graph_accesspage 0
graph_showpage al
call graph_clear
call graph_show
call @cutscene_script_load$qnxc pascal, [off_E4B6]
call @cutscene_animate$qv
call @cutscene_script_free$qv
call sub_990C
call sub_9A2C
call gaiji_restore
loc_9F1E:
call @game_exit_from_mainl_to_main$qv
pushd 0
push ds
push offset aMain ; "main"
push ds
push offset aMain ; "main"
loc_9F2E:
call _execl
add sp, 0Ch
leave
retf
; ---------------------------------------------------------------------------
loc_9F38:
call cdg_free_all
freePISlotLarge 0
call sub_B7D2
call sub_9F8D
or ax, ax
jnz short loc_9F85
call sub_B92E
jmp short loc_9F69
; ---------------------------------------------------------------------------
loc_9F58:
call cdg_free_all
freePISlotLarge 0
loc_9F69:
call text_clear
call gaiji_restore
call @game_exit$qv
pushd 0
push ds
push offset path ; "op"
push ds
push offset path ; "op"
jmp short loc_9F2E
; ---------------------------------------------------------------------------
loc_9F85:
call sub_990C
jmp loc_9E75
; ---------------------------------------------------------------------------
@@ret:
leave
retf
_main endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_9F8D proc near
var_6 = dword ptr -6
var_2 = word ptr -2
enter 6, 0
push si
push di
mov si, 1
mov [bp+var_2], 0
mov word ptr [bp+var_6+2], ds
mov word ptr [bp+var_6], offset a0
xor di, di
jmp short loc_9FB3
; ---------------------------------------------------------------------------
loc_9FA7:
les bx, _resident
add bx, di
mov es:[bx+resident_t.score_last], 0
inc di
loc_9FB3:
cmp di, (PLAYER_COUNT * SCORE_DIGITS)
jl short loc_9FA7
les bx, _resident
cmp es:[bx+resident_t.rem_credits], 0
jnz short loc_9FC8
xor ax, ax
jmp loc_A12A
; ---------------------------------------------------------------------------
loc_9FC8:
call cdg_put_noalpha_8 pascal, large (192 shl 16) or 272, 0
call cdg_put_noalpha_8 pascal, large (352 shl 16) or 272, 3
les bx, _resident
mov al, es:[bx+resident_t.rem_credits]
les bx, [bp+var_6]
add al, es:[bx]
mov es:[bx], al
call graph_putsa_fx pascal, (576 shl 16) or 371, 2Fh, word ptr [bp+var_6+2], bx
push 1
call palette_black_in
loc_A00B:
call @input_mode_interface$qv
test _input_sp.lo, low INPUT_LEFT
jnz short loc_A01E
test _input_sp.lo, low INPUT_RIGHT
jz short loc_A056
loc_A01E:
cmp [bp+var_2], 0
jnz short loc_A05B
mov ax, 1
sub ax, si
mov si, ax
push (192 shl 16) or 272
add ax, ax
mov dx, 2
sub dx, ax
push dx
call cdg_put_noalpha_8
push (352 shl 16) or 272
mov ax, si
add ax, ax
inc ax
push ax
call cdg_put_noalpha_8
mov [bp+var_2], 1
jmp short loc_A05B
; ---------------------------------------------------------------------------
loc_A056:
mov [bp+var_2], 0
loc_A05B: