⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frustum.asm

📁 游戏编程精粹2第四章源码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
_DATA	ENDS
;	COMDAT __CTA3?AVout_of_range@std@@
xdata$x	SEGMENT DWORD USE32 PUBLIC 'CONST'
xdata$x	ENDS
FLAT	GROUP _DATA, CONST, _BSS, CRT$XCA, CRT$XCU, CRT$XCL, CRT$XCC, CRT$XCZ, xdata$x
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif
CRT$XCU	SEGMENT
_$S18	DD	FLAT:_$E17
_$S24	DD	FLAT:_$E23
_$S31	DD	FLAT:_$E30
CRT$XCU	ENDS
PUBLIC	?Set@Frustum@@QAEXHHHH@Z			; Frustum::Set
_TEXT	SEGMENT
_x1$ = 8
_y1$ = 12
_x2$ = 16
_y2$ = 20
?Set@Frustum@@QAEXHHHH@Z PROC NEAR			; Frustum::Set

; 18   : {

	push	ebp
	mov	ebp, esp

; 19   :   mX1 = x1;

	mov	eax, DWORD PTR _x1$[ebp]

; 20   :   mY1 = y1;

	mov	edx, DWORD PTR _y1$[ebp]
	mov	DWORD PTR [ecx], eax

; 21   :   mX2 = x2;

	mov	eax, DWORD PTR _x2$[ebp]
	mov	DWORD PTR [ecx+8], edx

; 22   :   mY2 = y2;

	mov	edx, DWORD PTR _y2$[ebp]
	mov	DWORD PTR [ecx+4], eax
	mov	DWORD PTR [ecx+12], edx

; 23   : }

	pop	ebp
	ret	16					; 00000010H
?Set@Frustum@@QAEXHHHH@Z ENDP				; Frustum::Set
_TEXT	ENDS
PUBLIC	?ViewVolumeTest@Frustum@@QBE?AW4ViewState@@ABV?$Vector3d@M@@M@Z ; Frustum::ViewVolumeTest
_TEXT	SEGMENT
_center$ = 8
_radius$ = 12
_acode$ = -16
_ocode$ = 8
_x$ = -12
_y$ = -20
?ViewVolumeTest@Frustum@@QBE?AW4ViewState@@ABV?$Vector3d@M@@M@Z PROC NEAR ; Frustum::ViewVolumeTest

