-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththing.asm
1546 lines (1259 loc) · 37.5 KB
/
thing.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
;1099 - make draw sprites and update in loopidiloop 1 and 2 to check if there is sprite in spritemap
.686
.MODEL Flat,StdCall
OPTION CaseMap:None
.MMX
.XMM
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\Advapi32.inc
;include \masm32\include\masm32rt.inc
include \masm32\include\winmm.inc
include \masm32\include\comctl32.inc
;include \masm32\include\commctrl.inc
includelib \masm32\lib\winmm.lib
include \masm32\include\dialogs.inc ; macro file for dialogs
include \masm32\macros\macros.asm ; masm32 macro file
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\ole32.lib
includelib \masm32\lib\msvcrt.lib
include \masm32\include\msvcrt.inc
include \masm32\include\Ws2_32.inc
includelib \masm32\lib\Ws2_32.lib
include \masm32\include\ntoskrnl.inc
includelib \masm32\lib\ntoskrnl.lib
;include \masm32\include\win32k.inc
;includelib \masm32\lib\win32k.lib
.const
WINDOW_WIDTH equ 800
WINDOW_HEIGHT equ 600
MAIN_TIMER_ID equ 0
.data
xPos DWORD 0
ClassName DB "TheClass",0
windowTitle DB "ayy lmao",0
linewidth DWORD 2
TWOPI real4 6.283185307179586f
PI real4 3.141592653589793f
fov real4 1.0471975511965976f ; 60 * pi / 180
viewdist real4 692.820323027551
magicnum real4 0.001308996938995747 ; fov / 800 foreach x
globalfloatvar real4 ?
globalfloatvar2 real4 ?
efes75 real4 0.75
efes25 real4 0.25
sngMinusOneHalf REAL4 -0.5
pt POINT <0,0>
lastmousept POINT <0,0>
lasttime DWORD 0
timebetweenframes real4 0.0f ; 1000/60
middlemousept POINT <WINDOW_WIDTH/2,WINDOW_HEIGHT/2>
PLAYER STRUCT
x real4 16.0f
y real4 10.0f
dir DWORD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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DWORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DWORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DWORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DWORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DWORD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
mapWidth DWORD 32
mapHeight DWORD 24
SPRITE STRUCT
x DWORD 0
y DWORD 0
SPRITE ENDS
spritestodraw SPRITE 1000 dup (<0,0>)
heightsarr DWORD 800 dup(0)
spritestodrawlen DWORD 0
spritetodrawlen DWORD 9
lamp HBITMAP ?
wolftextures HBITMAP ?
lampstr DB "C:/FFOutput/lamp.bmp",0
.code
BUILDRECT PROC, x:DWORD, y:DWORD, w:DWORD, h:DWORD, hdc:HDC, brush:HBRUSH
LOCAL rectangle:RECT
mov eax, x
mov rectangle.left, eax
add eax, w
mov rectangle.right, eax
mov eax, y
mov rectangle.top, eax
add eax, h
mov rectangle.bottom, eax
invoke FillRect, hdc, addr rectangle, brush
ret
BUILDRECT ENDP
NewBrushColor PROC, color:DWORD, brush:DWORD ;BGR FORMAT
mov eax,color
push eax
invoke DeleteObject,[brush]
pop eax
invoke CreateSolidBrush,eax
ret
NewBrushColor ENDP
FLOOR PROC , floatvalue:real4
cvttss2si ebx, [floatvalue]
mov eax, [floatvalue]
shr eax, 31
sub ebx, eax
cvtsi2ss xmm0, ebx
ret
FLOOR ENDP
CEIL PROC , floatvalue:real4
;movss xmm0,FP4(1.0)
movss xmm0, floatvalue
addss xmm0, xmm0
movss xmm1, sngMinusOneHalf
subss xmm1, xmm0
cvtss2si eax, xmm1
sar eax, 1
neg eax
cvtsi2ss xmm0, eax
ret
CEIL ENDP
MODULUS PROC , nvalue:real4 , dvalue:real4
;int c=8, m=3, result=c-(c/m*m); result=2
LOCAL tempvalue:real4
COMMENT @
movss xmm1,cvalue
movss xmm0,mvalue
mulss xmm0,xmm0 ; m^m
divss xmm1,xmm0 ; xmm1 = c/m*m
movss xmm2,cvalue
subss xmm2,xmm1
movss xmm0,xmm2
@
movss xmm0,nvalue
divss xmm0,dvalue
movss tempvalue,xmm0
invoke FLOOR,tempvalue
movss xmm3,xmm0
movss xmm0,dvalue
mulss xmm0,xmm3
movss xmm1,nvalue
subss xmm1,xmm0
movss xmm0,xmm1
ret
MODULUS ENDP
DrawImage PROC, hdc:HDC, img:HBITMAP, x:DWORD, y:DWORD,x2:DWORD,y2:DWORD,w:DWORD,h:DWORD,wstrech:DWORD,hstrech:DWORD
;--------------------------------------------------------------------------------
local hdcMem:HDC
local HOld:HBITMAP
invoke CreateCompatibleDC, hdc
mov hdcMem, eax
invoke SelectObject, hdcMem, img
mov HOld, eax
invoke SetStretchBltMode,hdc,COLORONCOLOR
invoke StretchBlt ,hdc,x,y,wstrech,hstrech,hdcMem,x2,y2,w,h,SRCCOPY
invoke SelectObject,hdcMem,HOld
invoke DeleteDC,hdcMem
invoke DeleteObject,HOld
;================================================================================
ret
DrawImage ENDP
CONTAINSPOSITIONINSPRITES PROC, x:DWORD ,y:DWORD
local tempx:DWORD
local tempy:DWORD
mov ecx,0
startloopcontains:
cmp ecx,spritestodrawlen
je CONTAINSPOSITIONINSPRITESFALSE
pusha
mov eax,spritestodraw[ecx * SizeOf SPRITE].x
mov tempx ,eax
mov eax,spritestodraw[ecx * SizeOf SPRITE].y
mov tempy,eax
mov eax,tempx
cmp eax,x
jne ENDOFLOOPCONTAINS
mov eax,tempy
cmp eax,y
je CONTAINSPOSITIONINSPRITESTRUE
ENDOFLOOPCONTAINS:
popa
inc ecx
jmp startloopcontains
CONTAINSPOSITIONINSPRITESTRUE:
mov eax,1
ret
CONTAINSPOSITIONINSPRITESFALSE:
mov eax,0
ret
CONTAINSPOSITIONINSPRITES ENDP
DRAWSPRITES PROC , hdc:HDC
local spritex:DWORD
local spritey:DWORD
local distance:real4
local spriteangle:real4
local sprxonscreen:real4
local spryonscreen:real4
local tempravrriable:real4
local dxx:real4
local dyy:real4
local sprxscreen:DWORD
local spryscreen:DWORD
local sizeofspr:real4
local sizeofsprfloor:DWORD
local finalxonscreen:DWORD
local finalimgwidth:DWORD
local finalwidthsize:DWORD
local finalxposontexture:DWORD
local mathmaxx:DWORD
mov eax,spritetodrawlen
mov ecx,0
loopspritestobedrawndraw:
cmp ecx,spritestodrawlen
je endloopspritestobedrawndraw
pusha
mov eax,spritestodraw[ecx * SizeOf SPRITE].x
mov spritex,eax
mov eax,spritestodraw[ecx * SizeOf SPRITE].y
mov spritey,eax
mov ebx,spritex
cvtsi2ss xmm0,ebx
subss xmm0,Player.x
mov ebx,spritey
cvtsi2ss xmm1,ebx
subss xmm1,Player.y
addss xmm0,FP4(0.5f)
addss xmm1,FP4(0.5f)
movss dxx,xmm0
movss dyy,xmm1
mulss xmm0,xmm0
mulss xmm1,xmm1
addss xmm0,xmm1
movss tempravrriable,xmm0
FLD tempravrriable
fsqrt
fstp distance
FLD dyy
fld dxx
fpatan
fstp tempravrriable
movss xmm0,tempravrriable
subss xmm0,Player.rot
movss spriteangle,xmm0
fld spriteangle
fsincos
fdiv
fstp tempravrriable
movss xmm0,tempravrriable
mulss xmm0,viewdist
movss sprxonscreen,xmm0
movss xmm0,spriteangle
movss tempravrriable,xmm0
fld tempravrriable
fcos
fstp tempravrriable
movss xmm0,tempravrriable
mulss xmm0,distance
movss xmm1,viewdist
divss xmm1,xmm0 ; viewdist / (cos(spriteangle) * distance)
movss sizeofspr,xmm1
movss xmm0,FP4(600.0f) ;WINDOW_HEIGHT
subss xmm0,sizeofspr
divss xmm0,FP4(2.0f)
movss spryonscreen,xmm0
movss xmm0,FP4(400.0f);WINDOW_WIDTH / 2
addss xmm0,sprxonscreen
movss xmm1,sizeofspr
divss xmm1,FP4(2.0f)
subss xmm0,xmm1 ; xmm0=(WINDOW_WIDTH / 2 + x - sizeofspr/2)
movss sprxonscreen,xmm0
invoke FLOOR,sizeofspr
cvtss2si eax, xmm0
mov sizeofsprfloor,eax
movss xmm0,sprxonscreen
movss tempravrriable,xmm0
invoke FLOOR, tempravrriable
cvtss2si eax, xmm0
mov sprxscreen,eax
movss xmm0,spryonscreen
movss tempravrriable,xmm0
invoke FLOOR, tempravrriable
cvtss2si eax, xmm0
mov spryscreen,eax
movss xmm0,sprxonscreen
comiss xmm0,FP4(0.0f)
jb xlowerthan0
mov eax,sprxscreen
mov mathmaxx,eax
jmp aftermathmaxcheck
xlowerthan0:
mov mathmaxx,0
aftermathmaxcheck:
mov ecx,mathmaxx
imul ecx,TYPE DWORD
mov eax,heightsarr[ecx]
cmp eax,sizeofsprfloor
jg morestufftocheck
jmp lesssufftocheck
morestufftocheck:
mov ecx,0
loopofmorstufftocheck:
cmp ecx,64
je justbeforedrawsprite
mov ebx,ecx
add ebx,mathmaxx
imul ebx,TYPE DWORD
mov eax,heightsarr[ebx]
cmp eax,sizeofsprfloor
jge endofloopmorestufftocheck
mov ebx,sprxscreen
add ebx,ecx
mov finalxonscreen,ebx
mov finalxposontexture,ecx
mov ebx,sizeofsprfloor
mov finalwidthsize,ebx
mov finalimgwidth,64
jmp justbeforedrawsprite
endofloopmorestufftocheck:
inc ecx
jmp loopofmorstufftocheck
jmp justbeforedrawsprite
lesssufftocheck:
mov ecx,0
lesssufftocheckloop:
cmp ecx,64
je lesssufftocheckendloop
mov ebx,ecx
add ebx,mathmaxx
imul ebx,TYPE DWORD
mov eax,heightsarr[ebx]
cmp eax,sizeofsprfloor
jg lesssufftocheckendloop
inc ecx
jmp lesssufftocheckloop
lesssufftocheckendloop:
cmp ecx,64
je everyfinisverynice
jmp fuckthissprite
everyfinisverynice:
mov finalimgwidth,64
mov ebx,sizeofsprfloor
mov finalwidthsize,ebx
mov ebx,sprxscreen
mov finalxonscreen,ebx
mov finalxposontexture,0
jmp justbeforedrawsprite
fuckthissprite:
mov finalimgwidth,ecx
mov finalwidthsize,ecx
mov ebx,sprxscreen
mov finalxonscreen,ebx
mov finalxposontexture,0
justbeforedrawsprite:
invoke DrawImage,hdc,lamp,finalxonscreen,spryscreen,finalxposontexture,0,finalimgwidth,64,finalwidthsize,sizeofsprfloor
afterdrawsprite:
popa
inc ecx
jmp loopspritestobedrawndraw
endloopspritestobedrawndraw:
ret
DRAWSPRITES ENDP
ISBLOCKING PROC , xvalue:real4 , yvalue:real4
local temporary:real4
local floorx:DWORD
local floory:DWORD
movss xmm0,xvalue
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb isblockfuncret0
mov ebx,mapWidth
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae isblockfuncret0
movss xmm0,yvalue
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb isblockfuncret0
mov ebx,mapHeight
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae isblockfuncret0
movss xmm0,xvalue
movss temporary,xmm0
invoke FLOOR,temporary
cvtss2si eax, xmm0
mov floorx,eax
movss xmm0,yvalue
movss temporary,xmm0
invoke FLOOR,temporary
cvtss2si eax, xmm0
mov floory,eax
mov ecx,floory
imul ecx,mapWidth
add ecx,floorx
imul ecx,type DWORD
mov edx,MAP[ecx]
cmp edx,0
je isblockfuncret0
isblockfuncret1:
mov eax,1
ret
isblockfuncret0:
mov eax,0
ret
ISBLOCKING ENDP
castRay PROC, rayangle:real4 , screenpos:DWORD , hdc:HDC , localbrush:HBRUSH
local right:DWORD
local up:DWORD
local angleSin:real4
local angleCos:real4
local dist:real4
local distchanged:DWORD
local wallX:DWORD
local wallY:DWORD
local height:DWORD
local slope:real4
local horizontal:DWORD
local dXVer:real4
local dYVer:real4
local dYHor:real4
local dXHor:real4
local x:real4
local y:real4
local tempvarr:real4
local tempvarr1:real4
local posinspritearr:DWORD
local todraw:DWORD
local typeofwall:DWORD
local floatingpoint:real4
local finaltexturex:DWORD
local screenypos:DWORD
local xHit:DWORD
local yHit:DWORD
mov right,0
mov up,0
mov horizontal,0
mov todraw,1
mov eax,spritestodrawlen
mov posinspritearr,eax
mov typeofwall,0
mov xHit,0
mov yHit,0
mov ebx,0
cvtsi2ss xmm0,ebx
movss dist,xmm0
;int c=8, m=3, result=c-(c/m*m); result=2
movss xmm0,rayangle
movss xmm1,TWOPI
movss tempvarr,xmm0
movss tempvarr1,xmm1
invoke MODULUS,tempvarr,tempvarr1
movss rayangle,xmm0
movss tempvarr,xmm0
movss tempvarr1,xmm1
modulusangle: ; xmm0=angle ,xmm1=pi * 2
ucomiss xmm0,xmm1
jge endmodulusangle
subss xmm0,xmm1
jmp modulusangle
endmodulusangle:
movss rayangle,xmm0
movss xmm0,rayangle
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1 ; xmm0=rayangle , xmm1=0
ja notneeded
addss xmm0,TWOPI
movss rayangle,xmm0
notneeded:
movss xmm1,TWOPI
movss xmm2,efes75
mulss xmm1,xmm2 ; xmm1 = TWOPI * 0.75
rightcheck:
movss xmm0,rayangle
comiss xmm0,xmm1 ;xmm0=angle ,TWOPI * 0.75
jbe rightcheck2
mov right,1
jmp afterrightcheck
rightcheck2:
movss xmm1,TWOPI
movss xmm2,efes25
mulss xmm1,xmm2 ; xmm1=TWOPI * 0.25
comiss xmm0,xmm1 ;xmm0=angle ,TWOPI * 0.25
ja afterrightcheck
mov right,1
afterrightcheck:
upcheck:
movss xmm0,rayangle
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1 ; xmm0=rayangle , xmm1=0
ja upcheck2
mov up,1
jmp afterupcheck
upcheck2:
movss xmm1,PI
comiss xmm0,xmm1
jb afterupcheck
mov up,1
afterupcheck:
;movss xmm0,rayangle
FLD rayangle
fcos
FSTP angleCos
FLD rayangle
fsin
FSTP angleSin
movss xmm0,angleSin
divss xmm0,angleCos
;divss xmm0,xmm1
movss slope,xmm0
mov eax,right
cmp eax,0
je thing1
mov ebx,1
cvtsi2ss xmm0,ebx
movss dXVer,xmm0
jmp afterthing1
thing1:
mov ebx,-1
cvtsi2ss xmm0,ebx
movss dXVer,xmm0
afterthing1:
movss xmm0,dXVer
movss xmm1,slope
mulss xmm0,xmm1
movss dYVer,xmm0
;checking right
mov eax,right
cmp eax,0
jne isrightayy
movss xmm0,Player.x
movss tempvarr,xmm0
invoke FLOOR ,tempvarr
movss x,xmm0
jmp jumpafterrightcheckingthing
isrightayy:
movss xmm0,Player.x
movss tempvarr,xmm0
invoke CEIL ,tempvarr
movss x,xmm0
jumpafterrightcheckingthing:
movss xmm0,x
subss xmm0,Player.x
mulss xmm0,slope
addss xmm0,Player.y
movss y,xmm0
loopidiloop1:
movss xmm0,x
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb endloopidiloop1
mov ebx,mapWidth
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae endloopidiloop1
movss xmm0,y
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb endloopidiloop1
mov ebx,mapHeight
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae endloopidiloop1
movss xmm0,x
mov ebx,0
mov eax,right
cmp eax,0
jne afterchangewallx ; right = 1
mov ebx,-1
cvtsi2ss xmm2,ebx
addss xmm0,xmm2
afterchangewallx:
movss tempvarr,xmm0
invoke FLOOR ,tempvarr
cvtss2si eax, xmm0
mov wallX,eax
movss xmm1,y
movss tempvarr,xmm1
invoke FLOOR ,tempvarr
cvtss2si eax, xmm0
mov wallY,eax
mov eax,wallX
mov ebx,wallY
;eax = round x
;ebx = round y
mov ecx,ebx
imul ecx,mapWidth
add ecx,eax
imul ecx,type DWORD
pusha
mov edx,SPRITEMAP[ecx]
cmp edx,0
je endofspriteadding1
invoke CONTAINSPOSITIONINSPRITES,wallX,wallY
cmp eax,0
jne endofspriteadding1
mov ebx,posinspritearr
mov eax,wallX
mov spritestodraw[ebx * SizeOf SPRITE].x,eax
mov eax,wallY
mov spritestodraw[ebx * SizeOf SPRITE].y,eax
inc posinspritearr
endofspriteadding1:
popa
mov edx,MAP[ecx]
mov typeofwall,edx
cmp edx,0
jne ayylmao1
jmp after
ayylmao1:
;mov typeofwall,edx
movss xmm0,x
movss xmm1,y
subss xmm0,Player.x
subss xmm1,Player.y
mulss xmm0,xmm0
mulss xmm1,xmm1
addss xmm0,xmm1;xmm0=new found dist
movss dist,xmm0 ; dist squared
mov distchanged,1
movss xmm0,y
movss globalfloatvar,xmm0
movss xmm1,FP4(1.0f)
movss globalfloatvar2,xmm1
invoke MODULUS ,globalfloatvar,globalfloatvar2
movss floatingpoint,xmm0
mov ebx,right
cmp ebx,1
je afterrightchecktexture
movss xmm1,FP4(1.0f)
movss xmm0,floatingpoint
subss xmm1,xmm0
movss floatingpoint,xmm1
afterrightchecktexture:
mov eax,wallX
mov ebx,wallY
;eax = round x
;ebx = round y
mov ecx,ebx
imul ecx,mapWidth
add ecx,eax
imul ecx,type DWORD
mov edx ,MAP[ecx]
mov typeofwall,edx
mov eax,wallX
mov xHit,eax
mov eax,wallY
mov yHit,eax
jmp endloopidiloop1
after:
movss xmm0,dXVer
addss xmm0,x
movss x,xmm0
movss xmm0,dYVer
addss xmm0,y
movss y,xmm0
jmp loopidiloop1
endloopidiloop1:
movss xmm0,angleCos
divss xmm0,angleSin
;divss xmm0,xmm1
movss slope,xmm0
mov eax,up
cmp eax,0
je isnotup
mov ebx,-1
cvtsi2ss xmm0,ebx
movss dYHor,xmm0
mulss xmm0,slope
movss dXHor,xmm0
jmp afterupping
isnotup:
mov ebx,1
cvtsi2ss xmm0,ebx
movss dYHor,xmm0
mulss xmm0,slope
movss dXHor,xmm0
afterupping:
mov eax,up
cmp eax,0
jne isuppayy
movss xmm0,Player.y
movss tempvarr,xmm0
invoke CEIL ,tempvarr
movss y,xmm0
jmp jumpafterupcheckingthing
isuppayy:
movss xmm0,Player.y
movss tempvarr,xmm0
invoke FLOOR ,tempvarr
movss y,xmm0
jumpafterupcheckingthing:
movss xmm1,y
subss xmm1,Player.y
mulss xmm1,slope
addss xmm1,Player.x
movss x,xmm1
loopidiloop2:
movss xmm0,x
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb endloopidiloop2
mov ebx,mapWidth
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae endloopidiloop2
movss xmm0,y
mov ebx,0
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jb endloopidiloop2
mov ebx,mapHeight
cvtsi2ss xmm1,ebx
comiss xmm0,xmm1
jae endloopidiloop2
mov ebx,0
movss xmm0,y
mov eax,up
cmp eax,0
je afterupcheckk
mov ebx,-1
afterupcheckk:
cvtsi2ss xmm1,ebx
addss xmm0,xmm1 ; y + up
movss tempvarr,xmm0
invoke FLOOR , tempvarr
cvtss2si eax, xmm0
mov wallY,eax
movss xmm0,x
movss tempvarr,xmm0
invoke FLOOR , tempvarr
cvtss2si eax, xmm0
mov wallX,eax
mov ecx,wallY
imul ecx,mapWidth
add ecx,wallX
imul ecx,type DWORD
pusha
mov edx,SPRITEMAP[ecx]
cmp edx,0
je endofspriteadding2
invoke CONTAINSPOSITIONINSPRITES,wallX,wallY
cmp eax,0
jne endofspriteadding2
mov ebx,posinspritearr
mov eax,wallX
mov spritestodraw[ebx * SizeOf SPRITE].x,eax
mov eax,wallY
mov spritestodraw[ebx * SizeOf SPRITE].y,eax
inc posinspritearr
endofspriteadding2:
popa
mov edx,MAP[ecx]
cmp edx,0
jne ayylmao2