Finally after resolving the problem why I could not link
the Directx examples from Scrontsoft, ( I needed to
replace the UUID.LIB with the UUID.LIB from VC++ v6 )
I started to translate the d3dx9 include files.

I've used the COINVOKE method.

They are complete, except for the d3dx9math.inl those are
not completed yet.

The most important ones are present:

D3DXVec3Length
D3DXVec3Dot
D3DXVec3Cross
D3DXMatrixIdentity

Also added some usefull macros:

1) FLOAT_

2) GUID_ADDR

3) TEXT_

4) Alloc_mem and Delete_mem (see sources how to use them)


To demonstrate the direct3D9 includes i've translated the
"meshes tutorial" of the directx9_sdk (summer edition)
(I'll do some more in the future when I find some time)


And here you can download the complete package:

http://members.home.nl/siekmanski/d3dx9_asm.zip

Have fun with it and let me know if you find some errors.

Dsound update... (june 13th)

Siekmanski
Posted on 2004-06-03 04:28:49 by Siekmanski
here are the includes without the libs:

Dsound update... (june 13th)

Update (june 18th)
Posted on 2004-06-03 04:33:21 by Siekmanski
Nice work.
The COINVOKE method is equivalent to the ICALL method from atc.
Under atc we have the options pcall, icall, ocall.
Therefore, should I wish, I can format my source similarly, or even add an equate COINVOKE textequ ICALL or similar to use YOUR source with MY headers :)
Posted on 2004-06-03 08:27:16 by Homer
Hello EvilHomer2k

I'm not familiar with all those other COM-calling stuff.
It's nice to share the same interest in 3d programming.
Hopefully we can use all the d3d9 stuff in assembler.
I'm going to try some stuff to test the includes and then
post it.

I need much more time (36 hours in a day sounds good to me).
Posted on 2004-06-03 10:55:04 by Siekmanski
just updated the FLOAT_ macro in the file: dx9macros.inc

FLOAT_ MACRO float_number:REQ
LOCAL float_num
.data
float_num FLOAT float_number
.code
EXITM <float_num>
ENDM

chanched to:

FLOAT_ MACRO float_number:REQ
LOCAL float_num
.data
float_num dd float_number
.code
EXITM <float_num>
ENDM


It couldn't handle negative numbers, now it can.

Allmost done translating the TEXT3D example of the dx9_SDK
Post it as it's done.

SIEKMANSKI
Posted on 2004-06-05 06:26:32 by Siekmanski
That still won't work, unless you type it as a SFLOAT (as a REAL4 or REAL8).
Posted on 2004-06-06 05:21:28 by Homer
Hello EvilHomer2k

If I do this piece of code,

.data
number dd 0
.code

fld FLOAT_(50.0f)
fadd FLOAT_(-10.0f)
fistp number

I get as a result: 40
Posted on 2004-06-06 07:09:37 by Siekmanski
Yes, but tests like .if fMyFloat>0 will fail (I think).
Check and tell me what happens :)
Posted on 2004-06-06 07:11:46 by Homer
I shall test it.

I don't have the time now, tell you in a few hours.
Posted on 2004-06-06 07:20:54 by Siekmanski
Floats are always signed, so there should only be one datatype anyway, the signed one.
I am not sure what the .IF macro would do though. Perhaps the problem is that the other side of the comparison is unsigned?
Posted on 2004-06-06 07:21:32 by Scali
d3dtext example translated.

let me know if i'ts working on your computer.
btw, float_ macro didn't work in ".IF" macro.

I'll use something like this instead of .IF:

fcomp st(1)
fnstsw ax
sahf
jnc label

Here is the exe and source-code.
Posted on 2004-06-07 12:22:28 by Siekmanski
Since negative floats use bit31 for sign just like signed integers, you can simply:
and eax,80000000h
jz label
Posted on 2004-06-07 12:35:45 by Homer
Thanks EvilHomer2k

Just fast and simple, will try that.
Tested your code and includes they work fine on my computer.
Posted on 2004-06-07 12:42:15 by Siekmanski
I still recommend Caleb's d3dx8math_fkt.def file from his dx8.0 includes, which contains a bunch of handy fpu math macros including such gems as __FJG (meant to be used in conjunction with fcom/fcomp), where it is appropriate to work strictly in fpu.
Posted on 2004-06-08 00:17:27 by Homer
I'll check it out, must have them somewhere.
Posted on 2004-06-08 01:40:19 by Siekmanski
DSound9 includes Translated..

