Hi,

I've got a problem with a DX8.1-app... It doesn't display
the triangle... Do someone know why not?

(SpAsm syntax)



; .--------------------------.
; | My own rotating triangle |
; '--------------------------'

[ErrorFlag: D$ 0]
[push | push #1 | #+1]
[call | push #L>2 | call #1]
[OnError | cmp eax, 0 | jne l1> | cmp D$ErrorFlag, 0 | jne l2> | mov D$ErrorFlag, 1
call 'USER32.MessageBoxA', 0, Error_Text, Error_Title, &MB_ICONSTOP+&MB_OK
l2: mov eax, 0]
[EndError | l1:]
[GetVTableStart | mov eax, D$#1 | mov eax, D$eax]
[ComCall | GetVTableStart #1 | call #2, D$#1, #3>L]

[IDirect3D8_QueryInterface D$eax+00][IDirect3D8_AddRef D$eax+04]
[IDirect3D8_Release D$eax+08][IDirect3D8_RegisterSoftwareDevice D$eax+12]
[IDirect3D8_GetAdapterCount D$eax+16][IDirect3D8_GetAdapterIdentifier D$eax+20]
[IDirect3D8_GetAdapterModeCount D$eax+24][IDirect3D8_EnumAdapterModes D$eax+28]
[IDirect3D8_GetAdapterDisplayMode D$eax+32][IDirect3D8_CheckDeviceType D$eax+36]
[IDirect3D8_CheckDeviceFormat D$eax+40][IDirect3D8_CheckDeviceMultiSampleType D$eax+44]
[IDirect3D8_CheckDepthStencilMatch D$eax+48][IDirect3D8_GetDeviceCaps D$eax+52]
[IDirect3D8_GetAdapterMonitor D$eax+56][IDirect3D8_CreateDevice D$eax+60]

[IDirect3DDevice8_QueryInterface D$eax+00][IDirect3DDevice8_AddRef D$eax+04]
[IDirect3DDevice8_Release D$eax+08][IDirect3DDevice8_TestCooperativeLevel D$eax+12]
[IDirect3DDevice8_GetAvailableTextureMem D$eax+16][IDirect3DDevice8_ResourceManagerDiscardBytes D$eax+20]
[IDirect3DDevice8_GetDirect3D D$eax+24][IDirect3DDevice8_GetDeviceCaps D$eax+28]
[IDirect3DDevice8_GetDisplayMode D$eax+32][IDirect3DDevice8_GetCreationParameters D$eax+36]
[IDirect3DDevice8_SetCursorProperties D$eax+40][IDirect3DDevice8_SetCursorPosition D$eax+44]
[IDirect3DDevice8_ShowCursor D$eax+48][IDirect3DDevice8_CreateAdditionalSwapChain D$eax+52]
[IDirect3DDevice8_Reset D$eax+56][IDirect3DDevice8_Present D$eax+60]
[IDirect3DDevice8_GetBackBuffer D$eax+64][IDirect3DDevice8_GetRasterStatus D$eax+68]
[IDirect3DDevice8_SetGammaRamp D$eax+72][IDirect3DDevice8_GetGammaRamp D$eax+76]
[IDirect3DDevice8_CreateTexture D$eax+80][IDirect3DDevice8_CreateVolumeTexture D$eax+84]
[IDirect3DDevice8_CreateCubeTexture D$eax+88][IDirect3DDevice8_CreateVertexBuffer D$eax+92]
[IDirect3DDevice8_CreateIndexBuffer D$eax+96][IDirect3DDevice8_CreateRenderTarget D$eax+100]
[IDirect3DDevice8_CreateDepthStencilSurface D$eax+104][IDirect3DDevice8_CreateImageSurface D$eax+108]
[IDirect3DDevice8_CopyRects D$eax+112][IDirect3DDevice8_UpdateTexture D$eax+116]
[IDirect3DDevice8_GetFrontBuffer D$eax+120][IDirect3DDevice8_SetRenderTarget D$eax+124]
[IDirect3DDevice8_GetRenderTarget D$eax+128][IDirect3DDevice8_GetDepthStencilSurface D$eax+132]
[IDirect3DDevice8_BeginScene D$eax+136][IDirect3DDevice8_EndScene D$eax+140]
[IDirect3DDevice8_Clear D$eax+144][IDirect3DDevice8_SetTransform D$eax+148]
[IDirect3DDevice8_GetTransform D$eax+152][IDirect3DDevice8_MultiplyTransform D$eax+156]
[IDirect3DDevice8_SetViewport D$eax+160][IDirect3DDevice8_GetViewport D$eax+164]
[IDirect3DDevice8_SetMaterial D$eax+168][IDirect3DDevice8_GetMaterial D$eax+172]
[IDirect3DDevice8_SetLight D$eax+176][IDirect3DDevice8_GetLight D$eax+180]
[IDirect3DDevice8_LightEnable D$eax+184][IDirect3DDevice8_GetLightEnable D$eax+188]
[IDirect3DDevice8_SetClipPlane D$eax+192][IDirect3DDevice8_GetClipPlane D$eax+196]
[IDirect3DDevice8_SetRenderState D$eax+200][IDirect3DDevice8_GetRenderState D$eax+204]
[IDirect3DDevice8_BeginStateBlock D$eax+208][IDirect3DDevice8_EndStateBlock D$eax+212]
[IDirect3DDevice8_ApplyStateBlock D$eax+216][IDirect3DDevice8_CaptureStateBlock D$eax+220]
[IDirect3DDevice8_DeleteStateBlock D$eax+224][IDirect3DDevice8_CreateStateBlock D$eax+228]
[IDirect3DDevice8_SetClipStatus D$eax+232][IDirect3DDevice8_GetClipStatus D$eax+236]
[IDirect3DDevice8_GetTexture D$eax+240][IDirect3DDevice8_SetTexture D$eax+244]
[IDirect3DDevice8_GetTextureStageState D$eax+248][IDirect3DDevice8_SetTextureStageState D$eax+252]
[IDirect3DDevice8_ValidateDevice D$eax+256][IDirect3DDevice8_GetInfo D$eax+260]
[IDirect3DDevice8_SetPaletteEntries D$eax+264][IDirect3DDevice8_GetPaletteEntries D$eax+268]
[IDirect3DDevice8_SetCurrentTexturePalette D$eax+272][IDirect3DDevice8_GetCurrentTexturePalette D$eax+276]
[IDirect3DDevice8_DrawPrimitive D$eax+280][IDirect3DDevice8_DrawIndexedPrimitive D$eax+284]
[IDirect3DDevice8_DrawPrimitiveUP D$eax+288][IDirect3DDevice8_DrawIndexedPrimitiveUP D$eax+292]
[IDirect3DDevice8_ProcessVertices D$eax+296][IDirect3DDevice8_CreateVertexShader D$eax+300]
[IDirect3DDevice8_SetVertexShader D$eax+304][IDirect3DDevice8_GetVertexShader D$eax+308]
[IDirect3DDevice8_DeleteVertexShader D$eax+312][IDirect3DDevice8_SetVertexShaderConstant D$eax+316]
[IDirect3DDevice8_GetVertexShaderConstant D$eax+320][IDirect3DDevice8_GetVertexShaderDeclaration D$eax+324]
[IDirect3DDevice8_GetVertexShaderFunction D$eax+328][IDirect3DDevice8_SetStreamSource D$eax+332]
[IDirect3DDevice8_GetStreamSource D$eax+336][IDirect3DDevice8_SetIndices D$eax+340]
[IDirect3DDevice8_GetIndices D$eax+344][IDirect3DDevice8_CreatePixelShader D$eax+348]
[IDirect3DDevice8_SetPixelShader D$eax+352][IDirect3DDevice8_GetPixelShader D$eax+360]
[IDirect3DDevice8_DeletePixelShader D$eax+364][IDirect3DDevice8_SetPixelShaderConstant D$eax+368]
[IDirect3DDevice8_GetPixelShaderConstant D$eax+372][IDirect3DDevice8_GetPixelShaderFunction D$eax+376]
[IDirect3DDevice8_DrawRectPatch D$eax+380][IDirect3DDevice8_DrawTriPatch D$eax+384]
[IDirect3DDevice8_DeletePatch D$eax+388]

[IDirect3DVertexBuffer8_QueryInterface D$eax+00][IDirect3DVertexBuffer8_AddRef D$eax+04]
[IDirect3DVertexBuffer8_Release D$eax+08][IDirect3DVertexBuffer8_GetDevice D$eax+12]
[IDirect3DVertexBuffer8_SetPrivateData D$eax+16][IDirect3DVertexBuffer8_GetPrivateData D$eax+20]
[IDirect3DVertexBuffer8_FreePrivateData D$eax+24][IDirect3DVertexBuffer8_SetPriority D$eax+28]
[IDirect3DVertexBuffer8_GetPriority D$eax+32][IDirect3DVertexBuffer8_PreLoad D$eax+36]
[IDirect3DVertexBuffer8_GetType D$eax+40][IDirect3DVertexBuffer8_Lock D$eax+44]
[IDirect3DVertexBuffer8_Unlock D$eax+48][IDirect3DVertexBuffer8_GetDesc D$eax+52]

[Error_Text: B$ 'Error in App!!!', 0 Error_Title: B$ 'Dude...', 0]
[OurWinTitle: B$ 'DirectX-Test', 0]
[WndClassName: B$ 'OurWndClass', 0]

[hInstance: D$ 0]
[ScreenWidth: D$ 0 ScreenHeight: D$ 0]
[hWnd: D$ 0]
[g_pD3D: D$ 0]
[g_pD3DDevice: D$ 0]

[wc:
wc.cbSize: D? 48 wc.style: D? 0 wc.lpfnWndProc: D? 0 wc.cbClsExtra: D? 0
wc.cbWndExtra: D? 0 wc.hInstance: D? 0 wc.hIcon: D? 0 wc.hCursor: D? 0
wc.hbrBackground: D? 0 wc.lpszMenuName: D? 0 wc.lpszClassName: D? 0 wc.hIconSm: D? 0]
[msg:
msg.hwnd: D? 0 msg.message: D? 0 msg.wParam: D? 0
msg.lParam: D? 0 msg.time: D? 0 msg.pt.x: D? 0
msg.pt.y: D? 0]
[d3ddm:
d3ddm.Width: D$ 0 d3ddm.Height: D$ 0
d3ddm.RefreshRate: D$ 0 d3ddm.Format: D$ 0]

[d3dpp:
d3dpp.BackBufferWidth: D$ 0 d3dpp.BackBufferHeight: D$ 0 d3dpp.BackBufferFormat: D$ 0
d3dpp.BackBufferCount: D$ 0 d3dpp.MultiSampleType: D$ 0 d3dpp.SwapEffect: D$ 0
d3dpp.hDeviceWindow: D$ 0 d3dpp.Windowed: D$ 0 d3dpp.EnableAutoDepthStencil: D$ 0
d3dpp.AutoDepthStencilFormat: D$ 0 d3dpp.Flags: D$ 0 d3dpp.FullScreen_RefreshRateInHz: D$ 0
d3dpp.FullScreen_PresentationInterval: D$ 0]

; -------------
; --- Main: ---
; -------------
Main:
call 'KERNEL32.GetModuleHandleA', 0
mov D$hInstance, eax

OnError | jmp step8 | EndError

step1:
call RegisterWindowClass

OnError | jmp step8 | EndError

step2:
call MakeWindow

OnError | jmp step7 | EndError

step3:
call InitD3D

OnError | jmp step6 | EndError

step4:
call MainMessageLoop

step5:
call KillD3D

step6:
call KillWindow

step7:
call UnRegisterWindowClass

step8:
call 'KERNEL32.ExitProcess', D$hInstance
ret

; ----------------------------
; --- RegisterWindowClass: ---
; ----------------------------
RegisterWindowClass:
mov D$wc.style, &CS_CLASSDC
mov D$wc.lpfnWndProc, WndProc
mov eax, D$hInstance
mov D$wc.hInstance, eax
call 'USER32.LoadIconA', D$hInstance, &IDI_APPLICATION
mov D$wc.hIcon, eax
call 'USER32.LoadCursorA', D$hInstance, &IDC_ARROW
mov D$wc.hCursor, eax
mov D$wc.hbrBackground, &COLOR_WINDOW
mov D$wc.lpszMenuName, 0
mov D$wc.lpszClassName, WndClassName
mov D$wc.hIconSm, 0

call 'USER32.RegisterClassExA', wc

OnError | ret | EndError

mov eax, 1
ret

; -------------------
; --- MakeWindow: ---
; -------------------
MakeWindow:
call 'USER32.GetSystemMetrics', &SM_CXSCREEN
mov D$ScreenWidth, eax
call 'USER32.GetSystemMetrics', &SM_CYSCREEN
mov D$ScreenHeight, eax


call 'USER32.CreateWindowExA', 0, WndClassName,
OurWinTitle, &WS_SYSMENU+&WS_CAPTION+&WS_VISIBLE,
0, 0, D$ScreenWidth, D$ScreenHeight, 0, 0,
D$hInstance, 0

OnError | ret | EndError

mov D$hWnd, eax

OnError
ret
EndError

call 'USER32.ShowWindow', D$hWnd, &SW_SHOWDEFAULT
call 'USER32.UpdateWindow', D$hWnd

mov eax, 1
ret

; ----------------
; --- InitD3D: ---
; ----------------
InitD3D:
call 'D3D8.Direct3DCreate8',
220 ; D3D_SDK_VERSION
mov D$g_pD3D, eax
OnError | ret | EndError

ComCall g_pD3D, IDirect3D8_GetAdapterDisplayMode,
0, ; D3DADAPTER_DEFAULT
d3ddm

mov D$d3dpp.Windowed, 1 ; TRUE
mov D$d3dpp.SwapEffect, 1 ; D3DSWAPEFFECT_DISCARD
mov eax, D$d3ddm.Format | mov D$d3dpp.BackBufferFormat, eax
ComCall g_pD3D, IDirect3D8_CreateDevice,
0, ; D3DADAPTER_DEFAULT
1, ; D3DDEVTYPE_HAL
D$hWnd,
020, ; D3DCREATE_SOFTWARE_VERTEXPROCESSING
d3dpp,
g_pD3DDevice
mov eax, D$g_pD3DDevice
OnError | ret | EndError

mov eax, 1
ret

; ---------------
; --- KillD3D ---
; ---------------
KillD3D:
cmp D$g_pD3DDevice, 0 | je NoD3DDevice
ComCall g_pD3DDevice, IDirect3DDevice8_Release

NoD3DDevice:
cmp D$g_pD3D, 0 | je NoD3DObject
ComCall g_pD3D, IDirect3D8_Release

NoD3DObject:

mov eax, 1
ret

; ------------------------
; --- MainMessageLoop: ---
; ------------------------
MainMessageLoop:
call 'USER32.PeekMessageA', msg, D$hWnd, 0, 0, &PM_REMOVE
cmp eax, 0 | je NoNewMessage
cmp D$msg.message, &WM_QUIT | je QuitLoop
call 'USER32.TranslateMessage', msg
call 'USER32.DispatchMessageA', msg
jmp MainMessageLoop

NoNewMessage:
call Render
jmp MainMessageLoop

QuitLoop:
call 'USER32.PostQuitMessage', 0

mov eax, 1
ret

; -------------------
; --- KillWindow: ---
; -------------------
KillWindow:
call 'USER32.DestroyWindow', D$hWnd

OnError | ret | EndError

mov eax, 1
ret

; ------------------------------
; --- UnRegisterWindowClass: ---
; ------------------------------
UnRegisterWindowClass:
call 'USER32.UnregisterClassA', WndClassName, D$hInstance

OnError | ret | EndError

mov eax, 1
ret

; ----------------
; --- WndProc: ---
; ----------------
WndProc:
[wp.hWnd: D$ 0 wp.uMsg: D$ 0 wp.wParam: D$ 0
wp.lParam: D$ 0]
mov eax, D$esp+ 4 | mov D$wp.hWnd, eax
mov eax, D$esp+ 8 | mov D$wp.uMsg, eax
mov eax, D$esp+12 | mov D$wp.wParam, eax
mov eax, D$esp+16 | mov D$wp.lParam, eax

cmp D$wp.uMsg, &WM_CLOSE | je Destroy
cmp D$wp.uMsg, &WM_DESTROY | je Destroy

call 'USER32.DefWindowProcA', D$wp.hWnd, D$wp.uMsg, D$wp.wParam, D$wp.lParam
jmp WndProcFinish

Destroy:
call 'USER32.PostQuitMessage', 0
jmp WndProcFinish

WndProcFinish:

ret 16

; ---------------
; --- Render: ---
; --------------
[NULL 00]
[D3DCLEAR_TARGET 01]
[D3DCLEAR_ZBUFFER 02]
[D3DCLEAR_STENCIL 04]
[D3DPT_POINTLIST 1]
[D3DPT_LINELIST 2]
[D3DPT_LINESTRIP 3]
[D3DPT_TRIANGLELIST 4]
[D3DPT_TRIANGLESTRIP 5]
[D3DPT_TRIANGLEFAN 6]
[D3DFVF_RESERVED0 01]
[D3DFVF_POSITION_MASK 0E]
[D3DFVF_XYZ 02]
[D3DFVF_XYZRHW 04]
[D3DFVF_XYZB1 06]
[D3DFVF_XYZB2 08]
[D3DFVF_XYZB3 0a]
[D3DFVF_XYZB4 0c]
[D3DFVF_XYZB5 0e]
[D3DFVF_NORMAL 010]
[D3DFVF_PSIZE 020]
[D3DFVF_DIFFUSE 040]
[D3DFVF_SPECULAR 080]
[D3DFMT_VERTEXDATA 100]
[D3DFMT_INDEX16 101]
[D3DFMT_INDEX32 102]

[tri: F$ 512.0, F$ 0.0, F$ 0.0, D$ 0ffff0000,
F$1024.0, F$768.0, F$ 0.0, D$ 0ff00ff00,
F$ 0.0, F$768.0, F$ 0.0, D$ 0ff00ffff]
Render:
ComCall g_pD3DDevice, IDirect3DDevice8_Clear,
0, NULL, D3DCLEAR_TARGET,
100, F$ 1.0, 0

ComCall g_pD3DDevice, IDirect3DDevice8_BeginScene

ComCall g_pD3DDevice, IDirect3DDevice8_SetVertexShader,
D3DFVF_XYZ+D3DFVF_DIFFUSE

ComCall g_pD3DDevice, IDirect3DDevice8_DrawPrimitiveUP,
D3DPT_TRIANGLELIST,
1,
tri,
20

ComCall g_pD3DDevice, IDirect3DDevice8_EndScene

ComCall g_pD3DDevice, IDirect3DDevice8_Present,
NULL, NULL, NULL, NULL
mov eax, 1
ret



Greetings
Nils
Posted on 2002-04-12 16:33:22 by Nils
Afternoon, Nils.



ComCall g_pD3DDevice, IDirect3DDevice8_DrawPrimitiveUP,
D3DPT_TRIANGLELIST,
1,
tri,
16
?

(I've never used Spasm nor DrawPrimitiveUP, so I don't really know what I'm talking about ;) )

Cheers,
Scronty
Posted on 2002-04-12 21:12:11 by Scronty