-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
th02_main.asm
29743 lines (26303 loc) · 564 KB
/
th02_main.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 : 96CEE07713A8E6460AE72276F3A9F909
; File Name : th02/MAIN.EXE
; Format : MS-DOS executable (EXE)
; Base Address: 0h Range: 0h-26EB0h Loaded length: 1F466h
; Entry Point : 0:0
; OS type : MS DOS
; Application type: Executable 16bit
.386
.model use16 large _TEXT
BINARY = 'M'
include ReC98.inc
include th01/math/subpixel.inc
include th02/th02.inc
include th02/main/entity.inc
include th02/main/playfld.inc
include th02/main/sparks.inc
include th02/main/hud/hud.inc
include th02/main/tile/tile.inc
include th02/main/player/player.inc
include th02/sprites/main_pat.inc
extern SCOPY@:proc
extern _execl:proc
extern _getdate:proc
extern _memcpy:proc
playperf_min = -6
SP_STAGE = 0
SP_BOSS = 1
SP_CLEAR = 2
MAP_ROWS_PER_SECTION = 8
MAP_BITS_PER_SECTION = 3
MAP_SECTION_COUNT = 16
MAP_LENGTH_MAX = 320
LIVES_MAX = 5
BOMBS_MAX = 5
DIALOG_LINE_LENGTH = 36
DIALOG_LINE_SIZE = (DIALOG_LINE_LENGTH + 4)
DIALOG_BOX_LINES = 2
FACE_REIMU_NEUTRAL = 0
FACE_REIMU_HUSHED = 3
FACE_REIMU_ANGRY = 6
FACE_REIMU_JOY = 9
FACE_REIMU_FROWN = 12
FACE_REIMU_FALL = 48
FACE_REIMU_CRY = 51
FACE_REIMU_QUESTION = 54
FACE_REIMU_SWEAT = 57
FACE_REIMU_FLIRTY = 60
FACE_GENJII = 96
FACE_RIKA = 99
FACE_MEIRA_NEUTRAL = 102
FACE_MIMA_SMILE = 105
FACE_MIMA_FROWN = 108
FACE_MARISA_SMILE = 144
FACE_MARISA_FROWN = 147
FACE_MEIRA_SWEAT = 150
FACE_EXRIKA_SMILE = 153
FACE_EXRIKA_FROWN = 156
FACE_COL_0 = 255
main_01 group main_01_TEXT, POINTNUM_TEXT, main_01__TEXT, ITEM_TEXT, HUD_TEXT, main_01___TEXT, PLAYER_B_TEXT, main_01____TEXT
main_03 group main_03_TEXT, DIALOG_TEXT, BOSS_5_TEXT, main_03__TEXT
main_06 group REGIST_M_TEXT, main_06_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_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/cutline.asm
include libs/master.lib/dos_axdx.asm
include libs/master.lib/dos_filesize.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_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_circlefill.asm
include libs/master.lib/grcg_circle.asm
include libs/master.lib/grcg_circle_x.asm
include libs/master.lib/grc_setclip.asm
include libs/master.lib/grcg_fill.asm
include libs/master.lib/grcg_hline.asm
include libs/master.lib/grcg_line.asm
include libs/master.lib/grcg_pset.asm
include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/grcg_vline.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_putca.asm
include libs/master.lib/gaiji_putsa.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_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_scroll.asm
include libs/master.lib/iatan2.asm
include libs/master.lib/key_sense.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/rottbl.asm
include libs/master.lib/smem_release.asm
include libs/master.lib/smem_wget.asm
include libs/master.lib/text_boxfilla.asm
include libs/master.lib/text_clear.asm
include libs/master.lib/text_fillca.asm
include libs/master.lib/text_putca.asm
include libs/master.lib/text_putsa.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_put_1plane.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_clean.asm
include libs/master.lib/super_roll_put_1plane.asm
include libs/master.lib/super_roll_put.asm
include libs/master.lib/super_put_rect.asm
include libs/master.lib/super_put.asm
include libs/master.lib/super_roll_put_tiny.asm
include libs/master.lib/super_convert_tiny.asm
include libs/master.lib/super_zoom.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
public @MPN_PUT_8$QIII
@mpn_put_8$qiii proc far
@@image = word ptr 6
@@top = word ptr 8
@@left = word ptr 0Ah
push bp
mov bp, sp
push si
push di
push ds
mov di, [bp+@@top]
mov ax, [bp+@@left]
sar ax, 3
mov dx, di
shl dx, 6
add ax, dx
shr dx, 2
add ax, dx
mov di, ax
mov ax, [bp+@@image]
shl ax, 7
mov dx, word ptr _mpn_images+2
mov bx, word ptr _mpn_images
add bx, ax
mov ds, dx
mov si, bx
mov cx, TILE_H
loc_39CC:
mov ax, SEG_PLANE_B
mov es, ax
assume es:nothing
mov ax, [si]
mov es:[di], ax
mov ax, SEG_PLANE_R
mov es, ax
assume es:nothing
mov ax, [si+20h]
mov es:[di], ax
mov ax, SEG_PLANE_G
mov es, ax
assume es:nothing
mov ax, [si+40h]
mov es:[di], ax
mov ax, SEG_PLANE_E
mov es, ax
assume es:nothing
mov ax, [si+60h]
mov es:[di], ax
add di, ROW_SIZE
add si, (TILE_W / 8)
loop loc_39CC
pop ds
pop di
pop si
pop bp
retf 6
@mpn_put_8$qiii endp
include libs/master.lib/pfint21.asm
db 0
include th02/formats/pfopen.asm
include libs/master.lib/pf_str_ieq.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3DDE proc far
push bp
mov bp, sp
xor bx, bx
jmp short loc_3DED
; ---------------------------------------------------------------------------
loc_3DE5:
mov byte ptr [bx+258Ch], 0
add bx, 0Ch
loc_3DED:
cmp bx, 168h
jl short loc_3DE5
mov word_1FFF0, 20h ; ' '
mov word_1FFF2, 1
mov word_1FFF4, 0
mov byte_1FFF8, V_WHITE
mov byte_1FFF9, 0
mov byte_1FFFA, -1
mov word_1FFF6, 20h ; ' '
pop bp
retf
sub_3DDE endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3E1C proc far
arg_0 = byte ptr 6
arg_2 = word ptr 8
arg_4 = word ptr 0Ah
push bp
mov bp, sp
push si
mov cx, [bp+arg_4]
mov bx, [bp+arg_2]
shl cx, 4
shl bx, 4
mov ax, 258Ch
mov si, ax
xor dx, dx
jmp short loc_3E5F
; ---------------------------------------------------------------------------
loc_3E35:
cmp byte ptr [si], 0
jnz short loc_3E5B
mov byte ptr [si], 1
mov al, [bp+arg_0]
mov [si+1], al
mov [si+2], cx
mov [si+6], cx
mov [si+4], bx
mov [si+8], bx
mov byte ptr [si+0Ah], 1
mov al, byte ptr word_1FFF0
mov [si+0Bh], al
jmp short loc_3E64
; ---------------------------------------------------------------------------
loc_3E5B:
inc dx
add si, 0Ch
loc_3E5F:
cmp dx, 1Eh
jl short loc_3E35
loc_3E64:
pop si
pop bp
retf 6
sub_3E1C endp
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3E6A proc far
var_2 = word ptr -2
arg_0 = word ptr 6
push bp
mov bp, sp
sub sp, 2
push si
push di
mov ax, 0A800h
mov es, ax
assume es:nothing
mov si, [bp+arg_0]
mov ax, word_20164
sar ax, 3
mov dx, word_20166
shl dx, 6
add ax, dx
shr dx, 2
add ax, dx
mov di, ax
mov bx, word_20164
and bx, 7
mov al, [si+8EEh]
mov ah, 0
mov [bp+var_2], ax
mov cl, bl
shr ax, cl
mov cl, 10h
sub cl, bl
mov dx, [bp+var_2]
shl dx, cl
or ax, dx
jmp short loc_3EB8
; ---------------------------------------------------------------------------
loc_3EB1:
mov es:[di], ax
add di, 50h ; 'P'
dec si
loc_3EB8:
or si, si
jg short loc_3EB1
pop di
pop si
leave
retf 2
sub_3E6A endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3EC2 proc near
arg_0 = word ptr 4
push bp
mov bp, sp
push si
mov si, [bp+arg_0]
mov ax, word_20164
sar ax, 3
mov dx, word_20166
shl dx, 6
add ax, dx
shr dx, 2
add ax, dx
mov bx, ax
jmp short loc_3EEA
; ---------------------------------------------------------------------------
loc_3EE1:
mov word ptr es:[bx], 0FFFFh
add bx, 50h ; 'P'
dec si
loc_3EEA:
or si, si
jg short loc_3EE1
pop si
pop bp
retn 2
sub_3EC2 endp
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3EF4 proc far
push bp
mov bp, sp
push si
push di
mov ax, 0A800h
mov es, ax
push GC_RMW
mov al, byte_1FFF9
mov ah, 0
push ax
nopcall grcg_setcolor
mov ax, 258Ch
mov si, ax
xor di, di
jmp short loc_3F7B
; ---------------------------------------------------------------------------
loc_3F15:
cmp byte ptr [si], 0
jz short loc_3F77
mov al, _page_back
mov ah, 0
shl ax, 2
mov bx, ax
mov ax, [bx+si+2]
sar ax, 4
mov word_20164, ax
mov ax, [bx+si+4]
sar ax, 4
mov word_20166, ax
cmp _reduce_effects, 0
jz short loc_3F4B
mov al, _page_back
mov ah, 0
mov dx, di
and dx, 1
cmp ax, dx
jnz short loc_3F54
loc_3F4B:
mov al, [si+0Ah]
mov ah, 0
push ax
call sub_3EC2
loc_3F54:
cmp byte ptr [si], 2
jnz short loc_3F5E
mov byte ptr [si], 0
jmp short loc_3F77
; ---------------------------------------------------------------------------
loc_3F5E:
mov al, _page_front
mov ah, 0
shl ax, 2
mov bx, ax
mov ax, [bx+si+2]
mov cx, [bx+si+4]
xor bx, 4
mov [bx+si+2], ax
mov [bx+si+4], cx
loc_3F77:
inc di
add si, 0Ch
loc_3F7B:
cmp di, 1Eh
jl short loc_3F15
nopcall grcg_off
pop di
pop si
pop bp
retf
sub_3EF4 endp
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_3F8A proc far
var_6 = word ptr -6
var_4 = word ptr -4
var_2 = word ptr -2
push bp
mov bp, sp
sub sp, 6
push si
push di
push GC_RMW
mov al, byte_1FFF8
mov ah, 0
push ax
nopcall grcg_setcolor
mov al, byte_1FFFA
mov byte_20168, al
mov al, byte_1FFF8
mov byte_20169, al
mov ax, 258Ch
mov si, ax
mov [bp+var_2], 0
jmp loc_407E
; ---------------------------------------------------------------------------
loc_3FB9:
cmp byte ptr [si], 1
jz short loc_3FC1
jmp loc_4078
; ---------------------------------------------------------------------------
loc_3FC1:
mov al, [si+0Bh]
add al, byte ptr word_1FFF2
mov [si+0Bh], al
mov al, [si+1]
add al, byte ptr word_1FFF4
mov [si+1], al
push ss
lea ax, [bp+var_4]
push ax
push ss
lea ax, [bp+var_6]
push ax
push word ptr [si+1]
mov al, [si+0Bh]
mov ah, 0
push ax
nop
push cs
; Hack (what is this I don't even)
db 0e8h
db 075h
db 0b5h
mov al, _page_back
mov ah, 0
shl ax, 2
mov bx, ax
mov dx, [bp+var_4]
add [bx+si+2], dx
mov dx, [bp+var_6]
add [bx+si+4], dx
mov dx, [bx+si+2]
sar dx, 4
mov word_20164, dx
mov ax, [bx+si+4]
sar ax, 4
mov word_20166, ax
cmp dx, 1A0h
jge short loc_402B
cmp dx, 18h
jle short loc_402B
cmp ax, 8
jle short loc_402B
cmp ax, 180h
jl short loc_4030
loc_402B:
mov byte ptr [si], 2
jmp short loc_4078
; ---------------------------------------------------------------------------
loc_4030:
mov ax, word_1FFF6
shl ax, 2
add ax, word_1FFF6
mov di, ax
mov bl, 5
jmp short loc_404F
; ---------------------------------------------------------------------------
loc_4040:
mov al, [si+0Bh]
mov ah, 0
cmp ax, di
jg short loc_4055
sub di, word_1FFF6
dec bl
loc_404F:
cmp di, word_1FFF6
jg short loc_4040
loc_4055:
mov [si+0Ah], bl
cmp _reduce_effects, 0
jz short loc_406E
mov al, _page_back
mov ah, 0
mov dx, [bp+var_2]
and dx, 1
cmp ax, dx
jnz short loc_4078
loc_406E:
mov al, [si+0Ah]
mov ah, 0
push ax
call sub_3E6A
loc_4078:
inc [bp+var_2]
add si, 0Ch
loc_407E:
cmp [bp+var_2], 1Eh
jge short loc_4087
jmp loc_3FB9
; ---------------------------------------------------------------------------
loc_4087:
nopcall grcg_off
pop di
pop si
leave
retf
sub_3F8A endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_4090 proc far
@@i = word ptr -8
@@page_offset = word ptr -6
var_4 = word ptr -4
var_2 = word ptr -2
@@as_circle_sprite = word ptr 6
@@count = word ptr 8
@@speed = word ptr 0Ah
@@top = word ptr 0Ch
@@left = word ptr 0Eh
enter 8, 0
push si
push di
mov ax, [bp+@@top]
cmp ax, RES_Y
jb short loc_40A1
sub ax, RES_Y
loc_40A1:
mov [bp+@@top], ax
shl [bp+@@left], SUBPIXEL_BITS
shl [bp+@@top], SUBPIXEL_BITS
mov ax, offset _sparks
mov si, ax
mov ax, _spark_ring_i
mov [bp+@@i], ax
mov cl, size spark_t
imul cl
add si, ax
mov al, _page_back
mov ah, 0
shl ax, 2
mov [bp+@@page_offset], ax
xor di, di
jmp short loc_4142
; ---------------------------------------------------------------------------
loc_40CC:
mov [si+spark_t.SPARK_flag], F_ALIVE
mov [si+spark_t.SPARK_age], 0
mov bx, [bp+@@page_offset]
mov dx, [bp+@@left]
mov [bx+si+spark_t.SPARK_screen_topleft+Point.x], dx
mov dx, [bp+@@top]
mov [bx+si+spark_t.SPARK_screen_topleft+Point.y], dx
cmp [bp+@@as_circle_sprite], 0
jnz short loc_4100
mov al, [si+spark_t.SPARK_default_render_as]
mov [si+spark_t.SPARK_render_as], al
mov al, [si+spark_t.SPARK_speed_base]
mov ah, 0
add ax, [bp+@@speed]
mov [bp+var_2], ax
mov al, [si+spark_t.SPARK_angle]
mov ah, 0
jmp short loc_4114
; ---------------------------------------------------------------------------
loc_4100:
mov [si+spark_t.SPARK_render_as], SRA_SPRITE
mov ax, [bp+@@speed]
mov [bp+var_2], ax
mov ax, di
mov cl, 8
shl ax, cl
cwd
idiv [bp+@@count]
loc_4114:
mov [bp+var_4], ax
push ds
lea ax, [si+spark_t.SPARK_velocity+Point.x]
push ax
push ds
lea ax, [si+spark_t.SPARK_velocity+Point.y]
push ax
push [bp+var_4]
push [bp+var_2]
nop
push cs
; Hack (what is this I don't even)
db 0e8h
db 036h
db 0b4h
inc di
add si, size spark_t
inc [bp+@@i]
cmp [bp+@@i], SPARK_COUNT
jl short loc_4142
mov [bp+@@i], 0
sub si, (SPARK_COUNT * size spark_t)
loc_4142:
cmp di, [bp+@@count]
jl short loc_40CC
mov ax, [bp+@@count]
add byte ptr _spark_ring_i, al
and byte ptr _spark_ring_i, (SPARK_COUNT - 1)
pop di
pop si
leave
retf 0Ah
sub_4090 endp
; ---------------------------------------------------------------------------
nop
include th02/main/spark_render.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_41AA proc far
@@screen_top = word ptr -0Eh
@@screen_left = word ptr -0Ch
@@top_p = word ptr -0Ah
@@left_p = word ptr -6
@@i = word ptr -2
enter 0Eh, 0
push si
push di
push GC_RMW
push 14
nopcall grcg_setcolor
mov ax, offset _sparks
mov si, ax
mov [bp+@@i], 0
jmp loc_4276
; ---------------------------------------------------------------------------
loc_41C7:
cmp [si+spark_t.SPARK_flag], F_ALIVE
jz short loc_41CF
jmp loc_4270
; ---------------------------------------------------------------------------
loc_41CF:
mov al, _page_back
mov ah, 0
shl ax, 2
add ax, si
add ax, SPARK_screen_topleft
mov [bp+@@left_p], ax
add ax, Point.y
mov [bp+@@top_p], ax
mov ax, [si+spark_t.SPARK_velocity+Point.x]
mov bx, [bp+@@left_p]
add [bx], ax
mov ax, _spark_accel_x
add [si+spark_t.SPARK_velocity+Point.x], ax
mov ax, [si+spark_t.SPARK_velocity+Point.y]
mov bx, [bp+@@top_p]
add [bx], ax
mov ax, [bx]
mov [bp+@@screen_top], ax
mov bx, [bp+@@left_p]
mov ax, [bx]
sar ax, 4
mov [bp+@@screen_left], ax
mov bx, [bp+@@top_p]
mov ax, [bx]
sar ax, 4
mov [bp+@@screen_top], ax
mov di, [bp+@@screen_top]
inc word ptr [si+spark_t.SPARK_velocity+Point.y]
inc [si+spark_t.SPARK_age]
cmp [bp+@@screen_left], PLAYFIELD_LEFT
jl short loc_4240
cmp [bp+@@screen_left], (PLAYFIELD_RIGHT - SPARK_W)
jge short loc_4240
mov al, [si+spark_t.SPARK_age]
cmp al, _spark_age_max
ja short loc_4240
cmp di, PLAYFIELD_BOTTOM
jge short loc_4240
cmp di, (PLAYFIELD_TOP - SPARK_H)
jg short loc_4245
loc_4240:
mov [si+spark_t.SPARK_flag], F_REMOVE
jmp short loc_4270
; ---------------------------------------------------------------------------
loc_4245:
add di, _scroll_line
cmp di, RES_Y
jb short loc_4253
sub di, RES_Y
loc_4253:
push [bp+@@screen_left]
push di
cmp [si+spark_t.SPARK_render_as], SRA_DOT
jnz short loc_4264
nopcall grcg_pset
jmp short loc_4270
; ---------------------------------------------------------------------------
loc_4264:
mov al, [si+spark_t.SPARK_age]
mov ah, 0
and ax, (SPARK_CELS - 1)
push ax
call spark_render
loc_4270:
inc [bp+@@i]
add si, size spark_t
loc_4276:
cmp [bp+@@i], SPARK_COUNT
jge short loc_427F
jmp loc_41C7
; ---------------------------------------------------------------------------
loc_427F:
nopcall grcg_off
pop di
pop si
leave
retf
sub_41AA endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_4288 proc far
push bp
mov bp, sp
push si
push di
mov ax, offset _sparks
mov si, ax
xor di, di
jmp short loc_42EF
; ---------------------------------------------------------------------------
loc_4296:
cmp [si+spark_t.SPARK_flag], F_FREE
jz short loc_42EB
mov al, _page_back
mov ah, 0
shl ax, 2
mov bx, ax
mov ax, [bx+si+spark_t.SPARK_screen_topleft+Point.x]
sar ax, SUBPIXEL_BITS
push ax ; left
mov ax, [bx+si+spark_t.SPARK_screen_topleft+Point.y]
sar ax, SUBPIXEL_BITS
push ax ; top
cmp [si+spark_t.SPARK_render_as], SRA_DOT
jnz short loc_42BF
push 1 ; w
push 1 ; h
jmp short loc_42C3
; ---------------------------------------------------------------------------
loc_42BF:
push SPARK_W ; w
push SPARK_H ; h
loc_42C3:
nopcall @tiles_invalidate_rect$qiiii
cmp [si+spark_t.SPARK_flag], F_REMOVE
jnz short loc_42D2
mov [si+spark_t.SPARK_flag], F_FREE
jmp short loc_42EB
; ---------------------------------------------------------------------------
loc_42D2:
mov al, _page_front
mov ah, 0
shl ax, 2
mov bx, ax
mov ax, [bx+si+spark_t.SPARK_screen_topleft+Point.x]
mov dx, [bx+si+spark_t.SPARK_screen_topleft+Point.y]
xor bx, size Point
mov [bx+si+spark_t.SPARK_screen_topleft+Point.x], ax
mov [bx+si+spark_t.SPARK_screen_topleft+Point.y], dx
loc_42EB:
inc di
add si, size spark_t
loc_42EF:
cmp di, SPARK_COUNT
jl short loc_4296
pop di
pop si
leave
retf
sub_4288 endp
extern @tiles_stuff_reset$qv:proc
extern @MAP_LOAD$QNXC:proc
extern @tile_area_init_and_put_both$qv:proc
extern @egc_start_copy_noframe$qv:proc
extern @TILES_SCROLL_AND_EGC_RENDER_BOTH$QI:proc
extern @tiles_fill_and_put_initial$qv:proc
extern @TILES_INVALIDATE_RECT$QIIII:proc
extern @tiles_egc_render$qv:proc
extern @tiles_render_all$qv:proc
extern @TILE_RING_SET_AND_PUT_BOTH_8$QIII:proc
extern @TILE_EGC_ROLL_COPY_8$QIII:proc
_TEXT ends
; ===========================================================================
; Segment type: Pure code
main_01_TEXT segment word public 'CODE' use16
assume cs:main_01
;org 3
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== 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
_argc = word ptr 6
_argv = dword ptr 8
_envp = dword ptr 0Ch