Included a Playwav example to demonstrate includes

Later, Siekmanski
Posted on 2004-06-13 14:34:28 by Siekmanski
Modified for atc, to test my dsound.inc



title Playwav - Siekmanski 2004 - Modified by Homer for ATC

.586
.model flat, stdcall
option casemap :none ; Case sensitive

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\winmm.inc

__DEBUG__ equ 0
return macro px:REQ
mov eax,px
ret
endm

m2m macro pd:REQ,ps:REQ
push ps
pop pd
endm

include \masm32\d3d9\class31.inc ;Ultrano
include \masm32\d3d9\include\dsound.inc ;Homer

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\winmm.lib

includelib dsound.lib

.data

align 4
g_pDS LPDIRECTSOUND8 NULL
set g_pDS as IDirectSound8
g_pDSWavSample LPDIRECTSOUNDBUFFER8 NULL
set g_pDSWavSample as IDirectSoundBuffer8

dshWnd dd 0
hInst dd 0
String_buffer db 128 dup (0)

OpenTitel db "Open Wav file",0
OpenFilter db "Wav files",0,"*.wav",0,0
FilenaamPlusPad db 260 dup(0)
Filenaam db 128 dup(0)
ofn OPENFILENAME <> ; structure

.code

Load_wav proc Wav_name:DWORD,pDSBuffer:DWORD
LOCAL w_pDSSample:LPDIRECTSOUNDBUFFER8
set w_pDSSample as IDirectSoundBuffer8
LOCAL dsbdesc:DSBUFFERDESC
LOCAL hMmio:DWORD
LOCAL WaveInfo:MMCKINFO
LOCAL ChunkInfo:MMCKINFO
LOCAL wfx:WAVEFORMATEX
LOCAL S_data:DWORD
LOCAL S_lengte:DWORD

mov eax,pDSBuffer ; get the soundbuffer adres
mov eax,[eax]
mov w_pDSSample,eax ; save adres

.if w_pDSSample ; release in case it is an old sample
pcall w_pDSSample.Release
.endif

;Open the WAV-file and get all info
invoke mmioOpen,Wav_name,NULL,MMIO_ALLOCBUF or MMIO_READ ; Open the WAV file
.if (eax)
mov hMmio,eax
mov WaveInfo.fccType,"EVAW" ; WAVE header info
invoke mmioDescend,hMmio,addr WaveInfo,NULL,MMIO_FINDRIFF
.if (eax)
invoke MessageBox,NULL,CTEXT("this is not a wav file..."),CTEXT("Wav read error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif
mov ChunkInfo.ckid," tmf" ; fmt field in WAVE header
invoke mmioDescend,hMmio,addr ChunkInfo,addr WaveInfo,MMIO_FINDCHUNK
.if (eax)
invoke MessageBox,NULL,CTEXT("FMT Chunk not found..."),CTEXT("Wav read error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif
invoke mmioRead,hMmio,addr wfx,ChunkInfo.ckSize ; read Wave Format Header
.if (eax != ChunkInfo.ckSize)
invoke MessageBox,NULL,CTEXT("Wave Format Info Read Error..."),CTEXT("Wav read error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif
invoke mmioAscend,hMmio,addr ChunkInfo,NULL
mov ChunkInfo.ckid,"atad" ; Wave Data
invoke mmioDescend, hMmio,addr ChunkInfo,addr WaveInfo,MMIO_FINDCHUNK
.if (eax)
invoke MessageBox,NULL,CTEXT("DATA Chunk not found..."),CTEXT("Wav read error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif


; Init a Directsound buffer with the Info we found in the Wav-file
invoke RtlZeroMemory,ADDR dsbdesc,sizeof dsbdesc
mov dsbdesc.dwSize,sizeof DSBUFFERDESC
mov dsbdesc.dwFlags,DSBCAPS_GLOBALFOCUS
mov eax,ChunkInfo.ckSize ; Wav-data size
mov dsbdesc.dwBufferBytes,eax
lea eax,wfx ; Wav-data format
mov dsbdesc.lpwfxFormat,eax
lea eax,dsbdesc.guid3DAlgorithm
lea ebx,DS3DALG_DEFAULT
invoke RtlMoveMemory,eax,ebx,16

; create the soundbuffer
icall g_pDS,IDirectSound8,CreateSoundBuffer,addr dsbdesc,addr w_pDSSample,NULL
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("CreateSoundBuffer..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif

; lock and get the adres of the soundbuffer
icall w_pDSSample,IDirectSoundBuffer8,Lock,0,ChunkInfo.ckSize,addr S_data,addr S_lengte,NULL,0,0
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("Lock SoundBuffer..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif

; Read the wave data into the soundbufffer
invoke mmioRead,hMmio,S_data,ChunkInfo.ckSize

; unlock the soundbuffer
icall w_pDSSample,IDirectSoundBuffer8,Unlock,S_data,S_lengte,NULL,0
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("Unlock SoundBuffer..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
jmp Load_wav_error
.endif
; set sample start position
icall w_pDSSample,IDirectSoundBuffer8,SetCurrentPosition,0
.else
invoke MessageBox,NULL,CTEXT("wav file not found..."),CTEXT("Wav read error"),MB_OK OR MB_ICONERROR
jmp No_wav
.endif
xor ecx,ecx
xor edx,edx
mov eax,wfx.nSamplesPerSec
mov cx,wfx.wBitsPerSample
mov dx,wfx.nChannels

invoke wsprintf,addr String_buffer,CTEXT(" Rate: %d BPS: %d Channels: %d Length: %d"),eax,ecx,edx,ChunkInfo.ckSize

invoke SetDlgItemText,dshWnd,101,addr String_buffer

invoke mmioClose,hMmio,NULL
mov eax,pDSBuffer
mov ecx,w_pDSSample
mov [eax],ecx ; save soundbuffer adres
return DS_OK
Load_wav_error:
invoke mmioClose,hMmio,NULL
.if w_pDSSample
pcall w_pDSSample.Release
.endif
No_wav:
invoke SetDlgItemText,dshWnd,100,CTEXT(" no file loaded..")
invoke SetDlgItemText,dshWnd,101,CTEXT(" none..")
mov eax,pDSBuffer
xor ecx,ecx
mov [eax],ecx ; clear soundbuffer adres
return E_FAIL
Load_wav endp

;________________________________________________________________________________

StartDSound proc hwnd:DWORD,Mono_stereo:DWORD,Sample_rate:DWORD,Sample_bits:DWORD
LOCAL dsbdesc:DSBUFFERDESC
LOCAL wfx:WAVEFORMATEX
LOCAL g_pDSBPrimary:LPDIRECTSOUNDBUFFER8

invoke DirectSoundCreate8,NULL,addr g_pDS,NULL
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("DirectSoundCreate..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
return E_FAIL
.endif

icall g_pDS,IDirectSound8,SetCooperativeLevel,hwnd,DSSCL_PRIORITY
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("SetCooperativeLevel..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
return E_FAIL
.endif

invoke RtlZeroMemory,ADDR dsbdesc,sizeof dsbdesc
mov dsbdesc.dwSize,sizeof DSBUFFERDESC
mov dsbdesc.dwFlags,DSBCAPS_PRIMARYBUFFER
icall g_pDS,IDirectSound8,CreateSoundBuffer,addr dsbdesc,addr g_pDSBPrimary,NULL
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("CreateSoundBuffer..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
return E_FAIL
.endif

invoke RtlZeroMemory,ADDR wfx,sizeof wfx
mov wfx.wFormatTag,WAVE_FORMAT_PCM
mov eax,Mono_stereo
mov wfx.nChannels,ax
mov eax,Sample_bits
mov wfx.wBitsPerSample,ax
mul Mono_stereo
shr eax,3
mov wfx.nBlockAlign,ax
mov ecx,Sample_rate
mov wfx.nSamplesPerSec,ecx
mul ecx
mov wfx.nAvgBytesPerSec,eax

icall g_pDSBPrimary,IDirectSoundBuffer8,SetFormat,addr wfx
.if (eax != DS_OK)
invoke MessageBox, NULL, CTEXT("SetFormat Primary Buffer..."), CTEXT("DSound Error"),MB_OK OR MB_ICONERROR
return E_FAIL
.endif
set g_pDSBPrimary as IDirectSoundBuffer8
.if g_pDSBPrimary
pcall g_pDSBPrimary.Release
.endif
return DS_OK
StartDSound endp


StopDSound proc
.if g_pDSWavSample
pcall g_pDSWavSample.Release
.endif
.if g_pDS
pcall g_pDS.Release
.endif
return 0
StopDSound endp

WndProc proc hWnd:DWORD, uMsg, wParam, lParam
LOCAL hIcon:DWORD
.if uMsg == WM_INITDIALOG
invoke LoadIcon, hInst, 200
mov hIcon,eax
mov eax,hWnd
mov dshWnd,eax
invoke SendMessage,hWnd,WM_SETICON,1,hIcon

invoke StartDSound,hWnd,2,44100,16
.if (eax != DS_OK)
jmp close
.endif

invoke Load_wav,CTEXT("directx4.wav"),addr g_pDSWavSample
.if (g_pDSWavSample != 0)
invoke SetDlgItemText,hWnd,100,CTEXT(" Name: directx4.wav")
icall g_pDSWavSample,IDirectSoundBuffer8,SetCurrentPosition,0
icall g_pDSWavSample,IDirectSoundBuffer8,Play,0,0,0
.endif
return 0

.elseif uMsg == WM_COMMAND
.if wParam == 102
mov FilenaamPlusPad[0],0
mov Filenaam[0],0
mov ofn.lStructSize,(sizeof OPENFILENAME)
m2m ofn.hWndOwner,hWnd
m2m ofn.hInstance,hInst
m2m ofn.lpstrFilter,offset OpenFilter
m2m ofn.lpstrFile,offset FilenaamPlusPad
mov ofn.nMaxFile,(sizeof FilenaamPlusPad)
m2m ofn.lpstrFileTitle,offset Filenaam
mov ofn.nMaxFileTitle,(sizeof Filenaam)
m2m ofn.lpstrTitle,offset OpenTitel
mov ofn.Flags,OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_LONGNAMES
invoke GetOpenFileName,ADDR ofn
.if (FilenaamPlusPad[0] != 0)
invoke Load_wav,addr FilenaamPlusPad,addr g_pDSWavSample
invoke wsprintf,addr String_buffer,CTEXT(" Name: %s"),addr Filenaam
invoke SetDlgItemText,hWnd,100,addr String_buffer
ret
.endif
.elseif wParam == 103
.if (g_pDSWavSample != 0)
icall g_pDSWavSample,IDirectSoundBuffer8,SetCurrentPosition,0
invoke GetDlgItem,hWnd,105
invoke SendMessage,eax,BM_GETSTATE,0,0
.if (eax == BST_CHECKED)
icall g_pDSWavSample,IDirectSoundBuffer8,Play,0,0,DSBPLAY_LOOPING
ret
.else
icall g_pDSWavSample,IDirectSoundBuffer8,Play,0,0,0
ret
.endif
.endif


.elseif wParam == 104
.if (g_pDSWavSample != 0)
icall g_pDSWavSample,IDirectSoundBuffer8,Stop
ret
.endif
.endif

.elseif uMsg == WM_CLOSE
close: invoke StopDSound
invoke EndDialog,hWnd,0
return 0
.endif
return 0
WndProc endp

start:
invoke GetModuleHandle,NULL
mov hInst,eax
invoke DialogBoxParam,hInst,CTEXT("TESTDLG",0),0,addr WndProc,0
invoke ExitProcess,0
end start


works :)
Posted on 2004-06-17 03:07:48 by Homer
Hello EvilHomer2k

Yes it works OK !!!

I have also included a streaming soundbuffer in my Aspi based
Digital CD-Player. It works perfectly !
I'm not finished yet with this CD-Player because of this DX9 project.

My next idea is to run to the Computer-shop and buy a FORCE-FEEDBACK
game pad and then translating the DirectInput include.

At this moment I'm coding a DX9 "skeleton source" wich will have all
the basic functionalities I need for GAME/DEMO coding such as:

Auto-search for the best Vertexprocessing_type and D3DDevice_type,
Enumerating display modes, flipping between Windowed and Fullscreen mode
or let the User choose from a dialogbox.

So everything will be there even for testing all modes.

BTW, Did anyone tested my DX9 examples or used my D3D9 includes ?

I'm all ears for comments suggestions bugs etc.

Later, Siekmanski
Posted on 2004-06-17 07:35:06 by Siekmanski
I tested your examples, they worked fine.
Don't be discouraged by the lack of interest in your includes, it's early days... besides, if they want to code dx in asm, they have little choice ;)
Posted on 2004-06-17 09:30:28 by Homer
D3D9 includes update !!!!

Removed a bug......

Later Siekmanski.
Posted on 2004-06-17 21:16:11 by Siekmanski