; 27   : {

	push	ebp
	mov	ebp, esp
	sub	esp, 28					; 0000001cH

; 28   :   int acode = 0xFFFFFF;
; 29   :   int ocode = 0;
; 30   : 
; 31   :   int x = int(center.x);

	mov	eax, DWORD PTR _center$[ebp]
	push	esi
	push	edi

; 32   :   int y = int(center.y);
; 33   :   int r = int(radius);
; 34   : 
; 35   :   ViewCode(x-r,y-r,acode,ocode);

	mov	edi, DWORD PTR [ecx]
	fld	DWORD PTR [eax]
	fistp	QWORD PTR -28+[ebp]
	mov	esi, DWORD PTR -28+[ebp]
	mov	DWORD PTR _x$[ebp], esi
	fld	DWORD PTR [eax+4]
	fistp	QWORD PTR -28+[ebp]
	mov	eax, DWORD PTR -28+[ebp]
	mov	DWORD PTR _y$[ebp], eax
	fld	DWORD PTR _radius$[ebp]
	fistp	QWORD PTR -28+[ebp]
	mov	edx, DWORD PTR -28+[ebp]
	sub	eax, edx
	sub	esi, edx
	mov	DWORD PTR 8+[ebp], eax
	xor	eax, eax
	cmp	esi, edi
	mov	DWORD PTR -24+[ebp], esi
	jge	SHORT $L13635
	mov	eax, 1
$L13635:
	push	ebx
	mov	ebx, DWORD PTR [ecx+4]
	cmp	esi, ebx
	mov	DWORD PTR 12+[ebp], ebx
	jle	SHORT $L13636
	or	al, 2
$L13636:
	mov	esi, DWORD PTR [ecx+8]
	mov	ebx, DWORD PTR 8+[ebp]
	cmp	ebx, esi
	mov	DWORD PTR -4+[ebp], esi
	jge	SHORT $L13637
	or	al, 4
$L13637:
	mov	ecx, DWORD PTR [ecx+12]
	cmp	ebx, ecx
	mov	DWORD PTR -8+[ebp], ecx
	jle	SHORT $L13638
	or	al, 8
$L13638:
	mov	DWORD PTR _ocode$[ebp], eax
	and	eax, 16777215				; 00ffffffH
	mov	DWORD PTR _acode$[ebp], eax

; 36   :   ViewCode(x+r,y-r,acode,ocode);

	mov	eax, DWORD PTR _x$[ebp]
	xor	ecx, ecx
	lea	esi, DWORD PTR [edx+eax]
	cmp	esi, edi
	jge	SHORT $L13645
	mov	ecx, 1
$L13645:
	cmp	esi, DWORD PTR 12+[ebp]
	jle	SHORT $L13646
	or	ecx, 2
$L13646:
	cmp	ebx, DWORD PTR -4+[ebp]
	jge	SHORT $L13647
	or	ecx, 4
$L13647:
	cmp	ebx, DWORD PTR -8+[ebp]
	jle	SHORT $L13648
	or	ecx, 8
$L13648:
	mov	ebx, DWORD PTR _ocode$[ebp]
	or	ebx, ecx
	mov	DWORD PTR _ocode$[ebp], ebx
	mov	ebx, DWORD PTR _acode$[ebp]
	and	ebx, ecx

; 37   :   ViewCode(x+r,y+r,acode,ocode);

	mov	ecx, DWORD PTR _y$[ebp]
	add	edx, ecx
	xor	ecx, ecx
	cmp	esi, edi
	jge	SHORT $L13655
	mov	ecx, 1
$L13655:
	cmp	esi, DWORD PTR 12+[ebp]
	jle	SHORT $L13656
	or	ecx, 2
$L13656:
	cmp	edx, DWORD PTR -4+[ebp]
	jge	SHORT $L13657
	or	ecx, 4
$L13657:
	cmp	edx, DWORD PTR -8+[ebp]
	jle	SHORT $L13658
	or	ecx, 8
$L13658:
	mov	esi, DWORD PTR _ocode$[ebp]
	and	ebx, ecx
	or	esi, ecx

; 38   :   ViewCode(x-r,y+r,acode,ocode);

	mov	ecx, DWORD PTR -24+[ebp]
	xor	eax, eax
	cmp	ecx, edi
	jge	SHORT $L13665
	mov	eax, 1
$L13665:
	cmp	ecx, DWORD PTR 12+[ebp]
	jle	SHORT $L13666
	or	al, 2
$L13666:
	cmp	edx, DWORD PTR -4+[ebp]
	jge	SHORT $L13667
	or	al, 4
$L13667:
	cmp	edx, DWORD PTR -8+[ebp]
	jle	SHORT $L13668
	or	al, 8
$L13668:
	test	eax, ebx
	pop	ebx

; 39   : 
; 40   :   if ( acode ) return VS_OUTSIDE;

	je	SHORT $L12103
	pop	edi
	mov	eax, 2
	pop	esi

; 42   : 
; 43   :   return VS_INSIDE;
; 44   : }

	mov	esp, ebp
	pop	ebp
	ret	8
$L12103:

; 38   :   ViewCode(x-r,y+r,acode,ocode);

	or	eax, esi
	pop	edi

; 41   :   if ( ocode ) return VS_PARTIAL;

	neg	eax
	sbb	eax, eax
	pop	esi
	neg	eax

; 42   : 
; 43   :   return VS_INSIDE;
; 44   : }

	mov	esp, ebp
	pop	ebp
	ret	8
?ViewVolumeTest@Frustum@@QBE?AW4ViewState@@ABV?$Vector3d@M@@M@Z ENDP ; Frustum::ViewVolumeTest
_TEXT	ENDS
PUBLIC	?ViewCode@Frustum@@ABEXHHAAH0@Z			; Frustum::ViewCode
_TEXT	SEGMENT
_x$ = 8
_y$ = 12
_acode$ = 16
_ocode$ = 20
?ViewCode@Frustum@@ABEXHHAAH0@Z PROC NEAR		; Frustum::ViewCode

; 48   : {

	push	ebp
	mov	ebp, esp

; 49   :   int code = 0;
; 50   :   if ( x < mX1 ) code|=CS_LEFT;

	mov	edx, DWORD PTR _x$[ebp]
	push	esi
	mov	esi, DWORD PTR [ecx]
	xor	eax, eax
	cmp	edx, esi
	jge	SHORT $L12113
	mov	eax, 1
$L12113:

; 51   :   if ( x > mX2 ) code|=CS_RIGHT;

	cmp	edx, DWORD PTR [ecx+4]
	jle	SHORT $L12114
	or	al, 2
$L12114:

; 52   :   if ( y < mY1 ) code|=CS_TOP;

	mov	edx, DWORD PTR _y$[ebp]
	mov	esi, DWORD PTR [ecx+8]
	cmp	edx, esi
	jge	SHORT $L12115
	or	al, 4
$L12115:

; 53   :   if ( y > mY2 ) code|=CS_BOTTOM;

	cmp	edx, DWORD PTR [ecx+12]
	jle	SHORT $L13678
	or	al, 8
$L13678:

; 54   :   ocode|=code;

	mov	ecx, DWORD PTR _ocode$[ebp]
	mov	esi, DWORD PTR [ecx]
	or	esi, eax
	mov	DWORD PTR [ecx], esi

; 55   :   acode&=code;

	mov	ecx, DWORD PTR _acode$[ebp]
	pop	esi
	and	DWORD PTR [ecx], eax

; 56   : }

	pop	ebp
	ret	16					; 00000010H
?ViewCode@Frustum@@ABEXHHAAH0@Z ENDP			; Frustum::ViewCode
_TEXT	ENDS
PUBLIC	?id@?$ctype@G@std@@$E				; std::ctype<unsigned short>::id
EXTRN	_atexit:NEAR
_DATA	SEGMENT
COMM	??_B?1???id@?$ctype@G@std@@$D@@9@51:BYTE							; std::ctype<unsigned short>::d::`local static guard'
_DATA	ENDS
_TEXT	SEGMENT
_$E30	PROC NEAR
	mov	cl, BYTE PTR ??_B?1???id@?$ctype@G@std@@$D@@9@51 ; std::ctype<unsigned short>::d::`local static guard'
	mov	al, 1
	test	cl, al
	jne	SHORT $L13683
	or	cl, al
	mov	BYTE PTR ??_B?1???id@?$ctype@G@std@@$D@@9@51, cl ; std::ctype<unsigned short>::d::`local static guard'
$L13683:
	push	OFFSET FLAT:?id@?$ctype@G@std@@$E	; std::ctype<unsigned short>::id
	call	_atexit
	pop	ecx
	ret	0
_$E30	ENDP
_TEXT	ENDS
;	COMDAT ?id@?$ctype@G@std@@$E
_TEXT	SEGMENT
?id@?$ctype@G@std@@$E PROC NEAR				; std::ctype<unsigned short>::id, COMDAT
	ret	0
?id@?$ctype@G@std@@$E ENDP				; std::ctype<unsigned short>::id
_TEXT	ENDS
EXTRN	??0Init@ios_base@std@@QAE@XZ:NEAR		; std::ios_base::Init::Init
_BSS	SEGMENT
__Ios_init DB	01H DUP (?)
_BSS	ENDS
_TEXT	SEGMENT
_$E17	PROC NEAR
	mov	ecx, OFFSET FLAT:__Ios_init
	call	??0Init@ios_base@std@@QAE@XZ		; std::ios_base::Init::Init
	push	OFFSET FLAT:_$E15
	call	_atexit
	pop	ecx
	ret	0
_$E17	ENDP
_TEXT	ENDS
EXTRN	??1Init@ios_base@std@@QAE@XZ:NEAR		; std::ios_base::Init::~Init
_TEXT	SEGMENT
_$E15	PROC NEAR
	mov	ecx, OFFSET FLAT:__Ios_init
	jmp	??1Init@ios_base@std@@QAE@XZ		; std::ios_base::Init::~Init
_$E15	ENDP
_TEXT	ENDS
EXTRN	??0_Winit@std@@QAE@XZ:NEAR			; std::_Winit::_Winit
_BSS	SEGMENT
	ALIGN	4

__Wios_init DB	01H DUP (?)
_BSS	ENDS
_TEXT	SEGMENT
_$E23	PROC NEAR
	mov	ecx, OFFSET FLAT:__Wios_init
	call	??0_Winit@std@@QAE@XZ			; std::_Winit::_Winit
	push	OFFSET FLAT:_$E21
	call	_atexit
	pop	ecx
	ret	0
_$E23	ENDP
_TEXT	ENDS
EXTRN	??1_Winit@std@@QAE@XZ:NEAR			; std::_Winit::~_Winit
_TEXT	SEGMENT
_$E21	PROC NEAR
	mov	ecx, OFFSET FLAT:__Wios_init
	jmp	??1_Winit@std@@QAE@XZ			; std::_Winit::~_Winit
_$E21	ENDP
_TEXT	ENDS
END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -