Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .686P
- .XMM
- .model flat, stdcall
- option casemap:none
- ;//===============================================================================================
- ;// Setup
- ;//===============================================================================================
- XRES equ 1024
- YRES equ 1024
- DC_ITERATIONS equ 20
- LOCALVAR_SPACE equ 24
- ;//===============================================================================================
- ;// Includes and externs
- ;//===============================================================================================
- include windows.inc
- include kernel32.inc
- ;// extrn _imp__ExitProcess@4:PROC
- ;// extrn _imp__DestroyWindow@4:PROC
- extrn _imp__GetAsyncKeyState@4:PROC
- extrn _imp__CreateWindowExA@48:PROC
- extrn Direct3DCreate9@4:PROC
- ;// extrn D3DXVec2Hermite@24:PROC
- ;//===============================================================================================
- ;// Teh marco definitns
- ;//===============================================================================================
- dcEnd macro a
- db 000h
- endm
- dcRotate macro a
- db 020h or ( a and 01fh )
- endm
- dcIncrease macro z
- db 040h or ( a and 01fh )
- endm
- dcReduce macro z
- db 060h or ( a and 01fh )
- endm
- dcDisplace macro x, y
- db 080h or ( x / 4 )
- db ( ( x and 003h ) * 64 ) or y
- endm
- dcVertex macro x, y
- db 0a0h or ( x / 4 )
- db ( ( x and 003h ) * 64 ) or y
- endm
- dcTangent macro x, y
- db 0b0h or ( x / 4 )
- db ( ( x and 003h ) * 64 ) or y
- endm
- dcARGB macro a, r, g, b
- db 0c0h or ( a * 16 ) or r
- db ( g * 16 ) or b
- endm
- dcRender macro
- db 0e0h
- endm
- dcClearStack macro
- db 0e1h
- endm
- dcOutline macro
- db 0e2h
- endm
- ;//===============================================================================================
- ;// Data
- ;//===============================================================================================
- public __fltused
- _BSS segment
- vertexStack dd 10000 * 5 dup ( ? )
- faces dd 1024 dup ( ? )
- _BSS ends
- _DATA segment
- vv:
- d3dDevice dd ?
- __fltused dd ?
- currentVertex dd ?
- renderVertex dd ?
- s0x dd ?
- s0y dd ?
- s0z dd ?
- s0argb dd ?
- s1x dd ?
- s1y dd ?
- s1z dd ?
- currentCol:
- currentColI:
- s1argb dd ?
- v0Pre dd ?
- v0x dd ?
- v0y dd ?
- t0x dd ?
- t0y dd ?
- currentColID:
- v1Pre dd ?
- v1x dd ?
- v1y dd ?
- t1x dd ?
- t1y dd ?
- scaleProduct dd 0
- scaleMatrix dd 0, 0, 0, 0
- dd 0, 0, 0, 0
- dd 0, 0
- ;//dd 03f800000h, 0
- ;//dd 0, 0, 0, 03f800000h
- translateMatrix dd 03f800000h, 0, 0, 0
- dd 0, 03f800000h, 0, 0
- dd 0, 0, 03f800000h, 0
- dd 0, 0, 0, 03f800000h
- rotateMatrix dd 0, 0, 0, 0
- dd 0, 0, 0, 0
- dd 0, 0
- ;//dd 03f800000h, 0
- ;//dd 0, 0, 0, 03f800000h
- identityMatrix dd 03f800000h, 0, 0, 0
- dd 0, 03f800000h, 0, 0
- dd 0, 0, 03f800000h, 0
- dd 0, 0, 0
- ;//dd 03f800000h
- quadVerts dd 03f800000h ;// 1
- dd 0bf800000h ;// -1
- dd 000000000h ;// 0
- dd 03f800000h ;// 1
- dd 000000000h ;// 0
- dd 0bf800000h ;// -1
- dd 0bf800000h ;// -1
- dd 000000000h ;// 0
- dd 000000000h ;// 0
- dd 000000000h ;// 0
- dd 03f800000h ;// 1
- dd 03f800000h ;// 1
- dd 000000000h ;// 0
- dd 03f800000h ;// 1
- dd 03f800000h ;// 1
- dd 0bf800000h ;// -1
- dd 03f800000h ;// 1
- dd 000000000h ;// 0
- dd 000000000h ;// 0
- dd 03f800000h ;// 1
- devParams dd XRES
- dd YRES
- dd 15h
- dd 0
- dd 0
- dd 0
- dd 1
- dd 0
- dd 1
- dd 0
- dd 0
- dd 0
- dd 0
- dd 1
- ;// DC data
- dcData:
- dcVertex 0, 0
- dcARGB 0, 15, 15, 15
- dcVertex 57, 20
- dcARGB 1, 15, 15, 15
- dcTangent 32, 43
- dcVertex 32, 30
- dcARGB 1, 3, 5, 15
- dcTangent 0, 63
- dcVertex 0, 0
- dcARGB 0, 15, 0, 15
- dcOutline
- rept 8
- dcRotate 8
- dcOutline
- endm
- dcRender
- dcEnd
- ;// DC data must be followed by at least 3 readable bytes (read but ignored)
- ;// Window
- textStatic db "static", 0
- ;// x86 sucks
- fpuSave db 128 dup ( ? )
- _DATA ends
- _TEXT segment
- ;//===============================================================================================
- ;// Entry point
- ;//===============================================================================================
- Start:
- mov ebp, offset vv
- ;// Create D3D object
- push 32
- call Direct3DCreate9@4
- push eax ;// Save device
- ;// Create window
- push 0
- push 0
- push 0
- push 0
- push YRES
- push XRES
- push 0
- push 0
- push 090000000h
- push 0
- push offset textStatic
- push 0
- call dword ptr _imp__CreateWindowExA@48
- ;// Create D3D device
- pop esi ;// D3D object
- push ebp ;// &d3dDevice
- push offset devParams
- push 00000040h ;// D3DCREATE_HARDWARE_VERTEXPROCESSING
- push eax ;// window
- push 1 ;// D3DDEVTYPE_HAL
- push 0 ;// D3DADAPTER_DEFAULT = 0
- mov dword ptr devParams + 28, eax ;// window
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 64 ] ;// CreateDevice
- ;// Set some states
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push 2 ;// D3DTEXF_LINEAR
- push 5 ;// D3DSAMP_MAGFILTER
- push 0
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 276 ] ;// SetSamplerState
- push 2 ;// D3DTEXF_LINEAR
- push 6 ;// D3DSAMP_MINFILTER
- push 0
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 276 ] ;// SetSamplerState
- ;// Generate textures
- mov eax, offset dcData
- mov edx, 1024
- call renderDC
- mov dword ptr [ faces ], ebx
- ;// Teh main loop
- waitLoop:
- call renderFrame
- push 27 ;// VK_ESCAPE
- call dword ptr _imp__GetAsyncKeyState@4
- test eax, eax
- je short waitLoop
- ;// Release D3D device
- ;// mov esi, DWORD PTR [ ebp + ( d3d - vv ) ]
- ;// push esi
- ;// mov eax, [ esi ]
- ;// call dword ptr [ eax + 8 ] ;// Release
- ;// jmp dword ptr _imp__ExitProcess@4
- ret
- ;//===============================================================================================
- ;// Render an frame
- ;//===============================================================================================
- ;// At entry - ebp = vv, eax = 0
- renderFrame:
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 164 ] ;// BeginScene
- push 0 ;// For Present
- push 0
- push 0
- push 0
- ;// Clear frame
- push 0
- push 03f800000h
- push 0 ;// Background col
- push 1 ;// D3DCLEAR_TARGET
- push 0
- push 0
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 172 ] ;// Clear
- ;// mov ebx, offset dcData
- ;// mov edx, 200
- ;// call dcLocalConstraints
- ;// Set texture
- push dword ptr [ faces ]
- push 0
- push esi
- mov eax, dword ptr [ esi ]
- call dword ptr [ eax + 260 ] ;// SetTexture
- ;// Set some states
- push 5 ;// D3DBLEND_SRCALPHA
- push 19 ;// D3DRS_SRCBLEND
- push esi
- mov eax, dword ptr [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- push 6 ;// D3DBLEND_INVSRCALPHA
- push 20 ;// D3DRS_DESTBLEND
- push esi
- mov eax, dword ptr [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- ;// Draw quad
- push 258 ;// D3DFVF_XYZ | D3DFVF_TEX1
- push esi
- mov eax, dword ptr [ esi ]
- call dword ptr [ eax + 356 ] ;// SetFVF
- lea eax, dword ptr [ ebp + ( quadVerts - vv ) ]
- push 20 ;// Vertex size
- push eax ;// Vertices
- push 2 ;// No. primitives
- push 5 ;// D3DPT_TRIANGLESTRIP
- push esi
- mov eax, dword ptr [ esi ]
- call dword ptr [ eax + 332 ] ;// DrawPrimitiveUP
- ;// End scene
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 168 ] ;// EndScene
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 68 ] ;// Present
- ret
- ;//===============================================================================================
- ;// Generate DC texture
- ;//
- ;// ebp - vv
- ;// edx - size
- ;// eax - texture code
- ;//
- ;// Returns texture in ebx, end of code in eax, texture surface in ecx
- ;//===============================================================================================
- sizeCopy equ -4
- codeCopy equ -8
- currentTexture equ -12
- currentSurface equ -16
- oldSurface equ -20
- lesserSurface equ -24
- renderDC:
- push edx ;// size
- push eax ;// code, size
- ;// Create texture
- push eax ;// ?, code, size
- mov eax, esp
- push 0
- push eax ;// &ctex
- push 0 ;// D3DPOOL_DEFAULT
- push 21 ;// D3DFMT_A8R8G8B8
- push 1 ;// D3DUSAGE_RENDERTARGET = 1
- push 1 ;// levels = 1
- push edx ;// width
- push edx ;// height
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 92 ] ;// CreateTexture
- ;// Save current rendertarget
- push eax ;// ?, ctex, code, size
- mov eax, esp
- push eax ;// &osurf
- push 0
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 152 ] ;// GetRenderTarget
- ;// Get texture surface
- mov esi, [ esp + 4 ] ;// ctex
- push eax ;// ?, osurf, ctex, code, size
- mov eax, esp
- push eax ;// &csurf
- push 0
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 72 ] ;// GetSurfaceLevel
- ;// csurf, osurf, ctex, code, size
- ;// Set rendertarget to new texture surface
- push dword ptr [ esp ] ;// csurf
- push 0
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 148 ] ;// SetRenderTarget
- ;// Recursively refine quarter-size copy
- push 0 ;// (lsurf), csurf, osurf, ctex, code, size
- mov edx, [ esp + 20 ]
- shr edx, 1 ;// size / 2
- je short skipRecurse
- mov eax, [ esp + 16 ] ;// code
- call renderDC
- ;// renderDC returns texture, get texture surface. If not recursing, lsurf = 0
- mov [ esp ], ecx
- skipRecurse:
- ;// Solve iteratively for current grid level
- mov eax, DC_ITERATIONS
- gridLoop: push eax
- ;// Scale lsurf to csurf
- cmp dword ptr [ esp + 4 ], 0
- je skipScale1
- push 2 ;// D3DTEXF_LINEAR
- push 0
- push dword ptr [ esp + 16 ] ;// csurf
- push 0
- push dword ptr [ esp + 20 ] ;// lsurf
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 136 ] ;// StretchRect
- skipScale1:
- ;// Apply constraints
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 164 ] ;// BeginScene
- mov ebx, [ esp + 20 ] ;// code
- mov edx, [ esp + 24 ] ;// size
- call dcLocalConstraints
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 168 ] ;// EndScene
- ;// Scale csurf to lsurf
- cmp dword ptr [ esp + 4 ], 0
- je skipScale2
- push 2 ;// D3DTEXF_LINEAR
- push 0
- push dword ptr [ esp + 12 ] ;// lsurf
- push 0
- push dword ptr [ esp + 24 ] ;// csurf
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 136 ] ;// StretchRect
- skipScale2:
- ;// Loop
- pop eax
- dec al
- jnz gridLoop
- ;// Restore rendertarget ;// lsurf, csurf, osurf, ctex, code, size
- push dword ptr [ esp + 8 ] ;// osurf
- push 0
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 148 ] ;// SetRenderTarget
- ;// Return
- mov eax, ebx ;// end of code
- pop ecx
- pop ecx ;// csurf
- pop ebx
- pop ebx ;// ctex
- pop edi
- pop edi
- ret
- ;//===============================================================================================
- ;// Apply DC local constraints
- ;//
- ;// ebx - texture code
- ;// edx - texture size
- ;// Target texture must be rendertarget
- ;//
- ;// Returns end of texture code in ebx
- ;//===============================================================================================
- endCodeLoop:
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- lea eax, dword ptr [ ebp + ( identityMatrix - vv ) ]
- push eax ;// Source matrix
- push 256 ;// World matrix
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 176 ] ;// SetTransform
- pop eax
- pop eax
- ret
- dcLocalConstraints: push edx
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push 2 ;// D3DBLEND_ONE
- push 19 ;// D3DRS_SRCBLEND
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- push 1 ;// D3DBLEND_ZERO
- push 20 ;// D3DRS_DESTBLEND
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- push 1
- push 27 ;// D3DRS_ALPHABLENDENABLE
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- push 0
- push 137 ;// D3DRS_LIGHTING
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 228 ] ;// SetRenderState
- ;// Initialise stack and colour
- mov dword ptr [ ebp + ( currentVertex - vv ) ], offset vertexStack
- mov dword ptr [ ebp + ( currentCol - vv ) ], 0
- ;// Keep track of how much we're scaling
- mov dword ptr [ ebp + ( scaleProduct - vv ) ], 03f800000h ;// 1.0f
- ;// Process code
- codeLoop:
- push codeLoop
- finit
- mov eax, dword ptr [ ebx ]
- inc ebx
- mov cl, ah
- mov ch, al
- sub al, 20h
- jc endCodeLoop
- sub al, 20h
- jc opcodeRotate
- sub al, 20h
- jc opcodeIncrease
- sub al, 20h
- jc opcodeReduce
- sub al, 20h
- jc opcodeDisplace
- sub al, 10h
- jc opcodeVertex
- sub al, 10h
- jc opcodeTangent
- sub al, 20h
- jc opcodeARGB
- opcodeCommand:
- and al,0fh
- je commandRender
- dec al
- je commandClearStack
- ;//-----------------------------------------------------------------------------------------------
- ;// Outline command
- commandOutline:
- push 5
- fild dword ptr [ esp ]
- pop eax
- jmp thickLoop
- ;//-----------------------------------------------------------------------------------------------
- ;// Render command
- commandRender:
- push 2
- fild dword ptr [ esp ]
- pop eax
- thickLoop:
- ;// Beginning of vertex stack
- mov esi, offset vertexStack
- ;// Get initial colour
- mov ecx, [ esi ]
- imul ecx, 17
- mov dword ptr [ ebp + ( currentColI - vv ) ], ecx
- ;// Get inital x, y, dx, dy
- lea edi, dword ptr [ ebp + ( v1Pre - vv ) ]
- movsd
- movsd
- movsd
- movsd
- movsd
- mov dword ptr [ ebp + ( renderVertex - vv ) ], esi
- ;// Begin processing segments
- vertexLoop:
- ;// Endpoint to beginning
- lea esi, dword ptr [ ebp + ( v1Pre - vv ) ]
- lea edi, dword ptr [ ebp + ( v0Pre - vv ) ]
- movsd
- movsd
- movsd
- movsd
- movsd
- ;// Read new vertex and colour delta
- mov esi, dword ptr [ ebp + ( renderVertex - vv ) ]
- movsd
- movsd
- movsd
- movsd
- movsd
- mov dword ptr [ ebp + ( renderVertex - vv ) ], esi
- ;// Begin subdivision
- push 3d70f0eeh ;// 1/17
- fld dword ptr [ esp ]
- fldz ;// 0
- pop eax
- subdivideLoop:
- ;// Save FPU state because DX doesn't, GRR
- ;//push eax ;// t for hermite spline
- ;//fst dword ptr [ esp ]
- fsave dword ptr [ ebp + ( fpuSave - vv ) ]
- frstor dword ptr [ ebp + ( fpuSave - vv ) ]
- ;// s1 -> s0
- lea esi, dword ptr [ ebp + ( s1x - vv ) ]
- lea edi, dword ptr [ ebp + ( s0x - vv ) ]
- movsd
- movsd
- movsd
- movsd
- ;// Hermite interpolation
- ;// edi -> s1x
- fld1
- fsubp st(3), st
- fld st(0) ;// s --
- fld st(0) ;// s s --
- fmul st(0), st(1) ;// s^2 s --
- fld st(1) ;// s s^2 s --
- fmul st(0), st(1) ;// s^3 s^2 s --
- fld dword ptr [ edi + ( v0x - s1x ) ]
- fadd dword ptr [ edi + ( v0x - s1x ) ]
- fadd dword ptr [ edi + ( t0x - s1x ) ]
- fadd dword ptr [ edi + ( t1x - s1x ) ]
- fsub dword ptr [ edi + ( v1x - s1x ) ]
- fsub dword ptr [ edi + ( v1x - s1x ) ]
- fmulp st(1), st
- fld dword ptr [ edi + ( v1x - s1x ) ]
- fadd dword ptr [ edi + ( v1x - s1x ) ]
- fadd dword ptr [ edi + ( v1x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( t0x - s1x ) ]
- fsub dword ptr [ edi + ( t0x - s1x ) ]
- fsub dword ptr [ edi + ( t1x - s1x ) ]
- fmulp st(2), st
- fld dword ptr [ edi + ( t0x - s1x ) ]
- fmulp st(3), st
- fld dword ptr [ edi + ( v0x - s1x ) ]
- faddp st(1), st
- faddp st(1), st
- faddp st(1), st
- fstp dword ptr [ edi + ( s1x - s1x ) ]
- add edi, 4
- fld st(0) ;// s --
- fld st(0) ;// s s --
- fmul st(0), st(1) ;// s^2 s --
- fld st(1) ;// s s^2 s --
- fmul st(0), st(1) ;// s^3 s^2 s --
- fld dword ptr [ edi + ( v0x - s1x ) ]
- fadd dword ptr [ edi + ( v0x - s1x ) ]
- fadd dword ptr [ edi + ( t0x - s1x ) ]
- fadd dword ptr [ edi + ( t1x - s1x ) ]
- fsub dword ptr [ edi + ( v1x - s1x ) ]
- fsub dword ptr [ edi + ( v1x - s1x ) ]
- fmulp st(1), st
- fld dword ptr [ edi + ( v1x - s1x ) ]
- fadd dword ptr [ edi + ( v1x - s1x ) ]
- fadd dword ptr [ edi + ( v1x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( v0x - s1x ) ]
- fsub dword ptr [ edi + ( t0x - s1x ) ]
- fsub dword ptr [ edi + ( t0x - s1x ) ]
- fsub dword ptr [ edi + ( t1x - s1x ) ]
- fmulp st(2), st
- fld dword ptr [ edi + ( t0x - s1x ) ]
- fmulp st(3), st
- fld dword ptr [ edi + ( v0x - s1x ) ]
- faddp st(1), st
- faddp st(1), st
- faddp st(1), st
- fstp dword ptr [ edi + ( s1x - s1x ) ]
- ;// Clear alpha if outlining
- fld1
- fucomi st(0), st(3)
- jnc noClearAlpha
- mov byte ptr [ ebp + ( s1argb - vv + 3 ) ], 0
- mov byte ptr [ ebp + ( currentColID - vv + 3 ) ], 0
- noClearAlpha:
- faddp st(3), st
- ;// First run through loop ends here
- fucomi st(0), st(1)
- jc endSubdivideLoop
- ;// Save unexpanded s1
- push dword ptr [ edi - 4 ]
- push dword ptr [ edi ]
- push edi
- ;// Expand
- fld dword ptr [ edi ] ;// y1 --
- fld dword ptr [ edi - 4 ] ;// x1 y1 --
- fld dword ptr [ edi - 16 ] ;// y0 x1 y1 --
- fsubp st(2), st ;// x1 dy --
- fld dword ptr [ edi - 20 ] ;// x0 x1 dy --
- fsubp st(1), st ;// dx dy --
- fld st(1) ;// dy dx dy --
- fmul st(0), st(2) ;// dy*dy dx dy --
- fld st(1) ;// dx dy*dy dx dy --
- fmul st(0), st(2) ;// dx*dx dy*dy dx dy --
- faddp st(1), st ;// len dx dy --
- fsqrt
- fimul dword ptr [ esp + 16 ]
- fdiv st(0), st(5) ;// scale
- fmul dword ptr [ ebp + ( scaleProduct - vv ) ]
- ;// slen dx dy --
- fld st(0) ;// slen slen dx dy --
- fdivp st(2), st ;// slen ndx dy --
- fdivp st(2), st ;// ndx ndy --
- fld st(1)
- fld st(1) ;// dx dy dx dy --
- fsubp st(3), st ;// dy dx dy-dx --
- faddp st(1), st ;// dx+dy dy-dx --
- fld dword ptr [ edi ]
- fadd st(0), st(2)
- fstp dword ptr [ edi ]
- sub edi, 4
- fld dword ptr [ edi ]
- fadd st(0), st(1)
- fstp dword ptr [ edi ]
- sub edi, 12
- fld dword ptr [ edi ]
- fsub st(0), st(1)
- fstp dword ptr [ edi ]
- sub edi, 4
- fld dword ptr [ edi ]
- fadd st(0), st(2)
- fstp dword ptr [ edi ]
- ;// Render
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push 66 ;// D3DFVF_XYZ | D3DFVF_DIFFUSE
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 356 ] ;// SetFVF
- push 16 ;// Vertex size
- lea eax, dword ptr [ ebp + ( s0x - vv ) ] ;// s0
- push eax
- push 1 ;// No. primitives
- push 2 ;// D3DPT_LINELIST
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 332 ] ;// DrawPrimitiveUP
- ;// Restore FPU state
- frstor dword ptr [ ebp + ( fpuSave - vv ) ]
- ;// Restore unexpanded s1
- pop edi
- pop dword ptr [ edi ]
- pop dword ptr [ edi - 4 ]
- ;// Interpolate colour
- lea esi, dword ptr [ ebp + ( currentColID - vv ) ]
- mov al, [ esi ]
- add [ esi + ( currentColI - currentColID ) ], al
- inc esi
- mov al, [ esi ]
- add [ esi + ( currentColI - currentColID ) ], al
- inc esi
- mov al, [ esi ]
- add [ esi + ( currentColI - currentColID ) ], al
- inc esi
- mov al, [ esi ]
- add [ esi + ( currentColI - currentColID ) ], al
- inc esi
- ;// End subdivision loop
- endSubdivideLoop:
- fadd st(0), st(1)
- fld1
- fucomip st(0), st(1)
- jnc subdivideLoop
- ;// End vertex loop
- fucomip st(0), st(1)
- fucomip st(0), st(1)
- mov eax, dword ptr [ ebp + ( renderVertex - vv ) ]
- cmp eax, dword ptr [ ebp + ( currentVertex - vv ) ]
- jne vertexLoop
- fldlg2
- fsubp st(1), st
- fldz
- fucomip st(0), st(1)
- jc thickLoop
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Clear stack command
- commandClearStack:
- mov dword ptr [ ebp + ( currentVertex - vv ) ], offset vertexStack
- mov dword ptr [ ebp + ( currentCol - vv ) ], 0
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Vertex or tangent command
- opcodeTangent:
- inc ebx
- mov eax, ecx
- shr eax, 6
- and eax, 03fh
- and ecx, 03fh
- sub eax, 32
- sub ecx, 32
- push ecx
- fild dword ptr [ esp ]
- push 20
- fidiv dword ptr [ esp ]
- push eax
- fild dword ptr [ esp ]
- push 20
- fidiv dword ptr [ esp ]
- pop eax
- pop eax
- pop eax
- pop eax
- mov esi, dword ptr [ ebp + ( currentVertex - vv ) ]
- sub esi, 8
- fstp dword ptr [ esi ]
- add esi, 4
- fstp dword ptr [ esi ]
- add esi, 4
- ret
- opcodeVertex:
- inc ebx
- mov eax, ecx
- shr eax, 6
- and eax, 03fh
- and ecx, 03fh
- push ecx
- fild dword ptr [ esp ]
- push 63
- fidiv dword ptr [ esp ]
- push eax
- fild dword ptr [ esp ]
- push 63
- fidiv dword ptr [ esp ]
- pop eax
- pop eax
- pop eax
- pop eax
- mov esi, dword ptr [ ebp + ( currentVertex - vv ) ]
- mov dword ptr [ esi ], 0
- add esi, 4
- fstp dword ptr [ esi ]
- add esi, 4
- fstp dword ptr [ esi ]
- add esi, 4
- mov dword ptr [ esi ], 0
- add esi, 4
- mov dword ptr [ esi ], 0
- add esi, 4
- mov dword ptr [ ebp + ( currentVertex - vv ) ], esi
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Displace command
- opcodeDisplace: inc ebx
- mov eax, ecx
- shr eax, 6
- and eax, 03fh
- and ecx, 03fh
- sub eax, 32
- sub ecx, 32
- push ecx
- fild dword ptr [ esp ]
- push 63
- fidiv dword ptr [ esp ]
- push eax
- fild dword ptr [ esp ]
- push 63
- fidiv dword ptr [ esp ]
- pop eax
- pop eax
- pop eax
- pop eax
- lea esi, dword ptr [ ebp + ( translateMatrix - vv ) ]
- fstp dword ptr [ esi + ( 12 * 4 ) ]
- fstp dword ptr [ esi + ( 13 * 4 ) ]
- push esi ;// Source matrix
- push 256 ;// World matrix
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 184 ] ;// MultiplyTransform
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Reduce command
- opcodeReduce:
- and eax, 1fh
- push eax
- fild dword ptr [ esp ]
- push 31
- fidiv dword ptr [ esp ]
- fld1
- fsubrp st(1), st
- pop eax
- pop eax
- lea esi, dword ptr [ ebp + ( scaleProduct - vv ) ]
- fld st(0)
- fmul dword ptr [ esi ]
- fstp dword ptr [ esi ]
- add esi, 4
- fst dword ptr [ esi + ( 0 * 4 ) ]
- fstp dword ptr [ esi + ( 5 * 4 ) ]
- push esi ;// Source matrix
- push 256 ;// World matrix
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 184 ] ;// MultiplyTransform
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Increase command
- opcodeIncrease:
- and eax, 1fh
- push eax
- fild dword ptr [ esp ]
- push 31
- fidiv dword ptr [ esp ]
- fld1
- fadd st(0), st(1)
- pop eax
- pop eax
- lea esi, dword ptr [ ebp + ( scaleProduct - vv ) ]
- fld st(0)
- fmul dword ptr [ esi ]
- fstp dword ptr [ esi ]
- add esi, 4
- fst dword ptr [ esi + ( 0 * 4 ) ]
- fstp dword ptr [ esi + ( 5 * 4 ) ]
- push esi ;// Source matrix
- push 256 ;// World matrix
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 184 ] ;// MultiplyTransform
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// Rotate command
- opcodeRotate:
- push edx
- and eax, 1fh
- push eax
- fild dword ptr [ esp ]
- push 3dc90fdbh
- fld dword ptr [ esp ]
- fmul st(0), st(1)
- fsincos
- pop eax
- pop eax
- lea esi, dword ptr [ ebp + ( rotateMatrix - vv ) ]
- fst dword ptr [ esi + ( 0 * 4 ) ]
- fstp dword ptr [ esi + ( 5 * 4 ) ]
- fst dword ptr [ esi + ( 1 * 4 ) ]
- fchs
- fstp dword ptr [ esi + ( 4 * 4 ) ]
- push esi ;// Source matrix
- push 256 ;// World matrix
- mov esi, dword ptr [ ebp + ( d3dDevice - vv ) ]
- push esi
- mov eax, [ esi ]
- call dword ptr [ eax + 184 ] ;// MultiplyTransform
- pop edx
- ret
- ;//-----------------------------------------------------------------------------------------------
- ;// ARGB command
- ;//t1 = agrb << 12;// t2 = argb | t1;// t2 = t2 << 4;// t2 = t2 & 0xf0f0f0f0;//
- opcodeARGB: inc ebx
- lea esi, dword ptr [ ebp + ( currentCol - vv ) ]
- mov al, cl
- and al, 0fh
- sub al, byte ptr [ esi ]
- add byte ptr [ esi ], al
- inc esi
- ror eax, 8
- shr ecx, 4
- mov al, cl
- and al, 0fh
- sub al, byte ptr [ esi ]
- add byte ptr [ esi ], al
- inc esi
- ror eax, 8
- shr ecx, 4
- mov al, cl
- and al, 0fh
- sub al, byte ptr [ esi ]
- add byte ptr [ esi ], al
- inc esi
- ror eax, 8
- shr ecx, 4
- mov al, cl
- and al, 1
- neg al
- and al, 0fh
- sub al, byte ptr [ esi ]
- add byte ptr [ esi ], al
- inc esi
- ror eax, 8
- mov esi, dword ptr [ ebp + ( currentVertex - vv ) ]
- mov dword ptr [ esi - 20 ], eax
- ret
- End Start
- _TEXT ends
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement