-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseg2.asm
4941 lines (4818 loc) · 105 KB
/
seg2.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
SEGMENT CODE ; 2
; UI Code
%include "base.inc"
%include "constants.asm"
%include "structs.asm"
%include "variables.asm"
%include "func.mac"
%include "if.mac"
%include "extern.inc"
%include "windows.inc"
EXTERN srand
EXTERN WEP4UTIL.FCHKWEPVERS
EXTERN WEP4UTIL.WEPABOUT2
EXTERN WEP4UTIL.WEPHELP
EXPORT MAINWNDPROC MAINWNDPROC 1
EXPORT COUNTERWNDPROC COUNTERWNDPROC 2
EXPORT BOARDWNDPROC BOARDWNDPROC 9
EXPORT INVENTORYWNDPROC INVENTORYWNDPROC 14
EXPORT HINTWNDPROC HINTWNDPROC 15
EXPORT INFOWNDPROC INFOWNDPROC 16
; 0
func ShowMessageBox
%arg hWnd:word ; +6
%arg message:dword ; +8
%arg flags:word ; +c
sub sp,byte +0x2
push si
call far PauseTimer ; e 2:17a2
; if sound is enabled, play a message beep before
; popping the message box open
cmp word [SoundEnabled],byte +0x0
if nz
; Warning
test byte [flags],0x30
if nz
mov si,0x30 ; MB_ICONWARNING
jmp short .playBeep ; ↓
nop
endif ; 26
; Info
test byte [flags],0x40
if nz
mov si,0x40 ; MB_ICONINFORMATION
jmp short .playBeep ; ↓
nop
endif ; 32
; Error
test byte [flags],0x10
if nz
mov si,0x10 ; MB_ICONERROR
jmp short .playBeep ; ↓
nop
endif ; 3e
; Question
mov al,[flags]
and ax,0x20
cmp ax,0x1
cmc
sbb si,si
and si,byte +0x20 ; MB_ICONQUESTION
.playBeep: ; 4d
push si
call far USER.MessageBeep ; 4e
endif ; 53
; Show the message box and unpause
push word [hWnd]
push word [message+FarPtr.Seg] ; segment
push word [message+FarPtr.Off]
push ds
push word MessageBoxCaption
push word [flags]
call far USER.MessageBox ; 63
mov si,ax
call far UnpauseTimer ; 6a 2:17ba
mov ax,si
pop si
endfunc
; 7a
; BOOL IsCoordOnscreen(int x, int y)
;
; Reports whether the given tile coordinate lies within the viewport
func IsCoordOnscreen
sub sp,byte +0x2
%arg x:word ; x position in level
%arg y:word ; y position in level
; ViewportX > x
mov dx,[x]
mov bx,[GameStatePtr]
cmp [bx+ViewportX],dx
jg .no
; ViewportX + ViewportWidth <= x
mov ax,[bx+ViewportX]
add ax,[bx+ViewportWidth]
cmp ax,dx
jng .no
; ViewportY > y
mov dx,[y]
cmp [bx+ViewportY],dx
jg .no
; ViewportY + ViewportHeight >= y
mov ax,[bx+ViewportY]
add ax,[bx+ViewportHeight]
cmp ax,dx
jng .no
.yes:
mov ax,0x1
jmp short .end
.no: ; ba
xor ax,ax
.end: ; bc
endfunc
; c4
func DrawTile
sub sp,byte +0xa
cmp byte [bp+0xe],0x0
if z
jmp .opaque ; ↓
endif ; da
cmp byte [bp+0xc],FirstTransparent
if b
jmp .opaque ; ↓
endif ; e3
cmp byte [bp+0xc],LastTransparent
if a
jmp .opaque ; ↓
endif ; ec
; Transparent tile
push byte +0x20
call far GetTileImagePos ; ee 3:2a3e
add sp,byte +0x2
mov [bp-0xa],ax
mov [bp-0x8],dx
mov al,[bp+0xe]
push ax
call far GetTileImagePos ; 100 3:2a3e
add sp,byte +0x2
push word [MainDC]
push word [bp-0xa]
push word [bp-0x8]
push byte TileWidth
push byte TileHeight
push word [MainDC]
push ax
push dx
push word 0xcc
push byte +0x20
call far GDI.BitBlt ; 121
mov al,[bp+0xc]
add al,0x60
push ax
call far GetTileImagePos ; 12c 3:2a3e
add sp,byte +0x2
push word [MainDC]
push word [bp-0xa]
push word [bp-0x8]
push byte TileWidth
push byte TileHeight
push word [MainDC]
push ax
push dx
push word 0xee
push word 0x86
call far GDI.BitBlt ; 14e
mov al,[bp+0xc]
add al,0x30
push ax
call far GetTileImagePos ; 159 3:2a3e
add sp,byte +0x2
push word [MainDC]
push word [bp-0xa]
push word [bp-0x8]
push byte TileWidth
push byte TileHeight
push word [MainDC]
push ax
push dx
push word 0x88
push word 0xc6
call far GDI.BitBlt ; 17b
push word [bp+0x6]
push word [bp+0x8]
push word [bp+0xa]
push byte TileWidth
push byte TileHeight
push word [MainDC]
push word [bp-0xa]
push word [bp-0x8]
jmp short .blit ; ↓
nop
.opaque: ; 19a
; Opaque tile
mov al,[bp+0xc]
push ax
call far GetTileImagePos ; 19e 3:2a3e
add sp,byte +0x2
push word [bp+0x6]
push word [bp+0x8]
push word [bp+0xa]
push byte TileWidth
push byte TileHeight
push word [MainDC]
push ax
push dx
.blit: ; 1b9
push word 0xcc
push byte +0x20
call far GDI.BitBlt ; 1be
endfunc
; 1ca
func UpdateTile
sub sp,byte +0x2
push si
mov si,[bp+0xa]
push si
push word [bp+0x8]
call far IsCoordOnscreen ; 1df 2:7a
add sp,byte +0x4
or ax,ax
jz .end ; ↓
mov ax,si
shl si,byte 0x5
add si,[bp+0x8]
add si,[GameStatePtr]
mov cl,[si+Lower]
push cx
mov cl,[si+Upper]
push cx
mov bx,[GameStatePtr]
sub ax,[bx+ViewportY]
sub ax,[bx+UnusedOffsetY]
shl ax,byte TileShift
push ax
mov ax,[bp+0x8]
sub ax,[bx+ViewportX]
sub ax,[bx+UnusedOffsetX]
shl ax,byte TileShift
push ax
push word [bp+0x6]
call far DrawTile ; 221 2:c4
add sp,byte +0xa
.end: ; 229
pop si
endfunc
; 232
func DrawInventoryTile
sub sp,byte +0x2
push byte +0x0
mov al,[bp+0xc]
push ax
push word [bp+0xa]
push word [bp+0x8]
push word [bp+0x6]
call far DrawTile ; 24e 2:c4
endfunc
; 25a
; void InvertTile(hdc, x, y)
; Invert the tile at the given coordinates. (unused)
func InvertTile_Unused
sub sp,byte +0x2
; if the coordinate isn't onscreen, do nothing
push word [bp+0xa]
push word [bp+0x8]
call far IsCoordOnscreen ; 26d 2:7a
add sp,byte +0x4
or ax,ax
jz .end ; ↓
; PatBlt(hdc, (x-ViewportX)*32, (y-ViewportY)*32, 32, 32, DSTINVERT)
push word [bp+0x6]
mov ax,[bp+0x8]
mov bx,[GameStatePtr]
sub ax,[bx+ViewportX]
sub ax,[bx+UnusedOffsetX]
shl ax,byte TileShift
push ax
mov ax,[bp+0xa]
sub ax,[bx+ViewportY]
sub ax,[bx+UnusedOffsetY]
shl ax,byte TileShift
push ax
push byte TileWidth
push byte TileHeight
push byte +0x55 ; DSTINVERT
push byte +0x9
call far GDI.PatBlt ; 2a6
.end: ; 2ab
endfunc
; 2b2
; Invalidate a tile, forcing it to be redrawn.
func InvalidateTile
sub sp,byte +0xa
push di
push si
push word [bp+0x8]
push word [bp+0x6]
call far IsCoordOnscreen ; 2c7 2:7a
add sp,byte +0x4
or ax,ax
jz .end ; ↓
push word [bp+0x8]
push word [bp+0x6]
call far GetTileRect ; 2d9 4:0
add sp,byte +0x4
lea di,[bp-0xa]
mov si,ax
push ss
pop es
movsw
movsw
movsw
movsw
push word [hwndBoard]
lea ax,[bp-0xa]
push ss
push ax
push byte +0x0
call far USER.InvalidateRect ; 2f7
.end: ; 2fc
pop si
pop di
endfunc
; 306
func ScrollViewport
sub sp,byte +0x1c
push di
push si
%arg hdc:word ; +6
%arg viewportDeltaX:word ; +8 number of tiles
%arg viewportDeltaY:word ; +a to move viewport by
%arg oldChipX:word ; +c
%arg oldChipY:word ; +e
%arg newChipX:word ; +10
%arg newChipY:word ; +12
%local local_4:word ; -4
%local local_6:word ; -6
%local local_8:word ; -8
%local local_a:word ; -a
%local yScrollPixels:word ; -c
%local local_e:word ; -e
%local local_10:word ; -10
%local rect.bottom:word ; -12
%local rect.right:word ; -14
%local rect.top:word ; -16
%local rect.left:word ; -18
%define rect rect.left
;;; if viewport position didn't change, return
mov di,[viewportDeltaX]
or di,di
jnz .label0 ; ↓
cmp [viewportDeltaY],di
jnz .label0 ; ↓
jmp .end ; ↓
;;
.label0: ; 324
; si = 32*(dx - 0)
mov bx,[GameStatePtr]
mov si,di
sub si,[bx+UnusedOffsetX]
shl si,byte TileShift
; ax = 32*(dy - 0)
mov ax,[viewportDeltaY]
sub ax,[bx+UnusedOffsetY]
shl ax,byte TileShift
mov [yScrollPixels],ax
; GetClientRectangle(hwndBoard, &rect)
; Note: getClientRectangle returns only the width and height of the window,
; not the absolute coordinates. the width is in rect.right and the height
; in rect.bottom.
%define rect.height rect.bottom
%define rect.width rect.right
push word [hwndBoard]
lea ax,[rect]
push ss
push ax
call far USER.GetClientRect ; 347
; vw-0
mov bx,[GameStatePtr]
mov ax,[bx+ViewportWidth]
sub ax,[bx+UnusedOffsetX]
; dx = rect.width/32
; cx = rect.width/32 + 1
mov cx,[rect.width]
sar cx,byte TileShift
mov dx,cx
inc cx
; bx = vw-0
mov bx,ax
; if vw-0 > rect.width/32+1 then ax = rect.width/32+1
cmp ax,cx
if g
mov ax,cx
endif ; 369
; stash ax
mov [local_4],ax
; ax = vw-0
mov ax,bx
; cx = vh-0
mov bx,[GameStatePtr]
mov cx,[bx+ViewportHeight]
sub cx,[bx+UnusedOffsetY]
; bx = rect.height/32+1
mov bx,[rect.height]
sar bx,byte TileShift
mov [bp-0x1a],bx
inc bx
mov [bp-0x1c],cx
; if cx > bx then cx = bx
cmp cx,bx
if g
mov cx,bx
endif ; 38d
mov [local_e],cx
; ax = vw-0-1
dec ax
; if ax > rect.width/32 then ax = dx
cmp ax,dx
if g
mov ax,dx
endif ; 397
mov [local_6],ax
; ax = vh-0-1
; if ax > rect.height/32 then ax = rect.height/32
mov ax,[bp-0x1c]
dec ax
cmp ax,[bp-0x1a]
if g
mov ax,[bp-0x1a]
endif ; 3a6
mov [local_10],ax
;; Draw chip in his new position, scroll the window,
;; set the new viewport position, and update the tile chip left
;
; UpdateTile(hdc, new x, new y)
push word [newChipY]
push word [newChipX]
push word [bp+0x6]
call far UpdateTile ; 3b2 2:1ca
add sp,byte +0x6
; ScrollWindow(hwndBoard, -32*(dx-0), -32*(dy-0), NULL, NULL)
push word [hwndBoard]
; x scroll amount = -32*(dx - 0)
mov ax,si
neg ax
push ax
; y scroll amount = -32*(dy - 0)
mov ax,[yScrollPixels]
neg ax
push ax
push byte +0x0
push byte +0x0
push byte +0x0
push byte +0x0
call far USER.ScrollWindow ; 3d1
; update ViewportX and ViewportY
mov bx,[GameStatePtr]
add [bx+ViewportX],di
mov ax,[viewportDeltaY]
mov bx,[GameStatePtr]
add [bx+ViewportY],ax
; UpdateTile(hdc, oldx, oldy)
push word [oldChipY]
push word [oldChipX]
push word [bp+0x6]
call far UpdateTile ; 3f2 2:1ca
add sp,byte +0x6
;; Now draw any tiles that were
;; scrolled into view
.check_x_delta:
; skip if x delta is zero
or si,si
if z
jmp .check_y_delta ; ↓
endif ; 401
or si,si
if g
mov ax,[local_6]
sub ax,di ; ax -= delta x
mov [local_a],ax
mov bx,[local_4]
else ; 412
mov word [local_a],0x0
mov bx,di
neg bx
endif ; 41b
mov si,[GameStatePtr]
mov ax,[si+ViewportY]
mov [local_4],ax
mov [local_8],bx
mov cx,ax
add ax,[si+ViewportHeight]
cmp ax,cx
if g
.loop1: ; 433
mov si,[local_a]
cmp si,[local_8]
if l
mov di,[bp+0x6]
.loop2: ; 43e
; UpdateTile(hdc, vx+0+si, local_4)
push word [local_4]
mov bx,[GameStatePtr]
mov ax,[bx+ViewportX]
add ax,[bx+UnusedOffsetX]
add ax,si
push ax
push di
call far UpdateTile ; 451 2:1ca
add sp,byte +0x6
inc si
cmp si,[local_8]
jl .loop2 ; ↑
endif ; 45f
mov bx,[GameStatePtr]
mov ax,[bx+ViewportY]
add ax,[bx+ViewportHeight]
inc word [local_4]
cmp ax,[local_4]
jg .loop1 ; ↑
endif ; 473
; rect = {local_a*32, -0*32, local_8*32, (vh-0)*32}
; ValidateRect(hwndBoard, &rect)
mov ax,[local_a]
shl ax,byte TileShift
mov [rect.left],ax
mov ax,[local_8]
shl ax,byte TileShift
mov [rect.right],ax
mov bx,[GameStatePtr]
mov ax,[bx+UnusedOffsetY]
shl ax,byte TileShift
neg ax
mov [rect.top],ax
mov ax,[bx+ViewportHeight]
sub ax,[bx+UnusedOffsetY]
shl ax,byte TileShift
mov [rect.bottom],ax
push word [hwndBoard]
lea ax,[rect]
push ss
push ax
call far USER.ValidateRect ; 4ac
.check_y_delta: ; 4b1
; skip if y delta is zero
cmp word [yScrollPixels],byte +0x0
if z
jmp .end ; ↓
endif ; 4ba
if g
mov di,[local_10]
sub di,[viewportDeltaY]
mov ax,[local_e]
else ; 4c8
xor di,di
mov ax,[viewportDeltaY]
neg ax
endif ; 4cf
mov [local_4],ax
mov bx,[GameStatePtr]
mov ax,[bx+ViewportX]
mov [local_6],ax
mov cx,ax
add ax,[bx+ViewportWidth]
cmp ax,cx
if g
mov [local_8],di
.loop3: ; 4ea
mov si,[local_8]
cmp si,[local_4]
if l
mov di,[bp+0x6]
.loop4: ; 4f5
mov bx,[GameStatePtr]
mov ax,[bx+ViewportY]
add ax,[bx+UnusedOffsetY]
add ax,si
push ax
push word [local_6]
push di
call far UpdateTile ; 508 2:1ca
add sp,byte +0x6
inc si
cmp si,[local_4]
jl .loop4 ; ↑
endif ; 516
mov bx,[GameStatePtr]
mov ax,[bx+ViewportX]
add ax,[bx+ViewportWidth]
inc word [local_6]
cmp ax,[local_6]
jg .loop3 ; ↑
mov di,[local_8]
endif ; 52d
; rect = {-0*32, di*32, (vw-0)*32, (local_4-0)*32}
; ValidateRect(hwndBoard, &rect)
mov ax,[bx+UnusedOffsetX]
shl ax,byte TileShift
neg ax
mov [rect.left],ax
mov ax,[bx+ViewportWidth]
sub ax,[bx+UnusedOffsetX]
shl ax,byte TileShift
mov [rect.right],ax
shl di,byte TileShift
mov [rect.top],di
mov ax,[local_4]
shl ax,byte TileShift
mov [rect.bottom],ax
push word [hwndBoard]
lea ax,[bp-0x18]
push ss
push ax
call far USER.ValidateRect ; 55f
.end: ; 564
pop si
pop di
endfunc
; 56e
; void UpdateChip(hdc, new x, new y, old x, old y)
func UpdateChip
sub sp,byte +0x6
push si
%arg hdc:word ; +6
%arg newX:word ; +8
%arg newY:word ; +a
%arg oldX:word ; +c
%arg oldY:word ; +e
;; calculate new viewportx (but do not store)
; ax = chipx - vw/2
mov bx,[GameStatePtr]
mov ax,[bx+ViewportWidth]
mov cx,ax
sub ax,0x20
neg ax
mov dx,ax
mov ax,cx
mov si,dx
cwd
sub ax,dx
sar ax,1
sub ax,[bp+0x8]
neg ax
; clamp to [0, 32 - vw]
or ax,ax
if l
xor ax,ax
endif ; 5a1
cmp ax,si
if g
mov ax,si
endif ; 5a7
; cx = difference between new position and old position
sub ax,[bx+ViewportX]
mov [bp-0x6],ax
mov cx,ax
;; calculate new ViewportY
mov ax,[bx+ViewportHeight]
mov dx,ax
sub ax,0x20
neg ax
mov si,ax
mov ax,dx
cwd
sub ax,dx
sar ax,1
sub ax,[newY]
neg ax
; clamp to [0, 32 - vh]
or ax,ax
if l
xor ax,ax
endif ; 5cf
cmp ax,si
if g
mov ax,si
endif ; 5d5
; ax = difference between new y position and old position
sub ax,[bx+ViewportY]
;; if viewport pos is the same, just update src and dest tiles
or cx,cx
jnz .viewportMoved ; ↓
cmp ax,cx
jnz .viewportMoved ; ↓
; UpdateTile(hdc, oldX, oldY)
mov si,[hdc]
push word [oldY]
push word [oldX]
push si
call far UpdateTile ; 5eb 2:1ca
add sp,byte +0x6
; UpdateTile(hdc, newX, newY)
push word [newY]
push word [newX]
push si
call far UpdateTile ; 5fa 2:1ca
add sp,byte +0x6
jmp short .end ; ↓
.viewportMoved: ; 604
; if viewport has moved, scroll the board
push word [oldY] ; old chipy
push word [oldX] ; old chipx
push word [newY] ; new chipy
push word [newX] ; new chipx
push ax ; viewport y diff
push word [bp-0x6] ; viewport x diff
push word [hdc] ; hdc probably
call far ScrollViewport ; 617 2:306
add sp,byte +0xe
.end: ; 61f
pop si
endfunc
; 628
func WinMain
%assign %$argsize 0xa
%arg nCmdShow:word ; +6
%arg lpCmdLine:dword ; +8
%arg hPrevInstance:word ; +c
%arg hInstance:word ; +e
sub sp,byte +0x14
push word 0x218
call far WEP4UTIL.FCHKWEPVERS ; 638
or ax,ax
if z
.returnZero: ; 641
xor ax,ax
jmp short .end ; ↓
nop
endif ; 646
cmp word [hPrevInstance],byte +0x0
if z
push word [hInstance]
call far CreateClasses ; 64f 2:6c8
add sp,byte +0x2
or ax,ax
jz .returnZero
endif ; 65b
push word [nCmdShow]
push word [hInstance]
call far CreateWindowsAndInitGame ; 661 2:8e8
add sp,byte +0x4
or ax,ax
jz .returnZero
mov word [Var2c],0x1
.messageLoop: ; 673
lea ax,[bp-0x14]
push ss
push ax
push byte +0x0
push byte +0x0
push byte +0x0
push byte +0x1
call far USER.PeekMessage ; 680
or ax,ax
; FIXME: call WaitMessage if ax==0
jz .messageLoop ; ↑
cmp word [bp-0x12],byte +0x12
jz .quit ; ↓
push word [hwndMain]
push word [hAccel]
lea ax,[bp-0x14]
push ss
push ax
call far USER.TranslateAccelerator ; 69c
or ax,ax
jnz .messageLoop ; ↑
lea ax,[bp-0x14]
push ss
push ax
call far USER.TranslateMessage ; 6aa
lea ax,[bp-0x14]
push ss
push ax
call far USER.DispatchMessage ; 6b4
jmp short .messageLoop ; ↑
nop
.quit: ; 6bc
mov ax,[bp-0x10]
.end: ; 6bf
endfunc
; 6c8
func CreateClasses
sub sp,byte +0x6a
push si
mov si,[bp+0x6]
mov word [bp-0x6a],0x1000 ; style
mov word [bp-0x68],MAINWNDPROC ; lpfnWndProc
mov word [bp-0x66],SEG MAINWNDPROC ;
xor ax,ax
mov [bp-0x64],ax ; cbClassExtra
mov [bp-0x62],ax ; cbWndExtra
mov [bp-0x60],si ; hInstance
push si
push ax
push word 0x100
call far USER.LoadIcon ; 6f8
mov [bp-0x5e],ax ; hIcon
push byte +0x0
push byte +0x0
push word 0x7f00
call far USER.LoadCursor ; 707
mov [bp-0x5c],ax ; hCursor
push byte +0x4
call far GDI.GetStockObject ; 711
mov [bp-0x5a],ax ; hbcBackground
sub ax,ax
mov [bp-0x56],ax ; lpszMenuName
mov [bp-0x58],ax ;
mov word [bp-0x54],MainClassName ; lpszClassName
mov [bp-0x52],ds ;
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 72e
or ax,ax
if z
.label0: ; 737
xor ax,ax
jmp .end ; ↓
endif ; 73c
mov word [bp-0x6a],0x8
mov word [bp-0x68],BOARDWNDPROC
mov word [bp-0x66],SEG BOARDWNDPROC
xor ax,ax
mov [bp-0x64],ax
mov [bp-0x62],ax
mov [bp-0x60],si
mov [bp-0x5e],ax
push ax
push ax
push word 0x7f03
call far USER.LoadCursor ; 75e
mov [bp-0x5c],ax
push byte +0x4
call far GDI.GetStockObject ; 768
mov [bp-0x5a],ax
sub ax,ax
mov [bp-0x56],ax
mov [bp-0x58],ax
mov word [bp-0x54],BoardClassName
mov [bp-0x52],ds
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 785
or ax,ax
jz .label0 ; ↑
mov word [bp-0x6a],0x8
mov word [bp-0x68],INFOWNDPROC
mov word [bp-0x66],SEG INFOWNDPROC
xor ax,ax
mov [bp-0x64],ax
mov [bp-0x62],ax
mov [bp-0x60],si
mov [bp-0x5e],ax
push ax
push ax
push word 0x7f00
call far USER.LoadCursor ; 7b0
mov [bp-0x5c],ax
push byte +0x4
call far GDI.GetStockObject ; 7ba
mov [bp-0x5a],ax
sub ax,ax
mov [bp-0x56],ax
mov [bp-0x58],ax
mov word [bp-0x54],InfoClassName
mov [bp-0x52],ds
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 7d7
or ax,ax
if z
jmp .label0 ; ↑
endif ; 7e3
mov word [bp-0x6a],0x8
mov word [bp-0x68],COUNTERWNDPROC
mov word [bp-0x66],SEG COUNTERWNDPROC
mov word [bp-0x64],0x0
mov word [bp-0x62],0x4
mov [bp-0x60],si
xor ax,ax
mov [bp-0x5e],ax
push ax
push ax
push word 0x7f00
call far USER.LoadCursor ; 809
mov [bp-0x5c],ax
push byte +0x4
call far GDI.GetStockObject ; 813
mov [bp-0x5a],ax
sub ax,ax
mov [bp-0x56],ax
mov [bp-0x58],ax
mov word [bp-0x54],CounterClassName
mov [bp-0x52],ds
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 830
or ax,ax
if z
jmp .label0 ; ↑
endif ; 83c
mov word [bp-0x6a],0x8
mov word [bp-0x68],INVENTORYWNDPROC
mov word [bp-0x66],SEG INVENTORYWNDPROC
xor ax,ax
mov [bp-0x64],ax
mov [bp-0x62],ax
mov [bp-0x60],si
mov [bp-0x5e],ax
push ax
push ax
push word 0x7f00
call far USER.LoadCursor ; 85e
mov [bp-0x5c],ax
push byte +0x4
call far GDI.GetStockObject ; 868
mov [bp-0x5a],ax
sub ax,ax
mov [bp-0x56],ax
mov [bp-0x58],ax
mov word [bp-0x54],InventoryClassName
mov [bp-0x52],ds
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 885
or ax,ax
if z
jmp .label0 ; ↑
endif ; 891
mov word [bp-0x6a],0x8
mov word [bp-0x68],HINTWNDPROC
mov word [bp-0x66],SEG HINTWNDPROC
xor ax,ax
mov [bp-0x64],ax
mov [bp-0x62],ax
mov [bp-0x60],si
mov [bp-0x5e],ax
push ax
push ax
push word 0x7f00
call far USER.LoadCursor ; 8b3
mov [bp-0x5c],ax
push byte +0x4
call far GDI.GetStockObject ; 8bd
mov [bp-0x5a],ax
sub ax,ax
mov [bp-0x56],ax
mov [bp-0x58],ax
mov word [bp-0x54],HintClassName
mov [bp-0x52],ds
lea ax,[bp-0x6a]
push ss
push ax
call far USER.RegisterClass ; 8da
.end: ; 8df
pop si
endfunc
; 8e8
func CreateWindowsAndInitGame
sub sp,byte +0x16
push di
push si
%arg hInstance:word ; +6
%arg nCmdShow:word ; +8
mov si,[hInstance]
mov word [bp-0x6],(WS_CLIPCHILDREN | WS_TILEDWINDOW)&0xffff
mov word [bp-0x4],(WS_CLIPCHILDREN | WS_TILEDWINDOW)>>16
mov [MainInstance],si